52 lines
2.1 KiB
PowerShell
52 lines
2.1 KiB
PowerShell
$ErrorActionPreference = 'Stop'
|
|
|
|
$root = Split-Path -Parent $PSScriptRoot
|
|
$api = Get-Content -LiteralPath (Join-Path $root 'utils/api.js') -Raw -Encoding UTF8
|
|
$t04 = Get-Content -LiteralPath (Join-Path $root 'pages/tree/t04-add-relative.vue') -Raw -Encoding UTF8
|
|
$t05 = Get-Content -LiteralPath (Join-Path $root 'pages/tree/t05-edit-member.vue') -Raw -Encoding UTF8
|
|
|
|
foreach ($required in @(
|
|
'const normalizeLineageWritePayload = (payload) =>',
|
|
"const lineageRelationPath = Object.freeze({",
|
|
"FATHER: 'parents'",
|
|
"SPOUSE: 'spouses'",
|
|
"SIBLING: 'siblings'",
|
|
"SON: 'children'",
|
|
'async createRelatedPerson(genealogyId, personId, relationType, payload, requestOptions = {})',
|
|
'async updatePerson(genealogyId, personId, payload, requestOptions = {})',
|
|
'method: ''PUT''',
|
|
'requestStrict({'
|
|
)) {
|
|
if (-not $api.Contains($required)) { throw "Lineage Apifox write contract missing: $required" }
|
|
}
|
|
|
|
foreach ($forbidden in @('relationType: relationType.value', 'sex: addForm.gender', 'sortOrder:')) {
|
|
if ($t04.Contains($forbidden)) { throw "T04 must not guess unsupported wire field: $forbidden" }
|
|
}
|
|
|
|
foreach ($required in @(
|
|
'v-model="addForm.aliasName"',
|
|
'v-model="addForm.generationName"',
|
|
'v-model="addForm.birthLunar"',
|
|
'v-model="addForm.birthPlace"',
|
|
'v-model="addForm.deathLunar"',
|
|
'v-model="addForm.deathPlace"',
|
|
'v-model="addForm.burialPlace"',
|
|
'v-model="addForm.biography"',
|
|
'v-model="addForm.remark"',
|
|
'aliasName: addForm.aliasName',
|
|
'generationName: addForm.generationName',
|
|
'biography: addForm.biography',
|
|
'remark: addForm.remark',
|
|
'...(isFirstMember.value ? { generation: 1 } : {})'
|
|
)) {
|
|
if (-not $t04.Contains($required)) { throw "T04 safe optional field missing: $required" }
|
|
}
|
|
|
|
foreach ($required in @('appApi.createRelatedPerson(', 'appApi.createPerson(', 'appApi.updatePerson(', 'failedAction.value = "save"')) {
|
|
$source = if ($required -eq 'appApi.updatePerson(' -or $required -eq 'failedAction.value = "save"') { $t05 } else { $t04 }
|
|
if (-not $source.Contains($required)) { throw "Lineage write page missing: $required" }
|
|
}
|
|
|
|
Write-Output 'LINEAGE-WRITE-APIFOX-CONTRACT PASS'
|