openyida 2026.11.5-beta.0 → 2026.11.6
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 +8 -7
- 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 +16 -2
- package/lib/app/form-view.js +123 -15
- package/lib/app/publish.js +6 -0
- package/lib/app/services/field-bindings.js +94 -0
- package/lib/app/subform-readback.js +11 -1
- package/lib/app/update-app.js +1 -1
- package/lib/core/babel.js +7 -2
- package/lib/core/command-manifest.js +24 -28
- package/lib/core/data-seed.js +29 -23
- package/lib/core/locales/en.js +3 -3
- package/lib/core/locales/zh.js +3 -3
- package/lib/core/query-data.js +56 -34
- 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 +74 -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/workflow/fast-build.md +3 -1
- 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 +14 -6
- package/yida-skills/skills/yida-create-app/SKILL.md +1 -1
- package/yida-skills/skills/yida-create-form-page/SKILL.md +1 -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 +47 -185
- package/yida-skills/skills/yida-data-management/references/data-format-guide.md +14 -5
- 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/lib/core/mock-records.js +0 -202
package/README.md
CHANGED
|
@@ -278,7 +278,7 @@ 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
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
|
|
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
|
|
282
282
|
openyida get-permission APP_XXX FORM_XXX
|
|
283
283
|
```
|
|
284
284
|
|
|
@@ -286,14 +286,15 @@ openyida get-permission APP_XXX FORM_XXX
|
|
|
286
286
|
|
|
287
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
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
|
+
|
|
289
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#组件支持与未适配配置).
|
|
290
293
|
|
|
291
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.
|
|
292
295
|
|
|
293
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).
|
|
294
297
|
|
|
295
|
-
`data mock form` is an explicit beta command for environments with the `/query/aiTool/mockRecords.json` endpoint deployed. It submits 1–3 records for one ordinary form in a single write request, using `[{"clientRecordId":"seed-1","data":{"textField_name":"Customer A"}}]`. The default app-building flow continues to use `data seed form` with its date conversion, readback and resumable receipts. Mock request IDs are for tracing only; every invocation creates a new request, with no automatic retry or fallback to single-record writes. Inspect `COMPLETED/UNKNOWN/REJECTED`, per-row states and counts; `COMPLETED` does not imply every row succeeded. Verify each created instance ID and visible fields separately (`readbackVerified=false`), and inspect existing data before any further write after an uncertain result.
|
|
296
|
-
|
|
297
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.
|
|
298
299
|
|
|
299
300
|
`configure-process` 的流程 JSON 中,审批人可配置为发起人、指定成员、指定角色、部门主管或直属主管,例如:
|
|
@@ -542,7 +543,7 @@ When preparing a PR that needs a personal Fork, or when you ask how to support t
|
|
|
542
543
|
| `openyida list-forms <appType> [--keyword <text>]` | List forms/pages in an app |
|
|
543
544
|
| `openyida aggregate-table <list\|create-empty\|inspect\|preview\|save\|publish\|status> <appType> ...` | Manage aggregate tables (virtualView) |
|
|
544
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 |
|
|
545
|
-
| `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 |
|
|
546
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 |
|
|
547
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 |
|
|
548
549
|
| `openyida get-schema <appType> <formUuid\|--all> [--summary-json\|--field-map-json\|--analysis-json]` | Get one form Schema or all form Schemas |
|
|
@@ -561,7 +562,7 @@ When preparing a PR that needs a personal Fork, or when you ask how to support t
|
|
|
561
562
|
|
|
562
563
|
| Command | Description |
|
|
563
564
|
|---------|-------------|
|
|
564
|
-
| `openyida data <query\|get\|create\|update\|transfer\|seed
|
|
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) |
|
|
565
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.) |
|
|
566
567
|
| `openyida basic-info <overview\|commodity\|grant\|capacity\|quota\|abs-path\|dataflow\|i18n\|domain>` | Query organization basic info, capacity, quotas, and domain settings |
|
|
567
568
|
| `openyida read-dingtalk-doc <docUrl> [--output <file>] [--json]` | Fetch Markdown content from a DingTalk document |
|
|
@@ -577,8 +578,8 @@ When preparing a PR that needs a personal Fork, or when you ask how to support t
|
|
|
577
578
|
|
|
578
579
|
| Command | Description |
|
|
579
580
|
|---------|-------------|
|
|
580
|
-
| `openyida configure-process <appType> <formUuid> <definition> [processCode] [--replace]` | Configure and publish process rules; Supports append/forward via JSON nodes[].actions.normalActions/appendActions |
|
|
581
|
-
| `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 |
|
|
582
583
|
| `openyida ai-form-setting <get\|fields\|models\|enable\|disable\|save> <appType> ...` | Manage process form AI approval prompts |
|
|
583
584
|
| `openyida process preview <appType> ...` | Preview process instance (visual flowchart) |
|
|
584
585
|
| `openyida process fields <appType> <formUuid> [--json]` | Check process designer field loading and subtable field paths |
|
|
@@ -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,
|
|
@@ -5004,6 +5005,7 @@ async function mainCreate(parsedArgs, authRef) {
|
|
|
5004
5005
|
const formUuid = createResult.content.formUuid || createResult.content;
|
|
5005
5006
|
success(t('create_form.blank_created', formUuid));
|
|
5006
5007
|
let postCreateStage = 'getFormSchema';
|
|
5008
|
+
let defaultView;
|
|
5007
5009
|
try {
|
|
5008
5010
|
const shellSchemaResult = await requestWithAutoLogin(function (auth) {
|
|
5009
5011
|
return sendGetRequest(
|
|
@@ -5052,6 +5054,8 @@ async function mainCreate(parsedArgs, authRef) {
|
|
|
5052
5054
|
await updateCreatedFormNavigationIcon(authRef, appType, formUuid, formIcon);
|
|
5053
5055
|
postCreateStage = 'verifyFinalSchema';
|
|
5054
5056
|
await verifyCreatedFormSchema(authRef, appType, formUuid, fields);
|
|
5057
|
+
postCreateStage = 'configureDefaultView';
|
|
5058
|
+
defaultView = await configureCreatedFormView(authRef, appType, formUuid);
|
|
5055
5059
|
} catch (err) {
|
|
5056
5060
|
emitCreateFormPostCreateFailure({
|
|
5057
5061
|
appType,
|
|
@@ -5071,7 +5075,7 @@ async function mainCreate(parsedArgs, authRef) {
|
|
|
5071
5075
|
['URL', formUrl],
|
|
5072
5076
|
]);
|
|
5073
5077
|
console.log(JSON.stringify(withBrowserHandoff(
|
|
5074
|
-
{ 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 },
|
|
5075
5079
|
formUrl,
|
|
5076
5080
|
{ stage: 'create_form_success', title: formTitle },
|
|
5077
5081
|
parsedArgs.browserOpenMode
|
|
@@ -5159,7 +5163,8 @@ async function createFormForLegacyProcessQuiet(context, input) {
|
|
|
5159
5163
|
const saveResult = await saveFormSchema(authRef, appType, formUuid, schema, serverRevision, 4);
|
|
5160
5164
|
await verifyCreatedFormSchema(authRef, appType, formUuid, fields);
|
|
5161
5165
|
const navIconResult = await updateCreatedFormNavigationIcon(authRef, appType, formUuid, formIcon);
|
|
5162
|
-
await verifyCreatedFormSchema(authRef, appType, formUuid, fields);
|
|
5166
|
+
const verifiedSchema = await verifyCreatedFormSchema(authRef, appType, formUuid, fields);
|
|
5167
|
+
const defaultView = await configureCreatedFormView(authRef, appType, formUuid);
|
|
5163
5168
|
const { appUrl, formUrl } = buildFormDeliveryUrls(authRef.baseUrl, appType, formUuid);
|
|
5164
5169
|
return {
|
|
5165
5170
|
success: true,
|
|
@@ -5167,9 +5172,13 @@ async function createFormForLegacyProcessQuiet(context, input) {
|
|
|
5167
5172
|
formUuid,
|
|
5168
5173
|
formTitle,
|
|
5169
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 })),
|
|
5170
5178
|
createResult,
|
|
5171
5179
|
saveResult,
|
|
5172
5180
|
navIconResult,
|
|
5181
|
+
defaultView,
|
|
5173
5182
|
icon: formIcon,
|
|
5174
5183
|
iconSource: iconResolution.source,
|
|
5175
5184
|
url: formUrl,
|
|
@@ -6176,6 +6185,7 @@ async function verifyCreatedFormSchema(authRef, appType, formUuid, fields) {
|
|
|
6176
6185
|
missingFieldCount: verified.missing.length, diagnostics: verified.conflicts,
|
|
6177
6186
|
});
|
|
6178
6187
|
}
|
|
6188
|
+
return readback.schema;
|
|
6179
6189
|
}
|
|
6180
6190
|
|
|
6181
6191
|
function isRetryableResumeSaveServerFailure(errorObject) {
|
|
@@ -6349,6 +6359,8 @@ async function mainResume(parsedArgs, authRef) {
|
|
|
6349
6359
|
});
|
|
6350
6360
|
}
|
|
6351
6361
|
completedStages.push('verify_final_schema');
|
|
6362
|
+
const defaultView = await configureCreatedFormView(authRef, appType, formUuid);
|
|
6363
|
+
completedStages.push('configure_default_view');
|
|
6352
6364
|
const { appUrl, formUrl } = buildFormDeliveryUrls(authRef.baseUrl, appType, formUuid);
|
|
6353
6365
|
const output = {
|
|
6354
6366
|
success: true,
|
|
@@ -6360,6 +6372,7 @@ async function mainResume(parsedArgs, authRef) {
|
|
|
6360
6372
|
addedFieldCount: plan.missing.length,
|
|
6361
6373
|
finalFieldCount: collectResumeFieldEvidence(finalContainer.children).length,
|
|
6362
6374
|
recoveredBlankShell,
|
|
6375
|
+
defaultView,
|
|
6363
6376
|
url: formUrl,
|
|
6364
6377
|
formUrl,
|
|
6365
6378
|
appUrl,
|
|
@@ -6587,6 +6600,7 @@ module.exports = {
|
|
|
6587
6600
|
run,
|
|
6588
6601
|
parseArgs,
|
|
6589
6602
|
_private: {
|
|
6603
|
+
readFieldsDefinition,
|
|
6590
6604
|
buildFormSchema,
|
|
6591
6605
|
buildEmptyFormSchema,
|
|
6592
6606
|
buildFormNodeComponent,
|
package/lib/app/form-view.js
CHANGED
|
@@ -9,8 +9,16 @@ const { t } = require('../core/i18n');
|
|
|
9
9
|
const { resolveProjectRoot } = require('../core/utils');
|
|
10
10
|
const { createAuthRef, createYidaClient } = require('../core/yida-client');
|
|
11
11
|
const { buildYidaTitleI18n } = require('../core/yida-i18n');
|
|
12
|
+
const { execute: executeCustomButton } = require('./custom-button');
|
|
12
13
|
|
|
13
|
-
const ACTIONS = ['list', 'inspect', 'save', 'create', 'order'];
|
|
14
|
+
const ACTIONS = ['list', 'inspect', 'save', 'create', 'order', 'rename', 'add-button'];
|
|
15
|
+
const VIEW_ACTIONS = ['inspect', 'save', 'rename', 'add-button'];
|
|
16
|
+
const SYSTEM_BUTTON_NAMES = {
|
|
17
|
+
detail: { zh_CN: '详情', en_US: 'Detail', ja_JP: '詳細' },
|
|
18
|
+
delete: { zh_CN: '删除', en_US: 'Delete', ja_JP: '削除' },
|
|
19
|
+
log: { zh_CN: '运行日志', en_US: 'Run Log', ja_JP: '実行ログ' },
|
|
20
|
+
var: { zh_CN: '变量', en_US: 'Variable', ja_JP: '変数' },
|
|
21
|
+
};
|
|
14
22
|
const object = value => value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
15
23
|
|
|
16
24
|
function fail(code, key, detail, details) {
|
|
@@ -67,6 +75,30 @@ function writableConfig(value) {
|
|
|
67
75
|
return { staticConfig: value.staticConfig, defaultConfig };
|
|
68
76
|
}
|
|
69
77
|
|
|
78
|
+
// Native button names gain derived English text and nullable i18n metadata on serialization.
|
|
79
|
+
function comparableButtonConfig(config) {
|
|
80
|
+
const result = writableConfig(config);
|
|
81
|
+
const buttonList = result.staticConfig.buttonList;
|
|
82
|
+
if (!Array.isArray(buttonList)) { return result; }
|
|
83
|
+
return {
|
|
84
|
+
...result,
|
|
85
|
+
staticConfig: {
|
|
86
|
+
...result.staticConfig,
|
|
87
|
+
buttonList: buttonList.map(button => {
|
|
88
|
+
if (!object(button?.name)) { return button; }
|
|
89
|
+
const { pureEn_US, ...name } = Object.fromEntries(
|
|
90
|
+
Object.entries(button.name).filter(([, value]) => value !== null && value !== undefined)
|
|
91
|
+
);
|
|
92
|
+
name.type ||= 'i18n';
|
|
93
|
+
const englishName = name.en_US || name.zh_CN;
|
|
94
|
+
if (englishName !== undefined) { name.en_US = englishName; }
|
|
95
|
+
if (pureEn_US !== undefined && pureEn_US !== name.en_US) { name.pureEn_US = pureEn_US; }
|
|
96
|
+
return { ...button, name };
|
|
97
|
+
}),
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
70
102
|
// Objects merge recursively; arrays and complete condition expressions replace.
|
|
71
103
|
function merge(base, patch) {
|
|
72
104
|
const result = { ...base };
|
|
@@ -120,7 +152,7 @@ function panelFields(panel) {
|
|
|
120
152
|
const visit = (items, parentId) => items.forEach(item => {
|
|
121
153
|
const id = item.componentId || item.id;
|
|
122
154
|
if (id) { fields.push({ id, parentId, name: item.varName, componentName: item.componentName,
|
|
123
|
-
supportVisible: item.supportVisible, showTerm: item.showTerm, operatorMap: item.operatorMap }); }
|
|
155
|
+
supportVisible: item.supportVisible, showTerm: item.showTerm, showOrder: item.showOrder, operatorMap: item.operatorMap }); }
|
|
124
156
|
if (Array.isArray(item.children)) { visit(item.children, id); }
|
|
125
157
|
});
|
|
126
158
|
visit(panel.componentValueVoList);
|
|
@@ -159,7 +191,7 @@ function parseArgs(args) {
|
|
|
159
191
|
for (let i = 0; i < args.length; i++) {
|
|
160
192
|
const arg = args[i];
|
|
161
193
|
if (['--json', '--with-config', '--replace', '--help', '-h'].includes(arg)) { flags[arg] = true; continue; }
|
|
162
|
-
if (['--config', '--name', '--expected-hash', '--backup'].includes(arg)) {
|
|
194
|
+
if (['--config', '--name', '--button', '--expected-hash', '--backup'].includes(arg)) {
|
|
163
195
|
if (!args[i + 1] || args[i + 1].startsWith('--')) { fail('USAGE', 'invalid_config', arg); }
|
|
164
196
|
flags[arg] = args[++i];
|
|
165
197
|
continue;
|
|
@@ -169,16 +201,26 @@ function parseArgs(args) {
|
|
|
169
201
|
}
|
|
170
202
|
if (flags['--help'] || flags['-h']) { return { help: true }; }
|
|
171
203
|
const [action, appType, formUuid, viewUuid] = positional;
|
|
172
|
-
if (!ACTIONS.includes(action) || !appType || !formUuid || positional.length > (
|
|
173
|
-
|| (
|
|
204
|
+
if (!ACTIONS.includes(action) || !appType || !formUuid || positional.length > (VIEW_ACTIONS.includes(action) ? 4 : 3)
|
|
205
|
+
|| (VIEW_ACTIONS.includes(action) && !viewUuid)
|
|
174
206
|
|| (['save', 'order'].includes(action) && !flags['--config'])
|
|
175
|
-
|| (
|
|
207
|
+
|| (['create', 'rename'].includes(action) && !flags['--name']?.trim())
|
|
208
|
+
|| (action === 'rename' && flags['--name'].trim().length > 20)
|
|
209
|
+
|| (action === 'add-button' && !flags['--button'])) {
|
|
176
210
|
fail('USAGE', 'usage');
|
|
177
211
|
}
|
|
178
|
-
const allowed = {
|
|
212
|
+
const allowed = {
|
|
213
|
+
list: ['--with-config'],
|
|
214
|
+
inspect: [],
|
|
215
|
+
save: ['--config', '--expected-hash', '--backup', '--replace'],
|
|
216
|
+
create: ['--name', '--backup'],
|
|
217
|
+
order: ['--config', '--backup'],
|
|
218
|
+
rename: ['--name', '--backup'],
|
|
219
|
+
'add-button': ['--button', '--expected-hash', '--backup'],
|
|
220
|
+
};
|
|
179
221
|
if (Object.keys(flags).some(flag => flag !== '--json' && !allowed[action].includes(flag))) { fail('USAGE', 'usage'); }
|
|
180
222
|
// IDs are path segments, never URLs or traversal components.
|
|
181
|
-
for (const id of [appType, formUuid, viewUuid].filter(Boolean)) {
|
|
223
|
+
for (const id of [appType, formUuid, viewUuid, flags['--button']].filter(Boolean)) {
|
|
182
224
|
if (!/^[A-Za-z0-9_-]+$/.test(id)) { fail('USAGE', 'invalid_config', id); }
|
|
183
225
|
}
|
|
184
226
|
return { action, appType, formUuid, viewUuid, flags };
|
|
@@ -201,11 +243,21 @@ function backup(value, filename) {
|
|
|
201
243
|
return output;
|
|
202
244
|
}
|
|
203
245
|
|
|
204
|
-
async function execute(parsed, client = createYidaClient({ authRef: createAuthRef() })) {
|
|
246
|
+
async function execute(parsed, client = createYidaClient({ authRef: createAuthRef() }), options = {}) {
|
|
205
247
|
const { action, appType, formUuid, viewUuid, flags } = parsed;
|
|
206
248
|
const prefix = `/dingtalk/web/${appType}/query/`;
|
|
207
|
-
const
|
|
249
|
+
const buttonUuid = flags['--button'];
|
|
250
|
+
const target = { appType, formUuid, ...(viewUuid ? { viewUuid } : {}), ...(buttonUuid ? { buttonUuid } : {}) };
|
|
208
251
|
const read = async (endpoint, params) => unwrap(await client.postForm(prefix + endpoint, params), endpoint);
|
|
252
|
+
const getNativeView = async () => {
|
|
253
|
+
const endpoint = 'dataview/listDataViewInForm.json';
|
|
254
|
+
const items = unwrap(await client.get(prefix + endpoint, { appType, formUuid }), endpoint);
|
|
255
|
+
if (!Array.isArray(items)) { fail('UNSUPPORTED', 'unsupported'); }
|
|
256
|
+
const matches = items.filter(item => item?.viewUuid === viewUuid && item.formUuid === formUuid);
|
|
257
|
+
if (matches.length !== 1) { fail('TARGET_MISMATCH', 'target_mismatch', viewUuid); }
|
|
258
|
+
const view = matches[0];
|
|
259
|
+
return { ...view, name: parseJson(view.name, 'name'), status: parseJson(view.status, 'status') };
|
|
260
|
+
};
|
|
209
261
|
const list = async () => {
|
|
210
262
|
const form = await read('formdesign/getFormSchemaInfo.json', { formUuid });
|
|
211
263
|
if (!object(form) || !Array.isArray(form.multiViewInfos)) { fail('UNSUPPORTED', 'unsupported'); }
|
|
@@ -219,7 +271,8 @@ async function execute(parsed, client = createYidaClient({ authRef: createAuthRe
|
|
|
219
271
|
const fields = async (id) => panelFields(unwrap(await client.get(prefix + 'dataview/getDataViewPanel.json', {
|
|
220
272
|
formUuid, viewUuid: id, pageType: 'manage', ccMode: 'tile',
|
|
221
273
|
}), 'dataview/getDataViewPanel.json'));
|
|
222
|
-
const
|
|
274
|
+
const nativeView = ['rename', 'add-button'].includes(action) ? await getNativeView() : null;
|
|
275
|
+
const views = nativeView ? [nativeView] : await list();
|
|
223
276
|
if (viewUuid && !views.some(view => view.viewUuid === viewUuid)) { fail('TARGET_MISMATCH', 'target_mismatch', viewUuid); }
|
|
224
277
|
const output = { success: true, action, ...target };
|
|
225
278
|
if (action === 'list') {
|
|
@@ -238,9 +291,54 @@ async function execute(parsed, client = createYidaClient({ authRef: createAuthRe
|
|
|
238
291
|
let endpoint;
|
|
239
292
|
let before;
|
|
240
293
|
let expected;
|
|
241
|
-
if (action === '
|
|
294
|
+
if (action === 'rename') {
|
|
295
|
+
before = nativeView;
|
|
296
|
+
if (!object(before.status)) { fail('UNSUPPORTED', 'unsupported'); }
|
|
297
|
+
const { zh_CN, en_US, ja_JP } = buildYidaTitleI18n(flags['--name'].trim());
|
|
298
|
+
expected = { type: 'i18n', zh_CN, en_US, ja_JP };
|
|
299
|
+
const matchesName = ['zh_CN', 'en_US', 'ja_JP'].every(key => before.name?.[key] === expected[key]);
|
|
300
|
+
if (matchesName && !before.name?.key) {
|
|
301
|
+
return { ...output, changed: false, readbackVerified: true, view: before };
|
|
302
|
+
}
|
|
303
|
+
if (!isDeepStrictEqual(await getNativeView(), before)) { fail('CONFLICT', 'conflict'); }
|
|
304
|
+
params = { formUuid, viewUuid, name: JSON.stringify(expected), status: JSON.stringify(before.status) };
|
|
305
|
+
if (before.description !== null && before.description !== undefined) {
|
|
306
|
+
params.description = typeof before.description === 'string' ? before.description : JSON.stringify(before.description);
|
|
307
|
+
}
|
|
308
|
+
endpoint = 'dataview/updateBaseInfo.json';
|
|
309
|
+
} else if (action === 'add-button') {
|
|
310
|
+
if (nativeView.viewType !== 'table') { fail('UNSUPPORTED', 'unsupported'); }
|
|
311
|
+
before = await get(viewUuid);
|
|
312
|
+
if (flags['--expected-hash'] && flags['--expected-hash'] !== configHash(before)) { fail('CONFLICT', 'conflict'); }
|
|
313
|
+
let buttonList = before.staticConfig.buttonList ?? [];
|
|
314
|
+
if (!Array.isArray(buttonList) || buttonList.some(item => !object(item))) { fail('UNSUPPORTED', 'unsupported'); }
|
|
315
|
+
const dataFormUuid = nativeView.dataFormUuid || formUuid;
|
|
316
|
+
const { button } = await executeCustomButton({ action: 'inspect', appType, formUuid: dataFormUuid, buttonUuid, flags: {} }, client);
|
|
317
|
+
if (!object(button.name)) { fail('UNSUPPORTED', 'unsupported'); }
|
|
318
|
+
if (buttonList.some(item => item.category === 'custom' && item.code === buttonUuid)) {
|
|
319
|
+
return { ...output, changed: false, readbackVerified: true, config: before, configHash: configHash(before) };
|
|
320
|
+
}
|
|
321
|
+
if (!buttonList.length) {
|
|
322
|
+
// The platform settings panel shows these system buttons when the list is empty.
|
|
323
|
+
const form = await read('formdesign/getFormSchemaInfo.json', { formUuid: dataFormUuid });
|
|
324
|
+
const formType = form?.formType || form?.pageType;
|
|
325
|
+
if (!['receipt', 'process'].includes(formType)) { fail('UNSUPPORTED', 'unsupported'); }
|
|
326
|
+
const codes = formType === 'process' ? ['detail', 'delete', 'log', 'var'] : ['detail', 'delete'];
|
|
327
|
+
buttonList = codes.map(code => ({ code, category: 'system', name: { type: 'i18n', ...SYSTEM_BUTTON_NAMES[code] } }));
|
|
328
|
+
}
|
|
329
|
+
const name = Object.fromEntries(['type', 'key', 'value', 'zh_CN', 'en_US', 'ja_JP']
|
|
330
|
+
.filter(key => button.name[key] !== null && button.name[key] !== undefined)
|
|
331
|
+
.map(key => [key, button.name[key]]));
|
|
332
|
+
expected = {
|
|
333
|
+
staticConfig: { ...before.staticConfig, buttonList: [...buttonList, { code: buttonUuid, category: 'custom', name }] },
|
|
334
|
+
defaultConfig: before.defaultConfig,
|
|
335
|
+
};
|
|
336
|
+
if (configHash(await get(viewUuid)) !== configHash(before)) { fail('CONFLICT', 'conflict'); }
|
|
337
|
+
params = { formUuid, viewUuid, staticConfig: JSON.stringify(expected.staticConfig) };
|
|
338
|
+
endpoint = 'dataview/updateConfig.json';
|
|
339
|
+
} else if (action === 'save') {
|
|
242
340
|
if (views.find(view => view.viewUuid === viewUuid).viewType !== 'table') { fail('UNSUPPORTED', 'unsupported'); }
|
|
243
|
-
const patch = validatePatch(parseJson(fs.readFileSync(flags['--config'], 'utf8'), 'config'));
|
|
341
|
+
const patch = validatePatch(options.configPatch ?? parseJson(fs.readFileSync(flags['--config'], 'utf8'), 'config'));
|
|
244
342
|
if (flags['--replace'] && (!patch.staticConfig || !patch.defaultConfig || !flags['--expected-hash'])) {
|
|
245
343
|
fail('INVALID_CONFIG', 'invalid_config', '--replace requires staticConfig, defaultConfig, --expected-hash');
|
|
246
344
|
}
|
|
@@ -295,9 +393,19 @@ async function execute(parsed, client = createYidaClient({ authRef: createAuthRe
|
|
|
295
393
|
throw new CliError(error.message, { code: error.code || 'FORM_VIEW_WRITE_FAILED', details: mutationDetails });
|
|
296
394
|
}
|
|
297
395
|
try {
|
|
298
|
-
if (action === '
|
|
396
|
+
if (action === 'rename') {
|
|
397
|
+
const view = await getNativeView();
|
|
398
|
+
if (!['zh_CN', 'en_US', 'ja_JP'].every(key => view.name?.[key] === expected[key])
|
|
399
|
+
|| !isDeepStrictEqual(view.status, before.status)
|
|
400
|
+
|| !isDeepStrictEqual(view.description ?? null, before.description ?? null)) {
|
|
401
|
+
fail('READBACK_MISMATCH', 'readback_mismatch');
|
|
402
|
+
}
|
|
403
|
+
return { ...output, changed: true, backupPath, readbackVerified: true, view };
|
|
404
|
+
}
|
|
405
|
+
if (action === 'save' || action === 'add-button') {
|
|
299
406
|
const config = await get(viewUuid);
|
|
300
|
-
|
|
407
|
+
const comparable = action === 'add-button' ? comparableButtonConfig : writableConfig;
|
|
408
|
+
if (!isDeepStrictEqual(stable(comparable(expected)), stable(comparable(config)))) {
|
|
301
409
|
fail('READBACK_MISMATCH', 'readback_mismatch');
|
|
302
410
|
}
|
|
303
411
|
return { ...output, changed: true, backupPath, readbackVerified: true, config, configHash: configHash(config) };
|
package/lib/app/publish.js
CHANGED
|
@@ -788,6 +788,12 @@ async function runMain(argv) {
|
|
|
788
788
|
let baseUrl = authRef.baseUrl;
|
|
789
789
|
await ensurePublishTargetOrExit(appType, formUuid, authRef, { force });
|
|
790
790
|
baseUrl = authRef.baseUrl;
|
|
791
|
+
if (isCanvas) {
|
|
792
|
+
await require('./services/field-bindings').verifyDeclaredBindings(sourceCode, (boundAppType, boundFormUuid) =>
|
|
793
|
+
requestWithAutoLogin(auth => httpGet(auth.baseUrl,
|
|
794
|
+
`/alibaba/web/${boundAppType}/_view/query/formdesign/getFormSchema.json`,
|
|
795
|
+
{ formUuid: boundFormUuid, schemaVersion: SCHEMA_VERSION }), authRef));
|
|
796
|
+
}
|
|
791
797
|
|
|
792
798
|
let schemaContent;
|
|
793
799
|
let expectedSchemaContent;
|
|
@@ -1,6 +1,98 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const { normalizeSchemaFields } = require('../schema-field-resolution');
|
|
4
|
+
const Babel = require('../../core/babel');
|
|
5
|
+
const { buildWriteContract } = require('../form-data-contract');
|
|
6
|
+
const { CliError } = require('../../core/cli-error');
|
|
7
|
+
const { t } = require('../../core/i18n');
|
|
8
|
+
|
|
9
|
+
function invalidBinding(details) {
|
|
10
|
+
throw new CliError(t('data_verify.binding_invalid'), { code: 'PAGE_DATA_BINDING_INVALID',
|
|
11
|
+
details: { ...details, remoteWrites: 0, nextStep: 'bind_real_schema_fields_and_options' } });
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Read JSON constants and aliases only; application code is never executed. */
|
|
15
|
+
function collectDeclaredBindings(source) {
|
|
16
|
+
const ast = Babel.packages.parser.parse(source, { sourceType: 'module', plugins: ['jsx', 'typescript'] });
|
|
17
|
+
const traverse = Babel.packages.traverse.default;
|
|
18
|
+
const unknown = Symbol('dynamic');
|
|
19
|
+
function literal(at, seen = new Set(), selectedKeys) {
|
|
20
|
+
if (!at?.node || seen.has(at.node) || seen.size > 40) {return unknown;}
|
|
21
|
+
seen = new Set(seen).add(at.node);
|
|
22
|
+
if (at.isStringLiteral() || at.isNumericLiteral() || at.isBooleanLiteral()) {return at.node.value;}
|
|
23
|
+
if (at.isNullLiteral()) {return null;}
|
|
24
|
+
if (at.isIdentifier()) {
|
|
25
|
+
const binding = at.scope.getBinding(at.node.name);
|
|
26
|
+
return binding?.constant && binding.path.isVariableDeclarator() && binding.path.parent.kind === 'const'
|
|
27
|
+
? literal(binding.path.get('init'), seen, selectedKeys) : unknown;
|
|
28
|
+
}
|
|
29
|
+
if (at.isMemberExpression()) {
|
|
30
|
+
const object = literal(at.get('object'), seen);
|
|
31
|
+
const key = at.node.computed ? literal(at.get('property'), seen) : at.node.property.name;
|
|
32
|
+
return object && typeof object === 'object' && Object.prototype.hasOwnProperty.call(object, key) ? object[key] : unknown;
|
|
33
|
+
}
|
|
34
|
+
if (at.isArrayExpression()) {
|
|
35
|
+
const items = at.get('elements').map(item => literal(item, seen));
|
|
36
|
+
return items.includes(unknown) ? unknown : items;
|
|
37
|
+
}
|
|
38
|
+
if (at.isObjectExpression()) {
|
|
39
|
+
const result = Object.create(null);
|
|
40
|
+
for (const item of at.get('properties')) {
|
|
41
|
+
if (item.isSpreadElement()) {
|
|
42
|
+
const spread = literal(item.get('argument'), seen, selectedKeys);
|
|
43
|
+
if (!spread || typeof spread !== 'object' || Array.isArray(spread)) {return unknown;}
|
|
44
|
+
Object.assign(result, spread);
|
|
45
|
+
} else if (item.isObjectProperty()) {
|
|
46
|
+
const key = item.node.computed ? literal(item.get('key'), seen) : item.node.key.name || item.node.key.value;
|
|
47
|
+
if (selectedKeys && key !== unknown && !selectedKeys.includes(key)) {continue;}
|
|
48
|
+
const value = literal(item.get('value'), seen);
|
|
49
|
+
if (key === unknown || value === unknown) {return unknown;}
|
|
50
|
+
result[key] = value;
|
|
51
|
+
} else {return unknown;}
|
|
52
|
+
}
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
return unknown;
|
|
56
|
+
}
|
|
57
|
+
const bindings = [];
|
|
58
|
+
traverse(ast, { ObjectExpression(at) {
|
|
59
|
+
const mode = at.get('properties').find(item => item.isObjectProperty() && !item.node.computed && (item.node.key.name || item.node.key.value) === 'mode');
|
|
60
|
+
const fields = at.get('properties').some(item => item.isObjectProperty() && !item.node.computed && (item.node.key.name || item.node.key.value) === 'fields');
|
|
61
|
+
if (!mode || !fields || !['form', 'process'].includes(literal(mode.get('value')))) {return;}
|
|
62
|
+
const value = literal(at, new Set(), ['mode', 'appType', 'formUuid', 'fields', 'optionValues']);
|
|
63
|
+
if (value === unknown || typeof value.appType !== 'string' || typeof value.formUuid !== 'string'
|
|
64
|
+
|| !value.fields || typeof value.fields !== 'object' || Array.isArray(value.fields)) {
|
|
65
|
+
invalidBinding({ reason: 'declared_binding_requires_static_resource_and_fields', line: at.node.loc?.start.line });
|
|
66
|
+
}
|
|
67
|
+
bindings.push(value);
|
|
68
|
+
} });
|
|
69
|
+
return bindings;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async function verifyDeclaredBindings(source, readSchema) {
|
|
73
|
+
const bindings = collectDeclaredBindings(source);
|
|
74
|
+
const schemas = new Map();
|
|
75
|
+
for (const binding of bindings) {
|
|
76
|
+
const key = JSON.stringify([binding.appType, binding.formUuid]);
|
|
77
|
+
if (!schemas.has(key)) {schemas.set(key, await readSchema(binding.appType, binding.formUuid));}
|
|
78
|
+
const schema = schemas.get(key);
|
|
79
|
+
if (schema?.success !== true) {invalidBinding({ formUuid: binding.formUuid, reason: 'schema_unavailable' });}
|
|
80
|
+
const verification = verifyFieldBindings(schema, binding.fields);
|
|
81
|
+
if (verification.missing.length || verification.mismatched.length) {
|
|
82
|
+
invalidBinding({ formUuid: binding.formUuid, ...verification });
|
|
83
|
+
}
|
|
84
|
+
const contract = buildWriteContract(schema);
|
|
85
|
+
for (const [semantic, values] of Object.entries(binding.optionValues || {})) {
|
|
86
|
+
const fieldId = normalizeExpectedBinding(binding.fields[semantic]).fieldId;
|
|
87
|
+
const options = contract.props[fieldId]?.dataSource;
|
|
88
|
+
const allowed = Array.isArray(options) ? options.map(item => typeof item === 'object' && item ? item.value : item) : [];
|
|
89
|
+
if (!fieldId || !Array.isArray(values) || values.some(value => !allowed.includes(value))) {
|
|
90
|
+
invalidBinding({ formUuid: binding.formUuid, fieldId, reason: 'option_value_mismatch', values, allowed });
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return { verifiedBindings: bindings.length, schemaReads: schemas.size };
|
|
95
|
+
}
|
|
4
96
|
|
|
5
97
|
function normalizeSchemaResult(schemaResult) {
|
|
6
98
|
if (schemaResult && schemaResult.content) {
|
|
@@ -65,4 +157,6 @@ function verifyFieldBindings(schemaResult, expectedBindings, options) {
|
|
|
65
157
|
|
|
66
158
|
module.exports = {
|
|
67
159
|
verifyFieldBindings,
|
|
160
|
+
collectDeclaredBindings,
|
|
161
|
+
verifyDeclaredBindings,
|
|
68
162
|
};
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
// This endpoint leaves data unset when there are no stored rows. Hidden-field
|
|
4
|
+
// filtering instead supplies data:[] with totalCount:0; that shape is ambiguous.
|
|
5
|
+
function isOmittedEmptySubformPage(response) {
|
|
6
|
+
const page = response && response.content;
|
|
7
|
+
return response?.success === true && page !== null && typeof page === 'object' && !Array.isArray(page)
|
|
8
|
+
&& page.currentPage === 1 && page.totalCount === 0
|
|
9
|
+
&& Object.keys(page).every(key => ['idCursor', 'currentPage', 'totalCount'].includes(key))
|
|
10
|
+
&& !['data', 'dataList', 'rows'].some(key => Object.prototype.hasOwnProperty.call(page, key));
|
|
11
|
+
}
|
|
12
|
+
|
|
3
13
|
// Kept in sync with the standalone Canvas sample; no network or guessed clears.
|
|
4
14
|
function readCanvasSubformRows(row, fieldId) {
|
|
5
15
|
const own = (value, key) => Object.prototype.hasOwnProperty.call(value, key);
|
|
@@ -57,4 +67,4 @@ function readCanvasSubformRows(row, fieldId) {
|
|
|
57
67
|
return { status: 'ready', rows, error: null };
|
|
58
68
|
}
|
|
59
69
|
|
|
60
|
-
module.exports = { readCanvasSubformRows };
|
|
70
|
+
module.exports = { readCanvasSubformRows, isOmittedEmptySubformPage };
|
package/lib/app/update-app.js
CHANGED
|
@@ -390,7 +390,7 @@ function requireAppStyleConfirmation(params, app) {
|
|
|
390
390
|
}
|
|
391
391
|
|
|
392
392
|
async function checkAppStyleInjection(params, authRef) {
|
|
393
|
-
//
|
|
393
|
+
// Validate the appType and login snapshot before writing app-level CSS.
|
|
394
394
|
// Never open /admin or follow a browser login redirect to validate an API write.
|
|
395
395
|
const app = await fetchCurrentApp(params.appType, authRef, true);
|
|
396
396
|
requireAppStyleConfirmation(params, app);
|