openyida 2026.11.4 → 2026.11.5-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -2
- package/lib/agent/mutation-receipt.js +1 -1
- package/lib/app/app-theme-state.js +2 -1
- package/lib/app/create-form/batch.js +6 -1
- package/lib/app/create-form/default-view.js +50 -0
- package/lib/app/create-form.js +58 -40
- package/lib/app/form-data-contract.js +121 -19
- package/lib/app/form-data-response-guard.js +122 -19
- package/lib/app/form-view.js +123 -15
- package/lib/app/publish.js +32 -6
- package/lib/app/services/form-compiler.js +1 -1
- package/lib/app/subform-readback.js +60 -0
- package/lib/app/update-app.js +1 -1
- package/lib/core/command-manifest.js +32 -16
- package/lib/core/data-seed.js +254 -0
- package/lib/core/locales/en.js +9 -1
- package/lib/core/locales/zh.js +9 -1
- package/lib/core/query-data.js +56 -35
- package/lib/core/utils.js +12 -5
- package/lib/samples/openyida-scaffold/canvas-data-source.jsx +120 -0
- package/package.json +1 -1
- package/yida-skills/SKILL.md +2 -2
- package/yida-skills/skills/yida-app/references/common-issues.md +3 -3
- package/yida-skills/skills/yida-app/workflow/fast-build.md +3 -0
- package/yida-skills/skills/yida-app/workflow/step-4-forms-processes.md +1 -1
- package/yida-skills/skills/yida-app/workflow/step-5-seed-records.md +4 -4
- package/yida-skills/skills/yida-canvas-data-binding/SKILL.md +29 -0
- package/yida-skills/skills/yida-create-app/SKILL.md +1 -1
- package/yida-skills/skills/yida-create-form-page/SKILL.md +5 -3
- package/yida-skills/skills/yida-create-form-page/references/association-form-field.md +3 -0
- package/yida-skills/skills/yida-custom-button/SKILL.md +9 -1
- package/yida-skills/skills/yida-data-management/SKILL.md +82 -111
- package/yida-skills/skills/yida-data-management/references/data-format-guide.md +46 -7
- package/yida-skills/skills/yida-design/references/application-style-library.md +1 -1
- package/yida-skills/skills/yida-form-view/SKILL.md +27 -4
- package/yida-skills/skills-index.json +8 -4
package/README.md
CHANGED
|
@@ -277,11 +277,20 @@ openyida data query form APP_XXX FORM_XXX --page 1 --size 20
|
|
|
277
277
|
openyida data query form APP_XXX FORM_XXX --dynamic-order '{"dateField_xxx":"-"}'
|
|
278
278
|
openyida data query process APP_XXX FORM_XXX --current-approver USER_ID --count
|
|
279
279
|
openyida data create form APP_XXX FORM_XXX --expect-form-name 客户 --expect-form-type receipt --data-file .cache/openyida/data-import/record.json
|
|
280
|
+
openyida data seed form APP_XXX FORM_XXX --expect-form-name 客户 --records-file .cache/openyida/data-import/customers.json --timezone +08:00 --json
|
|
280
281
|
openyida get-permission APP_XXX FORM_XXX
|
|
281
282
|
```
|
|
282
283
|
|
|
283
284
|
`--current-approver` takes an exact userId, not a display name. It scans running instances and their current TODO records, counts each matching instance once, and respects the current login's server-authorized data scope. Omit `--count` to include matching instance data. An incomplete scan or permission failure is reported as an error; the result does not claim application-wide visibility.
|
|
284
285
|
|
|
286
|
+
`data seed form` accepts one JSON array of 1–30 business records using real field IDs (or configured aliases with `--resolve-aliases`). It checks the whole batch against the live schema, then creates and reads back each record, returning `formInstIds`. Use `--check` to preview converted records without writing. `DateField` and date-range endpoints accept millisecond numbers, `YYYY-MM-DD`, or ISO date-times; date-times without an offset use `--timezone` (a fixed UTC offset, default `+08:00`). Subform dates are converted recursively. Invalid dates, reversed ranges and unknown fields/options fail before any write. Business values and real member/department/file/association IDs come from the caller; this command does not invent them or start workflows.
|
|
287
|
+
|
|
288
|
+
Seed supports the 18 writable business components created by default with `create-form`, including associations, subforms, countries, domestic addresses, attachments and images. Serial numbers are server-generated. Addresses support the default domestic `ADDRESS` mode; location/international modes and unknown components follow the CLI's actual diagnostics. Unsupported fields proven optional with no validation are omitted and listed in `skippedFields`, with `requestedFieldsVerified=false`; all-omitted input returns `skipped=true` without creating empty records. Server defaults may still apply. Required or uncertain unsupported fields and invalid supported values fail before writes. Recover pending/unknown writes from the receipt. See [support and recovery](yida-skills/skills/yida-data-management/SKILL.md#组件支持与未适配配置).
|
|
289
|
+
|
|
290
|
+
The input file gets a sibling `.seed-receipt.json`. Rerunning the unchanged command reuses verified records and reads back known pending IDs before continuing. An uncertain write without a trusted ID stops for inspection. Keep the receipt: changing the input, target, identity, schema or omission policy rejects reuse instead of silently creating duplicates. A `.lock` prevents concurrent use of the same receipt; after a process crash, confirm it has stopped and inspect its pending writes before removing the stale lock. Field verification covers submitted values; server-side permissions and business rules still apply.
|
|
291
|
+
|
|
292
|
+
Keep the complete JSON result. After `success=true` and `readbackVerified=true`, match each verified `items[].formInstId` to the input by its zero-based `recordIndex`; `formInstIds` also preserves input order. Create referenced records first, then use those IDs in dependent association values. Avoid `tail/head/grep` on the JSON or list queries whose only purpose is rediscovering returned IDs. Keep the required business spot-check, using `data query form APP_XXX FORM_XXX --inst-id <verified-id> --json`. If output is truncated, read the current command's `receiptFile`; uncertain or cross-session recovery uses the unchanged seed command. Check-only output, pending entries and candidate IDs are not verified association targets. See the [receipt workflow](yida-skills/skills/yida-data-management/SKILL.md#直接消费回执与关联-id).
|
|
293
|
+
|
|
285
294
|
Append and forward permissions are configured in the process definition through `nodes[].actions.normalActions/appendActions`. Both `create-process` and `configure-process` compile these settings into matching designer and runtime properties. See [approval action configuration](yida-skills/skills/yida-flow-node-config/references/actions.md) for the JSON example, defaults, and verification limits.
|
|
286
295
|
|
|
287
296
|
`configure-process` 的流程 JSON 中,审批人可配置为发起人、指定成员、指定角色、部门主管或直属主管,例如:
|
|
@@ -530,7 +539,7 @@ When preparing a PR that needs a personal Fork, or when you ask how to support t
|
|
|
530
539
|
| `openyida list-forms <appType> [--keyword <text>]` | List forms/pages in an app |
|
|
531
540
|
| `openyida aggregate-table <list\|create-empty\|inspect\|preview\|save\|publish\|status> <appType> ...` | Manage aggregate tables (virtualView) |
|
|
532
541
|
| `openyida print-template <list\|inspect\|fields\|build\|create\|copy\|save\|restore\|settings\|status\|order\|render\|files> <appType> <formUuid> [templateId] [--config <file>] [--scene <order\|quotation\|delivery\|receipt\|approval\|codes>] [--bindings <file>] [--name <title>] [--expected-hash <hash>] [--backup <file>] [--out <file>] [--status START\|STOP] [--instance <id>] [--page <n>] [--size <n>] [--allow-permission-change] [--json] \| print-template <list\|render> --detail-url <url> [--template-id <id>] [--json]` | Manage native YiDA print templates, generate document layouts, back up, restore and request PDFs |
|
|
533
|
-
| `openyida form-view <list\|inspect\|save\|create\|order> <appType> <formUuid> [viewUuid] [--config <file>] [--name <title>] [--with-config] [--expected-hash <hash>] [--backup <file>] [--replace] [--json]` | Native form views: list, inspect and configure columns, widths, frozen columns and filters |
|
|
542
|
+
| `openyida form-view <list\|inspect\|save\|create\|order\|rename\|add-button> <appType> <formUuid> [viewUuid] [--config <file>] [--name <title>] [--button <buttonUuid>] [--with-config] [--expected-hash <hash>] [--backup <file>] [--replace] [--json]` | Native form views: list, inspect and configure columns, widths, frozen columns and filters |
|
|
534
543
|
| `openyida custom-button <list\|inspect\|options\|create\|update\|delete> <appType> <formUuid> [buttonUuid] [--config <file>] [--expected-hash <hash>] [--backup <file>] [--yes] [--json]` | Native custom buttons: inspect and configure form edits, automation flows and page links |
|
|
535
544
|
| `openyida form-message <list\|inspect\|options\|create\|update\|delete> <appType> <formUuid> [messageId] [--config <file>] [--expected-hash <hash>] [--backup <file>] [--yes] [--json]` | Native form notifications: inspect triggers, recipients and templates, then safely maintain bindings |
|
|
536
545
|
| `openyida get-schema <appType> <formUuid\|--all> [--summary-json\|--field-map-json\|--analysis-json]` | Get one form Schema or all form Schemas |
|
|
@@ -549,7 +558,7 @@ When preparing a PR that needs a personal Fork, or when you ask how to support t
|
|
|
549
558
|
|
|
550
559
|
| Command | Description |
|
|
551
560
|
|---------|-------------|
|
|
552
|
-
| `openyida data <query\|get\|create\|update\|transfer> <resource> ... \| delete form <appType> <formUuid> --inst-id <id> --expect-form-name <name> --expect-form-type receipt --confirm [--json]` | Unified data management (form/process/task/subform) |
|
|
561
|
+
| `openyida data <query\|get\|create\|update\|transfer\|seed> <resource> ... \| delete form <appType> <formUuid> --inst-id <id> --expect-form-name <name> --expect-form-type receipt --confirm [--json]` | Unified data management (form/process/task/subform) |
|
|
553
562
|
| `openyida task-center <todo\|created\|done\|cc\|proxy\|capabilities\|link\|scaffold\|options\|inspect\|count> [--spec <file.json> --output <file.canvas.jsx>] [options]` | Global task center (todo/processed/cc etc.) |
|
|
554
563
|
| `openyida basic-info <overview\|commodity\|grant\|capacity\|quota\|abs-path\|dataflow\|i18n\|domain>` | Query organization basic info, capacity, quotas, and domain settings |
|
|
555
564
|
| `openyida read-dingtalk-doc <docUrl> [--output <file>] [--json]` | Fetch Markdown content from a DingTalk document |
|
|
@@ -49,7 +49,7 @@ function beginManagedMutationCapture({ command, args, env = process.env, console
|
|
|
49
49
|
return {
|
|
50
50
|
commit() {
|
|
51
51
|
restore();
|
|
52
|
-
if (explicitFailure || !latest) {return null;}
|
|
52
|
+
if (explicitFailure || !latest || latest.mutationPerformed === false) {return null;}
|
|
53
53
|
const isReport = command === 'create-report' || command === 'append-chart';
|
|
54
54
|
const formUuid = resourceId(latest?.formUuid, latest?.pageId,
|
|
55
55
|
isReport ? latest?.reportId : undefined, classification.formUuid);
|
|
@@ -66,7 +66,8 @@ async function fetchCurrentApp(appType, authRef, verifyIdentity = false) {
|
|
|
66
66
|
if (response?.success !== true || !app || typeof app !== 'object' || Array.isArray(app)) {
|
|
67
67
|
themeContextFailure('app_query_failed');
|
|
68
68
|
}
|
|
69
|
-
|
|
69
|
+
// The response corpId identifies the app owner. The auth snapshot tracks the login organization.
|
|
70
|
+
if (app.appType !== appType) {
|
|
70
71
|
themeContextFailure('app_identity_mismatch');
|
|
71
72
|
}
|
|
72
73
|
}
|
|
@@ -331,7 +331,8 @@ async function schedule(forms, concurrency, results, worker, save) {
|
|
|
331
331
|
// A create may persist the form before a later schema/readback stage fails.
|
|
332
332
|
// Retry that known UUID once inside the same authoritative batch so its
|
|
333
333
|
// dependents remain pending and can run after conservative resume.
|
|
334
|
-
if (!hadKnownFormUuid && results[form.key].formUuid && !recoveryAttempted.has(form.key)
|
|
334
|
+
if (!hadKnownFormUuid && results[form.key].formUuid && !recoveryAttempted.has(form.key)
|
|
335
|
+
&& !error.output?.errorCode?.startsWith('CREATE_FORM_DEFAULT_VIEW_')) {
|
|
335
336
|
recoveryAttempted.add(form.key);
|
|
336
337
|
pending.add(form.key);
|
|
337
338
|
}
|
|
@@ -419,6 +420,7 @@ async function run(args, dependencies = {}) {
|
|
|
419
420
|
...(created.url ? { url: created.url } : {}),
|
|
420
421
|
...(created.formUrl ? { formUrl: created.formUrl } : {}),
|
|
421
422
|
...(created.appUrl ? { appUrl: created.appUrl } : {}),
|
|
423
|
+
...(created.defaultView ? { defaultView: created.defaultView } : {}),
|
|
422
424
|
};
|
|
423
425
|
} catch (error) {
|
|
424
426
|
const createdFormUuid = error.output?.formUuid || error.output?.details?.formUuid;
|
|
@@ -426,6 +428,7 @@ async function run(args, dependencies = {}) {
|
|
|
426
428
|
throw error;
|
|
427
429
|
}
|
|
428
430
|
formUuid = createdFormUuid;
|
|
431
|
+
if (error.output?.errorCode?.startsWith('CREATE_FORM_DEFAULT_VIEW_')) { throw error; }
|
|
429
432
|
shouldResume = true;
|
|
430
433
|
}
|
|
431
434
|
}
|
|
@@ -439,6 +442,7 @@ async function run(args, dependencies = {}) {
|
|
|
439
442
|
...(resumeOutput.url ? { url: resumeOutput.url } : {}),
|
|
440
443
|
...(resumeOutput.formUrl ? { formUrl: resumeOutput.formUrl } : {}),
|
|
441
444
|
...(resumeOutput.appUrl ? { appUrl: resumeOutput.appUrl } : {}),
|
|
445
|
+
...(resumeOutput.defaultView ? { defaultView: resumeOutput.defaultView } : {}),
|
|
442
446
|
};
|
|
443
447
|
resumed = true;
|
|
444
448
|
}
|
|
@@ -450,6 +454,7 @@ async function run(args, dependencies = {}) {
|
|
|
450
454
|
...(resumeOutput.url ? { url: resumeOutput.url } : {}),
|
|
451
455
|
...(resumeOutput.formUrl ? { formUrl: resumeOutput.formUrl } : {}),
|
|
452
456
|
...(resumeOutput.appUrl ? { appUrl: resumeOutput.appUrl } : {}),
|
|
457
|
+
...(resumeOutput.defaultView ? { defaultView: resumeOutput.defaultView } : {}),
|
|
453
458
|
};
|
|
454
459
|
resumed = true;
|
|
455
460
|
schema = await call(['get-schema', options.appType, formUuid, '--field-map-json']);
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { createYidaClient } = require('../../core/yida-client');
|
|
4
|
+
const { CliError } = require('../../core/cli-error');
|
|
5
|
+
const { t } = require('../../core/i18n');
|
|
6
|
+
const { execute } = require('../form-view');
|
|
7
|
+
|
|
8
|
+
const TITLE_IDS = ['processInstanceTitle', 'formInstanceTitle'];
|
|
9
|
+
// Same exclusions as the native data-management table (yc-utils).
|
|
10
|
+
const HIDDEN_COMPONENTS = ['TableField', 'EditorField', 'TimeSelectField', 'RichText', 'Link'];
|
|
11
|
+
|
|
12
|
+
async function configureCreatedFormView(authRef, appType, formUuid) {
|
|
13
|
+
const client = createYidaClient({ authRef });
|
|
14
|
+
const target = { appType, formUuid };
|
|
15
|
+
try {
|
|
16
|
+
const listed = await execute({ ...target, action: 'list', flags: {} }, client);
|
|
17
|
+
const view = listed.views.find(item => item.viewType === 'table');
|
|
18
|
+
if (!view) {
|
|
19
|
+
throw new CliError(t('form_view.unsupported'), { code: 'CREATE_FORM_DEFAULT_VIEW_MISSING' });
|
|
20
|
+
}
|
|
21
|
+
const viewTarget = { ...target, viewUuid: view.viewUuid };
|
|
22
|
+
const inspected = await execute({ ...viewTarget, action: 'inspect', flags: {} }, client);
|
|
23
|
+
const { config, fields, configHash } = inspected;
|
|
24
|
+
const configured = config.defaultConfig.showFields;
|
|
25
|
+
const allowed = config.staticConfig.columnFilter;
|
|
26
|
+
const showFields = Array.isArray(configured) && configured.length
|
|
27
|
+
? configured
|
|
28
|
+
: fields.filter(field => field.supportVisible === true && field.showTerm === 'y'
|
|
29
|
+
&& !HIDDEN_COMPONENTS.includes(field.componentName)
|
|
30
|
+
&& (!Array.isArray(allowed) || allowed.includes('all') || allowed.includes(field.id)))
|
|
31
|
+
.sort((a, b) => a.showOrder - b.showOrder).map(field => field.id);
|
|
32
|
+
const titleIds = showFields.filter(id => TITLE_IDS.includes(id));
|
|
33
|
+
const ordered = [...showFields.filter(id => !TITLE_IDS.includes(id)), ...titleIds];
|
|
34
|
+
// A hidden title stays hidden; a one-column view still gets a concrete server default.
|
|
35
|
+
if (!ordered.length) {
|
|
36
|
+
throw new CliError(t('form_view.invalid_config', 'showFields'), { code: 'CREATE_FORM_DEFAULT_VIEW_EMPTY' });
|
|
37
|
+
}
|
|
38
|
+
const saved = await execute({ ...viewTarget, action: 'save', flags: { '--expected-hash': configHash } },
|
|
39
|
+
client, { configPatch: { defaultConfig: { showFields: ordered } } });
|
|
40
|
+
return { viewUuid: view.viewUuid, changed: saved.changed, readbackVerified: saved.readbackVerified,
|
|
41
|
+
showFields: saved.config.defaultConfig.showFields, ...(saved.backupPath ? { backupPath: saved.backupPath } : {}) };
|
|
42
|
+
} catch (error) {
|
|
43
|
+
throw new CliError(error.message, { code: error.code?.startsWith('CREATE_FORM_DEFAULT_VIEW_')
|
|
44
|
+
? error.code : 'CREATE_FORM_DEFAULT_VIEW_FAILED', details: {
|
|
45
|
+
...error.details, ...target, causeCode: error.code, stage: 'configureDefaultView', formCreated: true,
|
|
46
|
+
} });
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
module.exports = { configureCreatedFormView };
|
package/lib/app/create-form.js
CHANGED
|
@@ -83,6 +83,7 @@ const { createParseArgs } = require('./create-form/args');
|
|
|
83
83
|
const { createDefinitionReaders } = require('./create-form/definition-reader');
|
|
84
84
|
const { dispatchCreateFormCommand } = require('./create-form/commands');
|
|
85
85
|
const { buildApiPath } = require('./create-form/api-path');
|
|
86
|
+
const { configureCreatedFormView } = require('./create-form/default-view');
|
|
86
87
|
const {
|
|
87
88
|
FORM_NAV_ICON_GROUPS,
|
|
88
89
|
FORM_NAV_ICONS,
|
|
@@ -1125,7 +1126,7 @@ function buildFieldComponent(field) {
|
|
|
1125
1126
|
|
|
1126
1127
|
// 关联表单核心配置
|
|
1127
1128
|
props.associationForm = {
|
|
1128
|
-
formType: 'receipt',
|
|
1129
|
+
formType: assocConfig.formType || 'receipt',
|
|
1129
1130
|
formUuid: assocConfig.formUuid || '',
|
|
1130
1131
|
appType: assocConfig.appType || '',
|
|
1131
1132
|
appName: assocConfig.appName || '',
|
|
@@ -4317,27 +4318,25 @@ function applySmartValidations(schema, rawRules) {
|
|
|
4317
4318
|
};
|
|
4318
4319
|
}
|
|
4319
4320
|
|
|
4320
|
-
function collectSmartValidationRulesFromFields(fields,
|
|
4321
|
-
const
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
});
|
|
4340
|
-
}
|
|
4321
|
+
function collectSmartValidationRulesFromFields(fields, schema) {
|
|
4322
|
+
const root = schema.pages[0].componentsTree?.[0];
|
|
4323
|
+
const container = root ? findFormContainer(root) : null;
|
|
4324
|
+
const evidence = collectResumeFieldEvidence(container?.children);
|
|
4325
|
+
const rules = [];
|
|
4326
|
+
collectResumeDesiredFields(fields, { verifyNestedFields: true }).forEach(function ({ field, tablePath }) {
|
|
4327
|
+
const identity = desiredResumeFieldIdentity(field);
|
|
4328
|
+
const key = JSON.stringify([...tablePath, identity.label]);
|
|
4329
|
+
const matches = evidence.filter(item => JSON.stringify([...item.tablePath, item.label]) === key);
|
|
4330
|
+
// Inline rules belong to this definition's field, even when another table
|
|
4331
|
+
// uses the same label. Keep ambiguous definitions on the existing error path.
|
|
4332
|
+
const reference = matches.length === 1 && matches[0].componentName === identity.componentName
|
|
4333
|
+
? matches[0].fieldId : field.label;
|
|
4334
|
+
collectInputValidationRules(field, { includeAdvanced: true }).forEach(function (rule) {
|
|
4335
|
+
if (rule.type === 'required' && !field.required && !field.validation && !field.validations) {
|
|
4336
|
+
return;
|
|
4337
|
+
}
|
|
4338
|
+
rules.push(Object.assign({ field: reference }, rule));
|
|
4339
|
+
});
|
|
4341
4340
|
});
|
|
4342
4341
|
return rules;
|
|
4343
4342
|
}
|
|
@@ -5006,6 +5005,7 @@ async function mainCreate(parsedArgs, authRef) {
|
|
|
5006
5005
|
const formUuid = createResult.content.formUuid || createResult.content;
|
|
5007
5006
|
success(t('create_form.blank_created', formUuid));
|
|
5008
5007
|
let postCreateStage = 'getFormSchema';
|
|
5008
|
+
let defaultView;
|
|
5009
5009
|
try {
|
|
5010
5010
|
const shellSchemaResult = await requestWithAutoLogin(function (auth) {
|
|
5011
5011
|
return sendGetRequest(
|
|
@@ -5036,7 +5036,7 @@ async function mainCreate(parsedArgs, authRef) {
|
|
|
5036
5036
|
|
|
5037
5037
|
postCreateStage = 'buildFormSchema';
|
|
5038
5038
|
const schema = buildFormSchema(formTitle, fields, formUuid, corpId, appType, layout, theme, labelAlign);
|
|
5039
|
-
const createValidationRules = collectSmartValidationRulesFromFields(fields).concat(validations || []);
|
|
5039
|
+
const createValidationRules = collectSmartValidationRulesFromFields(fields, schema).concat(validations || []);
|
|
5040
5040
|
if (createValidationRules.length > 0) {
|
|
5041
5041
|
const appliedValidations = applySmartValidations(schema, createValidationRules);
|
|
5042
5042
|
info('已为创建表单写入 ' + appliedValidations.appliedRules.length + ' 条字段校验');
|
|
@@ -5054,6 +5054,8 @@ async function mainCreate(parsedArgs, authRef) {
|
|
|
5054
5054
|
await updateCreatedFormNavigationIcon(authRef, appType, formUuid, formIcon);
|
|
5055
5055
|
postCreateStage = 'verifyFinalSchema';
|
|
5056
5056
|
await verifyCreatedFormSchema(authRef, appType, formUuid, fields);
|
|
5057
|
+
postCreateStage = 'configureDefaultView';
|
|
5058
|
+
defaultView = await configureCreatedFormView(authRef, appType, formUuid);
|
|
5057
5059
|
} catch (err) {
|
|
5058
5060
|
emitCreateFormPostCreateFailure({
|
|
5059
5061
|
appType,
|
|
@@ -5073,7 +5075,7 @@ async function mainCreate(parsedArgs, authRef) {
|
|
|
5073
5075
|
['URL', formUrl],
|
|
5074
5076
|
]);
|
|
5075
5077
|
console.log(JSON.stringify(withBrowserHandoff(
|
|
5076
|
-
{ success: true, formUuid, formTitle, appType, fieldCount, icon: formIcon, iconSource: iconResolution.source, url: formUrl, formUrl, appUrl },
|
|
5078
|
+
{ success: true, formUuid, formTitle, appType, fieldCount, defaultView, icon: formIcon, iconSource: iconResolution.source, url: formUrl, formUrl, appUrl },
|
|
5077
5079
|
formUrl,
|
|
5078
5080
|
{ stage: 'create_form_success', title: formTitle },
|
|
5079
5081
|
parsedArgs.browserOpenMode
|
|
@@ -5154,7 +5156,7 @@ async function createFormForLegacyProcessQuiet(context, input) {
|
|
|
5154
5156
|
const serverRevision = extractSchemaServerRevision(shellSchemaResult);
|
|
5155
5157
|
const corpId = resolveCorpId(authRef.authData || authRef);
|
|
5156
5158
|
const schema = buildFormSchema(formTitle, fields, formUuid, corpId, appType, layout, theme, labelAlign);
|
|
5157
|
-
const createValidationRules = collectSmartValidationRulesFromFields(fields).concat(validations || []);
|
|
5159
|
+
const createValidationRules = collectSmartValidationRulesFromFields(fields, schema).concat(validations || []);
|
|
5158
5160
|
if (createValidationRules.length > 0) {
|
|
5159
5161
|
applySmartValidations(schema, createValidationRules);
|
|
5160
5162
|
}
|
|
@@ -5162,6 +5164,7 @@ async function createFormForLegacyProcessQuiet(context, input) {
|
|
|
5162
5164
|
await verifyCreatedFormSchema(authRef, appType, formUuid, fields);
|
|
5163
5165
|
const navIconResult = await updateCreatedFormNavigationIcon(authRef, appType, formUuid, formIcon);
|
|
5164
5166
|
await verifyCreatedFormSchema(authRef, appType, formUuid, fields);
|
|
5167
|
+
const defaultView = await configureCreatedFormView(authRef, appType, formUuid);
|
|
5165
5168
|
const { appUrl, formUrl } = buildFormDeliveryUrls(authRef.baseUrl, appType, formUuid);
|
|
5166
5169
|
return {
|
|
5167
5170
|
success: true,
|
|
@@ -5172,6 +5175,7 @@ async function createFormForLegacyProcessQuiet(context, input) {
|
|
|
5172
5175
|
createResult,
|
|
5173
5176
|
saveResult,
|
|
5174
5177
|
navIconResult,
|
|
5178
|
+
defaultView,
|
|
5175
5179
|
icon: formIcon,
|
|
5176
5180
|
iconSource: iconResolution.source,
|
|
5177
5181
|
url: formUrl,
|
|
@@ -5984,7 +5988,7 @@ async function mainValidation(parsedArgs, authRef) {
|
|
|
5984
5988
|
|
|
5985
5989
|
// ── update 模式主流程 ─────────────────────────────────
|
|
5986
5990
|
|
|
5987
|
-
function collectResumeFieldEvidence(fields, output) {
|
|
5991
|
+
function collectResumeFieldEvidence(fields, output, tablePath = []) {
|
|
5988
5992
|
const evidence = output || [];
|
|
5989
5993
|
(fields || []).forEach(function (field) {
|
|
5990
5994
|
if (!field || typeof field !== 'object') {
|
|
@@ -5996,10 +6000,12 @@ function collectResumeFieldEvidence(fields, output) {
|
|
|
5996
6000
|
label: labelText,
|
|
5997
6001
|
componentName: field.componentName,
|
|
5998
6002
|
fieldId: field.props && field.props.fieldId ? field.props.fieldId : null,
|
|
6003
|
+
tablePath,
|
|
5999
6004
|
});
|
|
6000
6005
|
}
|
|
6001
6006
|
if (Array.isArray(field.children)) {
|
|
6002
|
-
collectResumeFieldEvidence(field.children.flat(), evidence
|
|
6007
|
+
collectResumeFieldEvidence(field.children.flat(), evidence,
|
|
6008
|
+
field.componentName === 'TableField' ? tablePath.concat(labelText) : tablePath);
|
|
6003
6009
|
}
|
|
6004
6010
|
});
|
|
6005
6011
|
return evidence;
|
|
@@ -6020,9 +6026,9 @@ function collectResumeDesiredFields(fields, options) {
|
|
|
6020
6026
|
const output = [];
|
|
6021
6027
|
const verifyNestedFields = Boolean(options && options.verifyNestedFields);
|
|
6022
6028
|
|
|
6023
|
-
function visit(value) {
|
|
6029
|
+
function visit(value, tablePath) {
|
|
6024
6030
|
if (Array.isArray(value)) {
|
|
6025
|
-
value.forEach(visit);
|
|
6031
|
+
value.forEach(field => visit(field, tablePath));
|
|
6026
6032
|
return;
|
|
6027
6033
|
}
|
|
6028
6034
|
if (!value || typeof value !== 'object') {
|
|
@@ -6030,17 +6036,18 @@ function collectResumeDesiredFields(fields, options) {
|
|
|
6030
6036
|
}
|
|
6031
6037
|
const componentName = normalizeFormDefinitionType(value);
|
|
6032
6038
|
if (isSupportedBusinessFieldType(componentName)) {
|
|
6033
|
-
output.push(value);
|
|
6039
|
+
output.push({ field: value, tablePath });
|
|
6034
6040
|
if (!verifyNestedFields) {
|
|
6035
6041
|
return;
|
|
6036
6042
|
}
|
|
6037
6043
|
}
|
|
6038
6044
|
if (Array.isArray(value.children)) {
|
|
6039
|
-
value.children
|
|
6045
|
+
visit(value.children, componentName === 'TableField'
|
|
6046
|
+
? tablePath.concat(desiredResumeFieldIdentity(value).label) : tablePath);
|
|
6040
6047
|
}
|
|
6041
6048
|
}
|
|
6042
6049
|
|
|
6043
|
-
visit(fields);
|
|
6050
|
+
visit(fields, []);
|
|
6044
6051
|
return output;
|
|
6045
6052
|
}
|
|
6046
6053
|
|
|
@@ -6068,28 +6075,34 @@ function isRecoverableBlankResumeSchema(schema) {
|
|
|
6068
6075
|
}
|
|
6069
6076
|
|
|
6070
6077
|
function buildResumeChanges(existingFields, desiredFields) {
|
|
6071
|
-
|
|
6078
|
+
// Layout containers do not change identity. A table creates a new namespace;
|
|
6079
|
+
// JSON tuples preserve punctuation in labels without path collisions.
|
|
6080
|
+
const scopedKey = (tablePath, label) => JSON.stringify([...tablePath, label]);
|
|
6081
|
+
const existingByScope = new Map();
|
|
6072
6082
|
existingFields.forEach(function (field) {
|
|
6073
|
-
const
|
|
6083
|
+
const key = scopedKey(field.tablePath, field.label);
|
|
6084
|
+
const bucket = existingByScope.get(key) || [];
|
|
6074
6085
|
bucket.push(field);
|
|
6075
|
-
|
|
6086
|
+
existingByScope.set(key, bucket);
|
|
6076
6087
|
});
|
|
6077
6088
|
|
|
6078
6089
|
const desiredLabels = new Set();
|
|
6079
6090
|
const missing = [];
|
|
6080
6091
|
const existing = [];
|
|
6081
6092
|
const conflicts = [];
|
|
6082
|
-
desiredFields.forEach(function (field) {
|
|
6093
|
+
desiredFields.forEach(function ({ field, tablePath }) {
|
|
6083
6094
|
const identity = desiredResumeFieldIdentity(field);
|
|
6084
|
-
|
|
6095
|
+
const key = scopedKey(tablePath, identity.label);
|
|
6096
|
+
if (!identity.label || desiredLabels.has(key)) {
|
|
6085
6097
|
conflicts.push({
|
|
6086
6098
|
code: identity.label ? 'CREATE_FORM_RESUME_DUPLICATE_DESIRED_FIELD' : 'CREATE_FORM_RESUME_FIELD_LABEL_REQUIRED',
|
|
6087
6099
|
label: identity.label || null,
|
|
6100
|
+
tablePath,
|
|
6088
6101
|
});
|
|
6089
6102
|
return;
|
|
6090
6103
|
}
|
|
6091
|
-
desiredLabels.add(
|
|
6092
|
-
const matches =
|
|
6104
|
+
desiredLabels.add(key);
|
|
6105
|
+
const matches = existingByScope.get(key) || [];
|
|
6093
6106
|
if (matches.length === 0) {
|
|
6094
6107
|
missing.push(field);
|
|
6095
6108
|
return;
|
|
@@ -6098,6 +6111,7 @@ function buildResumeChanges(existingFields, desiredFields) {
|
|
|
6098
6111
|
conflicts.push({
|
|
6099
6112
|
code: 'CREATE_FORM_RESUME_FIELD_CONFLICT',
|
|
6100
6113
|
label: identity.label,
|
|
6114
|
+
tablePath,
|
|
6101
6115
|
requestedType: identity.componentName,
|
|
6102
6116
|
observedTypes: matches.map(function (item) { return item.componentName; }),
|
|
6103
6117
|
});
|
|
@@ -6107,6 +6121,7 @@ function buildResumeChanges(existingFields, desiredFields) {
|
|
|
6107
6121
|
label: identity.label,
|
|
6108
6122
|
componentName: identity.componentName,
|
|
6109
6123
|
fieldId: matches[0].fieldId,
|
|
6124
|
+
tablePath,
|
|
6110
6125
|
});
|
|
6111
6126
|
});
|
|
6112
6127
|
return { missing, existing, conflicts };
|
|
@@ -6258,7 +6273,7 @@ async function mainResume(parsedArgs, authRef) {
|
|
|
6258
6273
|
const corpId = resolveCorpId(authRef.authData);
|
|
6259
6274
|
const formTitle = firstRead.schemaResult.formTitle || firstRead.schemaResult.title || formUuid;
|
|
6260
6275
|
firstRead.schema = buildFormSchema(formTitle, fields, formUuid, corpId, appType, 'single', 'default', 'top');
|
|
6261
|
-
const resumeValidationRules = collectSmartValidationRulesFromFields(fields).concat(validations || []);
|
|
6276
|
+
const resumeValidationRules = collectSmartValidationRulesFromFields(fields, firstRead.schema).concat(validations || []);
|
|
6262
6277
|
if (resumeValidationRules.length > 0) {
|
|
6263
6278
|
applySmartValidations(firstRead.schema, resumeValidationRules);
|
|
6264
6279
|
}
|
|
@@ -6340,6 +6355,8 @@ async function mainResume(parsedArgs, authRef) {
|
|
|
6340
6355
|
});
|
|
6341
6356
|
}
|
|
6342
6357
|
completedStages.push('verify_final_schema');
|
|
6358
|
+
const defaultView = await configureCreatedFormView(authRef, appType, formUuid);
|
|
6359
|
+
completedStages.push('configure_default_view');
|
|
6343
6360
|
const { appUrl, formUrl } = buildFormDeliveryUrls(authRef.baseUrl, appType, formUuid);
|
|
6344
6361
|
const output = {
|
|
6345
6362
|
success: true,
|
|
@@ -6351,6 +6368,7 @@ async function mainResume(parsedArgs, authRef) {
|
|
|
6351
6368
|
addedFieldCount: plan.missing.length,
|
|
6352
6369
|
finalFieldCount: collectResumeFieldEvidence(finalContainer.children).length,
|
|
6353
6370
|
recoveredBlankShell,
|
|
6371
|
+
defaultView,
|
|
6354
6372
|
url: formUrl,
|
|
6355
6373
|
formUrl,
|
|
6356
6374
|
appUrl,
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const { normalizeSchemaFields, createSchemaHash } = require('./schema-field-resolution');
|
|
4
4
|
const { CliError } = require('../core/cli-error');
|
|
5
5
|
const { t } = require('../core/i18n');
|
|
6
|
+
const { readCanvasSubformRows } = require('./subform-readback');
|
|
6
7
|
|
|
7
8
|
const own = (object, key) => Object.prototype.hasOwnProperty.call(object, key);
|
|
8
9
|
const object = value => value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
@@ -12,6 +13,15 @@ const sets = new Set(['CheckboxField', 'MultiSelectField', 'EmployeeField', 'Dep
|
|
|
12
13
|
const files = new Set(['ImageField', 'AttachmentField']);
|
|
13
14
|
const numericText = value => typeof value === 'string' && /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i.test(value.trim());
|
|
14
15
|
|
|
16
|
+
function supportsWriteComponent(type, props = {}) {
|
|
17
|
+
if (type === 'AddressField') {
|
|
18
|
+
return (props.addressType === undefined || props.addressType === 'ADDRESS')
|
|
19
|
+
&& (props.countryMode === undefined || props.countryMode === 'default');
|
|
20
|
+
}
|
|
21
|
+
return strings.has(type) || numbers.has(type) || sets.has(type) || files.has(type)
|
|
22
|
+
|| ['TableField', 'CitySelectField', 'CascadeDateField', 'AssociationFormField', 'CountrySelectField'].includes(type);
|
|
23
|
+
}
|
|
24
|
+
|
|
15
25
|
function buildWriteContract(schema) {
|
|
16
26
|
const fields = normalizeSchemaFields(schema);
|
|
17
27
|
const props = Object.create(null);
|
|
@@ -29,7 +39,7 @@ function buildWriteContract(schema) {
|
|
|
29
39
|
function arrayValue(value, reading) {
|
|
30
40
|
if (reading) {
|
|
31
41
|
// Association projections can contain two JSON string envelopes.
|
|
32
|
-
for (let i = 0; i < 2 && typeof value === 'string'; i++) {
|
|
42
|
+
for (let i = 0; i < 2 && typeof value === 'string' && value !== ''; i++) {
|
|
33
43
|
try {value = JSON.parse(value);} catch {return null;}
|
|
34
44
|
}
|
|
35
45
|
}
|
|
@@ -37,12 +47,41 @@ function arrayValue(value, reading) {
|
|
|
37
47
|
return Array.isArray(value) ? value : null;
|
|
38
48
|
}
|
|
39
49
|
|
|
40
|
-
|
|
50
|
+
// Writes use native arrays; read projections may omit target metadata, but must
|
|
51
|
+
// never contradict it when it is present. Shared by verified and legacy writes.
|
|
52
|
+
function associationValueIssue(value, props = {}, reading = false) {
|
|
53
|
+
if (!Array.isArray(value)) {return { reason: 'value_must_be_array', index: null };}
|
|
54
|
+
if (props.multiple === false && value.length > 1) {return { reason: 'single_selection_required', index: null };}
|
|
55
|
+
const seen = new Set();
|
|
56
|
+
const keys = reading ? ['instanceId'] : ['appType', 'formUuid', 'formType', 'instanceId', 'title'];
|
|
57
|
+
for (let index = 0; index < value.length; index++) {
|
|
58
|
+
const item = value[index];
|
|
59
|
+
if (!object(item)) {return { reason: 'item_must_be_object', index };}
|
|
60
|
+
const missingFields = keys.filter(key => typeof item[key] !== 'string' || !item[key].trim());
|
|
61
|
+
if (missingFields.length) {return { reason: 'required_fields_missing', index, missingFields };}
|
|
62
|
+
for (const key of ['appType', 'formUuid', 'formType']) {
|
|
63
|
+
if (own(item, key) && (typeof item[key] !== 'string' || !item[key].trim())) {
|
|
64
|
+
return { reason: 'invalid_target_metadata', index };
|
|
65
|
+
}
|
|
66
|
+
const target = props.associationForm?.[key];
|
|
67
|
+
if (typeof target === 'string' && target.trim() && own(item, key) && item[key] !== target) {
|
|
68
|
+
return { reason: 'association_target_mismatch', index };
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (!reading && item.subTitle !== undefined && typeof item.subTitle !== 'string') {
|
|
72
|
+
return { reason: 'subtitle_must_be_string', index };
|
|
73
|
+
}
|
|
74
|
+
if (seen.has(item.instanceId)) {return { reason: 'duplicate_selection', index };}
|
|
75
|
+
seen.add(item.instanceId);
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function canonical(field, value, reading = false, props = {}) {
|
|
41
81
|
const type = field.componentType;
|
|
42
|
-
const supported =
|
|
43
|
-
|| ['CitySelectField', 'CascadeDateField', 'AssociationFormField'].includes(type);
|
|
82
|
+
const supported = supportsWriteComponent(type, props);
|
|
44
83
|
if (!supported) {return { ok: false, reason: 'UNSUPPORTED_COMPONENT' };}
|
|
45
|
-
if (value === null || reading && value === '') {
|
|
84
|
+
if ((value === null && (type !== 'AssociationFormField' || reading)) || reading && value === '') {
|
|
46
85
|
return { ok: true, value: strings.has(type) || numbers.has(type) ? null : [] };
|
|
47
86
|
}
|
|
48
87
|
if (strings.has(type)) {
|
|
@@ -52,8 +91,33 @@ function canonical(field, value, reading = false) {
|
|
|
52
91
|
const number = reading && numericText(value) ? Number(value) : value;
|
|
53
92
|
return typeof number === 'number' && Number.isFinite(number) ? { ok: true, value: number } : { ok: false };
|
|
54
93
|
}
|
|
94
|
+
if (type === 'AddressField') {
|
|
95
|
+
if (reading) {
|
|
96
|
+
for (let depth = 0; depth < 2 && typeof value === 'string'; depth++) {
|
|
97
|
+
try {value = JSON.parse(value);} catch {return { ok: false };}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (!object(value) || !Array.isArray(value.regionIds) || value.regionIds.length < 1 || value.regionIds.length > 4
|
|
101
|
+
|| !value.regionIds.every(id => typeof id === 'number' && Number.isSafeInteger(id) && id > 0
|
|
102
|
+
|| typeof id === 'string' && /^[1-9]\d*$/.test(id))
|
|
103
|
+
|| typeof value.address !== 'string' || !Array.isArray(value.regionText)
|
|
104
|
+
|| value.regionText.length !== value.regionIds.length
|
|
105
|
+
|| !value.regionText.every(text => object(text) && Object.entries(text).some(([key, label]) => key !== 'type' && typeof label === 'string' && label.trim()))) {
|
|
106
|
+
return { ok: false };
|
|
107
|
+
}
|
|
108
|
+
return { ok: true, value: { regionIds: value.regionIds.map(String), address: value.address } };
|
|
109
|
+
}
|
|
55
110
|
const list = arrayValue(value, reading);
|
|
56
111
|
if (!list) {return { ok: false };}
|
|
112
|
+
if (type === 'CountrySelectField') {
|
|
113
|
+
if (props.multiple !== true && list.length > 1) {return { ok: false, reason: 'SINGLE_SELECTION_REQUIRED' };}
|
|
114
|
+
const ids = list.map(item => reading && typeof item === 'string' ? item
|
|
115
|
+
: object(item) && (reading || object(item.text) && Object.entries(item.text)
|
|
116
|
+
.some(([key, label]) => key !== 'type' && typeof label === 'string' && label.trim())) ? item.value : null);
|
|
117
|
+
if (!ids.every(id => typeof id === 'string' && /^[A-Z]{2}$/.test(id))) {return { ok: false };}
|
|
118
|
+
if (new Set(ids).size !== ids.length) {return { ok: false, reason: 'DUPLICATE_SELECTION' };}
|
|
119
|
+
return { ok: true, value: ids.slice().sort() };
|
|
120
|
+
}
|
|
57
121
|
if (sets.has(type) || type === 'CitySelectField') {
|
|
58
122
|
if (!list.every(item => typeof item === 'string' && item.length > 0
|
|
59
123
|
|| ['DepartmentSelectField', 'CitySelectField'].includes(type) && typeof item === 'number' && Number.isFinite(item))) {
|
|
@@ -69,9 +133,9 @@ function canonical(field, value, reading = false) {
|
|
|
69
133
|
? { ok: true, value: endpoints } : { ok: false };
|
|
70
134
|
}
|
|
71
135
|
if (type === 'AssociationFormField') {
|
|
72
|
-
const
|
|
73
|
-
return
|
|
74
|
-
|
|
136
|
+
const issue = associationValueIssue(list, props, reading);
|
|
137
|
+
return issue ? { ok: false, reason: issue.reason.toUpperCase() }
|
|
138
|
+
: { ok: true, value: list.map(item => item.instanceId).sort() };
|
|
75
139
|
}
|
|
76
140
|
const identities = list.map(item => object(item)
|
|
77
141
|
? item.fileId || item.id || item.downloadUrl || item.url : null);
|
|
@@ -103,7 +167,7 @@ function prepareWriteData(data, contract, resolveAliases = false) {
|
|
|
103
167
|
output[field.fieldId] = value.map((row, index) => compile(row, field.fieldId, `${location}[${index}]`));
|
|
104
168
|
continue;
|
|
105
169
|
}
|
|
106
|
-
const normalized = canonical(field, value);
|
|
170
|
+
const normalized = canonical(field, value, false, contract.props[field.fieldId]);
|
|
107
171
|
if (!normalized.ok) {
|
|
108
172
|
issues.push({ path: location, fieldId: field.fieldId, componentType: field.componentType,
|
|
109
173
|
code: normalized.reason || 'INVALID_VALUE_TYPE' });
|
|
@@ -133,30 +197,68 @@ function prepareWriteData(data, contract, resolveAliases = false) {
|
|
|
133
197
|
return compiled;
|
|
134
198
|
}
|
|
135
199
|
|
|
136
|
-
function compareWriteData(expected, actual, contract) {
|
|
200
|
+
function compareWriteData(expected, actual, contract, instValue) {
|
|
137
201
|
const issues = [];
|
|
138
|
-
const compare = (wanted, observed, parent = null, prefix = '$') => {
|
|
202
|
+
const compare = (wanted, observed, parent = null, prefix = '$', rawEntries) => {
|
|
139
203
|
if (!object(observed)) {issues.push({ path: prefix, code: 'READBACK_DATA_UNAVAILABLE' }); return;}
|
|
140
204
|
for (const [id, value] of Object.entries(wanted)) {
|
|
141
205
|
const location = `${prefix}[${JSON.stringify(id)}]`;
|
|
142
206
|
const field = contract.fields.find(item => item.fieldId === id && item.parentFieldId === parent);
|
|
143
207
|
if (!field) {issues.push({ path: location, code: 'SCHEMA_FIELD_UNAVAILABLE' }); continue;}
|
|
144
|
-
|
|
145
|
-
|
|
208
|
+
// Member/department base projections contain display names; their _id
|
|
209
|
+
// projections carry identity. Association base values retain priority.
|
|
210
|
+
const identityProjection = ['EmployeeField', 'DepartmentSelectField', 'CountrySelectField'].includes(field.componentType)
|
|
211
|
+
&& own(observed, `${id}_id`);
|
|
212
|
+
const key = identityProjection || !own(observed, id) && field.componentType === 'AssociationFormField' ? `${id}_id` : id;
|
|
213
|
+
let found = own(observed, key), readValue = observed[key];
|
|
214
|
+
const emptyCollection = (sets.has(field.componentType) || files.has(field.componentType) || field.componentType === 'CountrySelectField')
|
|
215
|
+
&& Array.isArray(value) && value.length === 0;
|
|
216
|
+
if (!found && (field.componentType === 'AssociationFormField' || emptyCollection)) {
|
|
217
|
+
let entries = rawEntries;
|
|
218
|
+
if (typeof entries === 'string') {try {entries = JSON.parse(entries);} catch {entries = null;}}
|
|
219
|
+
const matches = Array.isArray(entries) ? entries.filter(entry => object(entry) && entry.fieldId === id) : [];
|
|
220
|
+
if (matches.length === 1 && (matches[0].componentName === undefined || matches[0].componentName === 'AssociationFormField')
|
|
221
|
+
&& field.componentType === 'AssociationFormField' && object(matches[0].fieldData) && own(matches[0].fieldData, 'value')) {
|
|
222
|
+
found = true; readValue = matches[0].fieldData.value;
|
|
223
|
+
}
|
|
224
|
+
const cell = matches.length === 1 ? matches[0] : null;
|
|
225
|
+
if (emptyCollection && cell?.componentName === field.componentType && object(cell.fieldData)
|
|
226
|
+
&& (parent === null ? !cell.rowId : typeof cell.rowId === 'string' && cell.rowId.trim())
|
|
227
|
+
&& !['HIDDEN', 'INVISIBLE'].includes(contract.props[id]?.behavior)
|
|
228
|
+
&& !['HIDDEN', 'INVISIBLE'].includes(contract.props[parent]?.behavior)
|
|
229
|
+
&& !['_id', '_value', '_all'].some(suffix => own(observed, id + suffix))) {
|
|
230
|
+
// This API retains the stored typed cell while null collection values
|
|
231
|
+
// serialize as fieldData={}. Its hidden-field filter removes cells or
|
|
232
|
+
// the whole raw snapshot. Row correspondence was checked above.
|
|
233
|
+
if (own(cell.fieldData, 'value')) { found = true; readValue = cell.fieldData.value; }
|
|
234
|
+
else if (Object.keys(cell.fieldData).length === 0) { found = true; readValue = []; }
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
if (!found) {issues.push({ path: location, fieldId: id, code: 'READBACK_FIELD_MISSING' }); continue;}
|
|
146
238
|
if (field.componentType === 'TableField') {
|
|
147
|
-
const
|
|
239
|
+
const result = readCanvasSubformRows({ formData: observed, instValue: rawEntries }, id);
|
|
240
|
+
const rows = result.status === 'error' ? null : result.rows;
|
|
148
241
|
if (!rows || rows.length !== value.length) {issues.push({ path: location, fieldId: id, code: 'READBACK_ROW_COUNT_MISMATCH' }); continue;}
|
|
149
|
-
value.forEach((row, index) => compare(row, rows[index], id, `${location}[${index}]
|
|
242
|
+
value.forEach((row, index) => compare(row, rows[index], id, `${location}[${index}]`, rows[index].instValue));
|
|
150
243
|
continue;
|
|
151
244
|
}
|
|
152
|
-
const
|
|
153
|
-
|
|
245
|
+
const props = contract.props[id];
|
|
246
|
+
const before = canonical(field, value, false, props), after = canonical(field, readValue, true, props);
|
|
247
|
+
let targetMismatch = false;
|
|
248
|
+
if (field.componentType === 'AssociationFormField' && before.ok && after.ok) {
|
|
249
|
+
const submitted = new Map(value.map(item => [item.instanceId, item]));
|
|
250
|
+
targetMismatch = (arrayValue(readValue, true) || []).some(item => {
|
|
251
|
+
const expected = submitted.get(item.instanceId);
|
|
252
|
+
return expected && ['appType', 'formUuid', 'formType'].some(k => own(item, k) && item[k] !== expected[k]);
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
if (!before.ok || !after.ok || targetMismatch || JSON.stringify(before.value) !== JSON.stringify(after.value)) {
|
|
154
256
|
issues.push({ path: location, fieldId: id, code: 'READBACK_VALUE_MISMATCH' });
|
|
155
257
|
}
|
|
156
258
|
}
|
|
157
259
|
};
|
|
158
|
-
compare(expected, actual);
|
|
260
|
+
compare(expected, actual, null, '$', instValue);
|
|
159
261
|
return issues;
|
|
160
262
|
}
|
|
161
263
|
|
|
162
|
-
module.exports = { buildWriteContract, prepareWriteData, compareWriteData };
|
|
264
|
+
module.exports = { buildWriteContract, prepareWriteData, compareWriteData, associationValueIssue, supportsWriteComponent };
|