@nocobase/plugin-flow-engine 2.2.0-alpha.1 → 2.2.0-alpha.11

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/ai/ai-employees/nathan/prompt.md +2 -0
  2. package/dist/ai/ai-employees/nathan/skills/frontend-developer/SKILLS.md +1 -0
  3. package/dist/ai/ai-employees/nathan/skills/frontend-developer/tools/getContextApis.js +2 -2
  4. package/dist/ai/ai-employees/nathan/skills/frontend-developer/tools/getContextEnvs.js +2 -2
  5. package/dist/ai/ai-employees/nathan/skills/frontend-developer/tools/getContextVars.js +2 -2
  6. package/dist/ai/ai-employees/nathan/skills/frontend-developer/tools/lintAndTestJS.js +2 -2
  7. package/dist/ai/ai-employees/nathan/skills/frontend-developer/tools/patchJSCode.js +4 -4
  8. package/dist/ai/ai-employees/nathan/skills/frontend-developer/tools/readJSCode.js +2 -2
  9. package/dist/ai/ai-employees/nathan/skills/frontend-developer/tools/writeJSCode.js +2 -2
  10. package/dist/ai/docs/runjs/context/ai.md +206 -0
  11. package/dist/client/index.js +1 -1
  12. package/dist/externalVersion.js +9 -9
  13. package/dist/locale/en-US.json +3 -0
  14. package/dist/locale/index.d.ts +6 -0
  15. package/dist/locale/zh-CN.json +3 -0
  16. package/dist/node_modules/@ant-design/icons-svg/package.json +1 -1
  17. package/dist/node_modules/acorn/package.json +1 -1
  18. package/dist/node_modules/acorn-jsx/package.json +1 -1
  19. package/dist/node_modules/acorn-walk/package.json +1 -1
  20. package/dist/node_modules/ses/package.json +1 -1
  21. package/dist/node_modules/zod/package.json +1 -1
  22. package/dist/server/flow-surfaces/{runjs-authoring/blocked-global-stop/index.d.ts → approval/authoring-validation.d.ts} +1 -2
  23. package/dist/server/flow-surfaces/approval/authoring-validation.js +1151 -0
  24. package/dist/server/flow-surfaces/approval/blueprint-service.js +2 -0
  25. package/dist/server/flow-surfaces/authoring-validation.d.ts +3 -1
  26. package/dist/server/flow-surfaces/authoring-validation.js +645 -59
  27. package/dist/server/flow-surfaces/blueprint/compile-blocks.js +7 -3
  28. package/dist/server/flow-surfaces/blueprint/compile-plan.js +23 -15
  29. package/dist/server/flow-surfaces/blueprint/export-document.d.ts +50 -0
  30. package/dist/server/flow-surfaces/blueprint/export-document.js +2510 -0
  31. package/dist/server/flow-surfaces/blueprint/normalize-document.js +18 -1
  32. package/dist/server/flow-surfaces/blueprint/public-types.d.ts +2 -0
  33. package/dist/server/flow-surfaces/builder.js +43 -5
  34. package/dist/server/flow-surfaces/catalog.js +13 -2
  35. package/dist/server/flow-surfaces/configure-options.js +5 -3
  36. package/dist/server/flow-surfaces/constants.d.ts +16 -2
  37. package/dist/server/flow-surfaces/constants.js +2 -0
  38. package/dist/server/flow-surfaces/contract-guard.js +37 -5
  39. package/dist/server/flow-surfaces/default-action-popup.d.ts +2 -0
  40. package/dist/server/flow-surfaces/default-action-popup.js +27 -13
  41. package/dist/server/flow-surfaces/errors.d.ts +2 -2
  42. package/dist/server/flow-surfaces/errors.js +4 -4
  43. package/dist/server/flow-surfaces/filter-group.d.ts +19 -2
  44. package/dist/server/flow-surfaces/filter-group.js +232 -3
  45. package/dist/server/flow-surfaces/navigation-targets.d.ts +73 -0
  46. package/dist/server/flow-surfaces/navigation-targets.js +439 -0
  47. package/dist/server/flow-surfaces/planning/compiler.d.ts +1 -0
  48. package/dist/server/flow-surfaces/planning/compiler.js +205 -82
  49. package/dist/server/flow-surfaces/planning/key-registry.d.ts +1 -1
  50. package/dist/server/flow-surfaces/planning/runtime.js +1 -0
  51. package/dist/server/flow-surfaces/planning/step-link.d.ts +1 -1
  52. package/dist/server/flow-surfaces/planning/step-link.js +22 -3
  53. package/dist/server/flow-surfaces/public-data-surface-default-filter.js +0 -9
  54. package/dist/server/flow-surfaces/reaction/field-value.d.ts +9 -0
  55. package/dist/server/flow-surfaces/reaction/field-value.js +51 -2
  56. package/dist/server/flow-surfaces/reaction/linkage.d.ts +6 -1
  57. package/dist/server/flow-surfaces/reaction/linkage.js +18 -3
  58. package/dist/server/flow-surfaces/reaction/meta.js +19 -1
  59. package/dist/server/flow-surfaces/reaction/types.d.ts +19 -0
  60. package/dist/server/flow-surfaces/relation-backing-foreign-key.d.ts +10 -0
  61. package/dist/server/flow-surfaces/relation-backing-foreign-key.js +79 -0
  62. package/dist/server/flow-surfaces/runjs-authoring/ast/source.d.ts +1 -0
  63. package/dist/server/flow-surfaces/runjs-authoring/ast/source.js +20 -0
  64. package/dist/server/flow-surfaces/runjs-authoring/rules.js +0 -2
  65. package/dist/server/flow-surfaces/runjs-authoring/runtime/constants.d.ts +0 -1
  66. package/dist/server/flow-surfaces/runjs-authoring/runtime/constants.js +12 -19
  67. package/dist/server/flow-surfaces/runjs-authoring/runtime/types.d.ts +0 -12
  68. package/dist/server/flow-surfaces/runjs-authoring/scan/filter.js +12 -2
  69. package/dist/server/flow-surfaces/runjs-authoring/scan/index.d.ts +0 -14
  70. package/dist/server/flow-surfaces/runjs-authoring/scan/index.js +10 -8
  71. package/dist/server/flow-surfaces/runjs-authoring/scan/source-patterns.d.ts +0 -14
  72. package/dist/server/flow-surfaces/runjs-authoring/scan/source-patterns.js +18 -73
  73. package/dist/server/flow-surfaces/runjs-authoring/types.d.ts +1 -1
  74. package/dist/server/flow-surfaces/runjs-authoring/validators/index.js +9 -53
  75. package/dist/server/flow-surfaces/service.d.ts +65 -0
  76. package/dist/server/flow-surfaces/service.js +1372 -148
  77. package/dist/server/flow-surfaces/types.d.ts +2 -1
  78. package/dist/server/variables/records.js +7 -2
  79. package/dist/server/variables/registry.js +3 -0
  80. package/dist/swagger/flow-surfaces.d.ts +289 -0
  81. package/dist/swagger/flow-surfaces.examples.d.ts +11 -0
  82. package/dist/swagger/flow-surfaces.examples.js +11 -0
  83. package/dist/swagger/flow-surfaces.js +261 -11
  84. package/dist/swagger/index.d.ts +289 -0
  85. package/package.json +2 -2
  86. package/dist/server/flow-surfaces/runjs-authoring/blocked-global-stop/index.js +0 -40
@@ -163,6 +163,13 @@ export type FlowSurfaceReactionCapabilityBase<TKind extends FlowSurfaceReactionK
163
163
  };
164
164
  export type FlowSurfaceFieldValueCapability = FlowSurfaceReactionCapabilityBase<'fieldValue', FlowSurfaceFieldValueRule> & {
165
165
  targetFields: FlowSurfaceFieldOption[];
166
+ conditionMeta: {
167
+ operatorsByPath: Record<string, string[]>;
168
+ fieldMetaByPath?: Record<string, {
169
+ type?: string;
170
+ interface?: string;
171
+ }>;
172
+ };
166
173
  valueExprMeta: {
167
174
  supportedSources: Array<'literal' | 'path' | 'runjs'>;
168
175
  runjsScene: 'fieldValue';
@@ -172,17 +179,29 @@ export type FlowSurfaceLinkageCapability = (FlowSurfaceReactionCapabilityBase<'b
172
179
  supportedActions: Array<Record<string, any>>;
173
180
  conditionMeta: {
174
181
  operatorsByPath: Record<string, string[]>;
182
+ fieldMetaByPath?: Record<string, {
183
+ type?: string;
184
+ interface?: string;
185
+ }>;
175
186
  };
176
187
  }) | (FlowSurfaceReactionCapabilityBase<'actionLinkage', FlowSurfaceActionLinkageRule> & {
177
188
  supportedActions: Array<Record<string, any>>;
178
189
  conditionMeta: {
179
190
  operatorsByPath: Record<string, string[]>;
191
+ fieldMetaByPath?: Record<string, {
192
+ type?: string;
193
+ interface?: string;
194
+ }>;
180
195
  };
181
196
  }) | (FlowSurfaceReactionCapabilityBase<'fieldLinkage', FlowSurfaceFieldLinkageRule> & {
182
197
  supportedActions: Array<Record<string, any>>;
183
198
  targetFields: FlowSurfaceFieldOption[];
184
199
  conditionMeta: {
185
200
  operatorsByPath: Record<string, string[]>;
201
+ fieldMetaByPath?: Record<string, {
202
+ type?: string;
203
+ interface?: string;
204
+ }>;
186
205
  };
187
206
  valueExprMeta?: {
188
207
  supportedSources: Array<'literal' | 'path' | 'runjs'>;
@@ -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 collectRelationBackingForeignKeyNames(collection: any): Set<string>;
10
+ export declare function isRelationBackingForeignKeyField(collection: any, fieldOrFieldName: any): boolean;
@@ -0,0 +1,79 @@
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 __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var relation_backing_foreign_key_exports = {};
28
+ __export(relation_backing_foreign_key_exports, {
29
+ collectRelationBackingForeignKeyNames: () => collectRelationBackingForeignKeyNames,
30
+ isRelationBackingForeignKeyField: () => isRelationBackingForeignKeyField
31
+ });
32
+ module.exports = __toCommonJS(relation_backing_foreign_key_exports);
33
+ var import_service_helpers = require("./service-helpers");
34
+ const CURRENT_COLLECTION_FOREIGN_KEY_RELATION_TYPES = /* @__PURE__ */ new Set(["belongsto"]);
35
+ const CURRENT_COLLECTION_FOREIGN_KEY_RELATION_INTERFACES = /* @__PURE__ */ new Set(["m2o"]);
36
+ const CONDITIONAL_CURRENT_COLLECTION_FOREIGN_KEY_RELATION_INTERFACES = /* @__PURE__ */ new Set(["o2o"]);
37
+ const RELATION_INTERFACES_WITH_FOREIGN_KEYS_OUTSIDE_CURRENT_COLLECTION = /* @__PURE__ */ new Set(["o2m", "m2m", "mbm"]);
38
+ const RELATION_TYPES_WITH_FOREIGN_KEYS_OUTSIDE_CURRENT_COLLECTION = /* @__PURE__ */ new Set(["hasone", "hasmany", "belongstomany"]);
39
+ function collectRelationBackingForeignKeyNames(collection) {
40
+ const fields = (0, import_service_helpers.getCollectionFields)(collection);
41
+ const scalarFieldNames = new Set(
42
+ fields.filter((field) => !(0, import_service_helpers.isAssociationField)(field)).map((field) => String((0, import_service_helpers.getFieldName)(field) || "").trim()).filter(Boolean)
43
+ );
44
+ const names = /* @__PURE__ */ new Set();
45
+ fields.forEach((field) => {
46
+ const foreignKey = getCurrentCollectionRelationForeignKey(field);
47
+ if (foreignKey && scalarFieldNames.has(foreignKey)) {
48
+ names.add(foreignKey);
49
+ }
50
+ });
51
+ return names;
52
+ }
53
+ function isRelationBackingForeignKeyField(collection, fieldOrFieldName) {
54
+ const fieldName = typeof fieldOrFieldName === "string" ? fieldOrFieldName.trim() : String((0, import_service_helpers.getFieldName)(fieldOrFieldName) || "").trim();
55
+ return !!fieldName && collectRelationBackingForeignKeyNames(collection).has(fieldName);
56
+ }
57
+ function getCurrentCollectionRelationForeignKey(field) {
58
+ var _a;
59
+ if (!(0, import_service_helpers.isAssociationField)(field)) {
60
+ return "";
61
+ }
62
+ if (!relationCanStoreForeignKeyInCurrentCollection(field)) {
63
+ return "";
64
+ }
65
+ return String((field == null ? void 0 : field.foreignKey) || ((_a = field == null ? void 0 : field.options) == null ? void 0 : _a.foreignKey) || "").trim();
66
+ }
67
+ function relationCanStoreForeignKeyInCurrentCollection(field) {
68
+ const type = String((0, import_service_helpers.getFieldType)(field) || "").trim().toLowerCase();
69
+ const fieldInterface = String((0, import_service_helpers.getFieldInterface)(field) || "").trim().toLowerCase();
70
+ if (RELATION_TYPES_WITH_FOREIGN_KEYS_OUTSIDE_CURRENT_COLLECTION.has(type) || RELATION_INTERFACES_WITH_FOREIGN_KEYS_OUTSIDE_CURRENT_COLLECTION.has(fieldInterface)) {
71
+ return false;
72
+ }
73
+ return CURRENT_COLLECTION_FOREIGN_KEY_RELATION_TYPES.has(type) || CURRENT_COLLECTION_FOREIGN_KEY_RELATION_INTERFACES.has(fieldInterface) || CONDITIONAL_CURRENT_COLLECTION_FOREIGN_KEY_RELATION_INTERFACES.has(fieldInterface);
74
+ }
75
+ // Annotate the CommonJS export names for ESM import in node:
76
+ 0 && (module.exports = {
77
+ collectRelationBackingForeignKeyNames,
78
+ isRelationBackingForeignKeyField
79
+ });
@@ -23,6 +23,7 @@ export declare function getPreviousSignificantTokenInfo(sourceLike: string | str
23
23
  export declare function skipQuotedLiteral(source: string, start: number, quote: string): number;
24
24
  export declare function skipTemplateLiteral(source: string, start: number): number;
25
25
  export declare function findFunctionRanges(masked: string): SourceRange[];
26
+ export declare function collectAstFunctionBodyRanges(ast: unknown): SourceRange[];
26
27
  export declare function collectFunctionRanges(masked: string, pattern: RegExp, ranges: SourceRange[]): void;
27
28
  export declare function collectArrowExpressionRanges(masked: string, ranges: SourceRange[]): void;
28
29
  export declare function collectMethodFunctionRanges(masked: string, ranges: SourceRange[]): void;
@@ -27,6 +27,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
27
27
  var source_exports = {};
28
28
  __export(source_exports, {
29
29
  collectArrowExpressionRanges: () => collectArrowExpressionRanges,
30
+ collectAstFunctionBodyRanges: () => collectAstFunctionBodyRanges,
30
31
  collectBraceRanges: () => collectBraceRanges,
31
32
  collectComputedMethodCandidates: () => collectComputedMethodCandidates,
32
33
  collectFunctionRanges: () => collectFunctionRanges,
@@ -69,6 +70,7 @@ __export(source_exports, {
69
70
  });
70
71
  module.exports = __toCommonJS(source_exports);
71
72
  var import_constants = require("../runtime/constants");
73
+ var import_walk = require("./walk");
72
74
  function maskJavaScriptSource(source) {
73
75
  const chars = source.split("");
74
76
  const maskRange = (start, end) => {
@@ -406,6 +408,23 @@ function findFunctionRanges(masked) {
406
408
  collectMethodFunctionRanges(masked, ranges);
407
409
  return mergeRanges(ranges);
408
410
  }
411
+ function collectAstFunctionBodyRanges(ast) {
412
+ const ranges = [];
413
+ const addBodyRange = (node) => {
414
+ var _a, _b;
415
+ const start = (_a = node.body) == null ? void 0 : _a.start;
416
+ const end = (_b = node.body) == null ? void 0 : _b.end;
417
+ if (typeof start === "number" && typeof end === "number" && end > start) {
418
+ ranges.push({ start, end });
419
+ }
420
+ };
421
+ (0, import_walk.walkAstSimple)(ast, {
422
+ FunctionDeclaration: addBodyRange,
423
+ FunctionExpression: addBodyRange,
424
+ ArrowFunctionExpression: addBodyRange
425
+ });
426
+ return mergeRanges(ranges);
427
+ }
409
428
  function collectFunctionRanges(masked, pattern, ranges) {
410
429
  for (const match of masked.matchAll(pattern)) {
411
430
  const openBrace = masked.indexOf("{", match.index || 0);
@@ -853,6 +872,7 @@ function getAstSource(node, source) {
853
872
  // Annotate the CommonJS export names for ESM import in node:
854
873
  0 && (module.exports = {
855
874
  collectArrowExpressionRanges,
875
+ collectAstFunctionBodyRanges,
856
876
  collectBraceRanges,
857
877
  collectComputedMethodCandidates,
858
878
  collectFunctionRanges,
@@ -32,7 +32,6 @@ __export(rules_exports, {
32
32
  });
33
33
  module.exports = __toCommonJS(rules_exports);
34
34
  var import_blocked_capability_reroute = require("./blocked-capability-reroute");
35
- var import_blocked_global_stop = require("./blocked-global-stop");
36
35
  var import_ctx_libs_member_mismatch_stop = require("./ctx-libs-member-mismatch-stop");
37
36
  var import_ctx_root_mismatch_stop = require("./ctx-root-mismatch-stop");
38
37
  var import_missing_top_level_return = require("./missing-top-level-return");
@@ -61,7 +60,6 @@ const RUNJS_AUTHORING_RULES = [
61
60
  import_replace_innerhtml_with_render.replaceInnerHtmlWithRenderRule,
62
61
  import_render_top_level_function_wrapper.renderTopLevelFunctionWrapperRule,
63
62
  import_render_unreachable_render_call.renderUnreachableRenderCallRule,
64
- import_blocked_global_stop.blockedGlobalStopRule,
65
63
  import_unknown_global_stop.unknownGlobalStopRule,
66
64
  import_blocked_capability_reroute.blockedCapabilityRerouteRule,
67
65
  import_react_runtime_contract_stop.reactRuntimeContractStopRule,
@@ -21,7 +21,6 @@ export declare const BLOCKED_CTX_CAPABILITIES: Record<string, {
21
21
  capability: string;
22
22
  reroute: string;
23
23
  }>;
24
- export declare const FORBIDDEN_BARE_GLOBALS: Set<string>;
25
24
  export declare const RUNJS_ALLOWED_BARE_GLOBALS: Set<string>;
26
25
  export declare const RUNJS_ALLOWED_BARE_GLOBALS_BY_MODEL_USE: Record<string, Set<string>>;
27
26
  export declare const NON_METHOD_CALL_KEYWORDS: Set<string>;
@@ -50,7 +50,6 @@ __export(constants_exports, {
50
50
  FLOW_RESOURCE_CLASS_NAMES: () => FLOW_RESOURCE_CLASS_NAMES,
51
51
  FLOW_RESOURCE_METHODS_BY_TYPE: () => FLOW_RESOURCE_METHODS_BY_TYPE,
52
52
  FLOW_RESOURCE_METHOD_SUGGESTIONS: () => FLOW_RESOURCE_METHOD_SUGGESTIONS,
53
- FORBIDDEN_BARE_GLOBALS: () => FORBIDDEN_BARE_GLOBALS,
54
53
  INIT_RESOURCE_CLASS_NAMES: () => INIT_RESOURCE_CLASS_NAMES,
55
54
  KNOWN_MODEL_USES: () => KNOWN_MODEL_USES,
56
55
  MAX_RUNJS_ERRORS_PER_SOURCE: () => MAX_RUNJS_ERRORS_PER_SOURCE,
@@ -160,6 +159,7 @@ const SURFACE_ALLOWED_MODEL_USES = {
160
159
  };
161
160
  const ALLOWED_CTX_ROOTS = /* @__PURE__ */ new Set([
162
161
  "acl",
162
+ "ai",
163
163
  "antd",
164
164
  "antdIcons",
165
165
  "api",
@@ -224,7 +224,12 @@ const ALLOWED_CTX_ROOTS = /* @__PURE__ */ new Set([
224
224
  ]);
225
225
  const CHART_CTX_ROOTS = /* @__PURE__ */ new Set(["data"]);
226
226
  const BLOCKED_CTX_CAPABILITIES = {};
227
- const FORBIDDEN_BARE_GLOBALS = /* @__PURE__ */ new Set([
227
+ const RUNJS_ALLOWED_BARE_GLOBALS = /* @__PURE__ */ new Set([
228
+ "ctx",
229
+ "console",
230
+ "window",
231
+ "document",
232
+ "navigator",
228
233
  "fetch",
229
234
  "localStorage",
230
235
  "sessionStorage",
@@ -237,22 +242,6 @@ const FORBIDDEN_BARE_GLOBALS = /* @__PURE__ */ new Set([
237
242
  "EventSource",
238
243
  "indexedDB",
239
244
  "caches",
240
- "Function",
241
- "eval",
242
- "globalThis",
243
- "Intl",
244
- "process",
245
- "require",
246
- "module",
247
- "exports",
248
- "location"
249
- ]);
250
- const RUNJS_ALLOWED_BARE_GLOBALS = /* @__PURE__ */ new Set([
251
- "ctx",
252
- "console",
253
- "window",
254
- "document",
255
- "navigator",
256
245
  "setTimeout",
257
246
  "clearTimeout",
258
247
  "setInterval",
@@ -296,9 +285,14 @@ const RUNJS_ALLOWED_BARE_GLOBALS = /* @__PURE__ */ new Set([
296
285
  "WeakMap",
297
286
  "WeakRef",
298
287
  "WeakSet",
288
+ "Function",
289
+ "eval",
290
+ "globalThis",
291
+ "Intl",
299
292
  "JSON",
300
293
  "Blob",
301
294
  "URL",
295
+ "location",
302
296
  "decodeURI",
303
297
  "decodeURIComponent",
304
298
  "encodeURI",
@@ -714,7 +708,6 @@ function escapeRegExp(value) {
714
708
  FLOW_RESOURCE_CLASS_NAMES,
715
709
  FLOW_RESOURCE_METHODS_BY_TYPE,
716
710
  FLOW_RESOURCE_METHOD_SUGGESTIONS,
717
- FORBIDDEN_BARE_GLOBALS,
718
711
  INIT_RESOURCE_CLASS_NAMES,
719
712
  KNOWN_MODEL_USES,
720
713
  MAX_RUNJS_ERRORS_PER_SOURCE,
@@ -40,9 +40,6 @@ export type RunJsScanResult = RunJsAstInspection & {
40
40
  match: string;
41
41
  }>;
42
42
  dynamicCtxAccesses: IndexedEntry[];
43
- forbiddenBareGlobals: Array<IndexedEntry & {
44
- name: string;
45
- }>;
46
43
  functionRanges: SourceRange[];
47
44
  invalidCtxLibMemberAccesses: InvalidCtxLibMemberAccess[];
48
45
  invalidReactRuntimeBindings: InvalidReactRuntimeBinding[];
@@ -65,15 +62,6 @@ export type RunJsScanResult = RunJsAstInspection & {
65
62
  }>;
66
63
  topLevelReturns: IndexedEntry[];
67
64
  unboundReactCreateElementCalls: IndexedEntry[];
68
- windowDocumentNavigatorAliases: Array<{
69
- alias: string;
70
- index: number;
71
- root: string;
72
- }>;
73
- windowDocumentNavigatorUses: Array<IndexedEntry & {
74
- member: string;
75
- root: string;
76
- }>;
77
65
  };
78
66
  export type RunJsInspectionRuntime = {
79
67
  context: RunJsAuthoringContext;
@@ -900,7 +900,13 @@ function buildRunJsResourceFilterOperatorError(operator, index, input) {
900
900
  };
901
901
  }
902
902
  function buildRunJsResourceDateFilterValueError(operator, index, valueNode, input) {
903
- if (!isRunJsDateFilterOperator(operator)) {
903
+ const fieldType = String((0, import_service_helpers.getFieldType)(input.field) || "").trim();
904
+ const fieldInterface = String((0, import_service_helpers.getFieldInterface)(input.field) || "").trim();
905
+ const shouldValidateDateValue = isRunJsDateFilterOperator(operator) || (0, import_filter_group.isFlowSurfaceDateLikeFieldMeta)({
906
+ type: fieldType,
907
+ interface: fieldInterface
908
+ });
909
+ if (!shouldValidateDateValue) {
904
910
  return null;
905
911
  }
906
912
  const valueObject = resolveRunJsStaticFilterObjectNode(
@@ -924,7 +930,11 @@ function buildRunJsResourceDateFilterValueError(operator, index, valueNode, inpu
924
930
  return null;
925
931
  }
926
932
  try {
927
- (0, import_filter_group.normalizeFlowSurfaceStrictFilterDateValue)(operator, resolvedValue.value, `${input.fieldPath}.${operator}`);
933
+ (0, import_filter_group.normalizeFlowSurfaceDateConditionValue)(operator, resolvedValue.value, `${input.fieldPath}.${operator}`, {
934
+ fieldPath: input.fieldPath,
935
+ fieldType,
936
+ fieldInterface
937
+ });
928
938
  return null;
929
939
  } catch (error) {
930
940
  return buildRunJsStrictDateFilterValueError(operator, index, resolvedValue.value, input, error);
@@ -149,16 +149,6 @@ export declare function scanJavaScriptSource(source: string, ast?: any, context?
149
149
  alias: string;
150
150
  index: number;
151
151
  }[];
152
- windowDocumentNavigatorUses: {
153
- root: string;
154
- member: string;
155
- index: number;
156
- }[];
157
- windowDocumentNavigatorAliases: {
158
- alias: string;
159
- root: string;
160
- index: number;
161
- }[];
162
152
  ctxAliases: {
163
153
  alias: string;
164
154
  index: number;
@@ -179,10 +169,6 @@ export declare function scanJavaScriptSource(source: string, ast?: any, context?
179
169
  ruleId: "runjs-ctx-member-not-callable";
180
170
  }[];
181
171
  invalidCtxLibMemberAccesses: import("../internal-types").InvalidCtxLibMemberAccess[];
182
- forbiddenBareGlobals: {
183
- name: string;
184
- index: number;
185
- }[];
186
172
  ctxMemberAccesses: {
187
173
  member: string;
188
174
  index: number;
@@ -43,7 +43,7 @@ var import_filter = require("./filter");
43
43
  var import_constants = require("../runtime/constants");
44
44
  function scanJavaScriptSource(source, ast, context = {}, modelUse = "") {
45
45
  const masked = (0, import_source.maskJavaScriptSource)(source);
46
- const functionRanges = (0, import_source.findFunctionRanges)(masked);
46
+ const functionRanges = collectScanFunctionRanges(masked, ast);
47
47
  const blockRanges = (0, import_source.collectBraceRanges)(masked);
48
48
  const staticBlockRanges = (0, import_source.collectStaticBlockRanges)(masked);
49
49
  const sourceBindings = (0, import_bindings.collectSourceBindings)(masked, functionRanges, blockRanges, staticBlockRanges);
@@ -71,10 +71,7 @@ function scanJavaScriptSource(source, ast, context = {}, modelUse = "") {
71
71
  const flowResourceAliases = (0, import_source_patterns.collectFlowResourceAliases)(masked, sourceBindings);
72
72
  const directDomWrites = (0, import_source_patterns.collectDirectDomWrites)(source, masked, sourceBindings);
73
73
  const directDomAliases = (0, import_source_patterns.collectDirectDomAliases)(masked, sourceBindings);
74
- const windowDocumentNavigatorUses = (0, import_source_patterns.collectWindowDocumentNavigatorUses)(source, masked, sourceBindings);
75
- const windowDocumentNavigatorAliases = (0, import_source_patterns.collectWindowDocumentNavigatorAliases)(masked, sourceBindings);
76
74
  const ctxAliases = (0, import_source_patterns.collectCtxAliases)(masked, sourceBindings);
77
- const forbiddenBareGlobals = (0, import_source_patterns.collectForbiddenBareGlobals)(masked, sourceBindings);
78
75
  return {
79
76
  source,
80
77
  masked,
@@ -126,19 +123,24 @@ function scanJavaScriptSource(source, ast, context = {}, modelUse = "") {
126
123
  ),
127
124
  directDomWrites,
128
125
  directDomAliases,
129
- windowDocumentNavigatorUses,
130
- windowDocumentNavigatorAliases,
131
126
  ctxAliases,
132
127
  ctxLibMemberCaseMismatches: (0, import_source_patterns.collectCtxLibMemberCaseMismatches)(source, masked, sourceBindings),
133
128
  invalidCtxApiMemberAccesses: (astInspection == null ? void 0 : astInspection.invalidCtxApiMemberAccesses) || [],
134
129
  invalidCtxNonFunctionCalls: (astInspection == null ? void 0 : astInspection.invalidCtxNonFunctionCalls) || [],
135
130
  invalidCtxLibMemberAccesses: (astInspection == null ? void 0 : astInspection.invalidCtxLibMemberAccesses) || [],
136
- forbiddenBareGlobals,
137
131
  ctxMemberAccesses: (0, import_source_patterns.collectCtxMemberAccesses)(masked, sourceBindings),
138
132
  dynamicCtxAccesses: (0, import_static_values.findUnboundCtxMatches)(masked, /\bctx\s*(?:\?\.\s*)?\[/g, sourceBindings),
139
133
  isTopLevelFunctionWrapper: (0, import_source_patterns.isTopLevelFunctionWrapper)(masked, functionRanges, topLevelReachableCtxRenderCalls)
140
134
  };
141
135
  }
136
+ function collectScanFunctionRanges(masked, ast) {
137
+ if (!ast) {
138
+ return (0, import_source.findFunctionRanges)(masked);
139
+ }
140
+ const ranges = (0, import_source.collectAstFunctionBodyRanges)(ast);
141
+ (0, import_source.collectArrowExpressionRanges)(masked, ranges);
142
+ return (0, import_source.mergeRanges)(ranges);
143
+ }
142
144
  function collectAstUnknownBareGlobalsFromAst(ast, identifierBindings, modelUse) {
143
145
  var _a;
144
146
  const allowedGlobals = new Set(import_constants.RUNJS_ALLOWED_BARE_GLOBALS);
@@ -151,7 +153,7 @@ function collectAstUnknownBareGlobalsFromAst(ast, identifierBindings, modelUse)
151
153
  if (!name) {
152
154
  return;
153
155
  }
154
- if (allowedGlobals.has(name) || import_constants.FORBIDDEN_BARE_GLOBALS.has(name)) {
156
+ if (allowedGlobals.has(name)) {
155
157
  return;
156
158
  }
157
159
  const index = typeof node.start === "number" ? node.start : 0;
@@ -7,10 +7,6 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
  import type { CtxLibMemberCaseMismatch, FlowResourceAlias, ReactComponentAlias, ResourceCallInReactHook, SourceBinding, SourceRange, StringLiteralBinding } from '../internal-types';
10
- export declare function collectForbiddenBareGlobals(masked: string, bindings: SourceBinding[]): {
11
- name: string;
12
- index: number;
13
- }[];
14
10
  export declare function collectInvalidApiResourceCalls(source: string, masked: string, bindings: SourceBinding[]): {
15
11
  index: number;
16
12
  match: string;
@@ -64,16 +60,6 @@ export declare function collectDirectDomWrites(source: string, masked: string, b
64
60
  index: number;
65
61
  match: string;
66
62
  }[];
67
- export declare function collectWindowDocumentNavigatorUses(source: string, masked: string, bindings: SourceBinding[]): {
68
- root: string;
69
- member: string;
70
- index: number;
71
- }[];
72
- export declare function collectWindowDocumentNavigatorAliases(masked: string, bindings: SourceBinding[]): {
73
- alias: string;
74
- root: string;
75
- index: number;
76
- }[];
77
63
  export declare function collectDirectDomAliases(masked: string, bindings: SourceBinding[]): {
78
64
  alias: string;
79
65
  index: number;
@@ -33,7 +33,6 @@ __export(source_patterns_exports, {
33
33
  collectDirectDomAliases: () => collectDirectDomAliases,
34
34
  collectDirectDomWrites: () => collectDirectDomWrites,
35
35
  collectFlowResourceAliases: () => collectFlowResourceAliases,
36
- collectForbiddenBareGlobals: () => collectForbiddenBareGlobals,
37
36
  collectInvalidApiResourceCalls: () => collectInvalidApiResourceCalls,
38
37
  collectInvalidFlowResourceListCalls: () => collectInvalidFlowResourceListCalls,
39
38
  collectInvalidResourceTypeCalls: () => collectInvalidResourceTypeCalls,
@@ -43,8 +42,6 @@ __export(source_patterns_exports, {
43
42
  collectReactHookCalls: () => collectReactHookCalls,
44
43
  collectResourceCallsInReactHooks: () => collectResourceCallsInReactHooks,
45
44
  collectUnboundReactCreateElementCalls: () => collectUnboundReactCreateElementCalls,
46
- collectWindowDocumentNavigatorAliases: () => collectWindowDocumentNavigatorAliases,
47
- collectWindowDocumentNavigatorUses: () => collectWindowDocumentNavigatorUses,
48
45
  getResourceLikeCtxRunjsEntrypoint: () => getResourceLikeCtxRunjsEntrypoint,
49
46
  isResourceLikeCtxRequest: () => isResourceLikeCtxRequest,
50
47
  isTopLevelFunctionWrapper: () => isTopLevelFunctionWrapper
@@ -53,18 +50,6 @@ module.exports = __toCommonJS(source_patterns_exports);
53
50
  var import_constants = require("../runtime/constants");
54
51
  var import_bindings = require("../ast/bindings");
55
52
  var import_source = require("../ast/source");
56
- function collectForbiddenBareGlobals(masked, bindings) {
57
- const entries = [];
58
- for (const name of import_constants.FORBIDDEN_BARE_GLOBALS) {
59
- const pattern = new RegExp(`(?<![.$\\w])${(0, import_source.escapeRegExp)(name)}\\b`, "g");
60
- for (const match of masked.matchAll(pattern)) {
61
- if (!(0, import_bindings.isNameBoundAtIndex)(bindings, name, match.index || 0) && !isObjectPropertyKey(masked, match.index || 0, name)) {
62
- entries.push({ name, index: match.index || 0 });
63
- }
64
- }
65
- }
66
- return entries.sort((left, right) => left.index - right.index);
67
- }
68
53
  function collectInvalidApiResourceCalls(source, masked, bindings) {
69
54
  var _a, _b, _c, _d, _e, _f, _g, _h;
70
55
  const resourceMethods = /* @__PURE__ */ new Set(["list", "get", "create", "update", "destroy"]);
@@ -618,6 +603,16 @@ function collectDirectDomWrites(source, masked, bindings) {
618
603
  }
619
604
  entries.push({ index, match: match[0].replace(/\s*(?:\?\.)?\($/, "") });
620
605
  }
606
+ for (const match of masked.matchAll(
607
+ /\b(document)\s*(?:\?\.|\.)\s*body\s*(?:\?\.|\.)\s*(innerHTML|insertAdjacentHTML)\b|(?<![.$\w])((window|globalThis)\s*(?:\?\.|\.)\s*document)\s*(?:\?\.|\.)\s*body\s*(?:\?\.|\.)\s*(innerHTML|insertAdjacentHTML)\b/g
608
+ )) {
609
+ const index = match.index || 0;
610
+ const root = match[1] || match[4];
611
+ if (root && (0, import_bindings.isNameBoundAtIndex)(bindings, root, index)) {
612
+ continue;
613
+ }
614
+ entries.push({ index, match: match[0] });
615
+ }
621
616
  for (const match of commentMasked.matchAll(
622
617
  /\b(ctx)\s*(?:\?\.|\.)\s*element\s*(?:\?\.\s*)?\[\s*(?:(['"])([A-Za-z_$][\w$]*)\2|([^\]]+))\s*\]/g
623
618
  )) {
@@ -639,71 +634,24 @@ function collectDirectDomWrites(source, masked, bindings) {
639
634
  }
640
635
  }
641
636
  for (const match of commentMasked.matchAll(
642
- /\b(element)\s*(?:\?\.\s*)?\[\s*(?:(['"])([A-Za-z_$][\w$]*)\2|([^\]]+))\s*\]/g
637
+ /(?<![.$\w])(window|globalThis)\s*(?:\?\.\s*)?\[\s*(['"])document\2\s*\]\s*(?:(?:\?\.|\.)\s*createElement|(?:\?\.\s*)?\[\s*(['"])createElement\3\s*\])/g
643
638
  )) {
644
639
  const index = match.index || 0;
645
- const member = match[3] || "";
646
- const dynamicMember = Boolean(match[4]);
647
- if (isCodeTokenAt(masked, index, match[1]) && !(0, import_bindings.isNameBoundAtIndex)(bindings, match[1], index) && (dynamicMember || isDirectDomMember(member))) {
640
+ if (isCodeTokenAt(masked, index, match[1]) && !(0, import_bindings.isNameBoundAtIndex)(bindings, match[1], index)) {
648
641
  entries.push({ index, match: match[0] });
649
642
  }
650
643
  }
651
- return entries;
652
- }
653
- function collectWindowDocumentNavigatorUses(source, masked, bindings) {
654
- const commentMasked = (0, import_source.maskJavaScriptComments)(source);
655
- const entries = [...masked.matchAll(/\b(window|document|navigator)\s*(?:\?\.|\.)\s*([A-Za-z_$][\w$]*)/g)].filter((match) => !(0, import_bindings.isNameBoundAtIndex)(bindings, match[1], match.index || 0)).map((match) => ({
656
- root: match[1],
657
- member: match[2],
658
- index: match.index || 0
659
- }));
660
644
  for (const match of commentMasked.matchAll(
661
- /\b(window|document|navigator)\s*(?:\?\.\s*)?\[\s*(?:(['"])([A-Za-z_$][\w$]*)\2|([^\]]+))\s*\]/g
645
+ /\b(element)\s*(?:\?\.\s*)?\[\s*(?:(['"])([A-Za-z_$][\w$]*)\2|([^\]]+))\s*\]/g
662
646
  )) {
663
647
  const index = match.index || 0;
664
- const root = match[1];
665
- if (!isCodeTokenAt(masked, index, root) || (0, import_bindings.isNameBoundAtIndex)(bindings, root, index)) {
666
- continue;
667
- }
668
- entries.push({
669
- root,
670
- member: match[3] || "[dynamic]",
671
- index
672
- });
673
- }
674
- return entries.sort((left, right) => left.index - right.index);
675
- }
676
- function collectWindowDocumentNavigatorAliases(masked, bindings) {
677
- const entries = [];
678
- collectAliasMatches(
679
- masked,
680
- [
681
- /\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*(window|document|navigator)\b/g,
682
- /(?<![.$\w])([A-Za-z_$][\w$]*)\s*=\s*(window|document|navigator)\b/g
683
- ],
684
- (match) => {
685
- const alias = match[1];
686
- const root = match[2];
687
- const rootIndex = (match.index || 0) + match[0].lastIndexOf(root);
688
- if (alias === root || (0, import_bindings.isNameBoundAtIndex)(bindings, root, rootIndex)) {
689
- return;
690
- }
691
- entries.push({ alias, root, index: rootIndex });
692
- }
693
- );
694
- for (const match of masked.matchAll(
695
- /\b(?:const|let|var)\s*\{([^}]*)\}\s*=\s*(window|document|navigator)\b(?!\s*(?:\.|\?\.))/g
696
- )) {
697
- const root = match[2];
698
- const rootIndex = (match.index || 0) + match[0].lastIndexOf(root);
699
- if ((0, import_bindings.isNameBoundAtIndex)(bindings, root, rootIndex)) {
700
- continue;
648
+ const member = match[3] || "";
649
+ const dynamicMember = Boolean(match[4]);
650
+ if (isCodeTokenAt(masked, index, match[1]) && !(0, import_bindings.isNameBoundAtIndex)(bindings, match[1], index) && (dynamicMember || isDirectDomMember(member))) {
651
+ entries.push({ index, match: match[0] });
701
652
  }
702
- collectObjectBindingAliases(match[1]).forEach((alias) => {
703
- entries.push({ alias, root, index: rootIndex });
704
- });
705
653
  }
706
- return dedupeAliasEntries(entries);
654
+ return entries;
707
655
  }
708
656
  function collectDirectDomAliases(masked, bindings) {
709
657
  const entries = [];
@@ -871,7 +819,6 @@ function isResourceLikeRunjsEntrypointExpression(value) {
871
819
  collectDirectDomAliases,
872
820
  collectDirectDomWrites,
873
821
  collectFlowResourceAliases,
874
- collectForbiddenBareGlobals,
875
822
  collectInvalidApiResourceCalls,
876
823
  collectInvalidFlowResourceListCalls,
877
824
  collectInvalidResourceTypeCalls,
@@ -881,8 +828,6 @@ function isResourceLikeRunjsEntrypointExpression(value) {
881
828
  collectReactHookCalls,
882
829
  collectResourceCallsInReactHooks,
883
830
  collectUnboundReactCreateElementCalls,
884
- collectWindowDocumentNavigatorAliases,
885
- collectWindowDocumentNavigatorUses,
886
831
  getResourceLikeCtxRunjsEntrypoint,
887
832
  isResourceLikeCtxRequest,
888
833
  isTopLevelFunctionWrapper
@@ -6,7 +6,7 @@
6
6
  * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
- export type RunJsAuthoringRepairClass = 'syntax-stop' | 'nested-runjs-stop' | 'source-limit-stop' | 'switch-to-resource-api' | 'missing-top-level-return' | 'value-surface-forbids-render' | 'unknown-surface-stop' | 'unknown-model-stop' | 'replace-innerhtml-with-render' | 'render-top-level-function-wrapper' | 'render-unreachable-render-call' | 'blocked-global-stop' | 'unknown-global-stop' | 'blocked-capability-reroute' | 'react-runtime-contract-stop' | 'resource-runtime-contract-stop' | 'ctx-libs-member-mismatch-stop' | 'ctx-root-mismatch-stop';
9
+ export type RunJsAuthoringRepairClass = 'syntax-stop' | 'nested-runjs-stop' | 'source-limit-stop' | 'switch-to-resource-api' | 'missing-top-level-return' | 'value-surface-forbids-render' | 'unknown-surface-stop' | 'unknown-model-stop' | 'replace-innerhtml-with-render' | 'render-top-level-function-wrapper' | 'render-unreachable-render-call' | 'unknown-global-stop' | 'blocked-capability-reroute' | 'react-runtime-contract-stop' | 'resource-runtime-contract-stop' | 'ctx-libs-member-mismatch-stop' | 'ctx-root-mismatch-stop';
10
10
  export type RunJsAuthoringSurfaceStyle = 'render' | 'value' | 'action';
11
11
  export interface RunJsAuthoringRuleDefinition {
12
12
  repairClass: RunJsAuthoringRepairClass;