@nocobase/actions 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.
- package/package.json +5 -5
- package/lib/actions/add.d.ts +0 -10
- package/lib/actions/add.js +0 -49
- package/lib/actions/create.d.ts +0 -10
- package/lib/actions/create.js +0 -51
- package/lib/actions/destroy.d.ts +0 -10
- package/lib/actions/destroy.js +0 -49
- package/lib/actions/first-or-create.d.ts +0 -9
- package/lib/actions/first-or-create.js +0 -37
- package/lib/actions/get.d.ts +0 -9
- package/lib/actions/get.js +0 -40
- package/lib/actions/index.d.ts +0 -20
- package/lib/actions/index.js +0 -52
- package/lib/actions/list.d.ts +0 -10
- package/lib/actions/list.js +0 -104
- package/lib/actions/move.d.ts +0 -26
- package/lib/actions/move.js +0 -166
- package/lib/actions/proxy-to-repository.d.ts +0 -10
- package/lib/actions/proxy-to-repository.js +0 -59
- package/lib/actions/remove.d.ts +0 -9
- package/lib/actions/remove.js +0 -37
- package/lib/actions/set.d.ts +0 -9
- package/lib/actions/set.js +0 -37
- package/lib/actions/toggle.d.ts +0 -10
- package/lib/actions/toggle.js +0 -48
- package/lib/actions/update-or-create.d.ts +0 -9
- package/lib/actions/update-or-create.js +0 -37
- package/lib/actions/update.d.ts +0 -9
- package/lib/actions/update.js +0 -49
- package/lib/constants.d.ts +0 -10
- package/lib/constants.js +0 -39
- package/lib/index.d.ts +0 -29
- package/lib/index.js +0 -75
- package/lib/utils.d.ts +0 -16
- package/lib/utils.js +0 -69
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/actions",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0-alpha.20240710084543",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "AGPL-3.0",
|
|
6
6
|
"main": "./lib/index.js",
|
|
7
7
|
"types": "./lib/index.d.ts",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@nocobase/cache": "1.
|
|
10
|
-
"@nocobase/database": "1.
|
|
11
|
-
"@nocobase/resourcer": "1.
|
|
9
|
+
"@nocobase/cache": "1.3.0-alpha.20240710084543",
|
|
10
|
+
"@nocobase/database": "1.3.0-alpha.20240710084543",
|
|
11
|
+
"@nocobase/resourcer": "1.3.0-alpha.20240710084543"
|
|
12
12
|
},
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
15
15
|
"url": "git+https://github.com/nocobase/nocobase.git",
|
|
16
16
|
"directory": "packages/actions"
|
|
17
17
|
},
|
|
18
|
-
"gitHead": "
|
|
18
|
+
"gitHead": "07a8b596fc64a9779a194cb9b0dc2ca7570ed9d4"
|
|
19
19
|
}
|
package/lib/actions/add.d.ts
DELETED
|
@@ -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 '..';
|
|
10
|
-
export declare function add(ctx: Context, next: any): Promise<any>;
|
package/lib/actions/add.js
DELETED
|
@@ -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 __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 add_exports = {};
|
|
29
|
-
__export(add_exports, {
|
|
30
|
-
add: () => add
|
|
31
|
-
});
|
|
32
|
-
module.exports = __toCommonJS(add_exports);
|
|
33
|
-
var import_database = require("@nocobase/database");
|
|
34
|
-
var import_utils = require("../utils");
|
|
35
|
-
async function add(ctx, next) {
|
|
36
|
-
const repository = (0, import_utils.getRepositoryFromParams)(ctx);
|
|
37
|
-
if (!(repository instanceof import_database.MultipleRelationRepository || repository instanceof import_database.HasManyRepository || repository instanceof import_database.ArrayFieldRepository)) {
|
|
38
|
-
return await next();
|
|
39
|
-
}
|
|
40
|
-
const filterByTk = ctx.action.params.filterByTk || ctx.action.params.filterByTks || ctx.action.params.values;
|
|
41
|
-
await repository.add(filterByTk);
|
|
42
|
-
ctx.status = 200;
|
|
43
|
-
await next();
|
|
44
|
-
}
|
|
45
|
-
__name(add, "add");
|
|
46
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
47
|
-
0 && (module.exports = {
|
|
48
|
-
add
|
|
49
|
-
});
|
package/lib/actions/create.d.ts
DELETED
|
@@ -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 '..';
|
|
10
|
-
export declare function create(ctx: Context, next: any): Promise<void>;
|
package/lib/actions/create.js
DELETED
|
@@ -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 __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 create_exports = {};
|
|
29
|
-
__export(create_exports, {
|
|
30
|
-
create: () => create
|
|
31
|
-
});
|
|
32
|
-
module.exports = __toCommonJS(create_exports);
|
|
33
|
-
var import_utils = require("../utils");
|
|
34
|
-
async function create(ctx, next) {
|
|
35
|
-
const repository = (0, import_utils.getRepositoryFromParams)(ctx);
|
|
36
|
-
const { whitelist, blacklist, updateAssociationValues, values } = ctx.action.params;
|
|
37
|
-
const instance = await repository.create({
|
|
38
|
-
values,
|
|
39
|
-
whitelist,
|
|
40
|
-
blacklist,
|
|
41
|
-
updateAssociationValues,
|
|
42
|
-
context: ctx
|
|
43
|
-
});
|
|
44
|
-
ctx.body = instance;
|
|
45
|
-
await next();
|
|
46
|
-
}
|
|
47
|
-
__name(create, "create");
|
|
48
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
49
|
-
0 && (module.exports = {
|
|
50
|
-
create
|
|
51
|
-
});
|
package/lib/actions/destroy.d.ts
DELETED
|
@@ -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 '../index';
|
|
10
|
-
export declare function destroy(ctx: Context, next: any): Promise<void>;
|
package/lib/actions/destroy.js
DELETED
|
@@ -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 __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 destroy_exports = {};
|
|
29
|
-
__export(destroy_exports, {
|
|
30
|
-
destroy: () => destroy
|
|
31
|
-
});
|
|
32
|
-
module.exports = __toCommonJS(destroy_exports);
|
|
33
|
-
var import_utils = require("../utils");
|
|
34
|
-
async function destroy(ctx, next) {
|
|
35
|
-
const repository = (0, import_utils.getRepositoryFromParams)(ctx);
|
|
36
|
-
const { filterByTk, filter } = ctx.action.params;
|
|
37
|
-
const instance = await repository.destroy({
|
|
38
|
-
filter,
|
|
39
|
-
filterByTk,
|
|
40
|
-
context: ctx
|
|
41
|
-
});
|
|
42
|
-
ctx.body = instance;
|
|
43
|
-
await next();
|
|
44
|
-
}
|
|
45
|
-
__name(destroy, "destroy");
|
|
46
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
47
|
-
0 && (module.exports = {
|
|
48
|
-
destroy
|
|
49
|
-
});
|
|
@@ -1,9 +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 const firstOrCreate: (ctx: import("..").Context, next: any) => Promise<void>;
|
|
@@ -1,37 +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 first_or_create_exports = {};
|
|
28
|
-
__export(first_or_create_exports, {
|
|
29
|
-
firstOrCreate: () => firstOrCreate
|
|
30
|
-
});
|
|
31
|
-
module.exports = __toCommonJS(first_or_create_exports);
|
|
32
|
-
var import_proxy_to_repository = require("./proxy-to-repository");
|
|
33
|
-
const firstOrCreate = (0, import_proxy_to_repository.proxyToRepository)(["values", "filterKeys"], "firstOrCreate");
|
|
34
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
-
0 && (module.exports = {
|
|
36
|
-
firstOrCreate
|
|
37
|
-
});
|
package/lib/actions/get.d.ts
DELETED
|
@@ -1,9 +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 const get: (ctx: import("..").Context, next: any) => Promise<void>;
|
package/lib/actions/get.js
DELETED
|
@@ -1,40 +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 get_exports = {};
|
|
28
|
-
__export(get_exports, {
|
|
29
|
-
get: () => get
|
|
30
|
-
});
|
|
31
|
-
module.exports = __toCommonJS(get_exports);
|
|
32
|
-
var import_proxy_to_repository = require("./proxy-to-repository");
|
|
33
|
-
const get = (0, import_proxy_to_repository.proxyToRepository)(
|
|
34
|
-
["filterByTk", "fields", "appends", "except", "filter", "targetCollection"],
|
|
35
|
-
"findOne"
|
|
36
|
-
);
|
|
37
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
-
0 && (module.exports = {
|
|
39
|
-
get
|
|
40
|
-
});
|
package/lib/actions/index.d.ts
DELETED
|
@@ -1,20 +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 './list';
|
|
10
|
-
export * from './create';
|
|
11
|
-
export * from './update';
|
|
12
|
-
export * from './destroy';
|
|
13
|
-
export * from './get';
|
|
14
|
-
export * from './add';
|
|
15
|
-
export * from './set';
|
|
16
|
-
export * from './remove';
|
|
17
|
-
export * from './toggle';
|
|
18
|
-
export * from './move';
|
|
19
|
-
export * from './first-or-create';
|
|
20
|
-
export * from './update-or-create';
|
package/lib/actions/index.js
DELETED
|
@@ -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 __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 actions_exports = {};
|
|
25
|
-
module.exports = __toCommonJS(actions_exports);
|
|
26
|
-
__reExport(actions_exports, require("./list"), module.exports);
|
|
27
|
-
__reExport(actions_exports, require("./create"), module.exports);
|
|
28
|
-
__reExport(actions_exports, require("./update"), module.exports);
|
|
29
|
-
__reExport(actions_exports, require("./destroy"), module.exports);
|
|
30
|
-
__reExport(actions_exports, require("./get"), module.exports);
|
|
31
|
-
__reExport(actions_exports, require("./add"), module.exports);
|
|
32
|
-
__reExport(actions_exports, require("./set"), module.exports);
|
|
33
|
-
__reExport(actions_exports, require("./remove"), module.exports);
|
|
34
|
-
__reExport(actions_exports, require("./toggle"), module.exports);
|
|
35
|
-
__reExport(actions_exports, require("./move"), module.exports);
|
|
36
|
-
__reExport(actions_exports, require("./first-or-create"), module.exports);
|
|
37
|
-
__reExport(actions_exports, require("./update-or-create"), module.exports);
|
|
38
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
-
0 && (module.exports = {
|
|
40
|
-
...require("./list"),
|
|
41
|
-
...require("./create"),
|
|
42
|
-
...require("./update"),
|
|
43
|
-
...require("./destroy"),
|
|
44
|
-
...require("./get"),
|
|
45
|
-
...require("./add"),
|
|
46
|
-
...require("./set"),
|
|
47
|
-
...require("./remove"),
|
|
48
|
-
...require("./toggle"),
|
|
49
|
-
...require("./move"),
|
|
50
|
-
...require("./first-or-create"),
|
|
51
|
-
...require("./update-or-create")
|
|
52
|
-
});
|
package/lib/actions/list.d.ts
DELETED
|
@@ -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 '..';
|
|
10
|
-
export declare function list(ctx: Context, next: any): Promise<void>;
|
package/lib/actions/list.js
DELETED
|
@@ -1,104 +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
|
-
var import_constants = require("../constants");
|
|
36
|
-
function totalPage(total, pageSize) {
|
|
37
|
-
return Math.ceil(total / pageSize);
|
|
38
|
-
}
|
|
39
|
-
__name(totalPage, "totalPage");
|
|
40
|
-
function findArgs(ctx) {
|
|
41
|
-
var _a;
|
|
42
|
-
const resourceName = ctx.action.resourceName;
|
|
43
|
-
const params = ctx.action.params;
|
|
44
|
-
if (params.tree) {
|
|
45
|
-
if ((0, import_utils.isValidFilter)(params.filter)) {
|
|
46
|
-
params.tree = false;
|
|
47
|
-
} else {
|
|
48
|
-
const [collectionName, associationName] = resourceName.split(".");
|
|
49
|
-
const collection = ctx.db.getCollection(resourceName);
|
|
50
|
-
if (collection.options.tree && !(associationName && collectionName === collection.name)) {
|
|
51
|
-
const foreignKey = ((_a = collection.treeParentField) == null ? void 0 : _a.foreignKey) || "parentId";
|
|
52
|
-
(0, import_utils.assign)(params, { filter: { [foreignKey]: null } }, { filter: "andMerge" });
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
const { tree, fields, filter, appends, except, sort } = params;
|
|
57
|
-
return { tree, filter, fields, appends, except, sort };
|
|
58
|
-
}
|
|
59
|
-
__name(findArgs, "findArgs");
|
|
60
|
-
async function listWithPagination(ctx) {
|
|
61
|
-
const { page = import_constants.DEFAULT_PAGE, pageSize = import_constants.DEFAULT_PER_PAGE } = ctx.action.params;
|
|
62
|
-
const repository = (0, import_utils2.getRepositoryFromParams)(ctx);
|
|
63
|
-
const options = {
|
|
64
|
-
context: ctx,
|
|
65
|
-
...findArgs(ctx),
|
|
66
|
-
...(0, import_utils2.pageArgsToLimitArgs)(parseInt(String(page)), parseInt(String(pageSize)))
|
|
67
|
-
};
|
|
68
|
-
Object.keys(options).forEach((key) => {
|
|
69
|
-
if (options[key] === void 0) {
|
|
70
|
-
delete options[key];
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
const [rows, count] = await repository.findAndCount(options);
|
|
74
|
-
ctx.body = {
|
|
75
|
-
count,
|
|
76
|
-
rows,
|
|
77
|
-
page: Number(page),
|
|
78
|
-
pageSize: Number(pageSize),
|
|
79
|
-
totalPage: totalPage(count, pageSize)
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
__name(listWithPagination, "listWithPagination");
|
|
83
|
-
async function listWithNonPaged(ctx) {
|
|
84
|
-
const repository = (0, import_utils2.getRepositoryFromParams)(ctx);
|
|
85
|
-
const rows = await repository.find({ context: ctx, ...findArgs(ctx) });
|
|
86
|
-
ctx.body = rows;
|
|
87
|
-
}
|
|
88
|
-
__name(listWithNonPaged, "listWithNonPaged");
|
|
89
|
-
async function list(ctx, next) {
|
|
90
|
-
const { paginate } = ctx.action.params;
|
|
91
|
-
if (paginate === false || paginate === "false") {
|
|
92
|
-
await listWithNonPaged(ctx);
|
|
93
|
-
ctx.paginate = false;
|
|
94
|
-
} else {
|
|
95
|
-
await listWithPagination(ctx);
|
|
96
|
-
ctx.paginate = true;
|
|
97
|
-
}
|
|
98
|
-
await next();
|
|
99
|
-
}
|
|
100
|
-
__name(list, "list");
|
|
101
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
102
|
-
0 && (module.exports = {
|
|
103
|
-
list
|
|
104
|
-
});
|
package/lib/actions/move.d.ts
DELETED
|
@@ -1,26 +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 'sequelize';
|
|
10
|
-
import { Collection, SortField, TargetKey } from '@nocobase/database';
|
|
11
|
-
import { Context } from '..';
|
|
12
|
-
export declare function move(ctx: Context, next: any): Promise<void>;
|
|
13
|
-
interface MoveOptions {
|
|
14
|
-
insertAfter?: boolean;
|
|
15
|
-
}
|
|
16
|
-
export declare class SortAbleCollection {
|
|
17
|
-
collection: Collection;
|
|
18
|
-
field: SortField;
|
|
19
|
-
scopeKey: string;
|
|
20
|
-
constructor(collection: Collection, fieldName?: string);
|
|
21
|
-
move(sourceInstanceId: TargetKey, targetInstanceId: TargetKey, options?: MoveOptions): Promise<void>;
|
|
22
|
-
changeScope(sourceInstanceId: TargetKey, targetScope: any, method?: string): Promise<void>;
|
|
23
|
-
sticky(sourceInstanceId: TargetKey): Promise<void>;
|
|
24
|
-
sameScopeMove(sourceInstance: Model, targetInstance: Model, options: MoveOptions): Promise<void>;
|
|
25
|
-
}
|
|
26
|
-
export {};
|
package/lib/actions/move.js
DELETED
|
@@ -1,166 +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
|
-
SortAbleCollection: () => SortAbleCollection,
|
|
31
|
-
move: () => move
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(move_exports);
|
|
34
|
-
var import_sequelize = require("sequelize");
|
|
35
|
-
var import_database = require("@nocobase/database");
|
|
36
|
-
var import_utils = require("../utils");
|
|
37
|
-
async function move(ctx, next) {
|
|
38
|
-
const repository = ctx.databaseRepository || (0, import_utils.getRepositoryFromParams)(ctx);
|
|
39
|
-
const { sourceId, targetId, targetScope, sticky, method } = ctx.action.params;
|
|
40
|
-
let sortField = ctx.action.params.sortField;
|
|
41
|
-
if (repository instanceof import_database.BelongsToManyRepository) {
|
|
42
|
-
throw new Error("Sorting association as 'belongs-to-many' type is not supported.");
|
|
43
|
-
}
|
|
44
|
-
if (repository instanceof import_database.HasManyRepository && !sortField) {
|
|
45
|
-
sortField = `${repository.association.foreignKey}Sort`;
|
|
46
|
-
}
|
|
47
|
-
const sortAbleCollection = new SortAbleCollection(repository.collection, sortField);
|
|
48
|
-
if (sourceId && targetId) {
|
|
49
|
-
await sortAbleCollection.move(sourceId, targetId, {
|
|
50
|
-
insertAfter: method === "insertAfter"
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
if (sourceId && targetScope) {
|
|
54
|
-
await sortAbleCollection.changeScope(sourceId, targetScope, method);
|
|
55
|
-
}
|
|
56
|
-
if (sourceId && sticky) {
|
|
57
|
-
await sortAbleCollection.sticky(sourceId);
|
|
58
|
-
}
|
|
59
|
-
ctx.body = "ok";
|
|
60
|
-
await next();
|
|
61
|
-
}
|
|
62
|
-
__name(move, "move");
|
|
63
|
-
const _SortAbleCollection = class _SortAbleCollection {
|
|
64
|
-
collection;
|
|
65
|
-
field;
|
|
66
|
-
scopeKey;
|
|
67
|
-
constructor(collection, fieldName = "sort") {
|
|
68
|
-
this.collection = collection;
|
|
69
|
-
this.field = collection.getField(fieldName);
|
|
70
|
-
if (!(this.field instanceof import_database.SortField)) {
|
|
71
|
-
throw new Error(`${fieldName} is not a sort field`);
|
|
72
|
-
}
|
|
73
|
-
this.scopeKey = this.field.get("scopeKey");
|
|
74
|
-
}
|
|
75
|
-
// insert source position to target position
|
|
76
|
-
async move(sourceInstanceId, targetInstanceId, options = {}) {
|
|
77
|
-
const sourceInstance = await this.collection.repository.findById(sourceInstanceId);
|
|
78
|
-
const targetInstance = await this.collection.repository.findById(targetInstanceId);
|
|
79
|
-
if (this.scopeKey && sourceInstance.get(this.scopeKey) !== targetInstance.get(this.scopeKey)) {
|
|
80
|
-
await sourceInstance.update({
|
|
81
|
-
[this.scopeKey]: targetInstance.get(this.scopeKey)
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
await this.sameScopeMove(sourceInstance, targetInstance, options);
|
|
85
|
-
}
|
|
86
|
-
async changeScope(sourceInstanceId, targetScope, method) {
|
|
87
|
-
const sourceInstance = await this.collection.repository.findById(sourceInstanceId);
|
|
88
|
-
const targetScopeValue = targetScope[this.scopeKey];
|
|
89
|
-
if (targetScopeValue && sourceInstance.get(this.scopeKey) !== targetScopeValue) {
|
|
90
|
-
await sourceInstance.update(
|
|
91
|
-
{
|
|
92
|
-
[this.scopeKey]: targetScopeValue
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
silent: false
|
|
96
|
-
}
|
|
97
|
-
);
|
|
98
|
-
if (method === "prepend") {
|
|
99
|
-
await this.sticky(sourceInstanceId);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
async sticky(sourceInstanceId) {
|
|
104
|
-
const sourceInstance = await this.collection.repository.findById(sourceInstanceId);
|
|
105
|
-
await sourceInstance.update(
|
|
106
|
-
{
|
|
107
|
-
[this.field.get("name")]: 0
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
silent: true
|
|
111
|
-
}
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
async sameScopeMove(sourceInstance, targetInstance, options) {
|
|
115
|
-
const fieldName = this.field.get("name");
|
|
116
|
-
const sourceSort = sourceInstance.get(fieldName);
|
|
117
|
-
let targetSort = targetInstance.get(fieldName);
|
|
118
|
-
if (options.insertAfter) {
|
|
119
|
-
targetSort = targetSort + 1;
|
|
120
|
-
}
|
|
121
|
-
const scopeValue = this.scopeKey ? sourceInstance.get(this.scopeKey) : null;
|
|
122
|
-
let updateCondition;
|
|
123
|
-
let change;
|
|
124
|
-
if (targetSort > sourceSort) {
|
|
125
|
-
updateCondition = {
|
|
126
|
-
[import_sequelize.Op.gt]: sourceSort,
|
|
127
|
-
[import_sequelize.Op.lte]: targetSort
|
|
128
|
-
};
|
|
129
|
-
change = -1;
|
|
130
|
-
} else {
|
|
131
|
-
updateCondition = {
|
|
132
|
-
[import_sequelize.Op.lt]: sourceSort,
|
|
133
|
-
[import_sequelize.Op.gte]: targetSort
|
|
134
|
-
};
|
|
135
|
-
change = 1;
|
|
136
|
-
}
|
|
137
|
-
const where = {
|
|
138
|
-
[fieldName]: updateCondition
|
|
139
|
-
};
|
|
140
|
-
if (scopeValue) {
|
|
141
|
-
where[this.scopeKey] = {
|
|
142
|
-
[import_sequelize.Op.eq]: scopeValue
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
await this.collection.model.increment(fieldName, {
|
|
146
|
-
where,
|
|
147
|
-
by: change,
|
|
148
|
-
silent: true
|
|
149
|
-
});
|
|
150
|
-
await sourceInstance.update(
|
|
151
|
-
{
|
|
152
|
-
[fieldName]: targetSort
|
|
153
|
-
},
|
|
154
|
-
{
|
|
155
|
-
silent: true
|
|
156
|
-
}
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
__name(_SortAbleCollection, "SortAbleCollection");
|
|
161
|
-
let SortAbleCollection = _SortAbleCollection;
|
|
162
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
163
|
-
0 && (module.exports = {
|
|
164
|
-
SortAbleCollection,
|
|
165
|
-
move
|
|
166
|
-
});
|
|
@@ -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 '../index';
|
|
10
|
-
export declare function proxyToRepository(paramKeys: string[], repositoryMethod: string): (ctx: Context, next: any) => Promise<void>;
|
|
@@ -1,59 +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
|
-
var import_utils = require("../utils");
|
|
45
|
-
function proxyToRepository(paramKeys, repositoryMethod) {
|
|
46
|
-
return async function(ctx, next) {
|
|
47
|
-
const repository = (0, import_utils.getRepositoryFromParams)(ctx);
|
|
48
|
-
const callObj = import_lodash.default.pick(ctx.action.params, paramKeys);
|
|
49
|
-
callObj.context = ctx;
|
|
50
|
-
ctx.body = await repository[repositoryMethod](callObj);
|
|
51
|
-
ctx.status = 200;
|
|
52
|
-
await next();
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
__name(proxyToRepository, "proxyToRepository");
|
|
56
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
57
|
-
0 && (module.exports = {
|
|
58
|
-
proxyToRepository
|
|
59
|
-
});
|
package/lib/actions/remove.d.ts
DELETED
|
@@ -1,9 +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 const remove: (ctx: import("..").Context, next: any) => Promise<void>;
|
package/lib/actions/remove.js
DELETED
|
@@ -1,37 +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_exports = {};
|
|
28
|
-
__export(remove_exports, {
|
|
29
|
-
remove: () => remove
|
|
30
|
-
});
|
|
31
|
-
module.exports = __toCommonJS(remove_exports);
|
|
32
|
-
var import_utils = require("../utils");
|
|
33
|
-
const remove = (0, import_utils.RelationRepositoryActionBuilder)("remove");
|
|
34
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
-
0 && (module.exports = {
|
|
36
|
-
remove
|
|
37
|
-
});
|
package/lib/actions/set.d.ts
DELETED
|
@@ -1,9 +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 const set: (ctx: import("..").Context, next: any) => Promise<void>;
|
package/lib/actions/set.js
DELETED
|
@@ -1,37 +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 set_exports = {};
|
|
28
|
-
__export(set_exports, {
|
|
29
|
-
set: () => set
|
|
30
|
-
});
|
|
31
|
-
module.exports = __toCommonJS(set_exports);
|
|
32
|
-
var import_utils = require("../utils");
|
|
33
|
-
const set = (0, import_utils.RelationRepositoryActionBuilder)("set");
|
|
34
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
-
0 && (module.exports = {
|
|
36
|
-
set
|
|
37
|
-
});
|
package/lib/actions/toggle.d.ts
DELETED
|
@@ -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 '..';
|
|
10
|
-
export declare function toggle(ctx: Context, next: any): Promise<any>;
|
package/lib/actions/toggle.js
DELETED
|
@@ -1,48 +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 toggle_exports = {};
|
|
29
|
-
__export(toggle_exports, {
|
|
30
|
-
toggle: () => toggle
|
|
31
|
-
});
|
|
32
|
-
module.exports = __toCommonJS(toggle_exports);
|
|
33
|
-
var import_database = require("@nocobase/database");
|
|
34
|
-
var import_utils = require("../utils");
|
|
35
|
-
async function toggle(ctx, next) {
|
|
36
|
-
const repository = (0, import_utils.getRepositoryFromParams)(ctx);
|
|
37
|
-
if (!(repository instanceof import_database.BelongsToManyRepository)) {
|
|
38
|
-
return await next();
|
|
39
|
-
}
|
|
40
|
-
await repository.toggle(ctx.action.params.values);
|
|
41
|
-
ctx.body = "ok";
|
|
42
|
-
await next();
|
|
43
|
-
}
|
|
44
|
-
__name(toggle, "toggle");
|
|
45
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
46
|
-
0 && (module.exports = {
|
|
47
|
-
toggle
|
|
48
|
-
});
|
|
@@ -1,9 +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 const updateOrCreate: (ctx: import("..").Context, next: any) => Promise<void>;
|
|
@@ -1,37 +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 update_or_create_exports = {};
|
|
28
|
-
__export(update_or_create_exports, {
|
|
29
|
-
updateOrCreate: () => updateOrCreate
|
|
30
|
-
});
|
|
31
|
-
module.exports = __toCommonJS(update_or_create_exports);
|
|
32
|
-
var import_proxy_to_repository = require("./proxy-to-repository");
|
|
33
|
-
const updateOrCreate = (0, import_proxy_to_repository.proxyToRepository)(["values", "filterKeys"], "updateOrCreate");
|
|
34
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
-
0 && (module.exports = {
|
|
36
|
-
updateOrCreate
|
|
37
|
-
});
|
package/lib/actions/update.d.ts
DELETED
|
@@ -1,9 +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 const update: (ctx: import("..").Context, next: any) => Promise<void>;
|
package/lib/actions/update.js
DELETED
|
@@ -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 update_exports = {};
|
|
28
|
-
__export(update_exports, {
|
|
29
|
-
update: () => update
|
|
30
|
-
});
|
|
31
|
-
module.exports = __toCommonJS(update_exports);
|
|
32
|
-
var import_proxy_to_repository = require("./proxy-to-repository");
|
|
33
|
-
const update = (0, import_proxy_to_repository.proxyToRepository)(
|
|
34
|
-
[
|
|
35
|
-
"filterByTk",
|
|
36
|
-
"values",
|
|
37
|
-
"whitelist",
|
|
38
|
-
"blacklist",
|
|
39
|
-
"filter",
|
|
40
|
-
"updateAssociationValues",
|
|
41
|
-
"forceUpdate",
|
|
42
|
-
"targetCollection"
|
|
43
|
-
],
|
|
44
|
-
"update"
|
|
45
|
-
);
|
|
46
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
47
|
-
0 && (module.exports = {
|
|
48
|
-
update
|
|
49
|
-
});
|
package/lib/constants.d.ts
DELETED
|
@@ -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
|
-
export declare const DEFAULT_PAGE = 1;
|
|
10
|
-
export declare const DEFAULT_PER_PAGE = 20;
|
package/lib/constants.js
DELETED
|
@@ -1,39 +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 constants_exports = {};
|
|
28
|
-
__export(constants_exports, {
|
|
29
|
-
DEFAULT_PAGE: () => DEFAULT_PAGE,
|
|
30
|
-
DEFAULT_PER_PAGE: () => DEFAULT_PER_PAGE
|
|
31
|
-
});
|
|
32
|
-
module.exports = __toCommonJS(constants_exports);
|
|
33
|
-
const DEFAULT_PAGE = 1;
|
|
34
|
-
const DEFAULT_PER_PAGE = 20;
|
|
35
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
-
0 && (module.exports = {
|
|
37
|
-
DEFAULT_PAGE,
|
|
38
|
-
DEFAULT_PER_PAGE
|
|
39
|
-
});
|
package/lib/index.d.ts
DELETED
|
@@ -1,29 +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 { Cache } from '@nocobase/cache';
|
|
10
|
-
import { Database } from '@nocobase/database';
|
|
11
|
-
import { Action } from '@nocobase/resourcer';
|
|
12
|
-
import Koa from 'koa';
|
|
13
|
-
import * as actions from './actions';
|
|
14
|
-
export * as utils from './utils';
|
|
15
|
-
export * from './constants';
|
|
16
|
-
export type Next = () => Promise<any>;
|
|
17
|
-
export interface Context extends Koa.Context {
|
|
18
|
-
db: Database;
|
|
19
|
-
cache: Cache;
|
|
20
|
-
action: Action;
|
|
21
|
-
body: any;
|
|
22
|
-
app: any;
|
|
23
|
-
[key: string]: any;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* @internal
|
|
27
|
-
*/
|
|
28
|
-
export declare function registerActions(api: any): void;
|
|
29
|
-
export default actions;
|
package/lib/index.js
DELETED
|
@@ -1,75 +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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
30
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
31
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
32
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
33
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
34
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
35
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
36
|
-
mod
|
|
37
|
-
));
|
|
38
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
39
|
-
var src_exports = {};
|
|
40
|
-
__export(src_exports, {
|
|
41
|
-
default: () => src_default,
|
|
42
|
-
registerActions: () => registerActions,
|
|
43
|
-
utils: () => utils
|
|
44
|
-
});
|
|
45
|
-
module.exports = __toCommonJS(src_exports);
|
|
46
|
-
var import_lodash = __toESM(require("lodash"));
|
|
47
|
-
var actions = __toESM(require("./actions"));
|
|
48
|
-
var utils = __toESM(require("./utils"));
|
|
49
|
-
__reExport(src_exports, require("./constants"), module.exports);
|
|
50
|
-
function registerActions(api) {
|
|
51
|
-
api.actions(
|
|
52
|
-
import_lodash.default.pick(actions, [
|
|
53
|
-
"add",
|
|
54
|
-
"create",
|
|
55
|
-
"destroy",
|
|
56
|
-
"get",
|
|
57
|
-
"list",
|
|
58
|
-
"remove",
|
|
59
|
-
"set",
|
|
60
|
-
"toggle",
|
|
61
|
-
"update",
|
|
62
|
-
"move",
|
|
63
|
-
"firstOrCreate",
|
|
64
|
-
"updateOrCreate"
|
|
65
|
-
])
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
__name(registerActions, "registerActions");
|
|
69
|
-
var src_default = actions;
|
|
70
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
71
|
-
0 && (module.exports = {
|
|
72
|
-
registerActions,
|
|
73
|
-
utils,
|
|
74
|
-
...require("./constants")
|
|
75
|
-
});
|
package/lib/utils.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
|
-
import { MultipleRelationRepository, Repository } from '@nocobase/database';
|
|
10
|
-
import { Context } from '.';
|
|
11
|
-
export declare function pageArgsToLimitArgs(page: number, pageSize: number): {
|
|
12
|
-
offset: number;
|
|
13
|
-
limit: number;
|
|
14
|
-
};
|
|
15
|
-
export declare function getRepositoryFromParams(ctx: Context): Repository<any, any> | MultipleRelationRepository;
|
|
16
|
-
export declare function RelationRepositoryActionBuilder(method: 'remove' | 'set'): (ctx: Context, next: any) => Promise<void>;
|
package/lib/utils.js
DELETED
|
@@ -1,69 +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
|
-
RelationRepositoryActionBuilder: () => RelationRepositoryActionBuilder,
|
|
31
|
-
getRepositoryFromParams: () => getRepositoryFromParams,
|
|
32
|
-
pageArgsToLimitArgs: () => pageArgsToLimitArgs
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(utils_exports);
|
|
35
|
-
function pageArgsToLimitArgs(page, pageSize) {
|
|
36
|
-
return {
|
|
37
|
-
offset: (page - 1) * pageSize,
|
|
38
|
-
limit: pageSize
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
__name(pageArgsToLimitArgs, "pageArgsToLimitArgs");
|
|
42
|
-
function getRepositoryFromParams(ctx) {
|
|
43
|
-
const { resourceName, sourceId, actionName } = ctx.action;
|
|
44
|
-
if (sourceId === "_" && ["get", "list"].includes(actionName)) {
|
|
45
|
-
const collection = ctx.db.getCollection(resourceName);
|
|
46
|
-
return ctx.db.getRepository(collection.name);
|
|
47
|
-
}
|
|
48
|
-
if (sourceId) {
|
|
49
|
-
return ctx.db.getRepository(resourceName, sourceId);
|
|
50
|
-
}
|
|
51
|
-
return ctx.db.getRepository(resourceName);
|
|
52
|
-
}
|
|
53
|
-
__name(getRepositoryFromParams, "getRepositoryFromParams");
|
|
54
|
-
function RelationRepositoryActionBuilder(method) {
|
|
55
|
-
return async function(ctx, next) {
|
|
56
|
-
const repository = getRepositoryFromParams(ctx);
|
|
57
|
-
const filterByTk = ctx.action.params.filterByTk || ctx.action.params.filterByTks || ctx.action.params.values;
|
|
58
|
-
await repository[method](filterByTk);
|
|
59
|
-
ctx.status = 200;
|
|
60
|
-
await next();
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
__name(RelationRepositoryActionBuilder, "RelationRepositoryActionBuilder");
|
|
64
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
65
|
-
0 && (module.exports = {
|
|
66
|
-
RelationRepositoryActionBuilder,
|
|
67
|
-
getRepositoryFromParams,
|
|
68
|
-
pageArgsToLimitArgs
|
|
69
|
-
});
|