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