openyida 2026.9.7-beta.0 → 2026.9.8-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/README.md +4 -1
  2. package/lib/app/canvas-compile.js +4 -37
  3. package/lib/app/create-form/args.js +36 -2
  4. package/lib/app/create-form/batch.js +24 -7
  5. package/lib/app/create-form/commands.js +2 -0
  6. package/lib/app/create-form.js +292 -0
  7. package/lib/app/display-page-readback.js +5 -63
  8. package/lib/app/get-schema.js +5 -158
  9. package/lib/app/publish.js +5 -127
  10. package/lib/app/update-app.js +8 -2
  11. package/lib/core/command-manifest.js +4 -1
  12. package/lib/core/locales/en.js +17 -13
  13. package/lib/core/locales/zh.js +17 -13
  14. package/lib/core/utils.js +0 -358
  15. package/lib/integration/integration-create.js +151 -4
  16. package/lib/integration/integration-diagnostics.js +12 -12
  17. package/lib/integration/integration-form-metadata.js +136 -0
  18. package/lib/integration/integration-process-builder.js +31 -4
  19. package/lib/integration/integration-spec-builder.js +570 -73
  20. package/lib/integration/integration-view-builder.js +240 -15
  21. package/lib/process/configure-process.js +18 -1
  22. package/package.json +1 -1
  23. package/yida-skills/SKILL.md +1 -0
  24. package/yida-skills/skills/yida-app/workflow/plan/step-4-deliver.md +3 -3
  25. package/yida-skills/skills/yida-app/workflow/step-4-forms-processes.md +2 -2
  26. package/yida-skills/skills/yida-app/workflow/step-9-output-finish.md +2 -0
  27. package/yida-skills/skills/yida-create-form-page/SKILL.md +17 -3
  28. package/yida-skills/skills/yida-design/references/ask-human-interaction-contract.md +18 -4
  29. package/yida-skills/skills/yida-integration/SKILL.md +44 -5
  30. package/yida-skills/skills/yida-integration/references/integration-node-schemas.md +21 -0
package/README.md CHANGED
@@ -174,6 +174,8 @@ openyida update-app APP_XXX --theme-file .cache/openyida/crm/app-theme.css --nav
174
174
  openyida corp-efficiency
175
175
  openyida create-form create APP_XXX "Customer" .cache/openyida/forms/customer-fields.json
176
176
  openyida create-form update APP_XXX FORM_XXX .cache/openyida/forms/customer-changes.json
177
+ openyida create-form update APP_XXX FORM_XXX --data-file .cache/openyida/forms/customer-changes.json
178
+ openyida create-form resume APP_XXX FORM_XXX .cache/openyida/forms/customer-fields.json --json
177
179
  openyida sample openyida-page-template form-fields --output .cache/openyida/forms/customer-fields.json
178
180
  openyida sample openyida-page-template canvas-form-drawer --output project/pages/src/customer-entry.canvas.jsx --var APP_TYPE=APP_XXX --var FORM_UUID=FORM_XXX
179
181
  openyida get-schema APP_XXX FORM_XXX
@@ -413,7 +415,8 @@ Run `openyida --help` or `openyida <command> --help` for detailed usage.
413
415
  | `openyida create-form create <appType> "<formTitle>" <fieldsJsonFile> [--icon auto\|<iconName>] [--locale zh_CN\|en_US\|ja_JP] [--open\|--no-open]` | Create a form page |
414
416
  | `openyida create-form icons [--json]` | List available form navigation icons |
415
417
  | `openyida create-form validate-fields <fieldsJsonOrFile> [--json]` | Validate form field JSON locally |
416
- | `openyida create-form update <appType> ... [--locale zh_CN\|en_US\|ja_JP] [--open\|--no-open]` | Update a form page |
418
+ | `openyida create-form update <appType> <formUuid> (<changesJsonOrFile> \| --data-file <changesJsonOrFile>) [--locale zh_CN\|en_US\|ja_JP] [--open\|--no-open]` | Update a form page |
419
+ | `openyida create-form resume <appType> <formUuid> <fieldsJsonOrFile> [--json]` | Update a form page |
417
420
  | `openyida create-form patch <appType> <formUuid> <patchJsonOrFile> [--open\|--no-open]` | Update a form page |
418
421
  | `openyida create-form rule <appType> <formUuid> <rulesJsonOrFile> [--open\|--no-open]` | Update a form page |
419
422
  | `openyida create-form validation <appType> <formUuid> <validationsJsonOrFile> [--open\|--no-open]` | Update a form page |
@@ -24,13 +24,12 @@
24
24
  * 3) 第三方依赖以 `window.<别名>` 形式引用(antd→window.antd、react→window.React …),
25
25
  * 这些 UMD 依赖由画布运行时依据 importedModules 白名单按需注入。
26
26
  *
27
- * 因此本地编译 = Babel 把 JSX/TS 转成 JS → 把 import 改写成 window 别名引用、
28
- * 把 export default 改写成画布入口 `YidaComp` → UglifyJS 压缩 → 正则抽出依赖包名。
27
+ * 因此本地编译 = Babel 把 JSX/TS 转成 ES5 → 把 import 改写成 window 别名引用、
28
+ * 把 export default 改写成画布入口 `YidaComp` → 正则抽出依赖包名。
29
29
  */
30
30
 
31
31
  const Babel = require('@babel/standalone');
32
32
  const globals = require('globals');
33
- const UglifyJS = require('uglify-js');
34
33
  const {
35
34
  assertNoEmojiInArtifactName,
36
35
  assertNoEmojiInText,
@@ -878,36 +877,6 @@ function assertCanvasRuntimeParseable(runtimeCode, options = {}) {
878
877
  }
879
878
  }
880
879
 
881
- /**
882
- * 压缩画布运行态代码,并显式保留装配器读取的 YidaComp 入口名。
883
- */
884
- function minifyCanvasRuntime(runtimeCode, options = {}) {
885
- let result;
886
- try {
887
- result = UglifyJS.minify(runtimeCode, {
888
- compress: true,
889
- mangle: {
890
- reserved: ['YidaComp'],
891
- },
892
- });
893
- } catch (error) {
894
- result = { error };
895
- }
896
- if (!result || result.error || typeof result.code !== 'string' || !result.code) {
897
- const detail = result && result.error && result.error.message
898
- ? result.error.message
899
- : '压缩结果为空';
900
- throw new CliError(`Code Canvas runtimeCode 压缩失败: ${detail}`, {
901
- code: 'OPENYIDA_CANVAS_MINIFY_FAILED',
902
- details: {
903
- stage: 'canvas_minify',
904
- sourcePath: options.sourcePath || '',
905
- },
906
- });
907
- }
908
- return result.code;
909
- }
910
-
911
880
  /**
912
881
  * 本地编译 Code Canvas 源码。
913
882
  * @param {string} source 原始 React/JSX/TSX 源码
@@ -1015,12 +984,11 @@ function compileCanvasLocal(source, options = {}) {
1015
984
  configFile: false,
1016
985
  });
1017
986
 
1018
- const unminifiedRuntimeCode = stage2.code || '';
1019
- assertNoEmojiInText(unminifiedRuntimeCode, {
987
+ const runtimeCode = stage2.code || '';
988
+ assertNoEmojiInText(runtimeCode, {
1020
989
  artifact: options.sourcePath ? options.sourcePath + ' runtime' : 'Code Canvas runtime',
1021
990
  code: 'OPENYIDA_CANVAS_SOURCE_EMOJI_FORBIDDEN',
1022
991
  });
1023
- const runtimeCode = minifyCanvasRuntime(unminifiedRuntimeCode, options);
1024
992
  assertCanvasRuntimeParseable(runtimeCode, options);
1025
993
  assertDependencyManifestConsistent(runtimeCode, importedModules, options);
1026
994
  return {
@@ -1088,7 +1056,6 @@ module.exports = {
1088
1056
  resolveWindowAlias,
1089
1057
  shouldAllowUnsupportedBareImports,
1090
1058
  assertCanvasRuntimeParseable,
1091
- minifyCanvasRuntime,
1092
1059
  findBareDependencyGlobalIssues,
1093
1060
  findSelfReferentialDependencyBindingIssues,
1094
1061
  findDependencyManifestIssues,
@@ -89,6 +89,7 @@ function createParseArgs(dependencies) {
89
89
  contentLocale: null,
90
90
  browserOpenMode: openOption.mode,
91
91
  };
92
+ let dataFileInput;
92
93
 
93
94
  const args = [...rawArgs];
94
95
 
@@ -111,6 +112,14 @@ function createParseArgs(dependencies) {
111
112
  i--;
112
113
  } else if (args[i] === '--icon') {
113
114
  throwCreateFormError('--icon requires a value', 'CREATE_FORM_INVALID_ARGUMENTS');
115
+ } else if (args[i] === '--data-file') {
116
+ const next = args[i + 1];
117
+ if (dataFileInput !== undefined || !next || next.startsWith('--')) {
118
+ throwCreateFormError('--data-file requires exactly one value', 'CREATE_FORM_INVALID_ARGUMENTS');
119
+ }
120
+ dataFileInput = next;
121
+ args.splice(i, 2);
122
+ i--;
114
123
  } else if ((args[i] === '--locale' || args[i] === '--content-locale' || args[i] === '--lang') && i + 1 < args.length) {
115
124
  options.contentLocale = args[i + 1];
116
125
  if (!normalizeYidaLocale(options.contentLocale)) {
@@ -145,6 +154,10 @@ function createParseArgs(dependencies) {
145
154
 
146
155
  const mode = args[0];
147
156
 
157
+ if (dataFileInput !== undefined && mode !== 'update') {
158
+ throwCreateFormError('--data-file is only supported by create-form update', 'CREATE_FORM_INVALID_ARGUMENTS');
159
+ }
160
+
148
161
  if (mode === 'icons' || mode === 'list-icons') {
149
162
  return {
150
163
  mode: 'icons',
@@ -182,7 +195,12 @@ function createParseArgs(dependencies) {
182
195
  }
183
196
 
184
197
  if (mode === 'update') {
185
- if (args.length < 4) {
198
+ const positionalInput = args[3];
199
+ if (args.length > 4 || (positionalInput && dataFileInput !== undefined)) {
200
+ throwCreateFormError('Use either <changesJsonOrFile> or --data-file, not both', 'CREATE_FORM_INVALID_ARGUMENTS');
201
+ }
202
+ const changesJsonOrFile = dataFileInput !== undefined ? dataFileInput : positionalInput;
203
+ if (args.length < 3 || !changesJsonOrFile) {
186
204
  usage(t('create_form.usage_update'), t('create_form.example_update'));
187
205
  throwCreateFormError(t('create_form.usage_update'), 'CREATE_FORM_INVALID_ARGUMENTS');
188
206
  }
@@ -190,7 +208,23 @@ function createParseArgs(dependencies) {
190
208
  mode: 'update',
191
209
  appType: args[1],
192
210
  formUuid: args[2],
193
- changesJsonOrFile: args[3],
211
+ changesJsonOrFile,
212
+ ...options
213
+ };
214
+ }
215
+
216
+ if (mode === 'resume') {
217
+ if (args.length !== 4) {
218
+ throwCreateFormError(
219
+ 'openyida create-form resume <appType> <formUuid> <fieldsJsonOrFile> --json',
220
+ 'CREATE_FORM_INVALID_ARGUMENTS'
221
+ );
222
+ }
223
+ return {
224
+ mode: 'resume',
225
+ appType: args[1],
226
+ formUuid: args[2],
227
+ fieldsJsonOrFile: args[3],
194
228
  ...options
195
229
  };
196
230
  }
@@ -101,7 +101,10 @@ function execute(args) {
101
101
  }
102
102
 
103
103
  async function schedule(forms, concurrency, results, worker, save) {
104
- const pending = new Set(forms.filter(form => !results[form.key] || results[form.key].status === 'blocked').map(form => form.key));
104
+ const pending = new Set(forms.filter(form => {
105
+ const result = results[form.key];
106
+ return !result || result.status === 'blocked' || (result.status === 'failed' && result.formUuid);
107
+ }).map(form => form.key));
105
108
  const active = new Map();
106
109
  try {
107
110
  while (pending.size || active.size) {
@@ -114,7 +117,7 @@ async function schedule(forms, concurrency, results, worker, save) {
114
117
  }
115
118
  if (active.size >= concurrency || deps.some(status => status !== 'success')) { continue; }
116
119
  pending.delete(form.key);
117
- results[form.key] = { status: 'running' };
120
+ results[form.key] = { ...results[form.key], status: 'running' };
118
121
  save(); // Record intent before the request; an interrupted create is never retried automatically.
119
122
  const task = Promise.resolve().then(() => worker(form)).then(output => {
120
123
  results[form.key] = { ...output, status: 'success' };
@@ -178,16 +181,30 @@ async function run(args, dependencies = {}) {
178
181
  return matches[0].fieldId;
179
182
  };
180
183
  await schedule(forms, options.concurrency, state.results, async form => {
181
- let formUuid = form.formUuid;
184
+ let formUuid = form.formUuid || state.results[form.key]?.formUuid;
185
+ let shouldResume = Boolean(!form.formUuid && formUuid);
186
+ const resolvedFields = mapReferences(form.fields, resolve);
182
187
  if (!formUuid) {
183
- const argv = ['create-form', 'create', options.appType, form.title, JSON.stringify(mapReferences(form.fields, resolve)), '--no-open'];
188
+ const argv = ['create-form', 'create', options.appType, form.title, JSON.stringify(resolvedFields), '--no-open'];
184
189
  for (const key of ['icon', 'locale']) { if (form[key]) { argv.push(`--${key}`, form[key]); } }
185
- const created = await call(argv);
186
- if (typeof created.formUuid !== 'string' || !created.formUuid.startsWith('FORM')) { invalid(`create result: ${form.key}`); }
187
- formUuid = created.formUuid;
190
+ try {
191
+ const created = await call(argv);
192
+ if (typeof created.formUuid !== 'string' || !created.formUuid.startsWith('FORM')) { invalid(`create result: ${form.key}`); }
193
+ formUuid = created.formUuid;
194
+ } catch (error) {
195
+ const createdFormUuid = error.output?.formUuid || error.output?.details?.formUuid;
196
+ if (typeof createdFormUuid !== 'string' || !createdFormUuid.startsWith('FORM')) {
197
+ throw error;
198
+ }
199
+ formUuid = createdFormUuid;
200
+ shouldResume = true;
201
+ }
188
202
  }
189
203
  state.results[form.key].formUuid = formUuid;
190
204
  save(state);
205
+ if (shouldResume) {
206
+ await call(['create-form', 'resume', options.appType, formUuid, JSON.stringify(resolvedFields), '--json']);
207
+ }
191
208
  const schema = await call(['get-schema', options.appType, formUuid, '--field-map-json']);
192
209
  if (schema.formUuid !== formUuid || !Array.isArray(schema.fields)) { invalid(`schema: ${form.key}`); }
193
210
  return { formUuid, fields: schema.fields };
@@ -6,6 +6,8 @@ function dispatchCreateFormCommand(parsedArgs, authContext, handlers) {
6
6
  switch (parsedArgs.mode) {
7
7
  case 'update':
8
8
  return handlers.update(...args);
9
+ case 'resume':
10
+ return handlers.resume(...args);
9
11
  case 'patch':
10
12
  return handlers.patch(...args);
11
13
  case 'rule':
@@ -5911,6 +5911,297 @@ async function mainValidation(parsedArgs, authRef) {
5911
5911
 
5912
5912
  // ── update 模式主流程 ─────────────────────────────────
5913
5913
 
5914
+ function collectResumeFieldEvidence(fields, output) {
5915
+ const evidence = output || [];
5916
+ (fields || []).forEach(function (field) {
5917
+ if (!field || typeof field !== 'object') {
5918
+ return;
5919
+ }
5920
+ const labelText = extractLabelText(field);
5921
+ if (labelText && !isFormPresentationComponent(field.componentName)) {
5922
+ evidence.push({
5923
+ label: labelText,
5924
+ componentName: field.componentName,
5925
+ fieldId: field.props && field.props.fieldId ? field.props.fieldId : null,
5926
+ });
5927
+ }
5928
+ if (Array.isArray(field.children)) {
5929
+ collectResumeFieldEvidence(field.children.flat(), evidence);
5930
+ }
5931
+ });
5932
+ return evidence;
5933
+ }
5934
+
5935
+ function desiredResumeFieldIdentity(field) {
5936
+ const labelValue = field && field.label;
5937
+ const label = typeof labelValue === 'string'
5938
+ ? labelValue
5939
+ : labelValue && (labelValue.zh_CN || labelValue.ja_JP || labelValue.en_US || labelValue.pureEn_US);
5940
+ return {
5941
+ label: String(label || '').trim(),
5942
+ componentName: normalizeFormDefinitionType(field),
5943
+ };
5944
+ }
5945
+
5946
+ function collectResumeDesiredFields(fields, options) {
5947
+ const output = [];
5948
+ const verifyNestedFields = Boolean(options && options.verifyNestedFields);
5949
+
5950
+ function visit(value) {
5951
+ if (Array.isArray(value)) {
5952
+ value.forEach(visit);
5953
+ return;
5954
+ }
5955
+ if (!value || typeof value !== 'object') {
5956
+ return;
5957
+ }
5958
+ const componentName = normalizeFormDefinitionType(value);
5959
+ if (isSupportedBusinessFieldType(componentName)) {
5960
+ output.push(value);
5961
+ if (!verifyNestedFields) {
5962
+ return;
5963
+ }
5964
+ }
5965
+ if (Array.isArray(value.children)) {
5966
+ value.children.forEach(visit);
5967
+ }
5968
+ }
5969
+
5970
+ visit(fields);
5971
+ return output;
5972
+ }
5973
+
5974
+ function isRecoverableBlankResumeSchema(schema) {
5975
+ const allowedShellComponents = new Set(['Page', 'RootHeader', 'RootContent', 'RootFooter', 'FooterYida']);
5976
+ const componentsTree = schema && schema.pages && schema.pages[0] && schema.pages[0].componentsTree;
5977
+ if (!Array.isArray(componentsTree) || componentsTree.length === 0) {
5978
+ return true;
5979
+ }
5980
+ let safe = true;
5981
+ function visit(node) {
5982
+ if (!node || typeof node !== 'object' || !safe) {
5983
+ return;
5984
+ }
5985
+ if (node.componentName && !allowedShellComponents.has(node.componentName)) {
5986
+ safe = false;
5987
+ return;
5988
+ }
5989
+ if (Array.isArray(node.children)) {
5990
+ node.children.forEach(visit);
5991
+ }
5992
+ }
5993
+ componentsTree.forEach(visit);
5994
+ return safe;
5995
+ }
5996
+
5997
+ function buildResumeChanges(existingFields, desiredFields) {
5998
+ const existingByLabel = new Map();
5999
+ existingFields.forEach(function (field) {
6000
+ const bucket = existingByLabel.get(field.label) || [];
6001
+ bucket.push(field);
6002
+ existingByLabel.set(field.label, bucket);
6003
+ });
6004
+
6005
+ const desiredLabels = new Set();
6006
+ const missing = [];
6007
+ const existing = [];
6008
+ const conflicts = [];
6009
+ desiredFields.forEach(function (field) {
6010
+ const identity = desiredResumeFieldIdentity(field);
6011
+ if (!identity.label || desiredLabels.has(identity.label)) {
6012
+ conflicts.push({
6013
+ code: identity.label ? 'CREATE_FORM_RESUME_DUPLICATE_DESIRED_FIELD' : 'CREATE_FORM_RESUME_FIELD_LABEL_REQUIRED',
6014
+ label: identity.label || null,
6015
+ });
6016
+ return;
6017
+ }
6018
+ desiredLabels.add(identity.label);
6019
+ const matches = existingByLabel.get(identity.label) || [];
6020
+ if (matches.length === 0) {
6021
+ missing.push(field);
6022
+ return;
6023
+ }
6024
+ if (matches.length !== 1 || matches[0].componentName !== identity.componentName) {
6025
+ conflicts.push({
6026
+ code: 'CREATE_FORM_RESUME_FIELD_CONFLICT',
6027
+ label: identity.label,
6028
+ requestedType: identity.componentName,
6029
+ observedTypes: matches.map(function (item) { return item.componentName; }),
6030
+ });
6031
+ return;
6032
+ }
6033
+ existing.push({
6034
+ label: identity.label,
6035
+ componentName: identity.componentName,
6036
+ fieldId: matches[0].fieldId,
6037
+ });
6038
+ });
6039
+ return { missing, existing, conflicts };
6040
+ }
6041
+
6042
+ async function readResumeSchema(authRef, appType, formUuid) {
6043
+ const schemaResult = await requestWithAutoLogin(function (auth) {
6044
+ return sendGetRequest(
6045
+ auth.baseUrl,
6046
+ buildApiPath(appType, 'getFormSchema', { prefix: '_view', namespace: 'alibaba' }),
6047
+ { formUuid: formUuid, schemaVersion: 'V5' }
6048
+ );
6049
+ }, authRef);
6050
+ if (!schemaResult || schemaResult.success === false || schemaResult.__needLogin || schemaResult.__csrfExpired) {
6051
+ throwCreateFormError(t('create_form.resume_readback_failed'), 'CREATE_FORM_RESUME_READBACK_FAILED', {
6052
+ appType,
6053
+ formUuid,
6054
+ result: sanitizeFailureResult(schemaResult),
6055
+ });
6056
+ }
6057
+ if (schemaResult.appType && schemaResult.appType !== appType) {
6058
+ throwCreateFormError(t('create_form.resume_ownership_unverified'), 'CREATE_FORM_RESUME_OWNERSHIP_UNVERIFIED', {
6059
+ appType,
6060
+ formUuid,
6061
+ });
6062
+ }
6063
+ if (schemaResult.formUuid && schemaResult.formUuid !== formUuid) {
6064
+ throwCreateFormError(t('create_form.resume_identity_mismatch'), 'CREATE_FORM_RESUME_OWNERSHIP_UNVERIFIED', {
6065
+ appType,
6066
+ formUuid,
6067
+ });
6068
+ }
6069
+ const schema = schemaResult.content
6070
+ ? (typeof schemaResult.content === 'string' ? JSON.parse(schemaResult.content) : schemaResult.content)
6071
+ : schemaResult.pages ? schemaResult : null;
6072
+ if (!schema || !Array.isArray(schema.pages) || schema.pages.length === 0) {
6073
+ throwCreateFormError(t('create_form.resume_schema_invalid'), 'CREATE_FORM_RESUME_SCHEMA_INVALID', {
6074
+ appType,
6075
+ formUuid,
6076
+ });
6077
+ }
6078
+ return { schemaResult, schema, version: extractSchemaServerRevision(schemaResult) };
6079
+ }
6080
+
6081
+ async function mainResume(parsedArgs, authRef) {
6082
+ const { appType, formUuid, fieldsJsonOrFile } = parsedArgs;
6083
+ assertNoEmojiInDefinitionFileName(fieldsJsonOrFile);
6084
+ const { fields, validations } = readFieldsDefinition(fieldsJsonOrFile);
6085
+ assertNoEmojiInFormDefinition(formUuid, fields, [], 'create-form resume input');
6086
+ validateFormFieldDefinitions(fields);
6087
+
6088
+ const firstRead = await readResumeSchema(authRef, appType, formUuid);
6089
+ const root = firstRead.schema.pages[0].componentsTree && firstRead.schema.pages[0].componentsTree[0];
6090
+ const formContainer = root ? findFormContainer(root) : null;
6091
+ const completedStages = ['read_target', 'verify_ownership'];
6092
+ let recoveredBlankShell = false;
6093
+ let plan;
6094
+
6095
+ if (!formContainer) {
6096
+ if (!isRecoverableBlankResumeSchema(firstRead.schema)) {
6097
+ throwCreateFormError(t('create_form.resume_container_invalid'), 'CREATE_FORM_RESUME_SCHEMA_INVALID', {
6098
+ appType,
6099
+ formUuid,
6100
+ retryable: false,
6101
+ remoteWrites: 0,
6102
+ });
6103
+ }
6104
+ const corpId = resolveCorpId(authRef.authData);
6105
+ const formTitle = firstRead.schemaResult.formTitle || firstRead.schemaResult.title || formUuid;
6106
+ firstRead.schema = buildFormSchema(formTitle, fields, formUuid, corpId, appType, 'single', 'default', 'top');
6107
+ const resumeValidationRules = collectSmartValidationRulesFromFields(fields).concat(validations || []);
6108
+ if (resumeValidationRules.length > 0) {
6109
+ applySmartValidations(firstRead.schema, resumeValidationRules);
6110
+ }
6111
+ await saveFormSchema(authRef, appType, formUuid, firstRead.schema, firstRead.version, 4);
6112
+ completedStages.push('rebuild_blank_schema', 'save_schema');
6113
+ recoveredBlankShell = true;
6114
+ plan = {
6115
+ existing: [],
6116
+ missing: collectResumeDesiredFields(fields, { verifyNestedFields: true }),
6117
+ conflicts: [],
6118
+ };
6119
+ } else if (!Array.isArray(formContainer.children)) {
6120
+ throwCreateFormError(t('create_form.resume_container_invalid'), 'CREATE_FORM_RESUME_SCHEMA_INVALID', {
6121
+ appType,
6122
+ formUuid,
6123
+ retryable: false,
6124
+ remoteWrites: 0,
6125
+ });
6126
+ } else {
6127
+ plan = buildResumeChanges(
6128
+ collectResumeFieldEvidence(formContainer.children),
6129
+ collectResumeDesiredFields(fields)
6130
+ );
6131
+ if (plan.conflicts.length > 0) {
6132
+ throwCreateFormError(t('create_form.resume_field_conflict'), 'CREATE_FORM_RESUME_CONFLICT', {
6133
+ appType,
6134
+ formUuid,
6135
+ retryable: false,
6136
+ remoteWrites: 0,
6137
+ diagnostics: plan.conflicts,
6138
+ });
6139
+ }
6140
+ completedStages.push('compare_fields');
6141
+ }
6142
+
6143
+ if (!recoveredBlankShell && plan.missing.length > 0) {
6144
+ const applied = applyChangesToSchema(
6145
+ firstRead.schema,
6146
+ plan.missing.map(function (field) { return { action: 'add', field }; }),
6147
+ { verbose: true }
6148
+ );
6149
+ if ((applied.diagnostics || []).length > 0) {
6150
+ throwCreateFormError(t('create_form.resume_field_resolution_failed'), 'CREATE_FORM_RESUME_CONFLICT', {
6151
+ appType,
6152
+ formUuid,
6153
+ retryable: false,
6154
+ remoteWrites: 0,
6155
+ diagnostics: applied.diagnostics,
6156
+ });
6157
+ }
6158
+ const corpId = resolveCorpId(authRef.authData);
6159
+ const updatedContainer = findFormContainer(firstRead.schema.pages[0].componentsTree[0]);
6160
+ fillSerialNumberFormulas(updatedContainer.children, corpId, appType, formUuid);
6161
+ await saveFormSchema(authRef, appType, formUuid, firstRead.schema, firstRead.version, 4);
6162
+ completedStages.push('add_missing_fields', 'save_schema');
6163
+ }
6164
+
6165
+ const finalRead = await readResumeSchema(authRef, appType, formUuid);
6166
+ const finalContainer = findFormContainer(finalRead.schema.pages[0].componentsTree[0]);
6167
+ const finalPlan = buildResumeChanges(
6168
+ collectResumeFieldEvidence(finalContainer && finalContainer.children),
6169
+ collectResumeDesiredFields(fields, { verifyNestedFields: true })
6170
+ );
6171
+ if (finalPlan.missing.length > 0 || finalPlan.conflicts.length > 0) {
6172
+ throwCreateFormError(t('create_form.resume_readback_mismatch'), 'CREATE_FORM_RESUME_READBACK_MISMATCH', {
6173
+ appType,
6174
+ formUuid,
6175
+ retryable: false,
6176
+ resultUnknown: true,
6177
+ completedStages,
6178
+ missingFieldCount: finalPlan.missing.length,
6179
+ diagnostics: finalPlan.conflicts,
6180
+ });
6181
+ }
6182
+ completedStages.push('verify_final_schema');
6183
+ const formUrl = authRef.baseUrl + '/' + appType + '/workbench/' + formUuid;
6184
+ const output = {
6185
+ success: true,
6186
+ appType,
6187
+ formUuid,
6188
+ completedStages,
6189
+ requestedFieldCount: fields.length,
6190
+ existingFieldCount: plan.existing.length,
6191
+ addedFieldCount: plan.missing.length,
6192
+ finalFieldCount: collectResumeFieldEvidence(finalContainer.children).length,
6193
+ recoveredBlankShell,
6194
+ url: formUrl,
6195
+ };
6196
+ console.log(JSON.stringify(withBrowserHandoff(
6197
+ output,
6198
+ formUrl,
6199
+ { stage: 'resume_form_success', title: formUuid },
6200
+ parsedArgs.browserOpenMode
6201
+ )));
6202
+ return output;
6203
+ }
6204
+
5914
6205
  async function mainUpdate(parsedArgs, authRef) {
5915
6206
  const { appType, formUuid, changesJsonOrFile } = parsedArgs;
5916
6207
 
@@ -6102,6 +6393,7 @@ async function run(args) {
6102
6393
  {
6103
6394
  create: mainCreate,
6104
6395
  update: mainUpdate,
6396
+ resume: mainResume,
6105
6397
  patch: mainPatch,
6106
6398
  rule: mainRule,
6107
6399
  validation: mainValidation,
@@ -23,30 +23,10 @@ function fingerprint(value) {
23
23
  return crypto.createHash('sha256').update(normalized).digest('hex');
24
24
  }
25
25
 
26
- function rawFingerprint(value) {
27
- if (typeof value !== 'string' || !value) {
28
- return '';
29
- }
30
- return crypto.createHash('sha256').update(value, 'utf8').digest('hex');
31
- }
32
-
33
- function positiveSize(value) {
34
- const size = Number(value);
35
- return Number.isFinite(size) && size > 0 ? size : 0;
36
- }
37
-
38
- function sha256(value) {
39
- const digest = String(value || '').toLowerCase();
40
- return /^[a-f0-9]{64}$/.test(digest) ? digest : '';
41
- }
42
-
43
26
  function createEmptyDisplayInfo() {
44
27
  return {
45
28
  hasYidaCodeCanvas: false,
46
- hasCodeBundle: false,
47
29
  hasNativeJsx: false,
48
- codeBundleCount: 0,
49
- bundleIds: [],
50
30
  runtimeCodeBytes: 0,
51
31
  sourceCodeBytes: 0,
52
32
  compiledCodeBytes: 0,
@@ -54,8 +34,6 @@ function createEmptyDisplayInfo() {
54
34
  componentCount: 0,
55
35
  canvasRuntimeCode: '',
56
36
  canvasSourceCode: '',
57
- canvasRuntimeSha256: '',
58
- canvasSourceSha256: '',
59
37
  nativeCompiledCode: '',
60
38
  nativeSourceCode: '',
61
39
  };
@@ -101,37 +79,12 @@ function traverseDisplayNodes(node, info) {
101
79
 
102
80
  if (node.componentName === 'YidaCodeCanvas') {
103
81
  const props = node.props || {};
104
- const codeBundle = props.codeBundle && typeof props.codeBundle === 'object'
105
- ? props.codeBundle
106
- : null;
107
82
  info.hasYidaCodeCanvas = true;
108
83
  info.componentCount++;
109
- if (typeof props.runtimeCode === 'string' && props.runtimeCode) {
110
- info.canvasRuntimeCode = props.runtimeCode;
111
- }
112
- if (typeof props.code === 'string' && props.code) {
113
- info.canvasSourceCode = props.code;
114
- }
84
+ info.canvasRuntimeCode = props.runtimeCode || '';
85
+ info.canvasSourceCode = props.code || '';
115
86
  info.runtimeCodeBytes += codeBytes(props.runtimeCode);
116
87
  info.sourceCodeBytes += codeBytes(props.code);
117
- if (codeBundle) {
118
- const bundleId = String(codeBundle.bundleId || '');
119
- const runtime = codeBundle.runtime && typeof codeBundle.runtime === 'object'
120
- ? codeBundle.runtime
121
- : {};
122
- const source = codeBundle.source && typeof codeBundle.source === 'object'
123
- ? codeBundle.source
124
- : {};
125
- info.hasCodeBundle = true;
126
- info.codeBundleCount++;
127
- if (bundleId && !info.bundleIds.includes(bundleId)) {
128
- info.bundleIds.push(bundleId);
129
- }
130
- info.runtimeCodeBytes += positiveSize(runtime.size);
131
- info.sourceCodeBytes += positiveSize(source.size);
132
- info.canvasRuntimeSha256 = sha256(runtime.sha256) || info.canvasRuntimeSha256;
133
- info.canvasSourceSha256 = sha256(source.sha256) || info.canvasSourceSha256;
134
- }
135
88
  addImportedModules(info.importedModules, props.importedModules);
136
89
  } else if (node.componentName === 'Jsx') {
137
90
  info.hasNativeJsx = true;
@@ -180,9 +133,7 @@ function hasExpectedDisplayComponent(info, publishMode) {
180
133
  return false;
181
134
  }
182
135
  if (publishMode === 'canvas') {
183
- return info.hasYidaCodeCanvas && (
184
- info.runtimeCodeBytes > 0 || !!info.canvasRuntimeSha256
185
- );
136
+ return info.hasYidaCodeCanvas && info.runtimeCodeBytes > 0;
186
137
  }
187
138
  return info.hasNativeJsx && info.compiledCodeBytes > 0;
188
139
  }
@@ -193,10 +144,7 @@ function summarizeDisplayPublishInfo(info) {
193
144
  }
194
145
  return {
195
146
  hasYidaCodeCanvas: info.hasYidaCodeCanvas,
196
- hasCodeBundle: info.hasCodeBundle,
197
147
  hasNativeJsx: info.hasNativeJsx,
198
- codeBundleCount: info.codeBundleCount,
199
- bundleIds: info.bundleIds.slice(),
200
148
  runtimeCodeBytes: info.runtimeCodeBytes,
201
149
  sourceCodeBytes: info.sourceCodeBytes,
202
150
  compiledCodeBytes: info.compiledCodeBytes,
@@ -211,13 +159,8 @@ function verifyPublishedContentMatch(readbackSchema, expectedSchemaContent, publ
211
159
  const displayComponentPresent = hasExpectedDisplayComponent(readbackInfo, publishMode);
212
160
  const readbackArtifact = getPublishArtifact(readbackInfo, publishMode);
213
161
  const expectedArtifact = getPublishArtifact(expectedInfo, publishMode);
214
- const codeBundleReadback = publishMode === 'canvas' && readbackInfo && readbackInfo.hasCodeBundle;
215
- const readbackFingerprint = codeBundleReadback
216
- ? readbackInfo.canvasRuntimeSha256
217
- : fingerprint(readbackArtifact);
218
- const expectedFingerprint = codeBundleReadback
219
- ? rawFingerprint(expectedArtifact)
220
- : fingerprint(expectedArtifact);
162
+ const readbackFingerprint = fingerprint(readbackArtifact);
163
+ const expectedFingerprint = fingerprint(expectedArtifact);
221
164
 
222
165
  return {
223
166
  readbackInfo,
@@ -237,7 +180,6 @@ function verifyPublishedContentMatch(readbackSchema, expectedSchemaContent, publ
237
180
  module.exports = {
238
181
  extractDisplayPublishInfo,
239
182
  fingerprint,
240
- rawFingerprint,
241
183
  hasExpectedDisplayComponent,
242
184
  parseSchemaContent,
243
185
  summarizeDisplayPublishInfo,