oak-domain 6.1.0 → 6.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/es/base-app-domain/ActionDefDict.d.ts +1 -0
  2. package/es/base-app-domain/ActionDefDict.js +3 -1
  3. package/es/base-app-domain/EntityDict.d.ts +86 -1
  4. package/es/base-app-domain/Log/Storage.js +4 -0
  5. package/es/base-app-domain/Log/_baseSchema.d.ts +5 -0
  6. package/es/base-app-domain/Storage.js +3 -1
  7. package/es/base-app-domain/StyleDict.js +3 -1
  8. package/es/base-app-domain/Version/Action.d.ts +6 -0
  9. package/es/base-app-domain/Version/Action.js +2 -0
  10. package/es/base-app-domain/Version/Schema.d.ts +19 -0
  11. package/es/base-app-domain/Version/Schema.js +1 -0
  12. package/es/base-app-domain/Version/Storage.d.ts +3 -0
  13. package/es/base-app-domain/Version/Storage.js +54 -0
  14. package/es/base-app-domain/Version/Style.d.ts +3 -0
  15. package/es/base-app-domain/Version/Style.js +6 -0
  16. package/es/base-app-domain/Version/_baseSchema.d.ts +57 -0
  17. package/es/base-app-domain/Version/_baseSchema.js +1 -0
  18. package/es/compiler/dependencyBuilder.d.ts +1 -0
  19. package/es/compiler/dependencyBuilder.js +173 -55
  20. package/es/compiler/routerBuilder.d.ts +4 -1
  21. package/es/compiler/routerBuilder.js +22 -19
  22. package/es/compiler/schemaBuilder.d.ts +5 -1
  23. package/es/compiler/schemaBuilder.js +10 -0
  24. package/es/context/BackendRuntimeContext.d.ts +9 -1
  25. package/es/context/BackendRuntimeContext.js +13 -1
  26. package/es/entities/Log.d.ts +2 -0
  27. package/es/entities/Log.js +2 -0
  28. package/es/entities/Version.d.ts +14 -0
  29. package/es/entities/Version.js +42 -0
  30. package/es/store/AsyncRowStore.d.ts +4 -1
  31. package/es/store/AsyncRowStore.js +7 -0
  32. package/es/store/CascadeStore.js +22 -0
  33. package/es/store/RelationAuth/authorizationFilter.d.ts +11 -0
  34. package/es/store/RelationAuth/authorizationFilter.js +104 -0
  35. package/es/store/RelationAuth/continuation.d.ts +9 -0
  36. package/es/store/RelationAuth/continuation.js +33 -0
  37. package/es/store/RelationAuth/index.d.ts +141 -0
  38. package/es/store/RelationAuth/index.js +1440 -0
  39. package/es/store/RelationAuth/model.d.ts +38 -0
  40. package/es/store/RelationAuth/model.js +24 -0
  41. package/es/store/RelationAuth/userLookup.d.ts +21 -0
  42. package/es/store/RelationAuth/userLookup.js +102 -0
  43. package/es/store/SyncRowStore.d.ts +2 -1
  44. package/es/store/SyncRowStore.js +3 -0
  45. package/es/store/filter.fix.d.ts +128 -0
  46. package/es/store/filter.fix.js +2862 -0
  47. package/es/store/filter.js +14 -9
  48. package/es/store/triggers.js +239 -44
  49. package/es/types/Context.d.ts +2 -1
  50. package/es/types/Demand.d.ts +11 -1
  51. package/es/types/Environment.d.ts +13 -2
  52. package/es/types/Exception.d.ts +3 -3
  53. package/es/types/Exception.js +25 -22
  54. package/es/types/Expression.d.ts +4 -1
  55. package/es/types/Expression.js +1 -1
  56. package/es/types/Storage.d.ts +15 -2
  57. package/es/utils/SimpleConnector.js +5 -2
  58. package/es/utils/decimal.js +2 -1
  59. package/es/utils/fetch/index.ali.d.ts +3 -0
  60. package/es/utils/fetch/index.ali.js +31 -0
  61. package/es/utils/fetch/index.d.ts +3 -0
  62. package/es/utils/fetch/index.js +5 -0
  63. package/es/utils/fetch/index.mp.d.ts +5 -3
  64. package/es/utils/fetch/index.mp.js +5 -280
  65. package/es/utils/fetch/index.wechat.d.ts +5 -0
  66. package/es/utils/fetch/index.wechat.js +174 -0
  67. package/es/utils/fetch/mini-program.shared.d.ts +37 -0
  68. package/es/utils/fetch/mini-program.shared.js +85 -0
  69. package/es/utils/geo.d.ts +1 -1
  70. package/es/utils/geo.js +1 -1
  71. package/es/utils/random/random.ali.d.ts +6 -0
  72. package/es/utils/random/random.ali.js +21 -0
  73. package/es/utils/random/random.mp.d.ts +5 -1
  74. package/es/utils/random/random.mp.js +11 -5
  75. package/es/utils/random/random.native.d.ts +1 -1
  76. package/es/utils/random/random.native.js +7 -4
  77. package/es/utils/random/random.wechat.d.ts +1 -0
  78. package/es/utils/random/random.wechat.js +10 -0
  79. package/lib/base-app-domain/ActionDefDict.d.ts +1 -0
  80. package/lib/base-app-domain/ActionDefDict.js +3 -1
  81. package/lib/base-app-domain/EntityDict.d.ts +86 -1
  82. package/lib/base-app-domain/Log/Storage.js +4 -0
  83. package/lib/base-app-domain/Log/_baseSchema.d.ts +5 -0
  84. package/lib/base-app-domain/Storage.js +3 -1
  85. package/lib/base-app-domain/StyleDict.js +3 -1
  86. package/lib/base-app-domain/Version/Action.d.ts +6 -0
  87. package/lib/base-app-domain/Version/Action.js +5 -0
  88. package/lib/base-app-domain/Version/Schema.d.ts +19 -0
  89. package/lib/base-app-domain/Version/Schema.js +4 -0
  90. package/lib/base-app-domain/Version/Storage.d.ts +3 -0
  91. package/lib/base-app-domain/Version/Storage.js +57 -0
  92. package/lib/base-app-domain/Version/Style.d.ts +3 -0
  93. package/lib/base-app-domain/Version/Style.js +9 -0
  94. package/lib/base-app-domain/Version/_baseSchema.d.ts +57 -0
  95. package/lib/base-app-domain/Version/_baseSchema.js +2 -0
  96. package/lib/compiler/dependencyBuilder.d.ts +1 -0
  97. package/lib/compiler/dependencyBuilder.js +173 -54
  98. package/lib/compiler/routerBuilder.d.ts +4 -1
  99. package/lib/compiler/routerBuilder.js +22 -19
  100. package/lib/compiler/schemaBuilder.d.ts +5 -1
  101. package/lib/compiler/schemaBuilder.js +10 -0
  102. package/lib/context/BackendRuntimeContext.d.ts +9 -1
  103. package/lib/context/BackendRuntimeContext.js +13 -1
  104. package/lib/entities/Log.d.ts +2 -0
  105. package/lib/entities/Log.js +2 -0
  106. package/lib/entities/Version.d.ts +14 -0
  107. package/lib/entities/Version.js +43 -0
  108. package/lib/store/AsyncRowStore.d.ts +4 -1
  109. package/lib/store/AsyncRowStore.js +7 -0
  110. package/lib/store/CascadeStore.js +22 -0
  111. package/lib/store/RelationAuth/authorizationFilter.d.ts +11 -0
  112. package/lib/store/RelationAuth/authorizationFilter.js +110 -0
  113. package/lib/store/RelationAuth/continuation.d.ts +9 -0
  114. package/lib/store/RelationAuth/continuation.js +37 -0
  115. package/lib/store/RelationAuth/index.d.ts +141 -0
  116. package/lib/store/RelationAuth/index.js +1445 -0
  117. package/lib/store/RelationAuth/model.d.ts +38 -0
  118. package/lib/store/RelationAuth/model.js +27 -0
  119. package/lib/store/RelationAuth/userLookup.d.ts +21 -0
  120. package/lib/store/RelationAuth/userLookup.js +105 -0
  121. package/lib/store/SyncRowStore.d.ts +2 -1
  122. package/lib/store/SyncRowStore.js +3 -0
  123. package/lib/store/filter.fix.d.ts +128 -0
  124. package/lib/store/filter.fix.js +2876 -0
  125. package/lib/store/filter.js +14 -9
  126. package/lib/store/triggers.js +239 -44
  127. package/lib/types/Context.d.ts +2 -1
  128. package/lib/types/Demand.d.ts +11 -1
  129. package/lib/types/Environment.d.ts +13 -2
  130. package/lib/types/Exception.d.ts +3 -3
  131. package/lib/types/Exception.js +25 -22
  132. package/lib/types/Expression.d.ts +4 -1
  133. package/lib/types/Expression.js +1 -1
  134. package/lib/types/Storage.d.ts +15 -2
  135. package/lib/utils/SimpleConnector.js +5 -2
  136. package/lib/utils/decimal.js +2 -1
  137. package/lib/utils/fetch/index.ali.d.ts +3 -0
  138. package/lib/utils/fetch/index.ali.js +36 -0
  139. package/lib/utils/fetch/index.d.ts +3 -0
  140. package/lib/utils/fetch/index.js +7 -0
  141. package/lib/utils/fetch/index.mp.d.ts +5 -3
  142. package/lib/utils/fetch/index.mp.js +5 -282
  143. package/lib/utils/fetch/index.wechat.d.ts +5 -0
  144. package/lib/utils/fetch/index.wechat.js +180 -0
  145. package/lib/utils/fetch/mini-program.shared.d.ts +37 -0
  146. package/lib/utils/fetch/mini-program.shared.js +96 -0
  147. package/lib/utils/geo.d.ts +1 -1
  148. package/lib/utils/geo.js +1 -1
  149. package/lib/utils/random/random.ali.d.ts +6 -0
  150. package/lib/utils/random/random.ali.js +24 -0
  151. package/lib/utils/random/random.mp.d.ts +5 -1
  152. package/lib/utils/random/random.mp.js +11 -5
  153. package/lib/utils/random/random.native.d.ts +1 -1
  154. package/lib/utils/random/random.native.js +7 -5
  155. package/lib/utils/random/random.wechat.d.ts +1 -0
  156. package/lib/utils/random/random.wechat.js +13 -0
  157. package/package.json +8 -5
  158. package/es/store/RelationAuth.d.ts +0 -115
  159. package/es/store/RelationAuth.js +0 -1340
  160. package/lib/store/RelationAuth.d.ts +0 -115
  161. package/lib/store/RelationAuth.js +0 -1345
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeFetchHeaders = normalizeFetchHeaders;
4
+ exports.getHeader = getHeader;
5
+ exports.normalizeMiniProgramResponse = normalizeMiniProgramResponse;
6
+ exports.updateResponseHeaders = updateResponseHeaders;
7
+ exports.createResponseHeaders = createResponseHeaders;
8
+ exports.resolveRequestUrl = resolveRequestUrl;
9
+ exports.resolveRequestData = resolveRequestData;
10
+ exports.getResponseType = getResponseType;
11
+ exports.createResponse = createResponse;
12
+ function normalizeFetchHeaders(headers) {
13
+ const result = { 'Content-Type': 'application/json' };
14
+ if (!headers)
15
+ return result;
16
+ if (Array.isArray(headers)) {
17
+ headers.forEach(([key, value]) => { result[key] = value; });
18
+ return result;
19
+ }
20
+ if (typeof headers.forEach === 'function') {
21
+ headers.forEach((value, key) => { result[key] = value; });
22
+ return result;
23
+ }
24
+ Object.assign(result, headers);
25
+ return result;
26
+ }
27
+ function getHeader(headers, key) {
28
+ const matchedKey = Object.keys(headers).find((headerKey) => headerKey.toLowerCase() === key.toLowerCase());
29
+ return matchedKey ? headers[matchedKey] : undefined;
30
+ }
31
+ function normalizeMiniProgramResponse(response) {
32
+ return {
33
+ data: response.data,
34
+ statusCode: response.statusCode ?? response.status ?? 0,
35
+ header: response.header ?? response.headers ?? {},
36
+ };
37
+ }
38
+ function updateResponseHeaders(target, headers) {
39
+ Object.keys(target).forEach((key) => {
40
+ if (key !== 'get')
41
+ delete target[key];
42
+ });
43
+ Object.entries(headers || {}).forEach(([key, value]) => {
44
+ target[key] = Array.isArray(value) ? value.join(',') : value?.toString() || '';
45
+ });
46
+ return target;
47
+ }
48
+ function createResponseHeaders(headers) {
49
+ const responseHeaders = {
50
+ get(key) {
51
+ return getHeader(this, key);
52
+ },
53
+ };
54
+ return updateResponseHeaders(responseHeaders, headers);
55
+ }
56
+ function resolveRequestUrl(url) {
57
+ if (typeof url === 'string')
58
+ return url;
59
+ if ('url' in url)
60
+ return url.url;
61
+ return String(url);
62
+ }
63
+ function resolveRequestData(body) {
64
+ return body === undefined || body === null ? {} : body;
65
+ }
66
+ function getResponseType(headers) {
67
+ const accept = getHeader(headers, 'Accept');
68
+ return accept && [
69
+ 'image/jpg',
70
+ 'image/jpeg',
71
+ 'image/png',
72
+ 'application/octet-stream',
73
+ ].includes(accept)
74
+ ? 'arraybuffer'
75
+ : 'text';
76
+ }
77
+ function createResponse(requestUrl, response) {
78
+ const normalized = normalizeMiniProgramResponse(response);
79
+ const headers = createResponseHeaders(normalized.header);
80
+ const result = {
81
+ status: normalized.statusCode,
82
+ ok: normalized.statusCode >= 200 && normalized.statusCode < 300,
83
+ headers,
84
+ arrayBuffer: async () => normalized.data,
85
+ json: async () => typeof normalized.data === 'string'
86
+ ? JSON.parse(normalized.data)
87
+ : normalized.data,
88
+ text: async () => String(normalized.data),
89
+ clone: () => result,
90
+ url: requestUrl,
91
+ statusText: normalized.statusCode >= 200 && normalized.statusCode < 300
92
+ ? 'ok'
93
+ : 'error',
94
+ };
95
+ return result;
96
+ }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * 计算地球上两点之间的球面距离(单位:cm)
2
+ * 计算地球上两点之间的球面距离(单位:mm)
3
3
  */
4
4
  export declare function getDistanceBetweenPoints(lat1: number, lon1: number, lat2: number, lon2: number): number;
5
5
  /**
package/lib/utils/geo.js CHANGED
@@ -6,7 +6,7 @@ exports.gcj02tobd09 = gcj02tobd09;
6
6
  exports.wgs84togcj02 = wgs84togcj02;
7
7
  exports.gcj02towgs84 = gcj02towgs84;
8
8
  /**
9
- * 计算地球上两点之间的球面距离(单位:cm)
9
+ * 计算地球上两点之间的球面距离(单位:mm)
10
10
  */
11
11
  function getDistanceBetweenPoints(lat1, lon1, lat2, lon2) {
12
12
  // 转为弧度
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Alipay's mini-program runtime does not expose `my.getRandomValues`.
3
+ * Prefer the standard Web Crypto API when the worker provides it, then use a
4
+ * non-cryptographic fallback for Oak's local UUID allocation.
5
+ */
6
+ export declare function getRandomValues(length: number): Promise<Uint8Array>;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getRandomValues = getRandomValues;
4
+ /**
5
+ * Alipay's mini-program runtime does not expose `my.getRandomValues`.
6
+ * Prefer the standard Web Crypto API when the worker provides it, then use a
7
+ * non-cryptographic fallback for Oak's local UUID allocation.
8
+ */
9
+ async function getRandomValues(length) {
10
+ if (length > 65536) {
11
+ throw new Error('Can only request a maximum of 65536 bytes');
12
+ }
13
+ const crypto = globalThis.crypto;
14
+ if (typeof crypto?.getRandomValues === 'function') {
15
+ const values = new Uint8Array(length);
16
+ crypto.getRandomValues(values);
17
+ return values;
18
+ }
19
+ const values = new Uint8Array(length);
20
+ for (let index = 0; index < values.length; index += 1) {
21
+ values[index] = Math.floor(Math.random() * 256);
22
+ }
23
+ return values;
24
+ }
@@ -1 +1,5 @@
1
- export declare function getRandomValues(length: number): Promise<Uint8Array<ArrayBuffer>>;
1
+ /**
2
+ * Legacy mini-program entry. Provider builds resolve `random.wechat` or
3
+ * `random.ali` before this shared fallback.
4
+ */
5
+ export declare function getRandomValues(length: number): Promise<Uint8Array>;
@@ -1,13 +1,19 @@
1
1
  "use strict";
2
- /// <reference types="wechat-miniprogram" />
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.getRandomValues = getRandomValues;
4
+ /**
5
+ * Legacy mini-program entry. Provider builds resolve `random.wechat` or
6
+ * `random.ali` before this shared fallback.
7
+ */
5
8
  async function getRandomValues(length) {
6
9
  if (length > 65536) {
7
10
  throw new Error('Can only request a maximum of 65536 bytes');
8
11
  }
9
- const { randomValues } = await wx.getRandomValues({
10
- length,
11
- });
12
- return new Uint8Array(randomValues);
12
+ const crypto = globalThis.crypto;
13
+ if (typeof crypto?.getRandomValues !== 'function') {
14
+ throw new Error('crypto.getRandomValues is unavailable');
15
+ }
16
+ const values = new Uint8Array(length);
17
+ crypto.getRandomValues(values);
18
+ return values;
13
19
  }
@@ -1 +1 @@
1
- export declare function getRandomValues(length: number): Promise<Uint8Array<ArrayBuffer>>;
1
+ export declare function getRandomValues(length: number): Promise<Uint8Array>;
@@ -1,13 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getRandomValues = getRandomValues;
4
- const tslib_1 = require("tslib");
5
- const crypto_1 = tslib_1.__importDefault(require("crypto"));
6
4
  async function getRandomValues(length) {
7
5
  if (length > 65536) {
8
6
  throw new Error('Can only request a maximum of 65536 bytes');
9
7
  }
10
- const randomValues = crypto_1.default.randomBytes(length);
11
- return new Uint8Array(randomValues);
12
- ;
8
+ const crypto = globalThis.crypto;
9
+ if (typeof crypto?.getRandomValues !== 'function') {
10
+ throw new Error('crypto.getRandomValues is unavailable');
11
+ }
12
+ const randomValues = new Uint8Array(length);
13
+ crypto.getRandomValues(randomValues);
14
+ return randomValues;
13
15
  }
@@ -0,0 +1 @@
1
+ export declare function getRandomValues(length: number): Promise<Uint8Array>;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ /// <reference types="wechat-miniprogram" />
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.getRandomValues = getRandomValues;
5
+ async function getRandomValues(length) {
6
+ if (length > 65536) {
7
+ throw new Error('Can only request a maximum of 65536 bytes');
8
+ }
9
+ const { randomValues } = await wx.getRandomValues({
10
+ length,
11
+ });
12
+ return new Uint8Array(randomValues);
13
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oak-domain",
3
- "version": "6.1.0",
3
+ "version": "6.1.2",
4
4
  "oak": {
5
5
  "package": true,
6
6
  "i18n": true,
@@ -26,8 +26,9 @@
26
26
  "build:es": "node --stack-size=65500 ./scripts/build.cjs -p ./tsconfig.es.json",
27
27
  "build": "npm run build:lib && npm run build:es",
28
28
  "test:build": "node --stack-size=65500 ./scripts/build.cjs -p ./tsconfig.test.json --noEmit",
29
+ "test:mutation": "stryker run --coverageAnalysis off",
29
30
  "prebuild": "npm run make:domain",
30
- "test": "mocha --require ts-node/register test/**.ts"
31
+ "test": "mocha --require ts-node/register --timeout 10000 test/**.ts"
31
32
  },
32
33
  "files": [
33
34
  "lib/**/*",
@@ -41,6 +42,8 @@
41
42
  "@babel/plugin-proposal-class-properties": "^7.12.13",
42
43
  "@babel/preset-env": "^7.12.13",
43
44
  "@babel/preset-typescript": "^7.12.13",
45
+ "@stryker-mutator/core": "^10.1.1",
46
+ "@stryker-mutator/mocha-runner": "^10.1.1",
44
47
  "@types/assert": "^1.5.6",
45
48
  "@types/cross-spawn": "^6.0.2",
46
49
  "@types/fs-extra": "^9.0.13",
@@ -60,9 +63,7 @@
60
63
  "fs-extra": "^10.0.0",
61
64
  "mocha": "^8.2.1",
62
65
  "node-watch": "^0.7.4",
63
- "ts-node": "^10.9.1",
64
- "tslib": "^2.4.0",
65
- "typescript": "^5.9.0"
66
+ "ts-node": "^10.9.1"
66
67
  },
67
68
  "dependencies": {
68
69
  "bignumber.js": "^11.1.1",
@@ -72,6 +73,8 @@
72
73
  "koa-body": "^5.0.0",
73
74
  "node-schedule": "^2.1.1",
74
75
  "socket.io": "^4.8.1",
76
+ "tslib": "^2.4.0",
77
+ "typescript": "5.9.3",
75
78
  "uuid": "^9.0.0"
76
79
  }
77
80
  }
@@ -1,115 +0,0 @@
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,解构出projection最底层的对象,如果最底层的对象可以被访问,则父对象一定可以
29
- * 假设对象的关系是:A -> B -> C,此时的projection如果是:
30
- * 1)A: { B: { }}
31
- * 查询的底层对象是A
32
- * 2)C: { B$c : { A$b: {}} }
33
- * 这样写,查询的最底层对象仍然是A
34
- *
35
- * 但如果又有一个对象D -> C,此时的projection如果是:
36
- * 1)C: { B$c : { A$b: {}}, D$c: {} }
37
- * 查询的底层对象是A和D
38
- * 2)B: { C: { D$c: {}} }
39
- * 这种情况,查询的最底层对象是B和D,但这种查询的写法在真实应用中出现的概率非常低,可能想到的情况只有D是静态维表(select free)
40
- * B和D如果同时是业务敏感对象,出现在同一个页面(逻辑)中的case应当不存在。
41
- *
42
- * 所以本函数不处理所有向父对象方向上的递归
43
- * @param entity
44
- * @param operation
45
- */
46
- private getLowestSelections;
47
- /**
48
- * 对于operation,解构出一个树形结构,以方便自顶向下的进行访问
49
- * 但对于deduce的子对象,不必再向底层查看
50
- * @param entity
51
- * @param selection
52
- */
53
- private destructOperation;
54
- private makePathFilter;
55
- /**
56
- * 对所有满足操作要求的actionAuth加以判断,找到可以满足当前用户身份的actionAuth
57
- * @param entity
58
- * @param filter
59
- * @param actionAuths
60
- * @param context
61
- * @return
62
- */
63
- private filterActionAuths;
64
- /**
65
- * 对于有些特殊的查询(带很多$or的查询,多发生在系统级别),单个actionAuth无法满足,需要共同加以判定
66
- * @param entity
67
- * @param filter
68
- * @param actionAuths
69
- * @param context
70
- * @param actions
71
- */
72
- private checkActionAuthInGroup;
73
- private checkSelection;
74
- /**
75
- * 此函数判定一个结点是否能通过权限检测,同时寻找该结点本身对象上成立的actionAuth,用于本结点子孙结点的快速检测
76
- * 如果结点因其deduce的对象通过了检测,其被推断对象的actionAuth无法用于更低对象的权限检测
77
- * @param node
78
- * @param context
79
- * @returns
80
- */
81
- private findActionAuthsOnNode;
82
- private checkOperationTree2;
83
- private checkOperation;
84
- /**
85
- * 检查一个operation是否能被通过权限测试
86
- * 一个cascadeOperation是一棵树形结构:
87
- * * 对于select,只要叶子通过其父结点必然通过;
88
- * * 对于update,自顶向下进行检查,若父亲被权限S通过,则只需要检查子对于S有没有相对路径上的actionAuth
89
- * 另外在update中,还需要考虑自建userRelation的case(例如在电子商务网站上购买商品,创建订单同时创建用户和订单的关系)
90
- * @param entity
91
- * @param operation
92
- * @param context
93
- * @param actions
94
- * @returns
95
- */
96
- private checkActions2;
97
- }
98
- /**
99
- * 获取有对entity进行actions操作权限的userRelation关系
100
- * @param params
101
- * @param context
102
- */
103
- export declare function getUserRelationsByActions<ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends AsyncContext<ED>>(params: {
104
- entity: T;
105
- filter: ED[T]['Filter'];
106
- actions: ED[T]['Action'][];
107
- overlap?: boolean;
108
- }, context: Cxt): Promise<{
109
- userRelations: ED["userRelation"]["Schema"][];
110
- userEntities: {
111
- entity: keyof ED;
112
- entityId: string;
113
- userId: string;
114
- }[];
115
- }>;