openyida 2026.7.18 → 2026.7.21

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 (200) hide show
  1. package/README.md +37 -2
  2. package/bin/yida.js +113 -18
  3. package/docs/capabilities.md +202 -0
  4. package/lib/agent-center/agent-center.js +2 -3
  5. package/lib/app/app-list.js +3 -4
  6. package/lib/app/build-page.js +13 -6
  7. package/lib/app/check-page.js +16 -6
  8. package/lib/app/compile.js +17 -7
  9. package/lib/app/create-app.js +14 -2
  10. package/lib/app/create-form/api-path.js +25 -0
  11. package/lib/app/create-form/args.js +13 -0
  12. package/lib/app/create-form/commands.js +4 -0
  13. package/lib/app/create-form/definition-reader.js +23 -23
  14. package/lib/app/create-form/field-normalizers.js +26 -7
  15. package/lib/app/create-form/schema-patch.js +4 -1
  16. package/lib/app/create-form.js +155 -68
  17. package/lib/app/create-page.js +47 -10
  18. package/lib/app/generate-page.js +20 -1
  19. package/lib/app/get-form-config.js +2 -1
  20. package/lib/app/get-schema.js +67 -15
  21. package/lib/app/import-app.js +94 -42
  22. package/lib/app/list-forms.js +4 -8
  23. package/lib/app/page-ir.js +140 -0
  24. package/lib/app/publish.js +289 -556
  25. package/lib/app/schema-field-resolution.js +370 -0
  26. package/lib/app/services/app-reader.js +85 -0
  27. package/lib/app/services/app-service.js +235 -0
  28. package/lib/app/services/canvas-page-compiler.js +91 -0
  29. package/lib/app/services/canvas-page-schema-builder.js +149 -0
  30. package/lib/app/services/field-bindings.js +68 -0
  31. package/lib/app/services/form-compiler.js +1922 -0
  32. package/lib/app/services/form-mode-service.js +182 -0
  33. package/lib/app/services/form-schema-patcher.js +333 -0
  34. package/lib/app/services/form-schema-reader.js +59 -0
  35. package/lib/app/services/form-service.js +379 -0
  36. package/lib/app/services/form-validation.js +562 -0
  37. package/lib/app/services/native-page-compiler.js +92 -0
  38. package/lib/app/services/native-page-schema-builder.js +428 -0
  39. package/lib/app/services/page-resource-service.js +185 -0
  40. package/lib/app/update-app.js +22 -9
  41. package/lib/app/update-form-config.js +4 -2
  42. package/lib/asset/asset-cmd.js +19 -6
  43. package/lib/auth/oauth-loopback.js +376 -15
  44. package/lib/auth/token-auth.js +34 -3
  45. package/lib/auth/token-store.js +22 -4
  46. package/lib/basic-info/basic-info.js +2 -1
  47. package/lib/bridge/bridge.js +43 -18
  48. package/lib/core/agent-capabilities.js +5 -3
  49. package/lib/core/command-errors.js +38 -0
  50. package/lib/core/command-manifest.js +59 -1
  51. package/lib/core/copy.js +12 -0
  52. package/lib/core/doctor.js +15 -4
  53. package/lib/core/env-cmd.js +1 -1
  54. package/lib/core/env.js +7 -6
  55. package/lib/core/i18n.js +66 -8
  56. package/lib/core/legacy-schema-guard.js +408 -0
  57. package/lib/core/locales/en.js +38 -46
  58. package/lib/core/locales/zh.js +30 -46
  59. package/lib/core/sample.js +12 -2
  60. package/lib/core/utils.js +334 -66
  61. package/lib/core/yida-client.js +108 -5
  62. package/lib/corp-efficiency/corp-efficiency.js +2 -2
  63. package/lib/corp-manager/corp-manager.js +3 -3
  64. package/lib/formula/evaluate.js +11 -68
  65. package/lib/formula/field-refs.js +83 -0
  66. package/lib/i18n-management/i18n-management.js +2 -3
  67. package/lib/process/configure-process.js +44 -1992
  68. package/lib/process/create-process.js +54 -87
  69. package/lib/process/preview-process.js +20 -8
  70. package/lib/process/services/process-compiler.js +2056 -0
  71. package/lib/process/services/process-reader.js +232 -0
  72. package/lib/process/services/process-resource-service.js +571 -0
  73. package/lib/process/services/process-service.js +122 -0
  74. package/lib/process/services/process-stage-checkpoint.js +246 -0
  75. package/lib/report/append.js +7 -26
  76. package/lib/report/http.js +31 -5
  77. package/lib/report/index.js +10 -2
  78. package/lib/samples/yida-canvas-custom-page/business-list.canvas.jsx +63 -14
  79. package/lib/samples/yida-canvas-custom-page/dashboard-overview.canvas.jsx +176 -32
  80. package/lib/samples/yida-canvas-custom-page/dashboard-starter.canvas.jsx +5 -2
  81. package/lib/samples/yida-canvas-custom-page/data-management.canvas.jsx +228 -14
  82. package/lib/samples/yida-canvas-custom-page/portal-shell-home.canvas.jsx +2 -2
  83. package/lib/samples/yida-canvas-custom-page/split-pane-detail.canvas.jsx +206 -10
  84. package/lib/samples/yida-custom-page/data-management.oyd.jsx +14 -3
  85. package/lib/samples/yida-custom-page/design-tokens.js +2 -2
  86. package/lib/samples/yida-custom-page/detail-profile.oyd.jsx +1 -1
  87. package/lib/samples/yida-custom-page/portal-shell-home.oyd.jsx +7 -2
  88. package/lib/samples/yida-custom-page/split-pane-detail.oyd.jsx +2 -1
  89. package/lib/schema/adapters/app-adapter.js +210 -0
  90. package/lib/schema/adapters/form-adapter.js +1362 -0
  91. package/lib/schema/adapters/keys.js +19 -0
  92. package/lib/schema/adapters/page-adapter.js +566 -0
  93. package/lib/schema/adapters/process-adapter.js +519 -0
  94. package/lib/schema/applier.js +1878 -0
  95. package/lib/schema/apply-store.js +1083 -0
  96. package/lib/schema/command.js +645 -0
  97. package/lib/schema/dependency-graph.js +83 -0
  98. package/lib/schema/errors.js +481 -0
  99. package/lib/schema/hash.js +9 -0
  100. package/lib/schema/manifest-limits.js +177 -0
  101. package/lib/schema/manifest-loader.js +309 -0
  102. package/lib/schema/manifest-schema-v1.json +193 -0
  103. package/lib/schema/normalize-manifest.js +281 -0
  104. package/lib/schema/page-canvas-foundation.js +447 -0
  105. package/lib/schema/page-data-source-builder.js +561 -0
  106. package/lib/schema/page-foundation.js +556 -0
  107. package/lib/schema/page-source-loader.js +314 -0
  108. package/lib/schema/planner.js +691 -0
  109. package/lib/schema/remote-dispatch-boundary.js +39 -0
  110. package/lib/schema/remote-missing.js +21 -0
  111. package/lib/schema/remote-reader.js +189 -0
  112. package/lib/schema/resource-registry.js +157 -0
  113. package/lib/schema/server-revision.js +71 -0
  114. package/lib/schema/sort.js +28 -0
  115. package/lib/schema/state-store.js +589 -0
  116. package/package.json +10 -8
  117. package/scripts/check-release-risks.js +254 -0
  118. package/scripts/generate-command-docs.js +6 -1
  119. package/scripts/i18n-baseline.json +11 -11
  120. package/scripts/postinstall.js +8 -12
  121. package/scripts/validate-ci.sh +15 -11
  122. package/scripts/validate-i18n.js +30 -9
  123. package/scripts/validate-package-size.js +5 -2
  124. package/scripts/validate-skills.js +4 -0
  125. package/scripts/validate-structure.js +15 -0
  126. package/yida-skills/SKILL.md +117 -30
  127. package/yida-skills/references/schema-as-code-phase1.md +99 -0
  128. package/yida-skills/references/setup-and-env.md +59 -59
  129. package/yida-skills/references/task-retrospective.md +6 -6
  130. package/yida-skills/skills/yida-app/SKILL.md +78 -17
  131. package/yida-skills/skills/yida-canvas-custom-page/SKILL.md +18 -7
  132. package/yida-skills/skills/yida-canvas-custom-page/references/data-bridge-guide.md +3 -3
  133. package/yida-skills/skills/yida-canvas-custom-page/references/page-generation-guide.md +15 -0
  134. package/yida-skills/skills/yida-create-app/SKILL.md +21 -3
  135. package/yida-skills/skills/yida-create-form-page/SKILL.md +19 -1
  136. package/yida-skills/skills/yida-create-page/SKILL.md +16 -3
  137. package/yida-skills/skills/yida-create-process/SKILL.md +100 -4
  138. package/yida-skills/skills/yida-custom-page/SKILL.md +19 -4
  139. package/yida-skills/skills/yida-dashboard/SKILL.md +1 -1
  140. package/yida-skills/skills/yida-dashboard/references/pitfalls.md +1 -1
  141. package/yida-skills/skills/yida-get-schema/SKILL.md +49 -5
  142. package/yida-skills/skills/yida-i18n/SKILL.md +1 -1
  143. package/yida-skills/skills/yida-integration/SKILL.md +7 -1
  144. package/yida-skills/skills/yida-login/SKILL.md +50 -99
  145. package/yida-skills/skills/yida-page-config/SKILL.md +7 -1
  146. package/yida-skills/skills/yida-page-uiux/references/app/blueprint.md +0 -1
  147. package/yida-skills/skills/yida-page-uiux/references/app/navigation-patterns.md +0 -1
  148. package/yida-skills/skills/yida-page-uiux/references/app/role-journey.md +0 -1
  149. package/yida-skills/skills/yida-page-uiux/references/dashboard/app-blueprint.md +0 -1
  150. package/yida-skills/skills/yida-page-uiux/references/dashboard/chart-contracts.md +0 -1
  151. package/yida-skills/skills/yida-page-uiux/references/dashboard/component-contracts.md +0 -1
  152. package/yida-skills/skills/yida-page-uiux/references/dashboard/layout-patterns.md +0 -1
  153. package/yida-skills/skills/yida-page-uiux/references/dashboard/theme-recipes.md +0 -1
  154. package/yida-skills/skills/yida-page-uiux/references/detail/object-narrative.md +0 -1
  155. package/yida-skills/skills/yida-page-uiux/references/detail/section-patterns.md +0 -1
  156. package/yida-skills/skills/yida-page-uiux/references/detail/timeline-and-related.md +0 -1
  157. package/yida-skills/skills/yida-page-uiux/references/landing/assets-workflow.md +0 -1
  158. package/yida-skills/skills/yida-page-uiux/references/landing/industry-playbooks.md +0 -1
  159. package/yida-skills/skills/yida-page-uiux/references/landing/research-levels.md +0 -1
  160. package/yida-skills/skills/yida-page-uiux/references/landing/section-patterns.md +0 -1
  161. package/yida-skills/skills/yida-page-uiux/references/list/drawer-detail.md +0 -1
  162. package/yida-skills/skills/yida-page-uiux/references/list/empty-loading-error.md +0 -1
  163. package/yida-skills/skills/yida-page-uiux/references/list/filter-patterns.md +0 -1
  164. package/yida-skills/skills/yida-page-uiux/references/list/table-patterns.md +0 -1
  165. package/yida-skills/skills/yida-page-uiux/references/scenes/screen.md +0 -1
  166. package/yida-skills/skills/yida-page-uiux/references/workbench/entry-patterns.md +0 -1
  167. package/yida-skills/skills/yida-page-uiux/references/workbench/portal-layouts.md +0 -1
  168. package/yida-skills/skills/yida-page-uiux/references/workbench/task-feed.md +0 -1
  169. package/yida-skills/skills/yida-page-uiux/workflow/output-decision-block.md +1 -1
  170. package/yida-skills/skills/yida-process-rule/SKILL.md +35 -1
  171. package/yida-skills/skills/yida-publish-page/SKILL.md +46 -4
  172. package/yida-skills/skills/yida-report/SKILL.md +9 -235
  173. package/yida-skills/skills/yida-report/references/schema-builder-details.md +239 -0
  174. package/yida-skills/skills/yida-skill-evaluator/SKILL.md +170 -0
  175. package/yida-skills/skills-index.json +238 -54
  176. package/lib/core/locales/ar.js +0 -834
  177. package/lib/core/locales/de.js +0 -834
  178. package/lib/core/locales/es.js +0 -834
  179. package/lib/core/locales/fr.js +0 -834
  180. package/lib/core/locales/hi.js +0 -834
  181. package/lib/core/locales/ja.js +0 -1227
  182. package/lib/core/locales/ko.js +0 -836
  183. package/lib/core/locales/pt.js +0 -834
  184. package/lib/core/locales/vi.js +0 -834
  185. package/lib/core/locales/zh-HK.js +0 -1263
  186. package/project/pages/src/demo-birthday-game.oyd.jsx +0 -832
  187. package/project/pages/src/demo-chip-insight.oyd.jsx +0 -983
  188. package/project/pages/src/demo-compat-smoke.oyd.jsx +0 -58
  189. package/project/pages/src/demo-crm-batch-entry.oyd.jsx +0 -805
  190. package/project/pages/src/demo-crm-dashboard.oyd.jsx +0 -677
  191. package/project/pages/src/demo-future-vision-2026.oyd.jsx +0 -1102
  192. package/project/pages/src/demo-ppt.oyd.jsx +0 -1192
  193. package/project/pages/src/demo-salary-calculator.oyd.jsx +0 -904
  194. package/project/pages/src/openyida-knowledge-doc.oyd.jsx +0 -1714
  195. package/yida-skills/skills/large-file-write/SKILL.md +0 -93
  196. package/yida-skills/skills/large-file-write/references/write-patterns.md +0 -147
  197. package/yida-skills/skills/large-file-write/scripts/write.js +0 -157
  198. package/yida-skills/skills/sls-log-workbench/SKILL.md +0 -134
  199. package/yida-skills/skills/sls-log-workbench/references/workbench-reference.md +0 -130
  200. package/yida-skills/skills/sls-log-workbench/sls-query.js +0 -295
@@ -0,0 +1,379 @@
1
+ 'use strict';
2
+
3
+ const querystring = require('querystring');
4
+ const { httpPost, requestWithAutoLogin } = require('../../core/utils');
5
+ const { normalizeFormulaFieldRefs } = require('../../formula/evaluate');
6
+ const { compileFormDefinition, i18n } = require('./form-compiler');
7
+ const { readFormSchema, createFormServiceError } = require('./form-schema-reader');
8
+ const { verifyFieldBindings } = require('./field-bindings');
9
+ const { patchManagedFormSchema } = require('./form-schema-patcher');
10
+ const {
11
+ createServerRevisionConflict,
12
+ isSaveFormSchemaRevisionConflict,
13
+ requireSchemaServerRevision,
14
+ } = require('../../schema/server-revision');
15
+ const {
16
+ dispatchRemotePrimitive,
17
+ hasRemoteDispatchBoundary,
18
+ } = require('../../schema/remote-dispatch-boundary');
19
+ const { isTokenAuthRef } = require('../../core/yida-client');
20
+
21
+ function resolveAuthRef(context) {
22
+ return context && context.authRef ? context.authRef : context;
23
+ }
24
+
25
+ function buildFormDesignApiPath(appType, apiName, options = {}) {
26
+ const { prefix = '', namespace = 'dingtalk', addTimestamp = false } = options;
27
+ const prefixPath = prefix ? `/${prefix}` : '';
28
+ const timestamp = addTimestamp ? `?_stamp=${Date.now()}` : '';
29
+ return `/${namespace}/web/${appType}${prefixPath}/query/formdesign/${apiName}.json${timestamp}`;
30
+ }
31
+
32
+ function postFormDesign(auth, appType, apiName, params, options, request = httpPost) {
33
+ const postData = querystring.stringify(
34
+ Object.assign({ _csrf_token: auth.csrfToken }, params)
35
+ );
36
+ const formUuid = params && params.formUuid;
37
+ const referer = formUuid
38
+ ? `${auth.baseUrl}/alibaba/web/${params.appType || appType || ''}/design/pageDesigner?formUuid=${formUuid}`
39
+ : auth.baseUrl + '/';
40
+ return request(
41
+ auth.baseUrl,
42
+ buildFormDesignApiPath(appType, apiName, options),
43
+ postData,
44
+ auth.cookies,
45
+ { referer }
46
+ );
47
+ }
48
+
49
+ function sanitizeServiceResult(result) {
50
+ if (!result || typeof result !== 'object') {
51
+ return result || null;
52
+ }
53
+ const sanitized = {};
54
+ ['success', 'errorMsg', 'errorCode', 'code', 'message', '__httpStatus', '__nonJsonResponse', '__emptyBody'].forEach(function (key) {
55
+ if (Object.prototype.hasOwnProperty.call(result, key)) {
56
+ sanitized[key] = result[key];
57
+ }
58
+ });
59
+ return sanitized;
60
+ }
61
+
62
+ function assertSuccess(result, code, details) {
63
+ if (result && result.success !== false && !result.__needLogin && !result.__csrfExpired) {
64
+ return result;
65
+ }
66
+ const message = result ? result.errorMsg || 'request failed' : 'request failed';
67
+ throw createFormServiceError(message, code, Object.assign({ result: sanitizeServiceResult(result) }, details));
68
+ }
69
+
70
+ function assertConfigSuccess(result, details) {
71
+ if (result && result.success) {
72
+ return result;
73
+ }
74
+ if (isAcceptedNonJsonConfigResponse(result)) {
75
+ return {
76
+ success: true,
77
+ acceptedNonJsonResponse: true,
78
+ acceptedEmptyResponse: result.__emptyBody === true,
79
+ };
80
+ }
81
+ const message = result ? result.errorMsg || 'config update failed' : 'config update failed';
82
+ throw createFormServiceError(message, 'FORM_CONFIG_UPDATE_FAILED', Object.assign({
83
+ result: sanitizeServiceResult(result),
84
+ }, details));
85
+ }
86
+
87
+ function isAcceptedNonJsonConfigResponse(result) {
88
+ return !!(
89
+ result &&
90
+ result.success === false &&
91
+ result.__httpStatus === 200 &&
92
+ result.__nonJsonResponse === true &&
93
+ !result.__needLogin &&
94
+ !result.__csrfExpired &&
95
+ result.errorCode === undefined &&
96
+ result.code === undefined
97
+ );
98
+ }
99
+
100
+ function assertFieldBindingVerification(verification, details) {
101
+ const missing = verification && Array.isArray(verification.missing) ? verification.missing : [];
102
+ const mismatched = verification && Array.isArray(verification.mismatched) ? verification.mismatched : [];
103
+ if (missing.length === 0 && mismatched.length === 0) {
104
+ return verification;
105
+ }
106
+ throw createFormServiceError('field binding verification failed', 'FORM_FIELD_BINDING_VERIFICATION_FAILED', Object.assign({
107
+ missing,
108
+ mismatched,
109
+ }, details));
110
+ }
111
+
112
+ function normalizeTitlePayload(input) {
113
+ if (input.titleI18n && typeof input.titleI18n === 'object') {
114
+ return JSON.stringify(input.titleI18n);
115
+ }
116
+ const definition = input.definition && typeof input.definition === 'object' ? input.definition : {};
117
+ const title = input.formTitle || input.title || definition.title || '';
118
+ return JSON.stringify(i18n(title));
119
+ }
120
+
121
+ async function createBlankForm(context, input) {
122
+ const authRef = resolveAuthRef(context);
123
+ const services = context && context.services || {};
124
+ const request = services.httpPost || httpPost;
125
+ const requestWithAutoLoginImpl = services.requestWithAutoLogin || requestWithAutoLogin;
126
+ const appType = input && input.appType;
127
+ const send = auth => postFormDesign(auth, appType, 'saveFormSchemaInfo', {
128
+ formType: input && input.formType || 'receipt',
129
+ title: normalizeTitlePayload(input || {}),
130
+ }, undefined, request);
131
+ const result = hasRemoteDispatchBoundary(context)
132
+ ? await dispatchRemotePrimitive(context, () => send(requireSchemaWriteAuth(authRef, { appType })))
133
+ : await requestWithAutoLoginImpl(send, authRef);
134
+ assertSuccess(result, 'FORM_CREATE_BLANK_FAILED', { appType });
135
+ const formUuid = result.content && result.content.formUuid || result.content;
136
+ if (!formUuid) {
137
+ throw createFormServiceError('missing formUuid in create blank form response', 'FORM_CREATE_BLANK_FAILED', {
138
+ appType,
139
+ result,
140
+ });
141
+ }
142
+ return { formUuid, createResult: result };
143
+ }
144
+
145
+ async function saveFormSchema(context, input) {
146
+ const authRef = resolveAuthRef(context);
147
+ const appType = input && input.appType;
148
+ const formUuid = input && input.formUuid;
149
+ const schema = input && input.schema;
150
+ const serverRevision = requireSchemaServerRevision(
151
+ { gmtModified: input && input.serverRevision },
152
+ () => createFormServiceError(
153
+ 'remote Schema revision is missing or invalid',
154
+ 'FORM_SAVE_SCHEMA_PRECHECK_FAILED',
155
+ { appType, formUuid }
156
+ )
157
+ );
158
+ const fixedFormulaRefs = input && input.normalizeFormulaRefs === false
159
+ ? 0
160
+ : normalizeFormulaFieldRefs(schema);
161
+ requireSchemaWriteAuth(authRef, { appType, formUuid });
162
+ const request = context && context.services && context.services.httpPost || httpPost;
163
+ const result = await dispatchRemotePrimitive(context, () => postFormDesign(authRef, appType, 'saveFormSchema', {
164
+ appType,
165
+ formUuid,
166
+ content: JSON.stringify(schema),
167
+ schemaVersion: input && input.schemaVersion || 'V5',
168
+ prefix: '_view',
169
+ gmtModified: serverRevision,
170
+ }, { prefix: '_view' }, request));
171
+ if (isSaveFormSchemaRevisionConflict(result)) {
172
+ throw createServerRevisionConflict('form');
173
+ }
174
+ assertSuccess(result, 'FORM_SAVE_SCHEMA_FAILED', { appType, formUuid });
175
+ return { saveResult: result, fixedFormulaRefs };
176
+ }
177
+
178
+ function requireSchemaWriteAuth(authRef, details) {
179
+ if (!authRef || typeof authRef.baseUrl !== 'string' || authRef.baseUrl.length === 0) {
180
+ throw createFormServiceError(
181
+ 'Schema write authentication is not ready',
182
+ 'FORM_SAVE_SCHEMA_PRECHECK_FAILED',
183
+ details
184
+ );
185
+ }
186
+ if (isTokenAuthRef(authRef)) {
187
+ return authRef;
188
+ }
189
+ if (
190
+ typeof authRef.csrfToken !== 'string' ||
191
+ authRef.csrfToken.length === 0 ||
192
+ !Array.isArray(authRef.cookies)
193
+ ) {
194
+ throw createFormServiceError(
195
+ 'Schema write authentication is not ready',
196
+ 'FORM_SAVE_SCHEMA_PRECHECK_FAILED',
197
+ details
198
+ );
199
+ }
200
+ return authRef;
201
+ }
202
+
203
+ async function updateFormConfig(context, input) {
204
+ const authRef = resolveAuthRef(context);
205
+ const services = context && context.services || {};
206
+ const request = services.httpPost || httpPost;
207
+ const requestWithAutoLoginImpl = services.requestWithAutoLogin || requestWithAutoLogin;
208
+ const appType = input && input.appType;
209
+ const formUuid = input && input.formUuid;
210
+ const version = input && input.version !== undefined ? input.version : 1;
211
+ const value = input && input.value !== undefined ? input.value : 0;
212
+ const send = function (auth) {
213
+ const postData = querystring.stringify({
214
+ _csrf_token: auth.csrfToken,
215
+ formUuid,
216
+ version,
217
+ configType: 'MINI_RESOURCE',
218
+ value,
219
+ });
220
+ return request(
221
+ auth.baseUrl,
222
+ buildFormDesignApiPath(appType, 'updateFormConfig'),
223
+ postData,
224
+ auth.cookies
225
+ );
226
+ };
227
+ const result = hasRemoteDispatchBoundary(context)
228
+ ? await dispatchRemotePrimitive(context, () => send(requireSchemaWriteAuth(authRef, { appType, formUuid })))
229
+ : await requestWithAutoLoginImpl(send, authRef);
230
+ let configResult = result;
231
+ if (input && input.strict) {
232
+ configResult = assertConfigSuccess(result, { appType, formUuid });
233
+ }
234
+ return { configResult };
235
+ }
236
+
237
+ async function saveFormSchemaAndConfig(context, input) {
238
+ const saveResult = await saveFormSchema(context, input);
239
+ const configResult = await updateFormConfig(context, Object.assign({}, input, { strict: true }));
240
+ return Object.assign({}, saveResult, configResult);
241
+ }
242
+
243
+ async function createFormResource(context, input) {
244
+ const blank = await callWithDispatchBoundary(context, () => createBlankForm(context, input));
245
+ const compiled = compileFormDefinition(input.definition || input, Object.assign({}, input, {
246
+ formUuid: blank.formUuid,
247
+ }));
248
+ if (typeof context.checkpointCreateIdentity === 'function') {
249
+ await context.checkpointCreateIdentity({
250
+ appType: input.appType,
251
+ formUuid: blank.formUuid,
252
+ fieldBindings: compiled.fieldBindings,
253
+ fieldBindingComponents: compiled.fieldBindingComponents,
254
+ });
255
+ }
256
+ return resumeFormResource(context, Object.assign({}, input, {
257
+ compiled,
258
+ createResult: blank.createResult,
259
+ formUuid: blank.formUuid,
260
+ }));
261
+ }
262
+
263
+ async function resumeFormResource(context, input) {
264
+ const currentSchemaResult = input.currentSchemaResult || await callWithDispatchBoundary(
265
+ context,
266
+ () => readFormSchema(context, {
267
+ appType: input.appType,
268
+ formUuid: input.formUuid,
269
+ })
270
+ );
271
+ const compiled = input.compiled || compileFormDefinition(input.definition || input, Object.assign({}, input, {
272
+ formUuid: input.formUuid,
273
+ }));
274
+ const saveResult = await callWithDispatchBoundary(
275
+ context,
276
+ () => saveFormSchema(context, Object.assign({}, input, {
277
+ schema: compiled.schema,
278
+ serverRevision: requireSchemaServerRevision(currentSchemaResult),
279
+ }))
280
+ );
281
+ const configResult = await callWithDispatchBoundary(
282
+ context,
283
+ () => updateFormConfig(context, Object.assign({}, input, { strict: true }))
284
+ );
285
+ const schemaResult = await callWithDispatchBoundary(context, () => readFormSchema(context, {
286
+ appType: input.appType,
287
+ formUuid: input.formUuid,
288
+ }));
289
+ const verification = verifyFieldBindings(schemaResult, compiled.fieldBindings, {
290
+ expectedComponentTypes: compiled.fieldBindingComponents,
291
+ });
292
+ assertFieldBindingVerification(verification, {
293
+ appType: input.appType,
294
+ formUuid: input.formUuid,
295
+ });
296
+
297
+ return {
298
+ appType: input.appType,
299
+ formUuid: input.formUuid,
300
+ schema: compiled.schema,
301
+ fieldBindings: compiled.fieldBindings,
302
+ fieldBindingComponents: compiled.fieldBindingComponents,
303
+ verification,
304
+ createResult: input.createResult,
305
+ saveResult: saveResult.saveResult,
306
+ configResult: configResult.configResult,
307
+ schemaResult,
308
+ };
309
+ }
310
+
311
+ function prepareFormResourceUpdate(input) {
312
+ const compiled = compileFormDefinition(input.definition || input, Object.assign({}, input, {
313
+ appType: input.appType,
314
+ existingBindings: input.existingBindings,
315
+ formUuid: input.formUuid,
316
+ }));
317
+ const schema = patchManagedFormSchema(input.currentSchemaResult, compiled, {
318
+ existingBindings: input.existingBindings,
319
+ });
320
+ return { compiled, schema };
321
+ }
322
+
323
+ async function updateFormResource(context, input) {
324
+ const prepared = input.prepared || prepareFormResourceUpdate(input);
325
+ const saveResult = await callWithDispatchBoundary(context, () => saveFormSchema(context, Object.assign({}, input, {
326
+ schema: prepared.schema,
327
+ serverRevision: input.serverRevision,
328
+ })));
329
+ const configResult = await callWithDispatchBoundary(
330
+ context,
331
+ () => updateFormConfig(context, Object.assign({}, input, { strict: true }))
332
+ );
333
+ const schemaResult = await callWithDispatchBoundary(context, () => readFormSchema(context, {
334
+ appType: input.appType,
335
+ formUuid: input.formUuid,
336
+ }));
337
+ const verification = verifyFieldBindings(schemaResult, prepared.compiled.fieldBindings, {
338
+ expectedComponentTypes: prepared.compiled.fieldBindingComponents,
339
+ });
340
+ assertFieldBindingVerification(verification, {
341
+ appType: input.appType,
342
+ formUuid: input.formUuid,
343
+ });
344
+
345
+ return {
346
+ appType: input.appType,
347
+ formUuid: input.formUuid,
348
+ schema: prepared.schema,
349
+ fieldBindings: prepared.compiled.fieldBindings,
350
+ fieldBindingComponents: prepared.compiled.fieldBindingComponents,
351
+ verification,
352
+ saveResult: saveResult.saveResult,
353
+ configResult: configResult.configResult,
354
+ schemaResult,
355
+ };
356
+ }
357
+
358
+ async function callWithDispatchBoundary(context, callback) {
359
+ if (typeof context.assertRemoteDispatchBoundary === 'function') {
360
+ context.assertRemoteDispatchBoundary('before');
361
+ }
362
+ const result = await callback();
363
+ if (typeof context.assertRemoteDispatchBoundary === 'function') {
364
+ context.assertRemoteDispatchBoundary('after');
365
+ }
366
+ return result;
367
+ }
368
+
369
+ module.exports = {
370
+ buildFormDesignApiPath,
371
+ createBlankForm,
372
+ saveFormSchema,
373
+ updateFormConfig,
374
+ saveFormSchemaAndConfig,
375
+ createFormResource,
376
+ resumeFormResource,
377
+ prepareFormResourceUpdate,
378
+ updateFormResource,
379
+ };