@nocobase/plugin-flow-engine 2.1.0-beta.14 → 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,416 @@
|
|
|
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 normalize_document_exports = {};
|
|
38
|
+
__export(normalize_document_exports, {
|
|
39
|
+
prepareFlowSurfaceApplyBlueprintDocument: () => prepareFlowSurfaceApplyBlueprintDocument
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(normalize_document_exports);
|
|
42
|
+
var import_lodash = __toESM(require("lodash"));
|
|
43
|
+
var import_errors = require("../errors");
|
|
44
|
+
var import_errors2 = require("../reaction/errors");
|
|
45
|
+
var import_service_utils = require("../service-utils");
|
|
46
|
+
var import_private_utils = require("./private-utils");
|
|
47
|
+
const APPLY_BLUEPRINT_REACTION_ITEM_ALLOWED_KEYS = ["type", "target", "rules", "expectedFingerprint"];
|
|
48
|
+
const APPLY_BLUEPRINT_REACTION_TYPES = [
|
|
49
|
+
"setFieldValueRules",
|
|
50
|
+
"setBlockLinkageRules",
|
|
51
|
+
"setFieldLinkageRules",
|
|
52
|
+
"setActionLinkageRules"
|
|
53
|
+
];
|
|
54
|
+
const APPLY_BLUEPRINT_REACTION_TYPE_SET = new Set(APPLY_BLUEPRINT_REACTION_TYPES);
|
|
55
|
+
const APPLY_BLUEPRINT_DEFAULT_COLLECTION_ALLOWED_KEYS = ["fieldGroups", "popups"];
|
|
56
|
+
const APPLY_BLUEPRINT_DEFAULT_FIELD_GROUP_ALLOWED_KEYS = ["key", "title", "fields"];
|
|
57
|
+
const APPLY_BLUEPRINT_DEFAULT_POPUPS_ALLOWED_KEYS = ["view", "addNew", "edit", "associations"];
|
|
58
|
+
const APPLY_BLUEPRINT_DEFAULT_POPUP_ACTION_ALLOWED_KEYS = ["name", "description"];
|
|
59
|
+
const APPLY_BLUEPRINT_DEFAULT_POPUP_ASSOCIATION_ALLOWED_KEYS = ["view", "addNew", "edit"];
|
|
60
|
+
const APPLY_BLUEPRINT_DEFAULT_POPUP_ACTIONS = ["view", "addNew", "edit"];
|
|
61
|
+
function assertSupportedApplyBlueprintTopLevelKeys(input) {
|
|
62
|
+
const allowedKeys = ["version", "mode", "target", "navigation", "page", "defaults", "assets", "tabs", "reaction"];
|
|
63
|
+
const unsupportedKeys = Object.keys(input).filter((key) => !allowedKeys.includes(key));
|
|
64
|
+
if (!unsupportedKeys.length) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
(0, import_errors.throwBadRequest)(
|
|
68
|
+
`flowSurfaces applyBlueprint only accepts top-level keys ${allowedKeys.join(
|
|
69
|
+
", "
|
|
70
|
+
)}; unsupported keys: ${unsupportedKeys.join(", ")}`
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
function assertSupportedApplyBlueprintTarget(input) {
|
|
74
|
+
if (import_lodash.default.isUndefined(input.target)) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
(0, import_private_utils.assertPlainObject)(input.target, "flowSurfaces applyBlueprint target");
|
|
78
|
+
if (import_lodash.default.isPlainObject(input.target) && typeof input.target.mode !== "undefined") {
|
|
79
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces applyBlueprint target only accepts pageSchemaUid; use top-level mode instead`);
|
|
80
|
+
}
|
|
81
|
+
(0, import_private_utils.assertOnlyAllowedKeys)(input.target, "flowSurfaces applyBlueprint target", ["pageSchemaUid"]);
|
|
82
|
+
}
|
|
83
|
+
function normalizePage(input) {
|
|
84
|
+
if (import_lodash.default.isUndefined(input)) {
|
|
85
|
+
return void 0;
|
|
86
|
+
}
|
|
87
|
+
(0, import_private_utils.assertPlainObject)(input, "flowSurfaces applyBlueprint page");
|
|
88
|
+
(0, import_private_utils.assertOnlyAllowedKeys)(input, "flowSurfaces applyBlueprint page", [
|
|
89
|
+
"title",
|
|
90
|
+
"icon",
|
|
91
|
+
"documentTitle",
|
|
92
|
+
"enableHeader",
|
|
93
|
+
"enableTabs",
|
|
94
|
+
"displayTitle"
|
|
95
|
+
]);
|
|
96
|
+
const normalized = (0, import_service_utils.buildDefinedPayload)({
|
|
97
|
+
title: (0, import_private_utils.readOptionalString)(input.title),
|
|
98
|
+
icon: (0, import_private_utils.readOptionalString)(input.icon),
|
|
99
|
+
documentTitle: (0, import_private_utils.readOptionalString)(input.documentTitle),
|
|
100
|
+
enableHeader: (0, import_private_utils.readBoolean)(input.enableHeader, "flowSurfaces applyBlueprint page.enableHeader"),
|
|
101
|
+
enableTabs: (0, import_private_utils.readBoolean)(input.enableTabs, "flowSurfaces applyBlueprint page.enableTabs"),
|
|
102
|
+
displayTitle: (0, import_private_utils.readBoolean)(input.displayTitle, "flowSurfaces applyBlueprint page.displayTitle")
|
|
103
|
+
});
|
|
104
|
+
return Object.keys(normalized).length ? normalized : void 0;
|
|
105
|
+
}
|
|
106
|
+
function normalizeNavigation(input) {
|
|
107
|
+
if (import_lodash.default.isUndefined(input)) {
|
|
108
|
+
return void 0;
|
|
109
|
+
}
|
|
110
|
+
(0, import_private_utils.assertPlainObject)(input, "flowSurfaces applyBlueprint navigation");
|
|
111
|
+
(0, import_private_utils.assertOnlyAllowedKeys)(input, "flowSurfaces applyBlueprint navigation", ["group", "item"]);
|
|
112
|
+
const normalized = (0, import_service_utils.buildDefinedPayload)({
|
|
113
|
+
group: import_lodash.default.isUndefined(input.group) ? void 0 : (() => {
|
|
114
|
+
(0, import_private_utils.assertPlainObject)(input.group, "flowSurfaces applyBlueprint navigation.group");
|
|
115
|
+
(0, import_private_utils.assertOnlyAllowedKeys)(input.group, "flowSurfaces applyBlueprint navigation.group", [
|
|
116
|
+
"routeId",
|
|
117
|
+
"title",
|
|
118
|
+
"icon",
|
|
119
|
+
"tooltip",
|
|
120
|
+
"hideInMenu"
|
|
121
|
+
]);
|
|
122
|
+
const routeId = input.group.routeId;
|
|
123
|
+
if (!import_lodash.default.isUndefined(routeId) && !import_lodash.default.isString(routeId) && !import_lodash.default.isNumber(routeId)) {
|
|
124
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces applyBlueprint navigation.group.routeId must be a string or integer`);
|
|
125
|
+
}
|
|
126
|
+
if (!import_lodash.default.isUndefined(routeId) && (0, import_private_utils.readString)(input.group.title)) {
|
|
127
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces applyBlueprint navigation.group cannot mix routeId with title`);
|
|
128
|
+
}
|
|
129
|
+
const routeMetadataKeys = import_private_utils.APPLY_BLUEPRINT_CREATE_MENU_GROUP_METADATA_KEYS.filter(
|
|
130
|
+
(key) => !import_lodash.default.isUndefined(input.group[key])
|
|
131
|
+
);
|
|
132
|
+
if (!import_lodash.default.isUndefined(routeId) && routeMetadataKeys.length) {
|
|
133
|
+
(0, import_errors.throwBadRequest)(
|
|
134
|
+
`flowSurfaces applyBlueprint navigation.group.routeId cannot mix with ${routeMetadataKeys.map((key) => `navigation.group.${key}`).join(
|
|
135
|
+
", "
|
|
136
|
+
)}; applyBlueprint create mode does not update existing menu-group metadata. Use flowSurfaces:updateMenu separately if needed`
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
const normalized2 = (0, import_service_utils.buildDefinedPayload)({
|
|
140
|
+
routeId: import_lodash.default.isUndefined(routeId) ? void 0 : routeId,
|
|
141
|
+
title: (0, import_private_utils.readOptionalString)(input.group.title),
|
|
142
|
+
icon: (0, import_private_utils.readOptionalString)(input.group.icon),
|
|
143
|
+
tooltip: (0, import_private_utils.readOptionalString)(input.group.tooltip),
|
|
144
|
+
hideInMenu: (0, import_private_utils.readBoolean)(input.group.hideInMenu, "flowSurfaces applyBlueprint navigation.group.hideInMenu")
|
|
145
|
+
});
|
|
146
|
+
if (import_lodash.default.isUndefined(normalized2.routeId) && !normalized2.title) {
|
|
147
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces applyBlueprint navigation.group requires routeId or title`);
|
|
148
|
+
}
|
|
149
|
+
return normalized2;
|
|
150
|
+
})(),
|
|
151
|
+
item: import_lodash.default.isUndefined(input.item) ? void 0 : (() => {
|
|
152
|
+
(0, import_private_utils.assertPlainObject)(input.item, "flowSurfaces applyBlueprint navigation.item");
|
|
153
|
+
(0, import_private_utils.assertOnlyAllowedKeys)(input.item, "flowSurfaces applyBlueprint navigation.item", [
|
|
154
|
+
"title",
|
|
155
|
+
"icon",
|
|
156
|
+
"tooltip",
|
|
157
|
+
"hideInMenu"
|
|
158
|
+
]);
|
|
159
|
+
return (0, import_service_utils.buildDefinedPayload)({
|
|
160
|
+
title: (0, import_private_utils.readOptionalString)(input.item.title),
|
|
161
|
+
icon: (0, import_private_utils.readOptionalString)(input.item.icon),
|
|
162
|
+
tooltip: (0, import_private_utils.readOptionalString)(input.item.tooltip),
|
|
163
|
+
hideInMenu: (0, import_private_utils.readBoolean)(input.item.hideInMenu, "flowSurfaces applyBlueprint navigation.item.hideInMenu")
|
|
164
|
+
});
|
|
165
|
+
})()
|
|
166
|
+
});
|
|
167
|
+
return Object.keys(normalized).length ? normalized : void 0;
|
|
168
|
+
}
|
|
169
|
+
function normalizeDefaultFieldGroups(input, context) {
|
|
170
|
+
if (import_lodash.default.isUndefined(input)) {
|
|
171
|
+
return void 0;
|
|
172
|
+
}
|
|
173
|
+
if (!Array.isArray(input) || !input.length) {
|
|
174
|
+
(0, import_errors.throwBadRequest)(`${context} must be a non-empty array`);
|
|
175
|
+
}
|
|
176
|
+
return input.map((group, groupIndex) => {
|
|
177
|
+
const groupContext = `${context}[${groupIndex}]`;
|
|
178
|
+
(0, import_private_utils.assertPlainObject)(group, groupContext);
|
|
179
|
+
(0, import_private_utils.assertOnlyAllowedKeys)(group, groupContext, APPLY_BLUEPRINT_DEFAULT_FIELD_GROUP_ALLOWED_KEYS);
|
|
180
|
+
if (!Array.isArray(group.fields) || !group.fields.length) {
|
|
181
|
+
(0, import_errors.throwBadRequest)(`${groupContext}.fields must be a non-empty array`);
|
|
182
|
+
}
|
|
183
|
+
return (0, import_service_utils.buildDefinedPayload)({
|
|
184
|
+
key: (0, import_private_utils.readOptionalString)(group.key),
|
|
185
|
+
title: (0, import_private_utils.assertNonEmptyString)(group.title, `${groupContext}.title`),
|
|
186
|
+
fields: group.fields.map(
|
|
187
|
+
(field, fieldIndex) => (0, import_private_utils.assertNonEmptyString)(field, `${groupContext}.fields[${fieldIndex}]`)
|
|
188
|
+
)
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
function normalizeDefaultPopupName(input, context) {
|
|
193
|
+
if (import_lodash.default.isUndefined(input)) {
|
|
194
|
+
return void 0;
|
|
195
|
+
}
|
|
196
|
+
(0, import_private_utils.assertPlainObject)(input, context);
|
|
197
|
+
(0, import_private_utils.assertOnlyAllowedKeys)(input, context, APPLY_BLUEPRINT_DEFAULT_POPUP_ACTION_ALLOWED_KEYS);
|
|
198
|
+
return {
|
|
199
|
+
name: (0, import_private_utils.assertNonEmptyString)(input.name, `${context}.name`),
|
|
200
|
+
description: (0, import_private_utils.assertNonEmptyString)(input.description, `${context}.description`)
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
function normalizeDefaultPopupActionMap(input, context, allowedKeys) {
|
|
204
|
+
if (import_lodash.default.isUndefined(input)) {
|
|
205
|
+
return void 0;
|
|
206
|
+
}
|
|
207
|
+
(0, import_private_utils.assertPlainObject)(input, context);
|
|
208
|
+
(0, import_private_utils.assertOnlyAllowedKeys)(input, context, [...allowedKeys]);
|
|
209
|
+
const normalized = (0, import_service_utils.buildDefinedPayload)(
|
|
210
|
+
Object.fromEntries(
|
|
211
|
+
APPLY_BLUEPRINT_DEFAULT_POPUP_ACTIONS.map((action) => [
|
|
212
|
+
action,
|
|
213
|
+
normalizeDefaultPopupName(input[action], `${context}.${action}`)
|
|
214
|
+
])
|
|
215
|
+
)
|
|
216
|
+
);
|
|
217
|
+
return Object.keys(normalized).length ? normalized : void 0;
|
|
218
|
+
}
|
|
219
|
+
function normalizeDefaultPopups(input, context) {
|
|
220
|
+
if (import_lodash.default.isUndefined(input)) {
|
|
221
|
+
return void 0;
|
|
222
|
+
}
|
|
223
|
+
const actionMap = normalizeDefaultPopupActionMap(input, context, APPLY_BLUEPRINT_DEFAULT_POPUPS_ALLOWED_KEYS);
|
|
224
|
+
const associationsInput = input.associations;
|
|
225
|
+
const associations = import_lodash.default.isUndefined(associationsInput) ? void 0 : (() => {
|
|
226
|
+
(0, import_private_utils.assertPlainObject)(associationsInput, `${context}.associations`);
|
|
227
|
+
return Object.fromEntries(
|
|
228
|
+
Object.entries(associationsInput).flatMap(([field, value]) => {
|
|
229
|
+
const associationField = (0, import_private_utils.assertNonEmptyString)(field, `${context}.associations key`);
|
|
230
|
+
const normalizedValue = normalizeDefaultPopupActionMap(
|
|
231
|
+
value,
|
|
232
|
+
`${context}.associations.${associationField}`,
|
|
233
|
+
APPLY_BLUEPRINT_DEFAULT_POPUP_ASSOCIATION_ALLOWED_KEYS
|
|
234
|
+
);
|
|
235
|
+
return normalizedValue ? [[associationField, normalizedValue]] : [];
|
|
236
|
+
})
|
|
237
|
+
);
|
|
238
|
+
})();
|
|
239
|
+
const normalized = (0, import_service_utils.buildDefinedPayload)({
|
|
240
|
+
...actionMap,
|
|
241
|
+
associations: associations && Object.keys(associations).length ? associations : void 0
|
|
242
|
+
});
|
|
243
|
+
return Object.keys(normalized).length ? normalized : void 0;
|
|
244
|
+
}
|
|
245
|
+
function normalizeDefaultCollection(input, context) {
|
|
246
|
+
(0, import_private_utils.assertPlainObject)(input, context);
|
|
247
|
+
(0, import_private_utils.assertOnlyAllowedKeys)(input, context, APPLY_BLUEPRINT_DEFAULT_COLLECTION_ALLOWED_KEYS);
|
|
248
|
+
return (0, import_service_utils.buildDefinedPayload)({
|
|
249
|
+
fieldGroups: normalizeDefaultFieldGroups(input.fieldGroups, `${context}.fieldGroups`),
|
|
250
|
+
popups: normalizeDefaultPopups(input.popups, `${context}.popups`)
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
function normalizeDefaults(input) {
|
|
254
|
+
if (import_lodash.default.isUndefined(input)) {
|
|
255
|
+
return void 0;
|
|
256
|
+
}
|
|
257
|
+
(0, import_private_utils.assertPlainObject)(input, "flowSurfaces applyBlueprint defaults");
|
|
258
|
+
(0, import_private_utils.assertOnlyAllowedKeys)(input, "flowSurfaces applyBlueprint defaults", ["collections"]);
|
|
259
|
+
if (import_lodash.default.isUndefined(input.collections)) {
|
|
260
|
+
return {};
|
|
261
|
+
}
|
|
262
|
+
(0, import_private_utils.assertPlainObject)(input.collections, "flowSurfaces applyBlueprint defaults.collections");
|
|
263
|
+
return {
|
|
264
|
+
collections: Object.fromEntries(
|
|
265
|
+
Object.entries(input.collections).map(([collectionName, collectionDefaults]) => {
|
|
266
|
+
const normalizedCollectionName = (0, import_private_utils.assertNonEmptyString)(
|
|
267
|
+
collectionName,
|
|
268
|
+
"flowSurfaces applyBlueprint defaults.collections key"
|
|
269
|
+
);
|
|
270
|
+
return [
|
|
271
|
+
normalizedCollectionName,
|
|
272
|
+
normalizeDefaultCollection(
|
|
273
|
+
collectionDefaults,
|
|
274
|
+
`flowSurfaces applyBlueprint defaults.collections.${normalizedCollectionName}`
|
|
275
|
+
)
|
|
276
|
+
];
|
|
277
|
+
})
|
|
278
|
+
)
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
function normalizeTabs(input) {
|
|
282
|
+
const seenTabKeys = /* @__PURE__ */ new Set();
|
|
283
|
+
return input.map((tab, index) => {
|
|
284
|
+
(0, import_private_utils.assertPlainObject)(tab, `flowSurfaces applyBlueprint tabs[${index}]`);
|
|
285
|
+
(0, import_private_utils.assertOnlyAllowedKeys)(tab, `flowSurfaces applyBlueprint tabs[${index}]`, [
|
|
286
|
+
"key",
|
|
287
|
+
"title",
|
|
288
|
+
"icon",
|
|
289
|
+
"documentTitle",
|
|
290
|
+
"blocks",
|
|
291
|
+
"layout"
|
|
292
|
+
]);
|
|
293
|
+
if (!Array.isArray(tab.blocks) || !tab.blocks.length) {
|
|
294
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces applyBlueprint tabs[${index}].blocks must be a non-empty array`);
|
|
295
|
+
}
|
|
296
|
+
const explicitKey = (0, import_private_utils.readString)(tab.key);
|
|
297
|
+
return {
|
|
298
|
+
key: (0, import_private_utils.normalizeTabLocalKey)(tab.key, (0, import_private_utils.readString)(tab.title) || `tab_${index + 1}`, index, seenTabKeys, {
|
|
299
|
+
explicit: !!explicitKey
|
|
300
|
+
}),
|
|
301
|
+
title: (0, import_private_utils.readOptionalString)(tab.title),
|
|
302
|
+
icon: (0, import_private_utils.readOptionalString)(tab.icon),
|
|
303
|
+
documentTitle: (0, import_private_utils.readOptionalString)(tab.documentTitle),
|
|
304
|
+
blocks: import_lodash.default.cloneDeep(tab.blocks),
|
|
305
|
+
layout: (0, import_private_utils.cloneOptionalPlainObject)(tab.layout, `flowSurfaces applyBlueprint tabs[${index}].layout`)
|
|
306
|
+
};
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
function normalizeReaction(input) {
|
|
310
|
+
if (import_lodash.default.isUndefined(input)) {
|
|
311
|
+
return void 0;
|
|
312
|
+
}
|
|
313
|
+
(0, import_private_utils.assertPlainObject)(input, "flowSurfaces applyBlueprint reaction");
|
|
314
|
+
(0, import_private_utils.assertOnlyAllowedKeys)(input, "flowSurfaces applyBlueprint reaction", ["items"]);
|
|
315
|
+
if (!Array.isArray(input.items)) {
|
|
316
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces applyBlueprint reaction.items must be an array`);
|
|
317
|
+
}
|
|
318
|
+
const seenSlots = /* @__PURE__ */ new Set();
|
|
319
|
+
return {
|
|
320
|
+
items: input.items.map((item, index) => {
|
|
321
|
+
const context = `flowSurfaces applyBlueprint reaction.items[${index}]`;
|
|
322
|
+
(0, import_private_utils.assertPlainObject)(item, context);
|
|
323
|
+
(0, import_private_utils.assertOnlyAllowedKeys)(item, context, [...APPLY_BLUEPRINT_REACTION_ITEM_ALLOWED_KEYS]);
|
|
324
|
+
const type = (0, import_private_utils.assertNonEmptyString)(item.type, `${context}.type`);
|
|
325
|
+
if (!APPLY_BLUEPRINT_REACTION_TYPE_SET.has(type)) {
|
|
326
|
+
(0, import_errors.throwBadRequest)(
|
|
327
|
+
`${context}.type '${type}' is unsupported; supported types: ${APPLY_BLUEPRINT_REACTION_TYPES.join(", ")}`
|
|
328
|
+
);
|
|
329
|
+
}
|
|
330
|
+
const target = (0, import_service_utils.normalizeFlowSurfaceComposeKey)(
|
|
331
|
+
(0, import_private_utils.assertNonEmptyString)(item.target, `${context}.target`),
|
|
332
|
+
`${context}.target`
|
|
333
|
+
);
|
|
334
|
+
if (!Array.isArray(item.rules)) {
|
|
335
|
+
(0, import_errors.throwBadRequest)(`${context}.rules must be an array`);
|
|
336
|
+
}
|
|
337
|
+
const slotKey = `${type}::${target}`;
|
|
338
|
+
if (seenSlots.has(slotKey)) {
|
|
339
|
+
(0, import_errors.throwBadRequest)(
|
|
340
|
+
`${context} duplicates reaction slot '${type}' for target '${target}'`,
|
|
341
|
+
import_errors2.FLOW_SURFACE_REACTION_DUPLICATE_SLOT
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
seenSlots.add(slotKey);
|
|
345
|
+
return (0, import_service_utils.buildDefinedPayload)({
|
|
346
|
+
type,
|
|
347
|
+
target,
|
|
348
|
+
rules: import_lodash.default.cloneDeep(item.rules),
|
|
349
|
+
expectedFingerprint: import_lodash.default.isUndefined(item.expectedFingerprint) ? void 0 : (0, import_private_utils.assertNonEmptyString)(item.expectedFingerprint, `${context}.expectedFingerprint`)
|
|
350
|
+
});
|
|
351
|
+
})
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
function prepareFlowSurfaceApplyBlueprintDocument(input) {
|
|
355
|
+
var _a, _b;
|
|
356
|
+
(0, import_private_utils.assertPlainObject)(input, "flowSurfaces applyBlueprint payload");
|
|
357
|
+
assertSupportedApplyBlueprintTopLevelKeys(input);
|
|
358
|
+
assertSupportedApplyBlueprintTarget(input);
|
|
359
|
+
const version = import_lodash.default.isUndefined(input.version) ? "1" : (0, import_private_utils.assertNonEmptyString)(input.version, "flowSurfaces applyBlueprint version");
|
|
360
|
+
if (version !== "1") {
|
|
361
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces applyBlueprint version '${version}' is not supported`);
|
|
362
|
+
}
|
|
363
|
+
const mode = (0, import_private_utils.assertNonEmptyString)(input.mode, "flowSurfaces applyBlueprint mode");
|
|
364
|
+
if (mode !== "create" && mode !== "replace") {
|
|
365
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces applyBlueprint mode must be 'create' or 'replace'`);
|
|
366
|
+
}
|
|
367
|
+
if (!Array.isArray(input.tabs) || !input.tabs.length) {
|
|
368
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces applyBlueprint tabs must be a non-empty array`);
|
|
369
|
+
}
|
|
370
|
+
const page = normalizePage(input.page);
|
|
371
|
+
const navigation = normalizeNavigation(input.navigation);
|
|
372
|
+
const defaults = normalizeDefaults(input.defaults);
|
|
373
|
+
if (mode === "create" && !import_lodash.default.isUndefined(input.target)) {
|
|
374
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces applyBlueprint create mode does not accept target`);
|
|
375
|
+
}
|
|
376
|
+
if (mode === "replace" && !import_lodash.default.isPlainObject(input.target)) {
|
|
377
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces applyBlueprint replace mode requires target.pageSchemaUid`);
|
|
378
|
+
}
|
|
379
|
+
if (mode === "replace" && navigation) {
|
|
380
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces applyBlueprint replace mode does not accept navigation`);
|
|
381
|
+
}
|
|
382
|
+
const target = mode === "replace" ? {
|
|
383
|
+
pageSchemaUid: (0, import_private_utils.assertNonEmptyString)(
|
|
384
|
+
input.target.pageSchemaUid,
|
|
385
|
+
"flowSurfaces applyBlueprint target.pageSchemaUid"
|
|
386
|
+
)
|
|
387
|
+
} : void 0;
|
|
388
|
+
if (!import_lodash.default.isUndefined(input.assets)) {
|
|
389
|
+
(0, import_private_utils.assertPlainObject)(input.assets, "flowSurfaces applyBlueprint assets");
|
|
390
|
+
(0, import_private_utils.assertOnlyAllowedKeys)(input.assets, "flowSurfaces applyBlueprint assets", ["scripts", "charts"]);
|
|
391
|
+
}
|
|
392
|
+
const assets = {
|
|
393
|
+
scripts: (0, import_private_utils.normalizeAssetRegistry)((_a = input.assets) == null ? void 0 : _a.scripts, "flowSurfaces applyBlueprint assets.scripts"),
|
|
394
|
+
charts: (0, import_private_utils.normalizeAssetRegistry)((_b = input.assets) == null ? void 0 : _b.charts, "flowSurfaces applyBlueprint assets.charts")
|
|
395
|
+
};
|
|
396
|
+
const tabs = normalizeTabs(input.tabs);
|
|
397
|
+
const reaction = normalizeReaction(input.reaction);
|
|
398
|
+
if (tabs.length > 1 && (page == null ? void 0 : page.enableTabs) === false) {
|
|
399
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces applyBlueprint page.enableTabs cannot be false when tabs.length > 1`);
|
|
400
|
+
}
|
|
401
|
+
return {
|
|
402
|
+
version: "1",
|
|
403
|
+
mode,
|
|
404
|
+
...target ? { target } : {},
|
|
405
|
+
...navigation ? { navigation } : {},
|
|
406
|
+
...page ? { page } : {},
|
|
407
|
+
...defaults ? { defaults } : {},
|
|
408
|
+
tabs,
|
|
409
|
+
assets,
|
|
410
|
+
...reaction ? { reaction } : {}
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
414
|
+
0 && (module.exports = {
|
|
415
|
+
prepareFlowSurfaceApplyBlueprintDocument
|
|
416
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
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 { FlowSurfaceApplyBlueprintAssetMap } from './public-types';
|
|
10
|
+
export declare const APPLY_BLUEPRINT_CREATE_MENU_GROUP_METADATA_KEYS: readonly ["icon", "tooltip", "hideInMenu"];
|
|
11
|
+
export declare function assertPlainObject(value: any, context: string): void;
|
|
12
|
+
export declare function assertOnlyAllowedKeys(input: Record<string, any>, context: string, allowedKeys: string[]): void;
|
|
13
|
+
export declare function normalizeApplyBlueprintToken(value: any, fallback?: string): string;
|
|
14
|
+
export declare function readString(value: any): string;
|
|
15
|
+
export declare function readOptionalString(value: any): string;
|
|
16
|
+
export declare function readBoolean(value: any, context: string): boolean;
|
|
17
|
+
export declare function assertNonEmptyString(value: any, context: string): string;
|
|
18
|
+
export declare function readOptionalArray<T = any>(value: any, context: string): T[] | undefined;
|
|
19
|
+
export declare function cloneOptionalPlainObject<T extends Record<string, any>>(value: any, context: string): T | undefined;
|
|
20
|
+
export declare function buildApplyBlueprintTabPublicPath(index: number): string;
|
|
21
|
+
export declare function buildScopedKey(scopePrefix: string, localKey: string): string;
|
|
22
|
+
export declare function normalizeBlueprintLocalKey(rawValue: any, fallback: string, context: string): string;
|
|
23
|
+
export declare function normalizeTabLocalKey(rawKey: any, fallback: string, index: number, usedKeys: Set<string>, options: {
|
|
24
|
+
explicit: boolean;
|
|
25
|
+
}): string;
|
|
26
|
+
export declare function normalizeAssetRegistry(input: any, context: string): FlowSurfaceApplyBlueprintAssetMap;
|
|
@@ -0,0 +1,182 @@
|
|
|
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 private_utils_exports = {};
|
|
38
|
+
__export(private_utils_exports, {
|
|
39
|
+
APPLY_BLUEPRINT_CREATE_MENU_GROUP_METADATA_KEYS: () => APPLY_BLUEPRINT_CREATE_MENU_GROUP_METADATA_KEYS,
|
|
40
|
+
assertNonEmptyString: () => assertNonEmptyString,
|
|
41
|
+
assertOnlyAllowedKeys: () => assertOnlyAllowedKeys,
|
|
42
|
+
assertPlainObject: () => assertPlainObject,
|
|
43
|
+
buildApplyBlueprintTabPublicPath: () => buildApplyBlueprintTabPublicPath,
|
|
44
|
+
buildScopedKey: () => buildScopedKey,
|
|
45
|
+
cloneOptionalPlainObject: () => cloneOptionalPlainObject,
|
|
46
|
+
normalizeApplyBlueprintToken: () => normalizeApplyBlueprintToken,
|
|
47
|
+
normalizeAssetRegistry: () => normalizeAssetRegistry,
|
|
48
|
+
normalizeBlueprintLocalKey: () => normalizeBlueprintLocalKey,
|
|
49
|
+
normalizeTabLocalKey: () => normalizeTabLocalKey,
|
|
50
|
+
readBoolean: () => readBoolean,
|
|
51
|
+
readOptionalArray: () => readOptionalArray,
|
|
52
|
+
readOptionalString: () => readOptionalString,
|
|
53
|
+
readString: () => readString
|
|
54
|
+
});
|
|
55
|
+
module.exports = __toCommonJS(private_utils_exports);
|
|
56
|
+
var import_lodash = __toESM(require("lodash"));
|
|
57
|
+
var import_errors = require("../errors");
|
|
58
|
+
var import_service_utils = require("../service-utils");
|
|
59
|
+
const APPLY_BLUEPRINT_CREATE_MENU_GROUP_METADATA_KEYS = ["icon", "tooltip", "hideInMenu"];
|
|
60
|
+
function assertPlainObject(value, context) {
|
|
61
|
+
if (!import_lodash.default.isPlainObject(value)) {
|
|
62
|
+
(0, import_errors.throwBadRequest)(`${context} must be an object`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function assertOnlyAllowedKeys(input, context, allowedKeys) {
|
|
66
|
+
const unsupportedKeys = Object.keys(input || {}).filter((key) => !allowedKeys.includes(key));
|
|
67
|
+
if (!unsupportedKeys.length) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
(0, import_errors.throwBadRequest)(
|
|
71
|
+
`${context} only accepts keys ${allowedKeys.join(", ")}; unsupported keys: ${unsupportedKeys.join(", ")}`
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
function normalizeApplyBlueprintToken(value, fallback = "item") {
|
|
75
|
+
const normalized = String(value || "").trim().replace(/[.[\](){}]+/g, "_").replace(/[^a-zA-Z0-9_]+/g, "_").replace(/_+/g, "_").replace(/^_+|_+$/g, "");
|
|
76
|
+
return normalized || fallback;
|
|
77
|
+
}
|
|
78
|
+
function readString(value) {
|
|
79
|
+
return typeof value === "string" ? value.trim() : "";
|
|
80
|
+
}
|
|
81
|
+
function readOptionalString(value) {
|
|
82
|
+
const normalized = readString(value);
|
|
83
|
+
return normalized || void 0;
|
|
84
|
+
}
|
|
85
|
+
function readBoolean(value, context) {
|
|
86
|
+
if (import_lodash.default.isUndefined(value)) {
|
|
87
|
+
return void 0;
|
|
88
|
+
}
|
|
89
|
+
if (typeof value !== "boolean") {
|
|
90
|
+
(0, import_errors.throwBadRequest)(`${context} must be a boolean`);
|
|
91
|
+
}
|
|
92
|
+
return value;
|
|
93
|
+
}
|
|
94
|
+
function assertNonEmptyString(value, context) {
|
|
95
|
+
const normalized = readString(value);
|
|
96
|
+
if (!normalized) {
|
|
97
|
+
(0, import_errors.throwBadRequest)(`${context} must be a non-empty string`);
|
|
98
|
+
}
|
|
99
|
+
return normalized;
|
|
100
|
+
}
|
|
101
|
+
function readOptionalArray(value, context) {
|
|
102
|
+
if (import_lodash.default.isUndefined(value)) {
|
|
103
|
+
return void 0;
|
|
104
|
+
}
|
|
105
|
+
if (!Array.isArray(value)) {
|
|
106
|
+
(0, import_errors.throwBadRequest)(`${context} must be an array`);
|
|
107
|
+
}
|
|
108
|
+
return value;
|
|
109
|
+
}
|
|
110
|
+
function cloneOptionalPlainObject(value, context) {
|
|
111
|
+
if (import_lodash.default.isUndefined(value)) {
|
|
112
|
+
return void 0;
|
|
113
|
+
}
|
|
114
|
+
assertPlainObject(value, context);
|
|
115
|
+
return import_lodash.default.cloneDeep(value);
|
|
116
|
+
}
|
|
117
|
+
function buildApplyBlueprintTabPublicPath(index) {
|
|
118
|
+
return `flowSurfaces applyBlueprint tabs[${index}]`;
|
|
119
|
+
}
|
|
120
|
+
function buildScopedKey(scopePrefix, localKey) {
|
|
121
|
+
return scopePrefix ? `${scopePrefix}.${localKey}` : localKey;
|
|
122
|
+
}
|
|
123
|
+
function normalizeBlueprintLocalKey(rawValue, fallback, context) {
|
|
124
|
+
const explicit = readString(rawValue);
|
|
125
|
+
if (explicit) {
|
|
126
|
+
return (0, import_service_utils.normalizeFlowSurfaceComposeKey)(explicit, context);
|
|
127
|
+
}
|
|
128
|
+
return (0, import_service_utils.normalizeFlowSurfaceComposeKey)(normalizeApplyBlueprintToken(fallback, fallback), context);
|
|
129
|
+
}
|
|
130
|
+
function normalizeTabLocalKey(rawKey, fallback, index, usedKeys, options) {
|
|
131
|
+
const normalizedBase = normalizeBlueprintLocalKey(rawKey, fallback, `flowSurfaces applyBlueprint tabs[${index}].key`);
|
|
132
|
+
if (!usedKeys.has(normalizedBase)) {
|
|
133
|
+
usedKeys.add(normalizedBase);
|
|
134
|
+
return normalizedBase;
|
|
135
|
+
}
|
|
136
|
+
if (options.explicit) {
|
|
137
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces applyBlueprint tabs[${index}].key '${normalizedBase}' is duplicated`);
|
|
138
|
+
}
|
|
139
|
+
let suffix = 2;
|
|
140
|
+
let candidate = `${normalizedBase}_${suffix}`;
|
|
141
|
+
while (usedKeys.has(candidate)) {
|
|
142
|
+
suffix += 1;
|
|
143
|
+
candidate = `${normalizedBase}_${suffix}`;
|
|
144
|
+
}
|
|
145
|
+
usedKeys.add(candidate);
|
|
146
|
+
return candidate;
|
|
147
|
+
}
|
|
148
|
+
function normalizeAssetRegistry(input, context) {
|
|
149
|
+
if (import_lodash.default.isUndefined(input)) {
|
|
150
|
+
return {};
|
|
151
|
+
}
|
|
152
|
+
if (!import_lodash.default.isPlainObject(input)) {
|
|
153
|
+
(0, import_errors.throwBadRequest)(`${context} must be an object map`);
|
|
154
|
+
}
|
|
155
|
+
return Object.fromEntries(
|
|
156
|
+
Object.entries(input).map(([key, value]) => {
|
|
157
|
+
const normalizedKey = assertNonEmptyString(key, `${context} key`);
|
|
158
|
+
if (!import_lodash.default.isPlainObject(value)) {
|
|
159
|
+
(0, import_errors.throwBadRequest)(`${context}['${normalizedKey}'] must be an object`);
|
|
160
|
+
}
|
|
161
|
+
return [normalizedKey, import_lodash.default.cloneDeep(value)];
|
|
162
|
+
})
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
166
|
+
0 && (module.exports = {
|
|
167
|
+
APPLY_BLUEPRINT_CREATE_MENU_GROUP_METADATA_KEYS,
|
|
168
|
+
assertNonEmptyString,
|
|
169
|
+
assertOnlyAllowedKeys,
|
|
170
|
+
assertPlainObject,
|
|
171
|
+
buildApplyBlueprintTabPublicPath,
|
|
172
|
+
buildScopedKey,
|
|
173
|
+
cloneOptionalPlainObject,
|
|
174
|
+
normalizeApplyBlueprintToken,
|
|
175
|
+
normalizeAssetRegistry,
|
|
176
|
+
normalizeBlueprintLocalKey,
|
|
177
|
+
normalizeTabLocalKey,
|
|
178
|
+
readBoolean,
|
|
179
|
+
readOptionalArray,
|
|
180
|
+
readOptionalString,
|
|
181
|
+
readString
|
|
182
|
+
});
|