oak-domain 5.1.0 → 5.1.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/lib/store/AsyncRowStore.js +6 -0
- package/lib/store/CascadeStore.d.ts +1 -1
- package/lib/store/CascadeStore.js +38 -38
- package/lib/store/IntrinsicCheckers.js +4 -4
- package/lib/store/RelationAuth.js +9 -0
- package/lib/store/relation.d.ts +1 -1
- package/lib/store/relation.js +4 -4
- package/lib/types/Auth.d.ts +1 -1
- package/lib/types/Entity.d.ts +3 -0
- package/lib/types/Exception.d.ts +6 -0
- package/lib/types/Exception.js +15 -1
- package/lib/types/Trigger.js +1 -0
- package/lib/utils/assert.d.ts +1 -0
- package/lib/utils/relationPath.js +1 -1
- package/package.json +1 -1
- package/src/entities/ModiEntity.ts +26 -26
- package/src/entities/OperEntity.ts +27 -27
- package/src/entities/Relation.ts +43 -43
- package/src/entities/UserEntityClaim.ts +29 -29
- package/src/entities/UserEntityGrant.ts +24 -24
- package/src/entities/UserRelation.ts +50 -50
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AsyncContext = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
const types_1 = require("../types");
|
|
5
6
|
const action_1 = require("../actions/action");
|
|
6
7
|
const assert_1 = tslib_1.__importDefault(require("assert"));
|
|
7
8
|
const filter_1 = require("./filter");
|
|
@@ -81,9 +82,14 @@ class AsyncContext {
|
|
|
81
82
|
break;
|
|
82
83
|
}
|
|
83
84
|
case 'remove': {
|
|
85
|
+
const deleteAt = data[types_1.DeleteAtAttribute];
|
|
86
|
+
(0, assert_1.default)(deleteAt);
|
|
84
87
|
this.opRecords.push({
|
|
85
88
|
id,
|
|
86
89
|
a: 'r',
|
|
90
|
+
d: {
|
|
91
|
+
[types_1.DeleteAtAttribute]: deleteAt,
|
|
92
|
+
},
|
|
87
93
|
e: entity,
|
|
88
94
|
f: filter,
|
|
89
95
|
});
|
|
@@ -67,7 +67,7 @@ export declare abstract class CascadeStore<ED extends EntityDict & BaseEntityDic
|
|
|
67
67
|
afterFns: (() => R)[];
|
|
68
68
|
};
|
|
69
69
|
protected preProcessDataCreated<T extends keyof ED>(entity: T, data: ED[T]['Create']['data']): void;
|
|
70
|
-
protected preProcessDataUpdated(data: Record<string, any
|
|
70
|
+
protected preProcessDataUpdated(action: string, data: Record<string, any>, async?: true): void;
|
|
71
71
|
judgeRelation(entity: keyof ED, attr: string): string | 1 | 2 | string[] | 0 | -1;
|
|
72
72
|
/**
|
|
73
73
|
* 和具体的update过程无关的例程放在这里,包括对later动作的处理、对oper的记录以及对record的收集等
|
|
@@ -22,7 +22,7 @@ class CascadeStore extends RowStore_1.RowStore {
|
|
|
22
22
|
selectionRewriters = [];
|
|
23
23
|
operationRewriters = [];
|
|
24
24
|
async reinforceSelectionAsync(entity, selection, context, option, isAggr) {
|
|
25
|
-
if (!isAggr && !selection.distinct) {
|
|
25
|
+
if (!isAggr && !selection.distinct && !option.dontCollect) {
|
|
26
26
|
this.reinforceSelectionInner(entity, selection, context);
|
|
27
27
|
}
|
|
28
28
|
const rewriterPromises = this.selectionRewriters.map(ele => ele(this.getSchema(), entity, selection, context, option, isAggr));
|
|
@@ -289,7 +289,11 @@ class CascadeStore extends RowStore_1.RowStore {
|
|
|
289
289
|
id: 1,
|
|
290
290
|
name: 1,
|
|
291
291
|
display: 1,
|
|
292
|
-
|
|
292
|
+
[Entity_1.CreateAtAttribute]: 1,
|
|
293
|
+
[Entity_1.UpdateAtAttribute]: 1,
|
|
294
|
+
},
|
|
295
|
+
[Entity_1.CreateAtAttribute]: 1,
|
|
296
|
+
[Entity_1.UpdateAtAttribute]: 1,
|
|
293
297
|
},
|
|
294
298
|
filter: {
|
|
295
299
|
userId,
|
|
@@ -1012,8 +1016,8 @@ class CascadeStore extends RowStore_1.RowStore {
|
|
|
1012
1016
|
}
|
|
1013
1017
|
}
|
|
1014
1018
|
Object.assign(data2, {
|
|
1015
|
-
[Entity_1.CreateAtAttribute]: now,
|
|
1016
|
-
[Entity_1.UpdateAtAttribute]: now,
|
|
1019
|
+
[Entity_1.CreateAtAttribute]: data2[Entity_1.CreateAtAttribute] || now,
|
|
1020
|
+
[Entity_1.UpdateAtAttribute]: data2[Entity_1.UpdateAtAttribute] || now,
|
|
1017
1021
|
[Entity_1.DeleteAtAttribute]: null,
|
|
1018
1022
|
});
|
|
1019
1023
|
};
|
|
@@ -1025,9 +1029,18 @@ class CascadeStore extends RowStore_1.RowStore {
|
|
|
1025
1029
|
}
|
|
1026
1030
|
}
|
|
1027
1031
|
// 对更新的数据,去掉所有的undefined属性
|
|
1028
|
-
preProcessDataUpdated(data) {
|
|
1032
|
+
preProcessDataUpdated(action, data, async) {
|
|
1029
1033
|
const undefinedKeys = Object.keys(data).filter(ele => data[ele] === undefined);
|
|
1030
1034
|
undefinedKeys.forEach(ele => (0, lodash_1.unset)(data, ele));
|
|
1035
|
+
// 优化一下,如果不更新任何属性,则不实际执行
|
|
1036
|
+
const now = Date.now();
|
|
1037
|
+
// 后台应该还是以实际操作时间为准,前台以传入的updateAt来界定操作的产生“时间”,这里可用来避免同一次更新被算做多次
|
|
1038
|
+
if ((Object.keys(data).length > 0 || action !== 'update') && (!data[Entity_1.UpdateAtAttribute] || async)) {
|
|
1039
|
+
data[Entity_1.UpdateAtAttribute] = now;
|
|
1040
|
+
}
|
|
1041
|
+
if (action === 'remove' && (!data[Entity_1.DeleteAtAttribute] || async)) {
|
|
1042
|
+
data[Entity_1.DeleteAtAttribute] = now;
|
|
1043
|
+
}
|
|
1031
1044
|
}
|
|
1032
1045
|
judgeRelation(entity, attr) {
|
|
1033
1046
|
return (0, relation_1.judgeRelation)(this.storageSchema, entity, attr);
|
|
@@ -1257,7 +1270,7 @@ class CascadeStore extends RowStore_1.RowStore {
|
|
|
1257
1270
|
});
|
|
1258
1271
|
}
|
|
1259
1272
|
if (data) {
|
|
1260
|
-
this.preProcessDataUpdated(data);
|
|
1273
|
+
this.preProcessDataUpdated(action, data, true);
|
|
1261
1274
|
}
|
|
1262
1275
|
if (option.modiParentEntity && !['modi', 'modiEntity'].includes(entity)) {
|
|
1263
1276
|
// 延时更新,变成对modi的插入
|
|
@@ -1270,16 +1283,15 @@ class CascadeStore extends RowStore_1.RowStore {
|
|
|
1270
1283
|
if (updateAttrCount === 0) {
|
|
1271
1284
|
return {};
|
|
1272
1285
|
}
|
|
1286
|
+
// 尝试和当前targetEntity的最后一条create/update进行合并,优化modi的条数
|
|
1273
1287
|
const upsertModis = await this.selectAbjointRowAsync('modi', {
|
|
1274
1288
|
data: {
|
|
1275
1289
|
id: 1,
|
|
1276
1290
|
data: 1,
|
|
1291
|
+
action: 1,
|
|
1277
1292
|
},
|
|
1278
1293
|
filter: {
|
|
1279
1294
|
targetEntity: entity,
|
|
1280
|
-
action: {
|
|
1281
|
-
$in: ['create', 'update'],
|
|
1282
|
-
},
|
|
1283
1295
|
entity: option.modiParentEntity,
|
|
1284
1296
|
entityId: option.modiParentId,
|
|
1285
1297
|
iState: 'active',
|
|
@@ -1301,17 +1313,19 @@ class CascadeStore extends RowStore_1.RowStore {
|
|
|
1301
1313
|
count: 1,
|
|
1302
1314
|
}, context, option);
|
|
1303
1315
|
if (upsertModis.length > 0) {
|
|
1304
|
-
const { data: originData, id: originId } = upsertModis[0];
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
data:
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1316
|
+
const { data: originData, id: originId, action } = upsertModis[0];
|
|
1317
|
+
if (['create', 'update'].includes(action)) {
|
|
1318
|
+
modiUpsert = {
|
|
1319
|
+
id: 'dummy',
|
|
1320
|
+
action: 'update',
|
|
1321
|
+
data: {
|
|
1322
|
+
data: Object.assign({}, originData, data),
|
|
1323
|
+
},
|
|
1324
|
+
filter: {
|
|
1325
|
+
id: originId,
|
|
1326
|
+
}
|
|
1327
|
+
};
|
|
1328
|
+
}
|
|
1315
1329
|
}
|
|
1316
1330
|
}
|
|
1317
1331
|
if (!modiUpsert) {
|
|
@@ -1394,22 +1408,18 @@ class CascadeStore extends RowStore_1.RowStore {
|
|
|
1394
1408
|
context.saveOpRecord(entity, {
|
|
1395
1409
|
id: operId,
|
|
1396
1410
|
action,
|
|
1397
|
-
data:
|
|
1411
|
+
data: data,
|
|
1398
1412
|
filter: {
|
|
1399
1413
|
id: {
|
|
1400
1414
|
$in: ids,
|
|
1401
1415
|
}
|
|
1402
|
-
}
|
|
1416
|
+
},
|
|
1403
1417
|
});
|
|
1404
1418
|
}
|
|
1405
1419
|
}
|
|
1406
1420
|
else {
|
|
1407
1421
|
const updateAttrCount = Object.keys(data).length;
|
|
1408
1422
|
if (updateAttrCount > 0) {
|
|
1409
|
-
// 优化一下,如果不更新任何属性,则不实际执行
|
|
1410
|
-
Object.assign(data, {
|
|
1411
|
-
[Entity_1.UpdateAtAttribute]: now,
|
|
1412
|
-
});
|
|
1413
1423
|
if (!option.dontCollect) {
|
|
1414
1424
|
context.saveOpRecord(entity, {
|
|
1415
1425
|
id: operId,
|
|
@@ -1423,11 +1433,6 @@ class CascadeStore extends RowStore_1.RowStore {
|
|
|
1423
1433
|
});
|
|
1424
1434
|
}
|
|
1425
1435
|
}
|
|
1426
|
-
else if (action !== 'update') {
|
|
1427
|
-
// 如果不是update动作而是用户自定义的动作,这里还是要记录oper
|
|
1428
|
-
await createOper();
|
|
1429
|
-
return {};
|
|
1430
|
-
}
|
|
1431
1436
|
else {
|
|
1432
1437
|
return {};
|
|
1433
1438
|
}
|
|
@@ -1483,15 +1488,10 @@ class CascadeStore extends RowStore_1.RowStore {
|
|
|
1483
1488
|
if (action === 'remove') {
|
|
1484
1489
|
}
|
|
1485
1490
|
else {
|
|
1491
|
+
this.preProcessDataUpdated(action, data);
|
|
1486
1492
|
const updateAttrCount = Object.keys(data).length;
|
|
1487
|
-
if (updateAttrCount
|
|
1493
|
+
if (updateAttrCount == 0) {
|
|
1488
1494
|
// 优化一下,如果不更新任何属性,则不实际执行
|
|
1489
|
-
Object.assign(data, {
|
|
1490
|
-
$$updateAt$$: now,
|
|
1491
|
-
});
|
|
1492
|
-
this.preProcessDataUpdated(data);
|
|
1493
|
-
}
|
|
1494
|
-
else {
|
|
1495
1495
|
return 0;
|
|
1496
1496
|
}
|
|
1497
1497
|
}
|
|
@@ -79,7 +79,7 @@ function createUniqueCheckers(schema) {
|
|
|
79
79
|
entity,
|
|
80
80
|
action: 'create',
|
|
81
81
|
type: 'logicalData',
|
|
82
|
-
priority: types_1.CHECKER_MAX_PRIORITY,
|
|
82
|
+
priority: types_1.CHECKER_MAX_PRIORITY, // 优先级要放在最低,所有前置的checker/trigger将数据完整之后再在这里检测
|
|
83
83
|
checker: (operation, context) => {
|
|
84
84
|
const { data } = operation;
|
|
85
85
|
if (data instanceof Array) {
|
|
@@ -95,9 +95,9 @@ function createUniqueCheckers(schema) {
|
|
|
95
95
|
}
|
|
96
96
|
}, {
|
|
97
97
|
entity,
|
|
98
|
-
action: 'update',
|
|
98
|
+
action: 'update', // 只检查update,其它状态转换的action应该不会涉及unique约束的属性
|
|
99
99
|
type: 'logicalData',
|
|
100
|
-
priority: types_1.CHECKER_MAX_PRIORITY,
|
|
100
|
+
priority: types_1.CHECKER_MAX_PRIORITY, // 优先级要放在最低,所有前置的checker/trigger将数据完整之后再在这里检测
|
|
101
101
|
checker: (operation, context) => {
|
|
102
102
|
const { data, filter: operationFilter } = operation;
|
|
103
103
|
if (data) {
|
|
@@ -227,7 +227,7 @@ function createActionTransformerCheckers(actionDefDict) {
|
|
|
227
227
|
action: 'create',
|
|
228
228
|
type: 'logical',
|
|
229
229
|
entity,
|
|
230
|
-
priority: 10,
|
|
230
|
+
priority: 10, // 优先级要高,先于真正的data检查进行
|
|
231
231
|
checker: (operation) => {
|
|
232
232
|
const { data } = operation;
|
|
233
233
|
if (data instanceof Array) {
|
|
@@ -60,6 +60,7 @@ class RelationAuth {
|
|
|
60
60
|
const relationAuths = context.select('relationAuth', {
|
|
61
61
|
data: {
|
|
62
62
|
id: 1,
|
|
63
|
+
pathId: 1,
|
|
63
64
|
path: {
|
|
64
65
|
id: 1,
|
|
65
66
|
sourceEntity: 1,
|
|
@@ -732,6 +733,7 @@ class RelationAuth {
|
|
|
732
733
|
const actionAuths = context.select('actionAuth', {
|
|
733
734
|
data: {
|
|
734
735
|
id: 1,
|
|
736
|
+
pathId: 1,
|
|
735
737
|
path: {
|
|
736
738
|
id: 1,
|
|
737
739
|
value: 1,
|
|
@@ -830,15 +832,21 @@ class RelationAuth {
|
|
|
830
832
|
value: 1,
|
|
831
833
|
recursive: 1,
|
|
832
834
|
},
|
|
835
|
+
pathId: 1,
|
|
833
836
|
deActions: 1,
|
|
837
|
+
relationId: 1,
|
|
834
838
|
relation: {
|
|
835
839
|
id: 1,
|
|
840
|
+
entity: 1,
|
|
841
|
+
entityId: 1,
|
|
836
842
|
userRelation$relation: {
|
|
837
843
|
$entity: 'userRelation',
|
|
838
844
|
data: {
|
|
839
845
|
id: 1,
|
|
840
846
|
entity: 1,
|
|
841
847
|
entityId: 1,
|
|
848
|
+
userId: 1,
|
|
849
|
+
relationId: 1,
|
|
842
850
|
},
|
|
843
851
|
filter: {
|
|
844
852
|
userId: context.getCurrentUserId(),
|
|
@@ -1123,6 +1131,7 @@ async function getUserRelationsByActions(params, context) {
|
|
|
1123
1131
|
const actionAuths = await context.select('actionAuth', {
|
|
1124
1132
|
data: {
|
|
1125
1133
|
id: 1,
|
|
1134
|
+
pathId: 1,
|
|
1126
1135
|
path: {
|
|
1127
1136
|
id: 1,
|
|
1128
1137
|
value: 1,
|
package/lib/store/relation.d.ts
CHANGED
|
@@ -9,4 +9,4 @@ import { StorageSchema } from "../types/Storage";
|
|
|
9
9
|
* @param row
|
|
10
10
|
* @returns
|
|
11
11
|
*/
|
|
12
|
-
export declare function judgeRelation<ED extends EntityDict & BaseEntityDict>(schema: StorageSchema<ED>, entity: keyof ED, attr: string,
|
|
12
|
+
export declare function judgeRelation<ED extends EntityDict & BaseEntityDict>(schema: StorageSchema<ED>, entity: keyof ED, attr: string, allowUnrecognized?: boolean): string | 1 | 2 | string[] | 0 | -1;
|
package/lib/store/relation.js
CHANGED
|
@@ -13,7 +13,7 @@ const Entity_1 = require("../types/Entity");
|
|
|
13
13
|
* @param row
|
|
14
14
|
* @returns
|
|
15
15
|
*/
|
|
16
|
-
function judgeRelation(schema, entity, attr,
|
|
16
|
+
function judgeRelation(schema, entity, attr, allowUnrecognized) {
|
|
17
17
|
const { [entity]: { attributes } } = schema;
|
|
18
18
|
if (attr.startsWith(Demand_1.EXPRESSION_PREFIX) || attr.startsWith('#')) {
|
|
19
19
|
// 表达式属性或者metadata
|
|
@@ -27,8 +27,8 @@ function judgeRelation(schema, entity, attr, allowUnrecoganized) {
|
|
|
27
27
|
const firstDelimiter = attr.indexOf('$');
|
|
28
28
|
const entity2 = attr.slice(0, firstDelimiter);
|
|
29
29
|
(0, assert_1.default)(schema.hasOwnProperty(entity2));
|
|
30
|
-
const
|
|
31
|
-
const foreignKey = attr.slice(firstDelimiter + 1,
|
|
30
|
+
const secondDelimiter = attr.indexOf('$', firstDelimiter + 1);
|
|
31
|
+
const foreignKey = attr.slice(firstDelimiter + 1, secondDelimiter > 0 ? secondDelimiter : attr.length);
|
|
32
32
|
const { [entity2]: { attributes: attributes2 } } = schema;
|
|
33
33
|
if (foreignKey === 'entity') {
|
|
34
34
|
// 基于反指对象的反向关联
|
|
@@ -63,7 +63,7 @@ function judgeRelation(schema, entity, attr, allowUnrecoganized) {
|
|
|
63
63
|
if (Entity_1.initinctiveAttributes.includes(attr)) {
|
|
64
64
|
return 1;
|
|
65
65
|
}
|
|
66
|
-
else if (
|
|
66
|
+
else if (allowUnrecognized) {
|
|
67
67
|
return -1;
|
|
68
68
|
}
|
|
69
69
|
else {
|
package/lib/types/Auth.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { SyncContext } from "../store/SyncRowStore";
|
|
|
4
4
|
import { EntityDict, OperateOption, SelectOption } from "../types/Entity";
|
|
5
5
|
import { EntityDict as BaseEntityDict } from '../base-app-domain';
|
|
6
6
|
import { ModiTurn } from './Trigger';
|
|
7
|
-
export type CheckerType = 'row' | 'data' | 'logical' | 'logicalData';
|
|
7
|
+
export type CheckerType = 'row' | 'data' | 'logical' | 'logicalData' | 'relation';
|
|
8
8
|
/**
|
|
9
9
|
* conditionalFilter是指该action发生时,operation所操作的行中有满足conditionalFilter的行
|
|
10
10
|
* 被转化成trigger的filter条件,详细可看trigger中的说明
|
package/lib/types/Entity.d.ts
CHANGED
|
@@ -162,6 +162,9 @@ export type UpdateOpResult<ED extends EntityDict, T extends keyof ED> = {
|
|
|
162
162
|
export type RemoveOpResult<ED extends EntityDict, T extends keyof ED> = {
|
|
163
163
|
id: string;
|
|
164
164
|
a: 'r';
|
|
165
|
+
d: {
|
|
166
|
+
[DeleteAtAttribute]: number;
|
|
167
|
+
};
|
|
165
168
|
e: T;
|
|
166
169
|
f?: Filter;
|
|
167
170
|
};
|
package/lib/types/Exception.d.ts
CHANGED
|
@@ -169,6 +169,12 @@ export declare class OakExternalException<ED extends EntityDict & BaseEntityDict
|
|
|
169
169
|
constructor(source: string, code?: string, message?: string, data?: any);
|
|
170
170
|
toString(): string;
|
|
171
171
|
}
|
|
172
|
+
/**
|
|
173
|
+
* socket连接异常
|
|
174
|
+
*/
|
|
175
|
+
export declare class OakSocketConnectException<ED extends EntityDict & BaseEntityDict> extends OakUserException<ED> {
|
|
176
|
+
constructor(message?: string);
|
|
177
|
+
}
|
|
172
178
|
export declare function makeException<ED extends EntityDict & BaseEntityDict>(data: {
|
|
173
179
|
name: string;
|
|
174
180
|
message?: string;
|
package/lib/types/Exception.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.makeException = exports.OakExternalException = exports.OakPreConditionUnsetException = exports.OakDeadlock = exports.OakCongruentRowExists = exports.OakRowLockedException = exports.OakUnloggedInException = exports.OakUserInvisibleException = exports.OakUserUnpermittedException = exports.OakAttrCantUpdateException = exports.OakAttrNotNullException = exports.OakInputIllegalException = exports.OakRowInconsistencyException = exports.OakServerProxyException = exports.OakNetworkException = exports.OakImportDataParseException = exports.OakUniqueViolationException = exports.OakUserException = exports.OakRowUnexistedException = exports.OakOperExistedException = exports.OakNoRelationDefException = exports.OakDataException = exports.OakPartialSuccess = exports.OakMakeSureByMySelfException = exports.OakException = void 0;
|
|
3
|
+
exports.makeException = exports.OakSocketConnectException = exports.OakExternalException = exports.OakPreConditionUnsetException = exports.OakDeadlock = exports.OakCongruentRowExists = exports.OakRowLockedException = exports.OakUnloggedInException = exports.OakUserInvisibleException = exports.OakUserUnpermittedException = exports.OakAttrCantUpdateException = exports.OakAttrNotNullException = exports.OakInputIllegalException = exports.OakRowInconsistencyException = exports.OakServerProxyException = exports.OakNetworkException = exports.OakImportDataParseException = exports.OakUniqueViolationException = exports.OakUserException = exports.OakRowUnexistedException = exports.OakOperExistedException = exports.OakNoRelationDefException = exports.OakDataException = exports.OakPartialSuccess = exports.OakMakeSureByMySelfException = exports.OakException = void 0;
|
|
4
4
|
const relation_1 = require("../store/relation");
|
|
5
5
|
const lodash_1 = require("../utils/lodash");
|
|
6
6
|
class OakException extends Error {
|
|
@@ -385,6 +385,16 @@ class OakExternalException extends OakUserException {
|
|
|
385
385
|
}
|
|
386
386
|
}
|
|
387
387
|
exports.OakExternalException = OakExternalException;
|
|
388
|
+
/**
|
|
389
|
+
* socket连接异常
|
|
390
|
+
*/
|
|
391
|
+
class OakSocketConnectException extends OakUserException {
|
|
392
|
+
constructor(message) {
|
|
393
|
+
super(message || '连接出现问题,请尝试刷新页面');
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
exports.OakSocketConnectException = OakSocketConnectException;
|
|
397
|
+
;
|
|
388
398
|
function makeException(data) {
|
|
389
399
|
const { name } = data;
|
|
390
400
|
let e = undefined;
|
|
@@ -473,6 +483,10 @@ function makeException(data) {
|
|
|
473
483
|
e = new OakServerProxyException(data.message);
|
|
474
484
|
break;
|
|
475
485
|
}
|
|
486
|
+
case 'OakSocketConnectException': {
|
|
487
|
+
e = new OakSocketConnectException(data.message);
|
|
488
|
+
break;
|
|
489
|
+
}
|
|
476
490
|
default:
|
|
477
491
|
return;
|
|
478
492
|
}
|
package/lib/types/Trigger.js
CHANGED
package/lib/utils/assert.d.ts
CHANGED
|
@@ -60,7 +60,7 @@ function destructRelationPath(schema, entity, path, relationFilter, recursive) {
|
|
|
60
60
|
},
|
|
61
61
|
filter: relationFilter,
|
|
62
62
|
} // as ED['userRelation']['Selection']
|
|
63
|
-
},
|
|
63
|
+
}, // as ED[keyof ED]['Selection']['data'],
|
|
64
64
|
getData: (d) => {
|
|
65
65
|
return d.userRelation$entity;
|
|
66
66
|
},
|
package/package.json
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { String } from '../types/DataType';
|
|
2
|
-
import { EntityShape } from '../types/Entity';
|
|
3
|
-
import { Schema as Modi } from './Modi';
|
|
4
|
-
import { EntityDesc } from '../types/EntityDesc';
|
|
5
|
-
|
|
6
|
-
export interface Schema extends EntityShape {
|
|
7
|
-
modi: Modi,
|
|
8
|
-
entity: String<32>;
|
|
9
|
-
entityId: String<64>;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const entityDesc: EntityDesc<Schema> = {
|
|
13
|
-
locales: {
|
|
14
|
-
zh_CN: {
|
|
15
|
-
name: '更新对象连接',
|
|
16
|
-
attr: {
|
|
17
|
-
modi: '更新',
|
|
18
|
-
entity: '关联对象',
|
|
19
|
-
entityId: '关联对象id',
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
configuration: {
|
|
24
|
-
actionType: 'appendOnly',
|
|
25
|
-
}
|
|
26
|
-
};
|
|
1
|
+
import { String } from '../types/DataType';
|
|
2
|
+
import { EntityShape } from '../types/Entity';
|
|
3
|
+
import { Schema as Modi } from './Modi';
|
|
4
|
+
import { EntityDesc } from '../types/EntityDesc';
|
|
5
|
+
|
|
6
|
+
export interface Schema extends EntityShape {
|
|
7
|
+
modi: Modi,
|
|
8
|
+
entity: String<32>;
|
|
9
|
+
entityId: String<64>;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const entityDesc: EntityDesc<Schema> = {
|
|
13
|
+
locales: {
|
|
14
|
+
zh_CN: {
|
|
15
|
+
name: '更新对象连接',
|
|
16
|
+
attr: {
|
|
17
|
+
modi: '更新',
|
|
18
|
+
entity: '关联对象',
|
|
19
|
+
entityId: '关联对象id',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
configuration: {
|
|
24
|
+
actionType: 'appendOnly',
|
|
25
|
+
}
|
|
26
|
+
};
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { String } from '../types/DataType';
|
|
2
|
-
import { EntityShape, Configuration } from '../types/Entity';
|
|
3
|
-
import { LocaleDef } from '../types/Locale';
|
|
4
|
-
import { Schema as Oper } from './Oper';
|
|
5
|
-
import { EntityDesc } from '../types/EntityDesc';
|
|
6
|
-
|
|
7
|
-
export interface Schema extends EntityShape {
|
|
8
|
-
oper: Oper,
|
|
9
|
-
entity: String<32>;
|
|
10
|
-
entityId: String<64>;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const entityDesc: EntityDesc<Schema> = {
|
|
14
|
-
locales: {
|
|
15
|
-
zh_CN: {
|
|
16
|
-
name: '操作对象连接',
|
|
17
|
-
attr: {
|
|
18
|
-
oper: '操作',
|
|
19
|
-
entity: '关联对象',
|
|
20
|
-
entityId: '关联对象id',
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
configuration: {
|
|
25
|
-
actionType: 'appendOnly',
|
|
26
|
-
}
|
|
27
|
-
};
|
|
1
|
+
import { String } from '../types/DataType';
|
|
2
|
+
import { EntityShape, Configuration } from '../types/Entity';
|
|
3
|
+
import { LocaleDef } from '../types/Locale';
|
|
4
|
+
import { Schema as Oper } from './Oper';
|
|
5
|
+
import { EntityDesc } from '../types/EntityDesc';
|
|
6
|
+
|
|
7
|
+
export interface Schema extends EntityShape {
|
|
8
|
+
oper: Oper,
|
|
9
|
+
entity: String<32>;
|
|
10
|
+
entityId: String<64>;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const entityDesc: EntityDesc<Schema> = {
|
|
14
|
+
locales: {
|
|
15
|
+
zh_CN: {
|
|
16
|
+
name: '操作对象连接',
|
|
17
|
+
attr: {
|
|
18
|
+
oper: '操作',
|
|
19
|
+
entity: '关联对象',
|
|
20
|
+
entityId: '关联对象id',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
configuration: {
|
|
25
|
+
actionType: 'appendOnly',
|
|
26
|
+
}
|
|
27
|
+
};
|
package/src/entities/Relation.ts
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import { String } from '../types/DataType';
|
|
2
|
-
import { EntityShape } from '../types/Entity';
|
|
3
|
-
import { EntityDesc } from '../types/EntityDesc';
|
|
4
|
-
|
|
5
|
-
export interface Schema extends EntityShape {
|
|
6
|
-
entity: String<32>;
|
|
7
|
-
entityId?: String<64>; // 可以为空
|
|
8
|
-
name?: String<32>;
|
|
9
|
-
display?: String<32>;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const entityDesc: EntityDesc<Schema> = {
|
|
13
|
-
locales: {
|
|
14
|
-
zh_CN: {
|
|
15
|
-
name: '用户授权',
|
|
16
|
-
attr: {
|
|
17
|
-
name: '关系',
|
|
18
|
-
entity: '目标对象',
|
|
19
|
-
entityId: '目标对象id',
|
|
20
|
-
display: '显示值',
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
indexes: [
|
|
25
|
-
{
|
|
26
|
-
name: 'index_targetEntity_entityId_name',
|
|
27
|
-
attributes: [
|
|
28
|
-
{
|
|
29
|
-
name: 'entity',
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
name: 'entityId',
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
name: 'name',
|
|
36
|
-
}
|
|
37
|
-
],
|
|
38
|
-
config: {
|
|
39
|
-
unique: true,
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
]
|
|
43
|
-
};
|
|
1
|
+
import { String } from '../types/DataType';
|
|
2
|
+
import { EntityShape } from '../types/Entity';
|
|
3
|
+
import { EntityDesc } from '../types/EntityDesc';
|
|
4
|
+
|
|
5
|
+
export interface Schema extends EntityShape {
|
|
6
|
+
entity: String<32>;
|
|
7
|
+
entityId?: String<64>; // 可以为空
|
|
8
|
+
name?: String<32>;
|
|
9
|
+
display?: String<32>;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const entityDesc: EntityDesc<Schema> = {
|
|
13
|
+
locales: {
|
|
14
|
+
zh_CN: {
|
|
15
|
+
name: '用户授权',
|
|
16
|
+
attr: {
|
|
17
|
+
name: '关系',
|
|
18
|
+
entity: '目标对象',
|
|
19
|
+
entityId: '目标对象id',
|
|
20
|
+
display: '显示值',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
indexes: [
|
|
25
|
+
{
|
|
26
|
+
name: 'index_targetEntity_entityId_name',
|
|
27
|
+
attributes: [
|
|
28
|
+
{
|
|
29
|
+
name: 'entity',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: 'entityId',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'name',
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
config: {
|
|
39
|
+
unique: true,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
]
|
|
43
|
+
};
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { String } from '../types/DataType';
|
|
2
|
-
import { EntityShape } from '../types/Entity';
|
|
3
|
-
import { EntityDesc } from '../types/EntityDesc';
|
|
4
|
-
import { Schema as UserEntityGrant } from './UserEntityGrant';
|
|
5
|
-
import { Schema as User } from './User';
|
|
6
|
-
import { Schema as Relation } from './Relation';
|
|
7
|
-
import { Schema as UserRelation } from './UserRelation';
|
|
8
|
-
|
|
9
|
-
export interface Schema extends EntityShape {
|
|
10
|
-
ueg: UserEntityGrant;
|
|
11
|
-
user: User;
|
|
12
|
-
relation: Relation;
|
|
13
|
-
claimEntityId: String<64>;
|
|
14
|
-
userRelation: UserRelation;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const entityDesc: EntityDesc<Schema, ''> = {
|
|
18
|
-
locales: {
|
|
19
|
-
zh_CN: {
|
|
20
|
-
name: '用户授权领取',
|
|
21
|
-
attr: {
|
|
22
|
-
ueg: '授权',
|
|
23
|
-
user: '用户',
|
|
24
|
-
relation: '关系',
|
|
25
|
-
claimEntityId: '对象Id',
|
|
26
|
-
userRelation: '用户关系',
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
},
|
|
1
|
+
import { String } from '../types/DataType';
|
|
2
|
+
import { EntityShape } from '../types/Entity';
|
|
3
|
+
import { EntityDesc } from '../types/EntityDesc';
|
|
4
|
+
import { Schema as UserEntityGrant } from './UserEntityGrant';
|
|
5
|
+
import { Schema as User } from './User';
|
|
6
|
+
import { Schema as Relation } from './Relation';
|
|
7
|
+
import { Schema as UserRelation } from './UserRelation';
|
|
8
|
+
|
|
9
|
+
export interface Schema extends EntityShape {
|
|
10
|
+
ueg: UserEntityGrant;
|
|
11
|
+
user: User;
|
|
12
|
+
relation: Relation;
|
|
13
|
+
claimEntityId: String<64>;
|
|
14
|
+
userRelation: UserRelation;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const entityDesc: EntityDesc<Schema, ''> = {
|
|
18
|
+
locales: {
|
|
19
|
+
zh_CN: {
|
|
20
|
+
name: '用户授权领取',
|
|
21
|
+
attr: {
|
|
22
|
+
ueg: '授权',
|
|
23
|
+
user: '用户',
|
|
24
|
+
relation: '关系',
|
|
25
|
+
claimEntityId: '对象Id',
|
|
26
|
+
userRelation: '用户关系',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
30
|
};
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { String } from '../types/DataType';
|
|
2
|
-
import { EntityShape } from '../types/Entity';
|
|
3
|
-
import { EntityDesc } from '../types/EntityDesc';
|
|
4
|
-
|
|
5
|
-
type RelationIds = string[];
|
|
6
|
-
|
|
7
|
-
export interface Schema extends EntityShape {
|
|
8
|
-
relationEntity: String<32>;
|
|
9
|
-
relationEntityFilter: Object;
|
|
10
|
-
relationIds: RelationIds;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const entityDesc: EntityDesc<Schema, ''> = {
|
|
14
|
-
locales: {
|
|
15
|
-
zh_CN: {
|
|
16
|
-
name: '用户授权',
|
|
17
|
-
attr: {
|
|
18
|
-
relationIds: '关系',
|
|
19
|
-
relationEntity: '关联对象',
|
|
20
|
-
relationEntityFilter: '对象限定条件',
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
};
|
|
1
|
+
import { String } from '../types/DataType';
|
|
2
|
+
import { EntityShape } from '../types/Entity';
|
|
3
|
+
import { EntityDesc } from '../types/EntityDesc';
|
|
4
|
+
|
|
5
|
+
type RelationIds = string[];
|
|
6
|
+
|
|
7
|
+
export interface Schema extends EntityShape {
|
|
8
|
+
relationEntity: String<32>;
|
|
9
|
+
relationEntityFilter: Object;
|
|
10
|
+
relationIds: RelationIds;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const entityDesc: EntityDesc<Schema, ''> = {
|
|
14
|
+
locales: {
|
|
15
|
+
zh_CN: {
|
|
16
|
+
name: '用户授权',
|
|
17
|
+
attr: {
|
|
18
|
+
relationIds: '关系',
|
|
19
|
+
relationEntity: '关联对象',
|
|
20
|
+
relationEntityFilter: '对象限定条件',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
};
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import { String } from '../types/DataType';
|
|
2
|
-
import { LocaleDef } from '../types/Locale';
|
|
3
|
-
import { EntityShape } from '../types/Entity';
|
|
4
|
-
import { Index } from '../types/Storage';
|
|
5
|
-
import { Schema as User } from './User';
|
|
6
|
-
import { Schema as Relation } from './Relation';
|
|
7
|
-
import { EntityDesc } from '../types/EntityDesc';
|
|
8
|
-
|
|
9
|
-
export interface Schema extends EntityShape {
|
|
10
|
-
user: User;
|
|
11
|
-
relation: Relation;
|
|
12
|
-
entity: String<32>;
|
|
13
|
-
entityId: String<64>;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const entityDesc: EntityDesc<Schema> = {
|
|
17
|
-
locales: {
|
|
18
|
-
zh_CN: {
|
|
19
|
-
name: '用户对象关系',
|
|
20
|
-
attr: {
|
|
21
|
-
user: '关系',
|
|
22
|
-
relation: '目标关系',
|
|
23
|
-
entity: '目标对象',
|
|
24
|
-
entityId: '目标对象ID',
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
indexes: [
|
|
29
|
-
{
|
|
30
|
-
name: 'index_user_entity_entityId_relation',
|
|
31
|
-
attributes: [
|
|
32
|
-
{
|
|
33
|
-
name: 'user',
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
name: 'entity',
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
name: 'entityId',
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
name: 'relation',
|
|
43
|
-
},
|
|
44
|
-
],
|
|
45
|
-
config: {
|
|
46
|
-
unique: true,
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
]
|
|
50
|
-
};
|
|
1
|
+
import { String } from '../types/DataType';
|
|
2
|
+
import { LocaleDef } from '../types/Locale';
|
|
3
|
+
import { EntityShape } from '../types/Entity';
|
|
4
|
+
import { Index } from '../types/Storage';
|
|
5
|
+
import { Schema as User } from './User';
|
|
6
|
+
import { Schema as Relation } from './Relation';
|
|
7
|
+
import { EntityDesc } from '../types/EntityDesc';
|
|
8
|
+
|
|
9
|
+
export interface Schema extends EntityShape {
|
|
10
|
+
user: User;
|
|
11
|
+
relation: Relation;
|
|
12
|
+
entity: String<32>;
|
|
13
|
+
entityId: String<64>;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const entityDesc: EntityDesc<Schema> = {
|
|
17
|
+
locales: {
|
|
18
|
+
zh_CN: {
|
|
19
|
+
name: '用户对象关系',
|
|
20
|
+
attr: {
|
|
21
|
+
user: '关系',
|
|
22
|
+
relation: '目标关系',
|
|
23
|
+
entity: '目标对象',
|
|
24
|
+
entityId: '目标对象ID',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
indexes: [
|
|
29
|
+
{
|
|
30
|
+
name: 'index_user_entity_entityId_relation',
|
|
31
|
+
attributes: [
|
|
32
|
+
{
|
|
33
|
+
name: 'user',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'entity',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: 'entityId',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: 'relation',
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
config: {
|
|
46
|
+
unique: true,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
]
|
|
50
|
+
};
|