@nocobase/resourcer 1.3.44-beta → 1.4.0-alpha.0
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/lib/action.js +1 -1
- package/lib/resourcer.js +10 -9
- package/package.json +3 -3
package/lib/action.js
CHANGED
package/lib/resourcer.js
CHANGED
|
@@ -180,29 +180,30 @@ const _ResourceManager = class _ResourceManager {
|
|
|
180
180
|
this.middlewares.add(middlewares, options);
|
|
181
181
|
}
|
|
182
182
|
middleware({ prefix, accessors, skipIfDataSourceExists = false } = {}) {
|
|
183
|
-
|
|
183
|
+
const self = this;
|
|
184
|
+
return /* @__PURE__ */ __name(async function resourcerMiddleware(ctx, next) {
|
|
184
185
|
if (skipIfDataSourceExists) {
|
|
185
186
|
const dataSource = ctx.get("x-data-source");
|
|
186
187
|
if (dataSource) {
|
|
187
188
|
return next();
|
|
188
189
|
}
|
|
189
190
|
}
|
|
190
|
-
ctx.resourcer =
|
|
191
|
+
ctx.resourcer = self;
|
|
191
192
|
let params = (0, import_utils2.parseRequest)(
|
|
192
193
|
{
|
|
193
194
|
path: ctx.request.path,
|
|
194
195
|
method: ctx.request.method
|
|
195
196
|
},
|
|
196
197
|
{
|
|
197
|
-
prefix:
|
|
198
|
-
accessors:
|
|
198
|
+
prefix: self.options.prefix || prefix,
|
|
199
|
+
accessors: self.options.accessors || accessors
|
|
199
200
|
}
|
|
200
201
|
);
|
|
201
202
|
if (!params) {
|
|
202
203
|
return next();
|
|
203
204
|
}
|
|
204
205
|
try {
|
|
205
|
-
const resource =
|
|
206
|
+
const resource = self.getResource((0, import_utils2.getNameByParams)(params));
|
|
206
207
|
if (resource.options.type && resource.options.type !== "single") {
|
|
207
208
|
params = (0, import_utils2.parseRequest)(
|
|
208
209
|
{
|
|
@@ -211,15 +212,15 @@ const _ResourceManager = class _ResourceManager {
|
|
|
211
212
|
type: resource.options.type
|
|
212
213
|
},
|
|
213
214
|
{
|
|
214
|
-
prefix:
|
|
215
|
-
accessors:
|
|
215
|
+
prefix: self.options.prefix || prefix,
|
|
216
|
+
accessors: self.options.accessors || accessors
|
|
216
217
|
}
|
|
217
218
|
);
|
|
218
219
|
if (!params) {
|
|
219
220
|
return next();
|
|
220
221
|
}
|
|
221
222
|
}
|
|
222
|
-
ctx.action =
|
|
223
|
+
ctx.action = self.getAction((0, import_utils2.getNameByParams)(params), params.actionName).clone();
|
|
223
224
|
ctx.action.setContext(ctx);
|
|
224
225
|
ctx.action.actionName = params.actionName;
|
|
225
226
|
ctx.action.sourceId = params.associatedIndex;
|
|
@@ -245,7 +246,7 @@ const _ResourceManager = class _ResourceManager {
|
|
|
245
246
|
console.log(error);
|
|
246
247
|
return next();
|
|
247
248
|
}
|
|
248
|
-
};
|
|
249
|
+
}, "resourcerMiddleware");
|
|
249
250
|
}
|
|
250
251
|
/**
|
|
251
252
|
* This method is deprecated and should not be used.
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/resourcer",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0-alpha.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
7
7
|
"license": "AGPL-3.0",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@nocobase/utils": "1.
|
|
9
|
+
"@nocobase/utils": "1.4.0-alpha.0",
|
|
10
10
|
"deepmerge": "^4.2.2",
|
|
11
11
|
"koa-compose": "^4.1.0",
|
|
12
12
|
"lodash": "^4.17.21",
|
|
@@ -18,5 +18,5 @@
|
|
|
18
18
|
"url": "git+https://github.com/nocobase/nocobase.git",
|
|
19
19
|
"directory": "packages/resourcer"
|
|
20
20
|
},
|
|
21
|
-
"gitHead": "
|
|
21
|
+
"gitHead": "8ffa7b54bbaf720c0c9857da4b19a99110dffc4b"
|
|
22
22
|
}
|