openyida 2026.11.4 → 2026.11.5-3
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 +17 -4
- package/lib/agent/mutation-receipt.js +1 -1
- package/lib/app/app-theme-state.js +2 -1
- package/lib/app/create-form/batch.js +10 -1
- package/lib/app/create-form/default-view.js +50 -0
- package/lib/app/create-form.js +64 -41
- 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 +38 -6
- package/lib/app/services/field-bindings.js +94 -0
- package/lib/app/services/form-compiler.js +1 -1
- package/lib/app/subform-readback.js +70 -0
- package/lib/app/update-app.js +1 -1
- package/lib/core/command-manifest.js +38 -19
- package/lib/core/data-seed.js +260 -0
- package/lib/core/locales/en.js +10 -1
- package/lib/core/locales/zh.js +10 -1
- package/lib/core/query-data.js +98 -42
- package/lib/core/utils.js +12 -5
- package/lib/process/configure-process.js +16 -5
- package/lib/process/create-process.js +7 -1
- package/lib/process/process-diagnostics.js +5 -1
- package/lib/process/services/process-compiler.js +18 -75
- package/lib/process/services/process-form-fields.js +54 -1
- package/lib/process/services/process-view-verifier.js +29 -0
- package/lib/samples/openyida-scaffold/canvas-data-source.jsx +194 -5
- package/package.json +1 -1
- package/yida-skills/SKILL.md +2 -2
- package/yida-skills/skills/yida-app/SKILL.md +5 -5
- 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 +2 -2
- package/yida-skills/skills/yida-app/workflow/step-5-seed-records.md +17 -42
- package/yida-skills/skills/yida-app/workflow/step-7-page-code.md +1 -1
- package/yida-skills/skills/yida-app/workflow/step-9-output-finish.md +1 -1
- package/yida-skills/skills/yida-canvas-custom-page/SKILL.md +3 -3
- package/yida-skills/skills/yida-canvas-custom-page/references/data-bridge-guide.md +3 -3
- package/yida-skills/skills/yida-canvas-custom-page/references/page-generation-guide.md +3 -3
- package/yida-skills/skills/yida-canvas-data-binding/SKILL.md +42 -5
- 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-create-process/SKILL.md +59 -207
- package/yida-skills/skills/yida-custom-button/SKILL.md +9 -1
- package/yida-skills/skills/yida-data-management/SKILL.md +100 -240
- package/yida-skills/skills/yida-data-management/references/data-format-guide.md +56 -8
- package/yida-skills/skills/yida-data-management/references/process-seed-workflow.md +31 -0
- package/yida-skills/skills/yida-design/references/application-style-library.md +1 -1
- package/yida-skills/skills/yida-flow-node-config/references/conditions-variables.md +2 -0
- package/yida-skills/skills/yida-form-view/SKILL.md +27 -4
- package/yida-skills/skills/yida-process-rule/SKILL.md +6 -4
- package/yida-skills/skills-index.json +12 -6
package/README.md
CHANGED
|
@@ -277,11 +277,24 @@ 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
|
|
281
|
+
openyida data seed process APP_XXX FORM_XXX --process-code TPROC_XXX --expect-form-name 申请 --records-file .cache/openyida/data-import/applications.json --json
|
|
280
282
|
openyida get-permission APP_XXX FORM_XXX
|
|
281
283
|
```
|
|
282
284
|
|
|
283
285
|
`--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
286
|
|
|
287
|
+
`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.
|
|
288
|
+
|
|
289
|
+
`data seed process` shares the schema, date conversion, receipt and readback behavior. It requires `--process-code`, starts real workflow instances and returns `processInstanceIds`. For application samples, create a temporary originator-only approval flow, seed and verify, then edit and publish the final flow on the same form. Existing samples retain their original workflow version.
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
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#组件支持与未适配配置).
|
|
293
|
+
|
|
294
|
+
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.
|
|
295
|
+
|
|
296
|
+
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).
|
|
297
|
+
|
|
285
298
|
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
299
|
|
|
287
300
|
`configure-process` 的流程 JSON 中,审批人可配置为发起人、指定成员、指定角色、部门主管或直属主管,例如:
|
|
@@ -530,7 +543,7 @@ When preparing a PR that needs a personal Fork, or when you ask how to support t
|
|
|
530
543
|
| `openyida list-forms <appType> [--keyword <text>]` | List forms/pages in an app |
|
|
531
544
|
| `openyida aggregate-table <list\|create-empty\|inspect\|preview\|save\|publish\|status> <appType> ...` | Manage aggregate tables (virtualView) |
|
|
532
545
|
| `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 |
|
|
546
|
+
| `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
547
|
| `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
548
|
| `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
549
|
| `openyida get-schema <appType> <formUuid\|--all> [--summary-json\|--field-map-json\|--analysis-json]` | Get one form Schema or all form Schemas |
|
|
@@ -549,7 +562,7 @@ When preparing a PR that needs a personal Fork, or when you ask how to support t
|
|
|
549
562
|
|
|
550
563
|
| Command | Description |
|
|
551
564
|
|---------|-------------|
|
|
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) |
|
|
565
|
+
| `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
566
|
| `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
567
|
| `openyida basic-info <overview\|commodity\|grant\|capacity\|quota\|abs-path\|dataflow\|i18n\|domain>` | Query organization basic info, capacity, quotas, and domain settings |
|
|
555
568
|
| `openyida read-dingtalk-doc <docUrl> [--output <file>] [--json]` | Fetch Markdown content from a DingTalk document |
|
|
@@ -565,8 +578,8 @@ When preparing a PR that needs a personal Fork, or when you ask how to support t
|
|
|
565
578
|
|
|
566
579
|
| Command | Description |
|
|
567
580
|
|---------|-------------|
|
|
568
|
-
| `openyida configure-process <appType> <formUuid> <definition> [processCode] [--replace]` | Configure and publish process rules; Supports append/forward via JSON nodes[].actions.normalActions/appendActions |
|
|
569
|
-
| `openyida create-process <appType> <formTitle> <fieldsJsonFile> <processDefinitionFile> [--replace] \| create-process <appType> --formUuid <formUuid> <processDefinitionFile> [--replace]` | Create process form (all-in-one); Supports append/forward via JSON nodes[].actions.normalActions/appendActions |
|
|
581
|
+
| `openyida configure-process <appType> <formUuid> <definition> [processCode] [--replace] [--json]` | Configure and publish process rules; Supports append/forward via JSON nodes[].actions.normalActions/appendActions |
|
|
582
|
+
| `openyida create-process <appType> <formTitle> <fieldsJsonFile> <processDefinitionFile> [--replace] [--json] \| create-process <appType> --formUuid <formUuid> <processDefinitionFile> [--replace] [--json]` | Create process form (all-in-one); Supports append/forward via JSON nodes[].actions.normalActions/appendActions |
|
|
570
583
|
| `openyida ai-form-setting <get\|fields\|models\|enable\|disable\|save> <appType> ...` | Manage process form AI approval prompts |
|
|
571
584
|
| `openyida process preview <appType> ...` | Preview process instance (visual flowchart) |
|
|
572
585
|
| `openyida process fields <appType> <formUuid> [--json]` | Check process designer field loading and subtable field paths |
|
|
@@ -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
|
}
|
|
@@ -126,8 +126,12 @@ function normalizeAssociationReferences(value, appType) {
|
|
|
126
126
|
typeof association.$form === 'string'
|
|
127
127
|
) {
|
|
128
128
|
const reference = { $form: association.$form };
|
|
129
|
+
const metadata = { ...normalized.associationForm };
|
|
130
|
+
delete metadata.$form;
|
|
131
|
+
delete metadata.field;
|
|
129
132
|
normalized.associationForm = {
|
|
130
133
|
...(appType ? { appType } : {}),
|
|
134
|
+
...metadata,
|
|
131
135
|
formUuid: reference,
|
|
132
136
|
...(typeof association.field === 'string' && association.field.trim() ? {
|
|
133
137
|
mainFieldId: { ...reference, field: association.field },
|
|
@@ -331,7 +335,8 @@ async function schedule(forms, concurrency, results, worker, save) {
|
|
|
331
335
|
// A create may persist the form before a later schema/readback stage fails.
|
|
332
336
|
// Retry that known UUID once inside the same authoritative batch so its
|
|
333
337
|
// dependents remain pending and can run after conservative resume.
|
|
334
|
-
if (!hadKnownFormUuid && results[form.key].formUuid && !recoveryAttempted.has(form.key)
|
|
338
|
+
if (!hadKnownFormUuid && results[form.key].formUuid && !recoveryAttempted.has(form.key)
|
|
339
|
+
&& !error.output?.errorCode?.startsWith('CREATE_FORM_DEFAULT_VIEW_')) {
|
|
335
340
|
recoveryAttempted.add(form.key);
|
|
336
341
|
pending.add(form.key);
|
|
337
342
|
}
|
|
@@ -419,6 +424,7 @@ async function run(args, dependencies = {}) {
|
|
|
419
424
|
...(created.url ? { url: created.url } : {}),
|
|
420
425
|
...(created.formUrl ? { formUrl: created.formUrl } : {}),
|
|
421
426
|
...(created.appUrl ? { appUrl: created.appUrl } : {}),
|
|
427
|
+
...(created.defaultView ? { defaultView: created.defaultView } : {}),
|
|
422
428
|
};
|
|
423
429
|
} catch (error) {
|
|
424
430
|
const createdFormUuid = error.output?.formUuid || error.output?.details?.formUuid;
|
|
@@ -426,6 +432,7 @@ async function run(args, dependencies = {}) {
|
|
|
426
432
|
throw error;
|
|
427
433
|
}
|
|
428
434
|
formUuid = createdFormUuid;
|
|
435
|
+
if (error.output?.errorCode?.startsWith('CREATE_FORM_DEFAULT_VIEW_')) { throw error; }
|
|
429
436
|
shouldResume = true;
|
|
430
437
|
}
|
|
431
438
|
}
|
|
@@ -439,6 +446,7 @@ async function run(args, dependencies = {}) {
|
|
|
439
446
|
...(resumeOutput.url ? { url: resumeOutput.url } : {}),
|
|
440
447
|
...(resumeOutput.formUrl ? { formUrl: resumeOutput.formUrl } : {}),
|
|
441
448
|
...(resumeOutput.appUrl ? { appUrl: resumeOutput.appUrl } : {}),
|
|
449
|
+
...(resumeOutput.defaultView ? { defaultView: resumeOutput.defaultView } : {}),
|
|
442
450
|
};
|
|
443
451
|
resumed = true;
|
|
444
452
|
}
|
|
@@ -450,6 +458,7 @@ async function run(args, dependencies = {}) {
|
|
|
450
458
|
...(resumeOutput.url ? { url: resumeOutput.url } : {}),
|
|
451
459
|
...(resumeOutput.formUrl ? { formUrl: resumeOutput.formUrl } : {}),
|
|
452
460
|
...(resumeOutput.appUrl ? { appUrl: resumeOutput.appUrl } : {}),
|
|
461
|
+
...(resumeOutput.defaultView ? { defaultView: resumeOutput.defaultView } : {}),
|
|
453
462
|
};
|
|
454
463
|
resumed = true;
|
|
455
464
|
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,14 +5156,15 @@ 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
|
}
|
|
5161
5163
|
const saveResult = await saveFormSchema(authRef, appType, formUuid, schema, serverRevision, 4);
|
|
5162
5164
|
await verifyCreatedFormSchema(authRef, appType, formUuid, fields);
|
|
5163
5165
|
const navIconResult = await updateCreatedFormNavigationIcon(authRef, appType, formUuid, formIcon);
|
|
5164
|
-
await verifyCreatedFormSchema(authRef, appType, formUuid, fields);
|
|
5166
|
+
const verifiedSchema = 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,
|
|
@@ -5169,9 +5172,13 @@ async function createFormForLegacyProcessQuiet(context, input) {
|
|
|
5169
5172
|
formUuid,
|
|
5170
5173
|
formTitle,
|
|
5171
5174
|
fieldCount,
|
|
5175
|
+
fields: require('./schema-field-resolution').normalizeSchemaFields({ content: verifiedSchema })
|
|
5176
|
+
.filter(field => /Field$/.test(field.componentType)).map(field => ({ fieldId: field.fieldId,
|
|
5177
|
+
label: field.label, componentName: field.componentType, parentFieldId: field.parentFieldId, labelPath: field.labelPath, alias: field.alias })),
|
|
5172
5178
|
createResult,
|
|
5173
5179
|
saveResult,
|
|
5174
5180
|
navIconResult,
|
|
5181
|
+
defaultView,
|
|
5175
5182
|
icon: formIcon,
|
|
5176
5183
|
iconSource: iconResolution.source,
|
|
5177
5184
|
url: formUrl,
|
|
@@ -5984,7 +5991,7 @@ async function mainValidation(parsedArgs, authRef) {
|
|
|
5984
5991
|
|
|
5985
5992
|
// ── update 模式主流程 ─────────────────────────────────
|
|
5986
5993
|
|
|
5987
|
-
function collectResumeFieldEvidence(fields, output) {
|
|
5994
|
+
function collectResumeFieldEvidence(fields, output, tablePath = []) {
|
|
5988
5995
|
const evidence = output || [];
|
|
5989
5996
|
(fields || []).forEach(function (field) {
|
|
5990
5997
|
if (!field || typeof field !== 'object') {
|
|
@@ -5996,10 +6003,12 @@ function collectResumeFieldEvidence(fields, output) {
|
|
|
5996
6003
|
label: labelText,
|
|
5997
6004
|
componentName: field.componentName,
|
|
5998
6005
|
fieldId: field.props && field.props.fieldId ? field.props.fieldId : null,
|
|
6006
|
+
tablePath,
|
|
5999
6007
|
});
|
|
6000
6008
|
}
|
|
6001
6009
|
if (Array.isArray(field.children)) {
|
|
6002
|
-
collectResumeFieldEvidence(field.children.flat(), evidence
|
|
6010
|
+
collectResumeFieldEvidence(field.children.flat(), evidence,
|
|
6011
|
+
field.componentName === 'TableField' ? tablePath.concat(labelText) : tablePath);
|
|
6003
6012
|
}
|
|
6004
6013
|
});
|
|
6005
6014
|
return evidence;
|
|
@@ -6020,9 +6029,9 @@ function collectResumeDesiredFields(fields, options) {
|
|
|
6020
6029
|
const output = [];
|
|
6021
6030
|
const verifyNestedFields = Boolean(options && options.verifyNestedFields);
|
|
6022
6031
|
|
|
6023
|
-
function visit(value) {
|
|
6032
|
+
function visit(value, tablePath) {
|
|
6024
6033
|
if (Array.isArray(value)) {
|
|
6025
|
-
value.forEach(visit);
|
|
6034
|
+
value.forEach(field => visit(field, tablePath));
|
|
6026
6035
|
return;
|
|
6027
6036
|
}
|
|
6028
6037
|
if (!value || typeof value !== 'object') {
|
|
@@ -6030,17 +6039,18 @@ function collectResumeDesiredFields(fields, options) {
|
|
|
6030
6039
|
}
|
|
6031
6040
|
const componentName = normalizeFormDefinitionType(value);
|
|
6032
6041
|
if (isSupportedBusinessFieldType(componentName)) {
|
|
6033
|
-
output.push(value);
|
|
6042
|
+
output.push({ field: value, tablePath });
|
|
6034
6043
|
if (!verifyNestedFields) {
|
|
6035
6044
|
return;
|
|
6036
6045
|
}
|
|
6037
6046
|
}
|
|
6038
6047
|
if (Array.isArray(value.children)) {
|
|
6039
|
-
value.children
|
|
6048
|
+
visit(value.children, componentName === 'TableField'
|
|
6049
|
+
? tablePath.concat(desiredResumeFieldIdentity(value).label) : tablePath);
|
|
6040
6050
|
}
|
|
6041
6051
|
}
|
|
6042
6052
|
|
|
6043
|
-
visit(fields);
|
|
6053
|
+
visit(fields, []);
|
|
6044
6054
|
return output;
|
|
6045
6055
|
}
|
|
6046
6056
|
|
|
@@ -6068,28 +6078,34 @@ function isRecoverableBlankResumeSchema(schema) {
|
|
|
6068
6078
|
}
|
|
6069
6079
|
|
|
6070
6080
|
function buildResumeChanges(existingFields, desiredFields) {
|
|
6071
|
-
|
|
6081
|
+
// Layout containers do not change identity. A table creates a new namespace;
|
|
6082
|
+
// JSON tuples preserve punctuation in labels without path collisions.
|
|
6083
|
+
const scopedKey = (tablePath, label) => JSON.stringify([...tablePath, label]);
|
|
6084
|
+
const existingByScope = new Map();
|
|
6072
6085
|
existingFields.forEach(function (field) {
|
|
6073
|
-
const
|
|
6086
|
+
const key = scopedKey(field.tablePath, field.label);
|
|
6087
|
+
const bucket = existingByScope.get(key) || [];
|
|
6074
6088
|
bucket.push(field);
|
|
6075
|
-
|
|
6089
|
+
existingByScope.set(key, bucket);
|
|
6076
6090
|
});
|
|
6077
6091
|
|
|
6078
6092
|
const desiredLabels = new Set();
|
|
6079
6093
|
const missing = [];
|
|
6080
6094
|
const existing = [];
|
|
6081
6095
|
const conflicts = [];
|
|
6082
|
-
desiredFields.forEach(function (field) {
|
|
6096
|
+
desiredFields.forEach(function ({ field, tablePath }) {
|
|
6083
6097
|
const identity = desiredResumeFieldIdentity(field);
|
|
6084
|
-
|
|
6098
|
+
const key = scopedKey(tablePath, identity.label);
|
|
6099
|
+
if (!identity.label || desiredLabels.has(key)) {
|
|
6085
6100
|
conflicts.push({
|
|
6086
6101
|
code: identity.label ? 'CREATE_FORM_RESUME_DUPLICATE_DESIRED_FIELD' : 'CREATE_FORM_RESUME_FIELD_LABEL_REQUIRED',
|
|
6087
6102
|
label: identity.label || null,
|
|
6103
|
+
tablePath,
|
|
6088
6104
|
});
|
|
6089
6105
|
return;
|
|
6090
6106
|
}
|
|
6091
|
-
desiredLabels.add(
|
|
6092
|
-
const matches =
|
|
6107
|
+
desiredLabels.add(key);
|
|
6108
|
+
const matches = existingByScope.get(key) || [];
|
|
6093
6109
|
if (matches.length === 0) {
|
|
6094
6110
|
missing.push(field);
|
|
6095
6111
|
return;
|
|
@@ -6098,6 +6114,7 @@ function buildResumeChanges(existingFields, desiredFields) {
|
|
|
6098
6114
|
conflicts.push({
|
|
6099
6115
|
code: 'CREATE_FORM_RESUME_FIELD_CONFLICT',
|
|
6100
6116
|
label: identity.label,
|
|
6117
|
+
tablePath,
|
|
6101
6118
|
requestedType: identity.componentName,
|
|
6102
6119
|
observedTypes: matches.map(function (item) { return item.componentName; }),
|
|
6103
6120
|
});
|
|
@@ -6107,6 +6124,7 @@ function buildResumeChanges(existingFields, desiredFields) {
|
|
|
6107
6124
|
label: identity.label,
|
|
6108
6125
|
componentName: identity.componentName,
|
|
6109
6126
|
fieldId: matches[0].fieldId,
|
|
6127
|
+
tablePath,
|
|
6110
6128
|
});
|
|
6111
6129
|
});
|
|
6112
6130
|
return { missing, existing, conflicts };
|
|
@@ -6167,6 +6185,7 @@ async function verifyCreatedFormSchema(authRef, appType, formUuid, fields) {
|
|
|
6167
6185
|
missingFieldCount: verified.missing.length, diagnostics: verified.conflicts,
|
|
6168
6186
|
});
|
|
6169
6187
|
}
|
|
6188
|
+
return readback.schema;
|
|
6170
6189
|
}
|
|
6171
6190
|
|
|
6172
6191
|
function isRetryableResumeSaveServerFailure(errorObject) {
|
|
@@ -6258,7 +6277,7 @@ async function mainResume(parsedArgs, authRef) {
|
|
|
6258
6277
|
const corpId = resolveCorpId(authRef.authData);
|
|
6259
6278
|
const formTitle = firstRead.schemaResult.formTitle || firstRead.schemaResult.title || formUuid;
|
|
6260
6279
|
firstRead.schema = buildFormSchema(formTitle, fields, formUuid, corpId, appType, 'single', 'default', 'top');
|
|
6261
|
-
const resumeValidationRules = collectSmartValidationRulesFromFields(fields).concat(validations || []);
|
|
6280
|
+
const resumeValidationRules = collectSmartValidationRulesFromFields(fields, firstRead.schema).concat(validations || []);
|
|
6262
6281
|
if (resumeValidationRules.length > 0) {
|
|
6263
6282
|
applySmartValidations(firstRead.schema, resumeValidationRules);
|
|
6264
6283
|
}
|
|
@@ -6340,6 +6359,8 @@ async function mainResume(parsedArgs, authRef) {
|
|
|
6340
6359
|
});
|
|
6341
6360
|
}
|
|
6342
6361
|
completedStages.push('verify_final_schema');
|
|
6362
|
+
const defaultView = await configureCreatedFormView(authRef, appType, formUuid);
|
|
6363
|
+
completedStages.push('configure_default_view');
|
|
6343
6364
|
const { appUrl, formUrl } = buildFormDeliveryUrls(authRef.baseUrl, appType, formUuid);
|
|
6344
6365
|
const output = {
|
|
6345
6366
|
success: true,
|
|
@@ -6351,6 +6372,7 @@ async function mainResume(parsedArgs, authRef) {
|
|
|
6351
6372
|
addedFieldCount: plan.missing.length,
|
|
6352
6373
|
finalFieldCount: collectResumeFieldEvidence(finalContainer.children).length,
|
|
6353
6374
|
recoveredBlankShell,
|
|
6375
|
+
defaultView,
|
|
6354
6376
|
url: formUrl,
|
|
6355
6377
|
formUrl,
|
|
6356
6378
|
appUrl,
|
|
@@ -6578,6 +6600,7 @@ module.exports = {
|
|
|
6578
6600
|
run,
|
|
6579
6601
|
parseArgs,
|
|
6580
6602
|
_private: {
|
|
6603
|
+
readFieldsDefinition,
|
|
6581
6604
|
buildFormSchema,
|
|
6582
6605
|
buildEmptyFormSchema,
|
|
6583
6606
|
buildFormNodeComponent,
|