oak-domain 2.4.2 → 2.4.3
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/store/checker.js +26 -26
- package/lib/store/selection.js +3 -0
- package/package.json +1 -1
package/lib/store/checker.js
CHANGED
|
@@ -287,8 +287,19 @@ function translateCascadeRelationFilterMaker(schema, lch, entity2) {
|
|
|
287
287
|
var cascadePath = lch.cascadePath, relations = lch.relations;
|
|
288
288
|
var paths = cascadePath.split('.');
|
|
289
289
|
var translateRelationFilter = function (entity) {
|
|
290
|
-
// 有两种情况,此entity和user有Relation定义,或是此entity
|
|
291
|
-
if (
|
|
290
|
+
// 有两种情况,此entity和user有Relation定义,或是此entity已经指向user
|
|
291
|
+
if (entity === 'user') {
|
|
292
|
+
return function (userId) { return ({
|
|
293
|
+
id: userId,
|
|
294
|
+
}); };
|
|
295
|
+
}
|
|
296
|
+
else if (schema[entity].relation) {
|
|
297
|
+
if (relations) {
|
|
298
|
+
var diff = (0, lodash_1.difference)(relations, schema[entity].relation);
|
|
299
|
+
if (diff.length > 0) {
|
|
300
|
+
throw new Error("".concat(entity2, "\u4E0A\u67D0auth\u5B9A\u4E49\u7684relations\u4E2D\u542B\u6709\u4E0D\u53EF\u8BC6\u522B\u7684\u5173\u7CFB\u5B9A\u4E49").concat(diff.join(','), "\uFF0C \u8BF7\u4ED4\u7EC6\u68C0\u67E5"));
|
|
301
|
+
}
|
|
302
|
+
}
|
|
292
303
|
var relationEntityName_1 = "user".concat((0, string_1.firstLetterUpperCase)(entity));
|
|
293
304
|
return function (userId) {
|
|
294
305
|
var _a;
|
|
@@ -313,11 +324,9 @@ function translateCascadeRelationFilterMaker(schema, lch, entity2) {
|
|
|
313
324
|
};
|
|
314
325
|
};
|
|
315
326
|
}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
userId: userId,
|
|
320
|
-
}); };
|
|
327
|
+
else {
|
|
328
|
+
(0, assert_1.default)(false, "".concat(entity2, "\u4E0A\u67D0auth\u5B9A\u4E49\u7684cascadePath").concat(cascadePath, "\u4E0D\u80FD\u5B9A\u4F4D\u5230User\u5BF9\u8C61\u6216\u8005\u548CUser\u5173\u8054\u7684\u5173\u7CFB\u5BF9\u8C61\uFF0C \u8BF7\u4ED4\u7EC6\u68C0\u67E5"));
|
|
329
|
+
}
|
|
321
330
|
};
|
|
322
331
|
var translateFilterMakerIter = function (entity, iter) {
|
|
323
332
|
var relation = (0, relation_1.judgeRelation)(schema, entity, paths[iter]);
|
|
@@ -325,32 +334,23 @@ function translateCascadeRelationFilterMaker(schema, lch, entity2) {
|
|
|
325
334
|
if (relation === 2) {
|
|
326
335
|
var filterMaker_1 = translateRelationFilter(paths[iter]);
|
|
327
336
|
return function (userId) {
|
|
328
|
-
var _a;
|
|
329
337
|
var filter = filterMaker_1(userId);
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
}
|
|
336
|
-
return _a = {},
|
|
337
|
-
_a[paths[iter]] = filter,
|
|
338
|
-
_a;
|
|
338
|
+
(0, assert_1.default)(filter.id);
|
|
339
|
+
return {
|
|
340
|
+
entity: paths[iter],
|
|
341
|
+
entityId: filter.id,
|
|
342
|
+
};
|
|
339
343
|
};
|
|
340
344
|
}
|
|
341
345
|
(0, assert_1.default)(typeof relation === 'string');
|
|
342
346
|
var filterMaker_2 = translateRelationFilter(relation);
|
|
343
347
|
return function (userId) {
|
|
344
|
-
var _a
|
|
348
|
+
var _a;
|
|
345
349
|
var filter = filterMaker_2(userId);
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
}
|
|
351
|
-
return _b = {},
|
|
352
|
-
_b[paths[iter]] = filter,
|
|
353
|
-
_b;
|
|
350
|
+
(0, assert_1.default)(filter.id);
|
|
351
|
+
return _a = {},
|
|
352
|
+
_a["".concat(paths[iter], "Id")] = filter.id,
|
|
353
|
+
_a;
|
|
354
354
|
};
|
|
355
355
|
}
|
|
356
356
|
else {
|
package/lib/store/selection.js
CHANGED