oak-domain 1.1.12 → 1.1.14
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 +9 -12
- package/lib/base-app-domain/ModiEntity/Schema.d.ts +9 -12
- package/lib/base-app-domain/Oper/Schema.d.ts +9 -12
- package/lib/base-app-domain/OperEntity/Schema.d.ts +9 -12
- package/lib/base-app-domain/User/Schema.d.ts +9 -12
- package/lib/compiler/schemalBuilder.js +13 -15
- package/lib/store/CascadeStore.js +13 -8
- package/lib/store/UniversalContext.d.ts +1 -1
- package/lib/store/actionDef.js +3 -2
- package/lib/store/filter.js +1 -1
- package/lib/store/modi.js +4 -33
- package/lib/store/selection.js +1 -0
- package/lib/triggers/modi.js +12 -22
- package/lib/types/Context.d.ts +1 -1
- package/lib/types/DataType.d.ts +1 -0
- package/lib/types/Entity.d.ts +7 -4
- package/lib/types/Entity.js +1 -1
- package/lib/types/Exception.d.ts +6 -1
- package/lib/types/Exception.js +20 -3
- package/lib/types/Storage.d.ts +1 -0
- package/lib/types/schema/DataTypes.d.ts +1 -1
- package/lib/utils/lodash.d.ts +1 -16
- package/lib/utils/lodash.js +31 -31
- package/lib/utils/validator.d.ts +2 -2
- package/lib/utils/validator.js +4 -4
- package/package.json +1 -1
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
import { String
|
|
1
|
+
import { String } from "../../types/DataType";
|
|
2
2
|
import { Q_DateValue, Q_StringValue, Q_EnumValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "../../types/Demand";
|
|
3
3
|
import { OneOf } from "../../types/Polyfill";
|
|
4
4
|
import * as SubQuery from "../_SubQuery";
|
|
5
|
-
import { FormCreateData, FormUpdateData, Operation as OakOperation, MakeAction as OakMakeAction } from "../../types/Entity";
|
|
5
|
+
import { FormCreateData, FormUpdateData, Operation as OakOperation, MakeAction as OakMakeAction, EntityShape } from "../../types/Entity";
|
|
6
6
|
import { Action, ParticularAction, IState } from "./Action";
|
|
7
7
|
import * as ModiEntity from "../ModiEntity/Schema";
|
|
8
8
|
import * as OperEntity from "../OperEntity/Schema";
|
|
9
|
-
export declare type OpSchema = {
|
|
10
|
-
id: PrimaryKey;
|
|
11
|
-
$$createAt$$: Datetime;
|
|
12
|
-
$$updateAt$$: Datetime;
|
|
13
|
-
$$deleteAt$$?: Datetime | null;
|
|
9
|
+
export declare type OpSchema = EntityShape & {
|
|
14
10
|
targetEntity: String<32>;
|
|
15
11
|
entity: String<32>;
|
|
16
12
|
entityId: String<64>;
|
|
@@ -21,11 +17,7 @@ export declare type OpSchema = {
|
|
|
21
17
|
iState?: IState | null;
|
|
22
18
|
};
|
|
23
19
|
export declare type OpAttr = keyof OpSchema;
|
|
24
|
-
export declare type Schema = {
|
|
25
|
-
id: PrimaryKey;
|
|
26
|
-
$$createAt$$: Datetime;
|
|
27
|
-
$$updateAt$$: Datetime;
|
|
28
|
-
$$deleteAt$$?: Datetime | null;
|
|
20
|
+
export declare type Schema = EntityShape & {
|
|
29
21
|
targetEntity: String<32>;
|
|
30
22
|
entity: String<32>;
|
|
31
23
|
entityId: String<64>;
|
|
@@ -42,6 +34,7 @@ export declare type Schema = {
|
|
|
42
34
|
declare type AttrFilter = {
|
|
43
35
|
id: Q_StringValue | SubQuery.ModiIdSubQuery;
|
|
44
36
|
$$createAt$$: Q_DateValue;
|
|
37
|
+
$$seq$$: Q_StringValue;
|
|
45
38
|
$$updateAt$$: Q_DateValue;
|
|
46
39
|
targetEntity: Q_StringValue;
|
|
47
40
|
entity: Q_StringValue;
|
|
@@ -59,6 +52,7 @@ export declare type Projection = {
|
|
|
59
52
|
id: 1;
|
|
60
53
|
$$createAt$$?: 1;
|
|
61
54
|
$$updateAt$$?: 1;
|
|
55
|
+
$$seq$$?: 1;
|
|
62
56
|
targetEntity?: 1;
|
|
63
57
|
entity?: 1;
|
|
64
58
|
entityId?: 1;
|
|
@@ -80,6 +74,7 @@ export declare type ExportProjection = {
|
|
|
80
74
|
id?: string;
|
|
81
75
|
$$createAt$$?: string;
|
|
82
76
|
$$updateAt$$?: string;
|
|
77
|
+
$$seq$$?: string;
|
|
83
78
|
targetEntity?: string;
|
|
84
79
|
entity?: string;
|
|
85
80
|
entityId?: string;
|
|
@@ -102,6 +97,8 @@ export declare type SortAttr = {
|
|
|
102
97
|
id: 1;
|
|
103
98
|
} | {
|
|
104
99
|
$$createAt$$: 1;
|
|
100
|
+
} | {
|
|
101
|
+
$$seq$$: 1;
|
|
105
102
|
} | {
|
|
106
103
|
$$updateAt$$: 1;
|
|
107
104
|
} | {
|
|
@@ -1,26 +1,18 @@
|
|
|
1
|
-
import { String,
|
|
1
|
+
import { String, ForeignKey } from "../../types/DataType";
|
|
2
2
|
import { Q_DateValue, Q_StringValue, Q_EnumValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "../../types/Demand";
|
|
3
3
|
import { OneOf } from "../../types/Polyfill";
|
|
4
4
|
import * as SubQuery from "../_SubQuery";
|
|
5
|
-
import { FormCreateData, FormUpdateData, Operation as OakOperation, MakeAction as OakMakeAction } from "../../types/Entity";
|
|
5
|
+
import { FormCreateData, FormUpdateData, Operation as OakOperation, MakeAction as OakMakeAction, EntityShape } from "../../types/Entity";
|
|
6
6
|
import { AppendOnlyAction } from "../../actions/action";
|
|
7
7
|
import * as Modi from "../Modi/Schema";
|
|
8
8
|
import * as User from "../User/Schema";
|
|
9
|
-
export declare type OpSchema = {
|
|
10
|
-
id: PrimaryKey;
|
|
11
|
-
$$createAt$$: Datetime;
|
|
12
|
-
$$updateAt$$: Datetime;
|
|
13
|
-
$$deleteAt$$?: Datetime | null;
|
|
9
|
+
export declare type OpSchema = EntityShape & {
|
|
14
10
|
modiId: ForeignKey<"modi">;
|
|
15
11
|
entity: "user" | string;
|
|
16
12
|
entityId: String<64>;
|
|
17
13
|
};
|
|
18
14
|
export declare type OpAttr = keyof OpSchema;
|
|
19
|
-
export declare type Schema = {
|
|
20
|
-
id: PrimaryKey;
|
|
21
|
-
$$createAt$$: Datetime;
|
|
22
|
-
$$updateAt$$: Datetime;
|
|
23
|
-
$$deleteAt$$?: Datetime | null;
|
|
15
|
+
export declare type Schema = EntityShape & {
|
|
24
16
|
modiId: ForeignKey<"modi">;
|
|
25
17
|
entity: "user" | string;
|
|
26
18
|
entityId: String<64>;
|
|
@@ -32,6 +24,7 @@ export declare type Schema = {
|
|
|
32
24
|
declare type AttrFilter<E> = {
|
|
33
25
|
id: Q_StringValue | SubQuery.ModiEntityIdSubQuery;
|
|
34
26
|
$$createAt$$: Q_DateValue;
|
|
27
|
+
$$seq$$: Q_StringValue;
|
|
35
28
|
$$updateAt$$: Q_DateValue;
|
|
36
29
|
modiId: Q_StringValue | SubQuery.ModiIdSubQuery;
|
|
37
30
|
modi: Modi.Filter;
|
|
@@ -46,6 +39,7 @@ export declare type Projection = {
|
|
|
46
39
|
id: 1;
|
|
47
40
|
$$createAt$$?: 1;
|
|
48
41
|
$$updateAt$$?: 1;
|
|
42
|
+
$$seq$$?: 1;
|
|
49
43
|
modiId?: 1;
|
|
50
44
|
modi?: Modi.Projection;
|
|
51
45
|
entity?: 1;
|
|
@@ -58,6 +52,7 @@ export declare type ExportProjection = {
|
|
|
58
52
|
id?: string;
|
|
59
53
|
$$createAt$$?: string;
|
|
60
54
|
$$updateAt$$?: string;
|
|
55
|
+
$$seq$$?: string;
|
|
61
56
|
modiId?: string;
|
|
62
57
|
modi?: Modi.ExportProjection;
|
|
63
58
|
entity?: string;
|
|
@@ -77,6 +72,8 @@ export declare type SortAttr = {
|
|
|
77
72
|
id: 1;
|
|
78
73
|
} | {
|
|
79
74
|
$$createAt$$: 1;
|
|
75
|
+
} | {
|
|
76
|
+
$$seq$$: 1;
|
|
80
77
|
} | {
|
|
81
78
|
$$updateAt$$: 1;
|
|
82
79
|
} | {
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
import { String,
|
|
1
|
+
import { String, ForeignKey } from "../../types/DataType";
|
|
2
2
|
import { Q_DateValue, Q_StringValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "../../types/Demand";
|
|
3
3
|
import { OneOf } from "../../types/Polyfill";
|
|
4
4
|
import * as SubQuery from "../_SubQuery";
|
|
5
|
-
import { FormCreateData, FormUpdateData, Operation as OakOperation, MakeAction as OakMakeAction } from "../../types/Entity";
|
|
5
|
+
import { FormCreateData, FormUpdateData, Operation as OakOperation, MakeAction as OakMakeAction, EntityShape } from "../../types/Entity";
|
|
6
6
|
import { AppendOnlyAction } from "../../actions/action";
|
|
7
7
|
import * as User from "../User/Schema";
|
|
8
8
|
import * as OperEntity from "../OperEntity/Schema";
|
|
9
|
-
export declare type OpSchema = {
|
|
10
|
-
id: PrimaryKey;
|
|
11
|
-
$$createAt$$: Datetime;
|
|
12
|
-
$$updateAt$$: Datetime;
|
|
13
|
-
$$deleteAt$$?: Datetime | null;
|
|
9
|
+
export declare type OpSchema = EntityShape & {
|
|
14
10
|
action: String<16>;
|
|
15
11
|
data: Object;
|
|
16
12
|
filter?: Object | null;
|
|
@@ -18,11 +14,7 @@ export declare type OpSchema = {
|
|
|
18
14
|
operatorId?: ForeignKey<"user"> | null;
|
|
19
15
|
};
|
|
20
16
|
export declare type OpAttr = keyof OpSchema;
|
|
21
|
-
export declare type Schema = {
|
|
22
|
-
id: PrimaryKey;
|
|
23
|
-
$$createAt$$: Datetime;
|
|
24
|
-
$$updateAt$$: Datetime;
|
|
25
|
-
$$deleteAt$$?: Datetime | null;
|
|
17
|
+
export declare type Schema = EntityShape & {
|
|
26
18
|
action: String<16>;
|
|
27
19
|
data: Object;
|
|
28
20
|
filter?: Object | null;
|
|
@@ -36,6 +28,7 @@ export declare type Schema = {
|
|
|
36
28
|
declare type AttrFilter = {
|
|
37
29
|
id: Q_StringValue | SubQuery.OperIdSubQuery;
|
|
38
30
|
$$createAt$$: Q_DateValue;
|
|
31
|
+
$$seq$$: Q_StringValue;
|
|
39
32
|
$$updateAt$$: Q_DateValue;
|
|
40
33
|
action: Q_StringValue;
|
|
41
34
|
data: Object;
|
|
@@ -51,6 +44,7 @@ export declare type Projection = {
|
|
|
51
44
|
id: 1;
|
|
52
45
|
$$createAt$$?: 1;
|
|
53
46
|
$$updateAt$$?: 1;
|
|
47
|
+
$$seq$$?: 1;
|
|
54
48
|
action?: 1;
|
|
55
49
|
data?: 1;
|
|
56
50
|
filter?: 1;
|
|
@@ -67,6 +61,7 @@ export declare type ExportProjection = {
|
|
|
67
61
|
id?: string;
|
|
68
62
|
$$createAt$$?: string;
|
|
69
63
|
$$updateAt$$?: string;
|
|
64
|
+
$$seq$$?: string;
|
|
70
65
|
action?: string;
|
|
71
66
|
data?: string;
|
|
72
67
|
filter?: string;
|
|
@@ -87,6 +82,8 @@ export declare type SortAttr = {
|
|
|
87
82
|
id: 1;
|
|
88
83
|
} | {
|
|
89
84
|
$$createAt$$: 1;
|
|
85
|
+
} | {
|
|
86
|
+
$$seq$$: 1;
|
|
90
87
|
} | {
|
|
91
88
|
$$updateAt$$: 1;
|
|
92
89
|
} | {
|
|
@@ -1,27 +1,19 @@
|
|
|
1
|
-
import { String,
|
|
1
|
+
import { String, ForeignKey } from "../../types/DataType";
|
|
2
2
|
import { Q_DateValue, Q_StringValue, Q_EnumValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "../../types/Demand";
|
|
3
3
|
import { OneOf } from "../../types/Polyfill";
|
|
4
4
|
import * as SubQuery from "../_SubQuery";
|
|
5
|
-
import { FormCreateData, FormUpdateData, Operation as OakOperation, MakeAction as OakMakeAction } from "../../types/Entity";
|
|
5
|
+
import { FormCreateData, FormUpdateData, Operation as OakOperation, MakeAction as OakMakeAction, EntityShape } from "../../types/Entity";
|
|
6
6
|
import { AppendOnlyAction } from "../../actions/action";
|
|
7
7
|
import * as Oper from "../Oper/Schema";
|
|
8
8
|
import * as Modi from "../Modi/Schema";
|
|
9
9
|
import * as User from "../User/Schema";
|
|
10
|
-
export declare type OpSchema = {
|
|
11
|
-
id: PrimaryKey;
|
|
12
|
-
$$createAt$$: Datetime;
|
|
13
|
-
$$updateAt$$: Datetime;
|
|
14
|
-
$$deleteAt$$?: Datetime | null;
|
|
10
|
+
export declare type OpSchema = EntityShape & {
|
|
15
11
|
operId: ForeignKey<"oper">;
|
|
16
12
|
entity: "modi" | "user" | string;
|
|
17
13
|
entityId: String<64>;
|
|
18
14
|
};
|
|
19
15
|
export declare type OpAttr = keyof OpSchema;
|
|
20
|
-
export declare type Schema = {
|
|
21
|
-
id: PrimaryKey;
|
|
22
|
-
$$createAt$$: Datetime;
|
|
23
|
-
$$updateAt$$: Datetime;
|
|
24
|
-
$$deleteAt$$?: Datetime | null;
|
|
16
|
+
export declare type Schema = EntityShape & {
|
|
25
17
|
operId: ForeignKey<"oper">;
|
|
26
18
|
entity: "modi" | "user" | string;
|
|
27
19
|
entityId: String<64>;
|
|
@@ -34,6 +26,7 @@ export declare type Schema = {
|
|
|
34
26
|
declare type AttrFilter<E> = {
|
|
35
27
|
id: Q_StringValue | SubQuery.OperEntityIdSubQuery;
|
|
36
28
|
$$createAt$$: Q_DateValue;
|
|
29
|
+
$$seq$$: Q_StringValue;
|
|
37
30
|
$$updateAt$$: Q_DateValue;
|
|
38
31
|
operId: Q_StringValue | SubQuery.OperIdSubQuery;
|
|
39
32
|
oper: Oper.Filter;
|
|
@@ -49,6 +42,7 @@ export declare type Projection = {
|
|
|
49
42
|
id: 1;
|
|
50
43
|
$$createAt$$?: 1;
|
|
51
44
|
$$updateAt$$?: 1;
|
|
45
|
+
$$seq$$?: 1;
|
|
52
46
|
operId?: 1;
|
|
53
47
|
oper?: Oper.Projection;
|
|
54
48
|
entity?: 1;
|
|
@@ -62,6 +56,7 @@ export declare type ExportProjection = {
|
|
|
62
56
|
id?: string;
|
|
63
57
|
$$createAt$$?: string;
|
|
64
58
|
$$updateAt$$?: string;
|
|
59
|
+
$$seq$$?: string;
|
|
65
60
|
operId?: string;
|
|
66
61
|
oper?: Oper.ExportProjection;
|
|
67
62
|
entity?: string;
|
|
@@ -85,6 +80,8 @@ export declare type SortAttr = {
|
|
|
85
80
|
id: 1;
|
|
86
81
|
} | {
|
|
87
82
|
$$createAt$$: 1;
|
|
83
|
+
} | {
|
|
84
|
+
$$seq$$: 1;
|
|
88
85
|
} | {
|
|
89
86
|
$$updateAt$$: 1;
|
|
90
87
|
} | {
|
|
@@ -1,27 +1,19 @@
|
|
|
1
|
-
import { String, Text
|
|
1
|
+
import { String, Text } from "../../types/DataType";
|
|
2
2
|
import { Q_DateValue, Q_StringValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "../../types/Demand";
|
|
3
3
|
import { OneOf } from "../../types/Polyfill";
|
|
4
4
|
import * as SubQuery from "../_SubQuery";
|
|
5
|
-
import { FormCreateData, FormUpdateData, Operation as OakOperation, MakeAction as OakMakeAction } from "../../types/Entity";
|
|
5
|
+
import { FormCreateData, FormUpdateData, Operation as OakOperation, MakeAction as OakMakeAction, EntityShape } from "../../types/Entity";
|
|
6
6
|
import { GenericAction, RelationAction } from "../../actions/action";
|
|
7
7
|
import * as Oper from "../Oper/Schema";
|
|
8
8
|
import * as OperEntity from "../OperEntity/Schema";
|
|
9
9
|
import * as ModiEntity from "../ModiEntity/Schema";
|
|
10
|
-
export declare type OpSchema = {
|
|
11
|
-
id: PrimaryKey;
|
|
12
|
-
$$createAt$$: Datetime;
|
|
13
|
-
$$updateAt$$: Datetime;
|
|
14
|
-
$$deleteAt$$?: Datetime | null;
|
|
10
|
+
export declare type OpSchema = EntityShape & {
|
|
15
11
|
name?: String<16> | null;
|
|
16
12
|
nickname?: String<64> | null;
|
|
17
13
|
password?: Text | null;
|
|
18
14
|
};
|
|
19
15
|
export declare type OpAttr = keyof OpSchema;
|
|
20
|
-
export declare type Schema = {
|
|
21
|
-
id: PrimaryKey;
|
|
22
|
-
$$createAt$$: Datetime;
|
|
23
|
-
$$updateAt$$: Datetime;
|
|
24
|
-
$$deleteAt$$?: Datetime | null;
|
|
16
|
+
export declare type Schema = EntityShape & {
|
|
25
17
|
name?: String<16> | null;
|
|
26
18
|
nickname?: String<64> | null;
|
|
27
19
|
password?: Text | null;
|
|
@@ -34,6 +26,7 @@ export declare type Schema = {
|
|
|
34
26
|
declare type AttrFilter = {
|
|
35
27
|
id: Q_StringValue | SubQuery.UserIdSubQuery;
|
|
36
28
|
$$createAt$$: Q_DateValue;
|
|
29
|
+
$$seq$$: Q_StringValue;
|
|
37
30
|
$$updateAt$$: Q_DateValue;
|
|
38
31
|
name: Q_StringValue;
|
|
39
32
|
nickname: Q_StringValue;
|
|
@@ -46,6 +39,7 @@ export declare type Projection = {
|
|
|
46
39
|
id: 1;
|
|
47
40
|
$$createAt$$?: 1;
|
|
48
41
|
$$updateAt$$?: 1;
|
|
42
|
+
$$seq$$?: 1;
|
|
49
43
|
name?: 1;
|
|
50
44
|
nickname?: 1;
|
|
51
45
|
password?: 1;
|
|
@@ -65,6 +59,7 @@ export declare type ExportProjection = {
|
|
|
65
59
|
id?: string;
|
|
66
60
|
$$createAt$$?: string;
|
|
67
61
|
$$updateAt$$?: string;
|
|
62
|
+
$$seq$$?: string;
|
|
68
63
|
name?: string;
|
|
69
64
|
nickname?: string;
|
|
70
65
|
password?: string;
|
|
@@ -85,6 +80,8 @@ export declare type SortAttr = {
|
|
|
85
80
|
id: 1;
|
|
86
81
|
} | {
|
|
87
82
|
$$createAt$$: 1;
|
|
83
|
+
} | {
|
|
84
|
+
$$seq$$: 1;
|
|
88
85
|
} | {
|
|
89
86
|
$$updateAt$$: 1;
|
|
90
87
|
} | {
|
|
@@ -850,19 +850,7 @@ function analyzeEntity(filename, path, program, relativePath) {
|
|
|
850
850
|
function constructSchema(statements, entity) {
|
|
851
851
|
var e_1, _a, e_2, _b;
|
|
852
852
|
var schemaAttrs = Schema[entity].schemaAttrs;
|
|
853
|
-
var members = [
|
|
854
|
-
// id: String<64>
|
|
855
|
-
factory.createPropertySignature(undefined, factory.createIdentifier('id'), undefined, factory.createTypeReferenceNode(factory.createIdentifier('PrimaryKey'))),
|
|
856
|
-
// $$createAt$$: Datetime
|
|
857
|
-
factory.createPropertySignature(undefined, factory.createIdentifier('$$createAt$$'), undefined, factory.createTypeReferenceNode(factory.createIdentifier('Datetime'))),
|
|
858
|
-
// $$updateAt$$: Datetime
|
|
859
|
-
factory.createPropertySignature(undefined, factory.createIdentifier('$$updateAt$$'), undefined, factory.createTypeReferenceNode(factory.createIdentifier('Datetime'))),
|
|
860
|
-
// $$updateAt$$: Datetime
|
|
861
|
-
factory.createPropertySignature(undefined, factory.createIdentifier('$$deleteAt$$'), factory.createToken(ts.SyntaxKind.QuestionToken), factory.createUnionTypeNode([
|
|
862
|
-
factory.createTypeReferenceNode(factory.createIdentifier('Datetime')),
|
|
863
|
-
factory.createLiteralTypeNode(factory.createNull())
|
|
864
|
-
]))
|
|
865
|
-
];
|
|
853
|
+
var members = [];
|
|
866
854
|
var members2 = [];
|
|
867
855
|
var _c = ManyToOne, _d = entity, manyToOneSet = _c[_d];
|
|
868
856
|
var _e = OneToMany, _f = entity, oneToManySet = _e[_f];
|
|
@@ -997,10 +985,14 @@ function constructSchema(statements, entity) {
|
|
|
997
985
|
}
|
|
998
986
|
statements.push(factory.createTypeAliasDeclaration(undefined, [
|
|
999
987
|
factory.createModifier(ts.SyntaxKind.ExportKeyword)
|
|
1000
|
-
], factory.createIdentifier('OpSchema'), undefined, factory.
|
|
988
|
+
], factory.createIdentifier('OpSchema'), undefined, factory.createIntersectionTypeNode([
|
|
989
|
+
factory.createTypeReferenceNode('EntityShape'),
|
|
990
|
+
factory.createTypeLiteralNode(members)
|
|
991
|
+
])), factory.createTypeAliasDeclaration(undefined, [factory.createModifier(ts.SyntaxKind.ExportKeyword)], factory.createIdentifier("OpAttr"), undefined, factory.createTypeOperatorNode(ts.SyntaxKind.KeyOfKeyword, factory.createTypeReferenceNode(factory.createIdentifier("OpSchema"), undefined))));
|
|
1001
992
|
statements.push(factory.createTypeAliasDeclaration(undefined, [
|
|
1002
993
|
factory.createModifier(ts.SyntaxKind.ExportKeyword)
|
|
1003
994
|
], factory.createIdentifier('Schema'), undefined, factory.createIntersectionTypeNode([
|
|
995
|
+
factory.createTypeReferenceNode('EntityShape'),
|
|
1004
996
|
factory.createTypeLiteralNode(members.concat(members2)),
|
|
1005
997
|
factory.createMappedTypeNode(undefined, factory.createTypeParameterDeclaration(undefined, factory.createIdentifier("A"), factory.createTypeReferenceNode(factory.createIdentifier("ExpressionKey"), undefined), undefined), undefined, factory.createToken(ts.SyntaxKind.QuestionToken), factory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword), undefined)
|
|
1006
998
|
])));
|
|
@@ -1022,6 +1014,8 @@ function constructFilter(statements, entity) {
|
|
|
1022
1014
|
])),
|
|
1023
1015
|
// $$createAt$$: Q_DateValue
|
|
1024
1016
|
factory.createPropertySignature(undefined, factory.createIdentifier('$$createAt$$'), undefined, factory.createTypeReferenceNode(factory.createIdentifier('Q_DateValue'))),
|
|
1017
|
+
// $$seq$$: Q_StringValue
|
|
1018
|
+
factory.createPropertySignature(undefined, factory.createIdentifier('$$seq$$'), undefined, factory.createTypeReferenceNode(factory.createIdentifier('Q_StringValue'))),
|
|
1025
1019
|
// $$updateAt$$: Q_DateValue
|
|
1026
1020
|
factory.createPropertySignature(undefined, factory.createIdentifier('$$updateAt$$'), undefined, factory.createTypeReferenceNode(factory.createIdentifier('Q_DateValue')))
|
|
1027
1021
|
];
|
|
@@ -1176,6 +1170,7 @@ function constructProjection(statements, entity) {
|
|
|
1176
1170
|
['id', true],
|
|
1177
1171
|
['$$createAt$$', false],
|
|
1178
1172
|
['$$updateAt$$', false],
|
|
1173
|
+
['$$seq$$', false],
|
|
1179
1174
|
];
|
|
1180
1175
|
var foreignKeyProperties = (_a = {},
|
|
1181
1176
|
_a[entity] = [''],
|
|
@@ -1501,6 +1496,8 @@ function constructSorter(statements, entity) {
|
|
|
1501
1496
|
factory.createTypeLiteralNode([factory.createPropertySignature(undefined, factory.createIdentifier("id"), undefined, factory.createLiteralTypeNode(factory.createNumericLiteral("1")))]),
|
|
1502
1497
|
// $$createAt$$: 1
|
|
1503
1498
|
factory.createTypeLiteralNode([factory.createPropertySignature(undefined, factory.createIdentifier("$$createAt$$"), undefined, factory.createLiteralTypeNode(factory.createNumericLiteral("1")))]),
|
|
1499
|
+
// $$seq$$: 1
|
|
1500
|
+
factory.createTypeLiteralNode([factory.createPropertySignature(undefined, factory.createIdentifier("$$seq$$"), undefined, factory.createLiteralTypeNode(factory.createNumericLiteral("1")))]),
|
|
1504
1501
|
// $$updateAt$$: 1
|
|
1505
1502
|
factory.createTypeLiteralNode([factory.createPropertySignature(undefined, factory.createIdentifier("$$updateAt$$"), undefined, factory.createLiteralTypeNode(factory.createNumericLiteral("1")))]),
|
|
1506
1503
|
];
|
|
@@ -2549,7 +2546,8 @@ var initialStatements = function () { return [
|
|
|
2549
2546
|
factory.createImportSpecifier(false, undefined, factory.createIdentifier("FormCreateData")),
|
|
2550
2547
|
factory.createImportSpecifier(false, undefined, factory.createIdentifier("FormUpdateData")),
|
|
2551
2548
|
factory.createImportSpecifier(false, factory.createIdentifier("Operation"), factory.createIdentifier("OakOperation")),
|
|
2552
|
-
factory.createImportSpecifier(false, factory.createIdentifier("MakeAction"), factory.createIdentifier("OakMakeAction"))
|
|
2549
|
+
factory.createImportSpecifier(false, factory.createIdentifier("MakeAction"), factory.createIdentifier("OakMakeAction")),
|
|
2550
|
+
factory.createImportSpecifier(false, undefined, factory.createIdentifier("EntityShape")),
|
|
2553
2551
|
])), factory.createStringLiteral("".concat((0, env_1.TYPE_PATH_IN_OAK_DOMAIN)(), "Entity")), undefined)
|
|
2554
2552
|
]; };
|
|
2555
2553
|
function outputSubQuery(outputDir, printer) {
|
|
@@ -35,6 +35,9 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
35
35
|
_a[id] = (0, lodash_1.cloneDeep)(row),
|
|
36
36
|
_a));
|
|
37
37
|
}
|
|
38
|
+
else {
|
|
39
|
+
Object.assign(entityBranch_1[id], row);
|
|
40
|
+
}
|
|
38
41
|
});
|
|
39
42
|
return;
|
|
40
43
|
}
|
|
@@ -128,7 +131,7 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
128
131
|
subCascadeSelectionFns.forEach(function (ele) { return cascadeSelectionFns.push(function (result) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
129
132
|
return tslib_1.__generator(this, function (_a) {
|
|
130
133
|
switch (_a.label) {
|
|
131
|
-
case 0: return [4 /*yield*/, ele(result.map(function (ele2) { return ele2[attr]; }))];
|
|
134
|
+
case 0: return [4 /*yield*/, ele(result.map(function (ele2) { return ele2[attr]; }).filter(function (ele2) { return !!ele2; }))];
|
|
132
135
|
case 1:
|
|
133
136
|
_a.sent();
|
|
134
137
|
return [2 /*return*/];
|
|
@@ -222,7 +225,7 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
222
225
|
subCascadeSelectionFns.forEach(function (ele) { return cascadeSelectionFns.push(function (result) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
223
226
|
return tslib_1.__generator(this, function (_a) {
|
|
224
227
|
switch (_a.label) {
|
|
225
|
-
case 0: return [4 /*yield*/, ele(result.map(function (ele2) { return ele2[attr]; }))];
|
|
228
|
+
case 0: return [4 /*yield*/, ele(result.map(function (ele2) { return ele2[attr]; }).filter(function (ele2) { return !!ele2; }))];
|
|
226
229
|
case 1:
|
|
227
230
|
_a.sent();
|
|
228
231
|
return [2 /*return*/];
|
|
@@ -667,7 +670,7 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
667
670
|
modiAttr = this.getSchema()[entity].toModi;
|
|
668
671
|
option2 = Object.assign({}, option);
|
|
669
672
|
opData = {};
|
|
670
|
-
if (modiAttr && action !== 'remove') {
|
|
673
|
+
if (modiAttr && action !== 'remove' && !option.dontCreateModi) {
|
|
671
674
|
// create/update具有modi对象的对象,对其子对象的update行为全部是create modi对象(缓存动作)
|
|
672
675
|
// delete此对象,所有的modi子对象应该通过触发器作废,这个通过系统的trigger来搞
|
|
673
676
|
(0, assert_1.default)(!option2.modiParentId && !option2.modiParentEntity);
|
|
@@ -1074,7 +1077,7 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
1074
1077
|
*/
|
|
1075
1078
|
CascadeStore.prototype.doUpdateSingleRow = function (entity, operation, context, option) {
|
|
1076
1079
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1077
|
-
var data, action, operId, filter, now, _a, modiCreate, addTimestamp_1, result_1, createInner, multipleCreate, data_2, data_2_1, d, createSingleOper, e_4_1, createOper, _b, ids_1, selection, rows, modiUpsert, upsertModis, _c, originData, originId, createOper, updateAttrCount, result_2;
|
|
1080
|
+
var data, action, operId, filter, now, _a, modiCreate, addTimestamp_1, result_1, createInner, multipleCreate, data_2, data_2_1, d, createSingleOper, e_4_1, operatorId, createOper, _b, ids_1, selection, rows, modiUpsert, upsertModis, _c, originData, originId, createOper, updateAttrCount, result_2;
|
|
1078
1081
|
var e_4, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
1079
1082
|
var _this = this;
|
|
1080
1083
|
return tslib_1.__generator(this, function (_o) {
|
|
@@ -1257,6 +1260,10 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
1257
1260
|
if (!(!option.dontCreateOper && !['oper', 'operEntity', 'modiEntity', 'modi'].includes(entity))) return [3 /*break*/, 22];
|
|
1258
1261
|
// 按照框架要求生成Oper和OperEntity这两个内置的对象
|
|
1259
1262
|
(0, assert_1.default)(operId);
|
|
1263
|
+
return [4 /*yield*/, context.getCurrentUserId(true)];
|
|
1264
|
+
case 16:
|
|
1265
|
+
operatorId = _o.sent();
|
|
1266
|
+
if (!operatorId) return [3 /*break*/, 22];
|
|
1260
1267
|
_e = {
|
|
1261
1268
|
id: 'dummy',
|
|
1262
1269
|
action: 'create'
|
|
@@ -1264,11 +1271,9 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
1264
1271
|
_f = {
|
|
1265
1272
|
id: operId,
|
|
1266
1273
|
action: action,
|
|
1267
|
-
data: data
|
|
1274
|
+
data: data,
|
|
1275
|
+
operatorId: operatorId
|
|
1268
1276
|
};
|
|
1269
|
-
return [4 /*yield*/, context.getCurrentUserId()];
|
|
1270
|
-
case 16:
|
|
1271
|
-
_f.operatorId = _o.sent();
|
|
1272
1277
|
if (!(data instanceof Array)) return [3 /*break*/, 18];
|
|
1273
1278
|
_g = {
|
|
1274
1279
|
id: 'dummy',
|
|
@@ -28,5 +28,5 @@ export declare abstract class UniversalContext<ED extends EntityDict> implements
|
|
|
28
28
|
rollback(): Promise<void>;
|
|
29
29
|
getCurrentTxnId(): string | undefined;
|
|
30
30
|
abstract toString(): Promise<string>;
|
|
31
|
-
abstract getCurrentUserId(): Promise<string | undefined>;
|
|
31
|
+
abstract getCurrentUserId(allowUnloggedIn?: boolean): Promise<string | undefined>;
|
|
32
32
|
}
|
package/lib/store/actionDef.js
CHANGED
|
@@ -23,7 +23,7 @@ function getFullProjection(entity, schema) {
|
|
|
23
23
|
exports.getFullProjection = getFullProjection;
|
|
24
24
|
function checkFilterContains(entity, schema, contained, context, filter) {
|
|
25
25
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
26
|
-
var rowStore, filter2, result, data_1;
|
|
26
|
+
var rowStore, filter2, projection, result, data_1;
|
|
27
27
|
var _a;
|
|
28
28
|
return tslib_1.__generator(this, function (_b) {
|
|
29
29
|
switch (_b.label) {
|
|
@@ -39,8 +39,9 @@ function checkFilterContains(entity, schema, contained, context, filter) {
|
|
|
39
39
|
filter2 = (0, filter_1.combineFilters)([filter, {
|
|
40
40
|
$not: contained,
|
|
41
41
|
}]);
|
|
42
|
+
projection = process.env.OAK_PLATFORM === 'server' ? getFullProjection(entity, schema) : { id: 1 };
|
|
42
43
|
return [4 /*yield*/, rowStore.select(entity, {
|
|
43
|
-
data:
|
|
44
|
+
data: projection,
|
|
44
45
|
filter: filter2,
|
|
45
46
|
indexFrom: 0,
|
|
46
47
|
count: 10,
|
package/lib/store/filter.js
CHANGED
|
@@ -150,7 +150,7 @@ function getRelevantIds(filter) {
|
|
|
150
150
|
}
|
|
151
151
|
// 因为要准确判定id,如果有其它的过滤条件,可能会使实际处理的行数少于id指向的行数,只能返回空数组
|
|
152
152
|
var attrs = Object.keys(filter);
|
|
153
|
-
if ((0, lodash_1.
|
|
153
|
+
if ((0, lodash_1.intersection)(attrs, ['id', '$and', '$or']).length > 3) {
|
|
154
154
|
return [];
|
|
155
155
|
}
|
|
156
156
|
if (filter === null || filter === void 0 ? void 0 : filter.$and) {
|
package/lib/store/modi.js
CHANGED
|
@@ -21,48 +21,19 @@ function createOperationsFromModies(modies) {
|
|
|
21
21
|
exports.createOperationsFromModies = createOperationsFromModies;
|
|
22
22
|
function applyModis(filter, context, option) {
|
|
23
23
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
24
|
-
var
|
|
24
|
+
var _a, _b, _c;
|
|
25
25
|
var _d;
|
|
26
26
|
return tslib_1.__generator(this, function (_e) {
|
|
27
27
|
switch (_e.label) {
|
|
28
|
-
case 0:
|
|
29
|
-
data: {
|
|
30
|
-
id: 1,
|
|
31
|
-
},
|
|
32
|
-
filter: filter,
|
|
33
|
-
sorter: [
|
|
34
|
-
{
|
|
35
|
-
$attr: {
|
|
36
|
-
$$createAt$$: 1,
|
|
37
|
-
},
|
|
38
|
-
$direction: 'asc',
|
|
39
|
-
}
|
|
40
|
-
]
|
|
41
|
-
}, context, Object.assign({}, option, {
|
|
42
|
-
blockTrigger: false,
|
|
43
|
-
}))];
|
|
44
|
-
case 1:
|
|
45
|
-
modis = (_e.sent()).result;
|
|
28
|
+
case 0:
|
|
46
29
|
_b = (_a = context.rowStore).operate;
|
|
47
30
|
_c = ['modi'];
|
|
48
31
|
_d = {};
|
|
49
32
|
return [4 /*yield*/, generateNewId()];
|
|
50
|
-
case
|
|
33
|
+
case 1: return [2 /*return*/, _b.apply(_a, _c.concat([(_d.id = _e.sent(),
|
|
51
34
|
_d.action = 'apply',
|
|
52
35
|
_d.data = {},
|
|
53
|
-
_d.filter =
|
|
54
|
-
id: {
|
|
55
|
-
$in: modis.map(function (ele) { return ele.id; }),
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
_d.sorter = [
|
|
59
|
-
{
|
|
60
|
-
$attr: {
|
|
61
|
-
$$createAt$$: 1,
|
|
62
|
-
},
|
|
63
|
-
$direction: 'asc',
|
|
64
|
-
}
|
|
65
|
-
],
|
|
36
|
+
_d.filter = filter,
|
|
66
37
|
_d), context, Object.assign({}, option, {
|
|
67
38
|
blockTrigger: false,
|
|
68
39
|
})]))];
|
package/lib/store/selection.js
CHANGED
package/lib/triggers/modi.js
CHANGED
|
@@ -10,7 +10,7 @@ var triggers = [
|
|
|
10
10
|
fn: function (_a, context, option) {
|
|
11
11
|
var operation = _a.operation;
|
|
12
12
|
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
13
|
-
var filter, modies, modies_1, modies_1_1, modi, targetEntity, id, action, data, filter_1,
|
|
13
|
+
var filter, modies, modies_1, modies_1_1, modi, targetEntity, id, action, data, filter_1, e_1_1;
|
|
14
14
|
var e_1, _b;
|
|
15
15
|
return tslib_1.__generator(this, function (_c) {
|
|
16
16
|
switch (_c.label) {
|
|
@@ -30,49 +30,39 @@ var triggers = [
|
|
|
30
30
|
modies = (_c.sent()).result;
|
|
31
31
|
_c.label = 2;
|
|
32
32
|
case 2:
|
|
33
|
-
_c.trys.push([2, 8, 9
|
|
33
|
+
_c.trys.push([2, 7, 8, 9]);
|
|
34
34
|
modies_1 = tslib_1.__values(modies), modies_1_1 = modies_1.next();
|
|
35
35
|
_c.label = 3;
|
|
36
36
|
case 3:
|
|
37
|
-
if (!!modies_1_1.done) return [3 /*break*/,
|
|
37
|
+
if (!!modies_1_1.done) return [3 /*break*/, 6];
|
|
38
38
|
modi = modies_1_1.value;
|
|
39
39
|
targetEntity = modi.targetEntity, id = modi.id, action = modi.action, data = modi.data, filter_1 = modi.filter;
|
|
40
|
-
return [4 /*yield*/, context.rowStore.select(targetEntity, {
|
|
41
|
-
data: {
|
|
42
|
-
id: 1,
|
|
43
|
-
},
|
|
44
|
-
filter: filter_1,
|
|
45
|
-
}, context, Object.assign({}, option, {
|
|
46
|
-
blockTrigger: true,
|
|
47
|
-
}))];
|
|
48
|
-
case 4:
|
|
49
|
-
targets = _c.sent();
|
|
50
40
|
return [4 /*yield*/, context.rowStore.operate(targetEntity, {
|
|
51
41
|
id: id,
|
|
52
42
|
action: action,
|
|
53
43
|
data: data,
|
|
54
|
-
filter:
|
|
44
|
+
filter: filter_1,
|
|
55
45
|
}, context, Object.assign({}, option, {
|
|
56
46
|
blockTrigger: true,
|
|
57
47
|
}))];
|
|
58
|
-
case
|
|
48
|
+
case 4:
|
|
59
49
|
_c.sent();
|
|
60
|
-
_c.label =
|
|
61
|
-
case
|
|
50
|
+
_c.label = 5;
|
|
51
|
+
case 5:
|
|
62
52
|
modies_1_1 = modies_1.next();
|
|
63
53
|
return [3 /*break*/, 3];
|
|
64
|
-
case
|
|
65
|
-
case
|
|
54
|
+
case 6: return [3 /*break*/, 9];
|
|
55
|
+
case 7:
|
|
66
56
|
e_1_1 = _c.sent();
|
|
67
57
|
e_1 = { error: e_1_1 };
|
|
68
|
-
return [3 /*break*/,
|
|
69
|
-
case
|
|
58
|
+
return [3 /*break*/, 9];
|
|
59
|
+
case 8:
|
|
70
60
|
try {
|
|
71
61
|
if (modies_1_1 && !modies_1_1.done && (_b = modies_1.return)) _b.call(modies_1);
|
|
72
62
|
}
|
|
73
63
|
finally { if (e_1) throw e_1.error; }
|
|
74
64
|
return [7 /*endfinally*/];
|
|
75
|
-
case
|
|
65
|
+
case 9: return [2 /*return*/, modies.length];
|
|
76
66
|
}
|
|
77
67
|
});
|
|
78
68
|
});
|
package/lib/types/Context.d.ts
CHANGED
|
@@ -11,6 +11,6 @@ export interface Context<ED extends EntityDict> {
|
|
|
11
11
|
toString(): Promise<string>;
|
|
12
12
|
getScene(): string | undefined;
|
|
13
13
|
setScene(scene?: string): void;
|
|
14
|
-
getCurrentUserId(): Promise<string | undefined>;
|
|
14
|
+
getCurrentUserId(allowUnloggedIn?: boolean): Promise<string | undefined>;
|
|
15
15
|
getHeader(key: string): string | string[] | undefined;
|
|
16
16
|
}
|
package/lib/types/DataType.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export declare type Datetime = number | Date;
|
|
|
11
11
|
export declare type Boolean = boolean;
|
|
12
12
|
export declare type PrimaryKey = string;
|
|
13
13
|
export declare type ForeignKey<E extends string> = string;
|
|
14
|
+
export declare type Sequence = string;
|
|
14
15
|
export { Geo, SingleGeo } from './Geo';
|
|
15
16
|
export declare type DataTypes = number | string | Datetime | Geo | Object | SingleGeo;
|
|
16
17
|
export declare const types: string[];
|
package/lib/types/Entity.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { GenericAction } from '../actions/action';
|
|
2
2
|
import { ExpressionKey, ExprOp, MakeFilter, NodeId } from './Demand';
|
|
3
3
|
import { OneOf, OptionalKeys } from './Polyfill';
|
|
4
|
+
import { PrimaryKey, Sequence } from './DataType';
|
|
4
5
|
export declare type TriggerDataAttribute = '$$triggerData$$';
|
|
5
6
|
export declare type TriggerTimestampAttribute = '$$triggerTimestamp$$';
|
|
6
7
|
declare type PrimaryKeyAttribute = 'id';
|
|
7
|
-
export declare type InstinctiveAttributes = PrimaryKeyAttribute | '$$createAt$$' | '$$updateAt$$' | '$$deleteAt$$' | TriggerDataAttribute | TriggerTimestampAttribute;
|
|
8
|
+
export declare type InstinctiveAttributes = PrimaryKeyAttribute | '$$createAt$$' | '$$updateAt$$' | '$$deleteAt$$' | TriggerDataAttribute | TriggerTimestampAttribute | '$$seq$$';
|
|
8
9
|
export declare const initinctiveAttributes: string[];
|
|
9
10
|
export declare type Filter<A extends string, F extends Object | undefined = undefined> = {
|
|
10
11
|
filter?: A extends 'create' ? undefined : F;
|
|
@@ -23,6 +24,7 @@ export declare type OperateOption = {
|
|
|
23
24
|
blockTrigger?: true;
|
|
24
25
|
dontCollect?: boolean;
|
|
25
26
|
dontCreateOper?: boolean;
|
|
27
|
+
dontCreateModi?: boolean;
|
|
26
28
|
allowExists?: boolean;
|
|
27
29
|
modiParentId?: string;
|
|
28
30
|
modiParentEntity?: string;
|
|
@@ -35,14 +37,15 @@ export declare type FormCreateData<SH extends GeneralEntityShape> = Omit<SH, Ins
|
|
|
35
37
|
id: string;
|
|
36
38
|
};
|
|
37
39
|
export declare type Operation<A extends GenericAction | string, DATA extends Object, FILTER extends Object | undefined = undefined, SORTER extends Object | undefined = undefined> = {
|
|
38
|
-
id
|
|
40
|
+
id?: string;
|
|
39
41
|
action: A;
|
|
40
42
|
data: DATA;
|
|
41
43
|
sorter?: SORTER;
|
|
42
44
|
} & Filter<A, FILTER>;
|
|
43
|
-
export declare type Selection<DATA extends Object, FILTER extends Object | undefined = undefined, SORT extends Object | undefined = undefined> =
|
|
45
|
+
export declare type Selection<DATA extends Object, FILTER extends Object | undefined = undefined, SORT extends Object | undefined = undefined> = Operation<'select', DATA, FILTER, SORT>;
|
|
44
46
|
export interface EntityShape {
|
|
45
|
-
id:
|
|
47
|
+
id: PrimaryKey;
|
|
48
|
+
$$seq$$: Sequence;
|
|
46
49
|
$$createAt$$: number | Date;
|
|
47
50
|
$$updateAt$$: number | Date;
|
|
48
51
|
$$deleteAt$$?: number | Date | null;
|
package/lib/types/Entity.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.initinctiveAttributes = void 0;
|
|
4
|
-
exports.initinctiveAttributes = ['id', '$$createAt$$', '$$updateAt$$', '$$deleteAt$$', '$$triggerData$$', '$$triggerTimestamp$$'];
|
|
4
|
+
exports.initinctiveAttributes = ['id', '$$createAt$$', '$$updateAt$$', '$$deleteAt$$', '$$triggerData$$', '$$triggerTimestamp$$', '$$seq$$'];
|
|
5
5
|
;
|
|
6
6
|
;
|
|
7
7
|
;
|
package/lib/types/Exception.d.ts
CHANGED
|
@@ -38,7 +38,9 @@ export declare class OakRowInconsistencyException<ED extends EntityDict> extends
|
|
|
38
38
|
*/
|
|
39
39
|
export declare class OakInputIllegalException extends OakUserException {
|
|
40
40
|
private attributes;
|
|
41
|
-
|
|
41
|
+
private entity;
|
|
42
|
+
constructor(entity: string, attributes: string[], message?: string);
|
|
43
|
+
getEntity(): string;
|
|
42
44
|
getAttributes(): string[];
|
|
43
45
|
addAttributesPrefix(prefix: string): void;
|
|
44
46
|
toString(): string;
|
|
@@ -71,6 +73,9 @@ export declare class OakCongruentRowExists<ED extends EntityDict, T extends keyo
|
|
|
71
73
|
getEntity(): T;
|
|
72
74
|
toString(): string;
|
|
73
75
|
}
|
|
76
|
+
export declare class OakDeadlock extends OakUserException {
|
|
77
|
+
constructor(message?: string | undefined);
|
|
78
|
+
}
|
|
74
79
|
export declare function makeException(data: {
|
|
75
80
|
name: string;
|
|
76
81
|
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.OakCongruentRowExists = exports.OakRowLockedException = exports.OakUnloggedInException = exports.OakUserUnpermittedException = exports.OakInputIllegalException = exports.OakRowInconsistencyException = exports.OakUserException = exports.OakExternalException = exports.OakRowUnexistedException = exports.OakOperExistedException = exports.OakDataException = exports.OakException = void 0;
|
|
3
|
+
exports.makeException = exports.OakDeadlock = exports.OakCongruentRowExists = exports.OakRowLockedException = exports.OakUnloggedInException = exports.OakUserUnpermittedException = exports.OakInputIllegalException = exports.OakRowInconsistencyException = exports.OakUserException = exports.OakExternalException = exports.OakRowUnexistedException = exports.OakOperExistedException = exports.OakDataException = exports.OakException = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var OakException = /** @class */ (function (_super) {
|
|
6
6
|
tslib_1.__extends(OakException, _super);
|
|
@@ -109,11 +109,15 @@ exports.OakRowInconsistencyException = OakRowInconsistencyException;
|
|
|
109
109
|
*/
|
|
110
110
|
var OakInputIllegalException = /** @class */ (function (_super) {
|
|
111
111
|
tslib_1.__extends(OakInputIllegalException, _super);
|
|
112
|
-
function OakInputIllegalException(attributes, message) {
|
|
112
|
+
function OakInputIllegalException(entity, attributes, message) {
|
|
113
113
|
var _this = _super.call(this, message) || this;
|
|
114
|
+
_this.entity = entity;
|
|
114
115
|
_this.attributes = attributes;
|
|
115
116
|
return _this;
|
|
116
117
|
}
|
|
118
|
+
OakInputIllegalException.prototype.getEntity = function () {
|
|
119
|
+
return this.entity;
|
|
120
|
+
};
|
|
117
121
|
OakInputIllegalException.prototype.getAttributes = function () {
|
|
118
122
|
return this.attributes;
|
|
119
123
|
};
|
|
@@ -122,6 +126,7 @@ var OakInputIllegalException = /** @class */ (function (_super) {
|
|
|
122
126
|
};
|
|
123
127
|
OakInputIllegalException.prototype.toString = function () {
|
|
124
128
|
return JSON.stringify({
|
|
129
|
+
entity: this.entity,
|
|
125
130
|
name: this.constructor.name,
|
|
126
131
|
message: this.message,
|
|
127
132
|
attributes: this.attributes,
|
|
@@ -195,6 +200,15 @@ var OakCongruentRowExists = /** @class */ (function (_super) {
|
|
|
195
200
|
return OakCongruentRowExists;
|
|
196
201
|
}(OakUserException));
|
|
197
202
|
exports.OakCongruentRowExists = OakCongruentRowExists;
|
|
203
|
+
var OakDeadlock = /** @class */ (function (_super) {
|
|
204
|
+
tslib_1.__extends(OakDeadlock, _super);
|
|
205
|
+
function OakDeadlock(message) {
|
|
206
|
+
return _super.call(this, message || '发现死锁') || this;
|
|
207
|
+
}
|
|
208
|
+
return OakDeadlock;
|
|
209
|
+
}(OakUserException));
|
|
210
|
+
exports.OakDeadlock = OakDeadlock;
|
|
211
|
+
;
|
|
198
212
|
function makeException(data) {
|
|
199
213
|
var name = data.name;
|
|
200
214
|
switch (name) {
|
|
@@ -211,7 +225,7 @@ function makeException(data) {
|
|
|
211
225
|
return new OakRowInconsistencyException(data.data, data.message);
|
|
212
226
|
}
|
|
213
227
|
case OakInputIllegalException.name: {
|
|
214
|
-
return new OakInputIllegalException(data.attributes, data.message);
|
|
228
|
+
return new OakInputIllegalException(data.entity, data.attributes, data.message);
|
|
215
229
|
}
|
|
216
230
|
case OakUserUnpermittedException.name: {
|
|
217
231
|
return new OakUserUnpermittedException(data.message);
|
|
@@ -228,6 +242,9 @@ function makeException(data) {
|
|
|
228
242
|
case OakRowUnexistedException.name: {
|
|
229
243
|
return new OakRowUnexistedException(data.rows);
|
|
230
244
|
}
|
|
245
|
+
case OakDeadlock.name: {
|
|
246
|
+
return new OakDeadlock(data.message);
|
|
247
|
+
}
|
|
231
248
|
default:
|
|
232
249
|
return;
|
|
233
250
|
}
|
package/lib/types/Storage.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export declare type WithWidthColumnType = "tinyint" | "smallint" | "mediumint" |
|
|
|
18
18
|
/**
|
|
19
19
|
* All other regular column types.
|
|
20
20
|
*/
|
|
21
|
-
export declare type SimpleColumnType = "simple-array" | "simple-json" | "simple-enum" | "int2" | "integer" | "int4" | "int8" | "int64" | "unsigned big int" | "float" | "float4" | "float8" | "smallmoney" | "money" | "boolean" | "bool" | "tinyblob" | "tinytext" | "mediumblob" | "mediumtext" | "blob" | "text" | "ntext" | "citext" | "hstore" | "longblob" | "longtext" | "alphanum" | "shorttext" | "bytes" | "bytea" | "long" | "raw" | "long raw" | "bfile" | "clob" | "nclob" | "image" | "timetz" | "timestamptz" | "timestamp with local time zone" | "smalldatetime" | "date" | "interval year to month" | "interval day to second" | "interval" | "year" | "seconddate" | "point" | "line" | "lseg" | "box" | "circle" | "path" | "polygon" | "geography" | "geometry" | "linestring" | "multipoint" | "multilinestring" | "multipolygon" | "geometrycollection" | "st_geometry" | "st_point" | "int4range" | "int8range" | "numrange" | "tsrange" | "tstzrange" | "daterange" | "enum" | "set" | "cidr" | "inet" | "macaddr" | "bit" | "bit varying" | "varbit" | "tsvector" | "tsquery" | "uuid" | "xml" | "json" | "jsonb" | "varbinary" | "hierarchyid" | "sql_variant" | "rowid" | "urowid" | "uniqueidentifier" | "rowversion" | "array" | "cube" | "ltree" | "object" | "array" | "function";
|
|
21
|
+
export declare type SimpleColumnType = "simple-array" | "simple-json" | "simple-enum" | "int2" | "integer" | "int4" | "int8" | "int64" | "unsigned big int" | "float" | "float4" | "float8" | "smallmoney" | "money" | "boolean" | "bool" | "tinyblob" | "tinytext" | "mediumblob" | "mediumtext" | "blob" | "text" | "ntext" | "citext" | "hstore" | "longblob" | "longtext" | "alphanum" | "shorttext" | "bytes" | "bytea" | "long" | "raw" | "long raw" | "bfile" | "clob" | "nclob" | "image" | "timetz" | "timestamptz" | "timestamp with local time zone" | "smalldatetime" | "date" | "interval year to month" | "interval day to second" | "interval" | "year" | "seconddate" | "point" | "line" | "lseg" | "box" | "circle" | "path" | "polygon" | "geography" | "geometry" | "linestring" | "multipoint" | "multilinestring" | "multipolygon" | "geometrycollection" | "st_geometry" | "st_point" | "int4range" | "int8range" | "numrange" | "tsrange" | "tstzrange" | "daterange" | "enum" | "set" | "cidr" | "inet" | "macaddr" | "bit" | "bit varying" | "varbit" | "tsvector" | "tsquery" | "uuid" | "xml" | "json" | "jsonb" | "varbinary" | "hierarchyid" | "sql_variant" | "rowid" | "urowid" | "uniqueidentifier" | "rowversion" | "array" | "cube" | "ltree" | "object" | "array" | "function" | "sequence";
|
|
22
22
|
/**
|
|
23
23
|
* Any column type column can be.
|
|
24
24
|
*/
|
package/lib/utils/lodash.d.ts
CHANGED
|
@@ -2,19 +2,4 @@
|
|
|
2
2
|
* 避免lodash打包体积过大
|
|
3
3
|
* 像assign, keys尽量使用Object的函数
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
import uniqBy from 'lodash/uniqBy';
|
|
7
|
-
import pull from 'lodash/pull';
|
|
8
|
-
import uniq from 'lodash/uniq';
|
|
9
|
-
import get from 'lodash/get';
|
|
10
|
-
import set from 'lodash/set';
|
|
11
|
-
import intersection from 'lodash/intersection';
|
|
12
|
-
import omit from 'lodash/omit';
|
|
13
|
-
import merge from 'lodash/merge';
|
|
14
|
-
import cloneDeep from 'lodash/cloneDeep';
|
|
15
|
-
import pick from 'lodash/pick';
|
|
16
|
-
import isEqual from 'lodash/isEqual';
|
|
17
|
-
import union from 'lodash/union';
|
|
18
|
-
import difference from 'lodash/difference';
|
|
19
|
-
import groupBy from 'lodash/groupBy';
|
|
20
|
-
export { unset, pull, uniq, uniqBy, get, set, intersection, omit, merge, cloneDeep, pick, isEqual, union, difference, groupBy, };
|
|
5
|
+
export { unset, pull, uniq, uniqBy, get, set, intersection, omit, merge, cloneDeep, pick, isEqual, union, difference, groupBy, } from 'lodash';
|
package/lib/utils/lodash.js
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.groupBy = exports.difference = exports.union = exports.isEqual = exports.pick = exports.cloneDeep = exports.merge = exports.omit = exports.intersection = exports.set = exports.get = exports.uniqBy = exports.uniq = exports.pull = exports.unset = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
4
|
/**
|
|
6
5
|
* 避免lodash打包体积过大
|
|
7
6
|
* 像assign, keys尽量使用Object的函数
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
exports
|
|
27
|
-
|
|
28
|
-
exports
|
|
29
|
-
|
|
30
|
-
exports
|
|
31
|
-
|
|
32
|
-
exports
|
|
33
|
-
|
|
34
|
-
exports
|
|
35
|
-
|
|
36
|
-
exports
|
|
37
|
-
|
|
38
|
-
exports
|
|
8
|
+
/* import unset from 'lodash/unset';
|
|
9
|
+
import uniqBy from 'lodash/uniqBy';
|
|
10
|
+
import pull from 'lodash/pull';
|
|
11
|
+
import uniq from 'lodash/uniq';
|
|
12
|
+
import get from 'lodash/get';
|
|
13
|
+
import set from 'lodash/set';
|
|
14
|
+
import intersection from 'lodash/intersection';
|
|
15
|
+
import omit from 'lodash/omit';
|
|
16
|
+
import merge from 'lodash/merge';
|
|
17
|
+
import cloneDeep from 'lodash/cloneDeep';
|
|
18
|
+
import pick from 'lodash/pick';
|
|
19
|
+
import isEqual from 'lodash/isEqual';
|
|
20
|
+
import union from 'lodash/union';
|
|
21
|
+
import difference from 'lodash/difference';
|
|
22
|
+
import groupBy from 'lodash/groupBy'; */
|
|
23
|
+
var lodash_1 = require("lodash");
|
|
24
|
+
Object.defineProperty(exports, "unset", { enumerable: true, get: function () { return lodash_1.unset; } });
|
|
25
|
+
Object.defineProperty(exports, "pull", { enumerable: true, get: function () { return lodash_1.pull; } });
|
|
26
|
+
Object.defineProperty(exports, "uniq", { enumerable: true, get: function () { return lodash_1.uniq; } });
|
|
27
|
+
Object.defineProperty(exports, "uniqBy", { enumerable: true, get: function () { return lodash_1.uniqBy; } });
|
|
28
|
+
Object.defineProperty(exports, "get", { enumerable: true, get: function () { return lodash_1.get; } });
|
|
29
|
+
Object.defineProperty(exports, "set", { enumerable: true, get: function () { return lodash_1.set; } });
|
|
30
|
+
Object.defineProperty(exports, "intersection", { enumerable: true, get: function () { return lodash_1.intersection; } });
|
|
31
|
+
Object.defineProperty(exports, "omit", { enumerable: true, get: function () { return lodash_1.omit; } });
|
|
32
|
+
Object.defineProperty(exports, "merge", { enumerable: true, get: function () { return lodash_1.merge; } });
|
|
33
|
+
Object.defineProperty(exports, "cloneDeep", { enumerable: true, get: function () { return lodash_1.cloneDeep; } });
|
|
34
|
+
Object.defineProperty(exports, "pick", { enumerable: true, get: function () { return lodash_1.pick; } });
|
|
35
|
+
Object.defineProperty(exports, "isEqual", { enumerable: true, get: function () { return lodash_1.isEqual; } });
|
|
36
|
+
Object.defineProperty(exports, "union", { enumerable: true, get: function () { return lodash_1.union; } });
|
|
37
|
+
Object.defineProperty(exports, "difference", { enumerable: true, get: function () { return lodash_1.difference; } });
|
|
38
|
+
Object.defineProperty(exports, "groupBy", { enumerable: true, get: function () { return lodash_1.groupBy; } });
|
package/lib/utils/validator.d.ts
CHANGED
|
@@ -18,6 +18,6 @@ export declare const isPhone: ValidatorFunction;
|
|
|
18
18
|
export declare const isNumber: ValidatorFunction;
|
|
19
19
|
export declare const isMoney: ValidatorMoneyFunction;
|
|
20
20
|
export declare const isVehicleNumber: ValidatorFunction;
|
|
21
|
-
export declare function checkAttributesNotNull<T extends Record<string, any>>(data: T, attributes: Array<keyof T>, allowEmpty?: true): void;
|
|
22
|
-
export declare function checkAttributesScope<T extends Record<string, any>>(data: T, attributes: Array<keyof T>): void;
|
|
21
|
+
export declare function checkAttributesNotNull<T extends Record<string, any>>(entity: string, data: T, attributes: Array<keyof T>, allowEmpty?: true): void;
|
|
22
|
+
export declare function checkAttributesScope<T extends Record<string, any>>(entity: string, data: T, attributes: Array<keyof T>): void;
|
|
23
23
|
export {};
|
package/lib/utils/validator.js
CHANGED
|
@@ -99,7 +99,7 @@ var isVehicleNumber = function (str) {
|
|
|
99
99
|
return reg.test(str);
|
|
100
100
|
};
|
|
101
101
|
exports.isVehicleNumber = isVehicleNumber;
|
|
102
|
-
function checkAttributesNotNull(data, attributes, allowEmpty) {
|
|
102
|
+
function checkAttributesNotNull(entity, data, attributes, allowEmpty) {
|
|
103
103
|
var attrs = attributes.filter(function (attr) {
|
|
104
104
|
if (data[attr] === null || data[attr] === '') {
|
|
105
105
|
return true;
|
|
@@ -109,15 +109,15 @@ function checkAttributesNotNull(data, attributes, allowEmpty) {
|
|
|
109
109
|
}
|
|
110
110
|
});
|
|
111
111
|
if (attrs.length > 0) {
|
|
112
|
-
throw new types_1.OakInputIllegalException(attrs, '属性不能为空');
|
|
112
|
+
throw new types_1.OakInputIllegalException(entity, attrs, '属性不能为空');
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
exports.checkAttributesNotNull = checkAttributesNotNull;
|
|
116
116
|
;
|
|
117
|
-
function checkAttributesScope(data, attributes) {
|
|
117
|
+
function checkAttributesScope(entity, data, attributes) {
|
|
118
118
|
var attrs = attributes.filter(function (attr) { return !data.hasOwnProperty(attr); });
|
|
119
119
|
if (attrs.length > 0) {
|
|
120
|
-
throw new types_1.OakInputIllegalException(attrs, '多余的属性');
|
|
120
|
+
throw new types_1.OakInputIllegalException(entity, attrs, '多余的属性');
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
exports.checkAttributesScope = checkAttributesScope;
|