@nocobase/plugin-flow-engine 2.1.0-beta.42 → 2.1.0-beta.44

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 (86) hide show
  1. package/dist/externalVersion.js +9 -9
  2. package/dist/node_modules/@ant-design/icons-svg/package.json +1 -1
  3. package/dist/node_modules/acorn/package.json +1 -1
  4. package/dist/node_modules/acorn-jsx/package.json +1 -1
  5. package/dist/node_modules/acorn-walk/package.json +1 -1
  6. package/dist/node_modules/ses/package.json +1 -1
  7. package/dist/node_modules/zod/package.json +1 -1
  8. package/dist/server/flow-surfaces/authoring-validation.js +160 -21
  9. package/dist/server/flow-surfaces/catalog.js +9 -5
  10. package/dist/server/flow-surfaces/chart-config.js +29 -6
  11. package/dist/server/flow-surfaces/contract-guard.js +39 -5
  12. package/dist/server/flow-surfaces/default-block-actions.js +2 -0
  13. package/dist/server/flow-surfaces/errors.d.ts +15 -0
  14. package/dist/server/flow-surfaces/errors.js +49 -3
  15. package/dist/server/flow-surfaces/filter-group.d.ts +7 -1
  16. package/dist/server/flow-surfaces/filter-group.js +175 -71
  17. package/dist/server/flow-surfaces/public-data-surface-default-filter.js +2 -1
  18. package/dist/server/flow-surfaces/runjs-authoring/ast/bindings.d.ts +66 -0
  19. package/dist/server/flow-surfaces/runjs-authoring/ast/bindings.js +661 -0
  20. package/dist/server/flow-surfaces/runjs-authoring/ast/execution.d.ts +20 -0
  21. package/dist/server/flow-surfaces/runjs-authoring/ast/execution.js +275 -0
  22. package/dist/server/flow-surfaces/runjs-authoring/ast/parser.d.ts +16 -0
  23. package/dist/server/flow-surfaces/runjs-authoring/ast/parser.js +130 -0
  24. package/dist/server/flow-surfaces/runjs-authoring/ast/react-values.d.ts +20 -0
  25. package/dist/server/flow-surfaces/runjs-authoring/ast/react-values.js +401 -0
  26. package/dist/server/flow-surfaces/runjs-authoring/ast/request-config.d.ts +21 -0
  27. package/dist/server/flow-surfaces/runjs-authoring/ast/request-config.js +199 -0
  28. package/dist/server/flow-surfaces/runjs-authoring/ast/source.d.ts +70 -0
  29. package/dist/server/flow-surfaces/runjs-authoring/ast/source.js +895 -0
  30. package/dist/server/flow-surfaces/runjs-authoring/ast/static-bindings.d.ts +23 -0
  31. package/dist/server/flow-surfaces/runjs-authoring/ast/static-bindings.js +618 -0
  32. package/dist/server/flow-surfaces/runjs-authoring/ast/static-values.d.ts +196 -0
  33. package/dist/server/flow-surfaces/runjs-authoring/ast/static-values.js +1777 -0
  34. package/dist/server/flow-surfaces/runjs-authoring/ast/walk.d.ts +10 -0
  35. package/dist/server/flow-surfaces/runjs-authoring/ast/walk.js +55 -0
  36. package/dist/server/flow-surfaces/runjs-authoring/collectors.d.ts +12 -0
  37. package/dist/server/flow-surfaces/runjs-authoring/collectors.js +589 -0
  38. package/dist/server/flow-surfaces/runjs-authoring/index.d.ts +2 -25
  39. package/dist/server/flow-surfaces/runjs-authoring/index.js +5 -11138
  40. package/dist/server/flow-surfaces/runjs-authoring/inspect.d.ts +13 -0
  41. package/dist/server/flow-surfaces/runjs-authoring/inspect.js +149 -0
  42. package/dist/server/flow-surfaces/runjs-authoring/internal-types.d.ts +333 -0
  43. package/dist/server/flow-surfaces/runjs-authoring/internal-types.js +36 -0
  44. package/dist/server/flow-surfaces/runjs-authoring/rules.js +2 -0
  45. package/dist/server/flow-surfaces/runjs-authoring/runtime/constants.d.ts +67 -0
  46. package/dist/server/flow-surfaces/runjs-authoring/runtime/constants.js +757 -0
  47. package/dist/server/flow-surfaces/runjs-authoring/runtime/errors.d.ts +22 -0
  48. package/dist/server/flow-surfaces/runjs-authoring/runtime/errors.js +91 -0
  49. package/dist/server/flow-surfaces/runjs-authoring/runtime/source-budget.d.ts +16 -0
  50. package/dist/server/flow-surfaces/runjs-authoring/runtime/source-budget.js +115 -0
  51. package/dist/server/flow-surfaces/runjs-authoring/runtime/surface.d.ts +19 -0
  52. package/dist/server/flow-surfaces/runjs-authoring/runtime/surface.js +140 -0
  53. package/dist/server/flow-surfaces/runjs-authoring/runtime/types.d.ts +91 -0
  54. package/dist/server/flow-surfaces/runjs-authoring/runtime/types.js +24 -0
  55. package/dist/server/flow-surfaces/runjs-authoring/scan/ctx-api.d.ts +138 -0
  56. package/dist/server/flow-surfaces/runjs-authoring/scan/ctx-api.js +1779 -0
  57. package/dist/server/flow-surfaces/runjs-authoring/scan/filter.d.ts +10 -0
  58. package/dist/server/flow-surfaces/runjs-authoring/scan/filter.js +1583 -0
  59. package/dist/server/flow-surfaces/runjs-authoring/scan/index.d.ts +195 -0
  60. package/dist/server/flow-surfaces/runjs-authoring/scan/index.js +463 -0
  61. package/dist/server/flow-surfaces/runjs-authoring/scan/react-render.d.ts +48 -0
  62. package/dist/server/flow-surfaces/runjs-authoring/scan/react-render.js +379 -0
  63. package/dist/server/flow-surfaces/runjs-authoring/scan/react.d.ts +26 -0
  64. package/dist/server/flow-surfaces/runjs-authoring/scan/react.js +1441 -0
  65. package/dist/server/flow-surfaces/runjs-authoring/scan/resource.d.ts +23 -0
  66. package/dist/server/flow-surfaces/runjs-authoring/scan/resource.js +1427 -0
  67. package/dist/server/flow-surfaces/runjs-authoring/scan/source-patterns.d.ts +91 -0
  68. package/dist/server/flow-surfaces/runjs-authoring/scan/source-patterns.js +889 -0
  69. package/dist/server/flow-surfaces/runjs-authoring/types.d.ts +1 -1
  70. package/dist/server/flow-surfaces/runjs-authoring/unknown-global-stop/index.d.ts +10 -0
  71. package/dist/server/flow-surfaces/runjs-authoring/unknown-global-stop/index.js +40 -0
  72. package/dist/server/flow-surfaces/runjs-authoring/validators/index.d.ts +12 -0
  73. package/dist/server/flow-surfaces/runjs-authoring/validators/index.js +887 -0
  74. package/dist/server/flow-surfaces/service-helpers.d.ts +29 -0
  75. package/dist/server/flow-surfaces/service-helpers.js +105 -0
  76. package/dist/server/flow-surfaces/service-utils.d.ts +15 -3
  77. package/dist/server/flow-surfaces/service-utils.js +5 -4
  78. package/dist/server/flow-surfaces/service.d.ts +4 -0
  79. package/dist/server/flow-surfaces/service.js +360 -30
  80. package/dist/server/flow-surfaces/types.d.ts +3 -0
  81. package/dist/server/repository.d.ts +12 -1
  82. package/dist/server/repository.js +195 -23
  83. package/dist/swagger/flow-surfaces.d.ts +175 -0
  84. package/dist/swagger/flow-surfaces.js +130 -51
  85. package/dist/swagger/index.d.ts +175 -0
  86. package/package.json +2 -2
@@ -0,0 +1,10 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ export declare function walkAstSimple(ast: any, visitors: Record<string, (...args: any[]) => void>): void;
10
+ export declare function walkAstAncestor(ast: any, visitors: Record<string, (...args: any[]) => void>): void;
@@ -0,0 +1,55 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __create = Object.create;
11
+ var __defProp = Object.defineProperty;
12
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
13
+ var __getOwnPropNames = Object.getOwnPropertyNames;
14
+ var __getProtoOf = Object.getPrototypeOf;
15
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
16
+ var __export = (target, all) => {
17
+ for (var name in all)
18
+ __defProp(target, name, { get: all[name], enumerable: true });
19
+ };
20
+ var __copyProps = (to, from, except, desc) => {
21
+ if (from && typeof from === "object" || typeof from === "function") {
22
+ for (let key of __getOwnPropNames(from))
23
+ if (!__hasOwnProp.call(to, key) && key !== except)
24
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
25
+ }
26
+ return to;
27
+ };
28
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
+ // If the importer is in node compatibility mode or this is not an ESM
30
+ // file that has been converted to a CommonJS file using a Babel-
31
+ // compatible transform (i.e. "__esModule" has not been set), then set
32
+ // "default" to the CommonJS "module.exports" for node compatibility.
33
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
+ mod
35
+ ));
36
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
+ var walk_exports = {};
38
+ __export(walk_exports, {
39
+ walkAstAncestor: () => walkAstAncestor,
40
+ walkAstSimple: () => walkAstSimple
41
+ });
42
+ module.exports = __toCommonJS(walk_exports);
43
+ var acornWalk = __toESM(require("acorn-walk"));
44
+ var import_parser = require("./parser");
45
+ function walkAstSimple(ast, visitors) {
46
+ acornWalk.simple(ast, visitors, import_parser.ACORN_WALK_BASE);
47
+ }
48
+ function walkAstAncestor(ast, visitors) {
49
+ acornWalk.ancestor(ast, visitors, import_parser.ACORN_WALK_BASE);
50
+ }
51
+ // Annotate the CommonJS export names for ESM import in node:
52
+ 0 && (module.exports = {
53
+ walkAstAncestor,
54
+ walkAstSimple
55
+ });
@@ -0,0 +1,12 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import type { FlowSurfaceErrorItemInput } from '../errors';
10
+ import type { FlowSurfaceAuthoringWriteAction, RunJsAuthoringContext } from './internal-types';
11
+ export declare function collectRunJsAuthoringErrors(actionName: FlowSurfaceAuthoringWriteAction, values: any, context?: RunJsAuthoringContext): FlowSurfaceErrorItemInput[];
12
+ export declare function collectFlowRegistryRunJsAuthoringErrors(flowRegistry: any, path?: string, context?: RunJsAuthoringContext): FlowSurfaceErrorItemInput[];
@@ -0,0 +1,589 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __create = Object.create;
11
+ var __defProp = Object.defineProperty;
12
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
13
+ var __getOwnPropNames = Object.getOwnPropertyNames;
14
+ var __getProtoOf = Object.getPrototypeOf;
15
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
16
+ var __export = (target, all) => {
17
+ for (var name in all)
18
+ __defProp(target, name, { get: all[name], enumerable: true });
19
+ };
20
+ var __copyProps = (to, from, except, desc) => {
21
+ if (from && typeof from === "object" || typeof from === "function") {
22
+ for (let key of __getOwnPropNames(from))
23
+ if (!__hasOwnProp.call(to, key) && key !== except)
24
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
25
+ }
26
+ return to;
27
+ };
28
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
+ // If the importer is in node compatibility mode or this is not an ESM
30
+ // file that has been converted to a CommonJS file using a Babel-
31
+ // compatible transform (i.e. "__esModule" has not been set), then set
32
+ // "default" to the CommonJS "module.exports" for node compatibility.
33
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
+ mod
35
+ ));
36
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
+ var collectors_exports = {};
38
+ __export(collectors_exports, {
39
+ collectFlowRegistryRunJsAuthoringErrors: () => collectFlowRegistryRunJsAuthoringErrors,
40
+ collectRunJsAuthoringErrors: () => collectRunJsAuthoringErrors
41
+ });
42
+ module.exports = __toCommonJS(collectors_exports);
43
+ var _ = __toESM(require("lodash"));
44
+ var import_chart_config = require("../chart-config");
45
+ var import_errors = require("./runtime/errors");
46
+ var import_source_budget = require("./runtime/source-budget");
47
+ var import_surface = require("./runtime/surface");
48
+ var import_inspect = require("./inspect");
49
+ const HIDDEN_POPUP_SETTINGS_KEYS_BY_BLOCK_TYPE = {
50
+ calendar: ["quickCreatePopup", "eventPopup"],
51
+ kanban: ["quickCreatePopup", "cardPopup"]
52
+ };
53
+ function asPlainRecord(value) {
54
+ return _.isPlainObject(value) ? value : void 0;
55
+ }
56
+ function collectRunJsAuthoringErrors(actionName, values, context = {}) {
57
+ var _a, _b;
58
+ const errors = [];
59
+ const validationContext = {
60
+ ...context,
61
+ authoringActionName: actionName,
62
+ runJsSourceBudget: (0, import_source_budget.createRunJsSourceBudget)()
63
+ };
64
+ if (!_.isPlainObject(values)) {
65
+ return errors;
66
+ }
67
+ if (actionName === "configure") {
68
+ collectConfigureRunJsErrors(values, validationContext, errors);
69
+ collectReactionRunJsErrors(
70
+ values.reaction,
71
+ "$.reaction",
72
+ errors,
73
+ validationContext.runJsSourceBudget,
74
+ validationContext
75
+ );
76
+ collectReactionRunJsErrors(
77
+ (_a = values.changes) == null ? void 0 : _a.reaction,
78
+ "$.changes.reaction",
79
+ errors,
80
+ validationContext.runJsSourceBudget,
81
+ validationContext
82
+ );
83
+ return (0, import_errors.dedupeErrors)(errors);
84
+ }
85
+ if (actionName === "applyBlueprint") {
86
+ collectChartAssetRunJsErrors(
87
+ (_b = values.assets) == null ? void 0 : _b.charts,
88
+ "$.assets.charts",
89
+ errors,
90
+ validationContext.runJsSourceBudget,
91
+ validationContext
92
+ );
93
+ }
94
+ getAuthoringBlocks(actionName, values).forEach(
95
+ ({ block, path }) => collectBlockRunJsErrors(block, path, validationContext, errors)
96
+ );
97
+ collectReactionRunJsErrors(
98
+ values.reaction,
99
+ "$.reaction",
100
+ errors,
101
+ validationContext.runJsSourceBudget,
102
+ validationContext
103
+ );
104
+ return (0, import_errors.dedupeErrors)(errors);
105
+ }
106
+ function collectFlowRegistryRunJsAuthoringErrors(flowRegistry, path = "$.flowRegistry", context = {}) {
107
+ const errors = [];
108
+ collectFlowRegistryRunJsErrors(flowRegistry, path, errors, (0, import_source_budget.createRunJsSourceBudget)(), context);
109
+ return (0, import_errors.dedupeErrors)(errors);
110
+ }
111
+ function collectConfigureRunJsErrors(values, context, errors) {
112
+ var _a;
113
+ const changes = values.changes;
114
+ if (!_.isPlainObject(changes)) {
115
+ return;
116
+ }
117
+ const modelUse = (0, import_surface.resolveConfigureModelUse)(context.currentNode);
118
+ const surfaceStyle = (0, import_surface.resolveModelSurfaceStyle)(modelUse);
119
+ const hostBlockType = (0, import_surface.resolveConfigureBlockType)(context);
120
+ if (typeof changes.code === "string" && changes.code.trim()) {
121
+ errors.push(
122
+ ...(0, import_inspect.inspectRunJsAuthoringCodeForWrite)(
123
+ {
124
+ code: changes.code,
125
+ path: "$.changes.code",
126
+ modelUse: modelUse || "unknown",
127
+ surfaceStyle
128
+ },
129
+ context.runJsSourceBudget,
130
+ context
131
+ )
132
+ );
133
+ }
134
+ if (hostBlockType === "chart") {
135
+ collectChartRawRunJsErrors(changes, "$.changes", errors, context.runJsSourceBudget, context);
136
+ collectChartLegacyConfigureRunJsErrors(
137
+ changes.configure,
138
+ "$.changes.configure",
139
+ errors,
140
+ context.runJsSourceBudget,
141
+ context
142
+ );
143
+ }
144
+ const recursiveChanges = {
145
+ ...changes,
146
+ type: hostBlockType
147
+ };
148
+ delete recursiveChanges.code;
149
+ delete recursiveChanges.source;
150
+ if (_.isPlainObject(recursiveChanges.settings)) {
151
+ recursiveChanges.settings = _.omit(recursiveChanges.settings, ["code", "source"]);
152
+ }
153
+ collectBlockRunJsErrors(recursiveChanges, "$.changes", context, errors);
154
+ (_a = HIDDEN_POPUP_SETTINGS_KEYS_BY_BLOCK_TYPE[hostBlockType]) == null ? void 0 : _a.forEach((key) => {
155
+ var _a2, _b;
156
+ collectBlockListRunJsErrors((_a2 = changes == null ? void 0 : changes[key]) == null ? void 0 : _a2.blocks, `$.changes.${key}.blocks`, context, errors);
157
+ collectReactionRunJsErrors(
158
+ (_b = changes == null ? void 0 : changes[key]) == null ? void 0 : _b.reaction,
159
+ `$.changes.${key}.reaction`,
160
+ errors,
161
+ context.runJsSourceBudget,
162
+ context
163
+ );
164
+ });
165
+ }
166
+ function createRunJsResourceContext(context, resourceInit) {
167
+ const collectionName = (0, import_surface.normalizeText)(resourceInit == null ? void 0 : resourceInit.collectionName);
168
+ if (!collectionName) {
169
+ return context;
170
+ }
171
+ const dataSourceKey = (0, import_surface.normalizeText)(resourceInit == null ? void 0 : resourceInit.dataSourceKey) || (0, import_surface.normalizeText)(context.currentDataSourceKey || context.hostDataSourceKey) || "main";
172
+ return {
173
+ ...context,
174
+ currentDataSourceKey: dataSourceKey,
175
+ currentCollectionName: collectionName
176
+ };
177
+ }
178
+ function getRunJsBlockResourceInit(block, blockType) {
179
+ var _a, _b;
180
+ const resourceInit = asPlainRecord(block == null ? void 0 : block.resourceInit);
181
+ const resource = asPlainRecord(block == null ? void 0 : block.resource);
182
+ const chartResourceInit = blockType === "chart" ? (0, import_chart_config.getChartBuilderResourceInit)(((_a = block == null ? void 0 : block.settings) == null ? void 0 : _a.configure) || (block == null ? void 0 : block.configure) || ((_b = block == null ? void 0 : block.chartSettings) == null ? void 0 : _b.configure)) : null;
183
+ return {
184
+ dataSourceKey: (block == null ? void 0 : block.dataSourceKey) || (resource == null ? void 0 : resource.dataSourceKey) || (resourceInit == null ? void 0 : resourceInit.dataSourceKey) || (chartResourceInit == null ? void 0 : chartResourceInit.dataSourceKey),
185
+ collectionName: (block == null ? void 0 : block.collection) || (resource == null ? void 0 : resource.collectionName) || (resourceInit == null ? void 0 : resourceInit.collectionName) || (chartResourceInit == null ? void 0 : chartResourceInit.collectionName)
186
+ };
187
+ }
188
+ function getAuthoringBlocks(actionName, values) {
189
+ if (actionName === "addBlock") {
190
+ return [{ block: values, path: "$" }];
191
+ }
192
+ if (actionName === "addBlocks" || actionName === "compose") {
193
+ return _.castArray(values.blocks || []).map((block, index) => ({
194
+ block,
195
+ path: `$.blocks[${index}]`
196
+ }));
197
+ }
198
+ if (actionName === "applyBlueprint") {
199
+ return _.castArray(values.tabs || []).flatMap(
200
+ (tab, tabIndex) => _.castArray((tab == null ? void 0 : tab.blocks) || []).map((block, blockIndex) => ({
201
+ block,
202
+ path: `$.tabs[${tabIndex}].blocks[${blockIndex}]`
203
+ }))
204
+ );
205
+ }
206
+ return [];
207
+ }
208
+ function collectBlockRunJsErrors(block, path, context, errors) {
209
+ var _a, _b, _c, _d;
210
+ if (!_.isPlainObject(block)) {
211
+ return;
212
+ }
213
+ const blockType = (0, import_surface.resolvePublicBlockType)(block.type || block.use);
214
+ const blockContext = createRunJsResourceContext(context, getRunJsBlockResourceInit(block, blockType));
215
+ if (blockType === "jsBlock") {
216
+ collectRunJsSources(block, path, blockContext).forEach((source) => {
217
+ errors.push(
218
+ ...(0, import_inspect.inspectRunJsAuthoringCodeForWrite)(
219
+ {
220
+ code: source.code,
221
+ path: source.path,
222
+ modelUse: "JSBlockModel",
223
+ surfaceStyle: "render"
224
+ },
225
+ blockContext.runJsSourceBudget,
226
+ blockContext
227
+ )
228
+ );
229
+ });
230
+ }
231
+ if (blockType === "chart") {
232
+ collectChartRawRunJsErrors(
233
+ block.settings,
234
+ `${path}.settings`,
235
+ errors,
236
+ blockContext.runJsSourceBudget,
237
+ blockContext
238
+ );
239
+ collectChartLegacyConfigureRunJsErrors(
240
+ (_a = block.settings) == null ? void 0 : _a.configure,
241
+ `${path}.settings.configure`,
242
+ errors,
243
+ blockContext.runJsSourceBudget,
244
+ blockContext
245
+ );
246
+ }
247
+ collectFieldListRunJsErrors(block.fields, `${path}.fields`, blockType, blockContext, errors);
248
+ _.castArray(block.fieldGroups || []).forEach((group, groupIndex) => {
249
+ collectFieldListRunJsErrors(
250
+ group == null ? void 0 : group.fields,
251
+ `${path}.fieldGroups[${groupIndex}].fields`,
252
+ blockType,
253
+ blockContext,
254
+ errors
255
+ );
256
+ });
257
+ collectActionListRunJsErrors(block.actions, `${path}.actions`, blockType, "actions", blockContext, errors);
258
+ collectActionListRunJsErrors(
259
+ block.recordActions,
260
+ `${path}.recordActions`,
261
+ blockType,
262
+ "recordActions",
263
+ blockContext,
264
+ errors
265
+ );
266
+ collectReactionRunJsErrors(block.reaction, `${path}.reaction`, errors, blockContext.runJsSourceBudget, blockContext);
267
+ collectFlowRegistryRunJsErrors(
268
+ block.flowRegistry,
269
+ `${path}.flowRegistry`,
270
+ errors,
271
+ blockContext.runJsSourceBudget,
272
+ blockContext
273
+ );
274
+ collectBlockListRunJsErrors(block.blocks, `${path}.blocks`, blockContext, errors);
275
+ collectBlockListRunJsErrors((_b = block.popup) == null ? void 0 : _b.blocks, `${path}.popup.blocks`, blockContext, errors);
276
+ collectReactionRunJsErrors(
277
+ (_c = block.popup) == null ? void 0 : _c.reaction,
278
+ `${path}.popup.reaction`,
279
+ errors,
280
+ blockContext.runJsSourceBudget,
281
+ blockContext
282
+ );
283
+ (_d = HIDDEN_POPUP_SETTINGS_KEYS_BY_BLOCK_TYPE[blockType]) == null ? void 0 : _d.forEach((key) => {
284
+ var _a2, _b2, _c2, _d2;
285
+ collectBlockListRunJsErrors((_b2 = (_a2 = block.settings) == null ? void 0 : _a2[key]) == null ? void 0 : _b2.blocks, `${path}.settings.${key}.blocks`, blockContext, errors);
286
+ collectReactionRunJsErrors(
287
+ (_d2 = (_c2 = block.settings) == null ? void 0 : _c2[key]) == null ? void 0 : _d2.reaction,
288
+ `${path}.settings.${key}.reaction`,
289
+ errors,
290
+ blockContext.runJsSourceBudget,
291
+ blockContext
292
+ );
293
+ });
294
+ }
295
+ function collectBlockListRunJsErrors(blocks, path, context, errors) {
296
+ if (!Array.isArray(blocks)) {
297
+ return;
298
+ }
299
+ blocks.forEach((block, index) => collectBlockRunJsErrors(block, `${path}[${index}]`, context, errors));
300
+ }
301
+ function collectFieldListRunJsErrors(fields, path, blockType, context, errors) {
302
+ if (!Array.isArray(fields)) {
303
+ return;
304
+ }
305
+ fields.forEach((field, index) => {
306
+ var _a, _b;
307
+ const fieldPath = `${path}[${index}]`;
308
+ if (!_.isPlainObject(field)) {
309
+ return;
310
+ }
311
+ const type = (0, import_surface.normalizeText)(field.type);
312
+ const renderer = (0, import_surface.normalizeText)(field.renderer);
313
+ const modelUse = (0, import_surface.resolveFieldModelUse)(type, renderer, blockType);
314
+ if (modelUse) {
315
+ collectRunJsSources(field, fieldPath, context).forEach((source) => {
316
+ errors.push(
317
+ ...(0, import_inspect.inspectRunJsAuthoringCodeForWrite)(
318
+ {
319
+ code: source.code,
320
+ path: source.path,
321
+ modelUse,
322
+ surfaceStyle: "render"
323
+ },
324
+ context.runJsSourceBudget,
325
+ context
326
+ )
327
+ );
328
+ });
329
+ }
330
+ collectReactionRunJsErrors(field.reaction, `${fieldPath}.reaction`, errors, context.runJsSourceBudget, context);
331
+ collectActionListRunJsErrors(field.actions, `${fieldPath}.actions`, blockType, "actions", context, errors);
332
+ collectBlockListRunJsErrors((_a = field.popup) == null ? void 0 : _a.blocks, `${fieldPath}.popup.blocks`, context, errors);
333
+ collectReactionRunJsErrors(
334
+ (_b = field.popup) == null ? void 0 : _b.reaction,
335
+ `${fieldPath}.popup.reaction`,
336
+ errors,
337
+ context.runJsSourceBudget,
338
+ context
339
+ );
340
+ });
341
+ }
342
+ function collectActionListRunJsErrors(actions, path, blockType, slot, context, errors) {
343
+ if (!Array.isArray(actions)) {
344
+ return;
345
+ }
346
+ actions.forEach((action, index) => {
347
+ var _a, _b, _c, _d;
348
+ const actionPath = `${path}[${index}]`;
349
+ if (!_.isPlainObject(action)) {
350
+ return;
351
+ }
352
+ const actionType = (0, import_surface.normalizeActionType)(action.type || action.key || action.action || action.use);
353
+ const modelUse = (0, import_surface.resolveActionModelUse)(actionType, blockType, slot);
354
+ if (modelUse) {
355
+ collectRunJsSources(action, actionPath, context).forEach((source) => {
356
+ errors.push(
357
+ ...(0, import_inspect.inspectRunJsAuthoringCodeForWrite)(
358
+ {
359
+ code: source.code,
360
+ path: source.path,
361
+ modelUse,
362
+ surfaceStyle: (0, import_surface.resolveModelSurfaceStyle)(modelUse)
363
+ },
364
+ context.runJsSourceBudget,
365
+ context
366
+ )
367
+ );
368
+ });
369
+ }
370
+ collectReactionRunJsErrors(action.reaction, `${actionPath}.reaction`, errors, context.runJsSourceBudget, context);
371
+ collectBlockListRunJsErrors((_a = action.popup) == null ? void 0 : _a.blocks, `${actionPath}.popup.blocks`, context, errors);
372
+ collectReactionRunJsErrors(
373
+ (_b = action.popup) == null ? void 0 : _b.reaction,
374
+ `${actionPath}.popup.reaction`,
375
+ errors,
376
+ context.runJsSourceBudget,
377
+ context
378
+ );
379
+ collectBlockListRunJsErrors((_c = action.openView) == null ? void 0 : _c.blocks, `${actionPath}.openView.blocks`, context, errors);
380
+ collectReactionRunJsErrors(
381
+ (_d = action.openView) == null ? void 0 : _d.reaction,
382
+ `${actionPath}.openView.reaction`,
383
+ errors,
384
+ context.runJsSourceBudget,
385
+ context
386
+ );
387
+ });
388
+ }
389
+ function collectChartAssetRunJsErrors(charts, path, errors, budget, context = {}) {
390
+ if (!_.isPlainObject(charts)) {
391
+ return;
392
+ }
393
+ Object.entries(charts).forEach(([key, asset]) => {
394
+ if (!_.isPlainObject(asset)) {
395
+ return;
396
+ }
397
+ collectChartRawRunJsErrors(
398
+ asset,
399
+ `${path}.${key}`,
400
+ errors,
401
+ budget,
402
+ createRunJsResourceContext(context, (0, import_chart_config.getChartBuilderResourceInit)(asset))
403
+ );
404
+ });
405
+ }
406
+ function collectChartLegacyConfigureRunJsErrors(configure, path, errors, budget, context = {}) {
407
+ if (!_.isPlainObject(configure)) {
408
+ return;
409
+ }
410
+ const chartContext = createRunJsResourceContext(context, (0, import_chart_config.getChartBuilderResourceInit)(configure));
411
+ const chart = _.isPlainObject(configure.chart) ? configure.chart : void 0;
412
+ const option = _.isPlainObject(chart == null ? void 0 : chart.option) ? chart.option : void 0;
413
+ const events = _.isPlainObject(chart == null ? void 0 : chart.events) ? chart.events : void 0;
414
+ collectChartOptionRunJsErrors(option == null ? void 0 : option.raw, `${path}.chart.option.raw`, errors, budget, chartContext);
415
+ collectChartEventsRunJsErrors(events == null ? void 0 : events.raw, `${path}.chart.events.raw`, errors, budget, chartContext);
416
+ }
417
+ function collectChartRawRunJsErrors(value, path, errors, budget, context = {}) {
418
+ if (!_.isPlainObject(value)) {
419
+ return;
420
+ }
421
+ const chartContext = createRunJsResourceContext(context, (0, import_chart_config.getChartBuilderResourceInit)(value));
422
+ const visual = _.isPlainObject(value.visual) ? value.visual : void 0;
423
+ const events = _.isPlainObject(value.events) ? value.events : void 0;
424
+ collectChartOptionRunJsErrors(visual == null ? void 0 : visual.raw, `${path}.visual.raw`, errors, budget, chartContext);
425
+ collectChartEventsRunJsErrors(events == null ? void 0 : events.raw, `${path}.events.raw`, errors, budget, chartContext);
426
+ }
427
+ function collectChartOptionRunJsErrors(code, path, errors, budget, context = {}) {
428
+ if (typeof code !== "string" || !code.trim()) {
429
+ return;
430
+ }
431
+ errors.push(
432
+ ...(0, import_inspect.inspectRunJsAuthoringCodeForWrite)(
433
+ {
434
+ code,
435
+ path,
436
+ modelUse: "ChartOptionModel",
437
+ surfaceStyle: "value"
438
+ },
439
+ budget,
440
+ context
441
+ )
442
+ );
443
+ }
444
+ function collectChartEventsRunJsErrors(code, path, errors, budget, context = {}) {
445
+ if (typeof code !== "string" || !code.trim()) {
446
+ return;
447
+ }
448
+ errors.push(
449
+ ...(0, import_inspect.inspectRunJsAuthoringCodeForWrite)(
450
+ {
451
+ code,
452
+ path,
453
+ modelUse: "ChartEventsModel",
454
+ surfaceStyle: "action"
455
+ },
456
+ budget,
457
+ context
458
+ )
459
+ );
460
+ }
461
+ function collectReactionRunJsErrors(reaction, path, errors, budget, context = {}) {
462
+ if (!reaction || !_.isPlainObject(reaction) && !Array.isArray(reaction)) {
463
+ return;
464
+ }
465
+ const visit = (value, valuePath) => {
466
+ var _a, _b, _c, _d, _e;
467
+ if (Array.isArray(value)) {
468
+ value.forEach((item, index) => visit(item, `${valuePath}[${index}]`));
469
+ return;
470
+ }
471
+ if (!_.isPlainObject(value)) {
472
+ return;
473
+ }
474
+ if (value.source === "runjs" && typeof value.code === "string" && value.code.trim()) {
475
+ errors.push(
476
+ ...(0, import_inspect.inspectRunJsAuthoringCodeForWrite)(
477
+ {
478
+ code: value.code,
479
+ path: `${valuePath}.code`,
480
+ surface: "reaction.value-runjs",
481
+ surfaceStyle: "value"
482
+ },
483
+ budget,
484
+ context
485
+ )
486
+ );
487
+ }
488
+ const actionType = (0, import_surface.normalizeText)(value.type || value.name);
489
+ if (actionType === "runjs" || /runjs/i.test(actionType)) {
490
+ const code = typeof value.code === "string" ? value.code : typeof ((_b = (_a = value.params) == null ? void 0 : _a.value) == null ? void 0 : _b.script) === "string" ? value.params.value.script : typeof ((_c = value.params) == null ? void 0 : _c.code) === "string" ? value.params.code : "";
491
+ if (code.trim()) {
492
+ const codePath = typeof value.code === "string" ? `${valuePath}.code` : typeof ((_e = (_d = value.params) == null ? void 0 : _d.value) == null ? void 0 : _e.script) === "string" ? `${valuePath}.params.value.script` : `${valuePath}.params.code`;
493
+ errors.push(
494
+ ...(0, import_inspect.inspectRunJsAuthoringCodeForWrite)(
495
+ {
496
+ code,
497
+ path: codePath,
498
+ surface: "linkage.execute-javascript",
499
+ surfaceStyle: "action"
500
+ },
501
+ budget,
502
+ context
503
+ )
504
+ );
505
+ }
506
+ }
507
+ Object.entries(value).forEach(([key, child]) => {
508
+ if (key === "code" || key === "params") {
509
+ return;
510
+ }
511
+ visit(child, `${valuePath}.${key}`);
512
+ });
513
+ };
514
+ visit(reaction, path);
515
+ }
516
+ function collectFlowRegistryRunJsErrors(flowRegistry, path, errors, budget, context = {}) {
517
+ const registry = asPlainRecord(flowRegistry);
518
+ if (!registry) {
519
+ return;
520
+ }
521
+ Object.entries(registry).forEach(([flowKey, flowValue]) => {
522
+ const flow = asPlainRecord(flowValue);
523
+ if (!flow) {
524
+ return;
525
+ }
526
+ const steps = asPlainRecord(flow.steps) || {};
527
+ Object.entries(steps).forEach(([stepKey, stepValue]) => {
528
+ const step = asPlainRecord(stepValue);
529
+ if (!step || (0, import_surface.normalizeText)(step.use || step.type || step.action || step.key) !== "runjs") {
530
+ return;
531
+ }
532
+ collectEventFlowRunJsStepErrors(step, `${path}.${flowKey}.steps.${stepKey}`, errors, budget, context);
533
+ });
534
+ });
535
+ }
536
+ function collectEventFlowRunJsStepErrors(step, path, errors, budget, context = {}) {
537
+ var _a, _b, _c, _d, _e, _f;
538
+ const addSource = (code, sourcePath) => {
539
+ if (typeof code !== "string" || !code.trim()) {
540
+ return;
541
+ }
542
+ errors.push(
543
+ ...(0, import_inspect.inspectRunJsAuthoringCodeForWrite)(
544
+ {
545
+ code,
546
+ path: sourcePath,
547
+ surface: "event-flow.execute-javascript",
548
+ modelUse: "JSActionModel",
549
+ surfaceStyle: "action"
550
+ },
551
+ budget,
552
+ context
553
+ )
554
+ );
555
+ };
556
+ addSource((_a = step.defaultParams) == null ? void 0 : _a.code, `${path}.defaultParams.code`);
557
+ addSource((_b = step.params) == null ? void 0 : _b.code, `${path}.params.code`);
558
+ addSource((_d = (_c = step.defaultParams) == null ? void 0 : _c.value) == null ? void 0 : _d.script, `${path}.defaultParams.value.script`);
559
+ addSource((_f = (_e = step.params) == null ? void 0 : _e.value) == null ? void 0 : _f.script, `${path}.params.value.script`);
560
+ }
561
+ function collectRunJsSources(spec, path, context) {
562
+ const sources = [];
563
+ const settings = _.isPlainObject(spec.settings) ? spec.settings : void 0;
564
+ const addSource = (code, sourcePath) => {
565
+ if (typeof code === "string" && code.trim()) {
566
+ sources.push({ code, path: sourcePath });
567
+ }
568
+ };
569
+ addSource(settings == null ? void 0 : settings.code, `${path}.settings.code`);
570
+ addSource(settings == null ? void 0 : settings.source, `${path}.settings.source`);
571
+ addSource(spec.code, `${path}.code`);
572
+ addSource(spec.source, `${path}.source`);
573
+ if (context.authoringActionName === "applyBlueprint" && typeof spec.script === "string" && spec.script.trim()) {
574
+ const scriptKey = spec.script.trim();
575
+ const asset = _.isPlainObject(context.applyBlueprintScriptAssets) ? context.applyBlueprintScriptAssets[scriptKey] : void 0;
576
+ if (_.isPlainObject(asset) && typeof asset.code === "string" && asset.code.trim()) {
577
+ sources.push({
578
+ code: asset.code,
579
+ path: `${path}.script`
580
+ });
581
+ }
582
+ }
583
+ return sources;
584
+ }
585
+ // Annotate the CommonJS export names for ESM import in node:
586
+ 0 && (module.exports = {
587
+ collectFlowRegistryRunJsAuthoringErrors,
588
+ collectRunJsAuthoringErrors
589
+ });