@nocobase/plugin-flow-engine 2.2.0-beta.2 → 2.2.0-beta.5

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 (50) 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/approval/authoring-validation.d.ts +9 -0
  9. package/dist/server/flow-surfaces/approval/authoring-validation.js +1151 -0
  10. package/dist/server/flow-surfaces/approval/blueprint-service.js +2 -0
  11. package/dist/server/flow-surfaces/authoring-validation.js +429 -32
  12. package/dist/server/flow-surfaces/blueprint/export-document.d.ts +50 -0
  13. package/dist/server/flow-surfaces/blueprint/export-document.js +2505 -0
  14. package/dist/server/flow-surfaces/builder.js +16 -1
  15. package/dist/server/flow-surfaces/catalog.js +3 -1
  16. package/dist/server/flow-surfaces/configure-options.js +4 -3
  17. package/dist/server/flow-surfaces/constants.d.ts +9 -2
  18. package/dist/server/flow-surfaces/constants.js +1 -0
  19. package/dist/server/flow-surfaces/contract-guard.js +24 -2
  20. package/dist/server/flow-surfaces/default-action-popup.d.ts +2 -0
  21. package/dist/server/flow-surfaces/default-action-popup.js +27 -13
  22. package/dist/server/flow-surfaces/filter-group.d.ts +19 -2
  23. package/dist/server/flow-surfaces/filter-group.js +232 -3
  24. package/dist/server/flow-surfaces/planning/compiler.d.ts +1 -0
  25. package/dist/server/flow-surfaces/planning/compiler.js +205 -82
  26. package/dist/server/flow-surfaces/planning/runtime.js +1 -0
  27. package/dist/server/flow-surfaces/planning/step-link.d.ts +1 -1
  28. package/dist/server/flow-surfaces/planning/step-link.js +22 -3
  29. package/dist/server/flow-surfaces/public-data-surface-default-filter.js +0 -9
  30. package/dist/server/flow-surfaces/reaction/field-value.d.ts +9 -0
  31. package/dist/server/flow-surfaces/reaction/field-value.js +51 -2
  32. package/dist/server/flow-surfaces/reaction/linkage.d.ts +6 -1
  33. package/dist/server/flow-surfaces/reaction/linkage.js +18 -3
  34. package/dist/server/flow-surfaces/reaction/meta.js +19 -1
  35. package/dist/server/flow-surfaces/reaction/types.d.ts +19 -0
  36. package/dist/server/flow-surfaces/relation-backing-foreign-key.d.ts +10 -0
  37. package/dist/server/flow-surfaces/relation-backing-foreign-key.js +79 -0
  38. package/dist/server/flow-surfaces/runjs-authoring/ast/source.d.ts +1 -0
  39. package/dist/server/flow-surfaces/runjs-authoring/ast/source.js +20 -0
  40. package/dist/server/flow-surfaces/runjs-authoring/scan/filter.js +12 -2
  41. package/dist/server/flow-surfaces/runjs-authoring/scan/index.js +9 -1
  42. package/dist/server/flow-surfaces/service.d.ts +24 -0
  43. package/dist/server/flow-surfaces/service.js +308 -27
  44. package/dist/server/variables/registry.js +3 -0
  45. package/dist/swagger/flow-surfaces.d.ts +180 -0
  46. package/dist/swagger/flow-surfaces.examples.d.ts +8 -0
  47. package/dist/swagger/flow-surfaces.examples.js +8 -0
  48. package/dist/swagger/flow-surfaces.js +160 -4
  49. package/dist/swagger/index.d.ts +180 -0
  50. package/package.json +2 -2
@@ -56,10 +56,17 @@ function assertFlowSurfaceKnownPlanStepLink(actionName, stepLink, fieldName, kno
56
56
  }
57
57
  (0, import_errors.throwBadRequest)(`flowSurfaces ${actionName} ${fieldName}.step '${stepLink.step}' is not a previous step id`);
58
58
  }
59
- function replaceFlowSurfacePlanStepLinks(actionName, input, path, knownStepIds, knownRuntimeKeys) {
59
+ function replaceFlowSurfacePlanStepLinks(actionName, input, path, knownStepIds, knownRuntimeKeys, blockedRuntimeKeys) {
60
60
  if (Array.isArray(input)) {
61
61
  return input.map(
62
- (item, index) => replaceFlowSurfacePlanStepLinks(actionName, item, `${path}[${index}]`, knownStepIds, knownRuntimeKeys)
62
+ (item, index) => replaceFlowSurfacePlanStepLinks(
63
+ actionName,
64
+ item,
65
+ `${path}[${index}]`,
66
+ knownStepIds,
67
+ knownRuntimeKeys,
68
+ blockedRuntimeKeys
69
+ )
63
70
  );
64
71
  }
65
72
  if (!import_lodash.default.isPlainObject(input)) {
@@ -81,6 +88,11 @@ function replaceFlowSurfacePlanStepLinks(actionName, input, path, knownStepIds,
81
88
  if (!runtimeKey) {
82
89
  (0, import_errors.throwBadRequest)(`flowSurfaces ${actionName} ${path}.key cannot be empty`);
83
90
  }
91
+ if (blockedRuntimeKeys == null ? void 0 : blockedRuntimeKeys.has(runtimeKey)) {
92
+ (0, import_errors.throwBadRequest)(
93
+ `flowSurfaces ${actionName} ${path}.key '${runtimeKey}' belongs to the current replace scope; replace-step key links cannot resolve to old replace subtree nodes`
94
+ );
95
+ }
84
96
  if (!(knownRuntimeKeys == null ? void 0 : knownRuntimeKeys.has(runtimeKey))) {
85
97
  (0, import_errors.throwBadRequest)(`flowSurfaces ${actionName} ${path}.key '${runtimeKey}' is not defined`);
86
98
  }
@@ -91,7 +103,14 @@ function replaceFlowSurfacePlanStepLinks(actionName, input, path, knownStepIds,
91
103
  return Object.fromEntries(
92
104
  Object.entries(input).map(([key, value]) => [
93
105
  key,
94
- replaceFlowSurfacePlanStepLinks(actionName, value, `${path}.${key}`, knownStepIds, knownRuntimeKeys)
106
+ replaceFlowSurfacePlanStepLinks(
107
+ actionName,
108
+ value,
109
+ `${path}.${key}`,
110
+ knownStepIds,
111
+ knownRuntimeKeys,
112
+ blockedRuntimeKeys
113
+ )
95
114
  ])
96
115
  );
97
116
  }
@@ -299,9 +299,7 @@ function backfillFlowSurfaceDefaultFilterSetting(settings, defaultFilter) {
299
299
  if (import_lodash.default.isUndefined(defaultFilter)) {
300
300
  return settings;
301
301
  }
302
- const filterableFieldNames = resolveFlowSurfaceDefaultFilterFieldNames(defaultFilter);
303
302
  const defaults = {
304
- ...filterableFieldNames.length ? { filterableFieldNames } : {},
305
303
  defaultFilter: import_lodash.default.cloneDeep(defaultFilter)
306
304
  };
307
305
  if (import_lodash.default.isUndefined(settings)) {
@@ -311,13 +309,6 @@ function backfillFlowSurfaceDefaultFilterSetting(settings, defaultFilter) {
311
309
  return settings;
312
310
  }
313
311
  if (Object.prototype.hasOwnProperty.call(settings, "defaultFilter")) {
314
- const explicitFilterableFieldNames = resolveFlowSurfaceDefaultFilterFieldNames(settings.defaultFilter);
315
- if (!Object.prototype.hasOwnProperty.call(settings, "filterableFieldNames") && explicitFilterableFieldNames.length) {
316
- return {
317
- ...import_lodash.default.cloneDeep(settings),
318
- filterableFieldNames: explicitFilterableFieldNames
319
- };
320
- }
321
312
  return settings;
322
313
  }
323
314
  return {
@@ -17,6 +17,15 @@ export type FlowSurfaceFieldValueCompileResult = FlowSurfaceReactionWriteResult<
17
17
  export declare function isFieldValueTargetUseSupported(use?: string | null): boolean;
18
18
  export declare function assertFieldValueTargetSupported(target: FlowSurfaceFieldValueTarget): void;
19
19
  export declare function normalizeFieldValueRules(rules: FlowSurfaceFieldValueRule[] | undefined): FlowSurfaceFieldValueRule[];
20
+ export declare function validateFieldValueRulesAgainstCapability(rules: FlowSurfaceFieldValueRule[], capability: {
21
+ conditionMeta: {
22
+ operatorsByPath: Record<string, string[]>;
23
+ fieldMetaByPath?: Record<string, {
24
+ type?: string;
25
+ interface?: string;
26
+ }>;
27
+ };
28
+ }): void;
20
29
  export declare function compileFieldValueRulesToCanonical(rules: FlowSurfaceFieldValueRule[] | undefined): {
21
30
  key: string;
22
31
  enable: boolean;
@@ -41,11 +41,13 @@ __export(field_value_exports, {
41
41
  collectUpdateAssociationValuesFromFieldValueRules: () => collectUpdateAssociationValuesFromFieldValueRules,
42
42
  compileFieldValueRulesToCanonical: () => compileFieldValueRulesToCanonical,
43
43
  isFieldValueTargetUseSupported: () => isFieldValueTargetUseSupported,
44
- normalizeFieldValueRules: () => normalizeFieldValueRules
44
+ normalizeFieldValueRules: () => normalizeFieldValueRules,
45
+ validateFieldValueRulesAgainstCapability: () => validateFieldValueRulesAgainstCapability
45
46
  });
46
47
  module.exports = __toCommonJS(field_value_exports);
47
48
  var import_lodash = __toESM(require("lodash"));
48
49
  var import_errors = require("../errors");
50
+ var import_filter_group = require("../filter-group");
49
51
  var import_errors2 = require("./errors");
50
52
  var import_fingerprint = require("./fingerprint");
51
53
  var import_registry = require("./registry");
@@ -85,6 +87,52 @@ function normalizeFieldValueRules(rules) {
85
87
  const list = Array.isArray(rules) ? rules : [];
86
88
  return list.map((rule, index) => normalizeFieldValueRule(rule, index));
87
89
  }
90
+ function validateFieldValueRulesAgainstCapability(rules, capability) {
91
+ for (const [ruleIndex, rule] of (rules || []).entries()) {
92
+ validateFieldValueDateConditionFilter(rule.when, capability, `rules[${ruleIndex}].when`);
93
+ }
94
+ }
95
+ function validateFieldValueDateConditionFilter(filter, capability, prefix) {
96
+ const visit = (node, currentPrefix) => {
97
+ var _a;
98
+ if (!import_lodash.default.isPlainObject(node)) {
99
+ return;
100
+ }
101
+ if (Array.isArray(node.items)) {
102
+ node.items.forEach((item, index) => visit(item, `${currentPrefix}.items[${index}]`));
103
+ return;
104
+ }
105
+ const operator = typeof node.operator === "string" ? node.operator.trim() : "";
106
+ const path = typeof node.path === "string" ? node.path.trim() : "";
107
+ if (!operator || !path || !Object.prototype.hasOwnProperty.call(node, "value")) {
108
+ return;
109
+ }
110
+ const fieldMeta = resolveFieldValueConditionFieldMeta(path, (_a = capability.conditionMeta) == null ? void 0 : _a.fieldMetaByPath);
111
+ if (!import_filter_group.FLOW_SURFACE_DATE_FILTER_OPERATORS.has(operator) && !(0, import_filter_group.isFlowSurfaceDateLikeFieldMeta)(fieldMeta)) {
112
+ return;
113
+ }
114
+ (0, import_filter_group.normalizeFlowSurfaceDateConditionValue)(operator, node.value, `${currentPrefix}.value`, {
115
+ fieldPath: path,
116
+ fieldType: fieldMeta == null ? void 0 : fieldMeta.type,
117
+ fieldInterface: fieldMeta == null ? void 0 : fieldMeta.interface,
118
+ allowContextPathValue: true
119
+ });
120
+ };
121
+ visit(filter, prefix);
122
+ }
123
+ function resolveFieldValueConditionFieldMeta(path, fieldMetaByPath) {
124
+ if (!fieldMetaByPath) {
125
+ return void 0;
126
+ }
127
+ if (fieldMetaByPath[path]) {
128
+ return fieldMetaByPath[path];
129
+ }
130
+ const wildcardPath = Object.keys(fieldMetaByPath).filter((candidate) => candidate.endsWith(".*")).sort((a, b) => b.length - a.length).find((candidate) => {
131
+ const prefix = candidate.slice(0, -2);
132
+ return path.startsWith(`${prefix}.`) && path.length > prefix.length + 1;
133
+ });
134
+ return wildcardPath ? fieldMetaByPath[wildcardPath] : void 0;
135
+ }
88
136
  function compileFieldValueRulesToCanonical(rules) {
89
137
  return normalizeFieldValueRules(rules).map((rule) => ({
90
138
  key: rule.key,
@@ -177,5 +225,6 @@ function buildFieldValueWriteResult(params) {
177
225
  collectUpdateAssociationValuesFromFieldValueRules,
178
226
  compileFieldValueRulesToCanonical,
179
227
  isFieldValueTargetUseSupported,
180
- normalizeFieldValueRules
228
+ normalizeFieldValueRules,
229
+ validateFieldValueRulesAgainstCapability
181
230
  });
@@ -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
- import type { FlowSurfaceActionLinkageRule, FlowSurfaceFieldLinkageRule, FlowSurfaceFieldLinkageScene, FlowSurfaceFieldOption, FlowSurfaceFieldPathToUidResolver, FlowSurfaceFieldUidToPathResolver, FlowSurfaceBlockLinkageRule } from './types';
9
+ import type { FlowSurfaceActionLinkageRule, FlowSurfaceFieldLinkageRule, FlowSurfaceFieldLinkageScene, FlowSurfaceFieldOption, FlowSurfaceFieldPathToUidResolver, FlowSurfaceFieldUidToPathResolver, FlowSurfaceReactionFilter, FlowSurfaceBlockLinkageRule } from './types';
10
10
  type NormalizeFieldRuleOptions = {
11
11
  scene: FlowSurfaceFieldLinkageScene;
12
12
  resolveFieldPath?: FlowSurfaceFieldUidToPathResolver;
@@ -18,6 +18,10 @@ type CompileFieldRuleOptions = {
18
18
  type FlowSurfaceLinkageValidationCapability = {
19
19
  conditionMeta: {
20
20
  operatorsByPath: Record<string, string[]>;
21
+ fieldMetaByPath?: Record<string, {
22
+ type?: string;
23
+ interface?: string;
24
+ }>;
21
25
  };
22
26
  };
23
27
  type FlowSurfaceFieldLinkageValidationCapability = FlowSurfaceLinkageValidationCapability & {
@@ -26,6 +30,7 @@ type FlowSurfaceFieldLinkageValidationCapability = FlowSurfaceLinkageValidationC
26
30
  supportedSources: Array<'literal' | 'path' | 'runjs'>;
27
31
  };
28
32
  };
33
+ export declare function validateReactionFilterAgainstCapability(filter: FlowSurfaceReactionFilter | undefined, capability: FlowSurfaceLinkageValidationCapability, prefix: string): void;
29
34
  export declare function buildReactionFingerprint(value: any): string;
30
35
  export declare function normalizeBlockLinkageRules(rawRules: unknown): FlowSurfaceBlockLinkageRule[];
31
36
  export declare function normalizeActionLinkageRules(rawRules: unknown): FlowSurfaceActionLinkageRule[];
@@ -48,7 +48,8 @@ __export(linkage_exports, {
48
48
  validateBlockLinkageRulesAgainstCapability: () => validateBlockLinkageRulesAgainstCapability,
49
49
  validateBlockLinkageSceneSupport: () => validateBlockLinkageSceneSupport,
50
50
  validateFieldLinkageRulesAgainstCapability: () => validateFieldLinkageRulesAgainstCapability,
51
- validateFieldLinkageSceneSupport: () => validateFieldLinkageSceneSupport
51
+ validateFieldLinkageSceneSupport: () => validateFieldLinkageSceneSupport,
52
+ validateReactionFilterAgainstCapability: () => validateReactionFilterAgainstCapability
52
53
  });
53
54
  module.exports = __toCommonJS(linkage_exports);
54
55
  var import_node_crypto = require("node:crypto");
@@ -148,7 +149,10 @@ function normalizeReactionFilter(rawFilter) {
148
149
  }
149
150
  const normalizedFilter = (0, import_filter_group.normalizeFlowSurfaceCompatibleFilterGroupValue)(
150
151
  rawFilter,
151
- "flowSurfaces linkage rule condition"
152
+ "flowSurfaces linkage rule condition",
153
+ {
154
+ allowContextPathValue: true
155
+ }
152
156
  );
153
157
  const visit = (node) => {
154
158
  if (!import_lodash.default.isPlainObject(node)) {
@@ -639,6 +643,7 @@ function validateReactionFilterAgainstCapability(filter, capability, prefix) {
639
643
  var _a;
640
644
  const operatorsByPath = ((_a = capability.conditionMeta) == null ? void 0 : _a.operatorsByPath) || {};
641
645
  const visit = (node, currentPrefix) => {
646
+ var _a2, _b;
642
647
  if (!import_lodash.default.isPlainObject(node)) {
643
648
  return;
644
649
  }
@@ -683,6 +688,15 @@ function validateReactionFilterAgainstCapability(filter, capability, prefix) {
683
688
  );
684
689
  }
685
690
  if (hasValue) {
691
+ const fieldMeta = (_b = (_a2 = capability.conditionMeta) == null ? void 0 : _a2.fieldMetaByPath) == null ? void 0 : _b[operatorPath];
692
+ if (import_filter_group.FLOW_SURFACE_DATE_FILTER_OPERATORS.has(operator) || (0, import_filter_group.isFlowSurfaceDateLikeFieldMeta)(fieldMeta)) {
693
+ (0, import_filter_group.normalizeFlowSurfaceDateConditionValue)(operator, node.value, `${currentPrefix}.value`, {
694
+ fieldPath: path,
695
+ fieldType: fieldMeta == null ? void 0 : fieldMeta.type,
696
+ fieldInterface: fieldMeta == null ? void 0 : fieldMeta.interface,
697
+ allowContextPathValue: true
698
+ });
699
+ }
686
700
  validateContextBoundValue(node.value, capability, `${currentPrefix}.value`);
687
701
  }
688
702
  };
@@ -895,5 +909,6 @@ function compileFieldLinkageCanonicalRules(rules, options) {
895
909
  validateBlockLinkageRulesAgainstCapability,
896
910
  validateBlockLinkageSceneSupport,
897
911
  validateFieldLinkageRulesAgainstCapability,
898
- validateFieldLinkageSceneSupport
912
+ validateFieldLinkageSceneSupport,
913
+ validateReactionFilterAgainstCapability
899
914
  });
@@ -114,6 +114,19 @@ function buildConditionOperatorsByPath(context) {
114
114
  }
115
115
  return operatorsByPath;
116
116
  }
117
+ function buildConditionFieldMetaByPath(context) {
118
+ const fieldMetaByPath = {};
119
+ for (const [path, info] of collectContextPathEntries(context)) {
120
+ if (!isAuthorableLinkageContextPath(path)) {
121
+ continue;
122
+ }
123
+ fieldMetaByPath[path] = {
124
+ ...(info == null ? void 0 : info.type) ? { type: info.type } : {},
125
+ ...(info == null ? void 0 : info.interface) ? { interface: info.interface } : {}
126
+ };
127
+ }
128
+ return fieldMetaByPath;
129
+ }
117
130
  function isAuthorableLinkageContextPath(path) {
118
131
  const segments = String(path || "").split(".").filter(Boolean);
119
132
  const root = segments[0];
@@ -395,6 +408,10 @@ function buildFieldValueCapability(input, capability) {
395
408
  canonicalRules,
396
409
  context: input.context,
397
410
  targetFields: collectFieldOptions(input.resolvedTarget.node, input.context, capability.resolvedScene),
411
+ conditionMeta: {
412
+ operatorsByPath: buildConditionOperatorsByPath(input.context),
413
+ fieldMetaByPath: buildConditionFieldMetaByPath(input.context)
414
+ },
398
415
  valueExprMeta: {
399
416
  supportedSources: ["literal", "path", "runjs"],
400
417
  runjsScene: "fieldValue"
@@ -412,7 +429,8 @@ function buildLinkageCapability(input, capability) {
412
429
  context: input.context,
413
430
  supportedActions: buildSupportedActions(capability),
414
431
  conditionMeta: {
415
- operatorsByPath: buildConditionOperatorsByPath(input.context)
432
+ operatorsByPath: buildConditionOperatorsByPath(input.context),
433
+ fieldMetaByPath: buildConditionFieldMetaByPath(input.context)
416
434
  }
417
435
  };
418
436
  if (capability.kind === "fieldLinkage") {
@@ -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,
@@ -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);
@@ -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);
@@ -139,6 +139,14 @@ function scanJavaScriptSource(source, ast, context = {}, modelUse = "") {
139
139
  isTopLevelFunctionWrapper: (0, import_source_patterns.isTopLevelFunctionWrapper)(masked, functionRanges, topLevelReachableCtxRenderCalls)
140
140
  };
141
141
  }
142
+ function collectScanFunctionRanges(masked, ast) {
143
+ if (!ast) {
144
+ return (0, import_source.findFunctionRanges)(masked);
145
+ }
146
+ const ranges = (0, import_source.collectAstFunctionBodyRanges)(ast);
147
+ (0, import_source.collectArrowExpressionRanges)(masked, ranges);
148
+ return (0, import_source.mergeRanges)(ranges);
149
+ }
142
150
  function collectAstUnknownBareGlobalsFromAst(ast, identifierBindings, modelUse) {
143
151
  var _a;
144
152
  const allowedGlobals = new Set(import_constants.RUNJS_ALLOWED_BARE_GLOBALS);
@@ -142,6 +142,7 @@ export declare class FlowSurfacesService {
142
142
  private getCollectionFilterTargetKey;
143
143
  private normalizeFlowContextTemplateValue;
144
144
  private isSameConfiguredFlowContextValue;
145
+ private isPopupCurrentRecordFilterByTkMatch;
145
146
  private isPopupAssociatedRecordsSourceIdMatch;
146
147
  private classifyPopupRawResourceInit;
147
148
  private resolvePopupAssociationField;
@@ -160,6 +161,7 @@ export declare class FlowSurfacesService {
160
161
  private persistReactionSlot;
161
162
  private buildLinkageWriteResult;
162
163
  private getLiveLinkageCapability;
164
+ private getLiveFieldValueCapability;
163
165
  getReactionMeta(values: FlowSurfaceGetReactionMetaValues, options?: {
164
166
  transaction?: any;
165
167
  }): Promise<FlowSurfaceGetReactionMetaResult>;
@@ -182,6 +184,17 @@ export declare class FlowSurfacesService {
182
184
  private buildSurfaceReadPayload;
183
185
  private buildSurfaceContextFingerprint;
184
186
  get(input: Record<string, any>, options?: FlowSurfaceReadOptions): Promise<Record<string, any>>;
187
+ exportBlueprint(input: Record<string, unknown>, options?: FlowSurfaceReadOptions): Promise<{
188
+ document: FlowSurfaceApplyBlueprintDocument;
189
+ source: {
190
+ target: {
191
+ pageSchemaUid: string;
192
+ };
193
+ pageTitle?: string;
194
+ };
195
+ warnings: string[];
196
+ unsupported: import("./blueprint/export-document").FlowSurfaceExportBlueprintUnsupportedItem[];
197
+ }>;
185
198
  private getDeclaredKeyPersistenceDeps;
186
199
  private patchDeclaredKeyModel;
187
200
  private persistCreatedKeysForAction;
@@ -288,6 +301,7 @@ export declare class FlowSurfacesService {
288
301
  private createFlowTemplateReferenceBlockModel;
289
302
  private buildPopupTemplateReferenceOpenView;
290
303
  private shouldHydrateDetachedPopupTemplateBlockResourceContext;
304
+ private resolveDetachedPopupTemplateBlockCurrentRecordFilterByTk;
291
305
  private collectDetachedPopupTemplateBlockResourceContextPatches;
292
306
  private hydrateDetachedPopupTemplateBlockResourceContext;
293
307
  private hydrateDetachedPopupTemplateSourceContext;
@@ -736,6 +750,9 @@ export declare class FlowSurfacesService {
736
750
  private syncFilterActionSettingsForUpdateSettings;
737
751
  private resolveFilterActionDefaultFilterRequiredFieldCount;
738
752
  private syncMirroredStepParamsForUpdateSettings;
753
+ private syncActionButtonSettingsForUpdateSettings;
754
+ private supportsActionButtonSettingsSync;
755
+ private pickRequestedActionButtonSettings;
739
756
  private syncCreatedFieldWrapperTitleFieldStepParams;
740
757
  private syncUpdateActionAssignedValuesForUpdateSettings;
741
758
  private syncActionTriggerWorkflowsForUpdateSettings;
@@ -916,6 +933,12 @@ export declare class FlowSurfacesService {
916
933
  private normalizeRemoveNodeTarget;
917
934
  private assertRemoveNodeResolvedTarget;
918
935
  private normalizeGetTarget;
936
+ private normalizeExportBlueprintRequest;
937
+ private normalizeExportBlueprintUnsupportedPolicy;
938
+ private normalizeExportBlueprintLocatorValue;
939
+ private readRouteString;
940
+ private resolveExportBlueprintPageSchemaUid;
941
+ private assertExportBlueprintRootTarget;
919
942
  private normalizeContextPath;
920
943
  private normalizeContextMaxDepth;
921
944
  private buildReadTargetSummary;
@@ -1088,6 +1111,7 @@ export declare class FlowSurfacesService {
1088
1111
  private buildFieldCatalog;
1089
1112
  private getFieldMenuCatalogMode;
1090
1113
  private resolveRegisteredFieldBinding;
1114
+ private isCollectionTitleField;
1091
1115
  private resolveAssociationLeafDisplaySemantics;
1092
1116
  private buildFieldMenuDirectCandidates;
1093
1117
  private collectFieldMenuAssociationLeafCandidates;