oak-domain 4.2.2 → 4.2.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/base-app-domain/ActionDefDict.d.ts +8 -8
- package/lib/base-app-domain/Oper/Schema.d.ts +158 -158
- package/lib/base-app-domain/Oper/Storage.js +56 -56
- package/lib/base-app-domain/User/Action.d.ts +11 -11
- package/lib/base-app-domain/User/Action.js +12 -12
- package/lib/base-app-domain/UserEntityGrant/Action.d.ts +5 -5
- package/lib/base-app-domain/UserEntityGrant/Action.js +5 -5
- package/lib/compiler/schemalBuilder.js +4167 -4167
- package/lib/entities/Oper.d.ts +12 -12
- package/lib/entities/Oper.js +36 -36
- package/lib/entities/User.d.ts +18 -18
- package/lib/entities/User.js +32 -32
- package/lib/index.d.ts +1 -1
- package/lib/index.js +3 -3
- package/lib/store/AsyncRowStore.d.ts +66 -66
- package/lib/store/CascadeStore.d.ts +109 -109
- package/lib/store/CascadeStore.js +1728 -1726
- package/lib/store/RelationAuth.js +1209 -1209
- package/lib/store/TriggerExecutor.js +468 -468
- package/lib/store/actionDef.js +278 -278
- package/lib/store/checker.js +487 -487
- package/lib/store/relation.d.ts +12 -12
- package/lib/store/relation.js +74 -74
- package/lib/triggers/index.d.ts +5 -5
- package/lib/triggers/index.js +28 -28
- package/lib/types/Configuration.d.ts +42 -42
- package/lib/types/Configuration.js +3 -3
- package/lib/types/Connector.d.ts +39 -38
- package/lib/types/Entity.d.ts +209 -209
- package/lib/types/Sync.d.ts +74 -69
- package/lib/types/Sync.js +9 -9
- package/lib/types/index.d.ts +27 -27
- package/lib/types/index.js +30 -30
- package/lib/utils/SimpleConnector.d.ts +81 -64
- package/lib/utils/SimpleConnector.js +217 -206
- package/lib/utils/assert.d.ts +5 -5
- package/lib/utils/projection.d.ts +4 -4
- package/lib/utils/relationPath.d.ts +31 -31
- package/lib/utils/relationPath.js +202 -202
- package/package.json +51 -51
- package/src/entities/ActionAuth.ts +41 -41
- package/src/entities/I18n.ts +45 -45
- package/src/entities/Modi.ts +69 -69
- package/src/entities/ModiEntity.ts +26 -26
- package/src/entities/Oper.ts +48 -48
- package/src/entities/OperEntity.ts +27 -27
- package/src/entities/Path.ts +43 -43
- package/src/entities/Relation.ts +43 -43
- package/src/entities/RelationAuth.ts +44 -44
- package/src/entities/User.ts +48 -48
- package/src/entities/UserEntityClaim.ts +29 -29
- package/src/entities/UserEntityGrant.ts +24 -24
- package/src/entities/UserRelation.ts +50 -50
package/lib/entities/Oper.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { String, Datetime } from '../types/DataType';
|
|
2
|
-
import { EntityShape } from '../types/Entity';
|
|
3
|
-
import { Schema as User } from './User';
|
|
4
|
-
export interface Schema extends EntityShape {
|
|
5
|
-
action: String<16>;
|
|
6
|
-
data: Object;
|
|
7
|
-
filter?: Object;
|
|
8
|
-
extra?: Object;
|
|
9
|
-
operator?: User;
|
|
10
|
-
targetEntity: String<32>;
|
|
11
|
-
bornAt: Datetime;
|
|
12
|
-
}
|
|
1
|
+
import { String, Datetime } from '../types/DataType';
|
|
2
|
+
import { EntityShape } from '../types/Entity';
|
|
3
|
+
import { Schema as User } from './User';
|
|
4
|
+
export interface Schema extends EntityShape {
|
|
5
|
+
action: String<16>;
|
|
6
|
+
data: Object;
|
|
7
|
+
filter?: Object;
|
|
8
|
+
extra?: Object;
|
|
9
|
+
operator?: User;
|
|
10
|
+
targetEntity: String<32>;
|
|
11
|
+
bornAt: Datetime;
|
|
12
|
+
}
|
package/lib/entities/Oper.js
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
;
|
|
4
|
-
const entityDesc = {
|
|
5
|
-
locales: {
|
|
6
|
-
zh_CN: {
|
|
7
|
-
name: '操作',
|
|
8
|
-
attr: {
|
|
9
|
-
action: '动作',
|
|
10
|
-
data: '数据',
|
|
11
|
-
filter: '选择条件',
|
|
12
|
-
extra: '其它',
|
|
13
|
-
operator: '操作者',
|
|
14
|
-
targetEntity: '关联对象',
|
|
15
|
-
bornAt: '诞生时间'
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
configuration: {
|
|
20
|
-
actionType: 'appendOnly',
|
|
21
|
-
},
|
|
22
|
-
indexes: [
|
|
23
|
-
{
|
|
24
|
-
name: 'index_bornAt_operatorId',
|
|
25
|
-
attributes: [
|
|
26
|
-
{
|
|
27
|
-
name: 'bornAt',
|
|
28
|
-
direction: 'DESC',
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
name: 'operator',
|
|
32
|
-
},
|
|
33
|
-
]
|
|
34
|
-
}
|
|
35
|
-
]
|
|
36
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
;
|
|
4
|
+
const entityDesc = {
|
|
5
|
+
locales: {
|
|
6
|
+
zh_CN: {
|
|
7
|
+
name: '操作',
|
|
8
|
+
attr: {
|
|
9
|
+
action: '动作',
|
|
10
|
+
data: '数据',
|
|
11
|
+
filter: '选择条件',
|
|
12
|
+
extra: '其它',
|
|
13
|
+
operator: '操作者',
|
|
14
|
+
targetEntity: '关联对象',
|
|
15
|
+
bornAt: '诞生时间'
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
configuration: {
|
|
20
|
+
actionType: 'appendOnly',
|
|
21
|
+
},
|
|
22
|
+
indexes: [
|
|
23
|
+
{
|
|
24
|
+
name: 'index_bornAt_operatorId',
|
|
25
|
+
attributes: [
|
|
26
|
+
{
|
|
27
|
+
name: 'bornAt',
|
|
28
|
+
direction: 'DESC',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: 'operator',
|
|
32
|
+
},
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
};
|
package/lib/entities/User.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { String, Text } from '../types/DataType';
|
|
2
|
-
import { EntityShape } from '../types/Entity';
|
|
3
|
-
import { ActionDef } from '../types/Action';
|
|
4
|
-
import { EntityDesc } from '../types/EntityDesc';
|
|
5
|
-
export interface Schema extends EntityShape {
|
|
6
|
-
name?: String<16>;
|
|
7
|
-
nickname?: String<64>;
|
|
8
|
-
password?: Text;
|
|
9
|
-
ref?: Schema;
|
|
10
|
-
}
|
|
11
|
-
type UserAction = 'mergeTo';
|
|
12
|
-
type UserState = 'normal' | 'merged';
|
|
13
|
-
export type Action = UserAction;
|
|
14
|
-
export declare const UserActionDef: ActionDef<UserAction, UserState>;
|
|
15
|
-
export declare const entityDesc: EntityDesc<Schema, Action, '', {
|
|
16
|
-
userState: UserState;
|
|
17
|
-
}>;
|
|
18
|
-
export {};
|
|
1
|
+
import { String, Text } from '../types/DataType';
|
|
2
|
+
import { EntityShape } from '../types/Entity';
|
|
3
|
+
import { ActionDef } from '../types/Action';
|
|
4
|
+
import { EntityDesc } from '../types/EntityDesc';
|
|
5
|
+
export interface Schema extends EntityShape {
|
|
6
|
+
name?: String<16>;
|
|
7
|
+
nickname?: String<64>;
|
|
8
|
+
password?: Text;
|
|
9
|
+
ref?: Schema;
|
|
10
|
+
}
|
|
11
|
+
type UserAction = 'mergeTo';
|
|
12
|
+
type UserState = 'normal' | 'merged';
|
|
13
|
+
export type Action = UserAction;
|
|
14
|
+
export declare const UserActionDef: ActionDef<UserAction, UserState>;
|
|
15
|
+
export declare const entityDesc: EntityDesc<Schema, Action, '', {
|
|
16
|
+
userState: UserState;
|
|
17
|
+
}>;
|
|
18
|
+
export {};
|
package/lib/entities/User.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.entityDesc = exports.UserActionDef = void 0;
|
|
4
|
-
;
|
|
5
|
-
exports.UserActionDef = {
|
|
6
|
-
stm: {
|
|
7
|
-
mergeTo: ['normal', 'merged'],
|
|
8
|
-
},
|
|
9
|
-
};
|
|
10
|
-
exports.entityDesc = {
|
|
11
|
-
locales: {
|
|
12
|
-
zh_CN: {
|
|
13
|
-
name: '用户',
|
|
14
|
-
attr: {
|
|
15
|
-
name: '姓名',
|
|
16
|
-
nickname: '昵称',
|
|
17
|
-
password: '密码',
|
|
18
|
-
ref: '指向用户',
|
|
19
|
-
userState: '状态',
|
|
20
|
-
},
|
|
21
|
-
action: {
|
|
22
|
-
mergeTo: '合并',
|
|
23
|
-
},
|
|
24
|
-
v: {
|
|
25
|
-
userState: {
|
|
26
|
-
normal: '正常',
|
|
27
|
-
merged: '已被合并',
|
|
28
|
-
},
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.entityDesc = exports.UserActionDef = void 0;
|
|
4
|
+
;
|
|
5
|
+
exports.UserActionDef = {
|
|
6
|
+
stm: {
|
|
7
|
+
mergeTo: ['normal', 'merged'],
|
|
8
|
+
},
|
|
9
|
+
};
|
|
10
|
+
exports.entityDesc = {
|
|
11
|
+
locales: {
|
|
12
|
+
zh_CN: {
|
|
13
|
+
name: '用户',
|
|
14
|
+
attr: {
|
|
15
|
+
name: '姓名',
|
|
16
|
+
nickname: '昵称',
|
|
17
|
+
password: '密码',
|
|
18
|
+
ref: '指向用户',
|
|
19
|
+
userState: '状态',
|
|
20
|
+
},
|
|
21
|
+
action: {
|
|
22
|
+
mergeTo: '合并',
|
|
23
|
+
},
|
|
24
|
+
v: {
|
|
25
|
+
userState: {
|
|
26
|
+
normal: '正常',
|
|
27
|
+
merged: '已被合并',
|
|
28
|
+
},
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
};
|
package/lib/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export type { EntityDict as BaseEntityDict } from './base-app-domain';
|
|
1
|
+
export type { EntityDict as BaseEntityDict } from './base-app-domain';
|
package/lib/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
// export * from './types';
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// export * from './types';
|
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { EntityDict, RowStore, OperateOption, OperationResult, SelectOption, Context, TxnOption, OpRecord, AggregationResult, ClusterInfo } from "../types";
|
|
3
|
-
import { IncomingHttpHeaders } from "http";
|
|
4
|
-
/**
|
|
5
|
-
* 服务器端执行的异步环境的底层抽象
|
|
6
|
-
*/
|
|
7
|
-
export declare abstract class AsyncContext<ED extends EntityDict> implements Context {
|
|
8
|
-
rowStore: AsyncRowStore<ED, this>;
|
|
9
|
-
private uuid?;
|
|
10
|
-
opRecords: OpRecord<ED>[];
|
|
11
|
-
private scene?;
|
|
12
|
-
headers?: IncomingHttpHeaders;
|
|
13
|
-
clusterInfo?: ClusterInfo;
|
|
14
|
-
opResult: OperationResult<ED>;
|
|
15
|
-
private message?;
|
|
16
|
-
events: {
|
|
17
|
-
commit: Array<() => Promise<void>>;
|
|
18
|
-
rollback: Array<() => Promise<void>>;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* 在返回结果前调用,对数据行进行一些预处理,比如将一些敏感的列隐藏
|
|
22
|
-
*/
|
|
23
|
-
abstract refineOpRecords(): Promise<void>;
|
|
24
|
-
constructor(store: AsyncRowStore<ED, AsyncContext<ED>>);
|
|
25
|
-
restartToExecute(routine: (context: this) => Promise<any>): Promise<void>;
|
|
26
|
-
getHeader(key: string): string | string[] | undefined;
|
|
27
|
-
getScene(): string | undefined;
|
|
28
|
-
setScene(scene?: string): void;
|
|
29
|
-
private resetEvents;
|
|
30
|
-
on(event: 'commit' | 'rollback', callback: () => Promise<void>): void;
|
|
31
|
-
saveOpRecord<T extends keyof ED>(entity: T, operation: ED[T]['Operation']): void;
|
|
32
|
-
/**
|
|
33
|
-
* 一个context中不应该有并发的事务,这里将事务串行化,使用的时候千万要注意不要自己等自己
|
|
34
|
-
* @param options
|
|
35
|
-
*/
|
|
36
|
-
begin(options?: TxnOption): Promise<void>;
|
|
37
|
-
commit(): Promise<void>;
|
|
38
|
-
rollback(): Promise<void>;
|
|
39
|
-
operate<T extends keyof ED, OP extends OperateOption>(entity: T, operation: ED[T]['Operation'], option: OP): Promise<OperationResult<ED>>;
|
|
40
|
-
select<T extends keyof ED, OP extends SelectOption>(entity: T, selection: ED[T]['Selection'], option: OP): Promise<Partial<ED[T]["Schema"]>[]>;
|
|
41
|
-
aggregate<T extends keyof ED, OP extends SelectOption>(entity: T, aggregation: ED[T]['Aggregation'], option: OP): Promise<AggregationResult<ED[T]["Schema"]>>;
|
|
42
|
-
count<T extends keyof ED, OP extends SelectOption>(entity: T, selection: Pick<ED[T]['Selection'], 'filter' | 'count'>, option: OP): Promise<number>;
|
|
43
|
-
exec(script: string, txnId?: string): Promise<void>;
|
|
44
|
-
mergeMultipleResults(toBeMerged: OperationResult<ED>[]): OperationResult<ED>;
|
|
45
|
-
getCurrentTxnId(): string | undefined;
|
|
46
|
-
getSchema(): import("../types").StorageSchema<ED>;
|
|
47
|
-
setMessage(message: string): void;
|
|
48
|
-
getMessage(): string | undefined;
|
|
49
|
-
abstract isRoot(): boolean;
|
|
50
|
-
abstract getCurrentUserId(allowUnloggedIn?: boolean): string | undefined;
|
|
51
|
-
abstract setCurrentUserId(userId: string | undefined): void;
|
|
52
|
-
abstract toString(): Promise<string>;
|
|
53
|
-
abstract initialize(data: any): Promise<void>;
|
|
54
|
-
abstract allowUserUpdate(): boolean;
|
|
55
|
-
abstract openRootMode(): () => void;
|
|
56
|
-
}
|
|
57
|
-
export interface AsyncRowStore<ED extends EntityDict, Cxt extends AsyncContext<ED>> extends RowStore<ED> {
|
|
58
|
-
operate<T extends keyof ED, OP extends OperateOption>(entity: T, operation: ED[T]['Operation'], context: Cxt, option: OP): Promise<OperationResult<ED>>;
|
|
59
|
-
select<T extends keyof ED, OP extends SelectOption>(entity: T, selection: ED[T]['Selection'], context: Cxt, option: OP): Promise<Partial<ED[T]['Schema']>[]>;
|
|
60
|
-
aggregate<T extends keyof ED, OP extends SelectOption>(entity: T, aggregation: ED[T]['Aggregation'], context: Cxt, option: OP): Promise<AggregationResult<ED[T]['Schema']>>;
|
|
61
|
-
count<T extends keyof ED, OP extends SelectOption>(entity: T, selection: Pick<ED[T]['Selection'], 'filter' | 'count'>, context: Cxt, option: OP): Promise<number>;
|
|
62
|
-
begin(option?: TxnOption): Promise<string>;
|
|
63
|
-
commit(txnId: string): Promise<void>;
|
|
64
|
-
rollback(txnId: string): Promise<void>;
|
|
65
|
-
exec(script: string, txnId?: string): Promise<void>;
|
|
66
|
-
}
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EntityDict, RowStore, OperateOption, OperationResult, SelectOption, Context, TxnOption, OpRecord, AggregationResult, ClusterInfo } from "../types";
|
|
3
|
+
import { IncomingHttpHeaders } from "http";
|
|
4
|
+
/**
|
|
5
|
+
* 服务器端执行的异步环境的底层抽象
|
|
6
|
+
*/
|
|
7
|
+
export declare abstract class AsyncContext<ED extends EntityDict> implements Context {
|
|
8
|
+
rowStore: AsyncRowStore<ED, this>;
|
|
9
|
+
private uuid?;
|
|
10
|
+
opRecords: OpRecord<ED>[];
|
|
11
|
+
private scene?;
|
|
12
|
+
headers?: IncomingHttpHeaders;
|
|
13
|
+
clusterInfo?: ClusterInfo;
|
|
14
|
+
opResult: OperationResult<ED>;
|
|
15
|
+
private message?;
|
|
16
|
+
events: {
|
|
17
|
+
commit: Array<() => Promise<void>>;
|
|
18
|
+
rollback: Array<() => Promise<void>>;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* 在返回结果前调用,对数据行进行一些预处理,比如将一些敏感的列隐藏
|
|
22
|
+
*/
|
|
23
|
+
abstract refineOpRecords(): Promise<void>;
|
|
24
|
+
constructor(store: AsyncRowStore<ED, AsyncContext<ED>>);
|
|
25
|
+
restartToExecute(routine: (context: this) => Promise<any>): Promise<void>;
|
|
26
|
+
getHeader(key: string): string | string[] | undefined;
|
|
27
|
+
getScene(): string | undefined;
|
|
28
|
+
setScene(scene?: string): void;
|
|
29
|
+
private resetEvents;
|
|
30
|
+
on(event: 'commit' | 'rollback', callback: () => Promise<void>): void;
|
|
31
|
+
saveOpRecord<T extends keyof ED>(entity: T, operation: ED[T]['Operation']): void;
|
|
32
|
+
/**
|
|
33
|
+
* 一个context中不应该有并发的事务,这里将事务串行化,使用的时候千万要注意不要自己等自己
|
|
34
|
+
* @param options
|
|
35
|
+
*/
|
|
36
|
+
begin(options?: TxnOption): Promise<void>;
|
|
37
|
+
commit(): Promise<void>;
|
|
38
|
+
rollback(): Promise<void>;
|
|
39
|
+
operate<T extends keyof ED, OP extends OperateOption>(entity: T, operation: ED[T]['Operation'], option: OP): Promise<OperationResult<ED>>;
|
|
40
|
+
select<T extends keyof ED, OP extends SelectOption>(entity: T, selection: ED[T]['Selection'], option: OP): Promise<Partial<ED[T]["Schema"]>[]>;
|
|
41
|
+
aggregate<T extends keyof ED, OP extends SelectOption>(entity: T, aggregation: ED[T]['Aggregation'], option: OP): Promise<AggregationResult<ED[T]["Schema"]>>;
|
|
42
|
+
count<T extends keyof ED, OP extends SelectOption>(entity: T, selection: Pick<ED[T]['Selection'], 'filter' | 'count'>, option: OP): Promise<number>;
|
|
43
|
+
exec(script: string, txnId?: string): Promise<void>;
|
|
44
|
+
mergeMultipleResults(toBeMerged: OperationResult<ED>[]): OperationResult<ED>;
|
|
45
|
+
getCurrentTxnId(): string | undefined;
|
|
46
|
+
getSchema(): import("../types").StorageSchema<ED>;
|
|
47
|
+
setMessage(message: string): void;
|
|
48
|
+
getMessage(): string | undefined;
|
|
49
|
+
abstract isRoot(): boolean;
|
|
50
|
+
abstract getCurrentUserId(allowUnloggedIn?: boolean): string | undefined;
|
|
51
|
+
abstract setCurrentUserId(userId: string | undefined): void;
|
|
52
|
+
abstract toString(): Promise<string>;
|
|
53
|
+
abstract initialize(data: any, later?: boolean): Promise<void>;
|
|
54
|
+
abstract allowUserUpdate(): boolean;
|
|
55
|
+
abstract openRootMode(): () => void;
|
|
56
|
+
}
|
|
57
|
+
export interface AsyncRowStore<ED extends EntityDict, Cxt extends AsyncContext<ED>> extends RowStore<ED> {
|
|
58
|
+
operate<T extends keyof ED, OP extends OperateOption>(entity: T, operation: ED[T]['Operation'], context: Cxt, option: OP): Promise<OperationResult<ED>>;
|
|
59
|
+
select<T extends keyof ED, OP extends SelectOption>(entity: T, selection: ED[T]['Selection'], context: Cxt, option: OP): Promise<Partial<ED[T]['Schema']>[]>;
|
|
60
|
+
aggregate<T extends keyof ED, OP extends SelectOption>(entity: T, aggregation: ED[T]['Aggregation'], context: Cxt, option: OP): Promise<AggregationResult<ED[T]['Schema']>>;
|
|
61
|
+
count<T extends keyof ED, OP extends SelectOption>(entity: T, selection: Pick<ED[T]['Selection'], 'filter' | 'count'>, context: Cxt, option: OP): Promise<number>;
|
|
62
|
+
begin(option?: TxnOption): Promise<string>;
|
|
63
|
+
commit(txnId: string): Promise<void>;
|
|
64
|
+
rollback(txnId: string): Promise<void>;
|
|
65
|
+
exec(script: string, txnId?: string): Promise<void>;
|
|
66
|
+
}
|
|
@@ -1,109 +1,109 @@
|
|
|
1
|
-
import { EntityDict, OperateOption, SelectOption, OperationResult, AggregationResult } from "../types/Entity";
|
|
2
|
-
import { EntityDict as BaseEntityDict } from '../base-app-domain';
|
|
3
|
-
import { OperationRewriter, RowStore, SelectionRewriter } from '../types/RowStore';
|
|
4
|
-
import { StorageSchema } from '../types/Storage';
|
|
5
|
-
import { SyncContext } from "./SyncRowStore";
|
|
6
|
-
import { AsyncContext } from "./AsyncRowStore";
|
|
7
|
-
/**这个用来处理级联的select和update,对不同能力的 */
|
|
8
|
-
export declare abstract class CascadeStore<ED extends EntityDict & BaseEntityDict> extends RowStore<ED> {
|
|
9
|
-
constructor(storageSchema: StorageSchema<ED>);
|
|
10
|
-
protected abstract supportManyToOneJoin(): boolean;
|
|
11
|
-
protected abstract supportMultipleCreate(): boolean;
|
|
12
|
-
private selectionRewriters;
|
|
13
|
-
private operationRewriters;
|
|
14
|
-
private reinforceSelectionAsync;
|
|
15
|
-
private reinforceSelectionSync;
|
|
16
|
-
private reinforceSelectionInner;
|
|
17
|
-
private reinforceOperation;
|
|
18
|
-
registerOperationRewriter(rewriter: OperationRewriter<ED, AsyncContext<ED> | SyncContext<ED>, OperateOption>): void;
|
|
19
|
-
registerSelectionRewriter(rewriter: SelectionRewriter<ED, AsyncContext<ED> | SyncContext<ED>, SelectOption>): void;
|
|
20
|
-
protected abstract selectAbjointRow<T extends keyof ED, OP extends SelectOption, Cxt extends SyncContext<ED>>(entity: T, selection: ED[T]['Selection'], context: Cxt, option: OP): Partial<ED[T]['Schema']>[];
|
|
21
|
-
protected abstract countAbjointRow<T extends keyof ED, OP extends SelectOption, Cxt extends SyncContext<ED>>(entity: T, selection: Pick<ED[T]['Selection'], 'filter' | 'count'>, context: Cxt, option: OP): number;
|
|
22
|
-
protected abstract countAbjointRowAsync<T extends keyof ED, OP extends SelectOption, Cxt extends AsyncContext<ED>>(entity: T, selection: Pick<ED[T]['Selection'], 'filter' | 'count'>, context: Cxt, option: OP): Promise<number>;
|
|
23
|
-
protected abstract updateAbjointRow<T extends keyof ED, OP extends OperateOption, Cxt extends SyncContext<ED>>(entity: T, operation: ED[T]['Operation'], context: Cxt, option: OP): number;
|
|
24
|
-
protected abstract selectAbjointRowAsync<T extends keyof ED, OP extends SelectOption, Cxt extends AsyncContext<ED>>(entity: T, selection: ED[T]['Selection'], context: Cxt, option: OP): Promise<Partial<ED[T]['Schema']>[]>;
|
|
25
|
-
protected abstract updateAbjointRowAsync<T extends keyof ED, OP extends OperateOption, Cxt extends AsyncContext<ED>>(entity: T, operation: ED[T]['Create'] | ED[T]['Update'] | ED[T]['Remove'], context: Cxt, option: OP): Promise<number>;
|
|
26
|
-
protected abstract aggregateAbjointRowSync<T extends keyof ED, OP extends SelectOption, Cxt extends SyncContext<ED>>(entity: T, aggregation: ED[T]['Aggregation'], context: Cxt, option: OP): AggregationResult<ED[T]['Schema']>;
|
|
27
|
-
protected abstract aggregateAbjointRowAsync<T extends keyof ED, OP extends SelectOption, Cxt extends AsyncContext<ED>>(entity: T, aggregation: ED[T]['Aggregation'], context: Cxt, option: OP): Promise<AggregationResult<ED[T]['Schema']>>;
|
|
28
|
-
protected destructCascadeSelect<T extends keyof ED, OP extends SelectOption, Cxt extends SyncContext<ED> | AsyncContext<ED>>(entity: T, projection2: ED[T]['Selection']['data'], context: Cxt, cascadeSelectFn: <T2 extends keyof ED>(entity2: T2, selection: ED[T2]['Selection'], context: Cxt, op: OP) => Partial<ED[T2]['Schema']>[] | Promise<Partial<ED[T2]['Schema']>[]>, aggregateFn: <T2 extends keyof ED>(entity2: T2, aggregation: ED[T2]['Aggregation'], context: Cxt, op: OP) => AggregationResult<ED[T2]['Schema']> | Promise<AggregationResult<ED[T2]['Schema']>>, option: OP): {
|
|
29
|
-
projection: ED[T]["Selection"]["data"];
|
|
30
|
-
cascadeSelectionFns: ((result: Partial<ED[T]['Schema']>[]) => Promise<void> | void)[];
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* 级联更新
|
|
34
|
-
* A --> B
|
|
35
|
-
多对一:A CREATE/B CREATE,B data的主键赋到A的data上
|
|
36
|
-
A CREATE/B UPDATE,B filter的主键来自A的data
|
|
37
|
-
A UPDATE/B CREATE,B data的主键赋到A的data上
|
|
38
|
-
A UPDATE/B UPDATE,B filter的主键来自A的row
|
|
39
|
-
A UPDATE/B REMOVE,B filter的主键来自A的row
|
|
40
|
-
A REMOVE/B UPDATE,B filter的主键来自A的row
|
|
41
|
-
A REMOVE/B REMOVE,B filter的主键来自A的row
|
|
42
|
-
|
|
43
|
-
一对多:A CREATE/B CREATE,A data上的主键赋到B的data上
|
|
44
|
-
A CREATE/B UPDATE,A data上的主键赋到B的data上
|
|
45
|
-
A UPDATE/B CREATE,A filter上的主键赋到B的data上(一定是带主键的filter)
|
|
46
|
-
A UPDATE/B UPDATE,A filter上的主键赋到B的filter上(一定是带主键的filter)
|
|
47
|
-
A UPDATE/B REMOVE,A filter上的主键赋到B的filter上(一定是带主键的filter)
|
|
48
|
-
A REMOVE/B UPDATE,A filter上的主键赋到B的filter上(且B关于A的外键清空)
|
|
49
|
-
A REMOVE/B REMOVE,A filter上的主键赋到B的filter上
|
|
50
|
-
*
|
|
51
|
-
* 延时更新,
|
|
52
|
-
* A(业务级别的申请对象) ---> B(业务级别需要更新的对象)
|
|
53
|
-
* 两者必须通过entity/entityId关联
|
|
54
|
-
* 此时需要把对B的更新记录成一条新插入的Modi对象,并将A上的entity/entityId指向该对象(新生成的Modi对象的id与此operation的id保持一致)
|
|
55
|
-
* @param entity
|
|
56
|
-
* @param action
|
|
57
|
-
* @param data
|
|
58
|
-
* @param context
|
|
59
|
-
* @param option
|
|
60
|
-
* @param result
|
|
61
|
-
* @param filter
|
|
62
|
-
* @returns
|
|
63
|
-
*/
|
|
64
|
-
protected destructCascadeUpdate<T extends keyof ED, Cxt extends SyncContext<ED> | AsyncContext<ED>, OP extends OperateOption, R>(entity: T, action: ED[T]['Action'], data: ED[T]['CreateSingle']['data'] | ED[T]['Update']['data'] | ED[T]['Remove']['data'], context: Cxt, option: OP, cascadeUpdate: <T2 extends keyof ED>(entity: T2, operation: ED[T2]['Operation'], context: Cxt, option: OP) => R, filter?: ED[T]['Update']['filter'], bornAt?: number): {
|
|
65
|
-
data: Record<string, any>;
|
|
66
|
-
beforeFns: (() => R)[];
|
|
67
|
-
afterFns: (() => R)[];
|
|
68
|
-
};
|
|
69
|
-
protected preProcessDataCreated<T extends keyof ED>(entity: T, data: ED[T]['Create']['data']): void;
|
|
70
|
-
protected preProcessDataUpdated(data: Record<string, any>): void;
|
|
71
|
-
judgeRelation(entity: keyof ED, attr: string): string | 1 | 2 | string[] | 0 | -1;
|
|
72
|
-
/**
|
|
73
|
-
* 和具体的update过程无关的例程放在这里,包括对later动作的处理、对oper的记录以及对record的收集等
|
|
74
|
-
* @param entity
|
|
75
|
-
* @param operation
|
|
76
|
-
* @param context
|
|
77
|
-
* @param option
|
|
78
|
-
*/
|
|
79
|
-
private doUpdateSingleRowAsync;
|
|
80
|
-
private doUpdateSingleRow;
|
|
81
|
-
protected cascadeUpdate<T extends keyof ED, Cxt extends SyncContext<ED>, OP extends OperateOption>(entity: T, operation: ED[T]['Operation'], context: Cxt, option: OP): OperationResult<ED>;
|
|
82
|
-
/**
|
|
83
|
-
*
|
|
84
|
-
* @param entity
|
|
85
|
-
* @param operation
|
|
86
|
-
* @param context
|
|
87
|
-
* @param option
|
|
88
|
-
*/
|
|
89
|
-
protected cascadeUpdateAsync<T extends keyof ED, Cxt extends AsyncContext<ED>, OP extends OperateOption>(entity: T, operation: ED[T]['Operation'], context: Cxt, option: OP): Promise<OperationResult<ED>>;
|
|
90
|
-
protected cascadeSelect<T extends keyof ED, OP extends SelectOption, Cxt extends SyncContext<ED>>(entity: T, selection: ED[T]['Selection'], context: Cxt, option: OP): Partial<ED[T]['Schema']>[];
|
|
91
|
-
/**
|
|
92
|
-
* 将一次查询的结果集加入result
|
|
93
|
-
* todo 如果是supportMtoOJoin,这里还要解构(未充分测试)
|
|
94
|
-
* @param entity
|
|
95
|
-
* @param rows
|
|
96
|
-
* @param context
|
|
97
|
-
*/
|
|
98
|
-
private addToResultSelections;
|
|
99
|
-
private addSingleRowToResultSelections;
|
|
100
|
-
protected cascadeSelectAsync<T extends keyof ED, OP extends SelectOption, Cxt extends AsyncContext<ED>>(entity: T, selection: ED[T]['Selection'], context: Cxt, option: OP): Promise<Partial<ED[T]['Schema']>[]>;
|
|
101
|
-
protected aggregateAsync<T extends keyof ED, OP extends SelectOption, Cxt extends AsyncContext<ED>>(entity: T, aggregation: ED[T]['Aggregation'], context: Cxt, option: OP): Promise<AggregationResult<ED[T]['Schema']>>;
|
|
102
|
-
protected aggregateSync<T extends keyof ED, OP extends SelectOption, Cxt extends SyncContext<ED>>(entity: T, aggregation: ED[T]['Aggregation'], context: Cxt, option: OP): AggregationResult<ED[T]['Schema']>;
|
|
103
|
-
protected selectAsync<T extends keyof ED, OP extends SelectOption, Cxt extends AsyncContext<ED>>(entity: T, selection: ED[T]['Selection'], context: Cxt, option: OP): Promise<Partial<ED[T]['Schema']>[]>;
|
|
104
|
-
protected selectSync<T extends keyof ED, OP extends SelectOption, Cxt extends SyncContext<ED>>(entity: T, selection: ED[T]['Selection'], context: Cxt, option: OP): Partial<ED[T]['Schema']>[];
|
|
105
|
-
protected operateSync<T extends keyof ED, Cxt extends SyncContext<ED>, OP extends OperateOption>(entity: T, operation: ED[T]['Operation'], context: Cxt, option: OP): OperationResult<ED>;
|
|
106
|
-
protected operateAsync<T extends keyof ED, Cxt extends AsyncContext<ED>, OP extends OperateOption>(entity: T, operation: ED[T]['Operation'], context: Cxt, option: OP): Promise<OperationResult<ED>>;
|
|
107
|
-
protected countSync<T extends keyof ED, OP extends SelectOption, Cxt extends SyncContext<ED>>(entity: T, selection: Pick<ED[T]['Selection'], 'filter' | 'count'>, context: Cxt, option: OP): number;
|
|
108
|
-
protected countAsync<T extends keyof ED, OP extends SelectOption, Cxt extends AsyncContext<ED>>(entity: T, selection: Pick<ED[T]['Selection'], 'filter' | 'count'>, context: Cxt, option: OP): Promise<number>;
|
|
109
|
-
}
|
|
1
|
+
import { EntityDict, OperateOption, SelectOption, OperationResult, AggregationResult } from "../types/Entity";
|
|
2
|
+
import { EntityDict as BaseEntityDict } from '../base-app-domain';
|
|
3
|
+
import { OperationRewriter, RowStore, SelectionRewriter } from '../types/RowStore';
|
|
4
|
+
import { StorageSchema } from '../types/Storage';
|
|
5
|
+
import { SyncContext } from "./SyncRowStore";
|
|
6
|
+
import { AsyncContext } from "./AsyncRowStore";
|
|
7
|
+
/**这个用来处理级联的select和update,对不同能力的 */
|
|
8
|
+
export declare abstract class CascadeStore<ED extends EntityDict & BaseEntityDict> extends RowStore<ED> {
|
|
9
|
+
constructor(storageSchema: StorageSchema<ED>);
|
|
10
|
+
protected abstract supportManyToOneJoin(): boolean;
|
|
11
|
+
protected abstract supportMultipleCreate(): boolean;
|
|
12
|
+
private selectionRewriters;
|
|
13
|
+
private operationRewriters;
|
|
14
|
+
private reinforceSelectionAsync;
|
|
15
|
+
private reinforceSelectionSync;
|
|
16
|
+
private reinforceSelectionInner;
|
|
17
|
+
private reinforceOperation;
|
|
18
|
+
registerOperationRewriter(rewriter: OperationRewriter<ED, AsyncContext<ED> | SyncContext<ED>, OperateOption>): void;
|
|
19
|
+
registerSelectionRewriter(rewriter: SelectionRewriter<ED, AsyncContext<ED> | SyncContext<ED>, SelectOption>): void;
|
|
20
|
+
protected abstract selectAbjointRow<T extends keyof ED, OP extends SelectOption, Cxt extends SyncContext<ED>>(entity: T, selection: ED[T]['Selection'], context: Cxt, option: OP): Partial<ED[T]['Schema']>[];
|
|
21
|
+
protected abstract countAbjointRow<T extends keyof ED, OP extends SelectOption, Cxt extends SyncContext<ED>>(entity: T, selection: Pick<ED[T]['Selection'], 'filter' | 'count'>, context: Cxt, option: OP): number;
|
|
22
|
+
protected abstract countAbjointRowAsync<T extends keyof ED, OP extends SelectOption, Cxt extends AsyncContext<ED>>(entity: T, selection: Pick<ED[T]['Selection'], 'filter' | 'count'>, context: Cxt, option: OP): Promise<number>;
|
|
23
|
+
protected abstract updateAbjointRow<T extends keyof ED, OP extends OperateOption, Cxt extends SyncContext<ED>>(entity: T, operation: ED[T]['Operation'], context: Cxt, option: OP): number;
|
|
24
|
+
protected abstract selectAbjointRowAsync<T extends keyof ED, OP extends SelectOption, Cxt extends AsyncContext<ED>>(entity: T, selection: ED[T]['Selection'], context: Cxt, option: OP): Promise<Partial<ED[T]['Schema']>[]>;
|
|
25
|
+
protected abstract updateAbjointRowAsync<T extends keyof ED, OP extends OperateOption, Cxt extends AsyncContext<ED>>(entity: T, operation: ED[T]['Create'] | ED[T]['Update'] | ED[T]['Remove'], context: Cxt, option: OP): Promise<number>;
|
|
26
|
+
protected abstract aggregateAbjointRowSync<T extends keyof ED, OP extends SelectOption, Cxt extends SyncContext<ED>>(entity: T, aggregation: ED[T]['Aggregation'], context: Cxt, option: OP): AggregationResult<ED[T]['Schema']>;
|
|
27
|
+
protected abstract aggregateAbjointRowAsync<T extends keyof ED, OP extends SelectOption, Cxt extends AsyncContext<ED>>(entity: T, aggregation: ED[T]['Aggregation'], context: Cxt, option: OP): Promise<AggregationResult<ED[T]['Schema']>>;
|
|
28
|
+
protected destructCascadeSelect<T extends keyof ED, OP extends SelectOption, Cxt extends SyncContext<ED> | AsyncContext<ED>>(entity: T, projection2: ED[T]['Selection']['data'], context: Cxt, cascadeSelectFn: <T2 extends keyof ED>(entity2: T2, selection: ED[T2]['Selection'], context: Cxt, op: OP) => Partial<ED[T2]['Schema']>[] | Promise<Partial<ED[T2]['Schema']>[]>, aggregateFn: <T2 extends keyof ED>(entity2: T2, aggregation: ED[T2]['Aggregation'], context: Cxt, op: OP) => AggregationResult<ED[T2]['Schema']> | Promise<AggregationResult<ED[T2]['Schema']>>, option: OP): {
|
|
29
|
+
projection: ED[T]["Selection"]["data"];
|
|
30
|
+
cascadeSelectionFns: ((result: Partial<ED[T]['Schema']>[]) => Promise<void> | void)[];
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* 级联更新
|
|
34
|
+
* A --> B
|
|
35
|
+
多对一:A CREATE/B CREATE,B data的主键赋到A的data上
|
|
36
|
+
A CREATE/B UPDATE,B filter的主键来自A的data
|
|
37
|
+
A UPDATE/B CREATE,B data的主键赋到A的data上
|
|
38
|
+
A UPDATE/B UPDATE,B filter的主键来自A的row
|
|
39
|
+
A UPDATE/B REMOVE,B filter的主键来自A的row
|
|
40
|
+
A REMOVE/B UPDATE,B filter的主键来自A的row
|
|
41
|
+
A REMOVE/B REMOVE,B filter的主键来自A的row
|
|
42
|
+
|
|
43
|
+
一对多:A CREATE/B CREATE,A data上的主键赋到B的data上
|
|
44
|
+
A CREATE/B UPDATE,A data上的主键赋到B的data上
|
|
45
|
+
A UPDATE/B CREATE,A filter上的主键赋到B的data上(一定是带主键的filter)
|
|
46
|
+
A UPDATE/B UPDATE,A filter上的主键赋到B的filter上(一定是带主键的filter)
|
|
47
|
+
A UPDATE/B REMOVE,A filter上的主键赋到B的filter上(一定是带主键的filter)
|
|
48
|
+
A REMOVE/B UPDATE,A filter上的主键赋到B的filter上(且B关于A的外键清空)
|
|
49
|
+
A REMOVE/B REMOVE,A filter上的主键赋到B的filter上
|
|
50
|
+
*
|
|
51
|
+
* 延时更新,
|
|
52
|
+
* A(业务级别的申请对象) ---> B(业务级别需要更新的对象)
|
|
53
|
+
* 两者必须通过entity/entityId关联
|
|
54
|
+
* 此时需要把对B的更新记录成一条新插入的Modi对象,并将A上的entity/entityId指向该对象(新生成的Modi对象的id与此operation的id保持一致)
|
|
55
|
+
* @param entity
|
|
56
|
+
* @param action
|
|
57
|
+
* @param data
|
|
58
|
+
* @param context
|
|
59
|
+
* @param option
|
|
60
|
+
* @param result
|
|
61
|
+
* @param filter
|
|
62
|
+
* @returns
|
|
63
|
+
*/
|
|
64
|
+
protected destructCascadeUpdate<T extends keyof ED, Cxt extends SyncContext<ED> | AsyncContext<ED>, OP extends OperateOption, R>(entity: T, action: ED[T]['Action'], data: ED[T]['CreateSingle']['data'] | ED[T]['Update']['data'] | ED[T]['Remove']['data'], context: Cxt, option: OP, cascadeUpdate: <T2 extends keyof ED>(entity: T2, operation: ED[T2]['Operation'], context: Cxt, option: OP) => R, filter?: ED[T]['Update']['filter'], bornAt?: number): {
|
|
65
|
+
data: Record<string, any>;
|
|
66
|
+
beforeFns: (() => R)[];
|
|
67
|
+
afterFns: (() => R)[];
|
|
68
|
+
};
|
|
69
|
+
protected preProcessDataCreated<T extends keyof ED>(entity: T, data: ED[T]['Create']['data']): void;
|
|
70
|
+
protected preProcessDataUpdated(data: Record<string, any>): void;
|
|
71
|
+
judgeRelation(entity: keyof ED, attr: string): string | 1 | 2 | string[] | 0 | -1;
|
|
72
|
+
/**
|
|
73
|
+
* 和具体的update过程无关的例程放在这里,包括对later动作的处理、对oper的记录以及对record的收集等
|
|
74
|
+
* @param entity
|
|
75
|
+
* @param operation
|
|
76
|
+
* @param context
|
|
77
|
+
* @param option
|
|
78
|
+
*/
|
|
79
|
+
private doUpdateSingleRowAsync;
|
|
80
|
+
private doUpdateSingleRow;
|
|
81
|
+
protected cascadeUpdate<T extends keyof ED, Cxt extends SyncContext<ED>, OP extends OperateOption>(entity: T, operation: ED[T]['Operation'], context: Cxt, option: OP): OperationResult<ED>;
|
|
82
|
+
/**
|
|
83
|
+
*
|
|
84
|
+
* @param entity
|
|
85
|
+
* @param operation
|
|
86
|
+
* @param context
|
|
87
|
+
* @param option
|
|
88
|
+
*/
|
|
89
|
+
protected cascadeUpdateAsync<T extends keyof ED, Cxt extends AsyncContext<ED>, OP extends OperateOption>(entity: T, operation: ED[T]['Operation'], context: Cxt, option: OP): Promise<OperationResult<ED>>;
|
|
90
|
+
protected cascadeSelect<T extends keyof ED, OP extends SelectOption, Cxt extends SyncContext<ED>>(entity: T, selection: ED[T]['Selection'], context: Cxt, option: OP): Partial<ED[T]['Schema']>[];
|
|
91
|
+
/**
|
|
92
|
+
* 将一次查询的结果集加入result
|
|
93
|
+
* todo 如果是supportMtoOJoin,这里还要解构(未充分测试)
|
|
94
|
+
* @param entity
|
|
95
|
+
* @param rows
|
|
96
|
+
* @param context
|
|
97
|
+
*/
|
|
98
|
+
private addToResultSelections;
|
|
99
|
+
private addSingleRowToResultSelections;
|
|
100
|
+
protected cascadeSelectAsync<T extends keyof ED, OP extends SelectOption, Cxt extends AsyncContext<ED>>(entity: T, selection: ED[T]['Selection'], context: Cxt, option: OP): Promise<Partial<ED[T]['Schema']>[]>;
|
|
101
|
+
protected aggregateAsync<T extends keyof ED, OP extends SelectOption, Cxt extends AsyncContext<ED>>(entity: T, aggregation: ED[T]['Aggregation'], context: Cxt, option: OP): Promise<AggregationResult<ED[T]['Schema']>>;
|
|
102
|
+
protected aggregateSync<T extends keyof ED, OP extends SelectOption, Cxt extends SyncContext<ED>>(entity: T, aggregation: ED[T]['Aggregation'], context: Cxt, option: OP): AggregationResult<ED[T]['Schema']>;
|
|
103
|
+
protected selectAsync<T extends keyof ED, OP extends SelectOption, Cxt extends AsyncContext<ED>>(entity: T, selection: ED[T]['Selection'], context: Cxt, option: OP): Promise<Partial<ED[T]['Schema']>[]>;
|
|
104
|
+
protected selectSync<T extends keyof ED, OP extends SelectOption, Cxt extends SyncContext<ED>>(entity: T, selection: ED[T]['Selection'], context: Cxt, option: OP): Partial<ED[T]['Schema']>[];
|
|
105
|
+
protected operateSync<T extends keyof ED, Cxt extends SyncContext<ED>, OP extends OperateOption>(entity: T, operation: ED[T]['Operation'], context: Cxt, option: OP): OperationResult<ED>;
|
|
106
|
+
protected operateAsync<T extends keyof ED, Cxt extends AsyncContext<ED>, OP extends OperateOption>(entity: T, operation: ED[T]['Operation'], context: Cxt, option: OP): Promise<OperationResult<ED>>;
|
|
107
|
+
protected countSync<T extends keyof ED, OP extends SelectOption, Cxt extends SyncContext<ED>>(entity: T, selection: Pick<ED[T]['Selection'], 'filter' | 'count'>, context: Cxt, option: OP): number;
|
|
108
|
+
protected countAsync<T extends keyof ED, OP extends SelectOption, Cxt extends AsyncContext<ED>>(entity: T, selection: Pick<ED[T]['Selection'], 'filter' | 'count'>, context: Cxt, option: OP): Promise<number>;
|
|
109
|
+
}
|