openyida 2026.11.3 → 2026.11.4-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 +12 -7
- package/bin/yida.js +0 -25
- package/lib/agent/mutation-receipt.js +1 -1
- package/lib/app/application-style.js +2 -3
- package/lib/app/create-form.js +48 -39
- package/lib/app/fast-theme.js +9 -5
- package/lib/app/form-data-contract.js +121 -19
- package/lib/app/form-data-response-guard.js +122 -19
- 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/theme-source.js +2 -7
- package/lib/core/chalk.js +2 -1
- package/lib/core/command-manifest.js +25 -77
- package/lib/core/data-seed.js +254 -0
- package/lib/core/env-cmd.js +0 -1
- package/lib/core/locales/en.js +8 -8
- package/lib/core/locales/zh.js +8 -8
- package/lib/core/permission-guidance.js +25 -9
- package/lib/core/query-data.js +56 -35
- package/lib/core/update.js +1 -1
- package/lib/core/utils.js +12 -5
- package/lib/design/document.js +5 -0
- package/lib/design-plan/themes.js +30 -1
- package/lib/samples/openyida-scaffold/canvas-data-source.jsx +120 -0
- package/package.json +1 -1
- package/scripts/postinstall.js +35 -26
- package/yida-skills/SKILL.md +5 -3
- package/yida-skills/references/setup-and-env.md +6 -0
- package/yida-skills/references/yida-api.md +4 -4
- package/yida-skills/skills/yida-app/SKILL.md +8 -2
- package/yida-skills/skills/yida-app/references/common-issues.md +3 -3
- package/yida-skills/skills/yida-app/references/entry-navigation.md +1 -1
- package/yida-skills/skills/yida-app/workflow/fast-build.md +8 -3
- package/yida-skills/skills/yida-app/workflow/plan/step-4-deliver.md +1 -1
- package/yida-skills/skills/yida-app/workflow/step-1-resource-context.md +6 -5
- package/yida-skills/skills/yida-app/workflow/step-2-design.md +3 -3
- package/yida-skills/skills/yida-app/workflow/step-3-create-or-reuse-app.md +1 -1
- package/yida-skills/skills/yida-app/workflow/step-5-seed-records.md +4 -4
- package/yida-skills/skills/yida-app/workflow/step-8-publish-navigation.md +7 -5
- package/yida-skills/skills/yida-app/workflow/step-9-output-finish.md +4 -4
- package/yida-skills/skills/yida-canvas-custom-page/references/navigation-and-entry-guide.md +1 -1
- package/yida-skills/skills/yida-canvas-data-binding/SKILL.md +29 -0
- package/yida-skills/skills/yida-cool-card/references/configuration.md +1 -1
- package/yida-skills/skills/yida-create-app/SKILL.md +7 -7
- package/yida-skills/skills/yida-create-form-page/SKILL.md +4 -3
- package/yida-skills/skills/yida-create-form-page/references/association-form-field.md +3 -0
- package/yida-skills/skills/yida-create-form-page/references/form-field-properties.md +1 -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/SKILL.md +14 -14
- package/yida-skills/skills/yida-design/references/application-style-library.md +5 -3
- package/yida-skills/skills/yida-design/references/application-theme-consistency.md +7 -7
- package/yida-skills/skills/yida-design/references/design-mode.md +5 -2
- package/yida-skills/skills/yida-design/references/fast-design-spec.md +1 -1
- package/yida-skills/skills/yida-design/references/native-form-styles.md +4 -4
- package/yida-skills/skills/yida-design/references/page-quality-gates.md +2 -2
- package/yida-skills/skills/yida-design/references/reference-visual-dna.md +2 -2
- package/yida-skills/skills/yida-design/references/responsive-layout.md +1 -1
- package/yida-skills/skills/yida-design/references/theme-selection.md +11 -3
- package/yida-skills/skills/yida-design/sub_skill/yida-design-plan/SKILL.md +1 -1
- package/yida-skills/skills/yida-design/sub_skill/yida-design-plan/references/build-plan-compact-schema.md +1 -1
- package/yida-skills/skills/yida-design/workflow/output-design.md +13 -13
- package/yida-skills/skills/yida-design/workflow/step-1-read-brief.md +3 -3
- package/yida-skills/skills/yida-design/workflow/step-5-visual-states.md +1 -1
- package/yida-skills/skills/yida-design/workflow/step-6-handoff.md +3 -3
- package/yida-skills/skills/yida-image-assets/references/manifest-contract.md +6 -3
- package/yida-skills/skills/yida-login/SKILL.md +2 -0
- package/yida-skills/skills/yida-nav-group/SKILL.md +9 -1
- package/yida-skills/skills/yida-prd/SKILL.md +3 -3
- package/yida-skills/skills/yida-requirement-analysis/references/handoff.md +3 -1
- package/yida-skills/skills/yida-requirement-analysis/workflow/prepare-brief.md +3 -3
- package/yida-skills/skills-index.json +7 -8
- package/lib/a2a/cmd.js +0 -98
- package/lib/a2a/server.js +0 -370
- package/lib/bridge/bridge.js +0 -1292
- package/lib/dws/dws-wrapper.js +0 -230
- package/lib/mcp/server.js +0 -274
package/README.md
CHANGED
|
@@ -105,7 +105,7 @@ npm install -g dingtalk-workspace-cli
|
|
|
105
105
|
dws version
|
|
106
106
|
```
|
|
107
107
|
|
|
108
|
-
|
|
108
|
+
Run the installed `dws <command> [args]` directly. Check `dws --help` and the relevant subcommand's help for supported options.
|
|
109
109
|
|
|
110
110
|
OpenYida does not bundle or automatically install dws. Dws manages its own version, updates and login. Use `dws auth login` for DingTalk business access and verify the target organization and account. Native YiDA cool-card creation, reads and editor links work without dws; updating a chat card through dws does not save a YiDA template. See the official instructions for other installation methods and check the installed command's `--help` before use.
|
|
111
111
|
|
|
@@ -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 中,审批人可配置为发起人、指定成员、指定角色、部门主管或直属主管,例如:
|
|
@@ -534,7 +543,7 @@ When preparing a PR that needs a personal Fork, or when you ask how to support t
|
|
|
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 |
|
|
537
|
-
| `openyida check-prd-completeness
|
|
546
|
+
| `openyida check-prd-completeness (<prd.md> [--build-manifest <file>] \| --build-spec <build-context.json> [--build-manifest <file>] \| --manifest-only --build-manifest <file>) --app-type <appType> [--json]` | Check resources, frontend menu hiding and application theme delivery |
|
|
538
547
|
| `openyida check-design <design.md> [--prd <prd.md>] [--base-dir <dir>] [--json]` | Validate design documents, theme tokens and PRD handoff |
|
|
539
548
|
| `openyida er <appType> [--format mermaid\|json] [--output file] [--include-system] [--include-pages]` | Export app entity relationship diagram |
|
|
540
549
|
| `openyida create-page <appType> "<name>" [--mode dashboard] [--hide-nav] [--locale zh_CN\|en_US\|ja_JP] [--open\|--no-open]` | Create a custom display page |
|
|
@@ -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 |
|
|
@@ -624,8 +633,6 @@ When preparing a PR that needs a personal Fork, or when you ask how to support t
|
|
|
624
633
|
| `openyida integration check <appType...>` | Check abnormal integration automation run logs |
|
|
625
634
|
| `openyida integration detail-log <appType> <procInstId> [--json] [--include-params]` | View integration automation run log details |
|
|
626
635
|
| `openyida integration diagnose (--text <text>\|--file <path>\|--rules) [--json]` | Diagnose integration automation tickets and common pitfalls |
|
|
627
|
-
| `openyida dws <command> [args]` | DingTalk CLI (contacts/calendar/todo/approval etc.) |
|
|
628
|
-
| `openyida dws contact user search --keyword <text>` | DingTalk CLI (contacts/calendar/todo/approval etc.) |
|
|
629
636
|
| `openyida dingtalk-link <url> [--target fullScreen] [--legacy-scheme] [--json]` | Generate DingTalk AppLink / legacy dingtalk:// page links |
|
|
630
637
|
|
|
631
638
|
### Utility
|
|
@@ -635,8 +642,6 @@ When preparing a PR that needs a personal Fork, or when you ask how to support t
|
|
|
635
642
|
| `openyida commands [--json]` | Output machine-readable command manifest |
|
|
636
643
|
| `openyida agent-capabilities [--json] [--summary-json\|--compact]` | Output one-shot agent capability snapshot |
|
|
637
644
|
| `openyida agent <doctor\|diagnose\|status\|connect\|run\|disconnect\|logout\|logs> [options]` | Connect a local Agent (Go runtime, development preview) |
|
|
638
|
-
| `openyida a2a <serve\|agent-card> [options]` | Start local read-only A2A adapter or print Agent Card |
|
|
639
|
-
| `openyida bridge start [--token <pair-token>] [--port 6736] [--origin https://demo.aliwork.com] [--open\|--no-open]` | Start OpenYida local web bridge service |
|
|
640
645
|
| `openyida copy [--force]` | Copy project working directory |
|
|
641
646
|
| `openyida sample [--list] [<skill> <name>] [--output <file-or-directory>] [--var KEY=VALUE ...] [--design-file <design.md>] [--spec-file <spec.json>] [--primary-color <color>] [--tokens-file <theme.json>] [--nav-theme light\|dark] [--check] [--style-id <themeId\|free-creative>] [--theme-ids <id,...>] [--pop-art-context <explicit-request\|showcase>]` | Output code samples/templates |
|
|
642
647
|
| `openyida doctor [--fix]` | Environment diagnostics & auto-fix |
|
package/bin/yida.js
CHANGED
|
@@ -86,7 +86,6 @@ function printHelp() {
|
|
|
86
86
|
console.log(` ${DIM}${RESET} openyida login`);
|
|
87
87
|
console.log(` ${DIM}${RESET} openyida create-app "${t('help.quickstart_app_name')}"`);
|
|
88
88
|
console.log(` ${DIM}${RESET} openyida create-form create APP_XXX "${t('help.quickstart_form_name')}" .cache/openyida/forms/fields.json`);
|
|
89
|
-
console.log(` ${DIM}${RESET} openyida dws contact user search --keyword "张三"`);
|
|
90
89
|
console.log('');
|
|
91
90
|
console.log(` ${DIM}${t('help.docs')} https://demo.aliwork.com/o/openyida/helpCenter · https://github.com/openyida/openyida${RESET}`);
|
|
92
91
|
console.log('');
|
|
@@ -667,24 +666,6 @@ async function main() {
|
|
|
667
666
|
break;
|
|
668
667
|
}
|
|
669
668
|
|
|
670
|
-
case 'mcp': {
|
|
671
|
-
const { runStdioServer } = require('../lib/mcp/server');
|
|
672
|
-
runStdioServer();
|
|
673
|
-
break;
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
case 'a2a': {
|
|
677
|
-
const { run } = require('../lib/a2a/cmd');
|
|
678
|
-
await run(args);
|
|
679
|
-
break;
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
case 'bridge': {
|
|
683
|
-
const { run } = require('../lib/bridge/bridge');
|
|
684
|
-
await run(args);
|
|
685
|
-
break;
|
|
686
|
-
}
|
|
687
|
-
|
|
688
669
|
case 'env': {
|
|
689
670
|
if (shouldUseEnvManagement(args)) {
|
|
690
671
|
const { run } = require('../lib/core/env-cmd');
|
|
@@ -1346,12 +1327,6 @@ async function main() {
|
|
|
1346
1327
|
break;
|
|
1347
1328
|
}
|
|
1348
1329
|
|
|
1349
|
-
case 'dws': {
|
|
1350
|
-
const { run: runDws } = require('../lib/dws/dws-wrapper');
|
|
1351
|
-
await runDws(args);
|
|
1352
|
-
break;
|
|
1353
|
-
}
|
|
1354
|
-
|
|
1355
1330
|
case 'dingtalk-link': {
|
|
1356
1331
|
const { run: runDingTalkLink } = require('../lib/dingtalk/dingtalk-link');
|
|
1357
1332
|
await runDingTalkLink(args);
|
|
@@ -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);
|
|
@@ -4,7 +4,7 @@ const fs = require('fs');
|
|
|
4
4
|
const path = require('path');
|
|
5
5
|
const { CliError } = require('../core/cli-error');
|
|
6
6
|
const { t } = require('../core/i18n');
|
|
7
|
-
const { DESIGN_SKILL_ROOT,
|
|
7
|
+
const { DESIGN_SKILL_ROOT, resolveTheme } = require('../design-plan/themes');
|
|
8
8
|
const START = '/* OPENYIDA APPLICATION STYLE RECIPES START';
|
|
9
9
|
const END = '/* OPENYIDA APPLICATION STYLE RECIPES END */';
|
|
10
10
|
const CREATIVE_TOKENS = [
|
|
@@ -46,8 +46,7 @@ function applyApplicationStyle(css, metadata, tokens) {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
function exportApplicationStyle(id, outputDirectory) {
|
|
49
|
-
const theme =
|
|
50
|
-
if (!theme) {throw new CliError(t('design_document.invalid', id || '--style-id', 'APPLICATION_STYLE_UNKNOWN'), { code: 'APPLICATION_STYLE_UNKNOWN' });}
|
|
49
|
+
const theme = resolveTheme(id, '--style-id');
|
|
51
50
|
const directory = path.resolve(outputDirectory);
|
|
52
51
|
const assets = [['design.md', theme.templatePath], ['app_theme.css', theme.cssTemplatePath], ['form-layout.json', theme.formLayoutPath]];
|
|
53
52
|
const outputs = assets.map(([name, relative]) => {
|
package/lib/app/create-form.js
CHANGED
|
@@ -1125,7 +1125,7 @@ function buildFieldComponent(field) {
|
|
|
1125
1125
|
|
|
1126
1126
|
// 关联表单核心配置
|
|
1127
1127
|
props.associationForm = {
|
|
1128
|
-
formType: 'receipt',
|
|
1128
|
+
formType: assocConfig.formType || 'receipt',
|
|
1129
1129
|
formUuid: assocConfig.formUuid || '',
|
|
1130
1130
|
appType: assocConfig.appType || '',
|
|
1131
1131
|
appName: assocConfig.appName || '',
|
|
@@ -4317,27 +4317,25 @@ function applySmartValidations(schema, rawRules) {
|
|
|
4317
4317
|
};
|
|
4318
4318
|
}
|
|
4319
4319
|
|
|
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
|
-
}
|
|
4320
|
+
function collectSmartValidationRulesFromFields(fields, schema) {
|
|
4321
|
+
const root = schema.pages[0].componentsTree?.[0];
|
|
4322
|
+
const container = root ? findFormContainer(root) : null;
|
|
4323
|
+
const evidence = collectResumeFieldEvidence(container?.children);
|
|
4324
|
+
const rules = [];
|
|
4325
|
+
collectResumeDesiredFields(fields, { verifyNestedFields: true }).forEach(function ({ field, tablePath }) {
|
|
4326
|
+
const identity = desiredResumeFieldIdentity(field);
|
|
4327
|
+
const key = JSON.stringify([...tablePath, identity.label]);
|
|
4328
|
+
const matches = evidence.filter(item => JSON.stringify([...item.tablePath, item.label]) === key);
|
|
4329
|
+
// Inline rules belong to this definition's field, even when another table
|
|
4330
|
+
// uses the same label. Keep ambiguous definitions on the existing error path.
|
|
4331
|
+
const reference = matches.length === 1 && matches[0].componentName === identity.componentName
|
|
4332
|
+
? matches[0].fieldId : field.label;
|
|
4333
|
+
collectInputValidationRules(field, { includeAdvanced: true }).forEach(function (rule) {
|
|
4334
|
+
if (rule.type === 'required' && !field.required && !field.validation && !field.validations) {
|
|
4335
|
+
return;
|
|
4336
|
+
}
|
|
4337
|
+
rules.push(Object.assign({ field: reference }, rule));
|
|
4338
|
+
});
|
|
4341
4339
|
});
|
|
4342
4340
|
return rules;
|
|
4343
4341
|
}
|
|
@@ -5036,7 +5034,7 @@ async function mainCreate(parsedArgs, authRef) {
|
|
|
5036
5034
|
|
|
5037
5035
|
postCreateStage = 'buildFormSchema';
|
|
5038
5036
|
const schema = buildFormSchema(formTitle, fields, formUuid, corpId, appType, layout, theme, labelAlign);
|
|
5039
|
-
const createValidationRules = collectSmartValidationRulesFromFields(fields).concat(validations || []);
|
|
5037
|
+
const createValidationRules = collectSmartValidationRulesFromFields(fields, schema).concat(validations || []);
|
|
5040
5038
|
if (createValidationRules.length > 0) {
|
|
5041
5039
|
const appliedValidations = applySmartValidations(schema, createValidationRules);
|
|
5042
5040
|
info('已为创建表单写入 ' + appliedValidations.appliedRules.length + ' 条字段校验');
|
|
@@ -5154,7 +5152,7 @@ async function createFormForLegacyProcessQuiet(context, input) {
|
|
|
5154
5152
|
const serverRevision = extractSchemaServerRevision(shellSchemaResult);
|
|
5155
5153
|
const corpId = resolveCorpId(authRef.authData || authRef);
|
|
5156
5154
|
const schema = buildFormSchema(formTitle, fields, formUuid, corpId, appType, layout, theme, labelAlign);
|
|
5157
|
-
const createValidationRules = collectSmartValidationRulesFromFields(fields).concat(validations || []);
|
|
5155
|
+
const createValidationRules = collectSmartValidationRulesFromFields(fields, schema).concat(validations || []);
|
|
5158
5156
|
if (createValidationRules.length > 0) {
|
|
5159
5157
|
applySmartValidations(schema, createValidationRules);
|
|
5160
5158
|
}
|
|
@@ -5984,7 +5982,7 @@ async function mainValidation(parsedArgs, authRef) {
|
|
|
5984
5982
|
|
|
5985
5983
|
// ── update 模式主流程 ─────────────────────────────────
|
|
5986
5984
|
|
|
5987
|
-
function collectResumeFieldEvidence(fields, output) {
|
|
5985
|
+
function collectResumeFieldEvidence(fields, output, tablePath = []) {
|
|
5988
5986
|
const evidence = output || [];
|
|
5989
5987
|
(fields || []).forEach(function (field) {
|
|
5990
5988
|
if (!field || typeof field !== 'object') {
|
|
@@ -5996,10 +5994,12 @@ function collectResumeFieldEvidence(fields, output) {
|
|
|
5996
5994
|
label: labelText,
|
|
5997
5995
|
componentName: field.componentName,
|
|
5998
5996
|
fieldId: field.props && field.props.fieldId ? field.props.fieldId : null,
|
|
5997
|
+
tablePath,
|
|
5999
5998
|
});
|
|
6000
5999
|
}
|
|
6001
6000
|
if (Array.isArray(field.children)) {
|
|
6002
|
-
collectResumeFieldEvidence(field.children.flat(), evidence
|
|
6001
|
+
collectResumeFieldEvidence(field.children.flat(), evidence,
|
|
6002
|
+
field.componentName === 'TableField' ? tablePath.concat(labelText) : tablePath);
|
|
6003
6003
|
}
|
|
6004
6004
|
});
|
|
6005
6005
|
return evidence;
|
|
@@ -6020,9 +6020,9 @@ function collectResumeDesiredFields(fields, options) {
|
|
|
6020
6020
|
const output = [];
|
|
6021
6021
|
const verifyNestedFields = Boolean(options && options.verifyNestedFields);
|
|
6022
6022
|
|
|
6023
|
-
function visit(value) {
|
|
6023
|
+
function visit(value, tablePath) {
|
|
6024
6024
|
if (Array.isArray(value)) {
|
|
6025
|
-
value.forEach(visit);
|
|
6025
|
+
value.forEach(field => visit(field, tablePath));
|
|
6026
6026
|
return;
|
|
6027
6027
|
}
|
|
6028
6028
|
if (!value || typeof value !== 'object') {
|
|
@@ -6030,17 +6030,18 @@ function collectResumeDesiredFields(fields, options) {
|
|
|
6030
6030
|
}
|
|
6031
6031
|
const componentName = normalizeFormDefinitionType(value);
|
|
6032
6032
|
if (isSupportedBusinessFieldType(componentName)) {
|
|
6033
|
-
output.push(value);
|
|
6033
|
+
output.push({ field: value, tablePath });
|
|
6034
6034
|
if (!verifyNestedFields) {
|
|
6035
6035
|
return;
|
|
6036
6036
|
}
|
|
6037
6037
|
}
|
|
6038
6038
|
if (Array.isArray(value.children)) {
|
|
6039
|
-
value.children
|
|
6039
|
+
visit(value.children, componentName === 'TableField'
|
|
6040
|
+
? tablePath.concat(desiredResumeFieldIdentity(value).label) : tablePath);
|
|
6040
6041
|
}
|
|
6041
6042
|
}
|
|
6042
6043
|
|
|
6043
|
-
visit(fields);
|
|
6044
|
+
visit(fields, []);
|
|
6044
6045
|
return output;
|
|
6045
6046
|
}
|
|
6046
6047
|
|
|
@@ -6068,28 +6069,34 @@ function isRecoverableBlankResumeSchema(schema) {
|
|
|
6068
6069
|
}
|
|
6069
6070
|
|
|
6070
6071
|
function buildResumeChanges(existingFields, desiredFields) {
|
|
6071
|
-
|
|
6072
|
+
// Layout containers do not change identity. A table creates a new namespace;
|
|
6073
|
+
// JSON tuples preserve punctuation in labels without path collisions.
|
|
6074
|
+
const scopedKey = (tablePath, label) => JSON.stringify([...tablePath, label]);
|
|
6075
|
+
const existingByScope = new Map();
|
|
6072
6076
|
existingFields.forEach(function (field) {
|
|
6073
|
-
const
|
|
6077
|
+
const key = scopedKey(field.tablePath, field.label);
|
|
6078
|
+
const bucket = existingByScope.get(key) || [];
|
|
6074
6079
|
bucket.push(field);
|
|
6075
|
-
|
|
6080
|
+
existingByScope.set(key, bucket);
|
|
6076
6081
|
});
|
|
6077
6082
|
|
|
6078
6083
|
const desiredLabels = new Set();
|
|
6079
6084
|
const missing = [];
|
|
6080
6085
|
const existing = [];
|
|
6081
6086
|
const conflicts = [];
|
|
6082
|
-
desiredFields.forEach(function (field) {
|
|
6087
|
+
desiredFields.forEach(function ({ field, tablePath }) {
|
|
6083
6088
|
const identity = desiredResumeFieldIdentity(field);
|
|
6084
|
-
|
|
6089
|
+
const key = scopedKey(tablePath, identity.label);
|
|
6090
|
+
if (!identity.label || desiredLabels.has(key)) {
|
|
6085
6091
|
conflicts.push({
|
|
6086
6092
|
code: identity.label ? 'CREATE_FORM_RESUME_DUPLICATE_DESIRED_FIELD' : 'CREATE_FORM_RESUME_FIELD_LABEL_REQUIRED',
|
|
6087
6093
|
label: identity.label || null,
|
|
6094
|
+
tablePath,
|
|
6088
6095
|
});
|
|
6089
6096
|
return;
|
|
6090
6097
|
}
|
|
6091
|
-
desiredLabels.add(
|
|
6092
|
-
const matches =
|
|
6098
|
+
desiredLabels.add(key);
|
|
6099
|
+
const matches = existingByScope.get(key) || [];
|
|
6093
6100
|
if (matches.length === 0) {
|
|
6094
6101
|
missing.push(field);
|
|
6095
6102
|
return;
|
|
@@ -6098,6 +6105,7 @@ function buildResumeChanges(existingFields, desiredFields) {
|
|
|
6098
6105
|
conflicts.push({
|
|
6099
6106
|
code: 'CREATE_FORM_RESUME_FIELD_CONFLICT',
|
|
6100
6107
|
label: identity.label,
|
|
6108
|
+
tablePath,
|
|
6101
6109
|
requestedType: identity.componentName,
|
|
6102
6110
|
observedTypes: matches.map(function (item) { return item.componentName; }),
|
|
6103
6111
|
});
|
|
@@ -6107,6 +6115,7 @@ function buildResumeChanges(existingFields, desiredFields) {
|
|
|
6107
6115
|
label: identity.label,
|
|
6108
6116
|
componentName: identity.componentName,
|
|
6109
6117
|
fieldId: matches[0].fieldId,
|
|
6118
|
+
tablePath,
|
|
6110
6119
|
});
|
|
6111
6120
|
});
|
|
6112
6121
|
return { missing, existing, conflicts };
|
|
@@ -6258,7 +6267,7 @@ async function mainResume(parsedArgs, authRef) {
|
|
|
6258
6267
|
const corpId = resolveCorpId(authRef.authData);
|
|
6259
6268
|
const formTitle = firstRead.schemaResult.formTitle || firstRead.schemaResult.title || formUuid;
|
|
6260
6269
|
firstRead.schema = buildFormSchema(formTitle, fields, formUuid, corpId, appType, 'single', 'default', 'top');
|
|
6261
|
-
const resumeValidationRules = collectSmartValidationRulesFromFields(fields).concat(validations || []);
|
|
6270
|
+
const resumeValidationRules = collectSmartValidationRulesFromFields(fields, firstRead.schema).concat(validations || []);
|
|
6262
6271
|
if (resumeValidationRules.length > 0) {
|
|
6263
6272
|
applySmartValidations(firstRead.schema, resumeValidationRules);
|
|
6264
6273
|
}
|
package/lib/app/fast-theme.js
CHANGED
|
@@ -4,7 +4,7 @@ const fs = require('fs');
|
|
|
4
4
|
const path = require('path');
|
|
5
5
|
const { CliError, isCliError } = require('../core/cli-error');
|
|
6
6
|
const { t } = require('../core/i18n');
|
|
7
|
-
const { loadThemeIndex, themeTemplatePath, themeNavTheme, resolveThemeColors } = require('../design-plan/themes');
|
|
7
|
+
const { loadThemeIndex, themeSelectionDetails, themeTemplatePath, themeNavTheme, resolveThemeColors } = require('../design-plan/themes');
|
|
8
8
|
const { parseDesignDocument, serializeDesignDocument, extractDesignTokens } = require('../design/document');
|
|
9
9
|
const { normalizeCssColorToHex } = require('./custom-theme');
|
|
10
10
|
const { generateThemeCss } = require('./theme-source');
|
|
@@ -19,17 +19,21 @@ function preflight(error) {
|
|
|
19
19
|
return error;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
function invalid(field, expected, actual) {
|
|
22
|
+
function invalid(field, expected, actual, details = {}) {
|
|
23
23
|
throw preflight(new CliError(t('cli_argument.invalid', field), { code: 'FAST_THEME_INVALID',
|
|
24
|
-
details: { issues: [{ path: field, expected, ...(actual !== undefined ? { actual } : {}) }] } }));
|
|
24
|
+
details: { ...details, issues: [{ path: field, expected, ...(actual !== undefined ? { actual } : {}), ...details.issues?.[0] }] } }));
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
// Theme-only generation: no business plan, page specification or Plan renderer.
|
|
28
28
|
function prepareFastTheme(options) {
|
|
29
29
|
let theme, color, css, palette, navTheme;
|
|
30
30
|
try {
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
const themes = loadThemeIndex().themes;
|
|
32
|
+
theme = themes.find(item => item.themeId === options.styleId);
|
|
33
|
+
if (!theme) {
|
|
34
|
+
const details = themeSelectionDetails(options.styleId, '--style-id', themes);
|
|
35
|
+
invalid('--style-id', 'themeId from design-plan catalog --compact', options.styleId, details);
|
|
36
|
+
}
|
|
33
37
|
color = normalizeCssColorToHex(options.primaryColor);
|
|
34
38
|
if (!color) {invalid('--primary-color', 'CSS hex or rgb color', options.primaryColor);}
|
|
35
39
|
if (theme.themeId === 'app-pop' && !['explicit-request', 'showcase'].includes(options.popArtContext)) {
|
|
@@ -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 };
|