@nocobase/plugin-action-custom-request 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.
Files changed (38) hide show
  1. package/package.json +2 -2
  2. package/dist/client/components/CustomRequestAction.d.ts +0 -15
  3. package/dist/client/components/CustomRequestActionDesigner.d.ts +0 -20
  4. package/dist/client/components/index.d.ts +0 -9
  5. package/dist/client/constants.d.ts +0 -9
  6. package/dist/client/hooks/index.d.ts +0 -11
  7. package/dist/client/hooks/useCustomRequestVariableOptions.d.ts +0 -13
  8. package/dist/client/hooks/useCustomRequestsResource.d.ts +0 -9
  9. package/dist/client/hooks/useCustomizeRequestActionProps.d.ts +0 -11
  10. package/dist/client/hooks/useGetCustomRequest.d.ts +0 -15
  11. package/dist/client/index.d.ts +0 -13
  12. package/dist/client/index.js +0 -10
  13. package/dist/client/initializer/CustomRequestInitializer.d.ts +0 -26
  14. package/dist/client/initializer/index.d.ts +0 -9
  15. package/dist/client/locale.d.ts +0 -12
  16. package/dist/client/schemaSettings.d.ts +0 -10
  17. package/dist/client/schemas/CustomRequestACL.d.ts +0 -35
  18. package/dist/client/schemas/CustomRequestConfigurationFields.d.ts +0 -195
  19. package/dist/client/schemas/index.d.ts +0 -10
  20. package/dist/externalVersion.js +0 -27
  21. package/dist/index.d.ts +0 -10
  22. package/dist/index.js +0 -48
  23. package/dist/locale/ko_KR.json +0 -26
  24. package/dist/locale/zh-CN.json +0 -26
  25. package/dist/server/actions/listByCurrentRole.d.ts +0 -10
  26. package/dist/server/actions/listByCurrentRole.js +0 -51
  27. package/dist/server/actions/send.d.ts +0 -11
  28. package/dist/server/actions/send.js +0 -208
  29. package/dist/server/collections/customRequest.d.ts +0 -10
  30. package/dist/server/collections/customRequest.js +0 -60
  31. package/dist/server/collections/customRequestsRoles.d.ts +0 -10
  32. package/dist/server/collections/customRequestsRoles.js +0 -36
  33. package/dist/server/index.d.ts +0 -9
  34. package/dist/server/index.js +0 -42
  35. package/dist/server/migrations/20240425205017-change-locale-module.d.ts +0 -14
  36. package/dist/server/migrations/20240425205017-change-locale-module.js +0 -51
  37. package/dist/server/plugin.d.ts +0 -22
  38. package/dist/server/plugin.js +0 -79
@@ -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 listByCurrentRole(ctx: Context): 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 listByCurrentRole_exports = {};
28
- __export(listByCurrentRole_exports, {
29
- listByCurrentRole: () => listByCurrentRole
30
- });
31
- module.exports = __toCommonJS(listByCurrentRole_exports);
32
- async function listByCurrentRole(ctx) {
33
- const repo = ctx.db.getRepository("customRequests");
34
- const data = await repo.find({
35
- appends: ["roles"]
36
- });
37
- const crRepo = ctx.db.getRepository("customRequestsRoles");
38
- ctx.body = data.filter((item) => {
39
- return !item.roles.length;
40
- }).map((item) => item.key).concat(
41
- (await crRepo.find({
42
- filter: {
43
- roleName: ctx.state.currentRole
44
- }
45
- })).map((item) => item.customRequestKey)
46
- );
47
- }
48
- // Annotate the CommonJS export names for ESM import in node:
49
- 0 && (module.exports = {
50
- listByCurrentRole
51
- });
@@ -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 { Context, Next } from '@nocobase/actions';
10
- import CustomRequestPlugin from '../plugin';
11
- export declare function send(this: CustomRequestPlugin, ctx: Context, next: Next): Promise<any>;
@@ -1,208 +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 __export = (target, all) => {
17
- for (var name in all)
18
- __defProp(target, name, { get: all[name], enumerable: true });
19
- };
20
- var __copyProps = (to, from, except, desc) => {
21
- if (from && typeof from === "object" || typeof from === "function") {
22
- for (let key of __getOwnPropNames(from))
23
- if (!__hasOwnProp.call(to, key) && key !== except)
24
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
25
- }
26
- return to;
27
- };
28
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
- // If the importer is in node compatibility mode or this is not an ESM
30
- // file that has been converted to a CommonJS file using a Babel-
31
- // compatible transform (i.e. "__esModule" has not been set), then set
32
- // "default" to the CommonJS "module.exports" for node compatibility.
33
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
- mod
35
- ));
36
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
- var send_exports = {};
38
- __export(send_exports, {
39
- send: () => send
40
- });
41
- module.exports = __toCommonJS(send_exports);
42
- var import_utils = require("@nocobase/utils");
43
- var import_evaluators = require("@nocobase/evaluators");
44
- var import_axios = __toESM(require("axios"));
45
- const getHeaders = (headers) => {
46
- return Object.keys(headers).reduce((hds, key) => {
47
- if (key.toLocaleLowerCase().startsWith("x-")) {
48
- hds[key] = headers[key];
49
- }
50
- return hds;
51
- }, {});
52
- };
53
- const arrayToObject = (arr) => {
54
- return arr.reduce((acc, cur) => {
55
- acc[cur.name] = cur.value;
56
- return acc;
57
- }, {});
58
- };
59
- const omitNullAndUndefined = (obj) => {
60
- return Object.keys(obj).reduce((acc, cur) => {
61
- if (obj[cur] !== null && typeof obj[cur] !== "undefined") {
62
- acc[cur] = obj[cur];
63
- }
64
- return acc;
65
- }, {});
66
- };
67
- const CurrentUserVariableRegExp = /{{\s*(currentUser[^}]+)\s*}}/g;
68
- const getCurrentUserAppends = (str, user) => {
69
- const matched = str.matchAll(CurrentUserVariableRegExp);
70
- return Array.from(matched).map((item) => {
71
- const keys = (item == null ? void 0 : item[1].split(".")) || [];
72
- const appendKey = keys[1];
73
- if (keys.length > 2 && !Reflect.has(user || {}, appendKey)) {
74
- return appendKey;
75
- }
76
- }).filter(Boolean);
77
- };
78
- async function send(ctx, next) {
79
- var _a, _b, _c, _d;
80
- const resourceName = ctx.action.resourceName;
81
- const { filterByTk, values = {} } = ctx.action.params;
82
- const {
83
- currentRecord = {
84
- id: 0,
85
- appends: [],
86
- data: {}
87
- }
88
- } = values;
89
- if (ctx.state.currentRole !== "root") {
90
- const crRepo = ctx.db.getRepository("customRequestsRoles");
91
- const hasRoles = await crRepo.find({
92
- filter: {
93
- customRequestKey: filterByTk
94
- }
95
- });
96
- if (hasRoles.length) {
97
- if (!hasRoles.find((item) => item.roleName === ctx.state.currentRole)) {
98
- return ctx.throw(403, "custom request no permission");
99
- }
100
- }
101
- }
102
- const repo = ctx.db.getRepository(resourceName);
103
- const requestConfig = await repo.findOne({
104
- filter: {
105
- key: filterByTk
106
- }
107
- });
108
- if (!requestConfig) {
109
- ctx.throw(404, "request config not found");
110
- }
111
- ctx.withoutDataWrapping = true;
112
- const {
113
- dataSourceKey,
114
- collectionName,
115
- url,
116
- headers = [],
117
- params = [],
118
- data = {},
119
- ...options
120
- } = requestConfig.options || {};
121
- if (!url) {
122
- return ctx.throw(400, ctx.t("Please configure the request settings first", { ns: "action-custom-request" }));
123
- }
124
- let currentRecordValues = {};
125
- if (collectionName && typeof currentRecord.id !== "undefined") {
126
- const app = ctx.app;
127
- const dataSource = app.dataSourceManager.get(dataSourceKey || currentRecord.dataSourceKey || "main");
128
- const recordRepo = dataSource.collectionManager.getRepository(collectionName);
129
- currentRecordValues = ((_a = await recordRepo.findOne({
130
- filterByTk: currentRecord.id,
131
- appends: currentRecord.appends
132
- })) == null ? void 0 : _a.toJSON()) || {};
133
- }
134
- let currentUser = ctx.auth.user;
135
- const userAppends = getCurrentUserAppends(
136
- JSON.stringify(url) + JSON.stringify(headers) + JSON.stringify(params) + JSON.stringify(data),
137
- ctx.auth.user
138
- );
139
- if (userAppends.length) {
140
- currentUser = ((_b = await ctx.db.getRepository("users").findOne({
141
- filterByTk: ctx.auth.user.id,
142
- appends: userAppends
143
- })) == null ? void 0 : _b.toJSON()) || {};
144
- }
145
- const variables = {
146
- currentRecord: {
147
- ...currentRecordValues,
148
- ...currentRecord.data
149
- },
150
- currentUser,
151
- currentTime: (/* @__PURE__ */ new Date()).toISOString()
152
- };
153
- const getParsedValue = (value) => {
154
- const template = (0, import_utils.parse)(value);
155
- template.parameters.forEach(({ key }) => {
156
- (0, import_evaluators.appendArrayColumn)(variables, key);
157
- });
158
- return template(variables);
159
- };
160
- const axiosRequestConfig = {
161
- baseURL: ctx.origin,
162
- ...options,
163
- url: getParsedValue(url),
164
- headers: {
165
- Authorization: "Bearer " + ctx.getBearerToken(),
166
- ...getHeaders(ctx.headers),
167
- ...omitNullAndUndefined(getParsedValue(arrayToObject(headers)))
168
- },
169
- params: getParsedValue(arrayToObject(params)),
170
- data: getParsedValue(data)
171
- };
172
- console.log(axiosRequestConfig);
173
- const requestUrl = import_axios.default.getUri(axiosRequestConfig);
174
- this.logger.info(`custom-request:send:${filterByTk} request url ${requestUrl}`);
175
- this.logger.info(
176
- `custom-request:send:${filterByTk} request config ${JSON.stringify({
177
- ...axiosRequestConfig,
178
- headers: {
179
- ...axiosRequestConfig.headers,
180
- Authorization: null
181
- }
182
- })}`
183
- );
184
- try {
185
- const res = await (0, import_axios.default)(axiosRequestConfig);
186
- this.logger.info(`custom-request:send:${filterByTk} success`);
187
- ctx.body = res.data;
188
- if (res.headers["content-disposition"]) {
189
- ctx.set("Content-Disposition", res.headers["content-disposition"]);
190
- }
191
- } catch (err) {
192
- if (import_axios.default.isAxiosError(err)) {
193
- ctx.status = ((_c = err.response) == null ? void 0 : _c.status) || 500;
194
- ctx.body = ((_d = err.response) == null ? void 0 : _d.data) || { message: err.message };
195
- this.logger.error(
196
- `custom-request:send:${filterByTk} error. status: ${ctx.status}, body: ${typeof ctx.body === "string" ? ctx.body : JSON.stringify(ctx.body)}`
197
- );
198
- } else {
199
- this.logger.error(`custom-request:send:${filterByTk} error. status: ${ctx.status}, message: ${err.message}`);
200
- ctx.throw(500, err == null ? void 0 : err.message);
201
- }
202
- }
203
- return next();
204
- }
205
- // Annotate the CommonJS export names for ESM import in node:
206
- 0 && (module.exports = {
207
- send
208
- });
@@ -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
- declare const _default: import("@nocobase/database").CollectionOptions;
10
- export default _default;
@@ -1,60 +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 customRequest_exports = {};
28
- __export(customRequest_exports, {
29
- default: () => customRequest_default
30
- });
31
- module.exports = __toCommonJS(customRequest_exports);
32
- var import_database = require("@nocobase/database");
33
- var customRequest_default = (0, import_database.defineCollection)({
34
- dumpRules: "required",
35
- name: "customRequests",
36
- autoGenId: false,
37
- fields: [
38
- {
39
- type: "uid",
40
- name: "key",
41
- primaryKey: true
42
- },
43
- {
44
- type: "belongsToMany",
45
- name: "roles",
46
- onDelete: "CASCADE",
47
- through: "customRequestsRoles",
48
- target: "roles",
49
- foreignKey: "customRequestKey",
50
- otherKey: "roleName",
51
- sourceKey: "key",
52
- targetKey: "name"
53
- },
54
- {
55
- type: "json",
56
- name: "options"
57
- // 配置的请求参数都放这里
58
- }
59
- ]
60
- });
@@ -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
- declare const _default: import("@nocobase/database").CollectionOptions;
10
- export default _default;
@@ -1,36 +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 customRequestsRoles_exports = {};
28
- __export(customRequestsRoles_exports, {
29
- default: () => customRequestsRoles_default
30
- });
31
- module.exports = __toCommonJS(customRequestsRoles_exports);
32
- var import_database = require("@nocobase/database");
33
- var customRequestsRoles_default = (0, import_database.defineCollection)({
34
- dumpRules: "required",
35
- name: "customRequestsRoles"
36
- });
@@ -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 { default } from './plugin';
@@ -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 __create = Object.create;
11
- var __defProp = Object.defineProperty;
12
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
13
- var __getOwnPropNames = Object.getOwnPropertyNames;
14
- var __getProtoOf = Object.getPrototypeOf;
15
- var __hasOwnProp = Object.prototype.hasOwnProperty;
16
- var __export = (target, all) => {
17
- for (var name in all)
18
- __defProp(target, name, { get: all[name], enumerable: true });
19
- };
20
- var __copyProps = (to, from, except, desc) => {
21
- if (from && typeof from === "object" || typeof from === "function") {
22
- for (let key of __getOwnPropNames(from))
23
- if (!__hasOwnProp.call(to, key) && key !== except)
24
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
25
- }
26
- return to;
27
- };
28
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
- // If the importer is in node compatibility mode or this is not an ESM
30
- // file that has been converted to a CommonJS file using a Babel-
31
- // compatible transform (i.e. "__esModule" has not been set), then set
32
- // "default" to the CommonJS "module.exports" for node compatibility.
33
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
- mod
35
- ));
36
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
- var server_exports = {};
38
- __export(server_exports, {
39
- default: () => import_plugin.default
40
- });
41
- module.exports = __toCommonJS(server_exports);
42
- var import_plugin = __toESM(require("./plugin"));
@@ -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 { Migration } from '@nocobase/server';
10
- export default class extends Migration {
11
- on: string;
12
- appVersion: string;
13
- up(): Promise<void>;
14
- }
@@ -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 change_locale_module_exports = {};
28
- __export(change_locale_module_exports, {
29
- default: () => change_locale_module_default
30
- });
31
- module.exports = __toCommonJS(change_locale_module_exports);
32
- var import_server = require("@nocobase/server");
33
- class change_locale_module_default extends import_server.Migration {
34
- on = "afterLoad";
35
- // 'beforeLoad' or 'afterLoad'
36
- appVersion = "<1.0.0-alpha.1";
37
- async up() {
38
- const repo = this.db.getRepository("localizationTexts");
39
- if (!repo) {
40
- return;
41
- }
42
- await repo.update({
43
- filter: {
44
- module: "resources.custom-request"
45
- },
46
- values: {
47
- module: "resources.action-custom-request"
48
- }
49
- });
50
- }
51
- }
@@ -1,22 +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 { Logger } from '@nocobase/logger';
10
- import { InstallOptions, Plugin } from '@nocobase/server';
11
- export declare class PluginActionCustomRequestServer extends Plugin {
12
- logger: Logger;
13
- afterAdd(): void;
14
- beforeLoad(): void;
15
- getLogger(): Logger;
16
- load(): Promise<void>;
17
- install(options?: InstallOptions): Promise<void>;
18
- afterEnable(): Promise<void>;
19
- afterDisable(): Promise<void>;
20
- remove(): Promise<void>;
21
- }
22
- export default PluginActionCustomRequestServer;
@@ -1,79 +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 plugin_exports = {};
28
- __export(plugin_exports, {
29
- PluginActionCustomRequestServer: () => PluginActionCustomRequestServer,
30
- default: () => plugin_default
31
- });
32
- module.exports = __toCommonJS(plugin_exports);
33
- var import_server = require("@nocobase/server");
34
- var import_path = require("path");
35
- var import_listByCurrentRole = require("./actions/listByCurrentRole");
36
- var import_send = require("./actions/send");
37
- class PluginActionCustomRequestServer extends import_server.Plugin {
38
- logger;
39
- afterAdd() {
40
- }
41
- beforeLoad() {
42
- this.logger = this.getLogger();
43
- }
44
- getLogger() {
45
- const logger = this.createLogger({
46
- dirname: "custom-request",
47
- filename: "%DATE%.log"
48
- });
49
- return logger;
50
- }
51
- async load() {
52
- await this.importCollections((0, import_path.resolve)(__dirname, "collections"));
53
- this.app.resource({
54
- name: "customRequests",
55
- actions: {
56
- send: import_send.send.bind(this),
57
- listByCurrentRole: import_listByCurrentRole.listByCurrentRole
58
- }
59
- });
60
- this.app.acl.registerSnippet({
61
- name: `ui.${this.name}`,
62
- actions: ["customRequests:*", "roles:list"]
63
- });
64
- this.app.acl.allow("customRequests", ["send", "listByCurrentRole"], "loggedIn");
65
- }
66
- async install(options) {
67
- }
68
- async afterEnable() {
69
- }
70
- async afterDisable() {
71
- }
72
- async remove() {
73
- }
74
- }
75
- var plugin_default = PluginActionCustomRequestServer;
76
- // Annotate the CommonJS export names for ESM import in node:
77
- 0 && (module.exports = {
78
- PluginActionCustomRequestServer
79
- });