@nocobase/data-source-manager 1.2.13-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.
@@ -1,136 +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 __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 __name = (target, value) => __defProp(target, "name", { value, configurable: true });
17
- var __export = (target, all) => {
18
- for (var name in all)
19
- __defProp(target, name, { get: all[name], enumerable: true });
20
- };
21
- var __copyProps = (to, from, except, desc) => {
22
- if (from && typeof from === "object" || typeof from === "function") {
23
- for (let key of __getOwnPropNames(from))
24
- if (!__hasOwnProp.call(to, key) && key !== except)
25
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
26
- }
27
- return to;
28
- };
29
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
30
- // If the importer is in node compatibility mode or this is not an ESM
31
- // file that has been converted to a CommonJS file using a Babel-
32
- // compatible transform (i.e. "__esModule" has not been set), then set
33
- // "default" to the CommonJS "module.exports" for node compatibility.
34
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
35
- mod
36
- ));
37
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
38
- var data_source_exports = {};
39
- __export(data_source_exports, {
40
- DataSource: () => DataSource
41
- });
42
- module.exports = __toCommonJS(data_source_exports);
43
- var import_acl = require("@nocobase/acl");
44
- var import_resourcer = require("@nocobase/resourcer");
45
- var import_events = __toESM(require("events"));
46
- var import_koa_compose = __toESM(require("koa-compose"));
47
- var import_load_default_actions = require("./load-default-actions");
48
- const _DataSource = class _DataSource extends import_events.default {
49
- constructor(options) {
50
- super();
51
- this.options = options;
52
- this.init(options);
53
- }
54
- collectionManager;
55
- resourceManager;
56
- acl;
57
- get name() {
58
- return this.options.name;
59
- }
60
- static testConnection(options) {
61
- return Promise.resolve(true);
62
- }
63
- init(options = {}) {
64
- this.acl = this.createACL();
65
- this.resourceManager = this.createResourceManager({
66
- prefix: process.env.API_BASE_PATH,
67
- ...options.resourceManager
68
- });
69
- this.collectionManager = this.createCollectionManager(options);
70
- this.resourceManager.registerActionHandlers((0, import_load_default_actions.loadDefaultActions)());
71
- if (options.acl !== false) {
72
- this.resourceManager.use(this.acl.middleware(), { tag: "acl", after: ["auth"] });
73
- }
74
- }
75
- middleware(middlewares = []) {
76
- const dataSource = this;
77
- if (!this["_used"]) {
78
- for (const [fn, options] of middlewares) {
79
- this.resourceManager.use(fn, options);
80
- }
81
- this["_used"] = true;
82
- }
83
- return async (ctx, next) => {
84
- ctx.dataSource = dataSource;
85
- ctx.getCurrentRepository = () => {
86
- const { resourceName, resourceOf } = ctx.action;
87
- return this.collectionManager.getRepository(resourceName, resourceOf);
88
- };
89
- return (0, import_koa_compose.default)([this.collectionToResourceMiddleware(), this.resourceManager.middleware()])(ctx, next);
90
- };
91
- }
92
- createACL() {
93
- return new import_acl.ACL();
94
- }
95
- createResourceManager(options) {
96
- return new import_resourcer.ResourceManager(options);
97
- }
98
- async load(options = {}) {
99
- }
100
- collectionToResourceMiddleware() {
101
- return async (ctx, next) => {
102
- const params = (0, import_resourcer.parseRequest)(
103
- {
104
- path: ctx.request.path,
105
- method: ctx.request.method
106
- },
107
- {
108
- prefix: this.resourceManager.options.prefix,
109
- accessors: this.resourceManager.options.accessors
110
- }
111
- );
112
- if (!params) {
113
- return next();
114
- }
115
- const resourceName = (0, import_resourcer.getNameByParams)(params);
116
- if (this.resourceManager.isDefined(resourceName)) {
117
- return next();
118
- }
119
- const splitResult = resourceName.split(".");
120
- const collectionName = splitResult[0];
121
- if (!this.collectionManager.hasCollection(collectionName)) {
122
- return next();
123
- }
124
- this.resourceManager.define({
125
- name: resourceName
126
- });
127
- return next();
128
- };
129
- }
130
- };
131
- __name(_DataSource, "DataSource");
132
- let DataSource = _DataSource;
133
- // Annotate the CommonJS export names for ESM import in node:
134
- 0 && (module.exports = {
135
- DataSource
136
- });
@@ -1,10 +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 { Context } from '@nocobase/actions';
10
- export declare function list(ctx: Context, next: any): Promise<void>;
@@ -1,103 +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 __name = (target, value) => __defProp(target, "name", { value, configurable: true });
15
- var __export = (target, all) => {
16
- for (var name in all)
17
- __defProp(target, name, { get: all[name], enumerable: true });
18
- };
19
- var __copyProps = (to, from, except, desc) => {
20
- if (from && typeof from === "object" || typeof from === "function") {
21
- for (let key of __getOwnPropNames(from))
22
- if (!__hasOwnProp.call(to, key) && key !== except)
23
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
24
- }
25
- return to;
26
- };
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var list_exports = {};
29
- __export(list_exports, {
30
- list: () => list
31
- });
32
- module.exports = __toCommonJS(list_exports);
33
- var import_utils = require("@nocobase/utils");
34
- var import_utils2 = require("./utils");
35
- function totalPage(total, pageSize) {
36
- return Math.ceil(total / pageSize);
37
- }
38
- __name(totalPage, "totalPage");
39
- function findArgs(ctx) {
40
- var _a;
41
- const resourceName = ctx.action.resourceName;
42
- const params = ctx.action.params;
43
- if (params.tree) {
44
- if ((0, import_utils.isValidFilter)(params.filter)) {
45
- params.tree = false;
46
- } else {
47
- const [collectionName, associationName] = resourceName.split(".");
48
- const collection = ctx.dataSource.collectionManager.getCollection(resourceName);
49
- if (collection.options.tree && !(associationName && collectionName === collection.name)) {
50
- const foreignKey = ((_a = collection.treeParentField) == null ? void 0 : _a.foreignKey) || "parentId";
51
- (0, import_utils.assign)(params, { filter: { [foreignKey]: null } }, { filter: "andMerge" });
52
- }
53
- }
54
- }
55
- const { tree, fields, filter, appends, except, sort } = params;
56
- return { tree, filter, fields, appends, except, sort };
57
- }
58
- __name(findArgs, "findArgs");
59
- async function listWithPagination(ctx) {
60
- const { page = 1, pageSize = 50 } = ctx.action.params;
61
- const repository = ctx.getCurrentRepository();
62
- const options = {
63
- context: ctx,
64
- ...findArgs(ctx),
65
- ...(0, import_utils2.pageArgsToLimitArgs)(parseInt(String(page)), parseInt(String(pageSize)))
66
- };
67
- Object.keys(options).forEach((key) => {
68
- if (options[key] === void 0) {
69
- delete options[key];
70
- }
71
- });
72
- const [rows, count] = await repository.findAndCount(options);
73
- ctx.body = {
74
- count,
75
- rows,
76
- page: Number(page),
77
- pageSize: Number(pageSize),
78
- totalPage: totalPage(count, pageSize)
79
- };
80
- }
81
- __name(listWithPagination, "listWithPagination");
82
- async function listWithNonPaged(ctx) {
83
- const repository = ctx.getCurrentRepository();
84
- const rows = await repository.find({ context: ctx, ...findArgs(ctx) });
85
- ctx.body = rows;
86
- }
87
- __name(listWithNonPaged, "listWithNonPaged");
88
- async function list(ctx, next) {
89
- const { paginate } = ctx.action.params;
90
- if (paginate === false || paginate === "false") {
91
- await listWithNonPaged(ctx);
92
- ctx.paginate = false;
93
- } else {
94
- await listWithPagination(ctx);
95
- ctx.paginate = true;
96
- }
97
- await next();
98
- }
99
- __name(list, "list");
100
- // Annotate the CommonJS export names for ESM import in node:
101
- 0 && (module.exports = {
102
- list
103
- });
@@ -1,10 +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 { Context } from '@nocobase/actions';
10
- export declare function createMoveAction(databaseMoveAction: any): (ctx: Context, next: any) => Promise<any>;
@@ -1,52 +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 __name = (target, value) => __defProp(target, "name", { value, configurable: true });
15
- var __export = (target, all) => {
16
- for (var name in all)
17
- __defProp(target, name, { get: all[name], enumerable: true });
18
- };
19
- var __copyProps = (to, from, except, desc) => {
20
- if (from && typeof from === "object" || typeof from === "function") {
21
- for (let key of __getOwnPropNames(from))
22
- if (!__hasOwnProp.call(to, key) && key !== except)
23
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
24
- }
25
- return to;
26
- };
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var move_exports = {};
29
- __export(move_exports, {
30
- createMoveAction: () => createMoveAction
31
- });
32
- module.exports = __toCommonJS(move_exports);
33
- function createMoveAction(databaseMoveAction) {
34
- return /* @__PURE__ */ __name(async function move(ctx, next) {
35
- const repository = ctx.getCurrentRepository();
36
- if (repository.move) {
37
- ctx.body = await repository.move(ctx.action.params);
38
- await next();
39
- return;
40
- }
41
- if (repository.database) {
42
- ctx.databaseRepository = repository;
43
- return databaseMoveAction(ctx, next);
44
- }
45
- throw new Error(`Repository can not handle action move for ${ctx.action.resourceName}`);
46
- }, "move");
47
- }
48
- __name(createMoveAction, "createMoveAction");
49
- // Annotate the CommonJS export names for ESM import in node:
50
- 0 && (module.exports = {
51
- createMoveAction
52
- });
@@ -1,10 +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 { Context } from '@nocobase/actions';
10
- export declare function proxyToRepository(paramKeys: string[] | ((ctx: any) => object), repositoryMethod: string): (ctx: Context, next: () => Promise<void>) => Promise<void>;
@@ -1,62 +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 __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 __name = (target, value) => __defProp(target, "name", { value, configurable: true });
17
- var __export = (target, all) => {
18
- for (var name in all)
19
- __defProp(target, name, { get: all[name], enumerable: true });
20
- };
21
- var __copyProps = (to, from, except, desc) => {
22
- if (from && typeof from === "object" || typeof from === "function") {
23
- for (let key of __getOwnPropNames(from))
24
- if (!__hasOwnProp.call(to, key) && key !== except)
25
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
26
- }
27
- return to;
28
- };
29
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
30
- // If the importer is in node compatibility mode or this is not an ESM
31
- // file that has been converted to a CommonJS file using a Babel-
32
- // compatible transform (i.e. "__esModule" has not been set), then set
33
- // "default" to the CommonJS "module.exports" for node compatibility.
34
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
35
- mod
36
- ));
37
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
38
- var proxy_to_repository_exports = {};
39
- __export(proxy_to_repository_exports, {
40
- proxyToRepository: () => proxyToRepository
41
- });
42
- module.exports = __toCommonJS(proxy_to_repository_exports);
43
- var import_lodash = __toESM(require("lodash"));
44
- function proxyToRepository(paramKeys, repositoryMethod) {
45
- return async function(ctx, next) {
46
- const repository = ctx.getCurrentRepository();
47
- const callObj = typeof paramKeys === "function" ? paramKeys(ctx) : { ...import_lodash.default.pick(ctx.action.params, paramKeys), context: ctx };
48
- const dataSource = ctx.dataSource;
49
- if (!repository[repositoryMethod]) {
50
- throw new Error(
51
- `Repository can not handle action ${repositoryMethod} for ${ctx.action.resourceName} in ${dataSource.name}`
52
- );
53
- }
54
- ctx.body = await repository[repositoryMethod](callObj);
55
- await next();
56
- };
57
- }
58
- __name(proxyToRepository, "proxyToRepository");
59
- // Annotate the CommonJS export names for ESM import in node:
60
- 0 && (module.exports = {
61
- proxyToRepository
62
- });
@@ -1,12 +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 pageArgsToLimitArgs(page: number, pageSize: number): {
10
- offset: number;
11
- limit: number;
12
- };
@@ -1,43 +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 __name = (target, value) => __defProp(target, "name", { value, configurable: true });
15
- var __export = (target, all) => {
16
- for (var name in all)
17
- __defProp(target, name, { get: all[name], enumerable: true });
18
- };
19
- var __copyProps = (to, from, except, desc) => {
20
- if (from && typeof from === "object" || typeof from === "function") {
21
- for (let key of __getOwnPropNames(from))
22
- if (!__hasOwnProp.call(to, key) && key !== except)
23
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
24
- }
25
- return to;
26
- };
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var utils_exports = {};
29
- __export(utils_exports, {
30
- pageArgsToLimitArgs: () => pageArgsToLimitArgs
31
- });
32
- module.exports = __toCommonJS(utils_exports);
33
- function pageArgsToLimitArgs(page, pageSize) {
34
- return {
35
- offset: (page - 1) * pageSize,
36
- limit: pageSize
37
- };
38
- }
39
- __name(pageArgsToLimitArgs, "pageArgsToLimitArgs");
40
- // Annotate the CommonJS export names for ESM import in node:
41
- 0 && (module.exports = {
42
- pageArgsToLimitArgs
43
- });
package/lib/index.d.ts DELETED
@@ -1,16 +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 * from './collection-manager';
10
- export * from './data-source';
11
- export * from './data-source-manager';
12
- export * from './sequelize-collection-manager';
13
- export * from './sequelize-data-source';
14
- export * from './load-default-actions';
15
- export * from './types';
16
- export * from './utils';
package/lib/index.js DELETED
@@ -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 __copyProps = (to, from, except, desc) => {
15
- if (from && typeof from === "object" || typeof from === "function") {
16
- for (let key of __getOwnPropNames(from))
17
- if (!__hasOwnProp.call(to, key) && key !== except)
18
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
- }
20
- return to;
21
- };
22
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
23
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
- var src_exports = {};
25
- module.exports = __toCommonJS(src_exports);
26
- __reExport(src_exports, require("./collection-manager"), module.exports);
27
- __reExport(src_exports, require("./data-source"), module.exports);
28
- __reExport(src_exports, require("./data-source-manager"), module.exports);
29
- __reExport(src_exports, require("./sequelize-collection-manager"), module.exports);
30
- __reExport(src_exports, require("./sequelize-data-source"), module.exports);
31
- __reExport(src_exports, require("./load-default-actions"), module.exports);
32
- __reExport(src_exports, require("./types"), module.exports);
33
- __reExport(src_exports, require("./utils"), module.exports);
34
- // Annotate the CommonJS export names for ESM import in node:
35
- 0 && (module.exports = {
36
- ...require("./collection-manager"),
37
- ...require("./data-source"),
38
- ...require("./data-source-manager"),
39
- ...require("./sequelize-collection-manager"),
40
- ...require("./sequelize-data-source"),
41
- ...require("./load-default-actions"),
42
- ...require("./types"),
43
- ...require("./utils")
44
- });
@@ -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
- import { list } from './default-actions/list';
10
- export declare function loadDefaultActions(): {
11
- list: typeof list;
12
- move: (ctx: import("@nocobase/actions").Context, next: any) => Promise<any>;
13
- };
@@ -1,120 +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 __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 __name = (target, value) => __defProp(target, "name", { value, configurable: true });
17
- var __export = (target, all) => {
18
- for (var name in all)
19
- __defProp(target, name, { get: all[name], enumerable: true });
20
- };
21
- var __copyProps = (to, from, except, desc) => {
22
- if (from && typeof from === "object" || typeof from === "function") {
23
- for (let key of __getOwnPropNames(from))
24
- if (!__hasOwnProp.call(to, key) && key !== except)
25
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
26
- }
27
- return to;
28
- };
29
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
30
- // If the importer is in node compatibility mode or this is not an ESM
31
- // file that has been converted to a CommonJS file using a Babel-
32
- // compatible transform (i.e. "__esModule" has not been set), then set
33
- // "default" to the CommonJS "module.exports" for node compatibility.
34
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
35
- mod
36
- ));
37
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
38
- var load_default_actions_exports = {};
39
- __export(load_default_actions_exports, {
40
- loadDefaultActions: () => loadDefaultActions
41
- });
42
- module.exports = __toCommonJS(load_default_actions_exports);
43
- var import_list = require("./default-actions/list");
44
- var import_move = require("./default-actions/move");
45
- var import_proxy_to_repository = require("./default-actions/proxy-to-repository");
46
- var import_actions = __toESM(require("@nocobase/actions"));
47
- const actions = {
48
- add: {
49
- params(ctx) {
50
- return ctx.action.params.filterByTk || ctx.action.params.filterByTks || ctx.action.params.values;
51
- },
52
- method: "add"
53
- },
54
- create: {
55
- params: ["whitelist", "blacklist", "updateAssociationValues", "values"],
56
- method: "create"
57
- },
58
- get: {
59
- params: ["filterByTk", "fields", "appends", "except", "filter", "targetCollection"],
60
- method: "findOne"
61
- },
62
- update: {
63
- params: [
64
- "filterByTk",
65
- "values",
66
- "whitelist",
67
- "blacklist",
68
- "filter",
69
- "updateAssociationValues",
70
- "forceUpdate",
71
- "targetCollection"
72
- ],
73
- method: "update"
74
- },
75
- destroy: {
76
- params: ["filterByTk", "filter"],
77
- method: "destroy"
78
- },
79
- firstOrCreate: {
80
- params: ["values", "filterKeys"],
81
- method: "firstOrCreate"
82
- },
83
- updateOrCreate: {
84
- params: ["values", "filterKeys"],
85
- method: "updateOrCreate"
86
- },
87
- remove: {
88
- params(ctx) {
89
- return ctx.action.params.filterByTk || ctx.action.params.filterByTks || ctx.action.params.values;
90
- },
91
- method: "remove"
92
- },
93
- set: {
94
- params(ctx) {
95
- return ctx.action.params.filterByTk || ctx.action.params.filterByTks || ctx.action.params.values;
96
- },
97
- method: "set"
98
- },
99
- toggle: {
100
- params(ctx) {
101
- return ctx.action.params.values;
102
- },
103
- method: "toggle"
104
- }
105
- };
106
- function loadDefaultActions() {
107
- return {
108
- ...Object.keys(actions).reduce((carry, key) => {
109
- carry[key] = (0, import_proxy_to_repository.proxyToRepository)(actions[key].params, actions[key].method);
110
- return carry;
111
- }, {}),
112
- list: import_list.list,
113
- move: (0, import_move.createMoveAction)(import_actions.default.move)
114
- };
115
- }
116
- __name(loadDefaultActions, "loadDefaultActions");
117
- // Annotate the CommonJS export names for ESM import in node:
118
- 0 && (module.exports = {
119
- loadDefaultActions
120
- });
@@ -1,18 +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 { IModel, IRepository } from './types';
10
- export declare class Repository implements IRepository {
11
- create(options: any): Promise<void>;
12
- update(options: any): Promise<void>;
13
- find(options?: any): Promise<IModel[]>;
14
- findOne(options?: any): Promise<IModel>;
15
- destroy(options: any): Promise<void>;
16
- count(options?: any): Promise<Number>;
17
- findAndCount(options?: any): Promise<[IModel[], Number]>;
18
- }