@nocobase/plugin-flow-engine 2.1.0-alpha.15 → 2.1.0-alpha.17

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 (116) hide show
  1. package/dist/externalVersion.js +10 -10
  2. package/dist/node_modules/ses/package.json +1 -1
  3. package/dist/node_modules/zod/package.json +1 -1
  4. package/dist/server/flow-surfaces/{compiler.d.ts → apply/compiler.d.ts} +1 -10
  5. package/dist/server/flow-surfaces/{compiler.js → apply/compiler.js} +41 -280
  6. package/dist/server/flow-surfaces/apply/layout.d.ts +34 -0
  7. package/dist/server/flow-surfaces/apply/layout.js +175 -0
  8. package/dist/server/flow-surfaces/apply/matching.d.ts +16 -0
  9. package/dist/server/flow-surfaces/apply/matching.js +181 -0
  10. package/dist/server/flow-surfaces/association-title-field.d.ts +20 -0
  11. package/dist/server/flow-surfaces/association-title-field.js +158 -0
  12. package/dist/server/flow-surfaces/blueprint/compile-blocks.d.ts +14 -0
  13. package/dist/server/flow-surfaces/blueprint/compile-blocks.js +717 -0
  14. package/dist/server/flow-surfaces/blueprint/compile-plan.d.ts +13 -0
  15. package/dist/server/flow-surfaces/blueprint/compile-plan.js +308 -0
  16. package/dist/server/flow-surfaces/blueprint/compile-reaction.d.ts +11 -0
  17. package/dist/server/flow-surfaces/blueprint/compile-reaction.js +72 -0
  18. package/dist/server/flow-surfaces/blueprint/index.d.ts +12 -0
  19. package/dist/server/flow-surfaces/blueprint/index.js +44 -0
  20. package/dist/server/flow-surfaces/blueprint/normalize-document.d.ts +10 -0
  21. package/dist/server/flow-surfaces/blueprint/normalize-document.js +296 -0
  22. package/dist/server/flow-surfaces/blueprint/private-utils.d.ts +26 -0
  23. package/dist/server/flow-surfaces/blueprint/private-utils.js +182 -0
  24. package/dist/server/flow-surfaces/blueprint/public-types.d.ts +153 -0
  25. package/dist/server/flow-surfaces/blueprint/public-types.js +24 -0
  26. package/dist/server/flow-surfaces/catalog-smart.d.ts +18 -0
  27. package/dist/server/flow-surfaces/catalog-smart.js +239 -0
  28. package/dist/server/flow-surfaces/catalog-smart.projector.d.ts +15 -0
  29. package/dist/server/flow-surfaces/catalog-smart.projector.js +157 -0
  30. package/dist/server/flow-surfaces/catalog-smart.types.d.ts +99 -0
  31. package/dist/server/flow-surfaces/catalog-smart.types.js +24 -0
  32. package/dist/server/flow-surfaces/catalog.d.ts +3 -0
  33. package/dist/server/flow-surfaces/catalog.js +163 -34
  34. package/dist/server/flow-surfaces/compose-compiler.d.ts +104 -0
  35. package/dist/server/flow-surfaces/compose-compiler.js +162 -0
  36. package/dist/server/flow-surfaces/compose-runtime.d.ts +89 -0
  37. package/dist/server/flow-surfaces/compose-runtime.js +338 -0
  38. package/dist/server/flow-surfaces/configure-options.js +12 -3
  39. package/dist/server/flow-surfaces/constants.d.ts +3 -2
  40. package/dist/server/flow-surfaces/constants.js +36 -3
  41. package/dist/server/flow-surfaces/default-action-popup.d.ts +52 -0
  42. package/dist/server/flow-surfaces/default-action-popup.js +258 -0
  43. package/dist/server/flow-surfaces/executor.d.ts +10 -0
  44. package/dist/server/flow-surfaces/executor.js +59 -24
  45. package/dist/server/flow-surfaces/field-binding-registry.d.ts +23 -0
  46. package/dist/server/flow-surfaces/field-binding-registry.js +391 -0
  47. package/dist/server/flow-surfaces/field-semantics.d.ts +1 -1
  48. package/dist/server/flow-surfaces/index.js +75 -0
  49. package/dist/server/flow-surfaces/node-use-sets.d.ts +15 -0
  50. package/dist/server/flow-surfaces/node-use-sets.js +114 -0
  51. package/dist/server/flow-surfaces/payload-shape.d.ts +9 -0
  52. package/dist/server/flow-surfaces/payload-shape.js +61 -0
  53. package/dist/server/flow-surfaces/placement.js +2 -6
  54. package/dist/server/flow-surfaces/planning/action-specs.d.ts +179 -0
  55. package/dist/server/flow-surfaces/planning/action-specs.js +190 -0
  56. package/dist/server/flow-surfaces/planning/compiler.d.ts +37 -0
  57. package/dist/server/flow-surfaces/planning/compiler.js +376 -0
  58. package/dist/server/flow-surfaces/planning/context.d.ts +30 -0
  59. package/dist/server/flow-surfaces/planning/context.js +139 -0
  60. package/dist/server/flow-surfaces/planning/created-keys.d.ts +34 -0
  61. package/dist/server/flow-surfaces/planning/created-keys.js +375 -0
  62. package/dist/server/flow-surfaces/planning/key-kind.d.ts +11 -0
  63. package/dist/server/flow-surfaces/planning/key-kind.js +86 -0
  64. package/dist/server/flow-surfaces/planning/key-persistence.d.ts +34 -0
  65. package/dist/server/flow-surfaces/planning/key-persistence.js +148 -0
  66. package/dist/server/flow-surfaces/planning/key-registry.d.ts +40 -0
  67. package/dist/server/flow-surfaces/planning/key-registry.js +206 -0
  68. package/dist/server/flow-surfaces/planning/runtime.d.ts +37 -0
  69. package/dist/server/flow-surfaces/planning/runtime.js +259 -0
  70. package/dist/server/flow-surfaces/planning/step-link.d.ts +14 -0
  71. package/dist/server/flow-surfaces/planning/step-link.js +104 -0
  72. package/dist/server/flow-surfaces/planning/types.d.ts +55 -0
  73. package/dist/server/flow-surfaces/planning/types.js +24 -0
  74. package/dist/server/flow-surfaces/reaction/errors.d.ts +20 -0
  75. package/dist/server/flow-surfaces/reaction/errors.js +69 -0
  76. package/dist/server/flow-surfaces/reaction/field-value.d.ts +34 -0
  77. package/dist/server/flow-surfaces/reaction/field-value.js +181 -0
  78. package/dist/server/flow-surfaces/reaction/fingerprint.d.ts +16 -0
  79. package/dist/server/flow-surfaces/reaction/fingerprint.js +71 -0
  80. package/dist/server/flow-surfaces/reaction/linkage.d.ts +136 -0
  81. package/dist/server/flow-surfaces/reaction/linkage.js +882 -0
  82. package/dist/server/flow-surfaces/reaction/meta.d.ts +11 -0
  83. package/dist/server/flow-surfaces/reaction/meta.js +451 -0
  84. package/dist/server/flow-surfaces/reaction/registry.d.ts +136 -0
  85. package/dist/server/flow-surfaces/reaction/registry.js +186 -0
  86. package/dist/server/flow-surfaces/reaction/resolver.d.ts +22 -0
  87. package/dist/server/flow-surfaces/reaction/resolver.js +202 -0
  88. package/dist/server/flow-surfaces/reaction/types.d.ts +241 -0
  89. package/dist/server/flow-surfaces/reaction/types.js +24 -0
  90. package/dist/server/flow-surfaces/reaction/utils.d.ts +17 -0
  91. package/dist/server/flow-surfaces/reaction/utils.js +67 -0
  92. package/dist/server/flow-surfaces/reaction/value-expr.d.ts +15 -0
  93. package/dist/server/flow-surfaces/reaction/value-expr.js +209 -0
  94. package/dist/server/flow-surfaces/reference-guards.d.ts +19 -0
  95. package/dist/server/flow-surfaces/reference-guards.js +103 -0
  96. package/dist/server/flow-surfaces/service-helpers.d.ts +42 -0
  97. package/dist/server/flow-surfaces/service-helpers.js +377 -0
  98. package/dist/server/flow-surfaces/service-utils.d.ts +105 -0
  99. package/dist/server/flow-surfaces/service-utils.js +760 -0
  100. package/dist/server/flow-surfaces/service.d.ts +199 -104
  101. package/dist/server/flow-surfaces/service.js +4158 -1890
  102. package/dist/server/flow-surfaces/template-compatibility.d.ts +42 -0
  103. package/dist/server/flow-surfaces/template-compatibility.js +189 -0
  104. package/dist/server/flow-surfaces/template-service-utils.d.ts +62 -0
  105. package/dist/server/flow-surfaces/template-service-utils.js +281 -0
  106. package/dist/server/flow-surfaces/types.d.ts +129 -37
  107. package/dist/swagger/flow-surfaces.d.ts +3777 -1581
  108. package/dist/swagger/flow-surfaces.examples.d.ts +1246 -0
  109. package/dist/swagger/flow-surfaces.examples.js +1396 -0
  110. package/dist/swagger/flow-surfaces.js +2020 -1469
  111. package/dist/swagger/flow-surfaces.template-action-docs.d.ts +62 -0
  112. package/dist/swagger/flow-surfaces.template-action-docs.js +121 -0
  113. package/dist/swagger/flow-surfaces.template-schemas.d.ts +239 -0
  114. package/dist/swagger/flow-surfaces.template-schemas.js +255 -0
  115. package/dist/swagger/index.d.ts +3777 -1581
  116. package/package.json +2 -2
@@ -0,0 +1,175 @@
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 layout_exports = {};
38
+ __export(layout_exports, {
39
+ buildAutoLayout: () => buildAutoLayout,
40
+ didItemRefsChange: () => didItemRefsChange,
41
+ emitLayoutOp: () => emitLayoutOp,
42
+ emitMoveOps: () => emitMoveOps,
43
+ emitMovePopupTabOps: () => emitMovePopupTabOps,
44
+ emitMoveTabOps: () => emitMoveTabOps,
45
+ omitLayoutProps: () => omitLayoutProps
46
+ });
47
+ module.exports = __toCommonJS(layout_exports);
48
+ var import_lodash = __toESM(require("lodash"));
49
+ var import_placement = require("../placement");
50
+ function extractLayout(props) {
51
+ if (!props || !("rows" in props) && !("sizes" in props) && !("rowOrder" in props)) {
52
+ return null;
53
+ }
54
+ return {
55
+ rows: props.rows || {},
56
+ sizes: props.sizes || {},
57
+ rowOrder: props.rowOrder || Object.keys(props.rows || {})
58
+ };
59
+ }
60
+ function omitLayoutProps(props) {
61
+ if (!props) {
62
+ return props;
63
+ }
64
+ const next = import_lodash.default.omit(props, ["rows", "sizes", "rowOrder"]);
65
+ return Object.keys(next).length ? next : void 0;
66
+ }
67
+ function resolveLayoutRefs(layout, childClientKeyRefs) {
68
+ if (!layout) {
69
+ return layout;
70
+ }
71
+ return {
72
+ rows: Object.fromEntries(
73
+ Object.entries(layout.rows || {}).map(([rowId, cells]) => [
74
+ rowId,
75
+ import_lodash.default.castArray(cells).map(
76
+ (cell) => import_lodash.default.castArray(cell).map((itemUid) => childClientKeyRefs[itemUid] ?? itemUid)
77
+ )
78
+ ])
79
+ ),
80
+ sizes: layout.sizes || {},
81
+ rowOrder: layout.rowOrder || []
82
+ };
83
+ }
84
+ function hasRefValue(value) {
85
+ if (Array.isArray(value)) {
86
+ return value.some((item) => hasRefValue(item));
87
+ }
88
+ if (import_lodash.default.isPlainObject(value)) {
89
+ if (typeof value.ref === "string") {
90
+ return true;
91
+ }
92
+ return Object.values(value).some((item) => hasRefValue(item));
93
+ }
94
+ return false;
95
+ }
96
+ function buildAutoLayout(itemRefs) {
97
+ if (!itemRefs.length) {
98
+ return {
99
+ rows: {},
100
+ sizes: {},
101
+ rowOrder: []
102
+ };
103
+ }
104
+ return {
105
+ rows: Object.fromEntries(itemRefs.map((itemRef, index) => [`autoRow${index + 1}`, [[itemRef]]])),
106
+ sizes: Object.fromEntries(itemRefs.map((_2, index) => [`autoRow${index + 1}`, [24]])),
107
+ rowOrder: itemRefs.map((_2, index) => `autoRow${index + 1}`)
108
+ };
109
+ }
110
+ function didItemRefsChange(currentChildren, desiredRefs) {
111
+ if (currentChildren.length !== desiredRefs.length) {
112
+ return true;
113
+ }
114
+ return desiredRefs.some(
115
+ (item, index) => {
116
+ var _a;
117
+ return typeof item.uidRef !== "string" || ((_a = currentChildren[index]) == null ? void 0 : _a.uid) !== item.uidRef;
118
+ }
119
+ );
120
+ }
121
+ function emitLayoutOp(ops, target, currentNode, desiredNode, childSync) {
122
+ const explicitLayout = resolveLayoutRefs(extractLayout(desiredNode.props), childSync.childClientKeyRefs);
123
+ const desiredLayout = explicitLayout || ((0, import_placement.isGridUse)((currentNode == null ? void 0 : currentNode.use) || desiredNode.use) && childSync.itemsSpecified ? buildAutoLayout(childSync.finalItemRefs.map((item) => item.uidRef)) : null);
124
+ if (!desiredLayout) {
125
+ return;
126
+ }
127
+ if (!hasRefValue(desiredLayout) && import_lodash.default.isEqual(desiredLayout, extractLayout(currentNode == null ? void 0 : currentNode.props))) {
128
+ return;
129
+ }
130
+ ops.push({
131
+ type: "setLayout",
132
+ target,
133
+ values: desiredLayout
134
+ });
135
+ }
136
+ function emitMoveOps(ops, desiredRefs) {
137
+ for (let index = desiredRefs.length - 2; index >= 0; index -= 1) {
138
+ ops.push({
139
+ type: "moveNode",
140
+ values: {
141
+ sourceUid: desiredRefs[index].uidRef,
142
+ targetUid: desiredRefs[index + 1].uidRef,
143
+ position: "before"
144
+ }
145
+ });
146
+ }
147
+ }
148
+ function emitOrderedTabMoves(ops, desiredRefs, type) {
149
+ for (let index = desiredRefs.length - 2; index >= 0; index -= 1) {
150
+ ops.push({
151
+ type,
152
+ values: {
153
+ sourceUid: desiredRefs[index].uidRef,
154
+ targetUid: desiredRefs[index + 1].uidRef,
155
+ position: "before"
156
+ }
157
+ });
158
+ }
159
+ }
160
+ function emitMoveTabOps(ops, desiredRefs) {
161
+ emitOrderedTabMoves(ops, desiredRefs, "moveTab");
162
+ }
163
+ function emitMovePopupTabOps(ops, desiredRefs) {
164
+ emitOrderedTabMoves(ops, desiredRefs, "movePopupTab");
165
+ }
166
+ // Annotate the CommonJS export names for ESM import in node:
167
+ 0 && (module.exports = {
168
+ buildAutoLayout,
169
+ didItemRefsChange,
170
+ emitLayoutOp,
171
+ emitMoveOps,
172
+ emitMovePopupTabOps,
173
+ emitMoveTabOps,
174
+ omitLayoutProps
175
+ });
@@ -0,0 +1,16 @@
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 { FlowSurfaceApplySpec, FlowSurfaceNodeSpec } from '../types';
10
+ export declare function normalizeChildren(input: any): FlowSurfaceNodeSpec[];
11
+ export declare function hasExplicitSubModelKey(node: Pick<FlowSurfaceNodeSpec, 'subModels'> | FlowSurfaceApplySpec, key: string): any;
12
+ export declare function matchesObjectChild(currentChild: any, desiredChild: FlowSurfaceNodeSpec): boolean;
13
+ export declare function planArrayChildMatches(currentChildren: FlowSurfaceNodeSpec[], desiredChildren: FlowSurfaceNodeSpec[], parentUse: string, subKey: string): {
14
+ matchesByDesiredIndex: Map<number, FlowSurfaceNodeSpec>;
15
+ matchedCurrentUids: Set<string>;
16
+ };
@@ -0,0 +1,181 @@
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 matching_exports = {};
38
+ __export(matching_exports, {
39
+ hasExplicitSubModelKey: () => hasExplicitSubModelKey,
40
+ matchesObjectChild: () => matchesObjectChild,
41
+ normalizeChildren: () => normalizeChildren,
42
+ planArrayChildMatches: () => planArrayChildMatches
43
+ });
44
+ module.exports = __toCommonJS(matching_exports);
45
+ var import_lodash = __toESM(require("lodash"));
46
+ var import_errors = require("../errors");
47
+ function normalizeChildren(input) {
48
+ if (!input) {
49
+ return [];
50
+ }
51
+ return import_lodash.default.castArray(input).filter(Boolean);
52
+ }
53
+ function hasExplicitSubModelKey(node, key) {
54
+ return !!(node == null ? void 0 : node.subModels) && Object.prototype.hasOwnProperty.call(node.subModels, key);
55
+ }
56
+ function matchesObjectChild(currentChild, desiredChild) {
57
+ return currentChild.uid === desiredChild.uid || !desiredChild.uid && currentChild.use === desiredChild.use;
58
+ }
59
+ function planArrayChildMatches(currentChildren, desiredChildren, parentUse, subKey) {
60
+ const matchesByDesiredIndex = /* @__PURE__ */ new Map();
61
+ const matchedCurrentUids = /* @__PURE__ */ new Set();
62
+ const remainingDesiredByUse = /* @__PURE__ */ new Map();
63
+ for (const [desiredIndex, desiredChild] of desiredChildren.entries()) {
64
+ const matchedCurrent = findExactArrayChildMatch(currentChildren, desiredChild, matchedCurrentUids);
65
+ if (matchedCurrent) {
66
+ matchesByDesiredIndex.set(desiredIndex, matchedCurrent);
67
+ if (matchedCurrent.uid) {
68
+ matchedCurrentUids.add(matchedCurrent.uid);
69
+ }
70
+ continue;
71
+ }
72
+ if ((desiredChild == null ? void 0 : desiredChild.use) && !desiredChild.uid) {
73
+ const desiredIndexes = remainingDesiredByUse.get(desiredChild.use) || [];
74
+ desiredIndexes.push(desiredIndex);
75
+ remainingDesiredByUse.set(desiredChild.use, desiredIndexes);
76
+ }
77
+ }
78
+ const remainingCurrentByUse = /* @__PURE__ */ new Map();
79
+ for (const currentChild of currentChildren) {
80
+ if (!(currentChild == null ? void 0 : currentChild.use) || matchedCurrentUids.has(currentChild.uid || "")) {
81
+ continue;
82
+ }
83
+ const currentGroup = remainingCurrentByUse.get(currentChild.use) || [];
84
+ currentGroup.push(currentChild);
85
+ remainingCurrentByUse.set(currentChild.use, currentGroup);
86
+ }
87
+ const uses = /* @__PURE__ */ new Set([...remainingCurrentByUse.keys(), ...remainingDesiredByUse.keys()]);
88
+ for (const use of uses) {
89
+ const currentGroup = remainingCurrentByUse.get(use) || [];
90
+ const desiredIndexes = remainingDesiredByUse.get(use) || [];
91
+ const shouldReuseByOrder = currentGroup.length > 1 || desiredIndexes.length > 1;
92
+ if (currentGroup.length > 0 && desiredIndexes.length > 0 && currentGroup.length !== desiredIndexes.length && shouldReuseByOrder) {
93
+ throw new import_errors.FlowSurfaceBadRequestError(
94
+ `flowSurfaces apply cannot safely match duplicate '${use}' nodes under '${parentUse}.${subKey}' without explicit uid or signature`
95
+ );
96
+ }
97
+ if (!shouldReuseByOrder) {
98
+ continue;
99
+ }
100
+ const reuseCount = Math.min(currentGroup.length, desiredIndexes.length);
101
+ for (let index = 0; index < reuseCount; index += 1) {
102
+ const currentChild = currentGroup[index];
103
+ const desiredIndex = desiredIndexes[index];
104
+ matchesByDesiredIndex.set(desiredIndex, currentChild);
105
+ if (currentChild == null ? void 0 : currentChild.uid) {
106
+ matchedCurrentUids.add(currentChild.uid);
107
+ }
108
+ }
109
+ }
110
+ return {
111
+ matchesByDesiredIndex,
112
+ matchedCurrentUids
113
+ };
114
+ }
115
+ function findExactArrayChildMatch(currentChildren, desiredChild, matchedCurrent) {
116
+ if (desiredChild.uid) {
117
+ return currentChildren.find((item) => (item == null ? void 0 : item.uid) === desiredChild.uid);
118
+ }
119
+ const desiredStrongSignature = getStrongNodeSignature(desiredChild);
120
+ if (desiredStrongSignature) {
121
+ return currentChildren.find(
122
+ (item) => !matchedCurrent.has(item.uid || "") && getStrongNodeSignature(item) === desiredStrongSignature
123
+ );
124
+ }
125
+ const desiredWeakSignature = getWeakNodeSignature(desiredChild);
126
+ if (desiredWeakSignature) {
127
+ return currentChildren.find(
128
+ (item) => !matchedCurrent.has(item.uid || "") && getWeakNodeSignature(item) === desiredWeakSignature
129
+ );
130
+ }
131
+ return void 0;
132
+ }
133
+ function getStrongNodeSignature(node) {
134
+ if (!(node == null ? void 0 : node.use)) {
135
+ return null;
136
+ }
137
+ const resourceInit = import_lodash.default.get(node, ["stepParams", "resourceSettings", "init"]);
138
+ if ((resourceInit == null ? void 0 : resourceInit.dataSourceKey) || (resourceInit == null ? void 0 : resourceInit.collectionName) || (resourceInit == null ? void 0 : resourceInit.associationName) || (resourceInit == null ? void 0 : resourceInit.associationPathName) || !import_lodash.default.isUndefined(resourceInit == null ? void 0 : resourceInit.sourceId)) {
139
+ return [
140
+ "resource",
141
+ node.use,
142
+ resourceInit.dataSourceKey || "",
143
+ resourceInit.collectionName || "",
144
+ resourceInit.associationName || "",
145
+ resourceInit.associationPathName || "",
146
+ import_lodash.default.isUndefined(resourceInit.sourceId) ? "" : String(resourceInit.sourceId)
147
+ ].join(":");
148
+ }
149
+ const fieldInit = import_lodash.default.get(node, ["stepParams", "fieldSettings", "init"]) || import_lodash.default.get(node, ["subModels", "field", "stepParams", "fieldSettings", "init"]);
150
+ if (fieldInit == null ? void 0 : fieldInit.fieldPath) {
151
+ return [
152
+ "field",
153
+ node.use,
154
+ fieldInit.dataSourceKey || "",
155
+ fieldInit.collectionName || "",
156
+ fieldInit.associationPathName || "",
157
+ fieldInit.fieldPath
158
+ ].join(":");
159
+ }
160
+ if (node.use === "TableActionsColumnModel") {
161
+ return "slot:table-actions-column";
162
+ }
163
+ return null;
164
+ }
165
+ function getWeakNodeSignature(node) {
166
+ if (!(node == null ? void 0 : node.use)) {
167
+ return null;
168
+ }
169
+ const title = import_lodash.default.get(node, ["stepParams", "pageTabSettings", "tab", "title"]) || import_lodash.default.get(node, ["stepParams", "buttonSettings", "general", "title"]) || import_lodash.default.get(node, ["props", "title"]);
170
+ if (typeof title === "string" && title.trim()) {
171
+ return ["title", node.use, title.trim()].join(":");
172
+ }
173
+ return null;
174
+ }
175
+ // Annotate the CommonJS export names for ESM import in node:
176
+ 0 && (module.exports = {
177
+ hasExplicitSubModelKey,
178
+ matchesObjectChild,
179
+ normalizeChildren,
180
+ planArrayChildMatches
181
+ });
@@ -0,0 +1,20 @@
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 type FlowSurfaceResolvedAssociationTitleField = {
10
+ field: any;
11
+ fieldName: string;
12
+ source: 'explicit' | 'firstTitleable';
13
+ targetCollection?: any;
14
+ };
15
+ export declare function isTitleableCollectionField(field: any): any;
16
+ export declare function getExplicitCollectionTitleFieldName(collection: any): string;
17
+ export declare function assertCollectionTitleFieldExists(collection: any, fieldName: string): any;
18
+ export declare function resolveCollectionSafeTitleField(collection: any): FlowSurfaceResolvedAssociationTitleField | null;
19
+ export declare function resolveAssociationTitleFieldTargetCollection(field: any, dataSourceKey: string, getCollection: (dataSourceKey: string, collectionName: string) => any): any;
20
+ export declare function resolveAssociationSafeTitleField(field: any, dataSourceKey: string, getCollection: (dataSourceKey: string, collectionName: string) => any): FlowSurfaceResolvedAssociationTitleField | null;
@@ -0,0 +1,158 @@
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 association_title_field_exports = {};
28
+ __export(association_title_field_exports, {
29
+ assertCollectionTitleFieldExists: () => assertCollectionTitleFieldExists,
30
+ getExplicitCollectionTitleFieldName: () => getExplicitCollectionTitleFieldName,
31
+ isTitleableCollectionField: () => isTitleableCollectionField,
32
+ resolveAssociationSafeTitleField: () => resolveAssociationSafeTitleField,
33
+ resolveAssociationTitleFieldTargetCollection: () => resolveAssociationTitleFieldTargetCollection,
34
+ resolveCollectionSafeTitleField: () => resolveCollectionSafeTitleField
35
+ });
36
+ module.exports = __toCommonJS(association_title_field_exports);
37
+ var import_errors = require("./errors");
38
+ var import_service_helpers = require("./service-helpers");
39
+ const FALLBACK_TITLE_USABLE_INTERFACES = /* @__PURE__ */ new Set([
40
+ "attachmentURL",
41
+ "createdAt",
42
+ "date",
43
+ "datetime",
44
+ "datetimeNoTz",
45
+ "email",
46
+ "formula",
47
+ "id",
48
+ "input",
49
+ "integer",
50
+ "nanoid",
51
+ "number",
52
+ "percent",
53
+ "phone",
54
+ "radioGroup",
55
+ "select",
56
+ "sequence",
57
+ "snowflakeId",
58
+ "sort",
59
+ "space",
60
+ "textarea",
61
+ "time",
62
+ "unixTimestamp",
63
+ "updatedAt",
64
+ "url",
65
+ "uuid",
66
+ "vditor"
67
+ ]);
68
+ function isTitleableCollectionField(field) {
69
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
70
+ const configured = (field == null ? void 0 : field.titleable) ?? (field == null ? void 0 : field.titleUsable) ?? ((_a = field == null ? void 0 : field.options) == null ? void 0 : _a.titleable) ?? ((_b = field == null ? void 0 : field.options) == null ? void 0 : _b.titleUsable);
71
+ if (typeof configured === "boolean") {
72
+ return configured;
73
+ }
74
+ const interfaceOptions = typeof (field == null ? void 0 : field.getInterfaceOptions) === "function" ? field.getInterfaceOptions() : void 0;
75
+ if (typeof (interfaceOptions == null ? void 0 : interfaceOptions.titleUsable) === "boolean") {
76
+ return interfaceOptions.titleUsable;
77
+ }
78
+ const interfaceName = typeof (field == null ? void 0 : field.interface) === "string" ? field.interface : typeof ((_c = field == null ? void 0 : field.options) == null ? void 0 : _c.interface) === "string" ? field.options.interface : void 0;
79
+ const interfaceCtor = ((_f = (_e = (_d = field == null ? void 0 : field.collection) == null ? void 0 : _d.collectionManager) == null ? void 0 : _e.getFieldInterface) == null ? void 0 : _f.call(_e, interfaceName)) || ((_j = (_i = (_h = (_g = field == null ? void 0 : field.collection) == null ? void 0 : _g.db) == null ? void 0 : _h.interfaceManager) == null ? void 0 : _i.getInterfaceType) == null ? void 0 : _j.call(_i, interfaceName));
80
+ if (interfaceCtor) {
81
+ const interfaceInstance = typeof interfaceCtor === "function" ? new interfaceCtor(void 0) : interfaceCtor;
82
+ if (typeof (interfaceInstance == null ? void 0 : interfaceInstance.titleUsable) === "boolean") {
83
+ return interfaceInstance.titleUsable;
84
+ }
85
+ }
86
+ return !!(interfaceName && FALLBACK_TITLE_USABLE_INTERFACES.has(interfaceName));
87
+ }
88
+ function getExplicitCollectionTitleFieldName(collection) {
89
+ var _a;
90
+ const explicit = (_a = collection == null ? void 0 : collection.options) == null ? void 0 : _a.titleField;
91
+ return typeof explicit === "string" ? explicit.trim() || void 0 : void 0;
92
+ }
93
+ function assertCollectionTitleFieldExists(collection, fieldName) {
94
+ const normalizedFieldName = typeof fieldName === "string" ? fieldName.trim() : String(fieldName || "").trim();
95
+ if (!normalizedFieldName) {
96
+ (0, import_errors.throwBadRequest)("flowSurfaces association titleField must be a non-empty string");
97
+ }
98
+ const field = (0, import_service_helpers.resolveFieldFromCollection)(collection, normalizedFieldName);
99
+ if (!field) {
100
+ (0, import_errors.throwBadRequest)(
101
+ `flowSurfaces collection '${(0, import_service_helpers.getCollectionName)(collection) || "unknown"}' titleField '${normalizedFieldName}' not found`
102
+ );
103
+ }
104
+ return field;
105
+ }
106
+ function resolveCollectionSafeTitleField(collection) {
107
+ if (!collection) {
108
+ return null;
109
+ }
110
+ const explicitTitleField = getExplicitCollectionTitleFieldName(collection);
111
+ if (explicitTitleField) {
112
+ const field = assertCollectionTitleFieldExists(collection, explicitTitleField);
113
+ return {
114
+ field,
115
+ fieldName: (0, import_service_helpers.getFieldName)(field) || explicitTitleField,
116
+ source: "explicit",
117
+ targetCollection: collection
118
+ };
119
+ }
120
+ const firstTitleableField = (0, import_service_helpers.getCollectionFields)(collection).find(
121
+ (field) => !!(0, import_service_helpers.getFieldName)(field) && isTitleableCollectionField(field)
122
+ );
123
+ if (!firstTitleableField) {
124
+ return null;
125
+ }
126
+ return {
127
+ field: firstTitleableField,
128
+ fieldName: (0, import_service_helpers.getFieldName)(firstTitleableField),
129
+ source: "firstTitleable",
130
+ targetCollection: collection
131
+ };
132
+ }
133
+ function resolveAssociationTitleFieldTargetCollection(field, dataSourceKey, getCollection) {
134
+ return (0, import_service_helpers.resolveFieldTargetCollection)(field, dataSourceKey, getCollection) || null;
135
+ }
136
+ function resolveAssociationSafeTitleField(field, dataSourceKey, getCollection) {
137
+ const targetCollection = resolveAssociationTitleFieldTargetCollection(field, dataSourceKey, getCollection);
138
+ if (!targetCollection) {
139
+ return null;
140
+ }
141
+ const resolved = resolveCollectionSafeTitleField(targetCollection);
142
+ if (!resolved) {
143
+ return null;
144
+ }
145
+ return {
146
+ ...resolved,
147
+ targetCollection
148
+ };
149
+ }
150
+ // Annotate the CommonJS export names for ESM import in node:
151
+ 0 && (module.exports = {
152
+ assertCollectionTitleFieldExists,
153
+ getExplicitCollectionTitleFieldName,
154
+ isTitleableCollectionField,
155
+ resolveAssociationSafeTitleField,
156
+ resolveAssociationTitleFieldTargetCollection,
157
+ resolveCollectionSafeTitleField
158
+ });
@@ -0,0 +1,14 @@
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 _ from 'lodash';
10
+ import type { FlowSurfaceApplyBlueprintDocument, FlowSurfaceApplyBlueprintLayout, FlowSurfaceApplyBlueprintTabDocument } from './public-types';
11
+ export declare function collectReferencedBlockKeys(layout: FlowSurfaceApplyBlueprintLayout | undefined, context: string): Set<string>;
12
+ export declare function compileTabComposeValues(tab: FlowSurfaceApplyBlueprintTabDocument, document: FlowSurfaceApplyBlueprintDocument, tabIndex: number, options: {
13
+ mode: 'append' | 'replace';
14
+ }): _.Dictionary<any>;