oak-domain 1.1.14 → 2.0.2
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/base-app-domain/Modi/Schema.d.ts +22 -22
- package/lib/base-app-domain/ModiEntity/Schema.d.ts +17 -17
- package/lib/base-app-domain/Oper/Schema.d.ts +17 -17
- package/lib/base-app-domain/OperEntity/Schema.d.ts +18 -18
- package/lib/base-app-domain/User/Schema.d.ts +15 -15
- package/lib/checkers/index.d.ts +4 -2
- package/lib/compiler/schemalBuilder.js +10 -10
- package/lib/store/AsyncRowStore.d.ts +45 -0
- package/lib/store/{UniversalContext.js → AsyncRowStore.js} +39 -29
- package/lib/store/CascadeStore.d.ts +46 -20
- package/lib/store/CascadeStore.js +954 -995
- package/lib/store/SyncRowStore.d.ts +26 -0
- package/lib/store/SyncRowStore.js +45 -0
- package/lib/store/TriggerExecutor.d.ts +14 -14
- package/lib/store/TriggerExecutor.js +225 -238
- package/lib/store/actionDef.d.ts +5 -4
- package/lib/store/actionDef.js +44 -134
- package/lib/store/checker.d.ts +6 -0
- package/lib/store/checker.js +165 -0
- package/lib/store/filter.d.ts +30 -0
- package/lib/store/filter.js +571 -2
- package/lib/store/modi.d.ts +7 -6
- package/lib/store/modi.js +35 -46
- package/lib/store/relation.d.ts +1 -1
- package/lib/triggers/index.d.ts +4 -3
- package/lib/triggers/modi.d.ts +2 -2
- package/lib/triggers/modi.js +5 -5
- package/lib/types/AppLoader.d.ts +3 -3
- package/lib/types/Aspect.d.ts +3 -3
- package/lib/types/Auth.d.ts +25 -22
- package/lib/types/Connector.d.ts +7 -7
- package/lib/types/Context.d.ts +4 -14
- package/lib/types/Entity.d.ts +20 -15
- package/lib/types/Entity.js +9 -2
- package/lib/types/Exception.js +11 -11
- package/lib/types/RowStore.d.ts +2 -13
- package/lib/types/RowStore.js +1 -6
- package/lib/types/Trigger.d.ts +32 -48
- package/lib/types/Trigger.js +24 -9
- package/lib/types/Watcher.d.ts +7 -8
- package/lib/utils/SimpleConnector.d.ts +9 -8
- package/lib/utils/SimpleConnector.js +4 -5
- package/lib/utils/random/random.d.ts +1 -0
- package/lib/utils/random/random.js +24 -0
- package/lib/utils/random/random.mp.d.ts +1 -0
- package/lib/utils/random/random.mp.js +25 -0
- package/lib/utils/random/random.web.d.ts +1 -0
- package/lib/utils/random/random.web.js +17 -0
- package/lib/utils/string.d.ts +20 -0
- package/lib/utils/string.js +60 -1
- package/lib/utils/uuid.d.ts +10 -0
- package/lib/utils/uuid.js +172 -1
- package/lib/utils/validator.js +1 -1
- package/package.json +7 -4
- package/lib/OakError.d.ts +0 -7
- package/lib/OakError.js +0 -15
- package/lib/compiler/utils.d.ts +0 -2
- package/lib/compiler/utils.js +0 -11
- package/lib/entities/Action.d.ts +0 -12
- package/lib/entities/Action.js +0 -17
- package/lib/entities/Ooperation.d.ts +0 -12
- package/lib/entities/Ooperation.js +0 -17
- package/lib/entities/Update.d.ts +0 -9
- package/lib/entities/Update.js +0 -44
- package/lib/entities/Uupdate.d.ts +0 -9
- package/lib/entities/Uupdate.js +0 -44
- package/lib/store/UniversalContext.d.ts +0 -32
- package/lib/store/action.d.ts +0 -6
- package/lib/store/action.js +0 -14
- package/lib/store/projection.d.ts +0 -7
- package/lib/store/projection.js +0 -211
- package/lib/store/watchers.d.ts +0 -2
- package/lib/store/watchers.js +0 -32
|
@@ -49,18 +49,18 @@ export declare type Filter = MakeFilter<AttrFilter & ExprOp<OpAttr | string>>;
|
|
|
49
49
|
export declare type Projection = {
|
|
50
50
|
"#id"?: NodeId;
|
|
51
51
|
[k: string]: any;
|
|
52
|
-
id:
|
|
53
|
-
$$createAt$$?:
|
|
54
|
-
$$updateAt$$?:
|
|
55
|
-
$$seq$$?:
|
|
56
|
-
targetEntity?:
|
|
57
|
-
entity?:
|
|
58
|
-
entityId?:
|
|
59
|
-
action?:
|
|
60
|
-
data?:
|
|
61
|
-
filter?:
|
|
62
|
-
extra?:
|
|
63
|
-
iState?:
|
|
52
|
+
id: number;
|
|
53
|
+
$$createAt$$?: number;
|
|
54
|
+
$$updateAt$$?: number;
|
|
55
|
+
$$seq$$?: number;
|
|
56
|
+
targetEntity?: number;
|
|
57
|
+
entity?: number;
|
|
58
|
+
entityId?: number;
|
|
59
|
+
action?: number;
|
|
60
|
+
data?: number;
|
|
61
|
+
filter?: number;
|
|
62
|
+
extra?: number;
|
|
63
|
+
iState?: number;
|
|
64
64
|
modiEntity$modi?: ModiEntity.Selection & {
|
|
65
65
|
$entity: "modiEntity";
|
|
66
66
|
};
|
|
@@ -91,26 +91,26 @@ export declare type ExportProjection = {
|
|
|
91
91
|
};
|
|
92
92
|
} & Partial<ExprOp<OpAttr | string>>;
|
|
93
93
|
declare type ModiIdProjection = OneOf<{
|
|
94
|
-
id:
|
|
94
|
+
id: number;
|
|
95
95
|
}>;
|
|
96
96
|
export declare type SortAttr = {
|
|
97
|
-
id:
|
|
97
|
+
id: number;
|
|
98
98
|
} | {
|
|
99
|
-
$$createAt$$:
|
|
99
|
+
$$createAt$$: number;
|
|
100
100
|
} | {
|
|
101
|
-
$$seq$$:
|
|
101
|
+
$$seq$$: number;
|
|
102
102
|
} | {
|
|
103
|
-
$$updateAt$$:
|
|
103
|
+
$$updateAt$$: number;
|
|
104
104
|
} | {
|
|
105
|
-
targetEntity:
|
|
105
|
+
targetEntity: number;
|
|
106
106
|
} | {
|
|
107
|
-
entity:
|
|
107
|
+
entity: number;
|
|
108
108
|
} | {
|
|
109
|
-
entityId:
|
|
109
|
+
entityId: number;
|
|
110
110
|
} | {
|
|
111
|
-
action:
|
|
111
|
+
action: number;
|
|
112
112
|
} | {
|
|
113
|
-
iState:
|
|
113
|
+
iState: number;
|
|
114
114
|
} | {
|
|
115
115
|
[k: string]: any;
|
|
116
116
|
} | OneOf<ExprOp<OpAttr | string>>;
|
|
@@ -36,14 +36,14 @@ export declare type Filter<E = Q_EnumValue<"user" | string>> = MakeFilter<AttrFi
|
|
|
36
36
|
export declare type Projection = {
|
|
37
37
|
"#id"?: NodeId;
|
|
38
38
|
[k: string]: any;
|
|
39
|
-
id:
|
|
40
|
-
$$createAt$$?:
|
|
41
|
-
$$updateAt$$?:
|
|
42
|
-
$$seq$$?:
|
|
43
|
-
modiId?:
|
|
39
|
+
id: number;
|
|
40
|
+
$$createAt$$?: number;
|
|
41
|
+
$$updateAt$$?: number;
|
|
42
|
+
$$seq$$?: number;
|
|
43
|
+
modiId?: number;
|
|
44
44
|
modi?: Modi.Projection;
|
|
45
|
-
entity?:
|
|
46
|
-
entityId?:
|
|
45
|
+
entity?: number;
|
|
46
|
+
entityId?: number;
|
|
47
47
|
user?: User.Projection;
|
|
48
48
|
} & Partial<ExprOp<OpAttr | string>>;
|
|
49
49
|
export declare type ExportProjection = {
|
|
@@ -60,30 +60,30 @@ export declare type ExportProjection = {
|
|
|
60
60
|
user?: User.ExportProjection;
|
|
61
61
|
} & Partial<ExprOp<OpAttr | string>>;
|
|
62
62
|
declare type ModiEntityIdProjection = OneOf<{
|
|
63
|
-
id:
|
|
63
|
+
id: number;
|
|
64
64
|
}>;
|
|
65
65
|
declare type ModiIdProjection = OneOf<{
|
|
66
|
-
modiId:
|
|
66
|
+
modiId: number;
|
|
67
67
|
}>;
|
|
68
68
|
declare type UserIdProjection = OneOf<{
|
|
69
|
-
entityId:
|
|
69
|
+
entityId: number;
|
|
70
70
|
}>;
|
|
71
71
|
export declare type SortAttr = {
|
|
72
|
-
id:
|
|
72
|
+
id: number;
|
|
73
73
|
} | {
|
|
74
|
-
$$createAt$$:
|
|
74
|
+
$$createAt$$: number;
|
|
75
75
|
} | {
|
|
76
|
-
$$seq$$:
|
|
76
|
+
$$seq$$: number;
|
|
77
77
|
} | {
|
|
78
|
-
$$updateAt$$:
|
|
78
|
+
$$updateAt$$: number;
|
|
79
79
|
} | {
|
|
80
|
-
modiId:
|
|
80
|
+
modiId: number;
|
|
81
81
|
} | {
|
|
82
82
|
modi: Modi.SortAttr;
|
|
83
83
|
} | {
|
|
84
|
-
entity:
|
|
84
|
+
entity: number;
|
|
85
85
|
} | {
|
|
86
|
-
entityId:
|
|
86
|
+
entityId: number;
|
|
87
87
|
} | {
|
|
88
88
|
user: User.SortAttr;
|
|
89
89
|
} | {
|
|
@@ -41,15 +41,15 @@ export declare type Filter = MakeFilter<AttrFilter & ExprOp<OpAttr | string>>;
|
|
|
41
41
|
export declare type Projection = {
|
|
42
42
|
"#id"?: NodeId;
|
|
43
43
|
[k: string]: any;
|
|
44
|
-
id:
|
|
45
|
-
$$createAt$$?:
|
|
46
|
-
$$updateAt$$?:
|
|
47
|
-
$$seq$$?:
|
|
48
|
-
action?:
|
|
49
|
-
data?:
|
|
50
|
-
filter?:
|
|
51
|
-
extra?:
|
|
52
|
-
operatorId?:
|
|
44
|
+
id: number;
|
|
45
|
+
$$createAt$$?: number;
|
|
46
|
+
$$updateAt$$?: number;
|
|
47
|
+
$$seq$$?: number;
|
|
48
|
+
action?: number;
|
|
49
|
+
data?: number;
|
|
50
|
+
filter?: number;
|
|
51
|
+
extra?: number;
|
|
52
|
+
operatorId?: number;
|
|
53
53
|
operator?: User.Projection;
|
|
54
54
|
operEntity$oper?: OperEntity.Selection & {
|
|
55
55
|
$entity: "operEntity";
|
|
@@ -73,23 +73,23 @@ export declare type ExportProjection = {
|
|
|
73
73
|
};
|
|
74
74
|
} & Partial<ExprOp<OpAttr | string>>;
|
|
75
75
|
declare type OperIdProjection = OneOf<{
|
|
76
|
-
id:
|
|
76
|
+
id: number;
|
|
77
77
|
}>;
|
|
78
78
|
declare type UserIdProjection = OneOf<{
|
|
79
|
-
operatorId:
|
|
79
|
+
operatorId: number;
|
|
80
80
|
}>;
|
|
81
81
|
export declare type SortAttr = {
|
|
82
|
-
id:
|
|
82
|
+
id: number;
|
|
83
83
|
} | {
|
|
84
|
-
$$createAt$$:
|
|
84
|
+
$$createAt$$: number;
|
|
85
85
|
} | {
|
|
86
|
-
$$seq$$:
|
|
86
|
+
$$seq$$: number;
|
|
87
87
|
} | {
|
|
88
|
-
$$updateAt$$:
|
|
88
|
+
$$updateAt$$: number;
|
|
89
89
|
} | {
|
|
90
|
-
action:
|
|
90
|
+
action: number;
|
|
91
91
|
} | {
|
|
92
|
-
operatorId:
|
|
92
|
+
operatorId: number;
|
|
93
93
|
} | {
|
|
94
94
|
operator: User.SortAttr;
|
|
95
95
|
} | {
|
|
@@ -39,14 +39,14 @@ export declare type Filter<E = Q_EnumValue<"modi" | "user" | string>> = MakeFilt
|
|
|
39
39
|
export declare type Projection = {
|
|
40
40
|
"#id"?: NodeId;
|
|
41
41
|
[k: string]: any;
|
|
42
|
-
id:
|
|
43
|
-
$$createAt$$?:
|
|
44
|
-
$$updateAt$$?:
|
|
45
|
-
$$seq$$?:
|
|
46
|
-
operId?:
|
|
42
|
+
id: number;
|
|
43
|
+
$$createAt$$?: number;
|
|
44
|
+
$$updateAt$$?: number;
|
|
45
|
+
$$seq$$?: number;
|
|
46
|
+
operId?: number;
|
|
47
47
|
oper?: Oper.Projection;
|
|
48
|
-
entity?:
|
|
49
|
-
entityId?:
|
|
48
|
+
entity?: number;
|
|
49
|
+
entityId?: number;
|
|
50
50
|
modi?: Modi.Projection;
|
|
51
51
|
user?: User.Projection;
|
|
52
52
|
} & Partial<ExprOp<OpAttr | string>>;
|
|
@@ -65,33 +65,33 @@ export declare type ExportProjection = {
|
|
|
65
65
|
user?: User.ExportProjection;
|
|
66
66
|
} & Partial<ExprOp<OpAttr | string>>;
|
|
67
67
|
declare type OperEntityIdProjection = OneOf<{
|
|
68
|
-
id:
|
|
68
|
+
id: number;
|
|
69
69
|
}>;
|
|
70
70
|
declare type OperIdProjection = OneOf<{
|
|
71
|
-
operId:
|
|
71
|
+
operId: number;
|
|
72
72
|
}>;
|
|
73
73
|
declare type ModiIdProjection = OneOf<{
|
|
74
|
-
entityId:
|
|
74
|
+
entityId: number;
|
|
75
75
|
}>;
|
|
76
76
|
declare type UserIdProjection = OneOf<{
|
|
77
|
-
entityId:
|
|
77
|
+
entityId: number;
|
|
78
78
|
}>;
|
|
79
79
|
export declare type SortAttr = {
|
|
80
|
-
id:
|
|
80
|
+
id: number;
|
|
81
81
|
} | {
|
|
82
|
-
$$createAt$$:
|
|
82
|
+
$$createAt$$: number;
|
|
83
83
|
} | {
|
|
84
|
-
$$seq$$:
|
|
84
|
+
$$seq$$: number;
|
|
85
85
|
} | {
|
|
86
|
-
$$updateAt$$:
|
|
86
|
+
$$updateAt$$: number;
|
|
87
87
|
} | {
|
|
88
|
-
operId:
|
|
88
|
+
operId: number;
|
|
89
89
|
} | {
|
|
90
90
|
oper: Oper.SortAttr;
|
|
91
91
|
} | {
|
|
92
|
-
entity:
|
|
92
|
+
entity: number;
|
|
93
93
|
} | {
|
|
94
|
-
entityId:
|
|
94
|
+
entityId: number;
|
|
95
95
|
} | {
|
|
96
96
|
modi: Modi.SortAttr;
|
|
97
97
|
} | {
|
|
@@ -36,13 +36,13 @@ export declare type Filter = MakeFilter<AttrFilter & ExprOp<OpAttr | string>>;
|
|
|
36
36
|
export declare type Projection = {
|
|
37
37
|
"#id"?: NodeId;
|
|
38
38
|
[k: string]: any;
|
|
39
|
-
id:
|
|
40
|
-
$$createAt$$?:
|
|
41
|
-
$$updateAt$$?:
|
|
42
|
-
$$seq$$?:
|
|
43
|
-
name?:
|
|
44
|
-
nickname?:
|
|
45
|
-
password?:
|
|
39
|
+
id: number;
|
|
40
|
+
$$createAt$$?: number;
|
|
41
|
+
$$updateAt$$?: number;
|
|
42
|
+
$$seq$$?: number;
|
|
43
|
+
name?: number;
|
|
44
|
+
nickname?: number;
|
|
45
|
+
password?: number;
|
|
46
46
|
oper$operator?: Oper.Selection & {
|
|
47
47
|
$entity: "oper";
|
|
48
48
|
};
|
|
@@ -74,22 +74,22 @@ export declare type ExportProjection = {
|
|
|
74
74
|
};
|
|
75
75
|
} & Partial<ExprOp<OpAttr | string>>;
|
|
76
76
|
declare type UserIdProjection = OneOf<{
|
|
77
|
-
id:
|
|
77
|
+
id: number;
|
|
78
78
|
}>;
|
|
79
79
|
export declare type SortAttr = {
|
|
80
|
-
id:
|
|
80
|
+
id: number;
|
|
81
81
|
} | {
|
|
82
|
-
$$createAt$$:
|
|
82
|
+
$$createAt$$: number;
|
|
83
83
|
} | {
|
|
84
|
-
$$seq$$:
|
|
84
|
+
$$seq$$: number;
|
|
85
85
|
} | {
|
|
86
|
-
$$updateAt$$:
|
|
86
|
+
$$updateAt$$: number;
|
|
87
87
|
} | {
|
|
88
|
-
name:
|
|
88
|
+
name: number;
|
|
89
89
|
} | {
|
|
90
|
-
nickname:
|
|
90
|
+
nickname: number;
|
|
91
91
|
} | {
|
|
92
|
-
password:
|
|
92
|
+
password: number;
|
|
93
93
|
} | {
|
|
94
94
|
[k: string]: any;
|
|
95
95
|
} | OneOf<ExprOp<OpAttr | string>>;
|
package/lib/checkers/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { EntityDict } from '../base-app-domain';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { AsyncContext } from '../store/AsyncRowStore';
|
|
3
|
+
import { SyncContext } from '../store/SyncRowStore';
|
|
4
|
+
import { StorageSchema, EntityDict as BaseEntityDict } from '../types';
|
|
5
|
+
export declare function createDynamicCheckers<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED> | SyncContext<ED>>(schema: StorageSchema<ED>): import("../types").RowChecker<ED, keyof ED, Cxt>[];
|
|
@@ -1336,7 +1336,7 @@ function constructProjection(statements, entity) {
|
|
|
1336
1336
|
statements.push(factory.createTypeAliasDeclaration(undefined, [factory.createModifier(ts.SyntaxKind.ExportKeyword)], factory.createIdentifier("Projection"), undefined, factory.createIntersectionTypeNode([
|
|
1337
1337
|
factory.createTypeLiteralNode(MetaPropertySignaturs.concat(properties.map(function (_a) {
|
|
1338
1338
|
var _b = tslib_1.__read(_a, 3), n = _b[0], q = _b[1], v = _b[2];
|
|
1339
|
-
return factory.createPropertySignature(undefined, n, q ? undefined : factory.createToken(ts.SyntaxKind.QuestionToken), v || factory.
|
|
1339
|
+
return factory.createPropertySignature(undefined, n, q ? undefined : factory.createToken(ts.SyntaxKind.QuestionToken), v || factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword));
|
|
1340
1340
|
}))),
|
|
1341
1341
|
exprNode,
|
|
1342
1342
|
])));
|
|
@@ -1352,7 +1352,7 @@ function constructProjection(statements, entity) {
|
|
|
1352
1352
|
for (var foreignKey in foreignKeyProperties) {
|
|
1353
1353
|
var identifier = "".concat(foreignKey, "IdProjection");
|
|
1354
1354
|
statements.push(factory.createTypeAliasDeclaration(undefined, undefined, factory.createIdentifier(identifier), undefined, factory.createTypeReferenceNode(factory.createIdentifier("OneOf"), [
|
|
1355
|
-
factory.createTypeLiteralNode(foreignKeyProperties[foreignKey].map(function (attr) { return factory.createPropertySignature(undefined, attr ? factory.createIdentifier("".concat(attr, "Id")) : 'id', undefined, factory.
|
|
1355
|
+
factory.createTypeLiteralNode(foreignKeyProperties[foreignKey].map(function (attr) { return factory.createPropertySignature(undefined, attr ? factory.createIdentifier("".concat(attr, "Id")) : 'id', undefined, factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword)); }))
|
|
1356
1356
|
])));
|
|
1357
1357
|
}
|
|
1358
1358
|
}
|
|
@@ -1493,13 +1493,13 @@ function constructSorter(statements, entity) {
|
|
|
1493
1493
|
var schemaAttrs = Schema[entity].schemaAttrs;
|
|
1494
1494
|
var members = [
|
|
1495
1495
|
// id: 1
|
|
1496
|
-
factory.createTypeLiteralNode([factory.createPropertySignature(undefined, factory.createIdentifier("id"), undefined, factory.
|
|
1496
|
+
factory.createTypeLiteralNode([factory.createPropertySignature(undefined, factory.createIdentifier("id"), undefined, factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword))]),
|
|
1497
1497
|
// $$createAt$$: 1
|
|
1498
|
-
factory.createTypeLiteralNode([factory.createPropertySignature(undefined, factory.createIdentifier("$$createAt$$"), undefined, factory.
|
|
1498
|
+
factory.createTypeLiteralNode([factory.createPropertySignature(undefined, factory.createIdentifier("$$createAt$$"), undefined, factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword))]),
|
|
1499
1499
|
// $$seq$$: 1
|
|
1500
|
-
factory.createTypeLiteralNode([factory.createPropertySignature(undefined, factory.createIdentifier("$$seq$$"), undefined, factory.
|
|
1500
|
+
factory.createTypeLiteralNode([factory.createPropertySignature(undefined, factory.createIdentifier("$$seq$$"), undefined, factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword))]),
|
|
1501
1501
|
// $$updateAt$$: 1
|
|
1502
|
-
factory.createTypeLiteralNode([factory.createPropertySignature(undefined, factory.createIdentifier("$$updateAt$$"), undefined, factory.
|
|
1502
|
+
factory.createTypeLiteralNode([factory.createPropertySignature(undefined, factory.createIdentifier("$$updateAt$$"), undefined, factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword))]),
|
|
1503
1503
|
];
|
|
1504
1504
|
var _b = ManyToOne, _c = entity, manyToOneSet = _b[_c];
|
|
1505
1505
|
var _loop_6 = function (attr) {
|
|
@@ -1519,7 +1519,7 @@ function constructSorter(statements, entity) {
|
|
|
1519
1519
|
case 'Datetime':
|
|
1520
1520
|
case 'Image':
|
|
1521
1521
|
case 'File': {
|
|
1522
|
-
type2 = factory.
|
|
1522
|
+
type2 = factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword);
|
|
1523
1523
|
break;
|
|
1524
1524
|
}
|
|
1525
1525
|
default: {
|
|
@@ -1530,11 +1530,11 @@ function constructSorter(statements, entity) {
|
|
|
1530
1530
|
});
|
|
1531
1531
|
if (manyToOneItem) {
|
|
1532
1532
|
type2 = factory.createTypeReferenceNode(createForeignRef(entity, text2_5, 'SortAttr'));
|
|
1533
|
-
members.push(factory.createTypeLiteralNode([factory.createPropertySignature(undefined, factory.createIdentifier("".concat(name_5.text, "Id")), undefined, factory.
|
|
1533
|
+
members.push(factory.createTypeLiteralNode([factory.createPropertySignature(undefined, factory.createIdentifier("".concat(name_5.text, "Id")), undefined, factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword))]));
|
|
1534
1534
|
}
|
|
1535
1535
|
else if (!['Object'].includes(text)) {
|
|
1536
1536
|
// todo 对State的专门处理
|
|
1537
|
-
type2 = factory.
|
|
1537
|
+
type2 = factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword);
|
|
1538
1538
|
}
|
|
1539
1539
|
}
|
|
1540
1540
|
}
|
|
@@ -1544,7 +1544,7 @@ function constructSorter(statements, entity) {
|
|
|
1544
1544
|
}
|
|
1545
1545
|
}
|
|
1546
1546
|
else if (ts.isUnionTypeNode(type) && ts.isLiteralTypeNode(type.types[0]) || ts.isLiteralTypeNode(type)) {
|
|
1547
|
-
members.push(factory.createTypeLiteralNode([factory.createPropertySignature(undefined, name_5, undefined, factory.
|
|
1547
|
+
members.push(factory.createTypeLiteralNode([factory.createPropertySignature(undefined, name_5, undefined, factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword))]));
|
|
1548
1548
|
}
|
|
1549
1549
|
else {
|
|
1550
1550
|
// 本地规定的shape,非结构化属性不参与排序
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EntityDict, RowStore, OperateOption, OperationResult, SelectOption, Context, TxnOption, OpRecord } from "../types";
|
|
3
|
+
import { IncomingHttpHeaders } from "http";
|
|
4
|
+
export declare abstract class AsyncContext<ED extends EntityDict> implements Context {
|
|
5
|
+
private rowStore;
|
|
6
|
+
private uuid?;
|
|
7
|
+
opRecords: OpRecord<ED>[];
|
|
8
|
+
private scene?;
|
|
9
|
+
private headers?;
|
|
10
|
+
events: {
|
|
11
|
+
commit: Array<() => Promise<void>>;
|
|
12
|
+
rollback: Array<() => Promise<void>>;
|
|
13
|
+
};
|
|
14
|
+
constructor(store: AsyncRowStore<ED, AsyncContext<ED>>, headers?: IncomingHttpHeaders);
|
|
15
|
+
setHeaders(headers: IncomingHttpHeaders): void;
|
|
16
|
+
getHeader(key: string): string | string[] | undefined;
|
|
17
|
+
getScene(): string | undefined;
|
|
18
|
+
setScene(scene?: string): void;
|
|
19
|
+
private resetEvents;
|
|
20
|
+
on(event: 'commit' | 'rollback', callback: () => Promise<void>): void;
|
|
21
|
+
/**
|
|
22
|
+
* 一个context中不应该有并发的事务,这里将事务串行化,使用的时候千万要注意不要自己等自己
|
|
23
|
+
* @param options
|
|
24
|
+
*/
|
|
25
|
+
begin(options?: TxnOption): Promise<void>;
|
|
26
|
+
commit(): Promise<void>;
|
|
27
|
+
rollback(): Promise<void>;
|
|
28
|
+
operate<T extends keyof ED, OP extends OperateOption>(entity: T, operation: ED[T]['Operation'], option: OP): Promise<OperationResult<ED>>;
|
|
29
|
+
select<T extends keyof ED, OP extends SelectOption>(entity: T, selection: ED[T]['Selection'], option: OP): Promise<Partial<ED[T]["Schema"]>[]>;
|
|
30
|
+
count<T extends keyof ED, OP extends SelectOption>(entity: T, selection: Pick<ED[T]['Selection'], 'filter' | 'count'>, option: OP): Promise<number>;
|
|
31
|
+
mergeMultipleResults(toBeMerged: OperationResult<ED>[]): OperationResult<ED>;
|
|
32
|
+
getCurrentTxnId(): string | undefined;
|
|
33
|
+
getSchema(): import("../types").StorageSchema<ED>;
|
|
34
|
+
abstract isRoot(): boolean;
|
|
35
|
+
abstract getCurrentUserId(allowUnloggedIn?: boolean): string | undefined;
|
|
36
|
+
abstract toString(): string;
|
|
37
|
+
}
|
|
38
|
+
export interface AsyncRowStore<ED extends EntityDict, Cxt extends Context> extends RowStore<ED> {
|
|
39
|
+
operate<T extends keyof ED, OP extends OperateOption>(entity: T, operation: ED[T]['Operation'], context: Cxt, option: OP): Promise<OperationResult<ED>>;
|
|
40
|
+
select<T extends keyof ED, OP extends SelectOption>(entity: T, selection: ED[T]['Selection'], context: Cxt, option: OP): Promise<Partial<ED[T]['Schema']>[]>;
|
|
41
|
+
count<T extends keyof ED, OP extends SelectOption>(entity: T, selection: Pick<ED[T]['Selection'], 'filter' | 'count'>, context: Cxt, option: OP): Promise<number>;
|
|
42
|
+
begin(option?: TxnOption): Promise<string>;
|
|
43
|
+
commit(txnId: string): Promise<void>;
|
|
44
|
+
rollback(txnId: string): Promise<void>;
|
|
45
|
+
}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.AsyncContext = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var assert_1 = tslib_1.__importDefault(require("assert"));
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
function UniversalContext(store, headers) {
|
|
6
|
+
var AsyncContext = /** @class */ (function () {
|
|
7
|
+
function AsyncContext(store, headers) {
|
|
9
8
|
this.rowStore = store;
|
|
10
9
|
this.opRecords = [];
|
|
11
|
-
this.rwLock = new concurrent_1.RWLock();
|
|
12
10
|
this.events = {
|
|
13
11
|
commit: [],
|
|
14
12
|
rollback: [],
|
|
@@ -17,56 +15,54 @@ var UniversalContext = /** @class */ (function () {
|
|
|
17
15
|
this.headers = headers;
|
|
18
16
|
}
|
|
19
17
|
}
|
|
20
|
-
|
|
18
|
+
AsyncContext.prototype.setHeaders = function (headers) {
|
|
21
19
|
this.headers = headers;
|
|
22
20
|
};
|
|
23
|
-
|
|
21
|
+
AsyncContext.prototype.getHeader = function (key) {
|
|
24
22
|
if (this.headers) {
|
|
25
23
|
return this.headers[key];
|
|
26
24
|
}
|
|
27
25
|
};
|
|
28
|
-
|
|
26
|
+
AsyncContext.prototype.getScene = function () {
|
|
29
27
|
return this.scene;
|
|
30
28
|
};
|
|
31
|
-
|
|
29
|
+
AsyncContext.prototype.setScene = function (scene) {
|
|
32
30
|
this.scene = scene;
|
|
33
31
|
};
|
|
34
|
-
|
|
32
|
+
AsyncContext.prototype.resetEvents = function () {
|
|
35
33
|
this.events = {
|
|
36
34
|
commit: [],
|
|
37
35
|
rollback: [],
|
|
38
36
|
};
|
|
39
37
|
};
|
|
40
|
-
|
|
38
|
+
AsyncContext.prototype.on = function (event, callback) {
|
|
41
39
|
this.uuid && this.events[event].push(callback);
|
|
42
40
|
};
|
|
43
41
|
/**
|
|
44
42
|
* 一个context中不应该有并发的事务,这里将事务串行化,使用的时候千万要注意不要自己等自己
|
|
45
43
|
* @param options
|
|
46
44
|
*/
|
|
47
|
-
|
|
45
|
+
AsyncContext.prototype.begin = function (options) {
|
|
48
46
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
49
47
|
var _a;
|
|
50
48
|
return tslib_1.__generator(this, function (_b) {
|
|
51
49
|
switch (_b.label) {
|
|
52
|
-
case 0:
|
|
53
|
-
|
|
54
|
-
_b.sent();
|
|
55
|
-
if (!!this.uuid) return [3 /*break*/, 3];
|
|
50
|
+
case 0:
|
|
51
|
+
if (!!this.uuid) return [3 /*break*/, 2];
|
|
56
52
|
_a = this;
|
|
57
53
|
return [4 /*yield*/, this.rowStore.begin(options)];
|
|
58
|
-
case
|
|
54
|
+
case 1:
|
|
59
55
|
_a.uuid = _b.sent();
|
|
60
|
-
return [3 /*break*/,
|
|
61
|
-
case
|
|
56
|
+
return [3 /*break*/, 3];
|
|
57
|
+
case 2:
|
|
62
58
|
(0, assert_1.default)(false);
|
|
63
|
-
_b.label =
|
|
64
|
-
case
|
|
59
|
+
_b.label = 3;
|
|
60
|
+
case 3: return [2 /*return*/];
|
|
65
61
|
}
|
|
66
62
|
});
|
|
67
63
|
});
|
|
68
64
|
};
|
|
69
|
-
|
|
65
|
+
AsyncContext.prototype.commit = function () {
|
|
70
66
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
71
67
|
var _a, _b, e, e_1_1;
|
|
72
68
|
var e_1, _c;
|
|
@@ -77,9 +73,7 @@ var UniversalContext = /** @class */ (function () {
|
|
|
77
73
|
return [4 /*yield*/, this.rowStore.commit(this.uuid)];
|
|
78
74
|
case 1:
|
|
79
75
|
_d.sent();
|
|
80
|
-
// console.log('commit', this.uuid);
|
|
81
76
|
this.uuid = undefined;
|
|
82
|
-
this.rwLock.release();
|
|
83
77
|
_d.label = 2;
|
|
84
78
|
case 2:
|
|
85
79
|
_d.trys.push([2, 7, 8, 9]);
|
|
@@ -114,7 +108,7 @@ var UniversalContext = /** @class */ (function () {
|
|
|
114
108
|
});
|
|
115
109
|
});
|
|
116
110
|
};
|
|
117
|
-
|
|
111
|
+
AsyncContext.prototype.rollback = function () {
|
|
118
112
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
119
113
|
var _a, _b, e, e_2_1;
|
|
120
114
|
var e_2, _c;
|
|
@@ -127,7 +121,6 @@ var UniversalContext = /** @class */ (function () {
|
|
|
127
121
|
_d.sent();
|
|
128
122
|
// console.log('rollback', this.uuid);
|
|
129
123
|
this.uuid = undefined;
|
|
130
|
-
this.rwLock.release();
|
|
131
124
|
_d.label = 2;
|
|
132
125
|
case 2:
|
|
133
126
|
_d.trys.push([2, 7, 8, 9]);
|
|
@@ -162,9 +155,26 @@ var UniversalContext = /** @class */ (function () {
|
|
|
162
155
|
});
|
|
163
156
|
});
|
|
164
157
|
};
|
|
165
|
-
|
|
158
|
+
AsyncContext.prototype.operate = function (entity, operation, option) {
|
|
159
|
+
return this.rowStore.operate(entity, operation, this, option);
|
|
160
|
+
};
|
|
161
|
+
AsyncContext.prototype.select = function (entity, selection, option) {
|
|
162
|
+
return this.rowStore.select(entity, selection, this, option);
|
|
163
|
+
};
|
|
164
|
+
AsyncContext.prototype.count = function (entity, selection, option) {
|
|
165
|
+
return this.rowStore.count(entity, selection, this, option);
|
|
166
|
+
};
|
|
167
|
+
AsyncContext.prototype.mergeMultipleResults = function (toBeMerged) {
|
|
168
|
+
return this.rowStore.mergeMultipleResults(toBeMerged);
|
|
169
|
+
};
|
|
170
|
+
AsyncContext.prototype.getCurrentTxnId = function () {
|
|
166
171
|
return this.uuid;
|
|
167
172
|
};
|
|
168
|
-
|
|
173
|
+
AsyncContext.prototype.getSchema = function () {
|
|
174
|
+
return this.rowStore.getSchema();
|
|
175
|
+
};
|
|
176
|
+
return AsyncContext;
|
|
169
177
|
}());
|
|
170
|
-
exports.
|
|
178
|
+
exports.AsyncContext = AsyncContext;
|
|
179
|
+
;
|
|
180
|
+
;
|