@byted-apaas/server-sdk-node 0.0.1-beta.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.
Files changed (163) hide show
  1. package/LICENSE +7 -0
  2. package/NOTICE +3 -0
  3. package/README.md +1 -0
  4. package/application/application.d.ts +27 -0
  5. package/application/application.js +2 -0
  6. package/application/application.ts +40 -0
  7. package/application/function/function.d.ts +14 -0
  8. package/application/function/function.js +21 -0
  9. package/application/function/function.ts +37 -0
  10. package/application/impl/common.d.ts +2 -0
  11. package/application/impl/common.js +50 -0
  12. package/application/impl/common.ts +50 -0
  13. package/application/impl/impl.d.ts +16 -0
  14. package/application/impl/impl.js +38 -0
  15. package/application/impl/impl.ts +48 -0
  16. package/constants/constants.d.ts +10 -0
  17. package/constants/constants.js +15 -0
  18. package/constants/constants.ts +15 -0
  19. package/context/context.d.ts +74 -0
  20. package/context/context.js +25 -0
  21. package/context/context.ts +130 -0
  22. package/context/db/db.d.ts +73 -0
  23. package/context/db/db.js +4 -0
  24. package/context/db/db.ts +80 -0
  25. package/context/db/impl/IObject.d.ts +251 -0
  26. package/context/db/impl/IObject.js +5 -0
  27. package/context/db/impl/IObject.ts +247 -0
  28. package/context/db/impl/db.d.ts +61 -0
  29. package/context/db/impl/db.js +86 -0
  30. package/context/db/impl/db.ts +95 -0
  31. package/context/db/impl/object.d.ts +92 -0
  32. package/context/db/impl/object.js +524 -0
  33. package/context/db/impl/object.ts +631 -0
  34. package/context/db/impl/oql/ioql.d.ts +6 -0
  35. package/context/db/impl/oql/ioql.js +4 -0
  36. package/context/db/impl/oql/ioql.ts +9 -0
  37. package/context/db/impl/oql/oql.d.ts +8 -0
  38. package/context/db/impl/oql/oql.js +21 -0
  39. package/context/db/impl/oql/oql.ts +25 -0
  40. package/context/db/impl/order.d.ts +9 -0
  41. package/context/db/impl/order.js +15 -0
  42. package/context/db/impl/order.ts +19 -0
  43. package/context/db/impl/propertiesStore.d.ts +8 -0
  44. package/context/db/impl/propertiesStore.js +29 -0
  45. package/context/db/impl/propertiesStore.ts +31 -0
  46. package/context/db/impl/queryBuilder.d.ts +29 -0
  47. package/context/db/impl/queryBuilder.js +78 -0
  48. package/context/db/impl/queryBuilder.ts +106 -0
  49. package/context/db/impl/transaction/index.d.ts +20 -0
  50. package/context/db/impl/transaction/index.js +277 -0
  51. package/context/db/impl/transaction/index.ts +340 -0
  52. package/context/db/impl/transaction/operation.d.ts +27 -0
  53. package/context/db/impl/transaction/operation.js +69 -0
  54. package/context/db/impl/transaction/operation.ts +72 -0
  55. package/context/db/impl/transaction.d.ts +67 -0
  56. package/context/db/impl/transaction.js +4 -0
  57. package/context/db/impl/transaction.ts +79 -0
  58. package/context/globalConfig/globalConfig.d.ts +7 -0
  59. package/context/globalConfig/globalConfig.js +16 -0
  60. package/context/globalConfig/globalConfig.ts +14 -0
  61. package/context/metadata/components/common.d.ts +6 -0
  62. package/context/metadata/components/common.js +17 -0
  63. package/context/metadata/components/common.ts +22 -0
  64. package/context/metadata/components/components.d.ts +12 -0
  65. package/context/metadata/components/components.js +19 -0
  66. package/context/metadata/components/components.ts +22 -0
  67. package/context/metadata/components/desktop/list.d.ts +16 -0
  68. package/context/metadata/components/desktop/list.js +402 -0
  69. package/context/metadata/components/desktop/list.ts +457 -0
  70. package/context/metadata/components/desktop/recordDetail.d.ts +11 -0
  71. package/context/metadata/components/desktop/recordDetail.js +53 -0
  72. package/context/metadata/components/desktop/recordDetail.ts +67 -0
  73. package/context/metadata/components/mobile/list.d.ts +24 -0
  74. package/context/metadata/components/mobile/list.js +145 -0
  75. package/context/metadata/components/mobile/list.ts +179 -0
  76. package/context/metadata/metadata.d.ts +61 -0
  77. package/context/metadata/metadata.js +103 -0
  78. package/context/metadata/metadata.ts +178 -0
  79. package/context/metadata/objects/fields.d.ts +130 -0
  80. package/context/metadata/objects/fields.js +334 -0
  81. package/context/metadata/objects/fields.ts +457 -0
  82. package/context/metadata/objects/fields.util.d.ts +40 -0
  83. package/context/metadata/objects/fields.util.js +319 -0
  84. package/context/metadata/objects/fields.util.ts +360 -0
  85. package/context/metadata/objects/objects.d.ts +11 -0
  86. package/context/metadata/objects/objects.js +20 -0
  87. package/context/metadata/objects/objects.ts +30 -0
  88. package/context/metadata/types/common.d.ts +6 -0
  89. package/context/metadata/types/common.js +9 -0
  90. package/context/metadata/types/common.ts +13 -0
  91. package/context/metadata/types/components.d.ts +90 -0
  92. package/context/metadata/types/components.js +4 -0
  93. package/context/metadata/types/components.ts +108 -0
  94. package/context/metadata/types/objects.d.ts +226 -0
  95. package/context/metadata/types/objects.js +4 -0
  96. package/context/metadata/types/objects.ts +254 -0
  97. package/context/msg/msg.d.ts +38 -0
  98. package/context/msg/msg.js +35 -0
  99. package/context/msg/msg.ts +52 -0
  100. package/context/resources/IResources.d.ts +66 -0
  101. package/context/resources/IResources.js +2 -0
  102. package/context/resources/IResources.ts +73 -0
  103. package/context/resources/impl/resources.d.ts +42 -0
  104. package/context/resources/impl/resources.js +150 -0
  105. package/context/resources/impl/resources.ts +173 -0
  106. package/context/tasks/tasks.d.ts +33 -0
  107. package/context/tasks/tasks.js +139 -0
  108. package/context/tasks/tasks.ts +159 -0
  109. package/data/index.d.ts +27 -0
  110. package/data/index.js +4 -0
  111. package/data/index.ts +30 -0
  112. package/hooks/api.d.ts +61 -0
  113. package/hooks/api.js +327 -0
  114. package/hooks/api.ts +341 -0
  115. package/hooks/hooks.d.ts +1 -0
  116. package/hooks/hooks.js +88 -0
  117. package/hooks/hooks.ts +100 -0
  118. package/kunlun/kunlun.d.ts +55 -0
  119. package/kunlun/kunlun.js +58 -0
  120. package/kunlun/kunlun.ts +72 -0
  121. package/kunlun/operator/IOperator.d.ts +158 -0
  122. package/kunlun/operator/IOperator.js +4 -0
  123. package/kunlun/operator/IOperator.ts +166 -0
  124. package/kunlun/operator/impl/expression.d.ts +47 -0
  125. package/kunlun/operator/impl/expression.js +56 -0
  126. package/kunlun/operator/impl/expression.ts +74 -0
  127. package/kunlun/operator/impl/logic.d.ts +50 -0
  128. package/kunlun/operator/impl/logic.js +509 -0
  129. package/kunlun/operator/impl/logic.ts +598 -0
  130. package/kunlun/operator/impl/logicV2.d.ts +58 -0
  131. package/kunlun/operator/impl/logicV2.js +200 -0
  132. package/kunlun/operator/impl/logicV2.ts +254 -0
  133. package/kunlun/operator/impl/operator.d.ts +179 -0
  134. package/kunlun/operator/impl/operator.js +222 -0
  135. package/kunlun/operator/impl/operator.ts +258 -0
  136. package/kunlun/operator/impl/operatorV2.d.ts +180 -0
  137. package/kunlun/operator/impl/operatorV2.js +216 -0
  138. package/kunlun/operator/impl/operatorV2.ts +249 -0
  139. package/lib/core.d.ts +4 -0
  140. package/lib/core.js +19 -0
  141. package/lib/core.ts +7 -0
  142. package/package.json +50 -0
  143. package/request/common.d.ts +13 -0
  144. package/request/common.js +87 -0
  145. package/request/common.ts +91 -0
  146. package/request/constants.d.ts +10 -0
  147. package/request/constants.js +25 -0
  148. package/request/constants.ts +25 -0
  149. package/request/faasinfra.d.ts +8 -0
  150. package/request/faasinfra.js +358 -0
  151. package/request/faasinfra.ts +393 -0
  152. package/request/innerapi.d.ts +67 -0
  153. package/request/innerapi.js +1412 -0
  154. package/request/innerapi.ts +1648 -0
  155. package/request/interface.d.ts +95 -0
  156. package/request/interface.js +41 -0
  157. package/request/interface.ts +169 -0
  158. package/request/openapi.d.ts +69 -0
  159. package/request/openapi.js +1014 -0
  160. package/request/openapi.ts +1223 -0
  161. package/types/types.d.ts +79 -0
  162. package/types/types.js +4 -0
  163. package/types/types.ts +108 -0
@@ -0,0 +1,72 @@
1
+ // Copyright 2022 ByteDance Ltd. and/or its affiliates
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ import { IOperator } from './operator/IOperator';
5
+ import { globalVariables } from '../data/index'
6
+ import { GMTOffset as GMT } from "@byted-apaas/server-common-node/constants/timeZone";
7
+ import { area2code } from "@byted-apaas/server-common-node/constants/countryCode";
8
+ import { ITool, IToolsExtra } from "@byted-apaas/server-common-node/kunlun/tool/Itool";
9
+ import { Tool } from "@byted-apaas/server-common-node/kunlun/tool/impl/tool";
10
+ import { errCodes } from "@byted-apaas/server-common-node/utils/exceptions";
11
+ import { Operator } from "./operator/impl/operator";
12
+ import * as common from "@byted-apaas/server-common-node";
13
+ import * as Request from "../request/interface";
14
+
15
+ declare global {
16
+ export namespace kunlun {
17
+ /**
18
+ * 指令操作符
19
+ */
20
+ export let operator: IOperator;
21
+ }
22
+ }
23
+
24
+ export namespace kunlun {
25
+ /**
26
+ * 引用时区信息
27
+ */
28
+ export const GMTOffset: typeof GMT = GMT;
29
+
30
+ /**
31
+ * 引用国际区号
32
+ */
33
+ export const countryCode: typeof area2code = area2code;
34
+
35
+ /**
36
+ * 工具方法
37
+ */
38
+ export let tool: ITool & IToolsExtra = new Tool();
39
+
40
+ /**
41
+ * 生成复杂数据结构
42
+ */
43
+ export namespace type {
44
+ export import Multilingual = common.fieldType.Multilingual
45
+ export import Phone = common.fieldType.Phone
46
+ export import Date = common.fieldType.Date
47
+ export import DateTime = common.fieldType.DateTime
48
+ }
49
+
50
+ /**
51
+ * 错误码
52
+ */
53
+ export const errorCode = {
54
+ /**
55
+ * 限流错误码
56
+ */
57
+ RATE_LIMIT_ERROR: errCodes.RATE_LIMIT_ERROR,
58
+ }
59
+
60
+ /**
61
+ * 根据 key 获取对应的全局变量
62
+ * @param key 全局变量的 key
63
+ */
64
+ export async function getVar(key: string): Promise<string> {
65
+ return await Request.GetInstance().getGlobalConfigByKey(key);
66
+ }
67
+
68
+ /**
69
+ * 指令操作符
70
+ */
71
+ export const operator: IOperator = new Operator();
72
+ }
@@ -0,0 +1,158 @@
1
+ import { _Cond, _BooleanCond, _LogicalCond } from '../../types/types';
2
+ import { UserDataType } from './impl/expression';
3
+ export interface IOperator {
4
+ /**
5
+ * 逻辑与
6
+ * @param conditions 多个条件,用逗号分隔
7
+ * @example
8
+ * ```
9
+ * context.db.object("_user").where(kunlun.operator.and({
10
+ * age: "22"
11
+ * },{
12
+ * gender: "male"
13
+ * }))
14
+ * ```
15
+ */
16
+ and<T>(...conditions: (_Cond<T> | _BooleanCond<T>)[]): _LogicalCond<T>;
17
+ /**
18
+ * 逻辑或
19
+ * @param conditions 多个条件,用逗号分隔
20
+ * @example
21
+ * ```
22
+ * context.db.object("_user").where(kunlun.operator.or({
23
+ * age: "22"
24
+ * },{
25
+ * age: "25"
26
+ * }))
27
+ * ```
28
+ */
29
+ or<T>(...conditions: (_Cond<T> | _BooleanCond<T>)[]): _LogicalCond<T>;
30
+ /**
31
+ * 包含
32
+ * @param value 判定是否包含的文本值
33
+ * @example
34
+ * ```
35
+ * context.db.object("_user").where({_name: kunlun.operator.contain("a")})
36
+ * ```
37
+ */
38
+ contain<T>(value: UserDataType): _BooleanCond<T>;
39
+ /**
40
+ * 不包含
41
+ * @param value 判定是否不包含的文本值
42
+ * @example
43
+ * ```
44
+ * context.db.object("_user").where({_name: kunlun.operator.notContain("a")})
45
+ * ```
46
+ */
47
+ notContain<T>(value: UserDataType): _BooleanCond<T>;
48
+ /**
49
+ * 无需入参,判断是否为空
50
+ * @example
51
+ * ```
52
+ * context.db.object("_user").where({employeeType: kunlun.operator.empty()})
53
+ * ```
54
+ */
55
+ empty(): _BooleanCond<any>;
56
+ /**
57
+ * 无需入参,判断是否为空
58
+ * @example
59
+ * ```
60
+ * context.db.object("_user").where({employeeType: kunlun.operator.notEmpty()})
61
+ * ```
62
+ */
63
+ notEmpty(): _BooleanCond<any>;
64
+ /**
65
+ * 等于
66
+ * @param value 判定是否相等的值
67
+ * @example
68
+ * ```
69
+ * context.db.object("_user").where({age: kunlun.operator.eq(20)})
70
+ * ```
71
+ */
72
+ eq<T>(value: UserDataType): _BooleanCond<T>;
73
+ /**
74
+ * 不等于
75
+ * @param value 判定是否不相等的值
76
+ * @example
77
+ * ```
78
+ * context.db.object("_user").where({age: kunlun.operator.neq(20)})
79
+ * ```
80
+ */
81
+ neq<T>(value: UserDataType): _BooleanCond<T>;
82
+ /**
83
+ * 大于或晚于
84
+ * @param value 判定是否大于或晚于的值
85
+ * @example
86
+ * ```
87
+ * kunlun.operator.gt(new Date("2020-11-26").getTime())
88
+ * ```
89
+ */
90
+ gt<T>(value: number | Date): _BooleanCond<T>;
91
+ /**
92
+ * 大于等于或晚于等于
93
+ * @param value 判定是否大于等于或晚于等于的值
94
+ * @example
95
+ * ```
96
+ * kunlun.operator.gte(new Date("2020-11-26").getTime())
97
+ * ```
98
+ */
99
+ gte<T>(value: number | Date): _BooleanCond<T>;
100
+ /**
101
+ * 小于或早于
102
+ * @param value 判定是否小于或早于的值
103
+ * @example
104
+ * ```
105
+ * kunlun.operator.lt(new Date("2020-11-26").getTime())
106
+ * ```
107
+ */
108
+ lt<T>(value: number | Date): _BooleanCond<T>;
109
+ /**
110
+ * 小于等于或早于等于
111
+ * @param value 判定是否小于等于或早于等于的值
112
+ * @example
113
+ * ```
114
+ * kunlun.operator.lte(new Date("2020-11-26").getTime())
115
+ * ```
116
+ */
117
+ lte<T>(value: number | Date): _BooleanCond<T>;
118
+ /**
119
+ * 存在于给定的数组内
120
+ * @param values 判定是否存在于的一组值,用数组传递
121
+ */
122
+ in<T>(values: UserDataType[]): _BooleanCond<T>;
123
+ /**
124
+ * 存在于给定的数组内
125
+ * @param values 判定是否存在于的一组值,用逗号分隔
126
+ */
127
+ in<T>(...values: UserDataType[]): _BooleanCond<T>;
128
+ /**
129
+ * 不存在于给定的数组内
130
+ * @param values 判定是否不存在于的一组值,用数组传递
131
+ */
132
+ notIn<T>(values: UserDataType[]): _BooleanCond<T>;
133
+ /**
134
+ * 不存在于给定的数组内
135
+ * @param values 判定是否不存在于的一组值,用逗号分隔
136
+ */
137
+ notIn<T>(...values: UserDataType[]): _BooleanCond<T>;
138
+ /**
139
+ * 存在给定的多个值中的任何一个值
140
+ * @param values 判定是否不存在于的一组值,用逗号分隔
141
+ */
142
+ hasAnyOf<T>(values: number[] | string[]): _BooleanCond<T>;
143
+ /**
144
+ * 存在给定的多个值中的任何一个值
145
+ * @param values 判定是否不存在于的一组值,用逗号分隔
146
+ */
147
+ hasAnyOf<T>(...values: number[] | string[]): _BooleanCond<T>;
148
+ /**
149
+ * 不存在给定的多个值中的任何值
150
+ * @param values 判定是否不存在于的一组值,用逗号分隔
151
+ */
152
+ hasNoneOf<T>(values: number[] | string[]): _BooleanCond<T>;
153
+ /**
154
+ * 不存在给定的多个值中的任何值
155
+ * @param values 判定是否不存在于的一组值,用逗号分隔
156
+ */
157
+ hasNoneOf<T>(...values: number[] | string[]): _BooleanCond<T>;
158
+ }
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ // Copyright 2022 ByteDance Ltd. and/or its affiliates
3
+ // SPDX-License-Identifier: MIT
4
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,166 @@
1
+ // Copyright 2022 ByteDance Ltd. and/or its affiliates
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ import { _Cond, _BooleanCond, _LogicalCond } from '../../types/types'
5
+ import { UserDataType } from './impl/expression';
6
+
7
+ export interface IOperator {
8
+ /**
9
+ * 逻辑与
10
+ * @param conditions 多个条件,用逗号分隔
11
+ * @example
12
+ * ```
13
+ * context.db.object("_user").where(kunlun.operator.and({
14
+ * age: "22"
15
+ * },{
16
+ * gender: "male"
17
+ * }))
18
+ * ```
19
+ */
20
+ and<T>(...conditions: (_Cond<T> | _BooleanCond<T>)[]): _LogicalCond<T>;
21
+ /**
22
+ * 逻辑或
23
+ * @param conditions 多个条件,用逗号分隔
24
+ * @example
25
+ * ```
26
+ * context.db.object("_user").where(kunlun.operator.or({
27
+ * age: "22"
28
+ * },{
29
+ * age: "25"
30
+ * }))
31
+ * ```
32
+ */
33
+ or<T>(...conditions: (_Cond<T> | _BooleanCond<T>)[]): _LogicalCond<T>;
34
+ /**
35
+ * 包含
36
+ * @param value 判定是否包含的文本值
37
+ * @example
38
+ * ```
39
+ * context.db.object("_user").where({_name: kunlun.operator.contain("a")})
40
+ * ```
41
+ */
42
+ contain<T>(value: UserDataType): _BooleanCond<T>;
43
+ /**
44
+ * 不包含
45
+ * @param value 判定是否不包含的文本值
46
+ * @example
47
+ * ```
48
+ * context.db.object("_user").where({_name: kunlun.operator.notContain("a")})
49
+ * ```
50
+ */
51
+ notContain<T>(value: UserDataType): _BooleanCond<T>;
52
+ /**
53
+ * 无需入参,判断是否为空
54
+ * @example
55
+ * ```
56
+ * context.db.object("_user").where({employeeType: kunlun.operator.empty()})
57
+ * ```
58
+ */
59
+ empty(): _BooleanCond<any>;
60
+ /**
61
+ * 无需入参,判断是否为空
62
+ * @example
63
+ * ```
64
+ * context.db.object("_user").where({employeeType: kunlun.operator.notEmpty()})
65
+ * ```
66
+ */
67
+ notEmpty(): _BooleanCond<any>;
68
+ /**
69
+ * 等于
70
+ * @param value 判定是否相等的值
71
+ * @example
72
+ * ```
73
+ * context.db.object("_user").where({age: kunlun.operator.eq(20)})
74
+ * ```
75
+ */
76
+ eq<T>(value: UserDataType): _BooleanCond<T>;
77
+ /**
78
+ * 不等于
79
+ * @param value 判定是否不相等的值
80
+ * @example
81
+ * ```
82
+ * context.db.object("_user").where({age: kunlun.operator.neq(20)})
83
+ * ```
84
+ */
85
+ neq<T>(value: UserDataType): _BooleanCond<T>;
86
+ /**
87
+ * 大于或晚于
88
+ * @param value 判定是否大于或晚于的值
89
+ * @example
90
+ * ```
91
+ * kunlun.operator.gt(new Date("2020-11-26").getTime())
92
+ * ```
93
+ */
94
+ gt<T>(value: number | Date): _BooleanCond<T>;
95
+ /**
96
+ * 大于等于或晚于等于
97
+ * @param value 判定是否大于等于或晚于等于的值
98
+ * @example
99
+ * ```
100
+ * kunlun.operator.gte(new Date("2020-11-26").getTime())
101
+ * ```
102
+ */
103
+ gte<T>(value: number | Date): _BooleanCond<T>;
104
+ /**
105
+ * 小于或早于
106
+ * @param value 判定是否小于或早于的值
107
+ * @example
108
+ * ```
109
+ * kunlun.operator.lt(new Date("2020-11-26").getTime())
110
+ * ```
111
+ */
112
+ lt<T>(value: number | Date): _BooleanCond<T>;
113
+ /**
114
+ * 小于等于或早于等于
115
+ * @param value 判定是否小于等于或早于等于的值
116
+ * @example
117
+ * ```
118
+ * kunlun.operator.lte(new Date("2020-11-26").getTime())
119
+ * ```
120
+ */
121
+ lte<T>(value: number | Date): _BooleanCond<T>;
122
+ /**
123
+ * 存在于给定的数组内
124
+ * @param values 判定是否存在于的一组值,用数组传递
125
+ */
126
+ in<T>(values: UserDataType[]): _BooleanCond<T>;
127
+ /**
128
+ * 存在于给定的数组内
129
+ * @param values 判定是否存在于的一组值,用逗号分隔
130
+ */
131
+ in<T>(...values: UserDataType[]): _BooleanCond<T>;
132
+ /**
133
+ * 不存在于给定的数组内
134
+ * @param values 判定是否不存在于的一组值,用数组传递
135
+ */
136
+ notIn<T>(values: UserDataType[]): _BooleanCond<T>;
137
+ /**
138
+ * 不存在于给定的数组内
139
+ * @param values 判定是否不存在于的一组值,用逗号分隔
140
+ */
141
+ notIn<T>(...values: UserDataType[]): _BooleanCond<T>;
142
+
143
+ /**
144
+ * 存在给定的多个值中的任何一个值
145
+ * @param values 判定是否不存在于的一组值,用逗号分隔
146
+ */
147
+ hasAnyOf<T>(values: number[] | string[]): _BooleanCond<T>;
148
+
149
+ /**
150
+ * 存在给定的多个值中的任何一个值
151
+ * @param values 判定是否不存在于的一组值,用逗号分隔
152
+ */
153
+ hasAnyOf<T>(...values: number[] | string[]): _BooleanCond<T>;
154
+
155
+ /**
156
+ * 不存在给定的多个值中的任何值
157
+ * @param values 判定是否不存在于的一组值,用逗号分隔
158
+ */
159
+ hasNoneOf<T>(values: number[] | string[]): _BooleanCond<T>;
160
+
161
+ /**
162
+ * 不存在给定的多个值中的任何值
163
+ * @param values 判定是否不存在于的一组值,用逗号分隔
164
+ */
165
+ hasNoneOf<T>(...values: number[] | string[]): _BooleanCond<T>;
166
+ }
@@ -0,0 +1,47 @@
1
+ export declare type UserDataType = null | string | boolean | number | Date | object;
2
+ export declare class Expression {
3
+ index: number;
4
+ left: ExpressionField;
5
+ operator: string;
6
+ right: ExpressionField;
7
+ constructor(left: ExpressionField, operator: string, right: ExpressionField, index: number);
8
+ }
9
+ declare type SettingType = {
10
+ data?: UserDataType;
11
+ fieldPath?: PathType[];
12
+ };
13
+ export declare type PathType = {
14
+ objectApiName: string;
15
+ fieldApiName: string;
16
+ extendLogicTags: string[];
17
+ };
18
+ /**
19
+ * 总共有4种类型,当前仅支持constant,metadataVariable
20
+ *
21
+ * constant:不可为左值
22
+ * metadataVariable
23
+ * function
24
+ * customizedVariable
25
+ */
26
+ declare class ExpressionField {
27
+ type: string;
28
+ settings: SettingType;
29
+ constructor(type: string, settings: SettingType);
30
+ }
31
+ /**
32
+ * 常量表达式字段
33
+ *
34
+ * 比如在 condition: user.name equal "bob" 中,"bob" 将被构建为 ConstantExpressionField
35
+ */
36
+ export declare class ConstantExpressionField extends ExpressionField {
37
+ constructor(data: UserDataType);
38
+ }
39
+ /**
40
+ * 元数据表达式字段
41
+ *
42
+ * 比如在 condition: user.name equal "bob" 中,"user.name" 将被构建为 MetadataExpressionField
43
+ */
44
+ export declare class MetadataExpressionField extends ExpressionField {
45
+ constructor(objectApiName: string, fieldApiName: string);
46
+ }
47
+ export {};
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ // Copyright 2022 ByteDance Ltd. and/or its affiliates
3
+ // SPDX-License-Identifier: MIT
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.MetadataExpressionField = exports.ConstantExpressionField = exports.Expression = void 0;
6
+ class Expression {
7
+ constructor(left, operator, right, index) {
8
+ this.index = index;
9
+ this.left = left;
10
+ this.operator = operator;
11
+ this.right = right;
12
+ }
13
+ }
14
+ exports.Expression = Expression;
15
+ /**
16
+ * 总共有4种类型,当前仅支持constant,metadataVariable
17
+ *
18
+ * constant:不可为左值
19
+ * metadataVariable
20
+ * function
21
+ * customizedVariable
22
+ */
23
+ class ExpressionField {
24
+ constructor(type, settings) {
25
+ this.type = type;
26
+ this.settings = settings;
27
+ }
28
+ }
29
+ /**
30
+ * 常量表达式字段
31
+ *
32
+ * 比如在 condition: user.name equal "bob" 中,"bob" 将被构建为 ConstantExpressionField
33
+ */
34
+ class ConstantExpressionField extends ExpressionField {
35
+ constructor(data) {
36
+ super("constant", { "data": data });
37
+ }
38
+ }
39
+ exports.ConstantExpressionField = ConstantExpressionField;
40
+ /**
41
+ * 元数据表达式字段
42
+ *
43
+ * 比如在 condition: user.name equal "bob" 中,"user.name" 将被构建为 MetadataExpressionField
44
+ */
45
+ class MetadataExpressionField extends ExpressionField {
46
+ constructor(objectApiName, fieldApiName) {
47
+ super("metadataVariable", {
48
+ "fieldPath": [{
49
+ objectApiName: objectApiName,
50
+ fieldApiName: fieldApiName,
51
+ extendLogicTags: [],
52
+ }]
53
+ });
54
+ }
55
+ }
56
+ exports.MetadataExpressionField = MetadataExpressionField;
@@ -0,0 +1,74 @@
1
+ // Copyright 2022 ByteDance Ltd. and/or its affiliates
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ export type UserDataType = null | string | boolean | number | Date | object
5
+
6
+ export class Expression {
7
+ index: number
8
+ left: ExpressionField
9
+ operator: string
10
+ right: ExpressionField
11
+
12
+ constructor(left: ExpressionField, operator: string, right: ExpressionField, index: number) {
13
+ this.index = index;
14
+ this.left = left;
15
+ this.operator = operator;
16
+ this.right = right;
17
+ }
18
+ }
19
+
20
+ type SettingType = {
21
+ data?: UserDataType
22
+ fieldPath?: PathType[]
23
+ }
24
+
25
+ export type PathType = {
26
+ objectApiName: string
27
+ fieldApiName: string
28
+ extendLogicTags: string[]
29
+ }
30
+
31
+ /**
32
+ * 总共有4种类型,当前仅支持constant,metadataVariable
33
+ *
34
+ * constant:不可为左值
35
+ * metadataVariable
36
+ * function
37
+ * customizedVariable
38
+ */
39
+ class ExpressionField {
40
+ type: string
41
+ settings: SettingType
42
+ constructor(type: string, settings: SettingType) {
43
+ this.type = type;
44
+ this.settings = settings;
45
+ }
46
+ }
47
+
48
+ /**
49
+ * 常量表达式字段
50
+ *
51
+ * 比如在 condition: user.name equal "bob" 中,"bob" 将被构建为 ConstantExpressionField
52
+ */
53
+ export class ConstantExpressionField extends ExpressionField {
54
+ constructor(data: UserDataType) {
55
+ super("constant", {"data": data});
56
+ }
57
+ }
58
+
59
+ /**
60
+ * 元数据表达式字段
61
+ *
62
+ * 比如在 condition: user.name equal "bob" 中,"user.name" 将被构建为 MetadataExpressionField
63
+ */
64
+ export class MetadataExpressionField extends ExpressionField {
65
+ constructor(objectApiName: string, fieldApiName: string) {
66
+ super("metadataVariable", {
67
+ "fieldPath": [{
68
+ objectApiName: objectApiName,
69
+ fieldApiName: fieldApiName,
70
+ extendLogicTags: [],
71
+ }]
72
+ });
73
+ }
74
+ }
@@ -0,0 +1,50 @@
1
+ import { Expression, UserDataType } from './expression';
2
+ export declare class Condition {
3
+ left: string;
4
+ right: Condition | UserDataType;
5
+ op: string;
6
+ /**
7
+ *
8
+ * @param objectApiName 对象的ApiName
9
+ * @param fieldApiName 字段的ApiName,指左值,即key
10
+ * @param index 条件的排序
11
+ * @returns {Expression}
12
+ */
13
+ toExpression(objectApiName: string, fieldApiName: string, index: number): Expression;
14
+ constructor(left: string, right: Condition | UserDataType, op?: string);
15
+ }
16
+ export declare type Criterion = {
17
+ conditions: Expression[];
18
+ logic: string;
19
+ };
20
+ /**
21
+ * 构造 criterion
22
+ *
23
+ * @param logic
24
+ * @param objectApiName
25
+ * @param maxId 添加 _id>maxId 条件,为 -1 表示不使用该参数
26
+ */
27
+ export declare function buildCriterion(logic: Logic, objectApiName: string, maxId?: number): Criterion | string;
28
+ export declare function buildExpression(objectApiName: string, left: string, right: Condition | UserDataType, index?: number): Expression;
29
+ export declare class Logic {
30
+ value: string;
31
+ expressions: {
32
+ [index: string]: any;
33
+ };
34
+ logics: Logic[];
35
+ constructor(expressions?: {
36
+ [index: string]: any;
37
+ }, logicValue?: string);
38
+ /**
39
+ * 处理:右值包含逻辑表达式and|or的情况
40
+ *
41
+ * @param expressions
42
+ * @param lookupField
43
+ */
44
+ handleRightLogic(expressions: {
45
+ [index: string]: any;
46
+ }, lookupField?: string): void;
47
+ addLogic(logic: Logic): void;
48
+ }
49
+ export declare function buildLogic(param: (Logic | object)[], logicValue?: string): Logic;
50
+ export declare function handleCriterion(criterion: string | Criterion): Promise<string | Criterion>;