@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
@@ -0,0 +1,439 @@
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 navigation_targets_exports = {};
28
+ __export(navigation_targets_exports, {
29
+ DEFAULT_ADMIN_MULTI_PORTAL_UID: () => DEFAULT_ADMIN_MULTI_PORTAL_UID,
30
+ DEFAULT_ADMIN_UI_LAYOUT_UID: () => DEFAULT_ADMIN_UI_LAYOUT_UID,
31
+ DEFAULT_MOBILE_MULTI_PORTAL_UID: () => DEFAULT_MOBILE_MULTI_PORTAL_UID,
32
+ DEFAULT_MOBILE_UI_LAYOUT_UID: () => DEFAULT_MOBILE_UI_LAYOUT_UID,
33
+ FlowSurfaceNavigationTargetsService: () => FlowSurfaceNavigationTargetsService
34
+ });
35
+ module.exports = __toCommonJS(navigation_targets_exports);
36
+ var import_errors = require("./errors");
37
+ const DEFAULT_ADMIN_UI_LAYOUT_UID = "admin-layout-model";
38
+ const DEFAULT_MOBILE_UI_LAYOUT_UID = "mobile-layout-model";
39
+ const DEFAULT_ADMIN_MULTI_PORTAL_UID = "__default_admin__";
40
+ const DEFAULT_MOBILE_MULTI_PORTAL_UID = "__default_mobile__";
41
+ const RESERVED_MULTI_PORTAL_UIDS = /* @__PURE__ */ new Set([DEFAULT_ADMIN_MULTI_PORTAL_UID, DEFAULT_MOBILE_MULTI_PORTAL_UID]);
42
+ function readRecordField(record, field) {
43
+ if (!record || typeof record !== "object") {
44
+ return void 0;
45
+ }
46
+ const model = record;
47
+ if (typeof model.get === "function") {
48
+ return model.get(field);
49
+ }
50
+ return record[field];
51
+ }
52
+ function readStringField(record, field) {
53
+ const value = readRecordField(record, field);
54
+ return typeof value === "string" && value.trim() ? value.trim() : void 0;
55
+ }
56
+ function normalizeRoles(currentRoles) {
57
+ const roles = Array.isArray(currentRoles) ? currentRoles : typeof currentRoles === "string" ? [currentRoles] : [];
58
+ return roles.map((role) => String(role || "").trim()).filter(Boolean);
59
+ }
60
+ function normalizeRelationRouteId(routeId) {
61
+ return routeId === null || typeof routeId === "undefined" ? void 0 : routeId;
62
+ }
63
+ class FlowSurfaceNavigationTargetsService {
64
+ constructor(db) {
65
+ this.db = db;
66
+ }
67
+ hasMultiPortalCapability() {
68
+ var _a, _b;
69
+ try {
70
+ return !!this.db.getCollection("multiPortals") && !!((_b = (_a = this.db.getCollection("desktopRoutes")) == null ? void 0 : _a.getField) == null ? void 0 : _b.call(_a, "multiPortals"));
71
+ } catch (error) {
72
+ return false;
73
+ }
74
+ }
75
+ hasUiLayoutCapability() {
76
+ var _a, _b;
77
+ try {
78
+ return !!this.db.getCollection("uiLayouts") && !!((_b = (_a = this.db.getCollection("desktopRoutes")) == null ? void 0 : _a.getField) == null ? void 0 : _b.call(_a, "uiLayouts"));
79
+ } catch (error) {
80
+ return false;
81
+ }
82
+ }
83
+ normalizePortalUid(value) {
84
+ const portalUid = String(value || "").trim();
85
+ return portalUid || void 0;
86
+ }
87
+ async listNavigationTargets(currentRoles, transaction) {
88
+ const layoutTargets = await this.listLayoutTargets(transaction);
89
+ const multiPortal = this.hasMultiPortalCapability();
90
+ const portalTargets = multiPortal ? await this.listAccessiblePortalTargets(currentRoles, transaction) : [];
91
+ return {
92
+ version: "1",
93
+ capabilities: {
94
+ multiPortal
95
+ },
96
+ targets: [...layoutTargets, ...portalTargets]
97
+ };
98
+ }
99
+ async resolvePortal(portalUidValue, options) {
100
+ const portalUid = this.normalizePortalUid(portalUidValue);
101
+ if (!portalUid) {
102
+ (0, import_errors.throwBadRequest)(`flowSurfaces ${options.actionName} ${options.path} must be a non-empty string`, {
103
+ ruleId: "navigation-portal-invalid",
104
+ path: options.path
105
+ });
106
+ }
107
+ if (!this.hasMultiPortalCapability()) {
108
+ (0, import_errors.throwBadRequest)(`flowSurfaces ${options.actionName} ${options.path} requires the Multi-portal capability`, {
109
+ ruleId: "navigation-portal-unsupported",
110
+ path: options.path,
111
+ details: { portalUid }
112
+ });
113
+ }
114
+ if (RESERVED_MULTI_PORTAL_UIDS.has(portalUid)) {
115
+ (0, import_errors.throwBadRequest)(
116
+ `flowSurfaces ${options.actionName} ${options.path} cannot use reserved default portal uid '${portalUid}'; use layoutUid semantics instead`,
117
+ {
118
+ ruleId: "navigation-portal-reserved",
119
+ path: options.path,
120
+ details: { portalUid }
121
+ }
122
+ );
123
+ }
124
+ const portal = await this.db.getRepository("multiPortals").findOne({
125
+ filter: { uid: portalUid },
126
+ fields: ["uid", "title", "icon", "routeName", "routePath", "authCheck", "enabled", "uiLayoutUid"],
127
+ transaction: options.transaction
128
+ });
129
+ if (!portal) {
130
+ (0, import_errors.throwBadRequest)(`flowSurfaces ${options.actionName} ${options.path} references missing portal '${portalUid}'`, {
131
+ ruleId: "navigation-portal-not-found",
132
+ path: options.path,
133
+ details: { portalUid }
134
+ });
135
+ }
136
+ if (readRecordField(portal, "enabled") !== true) {
137
+ (0, import_errors.throwBadRequest)(`flowSurfaces ${options.actionName} portal '${portalUid}' is disabled`, {
138
+ ruleId: "navigation-portal-disabled",
139
+ path: options.path,
140
+ details: { portalUid }
141
+ });
142
+ }
143
+ const layoutUid = readStringField(portal, "uiLayoutUid");
144
+ if (!layoutUid || !this.db.getCollection("uiLayouts")) {
145
+ (0, import_errors.throwBadRequest)(`flowSurfaces ${options.actionName} portal '${portalUid}' has no available backing UI layout`, {
146
+ ruleId: "navigation-portal-layout-not-found",
147
+ path: options.path,
148
+ details: { portalUid, layoutUid: layoutUid || null }
149
+ });
150
+ }
151
+ const layout = await this.db.getRepository("uiLayouts").findOne({
152
+ filter: { uid: layoutUid },
153
+ fields: ["uid", "layoutType", "enabled"],
154
+ transaction: options.transaction
155
+ });
156
+ if (!layout) {
157
+ (0, import_errors.throwBadRequest)(
158
+ `flowSurfaces ${options.actionName} portal '${portalUid}' backing UI layout '${layoutUid}' does not exist`,
159
+ {
160
+ ruleId: "navigation-portal-layout-not-found",
161
+ path: options.path,
162
+ details: { portalUid, layoutUid }
163
+ }
164
+ );
165
+ }
166
+ if (readRecordField(layout, "enabled") !== true) {
167
+ (0, import_errors.throwBadRequest)(
168
+ `flowSurfaces ${options.actionName} portal '${portalUid}' backing UI layout '${layoutUid}' is disabled`,
169
+ {
170
+ ruleId: "navigation-portal-layout-disabled",
171
+ path: options.path,
172
+ details: { portalUid, layoutUid }
173
+ }
174
+ );
175
+ }
176
+ if (!await this.canAccessPortal(portalUid, options.currentRoles, options.transaction)) {
177
+ (0, import_errors.throwForbidden)(
178
+ `flowSurfaces ${options.actionName} current roles cannot access portal '${portalUid}'`,
179
+ "FLOW_SURFACE_NAVIGATION_PORTAL_FORBIDDEN",
180
+ {
181
+ ruleId: "navigation-portal-forbidden",
182
+ path: options.path,
183
+ details: { portalUid }
184
+ }
185
+ );
186
+ }
187
+ return {
188
+ uid: portalUid,
189
+ title: readStringField(portal, "title") || portalUid,
190
+ icon: readStringField(portal, "icon") || null,
191
+ routeName: readStringField(portal, "routeName"),
192
+ routePath: readStringField(portal, "routePath"),
193
+ authCheck: readRecordField(portal, "authCheck") === true,
194
+ enabled: true,
195
+ layoutUid,
196
+ layoutType: readStringField(layout, "layoutType")
197
+ };
198
+ }
199
+ async readRoutePortalUids(routeId, transaction) {
200
+ const relationRouteId = normalizeRelationRouteId(routeId);
201
+ if (typeof relationRouteId === "undefined" || !this.hasMultiPortalCapability()) {
202
+ return [];
203
+ }
204
+ const portals = await this.db.getRepository("desktopRoutes.multiPortals", relationRouteId).find({ fields: ["uid"], transaction });
205
+ return Array.from(
206
+ new Set(
207
+ portals.map((portal) => readStringField(portal, "uid")).filter((portalUid) => !!portalUid)
208
+ )
209
+ );
210
+ }
211
+ async assertRouteBelongsToPortal(actionName, routeId, portalUid, path, transaction) {
212
+ const routePortalUids = await this.readRoutePortalUids(routeId, transaction);
213
+ if (routePortalUids.includes(portalUid)) {
214
+ return;
215
+ }
216
+ (0, import_errors.throwBadRequest)(`flowSurfaces ${actionName} ${path} does not belong to portal '${portalUid}'`, {
217
+ ruleId: "navigation-route-portal-mismatch",
218
+ path,
219
+ details: {
220
+ routeId,
221
+ portalUid,
222
+ routePortalUids
223
+ }
224
+ });
225
+ }
226
+ async attachRouteTreeToPortals(routeId, portalUids, options) {
227
+ const normalizedPortalUids = Array.from(new Set(portalUids.map((uid) => String(uid || "").trim()).filter(Boolean)));
228
+ const relationRouteId = normalizeRelationRouteId(routeId);
229
+ if (typeof relationRouteId === "undefined" || !normalizedPortalUids.length || !this.hasMultiPortalCapability()) {
230
+ return;
231
+ }
232
+ const routeIds = await this.collectRouteTreeIds(relationRouteId, options.transaction);
233
+ for (const currentRouteId of routeIds) {
234
+ await this.db.getRepository("desktopRoutes.multiPortals", currentRouteId).set({ tk: normalizedPortalUids, transaction: options.transaction });
235
+ if (options.portalOnly && this.hasUiLayoutCapability()) {
236
+ await this.db.getRepository("desktopRoutes.uiLayouts", currentRouteId).set({ tk: [], transaction: options.transaction });
237
+ }
238
+ }
239
+ if (options.portalOnly) {
240
+ await this.removeDefaultLayoutRoutePermissions(routeIds, options.transaction);
241
+ }
242
+ for (const portalUid of normalizedPortalUids) {
243
+ await this.grantDefaultPortalRouteAccess(portalUid, routeIds, options.transaction);
244
+ }
245
+ }
246
+ async listLayoutTargets(transaction) {
247
+ const targets = [];
248
+ if (this.db.getCollection("uiLayouts")) {
249
+ const layouts = await this.db.getRepository("uiLayouts").find({
250
+ filter: { enabled: true },
251
+ fields: ["uid", "title", "layoutType", "routeName", "routePath", "authCheck"],
252
+ sort: ["uid"],
253
+ transaction
254
+ });
255
+ for (const layout of layouts) {
256
+ const layoutUid = readStringField(layout, "uid");
257
+ if (!layoutUid) {
258
+ continue;
259
+ }
260
+ targets.push({
261
+ kind: "layout",
262
+ uid: layoutUid,
263
+ title: readStringField(layout, "title") || layoutUid,
264
+ layoutUid,
265
+ layoutType: readStringField(layout, "layoutType"),
266
+ routeName: readStringField(layout, "routeName"),
267
+ routePath: readStringField(layout, "routePath"),
268
+ authCheck: readRecordField(layout, "authCheck") === true,
269
+ ...layoutUid === DEFAULT_ADMIN_UI_LAYOUT_UID ? { default: true } : {}
270
+ });
271
+ }
272
+ }
273
+ if (!targets.some((target) => target.uid === DEFAULT_ADMIN_UI_LAYOUT_UID)) {
274
+ targets.unshift({
275
+ kind: "layout",
276
+ uid: DEFAULT_ADMIN_UI_LAYOUT_UID,
277
+ title: "Admin",
278
+ layoutUid: DEFAULT_ADMIN_UI_LAYOUT_UID,
279
+ layoutType: "desktop",
280
+ routeName: "admin",
281
+ routePath: "/admin",
282
+ authCheck: true,
283
+ default: true
284
+ });
285
+ }
286
+ return targets.sort((left, right) => {
287
+ if (left.default) {
288
+ return -1;
289
+ }
290
+ if (right.default) {
291
+ return 1;
292
+ }
293
+ return left.uid.localeCompare(right.uid);
294
+ });
295
+ }
296
+ async listAccessiblePortalTargets(currentRoles, transaction) {
297
+ const roles = normalizeRoles(currentRoles);
298
+ let accessiblePortalUids;
299
+ if (!roles.includes("root")) {
300
+ if (!roles.length || !this.db.getCollection("rolesMultiPortals")) {
301
+ return [];
302
+ }
303
+ const grants = await this.db.getRepository("rolesMultiPortals").find({
304
+ fields: ["multiPortalUid"],
305
+ filter: { roleName: roles },
306
+ transaction
307
+ });
308
+ accessiblePortalUids = Array.from(
309
+ new Set(
310
+ grants.map((grant) => readStringField(grant, "multiPortalUid")).filter((portalUid) => !!portalUid)
311
+ )
312
+ );
313
+ if (!accessiblePortalUids.length) {
314
+ return [];
315
+ }
316
+ }
317
+ const accessiblePortalUidSet = accessiblePortalUids ? new Set(accessiblePortalUids) : void 0;
318
+ const filter = {
319
+ enabled: true,
320
+ "uid.$notIn": Array.from(RESERVED_MULTI_PORTAL_UIDS)
321
+ };
322
+ const portals = await this.db.getRepository("multiPortals").find({
323
+ filter,
324
+ fields: ["uid", "title", "icon", "routeName", "routePath", "authCheck", "enabled", "uiLayoutUid"],
325
+ sort: ["uid"],
326
+ transaction
327
+ });
328
+ const targets = [];
329
+ for (const portal of portals) {
330
+ const portalUid = readStringField(portal, "uid");
331
+ const layoutUid = readStringField(portal, "uiLayoutUid");
332
+ if (!portalUid || accessiblePortalUidSet && !accessiblePortalUidSet.has(portalUid) || !layoutUid || !this.db.getCollection("uiLayouts")) {
333
+ continue;
334
+ }
335
+ const layout = await this.db.getRepository("uiLayouts").findOne({
336
+ filter: { uid: layoutUid, enabled: true },
337
+ fields: ["layoutType"],
338
+ transaction
339
+ });
340
+ if (!layout) {
341
+ continue;
342
+ }
343
+ targets.push({
344
+ kind: "portal",
345
+ uid: portalUid,
346
+ portalUid,
347
+ title: readStringField(portal, "title") || portalUid,
348
+ icon: readStringField(portal, "icon") || null,
349
+ layoutUid,
350
+ layoutType: readStringField(layout, "layoutType"),
351
+ routeName: readStringField(portal, "routeName"),
352
+ routePath: readStringField(portal, "routePath"),
353
+ authCheck: readRecordField(portal, "authCheck") === true
354
+ });
355
+ }
356
+ return targets;
357
+ }
358
+ async canAccessPortal(portalUid, currentRoles, transaction) {
359
+ const roles = normalizeRoles(currentRoles);
360
+ if (roles.includes("root")) {
361
+ return true;
362
+ }
363
+ if (!roles.length || !this.db.getCollection("rolesMultiPortals")) {
364
+ return false;
365
+ }
366
+ const count = await this.db.getRepository("rolesMultiPortals").count({
367
+ filter: {
368
+ roleName: roles,
369
+ multiPortalUid: portalUid
370
+ },
371
+ transaction
372
+ });
373
+ return count > 0;
374
+ }
375
+ async collectRouteTreeIds(routeId, transaction) {
376
+ const routeIds = [routeId];
377
+ const children = await this.db.getRepository("desktopRoutes").find({
378
+ fields: ["id"],
379
+ filter: { parentId: routeId },
380
+ transaction
381
+ });
382
+ for (const child of children) {
383
+ const childId = normalizeRelationRouteId(readRecordField(child, "id"));
384
+ if (typeof childId !== "undefined") {
385
+ routeIds.push(...await this.collectRouteTreeIds(childId, transaction));
386
+ }
387
+ }
388
+ return routeIds;
389
+ }
390
+ async removeDefaultLayoutRoutePermissions(routeIds, transaction) {
391
+ if (!routeIds.length || !this.db.getCollection("rolesDesktopRoutes")) {
392
+ return;
393
+ }
394
+ await this.db.getRepository("rolesDesktopRoutes").destroy({
395
+ filter: { desktopRouteId: routeIds },
396
+ transaction
397
+ });
398
+ }
399
+ async grantDefaultPortalRouteAccess(portalUid, routeIds, transaction) {
400
+ if (!routeIds.length || !this.db.getCollection("rolesMultiPortalRoutePolicies") || !this.db.getCollection("rolesMultiPortalDesktopRoutes")) {
401
+ return;
402
+ }
403
+ const policies = await this.db.getRepository("rolesMultiPortalRoutePolicies").find({
404
+ fields: ["roleName"],
405
+ filter: {
406
+ multiPortalUid: portalUid,
407
+ allowNewMenu: true
408
+ },
409
+ transaction
410
+ });
411
+ const roleNames = Array.from(
412
+ new Set(
413
+ policies.map((policy) => readStringField(policy, "roleName")).filter((roleName) => !!roleName)
414
+ )
415
+ );
416
+ const repository = this.db.getRepository("rolesMultiPortalDesktopRoutes");
417
+ for (const roleName of roleNames) {
418
+ for (const desktopRouteId of routeIds) {
419
+ await repository.firstOrCreate({
420
+ filterKeys: ["roleName", "multiPortalUid", "desktopRouteId"],
421
+ values: {
422
+ roleName,
423
+ multiPortalUid: portalUid,
424
+ desktopRouteId
425
+ },
426
+ transaction
427
+ });
428
+ }
429
+ }
430
+ }
431
+ }
432
+ // Annotate the CommonJS export names for ESM import in node:
433
+ 0 && (module.exports = {
434
+ DEFAULT_ADMIN_MULTI_PORTAL_UID,
435
+ DEFAULT_ADMIN_UI_LAYOUT_UID,
436
+ DEFAULT_MOBILE_MULTI_PORTAL_UID,
437
+ DEFAULT_MOBILE_UI_LAYOUT_UID,
438
+ FlowSurfaceNavigationTargetsService
439
+ });
@@ -22,6 +22,7 @@ type CompilePlanStepDeps = NormalizePlanSelectorDeps & {
22
22
  resolveLocator: (target: FlowSurfaceReadLocator, options?: {
23
23
  transaction?: any;
24
24
  }) => Promise<FlowSurfaceResolvedTarget>;
25
+ loadResolvedSurfaceTree?: (resolved: FlowSurfaceResolvedTarget, transaction?: any) => Promise<any>;
25
26
  buildPlanKeyKind: (node: any, resolvedKind?: string) => string;
26
27
  };
27
28
  export declare function normalizePlanSelector(actionName: string, selector: any, deps: NormalizePlanSelectorDeps, fieldName?: string, options?: NormalizePlanSelectorOptions): FlowSurfacePlanSelector;