oak-domain 3.0.2 → 3.0.4
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/actions/action.d.ts +8 -8
- package/lib/actions/action.js +2 -2
- package/lib/actions/relation.d.ts +1 -1
- package/lib/actions/relation.js +9 -22
- package/lib/base-app-domain/ActionAuth/Schema.d.ts +68 -42
- package/lib/base-app-domain/ActionAuth/Storage.js +12 -15
- package/lib/base-app-domain/ActionDefDict.d.ts +2 -3
- package/lib/base-app-domain/ActionDefDict.js +3 -5
- package/lib/base-app-domain/EntityDict.d.ts +5 -1
- package/lib/base-app-domain/I18n/Schema.d.ts +24 -24
- package/lib/base-app-domain/I18n/Storage.js +5 -5
- package/lib/base-app-domain/Modi/Action.d.ts +4 -4
- package/lib/base-app-domain/Modi/Action.js +3 -3
- package/lib/base-app-domain/Modi/Schema.d.ts +24 -24
- package/lib/base-app-domain/Modi/Storage.js +3 -3
- package/lib/base-app-domain/ModiEntity/Schema.d.ts +128 -55
- package/lib/base-app-domain/ModiEntity/Storage.js +2 -2
- package/lib/base-app-domain/Oper/Schema.d.ts +30 -29
- package/lib/base-app-domain/Oper/Storage.js +1 -1
- package/lib/base-app-domain/OperEntity/Schema.d.ts +126 -53
- package/lib/base-app-domain/OperEntity/Storage.js +2 -2
- package/lib/base-app-domain/Path/Schema.d.ts +149 -0
- package/lib/base-app-domain/Path/Schema.js +2 -0
- package/lib/base-app-domain/Path/Storage.d.ts +3 -0
- package/lib/base-app-domain/Path/Storage.js +54 -0
- package/lib/base-app-domain/Relation/Schema.d.ts +34 -34
- package/lib/base-app-domain/Relation/Storage.js +6 -6
- package/lib/base-app-domain/Relation.d.ts +0 -8
- package/lib/base-app-domain/Relation.js +1 -7
- package/lib/base-app-domain/RelationAuth/Schema.d.ts +74 -40
- package/lib/base-app-domain/RelationAuth/Storage.js +9 -11
- package/lib/base-app-domain/Storage.js +20 -16
- package/lib/base-app-domain/User/Action.d.ts +4 -4
- package/lib/base-app-domain/User/Action.js +3 -3
- package/lib/base-app-domain/User/Schema.d.ts +40 -27
- package/lib/base-app-domain/User/Storage.js +1 -1
- package/lib/base-app-domain/UserEntityClaim/Schema.d.ts +264 -0
- package/lib/base-app-domain/UserEntityClaim/Schema.js +2 -0
- package/lib/base-app-domain/UserEntityClaim/Storage.d.ts +3 -0
- package/lib/base-app-domain/UserEntityClaim/Storage.js +37 -0
- package/lib/base-app-domain/UserEntityGrant/Action.d.ts +2 -2
- package/lib/base-app-domain/UserEntityGrant/Schema.d.ts +55 -81
- package/lib/base-app-domain/UserEntityGrant/Storage.js +7 -11
- package/lib/base-app-domain/UserRelation/Schema.d.ts +50 -36
- package/lib/base-app-domain/UserRelation/Storage.js +7 -7
- package/lib/base-app-domain/_SubQuery.d.ts +45 -15
- package/lib/base-app-domain/index.js +1 -1
- package/lib/checkers/index.js +6 -7
- package/lib/compiler/env.js +16 -18
- package/lib/compiler/localeBuilder.js +83 -79
- package/lib/compiler/schemalBuilder.d.ts +16 -0
- package/lib/compiler/schemalBuilder.js +1160 -1378
- package/lib/entities/ActionAuth.d.ts +3 -5
- package/lib/entities/ActionAuth.js +9 -7
- package/lib/entities/I18n.js +1 -1
- package/lib/entities/Modi.js +2 -2
- package/lib/entities/ModiEntity.js +1 -1
- package/lib/entities/Oper.js +1 -1
- package/lib/entities/OperEntity.js +1 -1
- package/lib/entities/Path.d.ts +8 -0
- package/lib/entities/Path.js +35 -0
- package/lib/entities/Relation.js +1 -1
- package/lib/entities/RelationAuth.d.ts +2 -2
- package/lib/entities/RelationAuth.js +1 -1
- package/lib/entities/User.js +2 -2
- package/lib/entities/UserEntityClaim.d.ts +13 -0
- package/lib/entities/UserEntityClaim.js +17 -0
- package/lib/entities/UserEntityGrant.d.ts +5 -4
- package/lib/entities/UserEntityGrant.js +4 -7
- package/lib/entities/UserRelation.js +1 -1
- package/lib/index.d.ts +23 -0
- package/lib/index.js +37 -0
- package/lib/store/AsyncRowStore.d.ts +2 -1
- package/lib/store/AsyncRowStore.js +75 -149
- package/lib/store/CascadeStore.js +968 -1341
- package/lib/store/RelationAuth.d.ts +9 -16
- package/lib/store/RelationAuth.js +752 -910
- package/lib/store/SyncRowStore.d.ts +1 -1
- package/lib/store/SyncRowStore.js +27 -26
- package/lib/store/TriggerExecutor.d.ts +17 -10
- package/lib/store/TriggerExecutor.js +350 -423
- package/lib/store/actionAuth.js +13 -28
- package/lib/store/actionDef.js +142 -215
- package/lib/store/checker.js +225 -361
- package/lib/store/filter.d.ts +2 -3
- package/lib/store/filter.js +451 -589
- package/lib/store/modi.js +116 -177
- package/lib/store/relation.js +17 -17
- package/lib/timers/oper.d.ts +1 -1
- package/lib/timers/oper.js +44 -47
- package/lib/timers/vaccum.d.ts +2 -2
- package/lib/timers/vaccum.js +100 -165
- package/lib/triggers/index.js +1 -1
- package/lib/types/Action.d.ts +7 -7
- package/lib/types/AppLoader.d.ts +8 -2
- package/lib/types/AppLoader.js +4 -4
- package/lib/types/Auth.d.ts +15 -19
- package/lib/types/Connector.d.ts +19 -14
- package/lib/types/Connector.js +0 -7
- package/lib/types/DataType.d.ts +19 -18
- package/lib/types/DataType.js +1 -1
- package/lib/types/Demand.d.ts +25 -25
- package/lib/types/Endpoint.d.ts +1 -1
- package/lib/types/Entity.d.ts +62 -53
- package/lib/types/Entity.js +4 -3
- package/lib/types/EntityDesc.d.ts +2 -1
- package/lib/types/Environment.d.ts +4 -4
- package/lib/types/Exception.d.ts +34 -2
- package/lib/types/Exception.js +214 -197
- package/lib/types/Expression.d.ts +14 -14
- package/lib/types/Expression.js +54 -87
- package/lib/types/Geo.d.ts +6 -6
- package/lib/types/Locale.d.ts +5 -5
- package/lib/types/Polyfill.d.ts +9 -9
- package/lib/types/Port.d.ts +4 -4
- package/lib/types/RowStore.d.ts +3 -3
- package/lib/types/RowStore.js +18 -19
- package/lib/types/Storage.d.ts +5 -4
- package/lib/types/Style.d.ts +2 -2
- package/lib/types/Timer.d.ts +3 -3
- package/lib/types/Trigger.d.ts +30 -14
- package/lib/types/Trigger.js +6 -2
- package/lib/types/Watcher.d.ts +2 -2
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +2 -1
- package/lib/types/schema/DataTypes.d.ts +7 -7
- package/lib/utils/SimpleConnector.d.ts +26 -10
- package/lib/utils/SimpleConnector.js +167 -141
- package/lib/utils/assert.js +2 -2
- package/lib/utils/concurrent.d.ts +1 -1
- package/lib/utils/concurrent.js +31 -57
- package/lib/utils/date.js +2 -2
- package/lib/utils/geo.js +8 -8
- package/lib/utils/lodash.d.ts +3 -1
- package/lib/utils/lodash.js +21 -34
- package/lib/utils/mask.js +12 -13
- package/lib/utils/money.d.ts +1 -1
- package/lib/utils/money.js +22 -11
- package/lib/utils/projection.d.ts +4 -0
- package/lib/utils/projection.js +15 -0
- package/lib/utils/random/random.js +11 -16
- package/lib/utils/random/random.mp.js +7 -18
- package/lib/utils/random/random.web.js +6 -12
- package/lib/utils/string.d.ts +4 -4
- package/lib/utils/string.js +19 -32
- package/lib/utils/url.js +5 -4
- package/lib/utils/uuid.d.ts +1 -1
- package/lib/utils/uuid.js +46 -85
- package/lib/utils/validator.d.ts +4 -3
- package/lib/utils/validator.js +35 -32
- package/lib/utils/version.js +6 -6
- package/package.json +7 -7
- package/src/entities/ActionAuth.ts +10 -10
- package/src/entities/Path.ts +43 -0
- package/src/entities/RelationAuth.ts +2 -1
- package/src/entities/UserEntityClaim.ts +30 -0
- package/src/entities/UserEntityGrant.ts +9 -12
package/lib/types/Demand.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { RefOrExpression } from "./Expression";
|
|
2
2
|
import { OneOf } from "./Polyfill";
|
|
3
3
|
export declare const EXPRESSION_PREFIX = "$expr";
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
4
|
+
export type NodeId = `node-${number}`;
|
|
5
|
+
export type ExpressionKey = '$expr' | '$expr1' | '$expr2' | '$expr3' | '$expr4' | '$expr5' | '$expr6' | '$expr7' | '$expr8' | '$expr9' | '$expr10' | '$expr11' | '$expr12' | '$expr13' | '$expr14' | '$expr15' | '$expr16' | '$expr17' | '$expr18' | '$expr19' | '$expr20';
|
|
6
|
+
export type ExprOp<A> = {
|
|
7
7
|
[K in ExpressionKey]: RefOrExpression<A>;
|
|
8
8
|
};
|
|
9
|
-
export
|
|
9
|
+
export type Q_NumberComparisonValue = number | OneOf<{
|
|
10
10
|
$gt: number;
|
|
11
11
|
$lt: number;
|
|
12
12
|
$gte: number;
|
|
@@ -17,7 +17,7 @@ export declare type Q_NumberComparisonValue = number | OneOf<{
|
|
|
17
17
|
$nin: number[];
|
|
18
18
|
$between: [number, number];
|
|
19
19
|
}>;
|
|
20
|
-
export
|
|
20
|
+
export type Q_StringComparisonValue = string | OneOf<{
|
|
21
21
|
$gt: string;
|
|
22
22
|
$lt: string;
|
|
23
23
|
$gte: string;
|
|
@@ -30,58 +30,58 @@ export declare type Q_StringComparisonValue = string | OneOf<{
|
|
|
30
30
|
$in: string[];
|
|
31
31
|
$nin: string[];
|
|
32
32
|
}>;
|
|
33
|
-
export
|
|
34
|
-
export
|
|
35
|
-
export
|
|
33
|
+
export type Q_BooleanComparisonValue = boolean;
|
|
34
|
+
export type Q_DateComparisonValue = Q_NumberComparisonValue;
|
|
35
|
+
export type Q_EnumComparisonValue<E> = E | OneOf<{
|
|
36
36
|
$in: E[];
|
|
37
37
|
$nin: E[];
|
|
38
38
|
$ne: E;
|
|
39
39
|
}>;
|
|
40
|
-
export
|
|
40
|
+
export type Q_ExistsValue = {
|
|
41
41
|
$exists: boolean;
|
|
42
42
|
};
|
|
43
|
-
export
|
|
44
|
-
export
|
|
45
|
-
export
|
|
46
|
-
export
|
|
47
|
-
export
|
|
48
|
-
export
|
|
43
|
+
export type Q_NumberValue = Q_NumberComparisonValue | Q_ExistsValue;
|
|
44
|
+
export type Q_StringValue = Q_StringComparisonValue | Q_ExistsValue;
|
|
45
|
+
export type Q_BooleanValue = Q_BooleanComparisonValue | Q_ExistsValue;
|
|
46
|
+
export type Q_DateValue = Q_DateComparisonValue | Q_ExistsValue;
|
|
47
|
+
export type Q_EnumValue<E> = Q_EnumComparisonValue<E> | Q_ExistsValue;
|
|
48
|
+
export type Q_State<S> = S | {
|
|
49
49
|
$in: S[];
|
|
50
50
|
} | {
|
|
51
51
|
$nin: S[];
|
|
52
52
|
} | Q_ExistsValue;
|
|
53
|
-
export
|
|
53
|
+
export type Q_FullTextValue = {
|
|
54
54
|
$search: string;
|
|
55
55
|
$language?: 'zh_CN' | 'en_US';
|
|
56
56
|
};
|
|
57
|
-
export
|
|
58
|
-
export
|
|
57
|
+
export type Q_FullTextKey = '$text';
|
|
58
|
+
export type FulltextFilter = {
|
|
59
59
|
[F in Q_FullTextKey]?: Q_FullTextValue;
|
|
60
60
|
};
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
export
|
|
61
|
+
type Q_LogicKey = '$and' | '$or';
|
|
62
|
+
type Q_LinearLogicKey = '$not';
|
|
63
|
+
export type MakeFilterWrapper<F extends Object> = {
|
|
64
64
|
[Q in Q_LogicKey]?: Array<MakeFilterWrapper<F>>;
|
|
65
65
|
} & {
|
|
66
66
|
[Q in Q_LinearLogicKey]?: MakeFilterWrapper<F>;
|
|
67
67
|
} & Partial<F>;
|
|
68
|
-
export
|
|
68
|
+
export type MakeFilter<F extends Object> = {
|
|
69
69
|
'#id'?: NodeId;
|
|
70
70
|
} & MakeFilterWrapper<F>;
|
|
71
|
-
export
|
|
71
|
+
export type RefAttr<A> = {
|
|
72
72
|
'#attr': A;
|
|
73
73
|
} | {
|
|
74
74
|
'#refId': NodeId;
|
|
75
75
|
'#refAttr': string;
|
|
76
76
|
};
|
|
77
77
|
export declare function isRefAttrNode<A>(node: any): node is RefAttr<A>;
|
|
78
|
-
export
|
|
78
|
+
export type JsonFilter<O extends any> = O extends Array<infer P> ? (JsonFilter<P> | undefined)[] | {
|
|
79
79
|
$contains?: P | P[];
|
|
80
80
|
$overlaps?: P | P[];
|
|
81
81
|
} : O extends number ? Q_NumberValue : O extends string ? Q_StringValue : O extends boolean ? Q_BooleanValue : O extends Record<string, any> ? {
|
|
82
82
|
[A in keyof O]?: JsonFilter<O[A]>;
|
|
83
83
|
} : never;
|
|
84
|
-
export
|
|
84
|
+
export type SubQueryPredicateMetadata = {
|
|
85
85
|
'#sqp'?: 'in' | 'not in' | 'all' | 'not all';
|
|
86
86
|
};
|
|
87
87
|
export declare const SUB_QUERY_PREDICATE_KEYWORD = "#sqp";
|
package/lib/types/Endpoint.d.ts
CHANGED
|
@@ -8,4 +8,4 @@ export interface EndpointItem<ED extends EntityDict, BackCxt extends AsyncContex
|
|
|
8
8
|
method: 'get' | 'post' | 'put' | 'delete';
|
|
9
9
|
fn: (context: BackCxt, params: Record<string, string>, headers: IncomingHttpHeaders, req: IncomingMessage, body?: any) => Promise<any>;
|
|
10
10
|
}
|
|
11
|
-
export
|
|
11
|
+
export type Endpoint<ED extends EntityDict, BackCxt extends AsyncContext<ED>> = EndpointItem<ED, BackCxt> | EndpointItem<ED, BackCxt>[];
|
package/lib/types/Entity.d.ts
CHANGED
|
@@ -1,59 +1,61 @@
|
|
|
1
1
|
import { ReadOnlyAction } from '../actions/action';
|
|
2
2
|
import { PrimaryKey, Sequence } from './DataType';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
type TriggerDataAttributeType = '$$triggerData$$';
|
|
4
|
+
type TriggerUuidAttributeType = '$$triggerUuid$$';
|
|
5
|
+
type PrimaryKeyAttributeType = 'id';
|
|
6
|
+
type CreateAtAttributeType = '$$createAt$$';
|
|
7
|
+
type UpdateAtAttributeType = '$$updateAt$$';
|
|
8
|
+
type DeleteAtAttributeType = '$$deleteAt$$';
|
|
9
|
+
type SeqAttributeType = '$$seq$$';
|
|
10
10
|
export declare const TriggerDataAttribute = "$$triggerData$$";
|
|
11
|
-
export declare const
|
|
11
|
+
export declare const TriggerUuidAttribute = "$$triggerUuid$$";
|
|
12
12
|
export declare const PrimaryKeyAttribute = "id";
|
|
13
13
|
export declare const CreateAtAttribute = "$$createAt$$";
|
|
14
14
|
export declare const UpdateAtAttribute = "$$updateAt$$";
|
|
15
15
|
export declare const DeleteAtAttribute = "$$deleteAt$$";
|
|
16
16
|
export declare const SeqAttribute = "$$seq$$";
|
|
17
|
-
export
|
|
17
|
+
export type InstinctiveAttributes = PrimaryKeyAttributeType | CreateAtAttributeType | UpdateAtAttributeType | DeleteAtAttributeType | TriggerDataAttributeType | SeqAttributeType | TriggerUuidAttributeType;
|
|
18
18
|
export declare const initinctiveAttributes: string[];
|
|
19
|
-
|
|
19
|
+
type FilterPart<A extends string, F extends Object | undefined> = {
|
|
20
20
|
filter?: A extends 'create' ? undefined : F;
|
|
21
21
|
indexFrom?: A extends 'create' ? undefined : number;
|
|
22
22
|
count?: A extends 'create' ? undefined : number;
|
|
23
23
|
};
|
|
24
|
-
export
|
|
24
|
+
export type SelectOption = {
|
|
25
25
|
dontCollect?: boolean;
|
|
26
26
|
blockTrigger?: true;
|
|
27
27
|
obscure?: boolean;
|
|
28
28
|
forUpdate?: true;
|
|
29
29
|
includedDeleted?: true;
|
|
30
|
-
|
|
30
|
+
ignoreAttrMiss?: true;
|
|
31
31
|
dummy?: 1;
|
|
32
32
|
};
|
|
33
|
-
export
|
|
33
|
+
export type OperateOption = {
|
|
34
34
|
blockTrigger?: true;
|
|
35
35
|
dontCollect?: boolean;
|
|
36
36
|
dontCreateOper?: boolean;
|
|
37
37
|
dontCreateModi?: boolean;
|
|
38
|
+
includedDeleted?: true;
|
|
38
39
|
allowExists?: boolean;
|
|
39
40
|
modiParentId?: string;
|
|
40
41
|
modiParentEntity?: string;
|
|
41
42
|
deletePhysically?: boolean;
|
|
43
|
+
applyingModi?: boolean;
|
|
42
44
|
dummy?: 1;
|
|
43
45
|
};
|
|
44
|
-
export
|
|
45
|
-
[K in keyof Omit<SH,
|
|
46
|
+
export type FormUpdateData<SH extends GeneralEntityShape> = Partial<{
|
|
47
|
+
[K in keyof Omit<SH, "id" | "$$createAt$$" | "$$seq$$">]: SH[K] | null;
|
|
46
48
|
}>;
|
|
47
|
-
export
|
|
49
|
+
export type FormCreateData<SH extends GeneralEntityShape> = Partial<SH> & {
|
|
48
50
|
id: string;
|
|
49
51
|
};
|
|
50
|
-
export
|
|
52
|
+
export type Operation<A extends string, D extends Projection, F extends Filter | undefined = undefined, S extends Sorter | undefined = undefined> = {
|
|
51
53
|
id: string;
|
|
52
54
|
action: A;
|
|
53
55
|
data: D;
|
|
54
56
|
sorter?: S;
|
|
55
57
|
} & FilterPart<A, F>;
|
|
56
|
-
export
|
|
58
|
+
export type Selection<A extends ReadOnlyAction, D extends Projection, F extends Filter | undefined = undefined, S extends Sorter | undefined = undefined> = {
|
|
57
59
|
id?: string;
|
|
58
60
|
action?: A;
|
|
59
61
|
data: D;
|
|
@@ -71,7 +73,7 @@ export interface EntityShape {
|
|
|
71
73
|
export interface GeneralEntityShape extends EntityShape {
|
|
72
74
|
[K: string]: any;
|
|
73
75
|
}
|
|
74
|
-
export
|
|
76
|
+
export type MakeAction<A extends string> = A;
|
|
75
77
|
export interface EntityDef {
|
|
76
78
|
Schema: GeneralEntityShape;
|
|
77
79
|
OpSchema: GeneralEntityShape;
|
|
@@ -93,79 +95,79 @@ export interface EntityDict {
|
|
|
93
95
|
export interface OtmSubProjection extends Omit<Operation<'select', any, any, any>, 'action'> {
|
|
94
96
|
$entity: string;
|
|
95
97
|
}
|
|
96
|
-
export
|
|
97
|
-
export
|
|
98
|
+
export type AggregationOp = `#max-${number}` | `#min-${number}` | `#avg-${number}` | `#count-${number}` | `#sum-${number}`;
|
|
99
|
+
export type DeduceAggregationData<P extends Projection> = {
|
|
98
100
|
[A in AggregationOp]?: P;
|
|
99
101
|
} & {
|
|
100
102
|
'#aggr'?: P;
|
|
101
103
|
};
|
|
102
|
-
export
|
|
104
|
+
export type AggregationResult<SH extends GeneralEntityShape> = Array<{
|
|
103
105
|
[A in AggregationOp]?: number | string;
|
|
104
106
|
} & {
|
|
105
107
|
'#data'?: Partial<SH>;
|
|
106
108
|
}>;
|
|
107
|
-
export
|
|
109
|
+
export type AttrFilter<SH extends GeneralEntityShape> = {
|
|
108
110
|
[K in keyof SH]?: any;
|
|
109
111
|
};
|
|
110
|
-
|
|
112
|
+
type SortAttr = {
|
|
111
113
|
[K: string]: any;
|
|
112
114
|
};
|
|
113
|
-
|
|
115
|
+
type SorterItem = {
|
|
114
116
|
$attr: SortAttr;
|
|
115
117
|
$direction?: "asc" | "desc";
|
|
116
118
|
};
|
|
117
|
-
|
|
118
|
-
|
|
119
|
+
type Sorter = Array<SorterItem>;
|
|
120
|
+
type Filter = {
|
|
119
121
|
[K: string]: any;
|
|
120
122
|
};
|
|
121
|
-
|
|
123
|
+
type Projection = {
|
|
122
124
|
[K: string]: any;
|
|
123
125
|
};
|
|
124
|
-
export
|
|
125
|
-
|
|
126
|
+
export type DeduceAggregation<P extends Projection, F extends Filter, S extends Sorter> = Omit<Selection<'aggregate', DeduceAggregationData<P>, F, S>, 'action'>;
|
|
127
|
+
type CreateOperationData = {
|
|
126
128
|
id: string;
|
|
127
129
|
[K: string]: any;
|
|
128
130
|
};
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
131
|
+
type CreateSingleOperation = Operation<'create', CreateOperationData, undefined, undefined>;
|
|
132
|
+
type CreateMultipleOperation = Operation<'create', Array<CreateOperationData>, undefined, undefined>;
|
|
133
|
+
type CreateOperation = CreateSingleOperation | CreateMultipleOperation;
|
|
134
|
+
type UpdateOperationData = {
|
|
133
135
|
id?: never;
|
|
134
136
|
[k: string]: any;
|
|
135
137
|
};
|
|
136
|
-
export
|
|
137
|
-
|
|
138
|
+
export type UpdateOperation = Operation<string, UpdateOperationData, Filter, Sorter>;
|
|
139
|
+
type RemoveOperationData = {
|
|
138
140
|
[k: string]: any;
|
|
139
141
|
};
|
|
140
|
-
export
|
|
141
|
-
export
|
|
142
|
-
export
|
|
142
|
+
export type RemoveOperation = Operation<'remove', RemoveOperationData, Filter, Sorter>;
|
|
143
|
+
export type CUDOperation = CreateOperation | UpdateOperation | RemoveOperation;
|
|
144
|
+
export type CreateOpResult<ED extends EntityDict, T extends keyof ED> = {
|
|
143
145
|
a: 'c';
|
|
144
146
|
e: T;
|
|
145
147
|
d: ED[T]['OpSchema'] | ED[T]['OpSchema'][];
|
|
146
148
|
};
|
|
147
|
-
export
|
|
149
|
+
export type UpdateOpResult<ED extends EntityDict, T extends keyof ED> = {
|
|
148
150
|
a: 'u';
|
|
149
151
|
e: T;
|
|
150
152
|
d: UpdateOperationData;
|
|
151
153
|
f?: Filter;
|
|
152
154
|
};
|
|
153
|
-
export
|
|
155
|
+
export type RemoveOpResult<ED extends EntityDict, T extends keyof ED> = {
|
|
154
156
|
a: 'r';
|
|
155
157
|
e: T;
|
|
156
158
|
f?: Filter;
|
|
157
159
|
};
|
|
158
|
-
export
|
|
160
|
+
export type RelationHierarchy<R extends string> = {
|
|
159
161
|
[K in R]?: R[];
|
|
160
162
|
};
|
|
161
|
-
export
|
|
163
|
+
export type CascadeRelationItem = {
|
|
162
164
|
cascadePath: string;
|
|
163
165
|
relations?: string[];
|
|
164
166
|
};
|
|
165
|
-
export
|
|
167
|
+
export type CascadeRelationAuth<R extends string> = {
|
|
166
168
|
[K in R]?: CascadeRelationItem | (CascadeRelationItem | CascadeRelationItem[])[];
|
|
167
169
|
};
|
|
168
|
-
export
|
|
170
|
+
export type SelectOpResult<ED extends EntityDict> = {
|
|
169
171
|
a: 's';
|
|
170
172
|
d: {
|
|
171
173
|
[T in keyof ED]?: {
|
|
@@ -173,21 +175,28 @@ export declare type SelectOpResult<ED extends EntityDict> = {
|
|
|
173
175
|
};
|
|
174
176
|
};
|
|
175
177
|
};
|
|
176
|
-
export
|
|
177
|
-
export
|
|
178
|
+
export type OpRecord<ED extends EntityDict> = CreateOpResult<ED, keyof ED> | UpdateOpResult<ED, keyof ED> | RemoveOpResult<ED, keyof ED> | SelectOpResult<ED>;
|
|
179
|
+
export type OperationResult<ED extends EntityDict> = {
|
|
178
180
|
[K in keyof ED]?: {
|
|
179
181
|
[A in ED[K]['Action']]?: number;
|
|
180
182
|
};
|
|
181
183
|
};
|
|
182
|
-
export
|
|
183
|
-
export
|
|
184
|
+
export type ActionType = 'readOnly' | 'appendOnly' | 'excludeUpdate' | 'excludeRemove' | 'crud';
|
|
185
|
+
export type Configuration = {
|
|
184
186
|
actionType?: ActionType;
|
|
185
187
|
static?: boolean;
|
|
186
188
|
};
|
|
187
|
-
export
|
|
188
|
-
export declare type AuthDeduceRelationMap<ED extends EntityDict> = {
|
|
189
|
+
export type AuthDeduceRelationMap<ED extends EntityDict> = {
|
|
189
190
|
[T in keyof ED]?: keyof ED[T]['OpSchema'];
|
|
190
191
|
};
|
|
191
|
-
export
|
|
192
|
-
export
|
|
192
|
+
export type SelectFreeEntities<ED extends EntityDict> = (keyof ED)[];
|
|
193
|
+
export type UpdateFreeDict<ED extends EntityDict> = {
|
|
194
|
+
[A in keyof ED]?: string[];
|
|
195
|
+
};
|
|
196
|
+
export type OtmKey<K extends string> = K | `${K}$${number}`;
|
|
197
|
+
export interface SubDataDef<ED extends EntityDict, T extends keyof ED> {
|
|
198
|
+
id: string;
|
|
199
|
+
entity: T;
|
|
200
|
+
filter: ED[T]['Selection']['filter'];
|
|
201
|
+
}
|
|
193
202
|
export {};
|
package/lib/types/Entity.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.initinctiveAttributes = exports.SeqAttribute = exports.DeleteAtAttribute = exports.UpdateAtAttribute = exports.CreateAtAttribute = exports.PrimaryKeyAttribute = exports.
|
|
3
|
+
exports.initinctiveAttributes = exports.SeqAttribute = exports.DeleteAtAttribute = exports.UpdateAtAttribute = exports.CreateAtAttribute = exports.PrimaryKeyAttribute = exports.TriggerUuidAttribute = exports.TriggerDataAttribute = void 0;
|
|
4
4
|
exports.TriggerDataAttribute = '$$triggerData$$';
|
|
5
|
-
exports.
|
|
5
|
+
exports.TriggerUuidAttribute = '$$triggerUuid$$';
|
|
6
6
|
exports.PrimaryKeyAttribute = 'id';
|
|
7
7
|
exports.CreateAtAttribute = '$$createAt$$';
|
|
8
8
|
exports.UpdateAtAttribute = '$$updateAt$$';
|
|
9
9
|
exports.DeleteAtAttribute = '$$deleteAt$$';
|
|
10
10
|
exports.SeqAttribute = '$$seq$$';
|
|
11
|
-
exports.initinctiveAttributes = [exports.PrimaryKeyAttribute, exports.TriggerDataAttribute, exports.
|
|
11
|
+
exports.initinctiveAttributes = [exports.PrimaryKeyAttribute, exports.TriggerDataAttribute, exports.TriggerUuidAttribute, exports.CreateAtAttribute, exports.UpdateAtAttribute, exports.DeleteAtAttribute, exports.SeqAttribute];
|
|
12
|
+
;
|
|
12
13
|
;
|
|
13
14
|
;
|
|
14
15
|
;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { LocaleDef } from './Locale';
|
|
2
2
|
import { Index } from './Storage';
|
|
3
3
|
import { EntityShape, Configuration } from './Entity';
|
|
4
|
-
export
|
|
4
|
+
export type EntityDesc<Schema extends EntityShape, Action extends string = '', Relation extends string = '', V extends Record<string, string> = {}> = {
|
|
5
5
|
locales: LocaleDef<Schema, Action, Relation, V>;
|
|
6
6
|
indexes?: Index<Schema>[];
|
|
7
7
|
configuration?: Configuration;
|
|
8
|
+
recursiveDepth?: number;
|
|
8
9
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type WechatMpEnv = {
|
|
2
2
|
type: 'wechatMp';
|
|
3
3
|
brand: string;
|
|
4
4
|
model: string;
|
|
@@ -33,7 +33,7 @@ export declare type WechatMpEnv = {
|
|
|
33
33
|
deviceOrientation: 'portrait' | 'landscape';
|
|
34
34
|
localStorageEnabled: true;
|
|
35
35
|
};
|
|
36
|
-
export
|
|
36
|
+
export type WebEnv = {
|
|
37
37
|
type: 'web';
|
|
38
38
|
visitorId: string;
|
|
39
39
|
platform: {
|
|
@@ -51,7 +51,7 @@ export declare type WebEnv = {
|
|
|
51
51
|
language: string;
|
|
52
52
|
localStorageEnabled: boolean;
|
|
53
53
|
};
|
|
54
|
-
export
|
|
54
|
+
export type ServerEnv = {
|
|
55
55
|
type: 'server';
|
|
56
56
|
};
|
|
57
|
-
export
|
|
57
|
+
export type Environment = WechatMpEnv | WebEnv | ServerEnv;
|
package/lib/types/Exception.d.ts
CHANGED
|
@@ -43,10 +43,18 @@ export declare class OakRowUnexistedException<ED extends EntityDict> extends Oak
|
|
|
43
43
|
selection: any;
|
|
44
44
|
}[];
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
/**
|
|
47
|
+
* 可接受的、由用户操作造成的异常
|
|
48
|
+
*/
|
|
48
49
|
export declare class OakUserException<ED extends EntityDict> extends OakException<ED> {
|
|
49
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* 网络中断异常
|
|
53
|
+
*/
|
|
54
|
+
export declare class OakNetworkException<ED extends EntityDict> extends OakException<ED> {
|
|
55
|
+
}
|
|
56
|
+
export declare class OakServerProxyException<ED extends EntityDict> extends OakException<ED> {
|
|
57
|
+
}
|
|
50
58
|
/**
|
|
51
59
|
* 数据不一致异常,系统认为现有的数据不允许相应的动作时抛此异常
|
|
52
60
|
*
|
|
@@ -67,6 +75,9 @@ export declare class OakInputIllegalException<ED extends EntityDict> extends Oak
|
|
|
67
75
|
addAttributesPrefix(prefix: string): void;
|
|
68
76
|
toString(): string;
|
|
69
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* 属性为空时抛的异常
|
|
80
|
+
*/
|
|
70
81
|
export declare class OakAttrNotNullException<ED extends EntityDict> extends OakInputIllegalException<ED> {
|
|
71
82
|
constructor(entity: keyof ED, attributes: string[], message?: string);
|
|
72
83
|
}
|
|
@@ -75,6 +86,11 @@ export declare class OakAttrNotNullException<ED extends EntityDict> extends OakI
|
|
|
75
86
|
*/
|
|
76
87
|
export declare class OakUserUnpermittedException<ED extends EntityDict> extends OakUserException<ED> {
|
|
77
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* 用户查询权限不够抛出异常
|
|
91
|
+
*/
|
|
92
|
+
export declare class OakUserInvisibleException<ED extends EntityDict> extends OakUserException<ED> {
|
|
93
|
+
}
|
|
78
94
|
/**
|
|
79
95
|
* 用户未登录抛的异常
|
|
80
96
|
*/
|
|
@@ -98,15 +114,31 @@ export declare class OakCongruentRowExists<ED extends EntityDict, T extends keyo
|
|
|
98
114
|
getEntity(): T;
|
|
99
115
|
toString(): string;
|
|
100
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* 死锁抛的异常
|
|
119
|
+
*/
|
|
101
120
|
export declare class OakDeadlock<ED extends EntityDict> extends OakUserException<ED> {
|
|
102
121
|
constructor(message?: string | undefined);
|
|
103
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* 前置条件不满足抛的异常
|
|
125
|
+
*/
|
|
104
126
|
export declare class OakPreConditionUnsetException<ED extends EntityDict> extends OakUserException<ED> {
|
|
105
127
|
entity?: keyof ED;
|
|
106
128
|
code?: string;
|
|
107
129
|
constructor(message?: string | undefined, entity?: keyof ED | undefined, code?: string | undefined);
|
|
108
130
|
toString(): string;
|
|
109
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* 调用外部接口抛出的异常
|
|
134
|
+
*/
|
|
135
|
+
export declare class OakExternalException<ED extends EntityDict> extends OakUserException<ED> {
|
|
136
|
+
code?: string;
|
|
137
|
+
source: string;
|
|
138
|
+
data?: any;
|
|
139
|
+
constructor(source: string, code?: string, message?: string, data?: any);
|
|
140
|
+
toString(): string;
|
|
141
|
+
}
|
|
110
142
|
export declare function makeException<ED extends EntityDict>(data: {
|
|
111
143
|
name: string;
|
|
112
144
|
message?: string;
|