@nocobase/plugin-ui-schema-storage 1.2.12-alpha → 1.3.0-alpha.20240710084543
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/package.json +2 -2
- package/dist/client/index.d.ts +0 -13
- package/dist/client/index.js +0 -10
- package/dist/externalVersion.js +0 -20
- package/dist/index.d.ts +0 -11
- package/dist/index.js +0 -39
- package/dist/server/actions/ui-schema-action.d.ts +0 -27
- package/dist/server/actions/ui-schema-action.js +0 -140
- package/dist/server/collections/uiSchemaServerHooks.d.ts +0 -11
- package/dist/server/collections/uiSchemaServerHooks.js +0 -58
- package/dist/server/collections/uiSchemaTemplates.d.ts +0 -10
- package/dist/server/collections/uiSchemaTemplates.js +0 -75
- package/dist/server/collections/uiSchemaTreePath.d.ts +0 -11
- package/dist/server/collections/uiSchemaTreePath.js +0 -73
- package/dist/server/collections/uiSchemas.d.ts +0 -11
- package/dist/server/collections/uiSchemas.js +0 -62
- package/dist/server/dao/ui_schema_node_dao.d.ts +0 -26
- package/dist/server/dao/ui_schema_node_dao.js +0 -24
- package/dist/server/helper.d.ts +0 -8
- package/dist/server/helper.js +0 -9
- package/dist/server/index.d.ts +0 -12
- package/dist/server/index.js +0 -41
- package/dist/server/migrations/20230330214649-filter-form-block.d.ts +0 -13
- package/dist/server/migrations/20230330214649-filter-form-block.js +0 -58
- package/dist/server/migrations/20230509221649-association-select.d.ts +0 -13
- package/dist/server/migrations/20230509221649-association-select.js +0 -71
- package/dist/server/migrations/20230509235247-record-picker.d.ts +0 -16
- package/dist/server/migrations/20230509235247-record-picker.js +0 -121
- package/dist/server/migrations/20230510235247-form-field.d.ts +0 -13
- package/dist/server/migrations/20230510235247-form-field.js +0 -100
- package/dist/server/migrations/20230522231231-association-field.d.ts +0 -13
- package/dist/server/migrations/20230522231231-association-field.js +0 -74
- package/dist/server/migrations/20231015125000-support-filter-blocks-in-select-record-drawer.d.ts +0 -13
- package/dist/server/migrations/20231015125000-support-filter-blocks-in-select-record-drawer.js +0 -55
- package/dist/server/model.d.ts +0 -14
- package/dist/server/model.js +0 -42
- package/dist/server/repository.d.ts +0 -101
- package/dist/server/repository.js +0 -980
- package/dist/server/server-hooks/hooks/bind-menu-to-role.d.ts +0 -13
- package/dist/server/server-hooks/hooks/bind-menu-to-role.js +0 -49
- package/dist/server/server-hooks/hooks/factory.d.ts +0 -14
- package/dist/server/server-hooks/hooks/factory.js +0 -42
- package/dist/server/server-hooks/hooks/index.d.ts +0 -14
- package/dist/server/server-hooks/hooks/index.js +0 -45
- package/dist/server/server-hooks/hooks/remove-parents-if-no-children.d.ts +0 -14
- package/dist/server/server-hooks/hooks/remove-parents-if-no-children.js +0 -44
- package/dist/server/server-hooks/hooks/remove-schema.d.ts +0 -14
- package/dist/server/server-hooks/hooks/remove-schema.js +0 -51
- package/dist/server/server-hooks/index.d.ts +0 -33
- package/dist/server/server-hooks/index.js +0 -174
- package/dist/server/server-hooks/model.d.ts +0 -11
- package/dist/server/server-hooks/model.js +0 -38
- package/dist/server/server.d.ts +0 -17
- package/dist/server/server.js +0 -117
- package/dist/swagger/index.d.ts +0 -334
- package/dist/swagger/index.js +0 -363
|
@@ -1,13 +0,0 @@
|
|
|
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 declare function bindMenuToRole({ schemaInstance, db, options }: {
|
|
10
|
-
schemaInstance: any;
|
|
11
|
-
db: any;
|
|
12
|
-
options: any;
|
|
13
|
-
}): Promise<void>;
|
|
@@ -1,49 +0,0 @@
|
|
|
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 bind_menu_to_role_exports = {};
|
|
28
|
-
__export(bind_menu_to_role_exports, {
|
|
29
|
-
bindMenuToRole: () => bindMenuToRole
|
|
30
|
-
});
|
|
31
|
-
module.exports = __toCommonJS(bind_menu_to_role_exports);
|
|
32
|
-
async function bindMenuToRole({ schemaInstance, db, options }) {
|
|
33
|
-
const { transaction } = options;
|
|
34
|
-
const addNewMenuRoles = await db.getRepository("roles").find({
|
|
35
|
-
filter: {
|
|
36
|
-
allowNewMenu: true
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
for (const role of addNewMenuRoles) {
|
|
40
|
-
await db.getRepository("roles.menuUiSchemas", role.get("name")).add({
|
|
41
|
-
tk: schemaInstance.get("x-uid"),
|
|
42
|
-
transaction
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
47
|
-
0 && (module.exports = {
|
|
48
|
-
bindMenuToRole
|
|
49
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
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 { HookType } from '../index';
|
|
10
|
-
export declare function hookFactory(hookType: HookType, hookName: string, hookFunc: any): {
|
|
11
|
-
hookType: HookType;
|
|
12
|
-
hookName: string;
|
|
13
|
-
hookFunc: any;
|
|
14
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
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 factory_exports = {};
|
|
28
|
-
__export(factory_exports, {
|
|
29
|
-
hookFactory: () => hookFactory
|
|
30
|
-
});
|
|
31
|
-
module.exports = __toCommonJS(factory_exports);
|
|
32
|
-
function hookFactory(hookType, hookName, hookFunc) {
|
|
33
|
-
return {
|
|
34
|
-
hookType,
|
|
35
|
-
hookName,
|
|
36
|
-
hookFunc
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
-
0 && (module.exports = {
|
|
41
|
-
hookFactory
|
|
42
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
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
|
-
declare const hooks: {
|
|
10
|
-
hookType: import("..").HookType;
|
|
11
|
-
hookName: string;
|
|
12
|
-
hookFunc: any;
|
|
13
|
-
}[];
|
|
14
|
-
export { hooks };
|
|
@@ -1,45 +0,0 @@
|
|
|
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 hooks_exports = {};
|
|
28
|
-
__export(hooks_exports, {
|
|
29
|
-
hooks: () => hooks
|
|
30
|
-
});
|
|
31
|
-
module.exports = __toCommonJS(hooks_exports);
|
|
32
|
-
var import_bind_menu_to_role = require("./bind-menu-to-role");
|
|
33
|
-
var import_factory = require("./factory");
|
|
34
|
-
var import_remove_parents_if_no_children = require("./remove-parents-if-no-children");
|
|
35
|
-
var import_remove_schema = require("./remove-schema");
|
|
36
|
-
const hooks = [
|
|
37
|
-
(0, import_factory.hookFactory)("onCollectionDestroy", "removeSchema", import_remove_schema.removeSchema),
|
|
38
|
-
(0, import_factory.hookFactory)("onCollectionFieldDestroy", "removeSchema", import_remove_schema.removeSchema),
|
|
39
|
-
(0, import_factory.hookFactory)("onSelfCreate", "bindMenuToRole", import_bind_menu_to_role.bindMenuToRole),
|
|
40
|
-
(0, import_factory.hookFactory)("onSelfMove", "removeParentsIfNoChildren", import_remove_parents_if_no_children.removeParentsIfNoChildren)
|
|
41
|
-
];
|
|
42
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
43
|
-
0 && (module.exports = {
|
|
44
|
-
hooks
|
|
45
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
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 declare function removeParentsIfNoChildren({ schemaInstance, db, options, params }: {
|
|
10
|
-
schemaInstance: any;
|
|
11
|
-
db: any;
|
|
12
|
-
options: any;
|
|
13
|
-
params: any;
|
|
14
|
-
}): Promise<void>;
|
|
@@ -1,44 +0,0 @@
|
|
|
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 remove_parents_if_no_children_exports = {};
|
|
28
|
-
__export(remove_parents_if_no_children_exports, {
|
|
29
|
-
removeParentsIfNoChildren: () => removeParentsIfNoChildren
|
|
30
|
-
});
|
|
31
|
-
module.exports = __toCommonJS(remove_parents_if_no_children_exports);
|
|
32
|
-
async function removeParentsIfNoChildren({ schemaInstance, db, options, params }) {
|
|
33
|
-
const { transaction, oldParentUid } = options;
|
|
34
|
-
const uiSchemaRepository = db.getRepository("uiSchemas");
|
|
35
|
-
await uiSchemaRepository.recursivelyRemoveIfNoChildren({
|
|
36
|
-
transaction,
|
|
37
|
-
uid: oldParentUid,
|
|
38
|
-
breakRemoveOn: params == null ? void 0 : params.breakRemoveOn
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
42
|
-
0 && (module.exports = {
|
|
43
|
-
removeParentsIfNoChildren
|
|
44
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
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 declare function removeSchema({ schemaInstance, options, db, params }: {
|
|
10
|
-
schemaInstance: any;
|
|
11
|
-
options: any;
|
|
12
|
-
db: any;
|
|
13
|
-
params: any;
|
|
14
|
-
}): Promise<void>;
|
|
@@ -1,51 +0,0 @@
|
|
|
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 remove_schema_exports = {};
|
|
28
|
-
__export(remove_schema_exports, {
|
|
29
|
-
removeSchema: () => removeSchema
|
|
30
|
-
});
|
|
31
|
-
module.exports = __toCommonJS(remove_schema_exports);
|
|
32
|
-
async function removeSchema({ schemaInstance, options, db, params }) {
|
|
33
|
-
const { transaction } = options;
|
|
34
|
-
const uiSchemaRepository = db.getRepository("uiSchemas");
|
|
35
|
-
const uid = schemaInstance.get("x-uid");
|
|
36
|
-
if (params == null ? void 0 : params.removeParentsIfNoChildren) {
|
|
37
|
-
await uiSchemaRepository.removeEmptyParents({
|
|
38
|
-
uid,
|
|
39
|
-
breakRemoveOn: params["breakRemoveOn"],
|
|
40
|
-
transaction
|
|
41
|
-
});
|
|
42
|
-
} else {
|
|
43
|
-
await uiSchemaRepository.remove(uid, {
|
|
44
|
-
transaction
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
49
|
-
0 && (module.exports = {
|
|
50
|
-
removeSchema
|
|
51
|
-
});
|
|
@@ -1,33 +0,0 @@
|
|
|
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 { Database } from '@nocobase/database';
|
|
10
|
-
export type HookType = 'onSelfDestroy' | 'onCollectionDestroy' | 'onCollectionFieldDestroy' | 'onAnyCollectionFieldDestroy' | 'onSelfCreate' | 'onSelfSave' | 'onSelfMove';
|
|
11
|
-
export declare class ServerHooks {
|
|
12
|
-
protected db: Database;
|
|
13
|
-
hooks: Map<HookType, Map<string, any>>;
|
|
14
|
-
constructor(db: Database);
|
|
15
|
-
registerHooks(): void;
|
|
16
|
-
listen(): void;
|
|
17
|
-
protected callSchemaInstanceHooksByType(schemaInstance: any, options: any, type: HookType): Promise<void>;
|
|
18
|
-
protected onUiSchemaMove(schemaInstance: any, options: any): Promise<void>;
|
|
19
|
-
protected onCollectionDestroy(collectionModel: any, options: any): Promise<void>;
|
|
20
|
-
protected onAnyCollectionFieldDestroy(fieldModel: any, options: any): Promise<void>;
|
|
21
|
-
protected onCollectionFieldDestroy(fieldModel: any, options: any): Promise<void>;
|
|
22
|
-
protected onUiSchemaCreate(schemaInstance: any, options: any): Promise<void>;
|
|
23
|
-
protected onUiSchemaSave(schemaInstance: any, options: any): Promise<void>;
|
|
24
|
-
protected findHooksAndCall(hooksFilter: any, hooksArgs: any, transaction: any): Promise<void>;
|
|
25
|
-
/**
|
|
26
|
-
* register a server hook function
|
|
27
|
-
* @param type type of server hook
|
|
28
|
-
* @param name name of server hook
|
|
29
|
-
* @param hookFunc server hook function
|
|
30
|
-
*/
|
|
31
|
-
register(type: HookType, name: string, hookFunc: any): void;
|
|
32
|
-
remove(type: HookType, name: string): void;
|
|
33
|
-
}
|
|
@@ -1,174 +0,0 @@
|
|
|
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 server_hooks_exports = {};
|
|
28
|
-
__export(server_hooks_exports, {
|
|
29
|
-
ServerHooks: () => ServerHooks
|
|
30
|
-
});
|
|
31
|
-
module.exports = __toCommonJS(server_hooks_exports);
|
|
32
|
-
var import_hooks = require("./hooks");
|
|
33
|
-
class ServerHooks {
|
|
34
|
-
constructor(db) {
|
|
35
|
-
this.db = db;
|
|
36
|
-
this.listen();
|
|
37
|
-
this.registerHooks();
|
|
38
|
-
}
|
|
39
|
-
hooks = /* @__PURE__ */ new Map();
|
|
40
|
-
registerHooks() {
|
|
41
|
-
import_hooks.hooks.forEach((hook) => this.register(hook.hookType, hook.hookName, hook.hookFunc));
|
|
42
|
-
}
|
|
43
|
-
listen() {
|
|
44
|
-
this.db.on("fields.afterDestroy", async (model, options) => {
|
|
45
|
-
await this.onCollectionFieldDestroy(model, options);
|
|
46
|
-
await this.onAnyCollectionFieldDestroy(model, options);
|
|
47
|
-
});
|
|
48
|
-
this.db.on("collections.afterDestroy", async (model, options) => {
|
|
49
|
-
await this.onCollectionDestroy(model, options);
|
|
50
|
-
});
|
|
51
|
-
this.db.on("uiSchemas.afterCreateWithAssociations", async (model, options) => {
|
|
52
|
-
await this.onUiSchemaCreate(model, options);
|
|
53
|
-
});
|
|
54
|
-
this.db.on("uiSchemaMove", async (model, options) => {
|
|
55
|
-
await this.onUiSchemaMove(model, options);
|
|
56
|
-
});
|
|
57
|
-
this.db.on("uiSchemas.afterSave", async (model, options) => {
|
|
58
|
-
await this.onUiSchemaSave(model, options);
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
async callSchemaInstanceHooksByType(schemaInstance, options, type) {
|
|
62
|
-
var _a;
|
|
63
|
-
const { transaction } = options;
|
|
64
|
-
const hooks2 = schemaInstance.getServerHooksByType(type);
|
|
65
|
-
for (const hook of hooks2) {
|
|
66
|
-
const hookFunc = (_a = this.hooks.get(type)) == null ? void 0 : _a.get(hook["method"]);
|
|
67
|
-
await (hookFunc == null ? void 0 : hookFunc({
|
|
68
|
-
schemaInstance,
|
|
69
|
-
options,
|
|
70
|
-
db: this.db,
|
|
71
|
-
params: hook["params"]
|
|
72
|
-
}));
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
async onUiSchemaMove(schemaInstance, options) {
|
|
76
|
-
await this.callSchemaInstanceHooksByType(schemaInstance, options, "onSelfMove");
|
|
77
|
-
}
|
|
78
|
-
async onCollectionDestroy(collectionModel, options) {
|
|
79
|
-
const { transaction } = options;
|
|
80
|
-
await this.findHooksAndCall(
|
|
81
|
-
{
|
|
82
|
-
type: "onCollectionDestroy",
|
|
83
|
-
collection: collectionModel.get("name")
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
collectionInstance: collectionModel,
|
|
87
|
-
options
|
|
88
|
-
},
|
|
89
|
-
transaction
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
async onAnyCollectionFieldDestroy(fieldModel, options) {
|
|
93
|
-
const { transaction } = options;
|
|
94
|
-
const collectionName = fieldModel.get("collectionName");
|
|
95
|
-
await this.findHooksAndCall(
|
|
96
|
-
{
|
|
97
|
-
type: "onAnyCollectionFieldDestroy",
|
|
98
|
-
collection: collectionName
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
collectionFieldInstance: fieldModel,
|
|
102
|
-
options
|
|
103
|
-
},
|
|
104
|
-
transaction
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
async onCollectionFieldDestroy(fieldModel, options) {
|
|
108
|
-
const { transaction } = options;
|
|
109
|
-
const collectionName = fieldModel.get("collectionName");
|
|
110
|
-
const fieldName = fieldModel.get("name");
|
|
111
|
-
await this.findHooksAndCall(
|
|
112
|
-
{
|
|
113
|
-
type: "onCollectionFieldDestroy",
|
|
114
|
-
collection: collectionName,
|
|
115
|
-
field: fieldName
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
collectionFieldInstance: fieldModel,
|
|
119
|
-
options
|
|
120
|
-
},
|
|
121
|
-
transaction
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
async onUiSchemaCreate(schemaInstance, options) {
|
|
125
|
-
await this.callSchemaInstanceHooksByType(schemaInstance, options, "onSelfCreate");
|
|
126
|
-
}
|
|
127
|
-
async onUiSchemaSave(schemaInstance, options) {
|
|
128
|
-
await this.callSchemaInstanceHooksByType(schemaInstance, options, "onSelfSave");
|
|
129
|
-
}
|
|
130
|
-
async findHooksAndCall(hooksFilter, hooksArgs, transaction) {
|
|
131
|
-
var _a;
|
|
132
|
-
const hooks2 = await this.db.getRepository("uiSchemaServerHooks").find({
|
|
133
|
-
filter: hooksFilter,
|
|
134
|
-
appends: ["uiSchema"],
|
|
135
|
-
transaction
|
|
136
|
-
});
|
|
137
|
-
for (const hookRecord of hooks2) {
|
|
138
|
-
const hoodMethodName = hookRecord.get("method");
|
|
139
|
-
const hookFunc = (_a = this.hooks.get(hookRecord.get("type"))) == null ? void 0 : _a.get(hoodMethodName);
|
|
140
|
-
if (hookFunc) {
|
|
141
|
-
await hookFunc({
|
|
142
|
-
...hooksArgs,
|
|
143
|
-
schemaInstance: hookRecord.uiSchema,
|
|
144
|
-
db: this.db,
|
|
145
|
-
params: hookRecord.get("params")
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* register a server hook function
|
|
152
|
-
* @param type type of server hook
|
|
153
|
-
* @param name name of server hook
|
|
154
|
-
* @param hookFunc server hook function
|
|
155
|
-
*/
|
|
156
|
-
register(type, name, hookFunc) {
|
|
157
|
-
if (!this.hooks.has(type)) {
|
|
158
|
-
this.hooks.set(type, /* @__PURE__ */ new Map());
|
|
159
|
-
}
|
|
160
|
-
const hookTypeMap = this.hooks.get(type);
|
|
161
|
-
hookTypeMap.set(name, hookFunc);
|
|
162
|
-
}
|
|
163
|
-
remove(type, name) {
|
|
164
|
-
if (!this.hooks.has(type)) {
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
const hookTypeMap = this.hooks.get(type);
|
|
168
|
-
hookTypeMap.delete(name);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
172
|
-
0 && (module.exports = {
|
|
173
|
-
ServerHooks
|
|
174
|
-
});
|
|
@@ -1,11 +0,0 @@
|
|
|
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 { Model } from '@nocobase/database';
|
|
10
|
-
export declare class ServerHookModel extends Model {
|
|
11
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
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 model_exports = {};
|
|
28
|
-
__export(model_exports, {
|
|
29
|
-
ServerHookModel: () => ServerHookModel
|
|
30
|
-
});
|
|
31
|
-
module.exports = __toCommonJS(model_exports);
|
|
32
|
-
var import_database = require("@nocobase/database");
|
|
33
|
-
class ServerHookModel extends import_database.Model {
|
|
34
|
-
}
|
|
35
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
-
0 && (module.exports = {
|
|
37
|
-
ServerHookModel
|
|
38
|
-
});
|
package/dist/server/server.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
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 { Plugin } from '@nocobase/server';
|
|
10
|
-
import { ServerHooks } from './server-hooks';
|
|
11
|
-
export declare class PluginUISchemaStorageServer extends Plugin {
|
|
12
|
-
serverHooks: ServerHooks;
|
|
13
|
-
registerRepository(): void;
|
|
14
|
-
beforeLoad(): Promise<void>;
|
|
15
|
-
load(): Promise<void>;
|
|
16
|
-
}
|
|
17
|
-
export default PluginUISchemaStorageServer;
|