@nocobase/plugin-flow-engine 2.1.0-beta.15 → 2.1.0-beta.16
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.
- package/dist/ai/ai-employees/nathan/index.d.ts +10 -0
- package/dist/ai/ai-employees/nathan/index.js +41 -0
- package/dist/ai/ai-employees/nathan/prompt.md +132 -0
- package/dist/ai/ai-employees/nathan/skills/frontend-developer/SKILLS.md +69 -0
- package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextApis.js +2 -2
- package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextEnvs.js +2 -2
- package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextVars.js +2 -2
- package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/lintAndTestJS.js +2 -2
- package/dist/ai/docs/runjs/context/block-model.md +35 -35
- package/dist/ai/docs/runjs/context/collection-field.md +53 -51
- package/dist/ai/docs/runjs/context/collection.md +39 -39
- package/dist/ai/docs/runjs/context/data-source-manager.md +40 -30
- package/dist/ai/docs/runjs/context/data-source.md +52 -44
- package/dist/ai/docs/runjs/context/element.md +44 -38
- package/dist/ai/docs/runjs/context/exit-all.md +37 -35
- package/dist/ai/docs/runjs/context/exit.md +38 -35
- package/dist/ai/docs/runjs/context/filter-manager.md +36 -30
- package/dist/ai/docs/runjs/context/form.md +57 -57
- package/dist/ai/docs/runjs/context/get-model.md +22 -21
- package/dist/ai/docs/runjs/context/get-value.md +20 -19
- package/dist/ai/docs/runjs/context/get-var.md +61 -55
- package/dist/ai/docs/runjs/context/i18n.md +17 -14
- package/dist/ai/docs/runjs/context/import-async.md +333 -45
- package/dist/ai/docs/runjs/context/init-resource.md +20 -20
- package/dist/ai/docs/runjs/context/libs.md +31 -31
- package/dist/ai/docs/runjs/context/location.md +34 -31
- package/dist/ai/docs/runjs/context/logger.md +41 -40
- package/dist/ai/docs/runjs/context/make-resource.md +27 -26
- package/dist/ai/docs/runjs/context/message.md +42 -41
- package/dist/ai/docs/runjs/context/modal.md +44 -44
- package/dist/ai/docs/runjs/context/model.md +36 -33
- package/dist/ai/docs/runjs/context/notification.md +41 -40
- package/dist/ai/docs/runjs/context/off.md +14 -14
- package/dist/ai/docs/runjs/context/on.md +30 -29
- package/dist/ai/docs/runjs/context/open-view.md +40 -40
- package/dist/ai/docs/runjs/context/render.md +37 -32
- package/dist/ai/docs/runjs/context/request.md +46 -45
- package/dist/ai/docs/runjs/context/require-async.md +28 -25
- package/dist/ai/docs/runjs/context/resource.md +34 -34
- package/dist/ai/docs/runjs/context/route.md +36 -34
- package/dist/ai/docs/runjs/context/router.md +43 -31
- package/dist/ai/docs/runjs/context/set-value.md +18 -17
- package/dist/ai/docs/runjs/context/t.md +20 -17
- package/dist/ai/docs/runjs/context/view.md +49 -46
- package/dist/ai/docs/runjs/document.md +1 -0
- package/dist/ai/docs/runjs/import-modules.md +32 -32
- package/dist/ai/docs/runjs/index.md +13 -13
- package/dist/ai/docs/runjs/jsx.md +19 -19
- package/dist/ai/docs/runjs/model/form-block-model.md +1 -3
- package/dist/ai/docs/runjs/render.md +15 -15
- package/dist/ai/docs/runjs/resource/api-resource.md +53 -53
- package/dist/ai/docs/runjs/resource/multi-record-resource.md +64 -64
- package/dist/ai/docs/runjs/resource/single-record-resource.md +55 -55
- package/dist/ai/docs/runjs/resource/sql-resource.md +57 -57
- package/dist/ai/docs/runjs/window.md +5 -5
- package/dist/client/index.js +1 -1
- package/dist/externalVersion.js +11 -10
- package/dist/node_modules/ses/dist/ses.cjs +1 -1
- package/dist/node_modules/ses/package.json +1 -1
- package/dist/node_modules/zod/index.cjs +1 -1
- package/dist/node_modules/zod/package.json +1 -1
- package/dist/server/flow-surfaces/action-scope.d.ts +38 -0
- package/dist/server/flow-surfaces/action-scope.js +152 -0
- package/dist/server/flow-surfaces/apply/compiler.d.ts +13 -0
- package/dist/server/flow-surfaces/apply/compiler.js +969 -0
- package/dist/server/flow-surfaces/apply/layout.d.ts +34 -0
- package/dist/server/flow-surfaces/apply/layout.js +175 -0
- package/dist/server/flow-surfaces/apply/matching.d.ts +16 -0
- package/dist/server/flow-surfaces/apply/matching.js +181 -0
- package/dist/server/flow-surfaces/approval/blueprint-service.d.ts +84 -0
- package/dist/server/flow-surfaces/approval/blueprint-service.js +589 -0
- package/dist/server/flow-surfaces/approval/blueprint.d.ts +21 -0
- package/dist/server/flow-surfaces/approval/blueprint.js +187 -0
- package/dist/server/flow-surfaces/approval/builder.d.ts +225 -0
- package/dist/server/flow-surfaces/approval/builder.js +384 -0
- package/dist/server/flow-surfaces/approval/catalog-specs.d.ts +33 -0
- package/dist/server/flow-surfaces/approval/catalog-specs.js +156 -0
- package/dist/server/flow-surfaces/approval/index.d.ts +14 -0
- package/dist/server/flow-surfaces/approval/index.js +40 -0
- package/dist/server/flow-surfaces/approval/runtime-config.d.ts +44 -0
- package/dist/server/flow-surfaces/approval/runtime-config.js +299 -0
- package/dist/server/flow-surfaces/approval/semantic-use.d.ts +23 -0
- package/dist/server/flow-surfaces/approval/semantic-use.js +155 -0
- package/dist/server/flow-surfaces/association-title-field.d.ts +20 -0
- package/dist/server/flow-surfaces/association-title-field.js +158 -0
- package/dist/server/flow-surfaces/blueprint/compile-blocks.d.ts +14 -0
- package/dist/server/flow-surfaces/blueprint/compile-blocks.js +1007 -0
- package/dist/server/flow-surfaces/blueprint/compile-plan.d.ts +13 -0
- package/dist/server/flow-surfaces/blueprint/compile-plan.js +308 -0
- package/dist/server/flow-surfaces/blueprint/compile-reaction.d.ts +11 -0
- package/dist/server/flow-surfaces/blueprint/compile-reaction.js +72 -0
- package/dist/server/flow-surfaces/blueprint/defaults.d.ts +26 -0
- package/dist/server/flow-surfaces/blueprint/defaults.js +133 -0
- package/dist/server/flow-surfaces/blueprint/index.d.ts +12 -0
- package/dist/server/flow-surfaces/blueprint/index.js +44 -0
- package/dist/server/flow-surfaces/blueprint/normalize-document.d.ts +10 -0
- package/dist/server/flow-surfaces/blueprint/normalize-document.js +416 -0
- package/dist/server/flow-surfaces/blueprint/private-utils.d.ts +26 -0
- package/dist/server/flow-surfaces/blueprint/private-utils.js +182 -0
- package/dist/server/flow-surfaces/blueprint/public-types.d.ts +193 -0
- package/dist/server/flow-surfaces/blueprint/public-types.js +24 -0
- package/dist/server/flow-surfaces/builder.d.ts +211 -0
- package/dist/server/flow-surfaces/builder.js +1029 -0
- package/dist/server/flow-surfaces/catalog-smart.d.ts +18 -0
- package/dist/server/flow-surfaces/catalog-smart.js +239 -0
- package/dist/server/flow-surfaces/catalog-smart.projector.d.ts +15 -0
- package/dist/server/flow-surfaces/catalog-smart.projector.js +157 -0
- package/dist/server/flow-surfaces/catalog-smart.types.d.ts +99 -0
- package/dist/server/flow-surfaces/catalog-smart.types.js +24 -0
- package/dist/server/flow-surfaces/catalog.d.ts +78 -0
- package/dist/server/flow-surfaces/catalog.js +3496 -0
- package/dist/server/flow-surfaces/chart-config.d.ts +121 -0
- package/dist/server/flow-surfaces/chart-config.js +1394 -0
- package/dist/server/flow-surfaces/compose-compiler.d.ts +108 -0
- package/dist/server/flow-surfaces/compose-compiler.js +167 -0
- package/dist/server/flow-surfaces/compose-runtime.d.ts +93 -0
- package/dist/server/flow-surfaces/compose-runtime.js +375 -0
- package/dist/server/flow-surfaces/configure-options.d.ts +23 -0
- package/dist/server/flow-surfaces/configure-options.js +827 -0
- package/dist/server/flow-surfaces/constants.d.ts +351 -0
- package/dist/server/flow-surfaces/constants.js +104 -0
- package/dist/server/flow-surfaces/context.d.ts +72 -0
- package/dist/server/flow-surfaces/context.js +556 -0
- package/dist/server/flow-surfaces/contract-guard.d.ts +19 -0
- package/dist/server/flow-surfaces/contract-guard.js +402 -0
- package/dist/server/flow-surfaces/default-action-popup.d.ts +63 -0
- package/dist/server/flow-surfaces/default-action-popup.js +322 -0
- package/dist/server/flow-surfaces/default-block-actions.d.ts +32 -0
- package/dist/server/flow-surfaces/default-block-actions.js +185 -0
- package/dist/server/flow-surfaces/errors.d.ts +47 -0
- package/dist/server/flow-surfaces/errors.js +145 -0
- package/dist/server/flow-surfaces/executor.d.ts +23 -0
- package/dist/server/flow-surfaces/executor.js +132 -0
- package/dist/server/flow-surfaces/field-binding-registry.d.ts +23 -0
- package/dist/server/flow-surfaces/field-binding-registry.js +391 -0
- package/dist/server/flow-surfaces/field-semantics.d.ts +15 -0
- package/dist/server/flow-surfaces/field-semantics.js +81 -0
- package/dist/server/flow-surfaces/filter-group.d.ts +15 -0
- package/dist/server/flow-surfaces/filter-group.js +94 -0
- package/dist/server/flow-surfaces/index.d.ts +11 -0
- package/dist/server/flow-surfaces/index.js +243 -0
- package/dist/server/flow-surfaces/locator.d.ts +28 -0
- package/dist/server/flow-surfaces/locator.js +240 -0
- package/dist/server/flow-surfaces/node-use-sets.d.ts +15 -0
- package/dist/server/flow-surfaces/node-use-sets.js +131 -0
- package/dist/server/flow-surfaces/payload-shape.d.ts +9 -0
- package/dist/server/flow-surfaces/payload-shape.js +61 -0
- package/dist/server/flow-surfaces/placement.d.ts +33 -0
- package/dist/server/flow-surfaces/placement.js +195 -0
- package/dist/server/flow-surfaces/planning/action-specs.d.ts +179 -0
- package/dist/server/flow-surfaces/planning/action-specs.js +190 -0
- package/dist/server/flow-surfaces/planning/compiler.d.ts +37 -0
- package/dist/server/flow-surfaces/planning/compiler.js +376 -0
- package/dist/server/flow-surfaces/planning/context.d.ts +30 -0
- package/dist/server/flow-surfaces/planning/context.js +139 -0
- package/dist/server/flow-surfaces/planning/created-keys.d.ts +34 -0
- package/dist/server/flow-surfaces/planning/created-keys.js +375 -0
- package/dist/server/flow-surfaces/planning/key-kind.d.ts +11 -0
- package/dist/server/flow-surfaces/planning/key-kind.js +88 -0
- package/dist/server/flow-surfaces/planning/key-persistence.d.ts +34 -0
- package/dist/server/flow-surfaces/planning/key-persistence.js +148 -0
- package/dist/server/flow-surfaces/planning/key-registry.d.ts +40 -0
- package/dist/server/flow-surfaces/planning/key-registry.js +206 -0
- package/dist/server/flow-surfaces/planning/runtime.d.ts +37 -0
- package/dist/server/flow-surfaces/planning/runtime.js +259 -0
- package/dist/server/flow-surfaces/planning/step-link.d.ts +14 -0
- package/dist/server/flow-surfaces/planning/step-link.js +104 -0
- package/dist/server/flow-surfaces/planning/types.d.ts +55 -0
- package/dist/server/flow-surfaces/planning/types.js +24 -0
- package/dist/server/flow-surfaces/public-data-surface-default-filter.d.ts +20 -0
- package/dist/server/flow-surfaces/public-data-surface-default-filter.js +111 -0
- package/dist/server/flow-surfaces/reaction/errors.d.ts +20 -0
- package/dist/server/flow-surfaces/reaction/errors.js +69 -0
- package/dist/server/flow-surfaces/reaction/field-value.d.ts +34 -0
- package/dist/server/flow-surfaces/reaction/field-value.js +181 -0
- package/dist/server/flow-surfaces/reaction/fingerprint.d.ts +16 -0
- package/dist/server/flow-surfaces/reaction/fingerprint.js +71 -0
- package/dist/server/flow-surfaces/reaction/linkage.d.ts +136 -0
- package/dist/server/flow-surfaces/reaction/linkage.js +882 -0
- package/dist/server/flow-surfaces/reaction/meta.d.ts +11 -0
- package/dist/server/flow-surfaces/reaction/meta.js +451 -0
- package/dist/server/flow-surfaces/reaction/registry.d.ts +156 -0
- package/dist/server/flow-surfaces/reaction/registry.js +206 -0
- package/dist/server/flow-surfaces/reaction/resolver.d.ts +22 -0
- package/dist/server/flow-surfaces/reaction/resolver.js +202 -0
- package/dist/server/flow-surfaces/reaction/types.d.ts +241 -0
- package/dist/server/flow-surfaces/reaction/types.js +24 -0
- package/dist/server/flow-surfaces/reaction/utils.d.ts +17 -0
- package/dist/server/flow-surfaces/reaction/utils.js +67 -0
- package/dist/server/flow-surfaces/reaction/value-expr.d.ts +15 -0
- package/dist/server/flow-surfaces/reaction/value-expr.js +209 -0
- package/dist/server/flow-surfaces/reference-guards.d.ts +19 -0
- package/dist/server/flow-surfaces/reference-guards.js +103 -0
- package/dist/server/flow-surfaces/route-sync.d.ts +47 -0
- package/dist/server/flow-surfaces/route-sync.js +392 -0
- package/dist/server/flow-surfaces/service-helpers.d.ts +42 -0
- package/dist/server/flow-surfaces/service-helpers.js +377 -0
- package/dist/server/flow-surfaces/service-utils.d.ts +108 -0
- package/dist/server/flow-surfaces/service-utils.js +811 -0
- package/dist/server/flow-surfaces/service.d.ts +773 -0
- package/dist/server/flow-surfaces/service.js +13008 -0
- package/dist/server/flow-surfaces/support-matrix.d.ts +31 -0
- package/dist/server/flow-surfaces/support-matrix.js +259 -0
- package/dist/server/flow-surfaces/surface-context.d.ts +52 -0
- package/dist/server/flow-surfaces/surface-context.js +437 -0
- package/dist/server/flow-surfaces/template-compatibility.d.ts +42 -0
- package/dist/server/flow-surfaces/template-compatibility.js +189 -0
- package/dist/server/flow-surfaces/template-display.d.ts +20 -0
- package/dist/server/flow-surfaces/template-display.js +289 -0
- package/dist/server/flow-surfaces/template-service-utils.d.ts +62 -0
- package/dist/server/flow-surfaces/template-service-utils.js +281 -0
- package/dist/server/flow-surfaces/types.d.ts +288 -0
- package/dist/server/flow-surfaces/types.js +24 -0
- package/dist/server/plugin.js +2 -0
- package/dist/swagger/flow-surfaces.d.ts +5964 -0
- package/dist/swagger/flow-surfaces.examples.d.ts +1533 -0
- package/dist/swagger/flow-surfaces.examples.js +1758 -0
- package/dist/swagger/flow-surfaces.js +5315 -0
- package/dist/swagger/flow-surfaces.template-action-docs.d.ts +62 -0
- package/dist/swagger/flow-surfaces.template-action-docs.js +121 -0
- package/dist/swagger/flow-surfaces.template-schemas.d.ts +239 -0
- package/dist/swagger/flow-surfaces.template-schemas.js +255 -0
- package/dist/swagger/index.d.ts +5969 -0
- package/dist/swagger/index.js +50 -0
- package/package.json +2 -2
- /package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextApis.d.ts +0 -0
- /package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextEnvs.d.ts +0 -0
- /package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextVars.d.ts +0 -0
- /package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/lintAndTestJS.d.ts +0 -0
|
@@ -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
|
+
import type { Database } from '@nocobase/database';
|
|
10
|
+
import type { FlowSurfaceTemplateRow } from './template-service-utils';
|
|
11
|
+
export type TemplateTranslate = (key: string, options?: Record<string, any>) => string;
|
|
12
|
+
export declare function compileTemplateString(value: any, t?: TemplateTranslate): any;
|
|
13
|
+
export declare function resolveFlowTemplateDisplayRow(db: Database, row: FlowSurfaceTemplateRow, options?: {
|
|
14
|
+
t?: TemplateTranslate;
|
|
15
|
+
transaction?: any;
|
|
16
|
+
}): Promise<FlowSurfaceTemplateRow>;
|
|
17
|
+
export declare function resolveFlowTemplateDisplayRows(db: Database, rows: FlowSurfaceTemplateRow[], options?: {
|
|
18
|
+
t?: TemplateTranslate;
|
|
19
|
+
transaction?: any;
|
|
20
|
+
}): Promise<FlowSurfaceTemplateRow[]>;
|
|
@@ -0,0 +1,289 @@
|
|
|
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 template_display_exports = {};
|
|
38
|
+
__export(template_display_exports, {
|
|
39
|
+
compileTemplateString: () => compileTemplateString,
|
|
40
|
+
resolveFlowTemplateDisplayRow: () => resolveFlowTemplateDisplayRow,
|
|
41
|
+
resolveFlowTemplateDisplayRows: () => resolveFlowTemplateDisplayRows
|
|
42
|
+
});
|
|
43
|
+
module.exports = __toCommonJS(template_display_exports);
|
|
44
|
+
var import_json_schema = require("@formily/json-schema");
|
|
45
|
+
var import_lodash = __toESM(require("lodash"));
|
|
46
|
+
var import_service_helpers = require("./service-helpers");
|
|
47
|
+
var import_service_utils = require("./service-utils");
|
|
48
|
+
const AUTO_GENERATED_SUFFIX = " (Auto generated)";
|
|
49
|
+
const LEGACY_AUTO_POPUP_PREFIX = "Auto popup ";
|
|
50
|
+
const LEGACY_AUTO_POPUP_DESCRIPTION_PREFIX = "Auto-generated popup template ";
|
|
51
|
+
function getFallbackTranslate() {
|
|
52
|
+
return (key, options) => key.replace(/\{\{\s*([^}\s]+)\s*\}\}/g, (_match, name) => {
|
|
53
|
+
const value = options == null ? void 0 : options[name];
|
|
54
|
+
return import_lodash.default.isUndefined(value) || import_lodash.default.isNull(value) ? "" : String(value);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function extractTranslationKey(tokenContent) {
|
|
58
|
+
var _a;
|
|
59
|
+
const matched = tokenContent.match(/["'`]([^"'`]+)["'`]/);
|
|
60
|
+
return ((_a = matched == null ? void 0 : matched[1]) == null ? void 0 : _a.trim()) || "";
|
|
61
|
+
}
|
|
62
|
+
function sanitizePendingTranslationTokens(value) {
|
|
63
|
+
if (!value.includes("{{")) {
|
|
64
|
+
return value;
|
|
65
|
+
}
|
|
66
|
+
return value.replace(/\{\{\s*t\(([\s\S]*?)\)\s*\}\}/g, (_match, tokenContent) => extractTranslationKey(tokenContent));
|
|
67
|
+
}
|
|
68
|
+
function compileTemplateString(value, t) {
|
|
69
|
+
if (typeof value !== "string" || !value) {
|
|
70
|
+
return value;
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
const compiled = import_json_schema.Schema.compile(value, { t: t || getFallbackTranslate() });
|
|
74
|
+
if (typeof compiled === "string") {
|
|
75
|
+
return sanitizePendingTranslationTokens(compiled).trim();
|
|
76
|
+
}
|
|
77
|
+
return compiled;
|
|
78
|
+
} catch (error) {
|
|
79
|
+
return sanitizePendingTranslationTokens(value).trim();
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function inferPopupDefaultTypeFromTargetTree(node) {
|
|
83
|
+
var _a, _b, _c, _d;
|
|
84
|
+
const popupPage = (0, import_service_utils.getSingleNodeSubModel)((_a = node == null ? void 0 : node.subModels) == null ? void 0 : _a.page);
|
|
85
|
+
const popupTab = import_lodash.default.castArray(((_b = popupPage == null ? void 0 : popupPage.subModels) == null ? void 0 : _b.tabs) || [])[0];
|
|
86
|
+
const popupGrid = (0, import_service_utils.getSingleNodeSubModel)((_c = popupTab == null ? void 0 : popupTab.subModels) == null ? void 0 : _c.grid);
|
|
87
|
+
const popupBlock = (0, import_service_utils.getNodeSubModelList)((_d = popupGrid == null ? void 0 : popupGrid.subModels) == null ? void 0 : _d.items)[0];
|
|
88
|
+
if ((popupBlock == null ? void 0 : popupBlock.use) === "DetailsBlockModel") {
|
|
89
|
+
return "view";
|
|
90
|
+
}
|
|
91
|
+
if ((popupBlock == null ? void 0 : popupBlock.use) === "EditFormModel") {
|
|
92
|
+
return "edit";
|
|
93
|
+
}
|
|
94
|
+
if ((popupBlock == null ? void 0 : popupBlock.use) === "CreateFormModel") {
|
|
95
|
+
return "addNew";
|
|
96
|
+
}
|
|
97
|
+
return "generic";
|
|
98
|
+
}
|
|
99
|
+
function getPopupLabelKey(defaultType) {
|
|
100
|
+
switch (defaultType) {
|
|
101
|
+
case "addNew":
|
|
102
|
+
return "Popup for Add New";
|
|
103
|
+
case "edit":
|
|
104
|
+
return "Popup for Edit";
|
|
105
|
+
case "view":
|
|
106
|
+
return "Popup for Details";
|
|
107
|
+
default:
|
|
108
|
+
return "popup";
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function getAutoGeneratedDisplaySuffix(t) {
|
|
112
|
+
const translate = t || getFallbackTranslate();
|
|
113
|
+
return ` (${translate("Auto generated")})`;
|
|
114
|
+
}
|
|
115
|
+
function isAutoGeneratedPopupTemplateName(name) {
|
|
116
|
+
return name.endsWith(AUTO_GENERATED_SUFFIX) || name.startsWith(LEGACY_AUTO_POPUP_PREFIX);
|
|
117
|
+
}
|
|
118
|
+
function isAutoGeneratedPopupTemplateDescription(description) {
|
|
119
|
+
return description.startsWith(LEGACY_AUTO_POPUP_DESCRIPTION_PREFIX) || description.startsWith("Automatically generated popup template for ");
|
|
120
|
+
}
|
|
121
|
+
function buildAutoGeneratedActionPopupMetadata(input) {
|
|
122
|
+
const translate = input.t || getFallbackTranslate();
|
|
123
|
+
const popupLabel = translate(getPopupLabelKey(input.popupType));
|
|
124
|
+
return {
|
|
125
|
+
name: `${input.collectionLabel} ${popupLabel}${getAutoGeneratedDisplaySuffix(input.t)}`,
|
|
126
|
+
description: translate(
|
|
127
|
+
'Automatically generated popup template for collection "{{collectionLabel}}" ({{popupLabel}}).',
|
|
128
|
+
{
|
|
129
|
+
collectionLabel: input.collectionLabel,
|
|
130
|
+
popupLabel
|
|
131
|
+
}
|
|
132
|
+
)
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
function buildAutoGeneratedAssociationPopupMetadata(input) {
|
|
136
|
+
const translate = input.t || getFallbackTranslate();
|
|
137
|
+
const popupLabel = translate(getPopupLabelKey(input.popupType));
|
|
138
|
+
return {
|
|
139
|
+
name: `${input.sourceCollectionLabel} -> ${input.associationFieldLabel} ${popupLabel}${getAutoGeneratedDisplaySuffix(input.t)}`,
|
|
140
|
+
description: translate(
|
|
141
|
+
'Automatically generated popup template for relation field "{{associationFieldLabel}}" in collection "{{sourceCollectionLabel}}", targeting "{{targetCollectionLabel}}" ({{popupLabel}}).',
|
|
142
|
+
{
|
|
143
|
+
associationFieldLabel: input.associationFieldLabel,
|
|
144
|
+
sourceCollectionLabel: input.sourceCollectionLabel,
|
|
145
|
+
targetCollectionLabel: input.targetCollectionLabel,
|
|
146
|
+
popupLabel
|
|
147
|
+
}
|
|
148
|
+
)
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
async function getTargetTree(db, targetUid, transaction) {
|
|
152
|
+
var _a;
|
|
153
|
+
const normalizedTargetUid = String(targetUid || "").trim();
|
|
154
|
+
if (!normalizedTargetUid) {
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
const repo = (_a = db.getCollection("flowModels")) == null ? void 0 : _a.repository;
|
|
158
|
+
if (!repo) {
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
return repo.findModelById(normalizedTargetUid, {
|
|
162
|
+
transaction,
|
|
163
|
+
includeAsyncNode: true
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
function getCollection(db, dataSourceKey, collectionName) {
|
|
167
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
168
|
+
const normalizedDataSourceKey = dataSourceKey || "main";
|
|
169
|
+
const mainCollection = normalizedDataSourceKey === "main" ? (_a = db.getCollection) == null ? void 0 : _a.call(db, collectionName) : null;
|
|
170
|
+
if (mainCollection) {
|
|
171
|
+
return mainCollection;
|
|
172
|
+
}
|
|
173
|
+
const dataSourceManager = ((_b = db.app) == null ? void 0 : _b.dataSourceManager) || db.dataSourceManager;
|
|
174
|
+
const ds = ((_c = dataSourceManager == null ? void 0 : dataSourceManager.get) == null ? void 0 : _c.call(dataSourceManager, normalizedDataSourceKey)) || ((_e = (_d = dataSourceManager == null ? void 0 : dataSourceManager.dataSources) == null ? void 0 : _d.get) == null ? void 0 : _e.call(_d, normalizedDataSourceKey));
|
|
175
|
+
return ((_g = (_f = ds == null ? void 0 : ds.collectionManager) == null ? void 0 : _f.getCollection) == null ? void 0 : _g.call(_f, collectionName)) || ((_h = db.getCollection) == null ? void 0 : _h.call(db, collectionName));
|
|
176
|
+
}
|
|
177
|
+
function getAssociationField(collection, associationName) {
|
|
178
|
+
var _a;
|
|
179
|
+
const normalized = String(associationName || "").trim();
|
|
180
|
+
if (!normalized) {
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
const fieldName = normalized.split(".").slice(-1)[0];
|
|
184
|
+
return ((_a = collection == null ? void 0 : collection.getField) == null ? void 0 : _a.call(collection, fieldName)) || null;
|
|
185
|
+
}
|
|
186
|
+
function parseAssociationSource(associationName) {
|
|
187
|
+
const normalized = String(associationName || "").trim();
|
|
188
|
+
if (!normalized || !normalized.includes(".")) {
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
const parts = normalized.split(".").filter(Boolean);
|
|
192
|
+
if (parts.length < 2) {
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
return {
|
|
196
|
+
sourceCollectionName: parts[0],
|
|
197
|
+
associationFieldName: parts[parts.length - 1]
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
async function buildAutoGeneratedPopupMetadata(db, row, t, transaction) {
|
|
201
|
+
var _a, _b;
|
|
202
|
+
const targetTree = await getTargetTree(db, row.targetUid, transaction);
|
|
203
|
+
const popupType = inferPopupDefaultTypeFromTargetTree(targetTree);
|
|
204
|
+
const dataSourceKey = String(row.dataSourceKey || "main").trim() || "main";
|
|
205
|
+
const collectionName = String(row.collectionName || "").trim();
|
|
206
|
+
const associationName = String(row.associationName || "").trim();
|
|
207
|
+
const collection = getCollection(db, dataSourceKey, collectionName);
|
|
208
|
+
const collectionLabel = String(
|
|
209
|
+
compileTemplateString((0, import_service_helpers.getCollectionTitle)(collection) || collectionName, t) || ""
|
|
210
|
+
).trim();
|
|
211
|
+
if (associationName) {
|
|
212
|
+
const associationSource = parseAssociationSource(associationName);
|
|
213
|
+
const sourceCollectionName = (associationSource == null ? void 0 : associationSource.sourceCollectionName) || collectionName;
|
|
214
|
+
const sourceCollection = getCollection(db, dataSourceKey, sourceCollectionName) || collection;
|
|
215
|
+
const associationField = getAssociationField(sourceCollection, associationName) || ((_a = sourceCollection == null ? void 0 : sourceCollection.getField) == null ? void 0 : _a.call(sourceCollection, (associationSource == null ? void 0 : associationSource.associationFieldName) || ""));
|
|
216
|
+
const targetCollectionName = String((associationField == null ? void 0 : associationField.target) || ((_b = associationField == null ? void 0 : associationField.options) == null ? void 0 : _b.target) || collectionName || "").trim() || collectionName;
|
|
217
|
+
const targetCollection = getCollection(db, dataSourceKey, targetCollectionName) || collection;
|
|
218
|
+
const sourceCollectionLabel = String(
|
|
219
|
+
compileTemplateString(
|
|
220
|
+
(0, import_service_helpers.getCollectionTitle)(sourceCollection) || (0, import_service_helpers.getCollectionName)(sourceCollection) || sourceCollectionName,
|
|
221
|
+
t
|
|
222
|
+
) || ""
|
|
223
|
+
).trim();
|
|
224
|
+
const associationFieldLabel = String(
|
|
225
|
+
compileTemplateString(
|
|
226
|
+
(0, import_service_helpers.getFieldTitle)(associationField) || (0, import_service_helpers.getFieldName)(associationField) || (associationSource == null ? void 0 : associationSource.associationFieldName) || "",
|
|
227
|
+
t
|
|
228
|
+
) || ""
|
|
229
|
+
).trim();
|
|
230
|
+
const targetCollectionLabel = String(
|
|
231
|
+
compileTemplateString(
|
|
232
|
+
(0, import_service_helpers.getCollectionTitle)(targetCollection) || (0, import_service_helpers.getCollectionName)(targetCollection) || targetCollectionName,
|
|
233
|
+
t
|
|
234
|
+
) || ""
|
|
235
|
+
).trim();
|
|
236
|
+
if (sourceCollectionLabel && associationFieldLabel && targetCollectionLabel) {
|
|
237
|
+
return buildAutoGeneratedAssociationPopupMetadata({
|
|
238
|
+
popupType,
|
|
239
|
+
sourceCollectionLabel,
|
|
240
|
+
associationFieldLabel,
|
|
241
|
+
targetCollectionLabel,
|
|
242
|
+
t
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
if (collectionLabel) {
|
|
247
|
+
return buildAutoGeneratedActionPopupMetadata({
|
|
248
|
+
popupType,
|
|
249
|
+
collectionLabel,
|
|
250
|
+
t
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
return null;
|
|
254
|
+
}
|
|
255
|
+
async function resolveFlowTemplateDisplayRow(db, row, options = {}) {
|
|
256
|
+
const plainRow = typeof (row == null ? void 0 : row.toJSON) === "function" ? row.toJSON() : row;
|
|
257
|
+
if (!plainRow) {
|
|
258
|
+
return plainRow;
|
|
259
|
+
}
|
|
260
|
+
const t = options.t || getFallbackTranslate();
|
|
261
|
+
const nextRow = {
|
|
262
|
+
...plainRow,
|
|
263
|
+
name: compileTemplateString(plainRow.name, t),
|
|
264
|
+
description: compileTemplateString(plainRow.description, t)
|
|
265
|
+
};
|
|
266
|
+
const hasAutoGeneratedName = isAutoGeneratedPopupTemplateName(String(nextRow.name || "").trim());
|
|
267
|
+
const hasAutoGeneratedDescription = isAutoGeneratedPopupTemplateDescription(String(nextRow.description || "").trim());
|
|
268
|
+
if (String(nextRow.type || "").trim() !== "popup" || !hasAutoGeneratedName && !hasAutoGeneratedDescription) {
|
|
269
|
+
return nextRow;
|
|
270
|
+
}
|
|
271
|
+
const rewritten = await buildAutoGeneratedPopupMetadata(db, nextRow, t, options.transaction);
|
|
272
|
+
if (!rewritten) {
|
|
273
|
+
return nextRow;
|
|
274
|
+
}
|
|
275
|
+
return {
|
|
276
|
+
...nextRow,
|
|
277
|
+
name: hasAutoGeneratedName ? rewritten.name : nextRow.name,
|
|
278
|
+
description: hasAutoGeneratedDescription ? rewritten.description : nextRow.description
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
async function resolveFlowTemplateDisplayRows(db, rows, options = {}) {
|
|
282
|
+
return Promise.all(rows.map((row) => resolveFlowTemplateDisplayRow(db, row, options)));
|
|
283
|
+
}
|
|
284
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
285
|
+
0 && (module.exports = {
|
|
286
|
+
compileTemplateString,
|
|
287
|
+
resolveFlowTemplateDisplayRow,
|
|
288
|
+
resolveFlowTemplateDisplayRows
|
|
289
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
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 { FlowSurfaceWriteTarget } from './types';
|
|
11
|
+
export type FlowSurfaceTemplateRow = {
|
|
12
|
+
uid: string;
|
|
13
|
+
name?: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
targetUid?: string;
|
|
16
|
+
useModel?: string;
|
|
17
|
+
type?: string;
|
|
18
|
+
dataSourceKey?: string;
|
|
19
|
+
collectionName?: string;
|
|
20
|
+
associationName?: string;
|
|
21
|
+
filterByTk?: string;
|
|
22
|
+
sourceId?: string;
|
|
23
|
+
usageCount?: number;
|
|
24
|
+
available?: boolean;
|
|
25
|
+
disabledReason?: string;
|
|
26
|
+
};
|
|
27
|
+
export type FlowSurfaceTemplateListValues = {
|
|
28
|
+
search?: string;
|
|
29
|
+
filter?: Record<string, any>;
|
|
30
|
+
sort?: string | string[];
|
|
31
|
+
page?: number;
|
|
32
|
+
pageSize?: number;
|
|
33
|
+
target?: FlowSurfaceWriteTarget;
|
|
34
|
+
type?: 'block' | 'popup';
|
|
35
|
+
usage?: 'block' | 'fields';
|
|
36
|
+
actionType?: string;
|
|
37
|
+
actionScope?: 'block' | 'record';
|
|
38
|
+
};
|
|
39
|
+
export type FlowSurfaceTemplateListPopupActionContext = {
|
|
40
|
+
hasCurrentRecord?: boolean;
|
|
41
|
+
};
|
|
42
|
+
export declare const FLOW_TEMPLATE_SUPPORTED_TYPES: Set<string>;
|
|
43
|
+
export declare const FLOW_TEMPLATE_SUPPORTED_MODES: Set<string>;
|
|
44
|
+
export declare const FLOW_TEMPLATE_BLOCK_USAGES: Set<string>;
|
|
45
|
+
export declare const FLOW_TEMPLATE_UNSUPPORTED_BLOCK_TEMPLATE_SOURCE_USES: Set<string>;
|
|
46
|
+
export declare const POPUP_HOST_STEP_PARAM_PATHS: readonly [readonly ["popupSettings", "openView"], readonly ["selectExitRecordSettings", "openView"], readonly ["openSelectRecordView", "openView"], readonly ["openAddRecordView", "openView"]];
|
|
47
|
+
export declare function normalizeTemplateUidValue(actionName: string, values: Record<string, any>): string;
|
|
48
|
+
export declare function normalizeRequiredTemplateString(actionName: string, value: any, field: string): string;
|
|
49
|
+
export declare function normalizeTemplateSaveMode(actionName: string, value: any): "duplicate" | "convert";
|
|
50
|
+
export declare function buildTemplateListFilter(existingFilter: any, search: any, requestedType?: 'block' | 'popup'): any;
|
|
51
|
+
export declare function findFlowTemplateOpenViewStep(node: any): {
|
|
52
|
+
flowKey: "popupSettings" | "selectExitRecordSettings" | "openSelectRecordView" | "openAddRecordView";
|
|
53
|
+
stepKey: "openView";
|
|
54
|
+
openView: any;
|
|
55
|
+
};
|
|
56
|
+
export declare function buildFlowTemplateReferenceBlockStepParams(template: FlowSurfaceTemplateRow, templateTargetUid: string, resourceInit?: Record<string, any>): _.Dictionary<any>;
|
|
57
|
+
export declare function collectFlowTemplateUsageMapFromModelOptions(modelUid: string, options: any, carry?: Map<string, Set<string>>): Map<string, Set<string>>;
|
|
58
|
+
export declare function collectFlowTemplateModelUids(node: any, carry?: Set<string>): Set<string>;
|
|
59
|
+
export declare function replaceFlowModelTreeUids(node: any, uidMap: Record<string, string>): any;
|
|
60
|
+
export declare function stripTemplateInternalOpenViewFields(openView: any): any;
|
|
61
|
+
export declare function stripTemplateInternalReferenceSettings(node: any): void;
|
|
62
|
+
export declare function findFieldsTemplateReferenceGrid(node: any): import("./types").FlowSurfaceNodeSpec;
|
|
@@ -0,0 +1,281 @@
|
|
|
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 template_service_utils_exports = {};
|
|
38
|
+
__export(template_service_utils_exports, {
|
|
39
|
+
FLOW_TEMPLATE_BLOCK_USAGES: () => FLOW_TEMPLATE_BLOCK_USAGES,
|
|
40
|
+
FLOW_TEMPLATE_SUPPORTED_MODES: () => FLOW_TEMPLATE_SUPPORTED_MODES,
|
|
41
|
+
FLOW_TEMPLATE_SUPPORTED_TYPES: () => FLOW_TEMPLATE_SUPPORTED_TYPES,
|
|
42
|
+
FLOW_TEMPLATE_UNSUPPORTED_BLOCK_TEMPLATE_SOURCE_USES: () => FLOW_TEMPLATE_UNSUPPORTED_BLOCK_TEMPLATE_SOURCE_USES,
|
|
43
|
+
POPUP_HOST_STEP_PARAM_PATHS: () => POPUP_HOST_STEP_PARAM_PATHS,
|
|
44
|
+
buildFlowTemplateReferenceBlockStepParams: () => buildFlowTemplateReferenceBlockStepParams,
|
|
45
|
+
buildTemplateListFilter: () => buildTemplateListFilter,
|
|
46
|
+
collectFlowTemplateModelUids: () => collectFlowTemplateModelUids,
|
|
47
|
+
collectFlowTemplateUsageMapFromModelOptions: () => collectFlowTemplateUsageMapFromModelOptions,
|
|
48
|
+
findFieldsTemplateReferenceGrid: () => findFieldsTemplateReferenceGrid,
|
|
49
|
+
findFlowTemplateOpenViewStep: () => findFlowTemplateOpenViewStep,
|
|
50
|
+
normalizeRequiredTemplateString: () => normalizeRequiredTemplateString,
|
|
51
|
+
normalizeTemplateSaveMode: () => normalizeTemplateSaveMode,
|
|
52
|
+
normalizeTemplateUidValue: () => normalizeTemplateUidValue,
|
|
53
|
+
replaceFlowModelTreeUids: () => replaceFlowModelTreeUids,
|
|
54
|
+
stripTemplateInternalOpenViewFields: () => stripTemplateInternalOpenViewFields,
|
|
55
|
+
stripTemplateInternalReferenceSettings: () => stripTemplateInternalReferenceSettings
|
|
56
|
+
});
|
|
57
|
+
module.exports = __toCommonJS(template_service_utils_exports);
|
|
58
|
+
var import_lodash = __toESM(require("lodash"));
|
|
59
|
+
var import_service_helpers = require("./service-helpers");
|
|
60
|
+
var import_service_utils = require("./service-utils");
|
|
61
|
+
var import_errors = require("./errors");
|
|
62
|
+
const FLOW_TEMPLATE_SUPPORTED_TYPES = /* @__PURE__ */ new Set(["block", "popup"]);
|
|
63
|
+
const FLOW_TEMPLATE_SUPPORTED_MODES = /* @__PURE__ */ new Set(["reference", "copy"]);
|
|
64
|
+
const FLOW_TEMPLATE_BLOCK_USAGES = /* @__PURE__ */ new Set(["block", "fields"]);
|
|
65
|
+
const FLOW_TEMPLATE_UNSUPPORTED_BLOCK_TEMPLATE_SOURCE_USES = /* @__PURE__ */ new Set([
|
|
66
|
+
"ApplyTaskCardDetailsModel",
|
|
67
|
+
"ApprovalTaskCardDetailsModel"
|
|
68
|
+
]);
|
|
69
|
+
const POPUP_HOST_STEP_PARAM_PATHS = [
|
|
70
|
+
["popupSettings", "openView"],
|
|
71
|
+
["selectExitRecordSettings", "openView"],
|
|
72
|
+
["openSelectRecordView", "openView"],
|
|
73
|
+
["openAddRecordView", "openView"]
|
|
74
|
+
];
|
|
75
|
+
function normalizeTemplateUidValue(actionName, values) {
|
|
76
|
+
const templateUid = String((values == null ? void 0 : values.filterByTk) || (values == null ? void 0 : values.uid) || "").trim();
|
|
77
|
+
if (!templateUid) {
|
|
78
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces ${actionName} template uid is required`, "FLOW_SURFACE_TEMPLATE_UID_REQUIRED");
|
|
79
|
+
}
|
|
80
|
+
return templateUid;
|
|
81
|
+
}
|
|
82
|
+
function normalizeRequiredTemplateString(actionName, value, field) {
|
|
83
|
+
const normalized = String(value || "").trim();
|
|
84
|
+
if (!normalized) {
|
|
85
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces ${actionName} ${field} is required`, "FLOW_SURFACE_TEMPLATE_REQUIRED_FIELD");
|
|
86
|
+
}
|
|
87
|
+
return normalized;
|
|
88
|
+
}
|
|
89
|
+
function normalizeTemplateSaveMode(actionName, value) {
|
|
90
|
+
const normalized = String(value || "duplicate").trim() || "duplicate";
|
|
91
|
+
if (normalized !== "duplicate" && normalized !== "convert") {
|
|
92
|
+
(0, import_errors.throwBadRequest)(
|
|
93
|
+
`flowSurfaces ${actionName} saveMode only supports 'duplicate' or 'convert'`,
|
|
94
|
+
"FLOW_SURFACE_TEMPLATE_SAVE_MODE_UNSUPPORTED"
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
return normalized;
|
|
98
|
+
}
|
|
99
|
+
function buildTemplateListFilter(existingFilter, search, requestedType) {
|
|
100
|
+
const typeFilter = requestedType ? { type: requestedType } : void 0;
|
|
101
|
+
return (0, import_service_helpers.buildFlowTemplateSearchFilter)(
|
|
102
|
+
existingFilter && typeFilter ? { $and: [existingFilter, typeFilter] } : existingFilter || typeFilter,
|
|
103
|
+
search
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
function findFlowTemplateOpenViewStep(node) {
|
|
107
|
+
for (const [flowKey, stepKey] of POPUP_HOST_STEP_PARAM_PATHS) {
|
|
108
|
+
const openView = import_lodash.default.get(node, ["stepParams", flowKey, stepKey]);
|
|
109
|
+
if (import_lodash.default.isPlainObject(openView)) {
|
|
110
|
+
return {
|
|
111
|
+
flowKey,
|
|
112
|
+
stepKey,
|
|
113
|
+
openView
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
function buildFlowTemplateReferenceBlockStepParams(template, templateTargetUid, resourceInit) {
|
|
120
|
+
const normalizedResourceInit = (0, import_service_utils.buildDefinedPayload)(resourceInit || {});
|
|
121
|
+
return (0, import_service_utils.buildDefinedPayload)({
|
|
122
|
+
referenceSettings: {
|
|
123
|
+
target: {
|
|
124
|
+
targetUid: templateTargetUid,
|
|
125
|
+
mode: "reference"
|
|
126
|
+
},
|
|
127
|
+
useTemplate: {
|
|
128
|
+
templateUid: template.uid,
|
|
129
|
+
templateName: template.name,
|
|
130
|
+
templateDescription: template.description,
|
|
131
|
+
targetUid: templateTargetUid,
|
|
132
|
+
mode: "reference"
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
...Object.keys(normalizedResourceInit).length ? {
|
|
136
|
+
resourceSettings: {
|
|
137
|
+
init: normalizedResourceInit
|
|
138
|
+
}
|
|
139
|
+
} : {}
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
function collectFlowTemplateUsageMapFromModelOptions(modelUid, options, carry = /* @__PURE__ */ new Map()) {
|
|
143
|
+
const normalizedModelUid = String(modelUid || "").trim();
|
|
144
|
+
if (!normalizedModelUid) {
|
|
145
|
+
return carry;
|
|
146
|
+
}
|
|
147
|
+
const addUsage = (templateUid) => {
|
|
148
|
+
var _a;
|
|
149
|
+
const normalizedTemplateUid = String(templateUid || "").trim();
|
|
150
|
+
if (!normalizedTemplateUid) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
if (!carry.has(normalizedModelUid)) {
|
|
154
|
+
carry.set(normalizedModelUid, /* @__PURE__ */ new Set());
|
|
155
|
+
}
|
|
156
|
+
(_a = carry.get(normalizedModelUid)) == null ? void 0 : _a.add(normalizedTemplateUid);
|
|
157
|
+
};
|
|
158
|
+
const normalizedOptions = import_lodash.default.isPlainObject(options) || Array.isArray(options) ? options : typeof options === "string" ? JSON.parse(options) : {};
|
|
159
|
+
const useTemplate = import_lodash.default.get(normalizedOptions, ["stepParams", "referenceSettings", "useTemplate"]);
|
|
160
|
+
const useTemplateUid = String((useTemplate == null ? void 0 : useTemplate.templateUid) || "").trim();
|
|
161
|
+
const useTemplateMode = String((useTemplate == null ? void 0 : useTemplate.mode) || "reference").trim() || "reference";
|
|
162
|
+
if (useTemplateUid && useTemplateMode !== "copy") {
|
|
163
|
+
addUsage(useTemplateUid);
|
|
164
|
+
}
|
|
165
|
+
const popupGroups = [
|
|
166
|
+
import_lodash.default.get(normalizedOptions, ["stepParams", "popupSettings"]),
|
|
167
|
+
import_lodash.default.get(normalizedOptions, ["stepParams", "selectExitRecordSettings"])
|
|
168
|
+
];
|
|
169
|
+
for (const group of popupGroups) {
|
|
170
|
+
if (!group || typeof group !== "object") {
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
for (const value of Object.values(group)) {
|
|
174
|
+
const popupTemplateUid = String((value == null ? void 0 : value.popupTemplateUid) || "").trim();
|
|
175
|
+
const popupTemplateMode = String((value == null ? void 0 : value.popupTemplateMode) || "reference").trim() || "reference";
|
|
176
|
+
if (popupTemplateUid && popupTemplateMode !== "copy") {
|
|
177
|
+
addUsage(popupTemplateUid);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return carry;
|
|
182
|
+
}
|
|
183
|
+
function collectFlowTemplateModelUids(node, carry = /* @__PURE__ */ new Set()) {
|
|
184
|
+
if (!(node == null ? void 0 : node.uid)) {
|
|
185
|
+
return carry;
|
|
186
|
+
}
|
|
187
|
+
carry.add(String(node.uid));
|
|
188
|
+
for (const child of Object.values(node.subModels || {})) {
|
|
189
|
+
for (const item of import_lodash.default.castArray(child)) {
|
|
190
|
+
collectFlowTemplateModelUids(item, carry);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return carry;
|
|
194
|
+
}
|
|
195
|
+
function replaceFlowModelTreeUids(node, uidMap) {
|
|
196
|
+
const replaceInPlace = (value) => {
|
|
197
|
+
if (Array.isArray(value)) {
|
|
198
|
+
for (let i = 0; i < value.length; i += 1) {
|
|
199
|
+
value[i] = replaceInPlace(value[i]);
|
|
200
|
+
}
|
|
201
|
+
return value;
|
|
202
|
+
}
|
|
203
|
+
if (value && typeof value === "object") {
|
|
204
|
+
for (const key of Object.keys(value)) {
|
|
205
|
+
value[key] = replaceInPlace(value[key]);
|
|
206
|
+
}
|
|
207
|
+
return value;
|
|
208
|
+
}
|
|
209
|
+
return typeof value === "string" && uidMap[value] ? uidMap[value] : value;
|
|
210
|
+
};
|
|
211
|
+
const walk = (current) => {
|
|
212
|
+
if (!current || typeof current !== "object") {
|
|
213
|
+
return current;
|
|
214
|
+
}
|
|
215
|
+
if (typeof current.uid === "string" && uidMap[current.uid]) {
|
|
216
|
+
current.uid = uidMap[current.uid];
|
|
217
|
+
}
|
|
218
|
+
if (typeof current.parent === "string" && uidMap[current.parent]) {
|
|
219
|
+
current.parent = uidMap[current.parent];
|
|
220
|
+
}
|
|
221
|
+
if (typeof current.parentId === "string" && uidMap[current.parentId]) {
|
|
222
|
+
current.parentId = uidMap[current.parentId];
|
|
223
|
+
}
|
|
224
|
+
if (current.stepParams) {
|
|
225
|
+
current.stepParams = replaceInPlace(current.stepParams);
|
|
226
|
+
}
|
|
227
|
+
Object.values(current.subModels || {}).forEach((child) => {
|
|
228
|
+
import_lodash.default.castArray(child).forEach((item) => walk(item));
|
|
229
|
+
});
|
|
230
|
+
return current;
|
|
231
|
+
};
|
|
232
|
+
return walk(import_lodash.default.cloneDeep(node));
|
|
233
|
+
}
|
|
234
|
+
function stripTemplateInternalOpenViewFields(openView) {
|
|
235
|
+
if (!import_lodash.default.isPlainObject(openView)) {
|
|
236
|
+
return openView;
|
|
237
|
+
}
|
|
238
|
+
const hasTemplateState = !!String(openView.popupTemplateUid || "").trim() || !!openView.popupTemplateContext || !!String(openView.popupTemplateMode || "").trim();
|
|
239
|
+
return import_lodash.default.omit(openView, [
|
|
240
|
+
"popupTemplateUid",
|
|
241
|
+
"popupTemplateMode",
|
|
242
|
+
"popupTemplateContext",
|
|
243
|
+
"popupTemplateHasFilterByTk",
|
|
244
|
+
"popupTemplateHasSourceId",
|
|
245
|
+
...hasTemplateState ? ["uid"] : []
|
|
246
|
+
]);
|
|
247
|
+
}
|
|
248
|
+
function stripTemplateInternalReferenceSettings(node) {
|
|
249
|
+
var _a;
|
|
250
|
+
if (!import_lodash.default.isPlainObject((_a = node == null ? void 0 : node.stepParams) == null ? void 0 : _a.referenceSettings)) {
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
delete node.stepParams.referenceSettings;
|
|
254
|
+
if (import_lodash.default.isPlainObject(node.stepParams) && !Object.keys(node.stepParams).length) {
|
|
255
|
+
delete node.stepParams;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
function findFieldsTemplateReferenceGrid(node) {
|
|
259
|
+
var _a;
|
|
260
|
+
return (0, import_service_utils.getSingleNodeSubModel)((_a = node == null ? void 0 : node.subModels) == null ? void 0 : _a.grid);
|
|
261
|
+
}
|
|
262
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
263
|
+
0 && (module.exports = {
|
|
264
|
+
FLOW_TEMPLATE_BLOCK_USAGES,
|
|
265
|
+
FLOW_TEMPLATE_SUPPORTED_MODES,
|
|
266
|
+
FLOW_TEMPLATE_SUPPORTED_TYPES,
|
|
267
|
+
FLOW_TEMPLATE_UNSUPPORTED_BLOCK_TEMPLATE_SOURCE_USES,
|
|
268
|
+
POPUP_HOST_STEP_PARAM_PATHS,
|
|
269
|
+
buildFlowTemplateReferenceBlockStepParams,
|
|
270
|
+
buildTemplateListFilter,
|
|
271
|
+
collectFlowTemplateModelUids,
|
|
272
|
+
collectFlowTemplateUsageMapFromModelOptions,
|
|
273
|
+
findFieldsTemplateReferenceGrid,
|
|
274
|
+
findFlowTemplateOpenViewStep,
|
|
275
|
+
normalizeRequiredTemplateString,
|
|
276
|
+
normalizeTemplateSaveMode,
|
|
277
|
+
normalizeTemplateUidValue,
|
|
278
|
+
replaceFlowModelTreeUids,
|
|
279
|
+
stripTemplateInternalOpenViewFields,
|
|
280
|
+
stripTemplateInternalReferenceSettings
|
|
281
|
+
});
|