oak-domain 4.0.2 → 4.0.3

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.
@@ -1,96 +1,103 @@
1
- import { EntityDict } from "../base-app-domain";
2
- import { StorageSchema } from "../types";
3
- import { EntityDict as BaseEntityDict, AuthDeduceRelationMap } from "../types/Entity";
4
- import { AsyncContext } from "./AsyncRowStore";
5
- import { SyncContext } from "./SyncRowStore";
6
- export declare class RelationAuth<ED extends EntityDict & BaseEntityDict> {
7
- private authDeduceRelationMap;
8
- private schema;
9
- static SPECIAL_ENTITIES: string[];
10
- private selectFreeEntities;
11
- private updateFreeDict;
12
- constructor(schema: StorageSchema<ED>, authDeduceRelationMap: AuthDeduceRelationMap<ED>, selectFreeEntities?: (keyof ED)[], updateFreeDict?: {
13
- [A in keyof ED]?: string[];
14
- });
15
- checkRelationSync<T extends keyof ED, Cxt extends SyncContext<ED>>(entity: T, operation: Omit<ED[T]['Operation'] | ED[T]['Selection'], 'id'>, context: Cxt): void;
16
- checkRelationAsync<T extends keyof ED, Cxt extends AsyncContext<ED>>(entity: T, operation: Omit<ED[T]['Operation'] | ED[T]['Selection'], 'id'>, context: Cxt): Promise<void>;
17
- private checkUserRelation;
18
- private checkOperateSpecialEntities2;
19
- private getDeducedEntityFilters;
20
- /**
21
- * 对于selection,解构出最底层的对象,如果最底层的对象可以被访问,则父对象一定可以
22
- * 但对于deduce的子对象,不必再向底层查看(假设deduce对象一般都位于树的最底层附近)
23
- * @param entity
24
- * @param operation
25
- */
26
- private destructSelection;
27
- /**
28
- * 对于operation,解构出一个树形结构,以方便自顶向下的进行访问
29
- * 但对于deduce的子对象,不必再向底层查看
30
- * @param entity
31
- * @param selection
32
- */
33
- private destructOperation;
34
- private makePathFilter;
35
- /**
36
- * 对所有满足操作要求的actionAuth加以判断,找到可以满足当前用户身份的actionAuth
37
- * @param entity
38
- * @param filter
39
- * @param actionAuths
40
- * @param context
41
- * @return
42
- */
43
- private filterActionAuths;
44
- /**
45
- * 对于有些特殊的查询(带很多$or的查询,多发生在系统级别),单个actionAuth无法满足,需要共同加以判定
46
- * @param entity
47
- * @param filter
48
- * @param actionAuths
49
- * @param context
50
- * @param actions
51
- */
52
- private checkActionAuthInGroup;
53
- private checkSelection;
54
- /**
55
- * 此函数判定一个结点是否能通过权限检测,同时寻找该结点本身对象上成立的actionAuth,用于本结点子孙结点的快速检测
56
- * 如果结点因其deduce的对象通过了检测,其被推断对象的actionAuth无法用于更低对象的权限检测
57
- * @param node
58
- * @param context
59
- * @returns
60
- */
61
- private findActionAuthsOnNode;
62
- private checkOperationTree2;
63
- private checkOperation;
64
- /**
65
- * 检查一个operation是否能被通过权限测试
66
- * 一个cascadeOperation是一棵树形结构:
67
- * * 对于select,只要叶子通过其父结点必然通过;
68
- * * 对于update,自顶向下进行检查,若父亲被权限S通过,则只需要检查子对于S有没有相对路径上的actionAuth
69
- * 另外在update中,还需要考虑自建userRelation的case(例如在电子商务网站上购买商品,创建订单同时创建用户和订单的关系)
70
- * @param entity
71
- * @param operation
72
- * @param context
73
- * @param actions
74
- * @returns
75
- */
76
- private checkActions2;
77
- }
78
- /**
79
- * 获取有对entity进行actions操作权限的userRelation关系
80
- * @param params
81
- * @param context
82
- * todo paths改成复数以后这里还未充分测试过
83
- */
84
- export declare function getUserRelationsByActions<ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends AsyncContext<ED>>(params: {
85
- entity: T;
86
- filter: ED[T]['Selection']['filter'];
87
- actions: ED[T]['Action'][];
88
- overlap?: boolean;
89
- }, context: Cxt): Promise<{
90
- userRelations: ED["userRelation"]["Schema"][];
91
- userEntities: {
92
- entity: keyof ED;
93
- entityId: string;
94
- userId: string;
95
- }[];
96
- }>;
1
+ import { EntityDict } from "../base-app-domain";
2
+ import { StorageSchema } from "../types";
3
+ import { EntityDict as BaseEntityDict, AuthDeduceRelationMap } from "../types/Entity";
4
+ import { AsyncContext } from "./AsyncRowStore";
5
+ import { SyncContext } from "./SyncRowStore";
6
+ export declare class RelationAuth<ED extends EntityDict & BaseEntityDict> {
7
+ private authDeduceRelationMap;
8
+ private schema;
9
+ static SPECIAL_ENTITIES: string[];
10
+ private selectFreeEntities;
11
+ private updateFreeDict;
12
+ constructor(schema: StorageSchema<ED>, authDeduceRelationMap: AuthDeduceRelationMap<ED>, selectFreeEntities?: (keyof ED)[], updateFreeDict?: {
13
+ [A in keyof ED]?: string[];
14
+ });
15
+ checkRelationSync<T extends keyof ED, Cxt extends SyncContext<ED>>(entity: T, operation: Omit<ED[T]['Operation'] | ED[T]['Selection'], 'id'>, context: Cxt): void;
16
+ checkRelationAsync<T extends keyof ED, Cxt extends AsyncContext<ED>>(entity: T, operation: Omit<ED[T]['Operation'] | ED[T]['Selection'], 'id'>, context: Cxt): Promise<void>;
17
+ /**
18
+ * 检查当前用户有无权限对filter约束的userRelation进行action操作
19
+ * @param context
20
+ * @param action
21
+ * @param filter
22
+ * @returns
23
+ */
24
+ private checkUserRelation;
25
+ private checkOperateSpecialEntities2;
26
+ private getDeducedEntityFilters;
27
+ /**
28
+ * 对于selection,解构出最底层的对象,如果最底层的对象可以被访问,则父对象一定可以
29
+ * 但对于deduce的子对象,不必再向底层查看(假设deduce对象一般都位于树的最底层附近)
30
+ * @param entity
31
+ * @param operation
32
+ */
33
+ private destructSelection;
34
+ /**
35
+ * 对于operation,解构出一个树形结构,以方便自顶向下的进行访问
36
+ * 但对于deduce的子对象,不必再向底层查看
37
+ * @param entity
38
+ * @param selection
39
+ */
40
+ private destructOperation;
41
+ private makePathFilter;
42
+ /**
43
+ * 对所有满足操作要求的actionAuth加以判断,找到可以满足当前用户身份的actionAuth
44
+ * @param entity
45
+ * @param filter
46
+ * @param actionAuths
47
+ * @param context
48
+ * @return
49
+ */
50
+ private filterActionAuths;
51
+ /**
52
+ * 对于有些特殊的查询(带很多$or的查询,多发生在系统级别),单个actionAuth无法满足,需要共同加以判定
53
+ * @param entity
54
+ * @param filter
55
+ * @param actionAuths
56
+ * @param context
57
+ * @param actions
58
+ */
59
+ private checkActionAuthInGroup;
60
+ private checkSelection;
61
+ /**
62
+ * 此函数判定一个结点是否能通过权限检测,同时寻找该结点本身对象上成立的actionAuth,用于本结点子孙结点的快速检测
63
+ * 如果结点因其deduce的对象通过了检测,其被推断对象的actionAuth无法用于更低对象的权限检测
64
+ * @param node
65
+ * @param context
66
+ * @returns
67
+ */
68
+ private findActionAuthsOnNode;
69
+ private checkOperationTree2;
70
+ private checkOperation;
71
+ /**
72
+ * 检查一个operation是否能被通过权限测试
73
+ * 一个cascadeOperation是一棵树形结构:
74
+ * * 对于select,只要叶子通过其父结点必然通过;
75
+ * * 对于update,自顶向下进行检查,若父亲被权限S通过,则只需要检查子对于S有没有相对路径上的actionAuth
76
+ * 另外在update中,还需要考虑自建userRelation的case(例如在电子商务网站上购买商品,创建订单同时创建用户和订单的关系)
77
+ * @param entity
78
+ * @param operation
79
+ * @param context
80
+ * @param actions
81
+ * @returns
82
+ */
83
+ private checkActions2;
84
+ }
85
+ /**
86
+ * 获取有对entity进行actions操作权限的userRelation关系
87
+ * @param params
88
+ * @param context
89
+ * todo paths改成复数以后这里还未充分测试过
90
+ */
91
+ export declare function getUserRelationsByActions<ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends AsyncContext<ED>>(params: {
92
+ entity: T;
93
+ filter: ED[T]['Selection']['filter'];
94
+ actions: ED[T]['Action'][];
95
+ overlap?: boolean;
96
+ }, context: Cxt): Promise<{
97
+ userRelations: ED["userRelation"]["Schema"][];
98
+ userEntities: {
99
+ entity: keyof ED;
100
+ entityId: string;
101
+ userId: string;
102
+ }[];
103
+ }>;