openyida 2026.11.5 → 2026.11.7

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.
Files changed (49) hide show
  1. package/README.md +8 -4
  2. package/bin/yida.js +19 -3
  3. package/lib/app/create-form/batch.js +10 -1
  4. package/lib/app/create-form/default-view.js +50 -0
  5. package/lib/app/create-form.js +16 -2
  6. package/lib/app/form-view.js +2 -2
  7. package/lib/app/publish.js +6 -0
  8. package/lib/app/services/field-bindings.js +94 -0
  9. package/lib/app/subform-readback.js +11 -1
  10. package/lib/auth/dingtalk-login.js +78 -0
  11. package/lib/auth/oauth-loopback.js +4 -0
  12. package/lib/auth/token-auth.js +4 -18
  13. package/lib/core/babel.js +7 -2
  14. package/lib/core/command-manifest.js +14 -9
  15. package/lib/core/data-seed.js +29 -23
  16. package/lib/core/env-cmd.js +1 -1
  17. package/lib/core/env-manager.js +4 -21
  18. package/lib/core/locales/en.js +14 -2
  19. package/lib/core/locales/zh.js +14 -2
  20. package/lib/core/query-data.js +55 -20
  21. package/lib/process/configure-process.js +16 -5
  22. package/lib/process/create-process.js +7 -1
  23. package/lib/process/process-diagnostics.js +5 -1
  24. package/lib/process/services/process-compiler.js +18 -75
  25. package/lib/process/services/process-form-fields.js +54 -1
  26. package/lib/process/services/process-view-verifier.js +29 -0
  27. package/lib/samples/openyida-scaffold/canvas-data-source.jsx +74 -5
  28. package/package.json +1 -1
  29. package/yida-skills/SKILL.md +1 -1
  30. package/yida-skills/skills/yida-app/SKILL.md +5 -5
  31. package/yida-skills/skills/yida-app/workflow/fast-build.md +2 -2
  32. package/yida-skills/skills/yida-app/workflow/step-4-forms-processes.md +2 -2
  33. package/yida-skills/skills/yida-app/workflow/step-5-seed-records.md +17 -42
  34. package/yida-skills/skills/yida-app/workflow/step-7-page-code.md +1 -1
  35. package/yida-skills/skills/yida-app/workflow/step-9-output-finish.md +1 -1
  36. package/yida-skills/skills/yida-canvas-custom-page/SKILL.md +3 -3
  37. package/yida-skills/skills/yida-canvas-custom-page/references/data-bridge-guide.md +3 -3
  38. package/yida-skills/skills/yida-canvas-custom-page/references/page-generation-guide.md +3 -3
  39. package/yida-skills/skills/yida-canvas-data-binding/SKILL.md +14 -6
  40. package/yida-skills/skills/yida-create-form-page/SKILL.md +1 -0
  41. package/yida-skills/skills/yida-create-process/SKILL.md +59 -207
  42. package/yida-skills/skills/yida-data-management/SKILL.md +47 -158
  43. package/yida-skills/skills/yida-data-management/references/data-format-guide.md +14 -5
  44. package/yida-skills/skills/yida-data-management/references/process-seed-workflow.md +31 -0
  45. package/yida-skills/skills/yida-flow-node-config/references/conditions-variables.md +2 -0
  46. package/yida-skills/skills/yida-form-view/SKILL.md +4 -5
  47. package/yida-skills/skills/yida-login/SKILL.md +5 -1
  48. package/yida-skills/skills/yida-process-rule/SKILL.md +6 -4
  49. package/yida-skills/skills-index.json +4 -2
package/README.md CHANGED
@@ -278,6 +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 seed process APP_XXX FORM_XXX --process-code TPROC_XXX --expect-form-name 申请 --records-file .cache/openyida/data-import/applications.json --json
281
282
  openyida get-permission APP_XXX FORM_XXX
282
283
  ```
283
284
 
@@ -285,6 +286,9 @@ openyida get-permission APP_XXX FORM_XXX
285
286
 
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.
287
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
+
288
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#组件支持与未适配配置).
289
293
 
290
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.
@@ -480,7 +484,7 @@ When preparing a PR that needs a personal Fork, or when you ask how to support t
480
484
 
481
485
  | Command | Description |
482
486
  |---------|-------------|
483
- | `openyida login [--qwenwork] [target-url] [--env <name>\|--intl\|--overseas\|--global\|--yidaapps\|--alibaba] [--client-id <clientId>] [--endpoint <url>] [--no-browser]` | Login with OAuth token mode |
487
+ | `openyida login [--qwenwork] [target-url] [--env <name>\|--intl\|--overseas\|--global\|--yidaapps\|--alibaba] [--dingtalk <domestic\|intl>] [--client-id <clientId>] [--endpoint <url>] [--no-browser]` | Login with OAuth token mode |
484
488
  | `openyida logout` | Logout / unbind current project auth |
485
489
  | `openyida auth <status\|login\|refresh\|logout\|profiles\|profile switch\|qwenwork user-info> [--json]` | Token login state and profile management |
486
490
  | `openyida org <list\|switch> [--json] [--corp-id <corpId>] [--no-browser]` | Organization management (list / switch existing profiles first) |
@@ -574,8 +578,8 @@ When preparing a PR that needs a personal Fork, or when you ask how to support t
574
578
 
575
579
  | Command | Description |
576
580
  |---------|-------------|
577
- | `openyida configure-process <appType> <formUuid> <definition> [processCode] [--replace]` | Configure and publish process rules; Supports append/forward via JSON nodes[].actions.normalActions/appendActions |
578
- | `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 |
579
583
  | `openyida ai-form-setting <get\|fields\|models\|enable\|disable\|save> <appType> ...` | Manage process form AI approval prompts |
580
584
  | `openyida process preview <appType> ...` | Preview process instance (visual flowchart) |
581
585
  | `openyida process fields <appType> <formUuid> [--json]` | Check process designer field loading and subtable field paths |
@@ -710,7 +714,7 @@ The opt-in `node scripts/e2e-real/connector/action-update-runner.js` regression
710
714
 
711
715
  #### Environment and Localization
712
716
 
713
- Environment selectors such as `--env intl`, `--intl`, `--overseas`, `--global`, and `--yidaapps` can be used on login-required commands to choose the target Yida environment for that run. The `intl` preset uses `https://www.yidaapps.com` as the built-in Global YiDA entrypoint (not the bare `https://yidaapps.com` domain) and DingTalk International OAuth at `https://login.dingtalk.io`; business API requests still use the authenticated environment `baseUrl`, so customer custom subdomains are supported.
717
+ Environment selectors such as `--env intl`, `--intl`, `--overseas`, `--global`, and `--yidaapps` choose the target YiDA environment for that run. `openyida login --intl` selects Global YiDA at `https://www.yidaapps.com`. In an interactive terminal, login offers domestic DingTalk for overseas YiDA (`login.dingtalk.com`, default) or DingTalk International for overseas YiDA (`login.dingtalk.io`). Press Enter to use domestic DingTalk, or pass `--dingtalk domestic` / `--dingtalk intl` explicitly. Non-interactive calls default to domestic DingTalk. Selecting the overseas YiDA site does not select the DingTalk account system. The CLI retains its local OAuth callback and token session; business API requests use the authenticated environment `baseUrl`, including supported customer custom subdomains.
714
718
 
715
719
  For overseas apps, pass `--locale en_US` or `--locale ja_JP` on creation commands, or set `OPENYIDA_CONTENT_LOCALE`. OpenYida writes YiDA resource names with `zh_CN`, `en_US`, and `ja_JP` values so Global YiDA does not fall back to Chinese-only metadata.
716
720
 
package/bin/yida.js CHANGED
@@ -280,6 +280,7 @@ function getFirstPositionalArg(cliArgs, startIndex = 0) {
280
280
  '--login-url',
281
281
  '--profile',
282
282
  '--user-id',
283
+ '--dingtalk',
283
284
  ]);
284
285
  for (let index = startIndex; index < cliArgs.length; index++) {
285
286
  const arg = cliArgs[index];
@@ -370,6 +371,14 @@ function applyLoginTargetUrl(value) {
370
371
  return true;
371
372
  }
372
373
 
374
+ function applyLoginEnvironmentName(envName) {
375
+ process.env.OPENYIDA_ENV = envName;
376
+ const { resolveEnvNameAlias, INTERNATIONAL_BASE_URL } = require('../lib/core/env-manager');
377
+ if (resolveEnvNameAlias(envName) === 'intl' && (command === 'login' || (command === 'auth' && rawArgs[0] === 'login'))) {
378
+ applyLoginTargetUrl(INTERNATIONAL_BASE_URL);
379
+ }
380
+ }
381
+
373
382
  function applyLoginEnvironmentFlags(cliArgs, options = {}) {
374
383
  const envFlagMap = {
375
384
  '--public': 'public',
@@ -387,6 +396,7 @@ function applyLoginEnvironmentFlags(cliArgs, options = {}) {
387
396
  '--client-id',
388
397
  '--profile',
389
398
  '--user-id',
399
+ '--dingtalk',
390
400
  ]);
391
401
  const targetUrlFlags = new Set([
392
402
  '--endpoint',
@@ -401,7 +411,7 @@ function applyLoginEnvironmentFlags(cliArgs, options = {}) {
401
411
  if (arg === '--env') {
402
412
  const envName = cliArgs[index + 1];
403
413
  if (envName && !envName.startsWith('--')) {
404
- process.env.OPENYIDA_ENV = envName;
414
+ applyLoginEnvironmentName(envName);
405
415
  index++;
406
416
  }
407
417
  continue;
@@ -422,7 +432,7 @@ function applyLoginEnvironmentFlags(cliArgs, options = {}) {
422
432
  continue;
423
433
  }
424
434
  if (envFlagMap[arg]) {
425
- process.env.OPENYIDA_ENV = envFlagMap[arg];
435
+ applyLoginEnvironmentName(envFlagMap[arg]);
426
436
  continue;
427
437
  }
428
438
  if (inferTargetUrl && !arg.startsWith('--') && applyLoginTargetUrl(arg)) {
@@ -534,11 +544,17 @@ function printManifestCommandHelp(commandName) {
534
544
  }
535
545
 
536
546
  function printLoginHelp() {
537
- printCommandUsage(t('cli.login_usage'), t('cli.login_example'));
547
+ printCommandUsage(t('cli.login_usage'), t('cli.login_example'), t('dingtalk_login.help'));
538
548
  }
539
549
 
540
550
  function buildTokenLoginOptions(loginArgs) {
551
+ const dingtalkIndex = loginArgs.indexOf('--dingtalk');
552
+ const dingtalkVersion = dingtalkIndex < 0 ? undefined : loginArgs[dingtalkIndex + 1];
553
+ if (dingtalkIndex >= 0 && !['domestic', 'intl'].includes(dingtalkVersion)) {
554
+ throwCliUsage(t('dingtalk_login.invalid_version'));
555
+ }
541
556
  return {
557
+ dingtalkVersion,
542
558
  clientId: getArgValue(loginArgs, '--client-id'),
543
559
  corpId: getArgValue(loginArgs, '--corp-id'),
544
560
  userId: getArgValue(loginArgs, '--user-id'),
@@ -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 };
@@ -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,
@@ -243,7 +243,7 @@ function backup(value, filename) {
243
243
  return output;
244
244
  }
245
245
 
246
- async function execute(parsed, client = createYidaClient({ authRef: createAuthRef() })) {
246
+ async function execute(parsed, client = createYidaClient({ authRef: createAuthRef() }), options = {}) {
247
247
  const { action, appType, formUuid, viewUuid, flags } = parsed;
248
248
  const prefix = `/dingtalk/web/${appType}/query/`;
249
249
  const buttonUuid = flags['--button'];
@@ -338,7 +338,7 @@ async function execute(parsed, client = createYidaClient({ authRef: createAuthRe
338
338
  endpoint = 'dataview/updateConfig.json';
339
339
  } else if (action === 'save') {
340
340
  if (views.find(view => view.viewUuid === viewUuid).viewType !== 'table') { fail('UNSUPPORTED', 'unsupported'); }
341
- const patch = validatePatch(parseJson(fs.readFileSync(flags['--config'], 'utf8'), 'config'));
341
+ const patch = validatePatch(options.configPatch ?? parseJson(fs.readFileSync(flags['--config'], 'utf8'), 'config'));
342
342
  if (flags['--replace'] && (!patch.staticConfig || !patch.defaultConfig || !flags['--expected-hash'])) {
343
343
  fail('INVALID_CONFIG', 'invalid_config', '--replace requires staticConfig, defaultConfig, --expected-hash');
344
344
  }
@@ -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 };
@@ -0,0 +1,78 @@
1
+ 'use strict';
2
+
3
+ const readline = require('readline');
4
+ const { t } = require('../core/i18n');
5
+ const { CliError } = require('../core/cli-error');
6
+ const {
7
+ DINGTALK_LOGIN_ORIGIN,
8
+ DINGTALK_INTL_LOGIN_ORIGIN,
9
+ isYidaAppsHost,
10
+ } = require('../core/env-manager');
11
+
12
+ function originForVersion(version) {
13
+ if (version === 'domestic') { return DINGTALK_LOGIN_ORIGIN; }
14
+ if (version === 'intl') { return DINGTALK_INTL_LOGIN_ORIGIN; }
15
+ throw new CliError(t('dingtalk_login.invalid_version'), { code: 'INVALID_ARGUMENTS' });
16
+ }
17
+
18
+ function explicitLoginOrigin(value) {
19
+ try {
20
+ const origin = new URL(value).origin;
21
+ if ([DINGTALK_LOGIN_ORIGIN, DINGTALK_INTL_LOGIN_ORIGIN].includes(origin)) {
22
+ return origin;
23
+ }
24
+ } catch {
25
+ // A service entry URL does not select the DingTalk account system.
26
+ }
27
+ return null;
28
+ }
29
+
30
+ async function selectDingtalkLoginOrigin(options = {}) {
31
+ if (options.dingtalkVersion !== undefined) {
32
+ return originForVersion(options.dingtalkVersion);
33
+ }
34
+ if (options.loginOrigin) {
35
+ const origin = explicitLoginOrigin(options.loginOrigin);
36
+ if (!origin) {
37
+ throw new CliError(t('dingtalk_login.invalid_origin'), { code: 'INVALID_ARGUMENTS' });
38
+ }
39
+ return origin;
40
+ }
41
+ const env = options.env || process.env;
42
+ const explicitOrigin = explicitLoginOrigin(options.loginUrl || env.OPENYIDA_LOGIN_URL);
43
+ if (explicitOrigin) { return explicitOrigin; }
44
+
45
+ const input = options.input || process.stdin;
46
+ const output = options.output || process.stderr;
47
+ if (!isYidaAppsHost(options.baseUrl) || options.quiet || !input.isTTY || !output.isTTY) {
48
+ return DINGTALK_LOGIN_ORIGIN;
49
+ }
50
+
51
+ const rl = readline.createInterface({ input, output });
52
+ output.write(`${t('dingtalk_login.select_version')}\n1. ${t('dingtalk_login.domestic')}\n2. ${t('dingtalk_login.international')}\n`);
53
+ try {
54
+ return await new Promise((resolve, reject) => {
55
+ let settled = false;
56
+ rl.once('close', () => {
57
+ if (!settled) {
58
+ reject(new CliError(t('dingtalk_login.cancelled'), { code: 'LOGIN_CANCELLED' }));
59
+ }
60
+ });
61
+ const ask = () => rl.question(t('dingtalk_login.choose'), answer => {
62
+ const choice = answer.trim();
63
+ if (choice === '' || choice === '1' || choice === '2') {
64
+ settled = true;
65
+ resolve(choice === '2' ? DINGTALK_INTL_LOGIN_ORIGIN : DINGTALK_LOGIN_ORIGIN);
66
+ } else {
67
+ output.write(`${t('dingtalk_login.invalid_choice')}\n`);
68
+ ask();
69
+ }
70
+ });
71
+ ask();
72
+ });
73
+ } finally {
74
+ rl.close();
75
+ }
76
+ }
77
+
78
+ module.exports = { selectDingtalkLoginOrigin };
@@ -456,6 +456,9 @@ function buildDingtalkOAuthUrl(options) {
456
456
  if (prompt) {
457
457
  url.searchParams.set('prompt', prompt);
458
458
  }
459
+ if (options.forceLogin) {
460
+ url.searchParams.set('FEForceLogin', 'true');
461
+ }
459
462
  return url.toString();
460
463
  }
461
464
 
@@ -694,6 +697,7 @@ function runDingtalkLoopback(options = {}) {
694
697
  redirectUri,
695
698
  state,
696
699
  loginOrigin: options.loginOrigin,
700
+ forceLogin: options.forceLogin,
697
701
  scope: options.scope,
698
702
  prompt: options.prompt,
699
703
  });
@@ -7,12 +7,12 @@ const https = require('https');
7
7
 
8
8
  const {
9
9
  DINGTALK_OAUTH_CLIENT_ID,
10
- DINGTALK_LOGIN_ORIGIN,
11
10
  DINGTALK_INTL_LOGIN_ORIGIN,
12
11
  getCurrentEnvConfig,
13
12
  normalizeBaseUrl,
14
13
  } = require('../core/env-manager');
15
14
  const { runDingtalkLoopback } = require('./oauth-loopback');
15
+ const { selectDingtalkLoginOrigin } = require('./dingtalk-login');
16
16
  const {
17
17
  clearTokenSession,
18
18
  deleteUserAuthProfile,
@@ -71,22 +71,6 @@ function resolveTokenBaseUrl(options = {}) {
71
71
  return baseUrl;
72
72
  }
73
73
 
74
- function resolveDingtalkLoginOrigin(options = {}) {
75
- if (options.loginOrigin) {
76
- return options.loginOrigin;
77
- }
78
- try {
79
- const { config } = getCurrentEnvConfig(options.projectRoot);
80
- const baseUrl = normalizeBaseUrl(config.baseUrl, '');
81
- if (baseUrl && baseUrl.includes('yidaapps.com')) {
82
- return DINGTALK_INTL_LOGIN_ORIGIN;
83
- }
84
- } catch {
85
- // Fall back to domestic DingTalk login.
86
- }
87
- return DINGTALK_LOGIN_ORIGIN;
88
- }
89
-
90
74
  function requestJson(method, url, body, headers = {}) {
91
75
  return new Promise((resolve, reject) => {
92
76
  const parsedUrl = new URL(url);
@@ -328,9 +312,11 @@ async function tokenLogin(options = {}) {
328
312
  const baseUrl = resolveTokenBaseUrl(options);
329
313
  const authBaseUrl = appendPath(baseUrl, DEFAULT_AUTH_PATH_PREFIX);
330
314
  const clientId = options.clientId || process.env.OPENYIDA_DINGTALK_CLIENT_ID || DINGTALK_OAUTH_CLIENT_ID;
315
+ const loginOrigin = await selectDingtalkLoginOrigin({ ...options, baseUrl });
331
316
  const callback = await runDingtalkLoopback({
332
317
  clientId,
333
- loginOrigin: resolveDingtalkLoginOrigin(options),
318
+ loginOrigin,
319
+ forceLogin: loginOrigin === DINGTALK_INTL_LOGIN_ORIGIN,
334
320
  scope: options.scope || process.env.OPENYIDA_DINGTALK_SCOPE || 'openid corpid',
335
321
  prompt: options.prompt,
336
322
  port: options.port,
package/lib/core/babel.js CHANGED
@@ -2,9 +2,14 @@
2
2
 
3
3
  const { transformSync } = require('@babel/core');
4
4
 
5
- // Compile user page source without loading Babel configuration from its project.
5
+ // Keep compilation independent of project Babel and Browserslist configuration.
6
6
  function transform(source, options = {}) {
7
- return transformSync(source, { ...options, babelrc: false, configFile: false });
7
+ return transformSync(source, {
8
+ ...options,
9
+ babelrc: false,
10
+ configFile: false,
11
+ browserslistConfigFile: false,
12
+ });
8
13
  }
9
14
 
10
15
  module.exports = {