@nocobase/plugin-flow-engine 2.1.0-alpha.18 → 2.1.0-alpha.19

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 (56) hide show
  1. package/dist/externalVersion.js +11 -11
  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/action-scope.js +3 -1
  5. package/dist/server/flow-surfaces/apply/compiler.js +84 -5
  6. package/dist/server/flow-surfaces/approval/blueprint-service.d.ts +84 -0
  7. package/dist/server/flow-surfaces/approval/blueprint-service.js +589 -0
  8. package/dist/server/flow-surfaces/approval/blueprint.d.ts +21 -0
  9. package/dist/server/flow-surfaces/approval/blueprint.js +190 -0
  10. package/dist/server/flow-surfaces/approval/builder.d.ts +225 -0
  11. package/dist/server/flow-surfaces/approval/builder.js +384 -0
  12. package/dist/server/flow-surfaces/approval/catalog-specs.d.ts +33 -0
  13. package/dist/server/flow-surfaces/approval/catalog-specs.js +156 -0
  14. package/dist/server/flow-surfaces/approval/index.d.ts +14 -0
  15. package/dist/server/flow-surfaces/approval/index.js +40 -0
  16. package/dist/server/flow-surfaces/approval/runtime-config.d.ts +44 -0
  17. package/dist/server/flow-surfaces/approval/runtime-config.js +299 -0
  18. package/dist/server/flow-surfaces/approval/semantic-use.d.ts +23 -0
  19. package/dist/server/flow-surfaces/approval/semantic-use.js +155 -0
  20. package/dist/server/flow-surfaces/blueprint/compile-blocks.js +36 -2
  21. package/dist/server/flow-surfaces/blueprint/public-types.d.ts +7 -0
  22. package/dist/server/flow-surfaces/builder.d.ts +2 -0
  23. package/dist/server/flow-surfaces/builder.js +83 -10
  24. package/dist/server/flow-surfaces/catalog.d.ts +10 -0
  25. package/dist/server/flow-surfaces/catalog.js +368 -9
  26. package/dist/server/flow-surfaces/chart-config.d.ts +1 -1
  27. package/dist/server/flow-surfaces/compose-compiler.d.ts +1 -0
  28. package/dist/server/flow-surfaces/compose-compiler.js +2 -1
  29. package/dist/server/flow-surfaces/configure-options.js +61 -3
  30. package/dist/server/flow-surfaces/constants.d.ts +342 -5
  31. package/dist/server/flow-surfaces/constants.js +59 -125
  32. package/dist/server/flow-surfaces/default-action-popup.d.ts +1 -0
  33. package/dist/server/flow-surfaces/default-action-popup.js +6 -2
  34. package/dist/server/flow-surfaces/field-semantics.js +2 -1
  35. package/dist/server/flow-surfaces/index.js +21 -273
  36. package/dist/server/flow-surfaces/locator.js +8 -6
  37. package/dist/server/flow-surfaces/node-use-sets.js +15 -3
  38. package/dist/server/flow-surfaces/placement.js +11 -7
  39. package/dist/server/flow-surfaces/planning/action-specs.d.ts +1 -1
  40. package/dist/server/flow-surfaces/planning/compiler.d.ts +1 -1
  41. package/dist/server/flow-surfaces/planning/key-kind.js +7 -5
  42. package/dist/server/flow-surfaces/reaction/registry.d.ts +13 -0
  43. package/dist/server/flow-surfaces/reaction/registry.js +13 -0
  44. package/dist/server/flow-surfaces/service-utils.d.ts +10 -14
  45. package/dist/server/flow-surfaces/service-utils.js +4 -2
  46. package/dist/server/flow-surfaces/service.d.ts +63 -1
  47. package/dist/server/flow-surfaces/service.js +1058 -109
  48. package/dist/server/flow-surfaces/surface-context.d.ts +1 -0
  49. package/dist/server/flow-surfaces/surface-context.js +99 -19
  50. package/dist/server/flow-surfaces/types.d.ts +4 -1
  51. package/dist/swagger/flow-surfaces.d.ts +406 -2
  52. package/dist/swagger/flow-surfaces.examples.d.ts +164 -0
  53. package/dist/swagger/flow-surfaces.examples.js +184 -0
  54. package/dist/swagger/flow-surfaces.js +390 -76
  55. package/dist/swagger/index.d.ts +406 -2
  56. package/package.json +2 -2
@@ -19,6 +19,7 @@ export declare class FlowSurfaceContextResolver {
19
19
  ensurePopupSurface: (parentUid: string, transaction?: any) => Promise<any>;
20
20
  getCollection: (dataSourceKey: string, collectionName: string) => any;
21
21
  });
22
+ private resolveBlockCatalogContainerUse;
22
23
  filterBlocksByTarget(targetNode?: any, resolved?: any): import("./types").FlowSurfaceCatalogItem[];
23
24
  resolveFilterFormTarget(filterFormOwnerUid: string, targetBlockUid?: string, transaction?: any): Promise<{
24
25
  ownerUid: any;
@@ -43,6 +43,7 @@ var import_lodash = __toESM(require("lodash"));
43
43
  var import_catalog = require("./catalog");
44
44
  var import_chart_config = require("./chart-config");
45
45
  var import_errors = require("./errors");
46
+ var import_approval = require("./approval");
46
47
  var import_placement = require("./placement");
47
48
  const FILTER_TARGET_BLOCK_USES = /* @__PURE__ */ new Set([
48
49
  "TableBlockModel",
@@ -55,18 +56,51 @@ const FILTER_TARGET_BLOCK_USES = /* @__PURE__ */ new Set([
55
56
  ]);
56
57
  const LIST_LIKE_BLOCK_USES = /* @__PURE__ */ new Set(["ListBlockModel", "GridCardBlockModel"]);
57
58
  const LIST_LIKE_ITEM_USES = /* @__PURE__ */ new Set(["ListItemModel", "GridCardItemModel"]);
59
+ function getDefaultGridUse(ownerUse, fallbackUse) {
60
+ return (0, import_approval.getApprovalDefaultGridUse)(ownerUse) || fallbackUse;
61
+ }
62
+ function getFieldWrapperUse(containerUse, fallbackUse) {
63
+ return (0, import_approval.getApprovalFieldWrapperUse)(containerUse) || fallbackUse;
64
+ }
58
65
  class FlowSurfaceContextResolver {
59
66
  constructor(repository, locator, options) {
60
67
  this.repository = repository;
61
68
  this.locator = locator;
62
69
  this.options = options;
63
70
  }
71
+ resolveBlockCatalogContainerUse(targetNode, resolved) {
72
+ var _a, _b, _c, _d, _e, _f, _g;
73
+ if (!targetNode && !resolved) {
74
+ return void 0;
75
+ }
76
+ if ((_b = (_a = targetNode == null ? void 0 : targetNode.use) == null ? void 0 : _a.endsWith) == null ? void 0 : _b.call(_a, "GridModel")) {
77
+ return targetNode.use;
78
+ }
79
+ if ((_d = (_c = targetNode == null ? void 0 : targetNode.subModels) == null ? void 0 : _c.grid) == null ? void 0 : _d.use) {
80
+ return targetNode.subModels.grid.use;
81
+ }
82
+ const firstTab = import_lodash.default.castArray(((_e = targetNode == null ? void 0 : targetNode.subModels) == null ? void 0 : _e.tabs) || [])[0];
83
+ if ((_g = (_f = firstTab == null ? void 0 : firstTab.subModels) == null ? void 0 : _f.grid) == null ? void 0 : _g.use) {
84
+ return firstTab.subModels.grid.use;
85
+ }
86
+ const directDefaultGridUse = (0, import_approval.getApprovalDefaultGridUse)(targetNode == null ? void 0 : targetNode.use);
87
+ if (directDefaultGridUse) {
88
+ return directDefaultGridUse;
89
+ }
90
+ const firstTabDefaultGridUse = (0, import_approval.getApprovalDefaultGridUse)(firstTab == null ? void 0 : firstTab.use);
91
+ if (firstTabDefaultGridUse) {
92
+ return firstTabDefaultGridUse;
93
+ }
94
+ return void 0;
95
+ }
64
96
  filterBlocksByTarget(targetNode, resolved) {
97
+ const containerUse = this.resolveBlockCatalogContainerUse(targetNode, resolved);
98
+ const blocks = (0, import_catalog.getAvailableBlockCatalogItems)(containerUse);
65
99
  if (!targetNode && !resolved) {
66
- return import_catalog.blockCatalog;
100
+ return blocks;
67
101
  }
68
102
  if ((0, import_placement.canCatalogAddBlock)({ node: targetNode, resolved })) {
69
- return import_catalog.blockCatalog;
103
+ return blocks;
70
104
  }
71
105
  return [];
72
106
  }
@@ -115,32 +149,40 @@ class FlowSurfaceContextResolver {
115
149
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
116
150
  const resolved = await this.locator.resolve(target, { transaction });
117
151
  const node = resolved.node || await this.repository.findModelById(resolved.uid, { transaction, includeAsyncNode: true });
152
+ const normalizedUse = (0, import_approval.normalizeApprovalSemanticUse)(node == null ? void 0 : node.use);
118
153
  if ((_a = node == null ? void 0 : node.use) == null ? void 0 : _a.endsWith("GridModel")) {
154
+ if ((0, import_approval.isApprovalTaskCardGridUse)(node.use)) {
155
+ (0, import_errors.throwBadRequest)(`flowSurfaces addBlock target '${node.use}' does not support blocks`);
156
+ }
119
157
  return {
120
158
  parentUid: node.uid,
121
159
  subKey: "items",
122
160
  subType: "array"
123
161
  };
124
162
  }
125
- if ((node == null ? void 0 : node.use) === "ChildPageTabModel") {
163
+ if (normalizedUse === "ChildPageTabModel") {
126
164
  return {
127
- parentUid: ((_c = (_b = node == null ? void 0 : node.subModels) == null ? void 0 : _b.grid) == null ? void 0 : _c.uid) || await this.options.ensureGridChild(node.uid, "BlockGridModel", transaction),
165
+ parentUid: ((_c = (_b = node == null ? void 0 : node.subModels) == null ? void 0 : _b.grid) == null ? void 0 : _c.uid) || await this.options.ensureGridChild(node.uid, getDefaultGridUse(node.use, "BlockGridModel"), transaction),
128
166
  subKey: "items",
129
167
  subType: "array"
130
168
  };
131
169
  }
132
- if ((node == null ? void 0 : node.use) === "ChildPageModel") {
170
+ if (normalizedUse === "ChildPageModel") {
133
171
  const firstTab = import_lodash.default.castArray(((_d = node == null ? void 0 : node.subModels) == null ? void 0 : _d.tabs) || [])[0];
134
172
  if (!(firstTab == null ? void 0 : firstTab.uid)) {
135
173
  (0, import_errors.throwBadRequest)(`flowSurfaces addBlock target '${node.use}' is missing its popup tab subtree`);
136
174
  }
137
175
  return {
138
- parentUid: ((_f = (_e = firstTab == null ? void 0 : firstTab.subModels) == null ? void 0 : _e.grid) == null ? void 0 : _f.uid) || await this.options.ensureGridChild(firstTab.uid, "BlockGridModel", transaction),
176
+ parentUid: ((_f = (_e = firstTab == null ? void 0 : firstTab.subModels) == null ? void 0 : _e.grid) == null ? void 0 : _f.uid) || await this.options.ensureGridChild(
177
+ firstTab.uid,
178
+ getDefaultGridUse(firstTab.use, "BlockGridModel"),
179
+ transaction
180
+ ),
139
181
  subKey: "items",
140
182
  subType: "array"
141
183
  };
142
184
  }
143
- if ((0, import_placement.isPopupHostUse)(node == null ? void 0 : node.use) || ((_h = (_g = node == null ? void 0 : node.subModels) == null ? void 0 : _g.page) == null ? void 0 : _h.use) === "ChildPageModel") {
185
+ if ((0, import_placement.isPopupHostUse)(node == null ? void 0 : node.use) || (0, import_approval.normalizeApprovalSemanticUse)((_h = (_g = node == null ? void 0 : node.subModels) == null ? void 0 : _g.page) == null ? void 0 : _h.use) === "ChildPageModel") {
144
186
  const popupSurface = await this.options.ensurePopupSurface(node.uid, transaction);
145
187
  return {
146
188
  parentUid: popupSurface.gridUid,
@@ -153,7 +195,7 @@ class FlowSurfaceContextResolver {
153
195
  return {
154
196
  parentUid: ((_j = (_i = node == null ? void 0 : node.subModels) == null ? void 0 : _i.grid) == null ? void 0 : _j.uid) || await this.options.ensureGridChild(
155
197
  ((_l = (_k = resolved.tabRoute) == null ? void 0 : _k.get) == null ? void 0 : _l.call(_k, "schemaUid")) || node.uid,
156
- "BlockGridModel",
198
+ getDefaultGridUse(node == null ? void 0 : node.use, "BlockGridModel"),
157
199
  transaction
158
200
  ),
159
201
  subKey: "items",
@@ -181,17 +223,18 @@ class FlowSurfaceContextResolver {
181
223
  const target = await this.locator.resolve({ uid }, { transaction });
182
224
  const node = target.node || await this.repository.findModelById(uid, { transaction, includeAsyncNode: true });
183
225
  const use = node == null ? void 0 : node.use;
226
+ const normalizedUse = (0, import_approval.normalizeApprovalSemanticUse)(use);
184
227
  if ((0, import_placement.isFormBlockUse)(use)) {
185
228
  return {
186
229
  ownerUid: node.uid,
187
230
  ownerUse: use,
188
- parentUid: ((_b = (_a = node.subModels) == null ? void 0 : _a.grid) == null ? void 0 : _b.uid) || await this.options.ensureGridChild(node.uid, "FormGridModel", transaction),
231
+ parentUid: ((_b = (_a = node.subModels) == null ? void 0 : _a.grid) == null ? void 0 : _b.uid) || await this.options.ensureGridChild(node.uid, getDefaultGridUse(use, "FormGridModel"), transaction),
189
232
  subKey: "items",
190
233
  subType: "array",
191
- wrapperUse: "FormItemModel"
234
+ wrapperUse: getFieldWrapperUse(use, "FormItemModel")
192
235
  };
193
236
  }
194
- if (use === "FormGridModel") {
237
+ if (normalizedUse === "FormGridModel") {
195
238
  const parentUid = await this.locator.findParentUid(node.uid, transaction);
196
239
  const parent = parentUid ? await this.repository.findModelById(parentUid, { transaction }) : null;
197
240
  return {
@@ -200,17 +243,17 @@ class FlowSurfaceContextResolver {
200
243
  parentUid: node.uid,
201
244
  subKey: "items",
202
245
  subType: "array",
203
- wrapperUse: "FormItemModel"
246
+ wrapperUse: getFieldWrapperUse((parent == null ? void 0 : parent.use) || use, "FormItemModel")
204
247
  };
205
248
  }
206
249
  if ((0, import_placement.isDetailsBlockUse)(use)) {
207
250
  return {
208
251
  ownerUid: node.uid,
209
252
  ownerUse: use,
210
- parentUid: ((_d = (_c = node.subModels) == null ? void 0 : _c.grid) == null ? void 0 : _d.uid) || await this.options.ensureGridChild(node.uid, "DetailsGridModel", transaction),
253
+ parentUid: ((_d = (_c = node.subModels) == null ? void 0 : _c.grid) == null ? void 0 : _d.uid) || await this.options.ensureGridChild(node.uid, getDefaultGridUse(use, "DetailsGridModel"), transaction),
211
254
  subKey: "items",
212
255
  subType: "array",
213
- wrapperUse: "DetailsItemModel"
256
+ wrapperUse: getFieldWrapperUse(use, "DetailsItemModel")
214
257
  };
215
258
  }
216
259
  if (LIST_LIKE_BLOCK_USES.has(use)) {
@@ -237,7 +280,7 @@ class FlowSurfaceContextResolver {
237
280
  wrapperUse: "DetailsItemModel"
238
281
  };
239
282
  }
240
- if (use === "DetailsGridModel") {
283
+ if (normalizedUse === "DetailsGridModel") {
241
284
  const parentUid = await this.locator.findParentUid(node.uid, transaction);
242
285
  const parent = parentUid ? await this.repository.findModelById(parentUid, { transaction }) : null;
243
286
  return {
@@ -246,7 +289,7 @@ class FlowSurfaceContextResolver {
246
289
  parentUid: node.uid,
247
290
  subKey: "items",
248
291
  subType: "array",
249
- wrapperUse: "DetailsItemModel"
292
+ wrapperUse: getFieldWrapperUse((parent == null ? void 0 : parent.use) || use, "DetailsItemModel")
250
293
  };
251
294
  }
252
295
  if ((0, import_placement.isFilterFormBlockUse)(use)) {
@@ -317,9 +360,10 @@ class FlowSurfaceContextResolver {
317
360
  (0, import_errors.throwBadRequest)(`flowSurfaces addAction target '${(node == null ? void 0 : node.use) || resolved.uid}' is not an action container`);
318
361
  }
319
362
  async resolveGridNode(uid, transaction) {
320
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
363
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
321
364
  const resolved = await this.locator.resolve({ uid }, { transaction });
322
365
  const node = resolved.node || await this.repository.findModelById(uid, { transaction, includeAsyncNode: true });
366
+ const normalizedUse = (0, import_approval.normalizeApprovalSemanticUse)(node == null ? void 0 : node.use);
323
367
  if ((_a = node == null ? void 0 : node.use) == null ? void 0 : _a.endsWith("GridModel")) {
324
368
  return node;
325
369
  }
@@ -327,7 +371,7 @@ class FlowSurfaceContextResolver {
327
371
  return this.repository.findModelById(
328
372
  ((_g = (_f = node == null ? void 0 : node.subModels) == null ? void 0 : _f.grid) == null ? void 0 : _g.uid) || await this.options.ensureGridChild(
329
373
  ((_i = (_h = resolved.tabRoute) == null ? void 0 : _h.get) == null ? void 0 : _i.call(_h, "schemaUid")) || node.uid,
330
- "BlockGridModel",
374
+ getDefaultGridUse(node == null ? void 0 : node.use, "BlockGridModel"),
331
375
  transaction
332
376
  ),
333
377
  { transaction, includeAsyncNode: true }
@@ -336,13 +380,49 @@ class FlowSurfaceContextResolver {
336
380
  if ((_k = (_j = node == null ? void 0 : node.subModels) == null ? void 0 : _j.grid) == null ? void 0 : _k.uid) {
337
381
  return this.repository.findModelById(node.subModels.grid.uid, { transaction, includeAsyncNode: true });
338
382
  }
383
+ if (normalizedUse === "ChildPageTabModel") {
384
+ return this.repository.findModelById(
385
+ await this.options.ensureGridChild(node.uid, getDefaultGridUse(node == null ? void 0 : node.use, "BlockGridModel"), transaction),
386
+ { transaction, includeAsyncNode: true }
387
+ );
388
+ }
389
+ if (normalizedUse === "ChildPageModel") {
390
+ const firstTab = import_lodash.default.castArray(((_l = node == null ? void 0 : node.subModels) == null ? void 0 : _l.tabs) || [])[0];
391
+ if (!(firstTab == null ? void 0 : firstTab.uid)) {
392
+ (0, import_errors.throwBadRequest)(`flowSurfaces setLayout target '${uid}' is missing its popup tab subtree`);
393
+ }
394
+ const gridUid = ((_n = (_m = firstTab == null ? void 0 : firstTab.subModels) == null ? void 0 : _m.grid) == null ? void 0 : _n.uid) || await this.options.ensureGridChild(
395
+ firstTab.uid,
396
+ getDefaultGridUse(firstTab.use, "BlockGridModel"),
397
+ transaction
398
+ );
399
+ return this.repository.findModelById(gridUid, { transaction, includeAsyncNode: true });
400
+ }
401
+ if ((0, import_placement.isFormBlockUse)(node == null ? void 0 : node.use)) {
402
+ return this.repository.findModelById(
403
+ await this.options.ensureGridChild(node.uid, getDefaultGridUse(node == null ? void 0 : node.use, "FormGridModel"), transaction),
404
+ { transaction, includeAsyncNode: true }
405
+ );
406
+ }
407
+ if ((0, import_placement.isDetailsBlockUse)(node == null ? void 0 : node.use)) {
408
+ return this.repository.findModelById(
409
+ await this.options.ensureGridChild(node.uid, getDefaultGridUse(node == null ? void 0 : node.use, "DetailsGridModel"), transaction),
410
+ { transaction, includeAsyncNode: true }
411
+ );
412
+ }
413
+ if ((0, import_placement.isFilterFormBlockUse)(node == null ? void 0 : node.use)) {
414
+ return this.repository.findModelById(
415
+ await this.options.ensureGridChild(node.uid, "FilterFormGridModel", transaction),
416
+ { transaction, includeAsyncNode: true }
417
+ );
418
+ }
339
419
  (0, import_errors.throwBadRequest)(`flowSurfaces setLayout target '${uid}' is not a grid node`);
340
420
  }
341
421
  async findOwningBlockGrid(uid, transaction) {
342
422
  let cursor = uid;
343
423
  while (cursor) {
344
424
  const node = await this.repository.findModelById(cursor, { transaction, includeAsyncNode: true });
345
- if ((node == null ? void 0 : node.use) === "BlockGridModel") {
425
+ if ((0, import_approval.normalizeApprovalSemanticUse)(node == null ? void 0 : node.use) === "BlockGridModel") {
346
426
  return node;
347
427
  }
348
428
  cursor = await this.locator.findParentUid(cursor, transaction);
@@ -192,7 +192,9 @@ export type FlowSurfaceNodeSpec = {
192
192
  uid?: string;
193
193
  clientKey?: string;
194
194
  sortIndex?: number;
195
+ async?: boolean;
195
196
  use: string;
197
+ popup?: Record<string, any>;
196
198
  props?: Record<string, any>;
197
199
  decoratorProps?: Record<string, any>;
198
200
  stepParams?: Record<string, any>;
@@ -200,10 +202,11 @@ export type FlowSurfaceNodeSpec = {
200
202
  subModels?: Record<string, FlowSurfaceNodeSpec | FlowSurfaceNodeSpec[]>;
201
203
  };
202
204
  export type FlowSurfaceNodeSubModel = FlowSurfaceNodeSpec | FlowSurfaceNodeSpec[];
203
- export type FlowSurfaceNodeDefaults = Partial<Pick<FlowSurfaceNodeSpec, 'props' | 'decoratorProps' | 'stepParams' | 'flowRegistry' | 'subModels'>>;
205
+ export type FlowSurfaceNodeDefaults = Partial<Pick<FlowSurfaceNodeSpec, 'async' | 'props' | 'decoratorProps' | 'stepParams' | 'flowRegistry' | 'subModels'>>;
204
206
  export type FlowSurfaceApplyMode = 'replace';
205
207
  export type FlowSurfaceComposeMode = 'append' | 'replace';
206
208
  export type FlowSurfaceApplySpec = {
209
+ popup?: Record<string, any>;
207
210
  props?: Record<string, any>;
208
211
  decoratorProps?: Record<string, any>;
209
212
  stepParams?: Record<string, any>;