@nocobase/plugin-ui-templates 2.0.0-alpha.57
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/LICENSE.txt +172 -0
- package/build.config.ts +12 -0
- package/client.js +1 -0
- package/dist/client/collections/flowModelTemplates.d.ts +67 -0
- package/dist/client/components/FlowModelTemplatesPage.d.ts +12 -0
- package/dist/client/components/TemplateSelectOption.d.ts +20 -0
- package/dist/client/constants.d.ts +9 -0
- package/dist/client/hooks/useFlowModelTemplateActions.d.ts +24 -0
- package/dist/client/index.d.ts +13 -0
- package/dist/client/index.js +10 -0
- package/dist/client/locale.d.ts +18 -0
- package/dist/client/menuExtensions.d.ts +9 -0
- package/dist/client/models/ReferenceBlockModel.d.ts +47 -0
- package/dist/client/models/ReferenceFormGridModel.d.ts +38 -0
- package/dist/client/models/SubModelTemplateImporterModel.d.ts +55 -0
- package/dist/client/models/referenceShared.d.ts +23 -0
- package/dist/client/openViewActionExtensions.d.ts +10 -0
- package/dist/client/schemas/flowModelTemplates.d.ts +11 -0
- package/dist/client/subModelMenuExtensions.d.ts +10 -0
- package/dist/client/utils/infiniteSelect.d.ts +28 -0
- package/dist/client/utils/refHost.d.ts +20 -0
- package/dist/client/utils/templateCompatibility.d.ts +91 -0
- package/dist/client.d.ts +9 -0
- package/dist/client.js +42 -0
- package/dist/externalVersion.js +24 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +48 -0
- package/dist/locale/de-DE.json +14 -0
- package/dist/locale/en-US.json +72 -0
- package/dist/locale/es-ES.json +14 -0
- package/dist/locale/fr-FR.json +14 -0
- package/dist/locale/hu-HU.json +14 -0
- package/dist/locale/id-ID.json +14 -0
- package/dist/locale/it-IT.json +14 -0
- package/dist/locale/ja-JP.json +14 -0
- package/dist/locale/ko-KR.json +14 -0
- package/dist/locale/nl-NL.json +14 -0
- package/dist/locale/pt-BR.json +14 -0
- package/dist/locale/ru-RU.json +14 -0
- package/dist/locale/tr-TR.json +14 -0
- package/dist/locale/uk-UA.json +14 -0
- package/dist/locale/vi-VN.json +14 -0
- package/dist/locale/zh-CN.json +71 -0
- package/dist/locale/zh-TW.json +14 -0
- package/dist/server/collections/flowModelTemplateUsages.d.ts +11 -0
- package/dist/server/collections/flowModelTemplateUsages.js +71 -0
- package/dist/server/collections/flowModelTemplates.d.ts +11 -0
- package/dist/server/collections/flowModelTemplates.js +96 -0
- package/dist/server/index.d.ts +9 -0
- package/dist/server/index.js +42 -0
- package/dist/server/plugin.d.ts +17 -0
- package/dist/server/plugin.js +242 -0
- package/dist/server/resources/flowModelTemplateUsages.d.ts +19 -0
- package/dist/server/resources/flowModelTemplateUsages.js +91 -0
- package/dist/server/resources/flowModelTemplates.d.ts +20 -0
- package/dist/server/resources/flowModelTemplates.js +267 -0
- package/package.json +37 -0
- package/server.js +1 -0
- package/src/client/__tests__/openViewActionExtensions.test.ts +1208 -0
- package/src/client/collections/flowModelTemplates.ts +131 -0
- package/src/client/components/FlowModelTemplatesPage.tsx +78 -0
- package/src/client/components/TemplateSelectOption.tsx +106 -0
- package/src/client/constants.ts +10 -0
- package/src/client/hooks/useFlowModelTemplateActions.tsx +137 -0
- package/src/client/index.ts +54 -0
- package/src/client/locale.ts +40 -0
- package/src/client/menuExtensions.tsx +1033 -0
- package/src/client/models/ReferenceBlockModel.tsx +793 -0
- package/src/client/models/ReferenceFormGridModel.tsx +302 -0
- package/src/client/models/SubModelTemplateImporterModel.tsx +634 -0
- package/src/client/models/__tests__/ReferenceBlockModel.test.tsx +482 -0
- package/src/client/models/__tests__/ReferenceFormGridModel.test.tsx +175 -0
- package/src/client/models/__tests__/SubModelTemplateImporterModel.test.ts +447 -0
- package/src/client/models/referenceShared.tsx +99 -0
- package/src/client/openViewActionExtensions.tsx +981 -0
- package/src/client/schemas/flowModelTemplates.ts +264 -0
- package/src/client/subModelMenuExtensions.ts +103 -0
- package/src/client/utils/infiniteSelect.ts +150 -0
- package/src/client/utils/refHost.ts +44 -0
- package/src/client/utils/templateCompatibility.ts +374 -0
- package/src/client.ts +10 -0
- package/src/index.ts +11 -0
- package/src/locale/de-DE.json +14 -0
- package/src/locale/en-US.json +72 -0
- package/src/locale/es-ES.json +14 -0
- package/src/locale/fr-FR.json +14 -0
- package/src/locale/hu-HU.json +14 -0
- package/src/locale/id-ID.json +14 -0
- package/src/locale/it-IT.json +14 -0
- package/src/locale/ja-JP.json +14 -0
- package/src/locale/ko-KR.json +14 -0
- package/src/locale/nl-NL.json +14 -0
- package/src/locale/pt-BR.json +14 -0
- package/src/locale/ru-RU.json +14 -0
- package/src/locale/tr-TR.json +14 -0
- package/src/locale/uk-UA.json +14 -0
- package/src/locale/vi-VN.json +14 -0
- package/src/locale/zh-CN.json +71 -0
- package/src/locale/zh-TW.json +14 -0
- package/src/server/__tests__/template-usage.test.ts +351 -0
- package/src/server/collections/flowModelTemplateUsages.ts +51 -0
- package/src/server/collections/flowModelTemplates.ts +76 -0
- package/src/server/index.ts +10 -0
- package/src/server/plugin.ts +236 -0
- package/src/server/resources/flowModelTemplateUsages.ts +61 -0
- package/src/server/resources/flowModelTemplates.ts +251 -0
|
@@ -0,0 +1,11 @@
|
|
|
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 { CollectionOptions } from '@nocobase/database';
|
|
10
|
+
declare const _default: CollectionOptions;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var flowModelTemplateUsages_exports = {};
|
|
28
|
+
__export(flowModelTemplateUsages_exports, {
|
|
29
|
+
default: () => flowModelTemplateUsages_default
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(flowModelTemplateUsages_exports);
|
|
32
|
+
var flowModelTemplateUsages_default = {
|
|
33
|
+
dumpRules: "required",
|
|
34
|
+
migrationRules: ["overwrite", "schema-only"],
|
|
35
|
+
name: "flowModelTemplateUsages",
|
|
36
|
+
autoGenId: false,
|
|
37
|
+
timestamps: true,
|
|
38
|
+
fields: [
|
|
39
|
+
{
|
|
40
|
+
type: "uid",
|
|
41
|
+
name: "uid",
|
|
42
|
+
primaryKey: true
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
type: "string",
|
|
46
|
+
name: "templateUid",
|
|
47
|
+
allowNull: false
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
type: "string",
|
|
51
|
+
name: "modelUid",
|
|
52
|
+
allowNull: false
|
|
53
|
+
}
|
|
54
|
+
],
|
|
55
|
+
indexes: [
|
|
56
|
+
{
|
|
57
|
+
fields: ["uid"],
|
|
58
|
+
unique: true
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
fields: ["templateUid", "modelUid"],
|
|
62
|
+
unique: true
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
fields: ["templateUid"]
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
fields: ["modelUid"]
|
|
69
|
+
}
|
|
70
|
+
]
|
|
71
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
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 { CollectionOptions } from '@nocobase/database';
|
|
10
|
+
declare const _default: CollectionOptions;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var flowModelTemplates_exports = {};
|
|
28
|
+
__export(flowModelTemplates_exports, {
|
|
29
|
+
default: () => flowModelTemplates_default
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(flowModelTemplates_exports);
|
|
32
|
+
var flowModelTemplates_default = {
|
|
33
|
+
dumpRules: "required",
|
|
34
|
+
migrationRules: ["overwrite", "schema-only"],
|
|
35
|
+
name: "flowModelTemplates",
|
|
36
|
+
autoGenId: false,
|
|
37
|
+
timestamps: true,
|
|
38
|
+
fields: [
|
|
39
|
+
{
|
|
40
|
+
type: "uid",
|
|
41
|
+
name: "uid",
|
|
42
|
+
primaryKey: true
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
type: "string",
|
|
46
|
+
name: "name",
|
|
47
|
+
allowNull: false
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
type: "text",
|
|
51
|
+
name: "description"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
type: "string",
|
|
55
|
+
name: "targetUid",
|
|
56
|
+
allowNull: false
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
type: "string",
|
|
60
|
+
name: "useModel"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
type: "string",
|
|
64
|
+
name: "type"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
type: "string",
|
|
68
|
+
name: "dataSourceKey"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
type: "string",
|
|
72
|
+
name: "collectionName"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
type: "string",
|
|
76
|
+
name: "associationName"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
type: "string",
|
|
80
|
+
name: "filterByTk"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
type: "string",
|
|
84
|
+
name: "sourceId"
|
|
85
|
+
}
|
|
86
|
+
],
|
|
87
|
+
indexes: [
|
|
88
|
+
{
|
|
89
|
+
fields: ["uid"],
|
|
90
|
+
unique: true
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
fields: ["targetUid"]
|
|
94
|
+
}
|
|
95
|
+
]
|
|
96
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
export { default } from './plugin';
|
|
@@ -0,0 +1,42 @@
|
|
|
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 server_exports = {};
|
|
38
|
+
__export(server_exports, {
|
|
39
|
+
default: () => import_plugin.default
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(server_exports);
|
|
42
|
+
var import_plugin = __toESM(require("./plugin"));
|
|
@@ -0,0 +1,17 @@
|
|
|
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 { InstallOptions, Plugin } from '@nocobase/server';
|
|
10
|
+
export declare class PluginBlockReferenceServer extends Plugin {
|
|
11
|
+
load(): Promise<void>;
|
|
12
|
+
install(options?: InstallOptions): Promise<void>;
|
|
13
|
+
afterEnable(): Promise<void>;
|
|
14
|
+
afterDisable(): Promise<void>;
|
|
15
|
+
remove(): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
export default PluginBlockReferenceServer;
|
|
@@ -0,0 +1,242 @@
|
|
|
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 plugin_exports = {};
|
|
38
|
+
__export(plugin_exports, {
|
|
39
|
+
PluginBlockReferenceServer: () => PluginBlockReferenceServer,
|
|
40
|
+
default: () => plugin_default
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(plugin_exports);
|
|
43
|
+
var import_server = require("@nocobase/server");
|
|
44
|
+
var import_lodash = __toESM(require("lodash"));
|
|
45
|
+
var import_flowModelTemplates = __toESM(require("./resources/flowModelTemplates"));
|
|
46
|
+
var import_flowModelTemplateUsages = __toESM(require("./resources/flowModelTemplateUsages"));
|
|
47
|
+
var import_plugin_flow_engine = require("@nocobase/plugin-flow-engine");
|
|
48
|
+
var import_utils = require("@nocobase/utils");
|
|
49
|
+
class PluginBlockReferenceServer extends import_server.Plugin {
|
|
50
|
+
async load() {
|
|
51
|
+
var _a;
|
|
52
|
+
this.app.resourceManager.define(import_flowModelTemplates.default);
|
|
53
|
+
this.app.resourceManager.define(import_flowModelTemplateUsages.default);
|
|
54
|
+
this.app.acl.allow("flowModelTemplates", "*", "loggedIn");
|
|
55
|
+
this.app.acl.allow("flowModelTemplateUsages", "*", "loggedIn");
|
|
56
|
+
this.app.acl.registerSnippet({
|
|
57
|
+
name: `pm.${this.name}.templates`,
|
|
58
|
+
actions: ["flowModelTemplates:*", "flowModelTemplateUsages:*"]
|
|
59
|
+
});
|
|
60
|
+
(_a = this.app.auditManager) == null ? void 0 : _a.registerActions([
|
|
61
|
+
"flowModelTemplates:create",
|
|
62
|
+
"flowModelTemplates:update",
|
|
63
|
+
"flowModelTemplates:destroy",
|
|
64
|
+
"flowModelTemplateUsages:create",
|
|
65
|
+
"flowModelTemplateUsages:destroy"
|
|
66
|
+
]);
|
|
67
|
+
const parseOptions = (value) => import_plugin_flow_engine.FlowModelRepository.optionsToJson(value || {});
|
|
68
|
+
const omitSubModels = (value) => {
|
|
69
|
+
if (!value || typeof value !== "object") return value;
|
|
70
|
+
const { subModels, ...rest } = value;
|
|
71
|
+
return rest;
|
|
72
|
+
};
|
|
73
|
+
const collectFlowModelsFromTree = (value) => {
|
|
74
|
+
const result = [];
|
|
75
|
+
const ensureNodeUid = (node) => {
|
|
76
|
+
const existing = node == null ? void 0 : node.uid;
|
|
77
|
+
if (typeof existing === "string" && existing) return existing;
|
|
78
|
+
if (typeof existing === "undefined" || existing === null || existing === "") {
|
|
79
|
+
const next = (0, import_utils.uid)();
|
|
80
|
+
node.uid = next;
|
|
81
|
+
return next;
|
|
82
|
+
}
|
|
83
|
+
throw new Error("[block-reference] flowModels uid must be a non-empty string");
|
|
84
|
+
};
|
|
85
|
+
const walk = (node, inheritedParentId) => {
|
|
86
|
+
if (!node || typeof node !== "object") return;
|
|
87
|
+
const nodeUid = ensureNodeUid(node);
|
|
88
|
+
const nextNode = omitSubModels(node);
|
|
89
|
+
if (inheritedParentId && nextNode && typeof nextNode === "object" && !nextNode.parentId) {
|
|
90
|
+
nextNode.parentId = inheritedParentId;
|
|
91
|
+
}
|
|
92
|
+
if (nodeUid) {
|
|
93
|
+
result.push(nextNode);
|
|
94
|
+
}
|
|
95
|
+
const subModels = node == null ? void 0 : node.subModels;
|
|
96
|
+
if (!subModels || typeof subModels !== "object") return;
|
|
97
|
+
for (const val of Object.values(subModels)) {
|
|
98
|
+
const items = Array.isArray(val) ? val : [val];
|
|
99
|
+
for (const child of items) {
|
|
100
|
+
walk(child, nodeUid || inheritedParentId);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
walk(value);
|
|
105
|
+
return result;
|
|
106
|
+
};
|
|
107
|
+
const extractTemplateUids = (options) => {
|
|
108
|
+
const stepParams = (options == null ? void 0 : options.stepParams) || {};
|
|
109
|
+
const uids = /* @__PURE__ */ new Set();
|
|
110
|
+
const mode = import_lodash.default.get(stepParams, ["referenceSettings", "useTemplate", "mode"]) || "reference";
|
|
111
|
+
const tplUid = import_lodash.default.get(stepParams, ["referenceSettings", "useTemplate", "templateUid"]);
|
|
112
|
+
if (tplUid && mode !== "copy") {
|
|
113
|
+
uids.add(String(tplUid));
|
|
114
|
+
}
|
|
115
|
+
const popupSettings = import_lodash.default.get(stepParams, ["popupSettings"]);
|
|
116
|
+
if (popupSettings && typeof popupSettings === "object") {
|
|
117
|
+
for (const val of Object.values(popupSettings)) {
|
|
118
|
+
if (!val || typeof val !== "object") continue;
|
|
119
|
+
const step = val;
|
|
120
|
+
const tplUidRaw = step["popupTemplateUid"];
|
|
121
|
+
const tplMode = String(step["popupTemplateMode"] || "") || "reference";
|
|
122
|
+
if (tplUidRaw !== null && typeof tplUidRaw !== "undefined" && String(tplUidRaw) && tplMode !== "copy") {
|
|
123
|
+
uids.add(String(tplUidRaw));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return Array.from(uids);
|
|
128
|
+
};
|
|
129
|
+
const syncUsages = async (instanceUid, options, { transaction } = {}) => {
|
|
130
|
+
const usageRepo = this.db.getRepository("flowModelTemplateUsages");
|
|
131
|
+
const currentUids = import_lodash.default.uniq(extractTemplateUids(options).map(String));
|
|
132
|
+
await usageRepo.destroy({
|
|
133
|
+
filter: { modelUid: instanceUid },
|
|
134
|
+
transaction
|
|
135
|
+
});
|
|
136
|
+
for (const templateUid of currentUids) {
|
|
137
|
+
await usageRepo.updateOrCreate({
|
|
138
|
+
filterKeys: ["templateUid", "modelUid"],
|
|
139
|
+
values: { uid: (0, import_utils.uid)(), templateUid, modelUid: instanceUid },
|
|
140
|
+
transaction,
|
|
141
|
+
context: { disableAfterDestroy: true }
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
const removeUsagesByInstance = async (instanceUid, _options, { transaction } = {}) => {
|
|
146
|
+
const usageRepo = this.db.getRepository("flowModelTemplateUsages");
|
|
147
|
+
await usageRepo.destroy({ filter: { modelUid: instanceUid }, transaction });
|
|
148
|
+
};
|
|
149
|
+
this.db.on("flowModels.afterDestroy", async (instance, { transaction } = {}) => {
|
|
150
|
+
var _a2, _b;
|
|
151
|
+
const instanceUid = ((_a2 = instance == null ? void 0 : instance.get) == null ? void 0 : _a2.call(instance, "uid")) || (instance == null ? void 0 : instance.uid);
|
|
152
|
+
if (!instanceUid) return;
|
|
153
|
+
const options = parseOptions(((_b = instance == null ? void 0 : instance.get) == null ? void 0 : _b.call(instance, "options")) || (instance == null ? void 0 : instance.options));
|
|
154
|
+
await removeUsagesByInstance(instanceUid, options, { transaction });
|
|
155
|
+
});
|
|
156
|
+
const handleFlowModelSave = async (instance, { transaction } = {}) => {
|
|
157
|
+
var _a2, _b;
|
|
158
|
+
const instanceUid = ((_a2 = instance == null ? void 0 : instance.get) == null ? void 0 : _a2.call(instance, "uid")) || (instance == null ? void 0 : instance.uid);
|
|
159
|
+
if (!instanceUid) return;
|
|
160
|
+
const options = parseOptions(((_b = instance == null ? void 0 : instance.get) == null ? void 0 : _b.call(instance, "options")) || (instance == null ? void 0 : instance.options));
|
|
161
|
+
await syncUsages(instanceUid, options, { transaction });
|
|
162
|
+
};
|
|
163
|
+
this.db.on("flowModels.afterSaveWithAssociations", handleFlowModelSave);
|
|
164
|
+
this.app.resourceManager.use(async (ctx, next) => {
|
|
165
|
+
var _a2, _b, _c, _d, _e, _f, _g;
|
|
166
|
+
const isFlowModels = ((_a2 = ctx == null ? void 0 : ctx.action) == null ? void 0 : _a2.resourceName) === "flowModels";
|
|
167
|
+
if (!isFlowModels) {
|
|
168
|
+
return next();
|
|
169
|
+
}
|
|
170
|
+
const actionName = (_b = ctx == null ? void 0 : ctx.action) == null ? void 0 : _b.actionName;
|
|
171
|
+
if (actionName === "save") {
|
|
172
|
+
const values = (_d = (_c = ctx == null ? void 0 : ctx.action) == null ? void 0 : _c.params) == null ? void 0 : _d.values;
|
|
173
|
+
if (!values || typeof values !== "object") {
|
|
174
|
+
ctx.throw(400, {
|
|
175
|
+
code: "INVALID_PAYLOAD",
|
|
176
|
+
message: "values is required"
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
const nodes = collectFlowModelsFromTree(values);
|
|
180
|
+
await next();
|
|
181
|
+
for (const node of nodes) {
|
|
182
|
+
const instanceUid = node == null ? void 0 : node.uid;
|
|
183
|
+
if (!instanceUid) continue;
|
|
184
|
+
const currentOptions = parseOptions(node);
|
|
185
|
+
await syncUsages(instanceUid, currentOptions, { transaction: ctx.transaction });
|
|
186
|
+
}
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
if (actionName === "destroy") {
|
|
190
|
+
const rootUid = (_f = (_e = ctx == null ? void 0 : ctx.action) == null ? void 0 : _e.params) == null ? void 0 : _f.filterByTk;
|
|
191
|
+
if (!rootUid || typeof rootUid !== "string") {
|
|
192
|
+
ctx.throw(400, {
|
|
193
|
+
code: "INVALID_PAYLOAD",
|
|
194
|
+
message: "filterByTk is required"
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
const flowRepo = ctx.db.getRepository("flowModels");
|
|
198
|
+
const nodes = await flowRepo.findNodesById(rootUid, {
|
|
199
|
+
includeAsyncNode: true,
|
|
200
|
+
transaction: ctx.transaction
|
|
201
|
+
});
|
|
202
|
+
await next();
|
|
203
|
+
for (const node of nodes) {
|
|
204
|
+
const instanceUid = node == null ? void 0 : node.uid;
|
|
205
|
+
if (!instanceUid) continue;
|
|
206
|
+
const options = parseOptions((node == null ? void 0 : node.options) || {});
|
|
207
|
+
if ((node == null ? void 0 : node.parent) && !(options == null ? void 0 : options.parentId)) {
|
|
208
|
+
options.parentId = node.parent;
|
|
209
|
+
}
|
|
210
|
+
await removeUsagesByInstance(instanceUid, options, { transaction: ctx.transaction });
|
|
211
|
+
}
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
if (actionName === "duplicate") {
|
|
215
|
+
await next();
|
|
216
|
+
const raw = ((_g = ctx.body) == null ? void 0 : _g.data) ?? ctx.body;
|
|
217
|
+
const nodes = collectFlowModelsFromTree(raw);
|
|
218
|
+
for (const node of nodes) {
|
|
219
|
+
const instanceUid = node == null ? void 0 : node.uid;
|
|
220
|
+
if (!instanceUid) continue;
|
|
221
|
+
const currentOptions = parseOptions(node);
|
|
222
|
+
await syncUsages(instanceUid, currentOptions, { transaction: ctx.transaction });
|
|
223
|
+
}
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
return next();
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
async install(options) {
|
|
230
|
+
}
|
|
231
|
+
async afterEnable() {
|
|
232
|
+
}
|
|
233
|
+
async afterDisable() {
|
|
234
|
+
}
|
|
235
|
+
async remove() {
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
var plugin_default = PluginBlockReferenceServer;
|
|
239
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
240
|
+
0 && (module.exports = {
|
|
241
|
+
PluginBlockReferenceServer
|
|
242
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
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 { Context } from '@nocobase/actions';
|
|
10
|
+
declare const _default: {
|
|
11
|
+
name: string;
|
|
12
|
+
actions: {
|
|
13
|
+
list(ctx: Context, next: any): Promise<void>;
|
|
14
|
+
get(ctx: Context, next: any): Promise<void>;
|
|
15
|
+
create(ctx: Context, next: any): Promise<never>;
|
|
16
|
+
destroy(ctx: Context, next: any): Promise<void>;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export default _default;
|
|
@@ -0,0 +1,91 @@
|
|
|
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 flowModelTemplateUsages_exports = {};
|
|
38
|
+
__export(flowModelTemplateUsages_exports, {
|
|
39
|
+
default: () => flowModelTemplateUsages_default
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(flowModelTemplateUsages_exports);
|
|
42
|
+
var import_actions = __toESM(require("@nocobase/actions"));
|
|
43
|
+
var import_utils = require("@nocobase/utils");
|
|
44
|
+
var flowModelTemplateUsages_default = {
|
|
45
|
+
name: "flowModelTemplateUsages",
|
|
46
|
+
actions: {
|
|
47
|
+
async list(ctx, next) {
|
|
48
|
+
await import_actions.default.list(ctx, next);
|
|
49
|
+
},
|
|
50
|
+
async get(ctx, next) {
|
|
51
|
+
await import_actions.default.get(ctx, next);
|
|
52
|
+
},
|
|
53
|
+
async create(ctx, next) {
|
|
54
|
+
var _a;
|
|
55
|
+
const values = ((_a = ctx.action.params) == null ? void 0 : _a.values) || {};
|
|
56
|
+
const templateUid = values.templateUid;
|
|
57
|
+
const modelUid = values.modelUid;
|
|
58
|
+
if (!templateUid || !modelUid) {
|
|
59
|
+
return ctx.throw(400, "templateUid and modelUid are required");
|
|
60
|
+
}
|
|
61
|
+
const usageRepo = ctx.db.getRepository("flowModelTemplateUsages");
|
|
62
|
+
const record = await usageRepo.updateOrCreate({
|
|
63
|
+
filterKeys: ["templateUid", "modelUid"],
|
|
64
|
+
values: {
|
|
65
|
+
uid: values.uid || (0, import_utils.uid)(),
|
|
66
|
+
templateUid,
|
|
67
|
+
modelUid
|
|
68
|
+
},
|
|
69
|
+
context: ctx
|
|
70
|
+
});
|
|
71
|
+
ctx.body = record;
|
|
72
|
+
await next();
|
|
73
|
+
},
|
|
74
|
+
async destroy(ctx, next) {
|
|
75
|
+
var _a;
|
|
76
|
+
const params = ((_a = ctx.action) == null ? void 0 : _a.params) || {};
|
|
77
|
+
const { filterByTk, values = {}, filter } = params;
|
|
78
|
+
const templateUid = values.templateUid;
|
|
79
|
+
const modelUid = values.modelUid;
|
|
80
|
+
if (!filterByTk && templateUid && modelUid && !filter) {
|
|
81
|
+
ctx.action.mergeParams({
|
|
82
|
+
filter: {
|
|
83
|
+
templateUid,
|
|
84
|
+
modelUid
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
await import_actions.default.destroy(ctx, next);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
};
|
|
@@ -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 { Context } from '@nocobase/actions';
|
|
10
|
+
declare const _default: {
|
|
11
|
+
name: string;
|
|
12
|
+
actions: {
|
|
13
|
+
list(ctx: Context, next: any): Promise<void>;
|
|
14
|
+
get(ctx: Context, next: any): Promise<void>;
|
|
15
|
+
create(ctx: Context, next: any): Promise<void>;
|
|
16
|
+
update(ctx: Context, next: any): Promise<void>;
|
|
17
|
+
destroy(ctx: Context, next: any): Promise<never>;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export default _default;
|