@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,222 @@
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.Operator = exports.operates = void 0;
6
+ const server_common_node_1 = require("@byted-apaas/server-common-node");
7
+ const logic_1 = require("./logic");
8
+ exports.operates = {
9
+ AND: "and",
10
+ OR: "or",
11
+ EMTPY: "isEmpty",
12
+ NOT_EMTPY: "isNotEmpty",
13
+ EQ: "equals",
14
+ NEQ: "notEquals",
15
+ LT: "lessThan",
16
+ LTE: "lessThanOrEquals",
17
+ GT: "greaterThan",
18
+ GTE: "greaterThanOrEquals",
19
+ CONTAIN: "contains",
20
+ NOT_CONTAIN: "notContains",
21
+ IN: "isAnyOf",
22
+ NIN: "isNoneOf",
23
+ HAS_ANY_OF: "hasAnyOf",
24
+ HAS_NONE_OF: "hasNoneOf",
25
+ isOnOrBefore: "isOnOrBefore",
26
+ isOnOrAfter: "isOnOrAfter",
27
+ };
28
+ class Operator {
29
+ /**
30
+ * 逻辑且
31
+ * @param conditions 多个条件,用逗号分隔
32
+ * @example
33
+ * ```
34
+ * context.db.object("_user").where(kunlun.operator.and({
35
+ * age: "22"
36
+ * },{
37
+ * gender: "male"
38
+ * }))
39
+ * ```
40
+ */
41
+ and(...conditions) {
42
+ if (conditions.length < 1) {
43
+ return null;
44
+ }
45
+ return (0, logic_1.buildLogic)(conditions, exports.operates.AND);
46
+ }
47
+ ;
48
+ /**
49
+ * 逻辑或
50
+ * @param conditions 多个条件,用逗号分隔
51
+ * @example
52
+ * ```
53
+ * context.db.object("_user").where(kunlun.operator.or({
54
+ * age: "22"
55
+ * },{
56
+ * age: "25"
57
+ * }))
58
+ * ```
59
+ */
60
+ or(...conditions) {
61
+ if (conditions.length < 1) {
62
+ return null;
63
+ }
64
+ return (0, logic_1.buildLogic)(conditions, exports.operates.OR);
65
+ }
66
+ ;
67
+ /**
68
+ * 包含
69
+ * @param value 判定是否包含的文本值
70
+ * @example
71
+ * ```
72
+ * context.db.object("_user").where({_name: kunlun.operator.contain("a")})
73
+ * ```
74
+ */
75
+ contain(value) {
76
+ return new logic_1.Condition(null, value, exports.operates.CONTAIN);
77
+ }
78
+ ;
79
+ /**
80
+ * 不包含
81
+ * @param value 判定是否不包含的文本值
82
+ * @example
83
+ * ```
84
+ * context.db.object("_user").where({_name: kunlun.operator.notContain("a")})
85
+ * ```
86
+ */
87
+ notContain(value) {
88
+ return new logic_1.Condition(null, value, exports.operates.NOT_CONTAIN);
89
+ }
90
+ ;
91
+ /**
92
+ * 无需入参,判断是否为空
93
+ * @example
94
+ * ```
95
+ * context.db.object("_user").where({employeeType: kunlun.operator.empty()})
96
+ * ```
97
+ */
98
+ empty() {
99
+ return new logic_1.Condition(null, null, exports.operates.EMTPY);
100
+ }
101
+ ;
102
+ /**
103
+ * 无需入参,判断是否为空
104
+ * @example
105
+ * ```
106
+ * context.db.object("_user").where({employeeType: kunlun.operator.notEmpty()})
107
+ * ```
108
+ */
109
+ notEmpty() {
110
+ return new logic_1.Condition(null, null, exports.operates.NOT_EMTPY);
111
+ }
112
+ ;
113
+ /**
114
+ * 等于
115
+ * @param value 判定是否相等的值
116
+ * @example
117
+ * ```
118
+ * context.db.object("_user").where({age: kunlun.operator.eq(20)})
119
+ * ```
120
+ */
121
+ eq(value) {
122
+ return new logic_1.Condition(null, value, exports.operates.EQ);
123
+ }
124
+ ;
125
+ /**
126
+ * 不等于
127
+ * @param value 判定是否不相等的值
128
+ * @example
129
+ * ```
130
+ * context.db.object("_user").where({age: kunlun.operator.neq(20)})
131
+ * ```
132
+ */
133
+ neq(value) {
134
+ return new logic_1.Condition(null, value, exports.operates.NEQ);
135
+ }
136
+ ;
137
+ /**
138
+ * 大于或晚于
139
+ * @param value 判定是否大于或晚于的值
140
+ * @example
141
+ * ```
142
+ * kunlun.operator.gt(new Date("2020-11-26").getTime())
143
+ * ```
144
+ */
145
+ gt(value) {
146
+ return new logic_1.Condition(null, value, exports.operates.GT);
147
+ }
148
+ ;
149
+ /**
150
+ * 大于等于或晚于等于
151
+ * @param value 判定是否大于等于或晚于等于的值
152
+ * @example
153
+ * ```
154
+ * kunlun.operator.gte(new Date("2020-11-26").getTime())
155
+ * ```
156
+ */
157
+ gte(value) {
158
+ return new logic_1.Condition(null, value, exports.operates.GTE);
159
+ }
160
+ ;
161
+ /**
162
+ * 小于或早于
163
+ * @param value 判定是否小于或早于的值
164
+ * @example
165
+ * ```
166
+ * kunlun.operator.lt(new Date("2020-11-26").getTime())
167
+ * ```
168
+ */
169
+ lt(value) {
170
+ return new logic_1.Condition(null, value, exports.operates.LT);
171
+ }
172
+ ;
173
+ /**
174
+ * 小于等于或早于等于
175
+ * @param value 判定是否小于等于或早于等于的值
176
+ * @example
177
+ * ```
178
+ * kunlun.operator.lte(new Date("2020-11-26").getTime())
179
+ * ```
180
+ */
181
+ lte(value) {
182
+ return new logic_1.Condition(null, value, exports.operates.LTE);
183
+ }
184
+ ;
185
+ in(value, ...restValues) {
186
+ value = !value ? [] : value;
187
+ const argList = server_common_node_1.utils.argsToList(value, restValues);
188
+ if (argList.length === 0) {
189
+ throw new server_common_node_1.exceptions.InvalidParamError("can not IN empty list");
190
+ }
191
+ return new logic_1.Condition(null, argList, exports.operates.IN);
192
+ }
193
+ ;
194
+ notIn(value, ...restValues) {
195
+ value = !value ? [] : value;
196
+ const argList = server_common_node_1.utils.argsToList(value, restValues);
197
+ if (argList.length === 0) {
198
+ throw new server_common_node_1.exceptions.InvalidParamError("can not NOT_IN empty list");
199
+ }
200
+ return new logic_1.Condition(null, argList, exports.operates.NIN);
201
+ }
202
+ ;
203
+ hasAnyOf(value, ...restValues) {
204
+ value = !value ? [] : value;
205
+ const argList = server_common_node_1.utils.argsToList(value, restValues);
206
+ if (argList.length === 0) {
207
+ throw new server_common_node_1.exceptions.InvalidParamError("can not HAS_ANY_OF empty list");
208
+ }
209
+ return new logic_1.Condition(null, argList, exports.operates.HAS_ANY_OF);
210
+ }
211
+ ;
212
+ hasNoneOf(value, ...restValues) {
213
+ value = !value ? [] : value;
214
+ const argList = server_common_node_1.utils.argsToList(value, restValues);
215
+ if (argList.length === 0) {
216
+ throw new server_common_node_1.exceptions.InvalidParamError("can not HAS_NONE_OF empty list");
217
+ }
218
+ return new logic_1.Condition(null, argList, exports.operates.HAS_NONE_OF);
219
+ }
220
+ ;
221
+ }
222
+ exports.Operator = Operator;
@@ -0,0 +1,258 @@
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 { IOperator } from "../IOperator";
6
+ import { exceptions, utils } from '@byted-apaas/server-common-node'
7
+ import { buildLogic, Condition } from './logic'
8
+ import { UserDataType } from './expression';
9
+
10
+ export const operates = {
11
+ AND: "and", // 逻辑与
12
+ OR: "or", // 逻辑或
13
+
14
+ EMTPY: "isEmpty", // 为空
15
+ NOT_EMTPY: "isNotEmpty", // 不为空
16
+
17
+ EQ: "equals", // 等于
18
+ NEQ: "notEquals", // 不等于
19
+ LT: "lessThan", // 小于
20
+ LTE: "lessThanOrEquals", // 小于或等于
21
+ GT: "greaterThan", // 大于
22
+ GTE: "greaterThanOrEquals", // 大于或等于
23
+
24
+ CONTAIN: "contains", // 包含
25
+ NOT_CONTAIN: "notContains", // 不包含
26
+
27
+ IN: "isAnyOf", // 在......列表内
28
+ NIN: "isNoneOf", // 不在......列表内
29
+
30
+ HAS_ANY_OF: "hasAnyOf", // 右值和左值有交集
31
+ HAS_NONE_OF: "hasNoneOf", // 右值和左值无交集
32
+
33
+ isOnOrBefore: "isOnOrBefore",
34
+ isOnOrAfter: "isOnOrAfter",
35
+ }
36
+
37
+ export class Operator<T> implements IOperator {
38
+ /**
39
+ * 逻辑且
40
+ * @param conditions 多个条件,用逗号分隔
41
+ * @example
42
+ * ```
43
+ * context.db.object("_user").where(kunlun.operator.and({
44
+ * age: "22"
45
+ * },{
46
+ * gender: "male"
47
+ * }))
48
+ * ```
49
+ */
50
+ and<T>(...conditions: (_Cond<T> | _BooleanCond<T>)[]): _LogicalCond<T> {
51
+ if (conditions.length < 1) {
52
+ return null;
53
+ }
54
+
55
+ return buildLogic(conditions, operates.AND);
56
+ };
57
+ /**
58
+ * 逻辑或
59
+ * @param conditions 多个条件,用逗号分隔
60
+ * @example
61
+ * ```
62
+ * context.db.object("_user").where(kunlun.operator.or({
63
+ * age: "22"
64
+ * },{
65
+ * age: "25"
66
+ * }))
67
+ * ```
68
+ */
69
+ or<T>(...conditions: (_Cond<T> | _BooleanCond<T>)[]): _LogicalCond<T> {
70
+ if (conditions.length < 1) {
71
+ return null;
72
+ }
73
+
74
+ return buildLogic(conditions, operates.OR);
75
+ };
76
+ /**
77
+ * 包含
78
+ * @param value 判定是否包含的文本值
79
+ * @example
80
+ * ```
81
+ * context.db.object("_user").where({_name: kunlun.operator.contain("a")})
82
+ * ```
83
+ */
84
+ contain<T>(value: UserDataType): _BooleanCond<T> {
85
+ return new Condition(null, value, operates.CONTAIN)
86
+ };
87
+ /**
88
+ * 不包含
89
+ * @param value 判定是否不包含的文本值
90
+ * @example
91
+ * ```
92
+ * context.db.object("_user").where({_name: kunlun.operator.notContain("a")})
93
+ * ```
94
+ */
95
+ notContain<T>(value: UserDataType): _BooleanCond<T> {
96
+ return new Condition(null, value, operates.NOT_CONTAIN)
97
+ };
98
+ /**
99
+ * 无需入参,判断是否为空
100
+ * @example
101
+ * ```
102
+ * context.db.object("_user").where({employeeType: kunlun.operator.empty()})
103
+ * ```
104
+ */
105
+ empty(): _BooleanCond<undefined> {
106
+ return new Condition(null, null, operates.EMTPY);
107
+ };
108
+ /**
109
+ * 无需入参,判断是否为空
110
+ * @example
111
+ * ```
112
+ * context.db.object("_user").where({employeeType: kunlun.operator.notEmpty()})
113
+ * ```
114
+ */
115
+ notEmpty(): _BooleanCond<undefined> {
116
+ return new Condition(null, null, operates.NOT_EMTPY);
117
+ };
118
+ /**
119
+ * 等于
120
+ * @param value 判定是否相等的值
121
+ * @example
122
+ * ```
123
+ * context.db.object("_user").where({age: kunlun.operator.eq(20)})
124
+ * ```
125
+ */
126
+ eq<T>(value: UserDataType): _BooleanCond<T> {
127
+ return new Condition(null, value, operates.EQ);
128
+ };
129
+ /**
130
+ * 不等于
131
+ * @param value 判定是否不相等的值
132
+ * @example
133
+ * ```
134
+ * context.db.object("_user").where({age: kunlun.operator.neq(20)})
135
+ * ```
136
+ */
137
+ neq<T>(value: UserDataType): _BooleanCond<T> {
138
+ return new Condition(null, value, operates.NEQ)
139
+ };
140
+ /**
141
+ * 大于或晚于
142
+ * @param value 判定是否大于或晚于的值
143
+ * @example
144
+ * ```
145
+ * kunlun.operator.gt(new Date("2020-11-26").getTime())
146
+ * ```
147
+ */
148
+ gt<T>(value: number | Date): _BooleanCond<T> {
149
+ return new Condition(null, value, operates.GT)
150
+ };
151
+ /**
152
+ * 大于等于或晚于等于
153
+ * @param value 判定是否大于等于或晚于等于的值
154
+ * @example
155
+ * ```
156
+ * kunlun.operator.gte(new Date("2020-11-26").getTime())
157
+ * ```
158
+ */
159
+ gte<T>(value: number | Date): _BooleanCond<T> {
160
+ return new Condition(null, value, operates.GTE)
161
+ };
162
+ /**
163
+ * 小于或早于
164
+ * @param value 判定是否小于或早于的值
165
+ * @example
166
+ * ```
167
+ * kunlun.operator.lt(new Date("2020-11-26").getTime())
168
+ * ```
169
+ */
170
+ lt<T>(value: number | Date): _BooleanCond<T> {
171
+ return new Condition(null, value, operates.LT)
172
+ };
173
+ /**
174
+ * 小于等于或早于等于
175
+ * @param value 判定是否小于等于或早于等于的值
176
+ * @example
177
+ * ```
178
+ * kunlun.operator.lte(new Date("2020-11-26").getTime())
179
+ * ```
180
+ */
181
+ lte<T>(value: number | Date): _BooleanCond<T> {
182
+ return new Condition(null, value, operates.LTE)
183
+ };
184
+ /**
185
+ * 存在于给定的数组内
186
+ * @param values 判定是否存在于的一组值,用数组传递
187
+ */
188
+ in<T>(values: T[]): _BooleanCond<T>;
189
+ /**
190
+ * 存在于给定的数组内
191
+ * @param values 判定是否存在于的一组值,用逗号分隔
192
+ */
193
+ in<T>(...values: T[]): _BooleanCond<T>;
194
+ in<T>(value: T | T[], ...restValues: T[]): _BooleanCond<T> {
195
+ value = !value ? [] : value;
196
+ const argList = utils.argsToList(value, restValues);
197
+ if (argList.length === 0) {
198
+ throw new exceptions.InvalidParamError("can not IN empty list");
199
+ }
200
+ return new Condition(null, argList, operates.IN)
201
+ };
202
+ /**
203
+ * 不存在于给定的数组内
204
+ * @param values 判定是否不存在于的一组值,用数组传递
205
+ */
206
+ notIn<T>(values: T[]): _BooleanCond<T>;
207
+ /**
208
+ * 不存在于给定的数组内
209
+ * @param values 判定是否不存在于的一组值,用逗号分隔
210
+ */
211
+ notIn<T>(...values: T[]): _BooleanCond<T>;
212
+ notIn<T>(value: T | T[], ...restValues: T[]): _BooleanCond<T> {
213
+ value = !value ? [] : value;
214
+ const argList = utils.argsToList(value, restValues);
215
+ if (argList.length === 0) {
216
+ throw new exceptions.InvalidParamError("can not NOT_IN empty list");
217
+ }
218
+ return new Condition(null, argList, operates.NIN)
219
+ };
220
+
221
+ /**
222
+ * 存在给定的多个值中的任何一个值
223
+ * @param values 判定是否不存在于的一组值,用逗号分隔
224
+ */
225
+ hasAnyOf<T>(values: number[] | string[]): _BooleanCond<T>;
226
+ /**
227
+ * 存在给定的多个值中的任何一个值
228
+ * @param values 判定是否不存在于的一组值,用逗号分隔
229
+ */
230
+ hasAnyOf<T>(...values: (number | string)[]): _BooleanCond<T>;
231
+ hasAnyOf<T>(value: (number | string) | (number | string)[], ...restValues: (number | string)[]): _BooleanCond<T> {
232
+ value = !value ? [] : value;
233
+ const argList = utils.argsToList(value, restValues);
234
+ if (argList.length === 0) {
235
+ throw new exceptions.InvalidParamError("can not HAS_ANY_OF empty list");
236
+ }
237
+ return new Condition(null, argList, operates.HAS_ANY_OF)
238
+ };
239
+ /**
240
+ * 不存在给定的多个值中的任何值
241
+ * @param values 判定是否不存在于的一组值,用逗号分隔
242
+ */
243
+ hasNoneOf<T>(values: number[] | string[]): _BooleanCond<T>;
244
+
245
+ /**
246
+ * 不存在给定的多个值中的任何值
247
+ * @param values 判定是否不存在于的一组值,用逗号分隔
248
+ */
249
+ hasNoneOf<T>(...values: (number | string)[]): _BooleanCond<T>;
250
+ hasNoneOf<T>(value: (number | string) | (number | string)[], ...restValues: (number | string)[]): _BooleanCond<T> {
251
+ value = !value ? [] : value;
252
+ const argList = utils.argsToList(value, restValues);
253
+ if (argList.length === 0) {
254
+ throw new exceptions.InvalidParamError("can not HAS_NONE_OF empty list");
255
+ }
256
+ return new Condition(null, argList, operates.HAS_NONE_OF)
257
+ };
258
+ }
@@ -0,0 +1,180 @@
1
+ import { _Cond, _BooleanCond } from '../../../types/types';
2
+ import { IOperator } from "../IOperator";
3
+ import { LogicalExpression } from './logicV2';
4
+ import { UserDataType } from './expression';
5
+ export declare const operates: {
6
+ AND: string;
7
+ OR: string;
8
+ EMPTY: string;
9
+ NOT_EMPTY: string;
10
+ EQ: string;
11
+ NEQ: string;
12
+ LT: string;
13
+ LTE: string;
14
+ GT: string;
15
+ GTE: string;
16
+ CONTAIN: string;
17
+ NOT_CONTAIN: string;
18
+ IN: string;
19
+ NIN: string;
20
+ HAS_ANY_OF: string;
21
+ HAS_NONE_OF: string;
22
+ isOnOrBefore: string;
23
+ isOnOrAfter: string;
24
+ };
25
+ export declare class OperatorV2<T> implements IOperator {
26
+ /**
27
+ * 逻辑且
28
+ * @param conditions 多个条件,用逗号分隔
29
+ * @example
30
+ * ```
31
+ * context.db.object("_user").where(kunlun.operator.and({
32
+ * age: "22"
33
+ * },{
34
+ * gender: "male"
35
+ * }))
36
+ * ```
37
+ */
38
+ and<T>(...exps: (_Cond<T> | _BooleanCond<T> | LogicalExpression)[]): LogicalExpression;
39
+ /**
40
+ * 逻辑或
41
+ * @param conditions 多个条件,用逗号分隔
42
+ * @example
43
+ * ```
44
+ * context.db.object("_user").where(kunlun.operator.or({
45
+ * age: "22"
46
+ * },{
47
+ * age: "25"
48
+ * }))
49
+ * ```
50
+ */
51
+ or<T>(...exps: (_Cond<T> | _BooleanCond<T> | LogicalExpression)[]): LogicalExpression;
52
+ /**
53
+ * 包含
54
+ * @param value 判定是否包含的文本值
55
+ * @example
56
+ * ```
57
+ * context.db.object("_user").where({_name: kunlun.operator.contain("a")})
58
+ * ```
59
+ */
60
+ contain<T>(value: UserDataType): _BooleanCond<T>;
61
+ /**
62
+ * 不包含
63
+ * @param value 判定是否不包含的文本值
64
+ * @example
65
+ * ```
66
+ * context.db.object("_user").where({_name: kunlun.operator.notContain("a")})
67
+ * ```
68
+ */
69
+ notContain<T>(value: UserDataType): _BooleanCond<T>;
70
+ /**
71
+ * 无需入参,判断是否为空
72
+ * @example
73
+ * ```
74
+ * context.db.object("_user").where({employeeType: kunlun.operator.empty()})
75
+ * ```
76
+ */
77
+ empty(): _BooleanCond<undefined>;
78
+ /**
79
+ * 无需入参,判断是否为空
80
+ * @example
81
+ * ```
82
+ * context.db.object("_user").where({employeeType: kunlun.operator.notEmpty()})
83
+ * ```
84
+ */
85
+ notEmpty(): _BooleanCond<undefined>;
86
+ /**
87
+ * 等于
88
+ * @param value 判定是否相等的值
89
+ * @example
90
+ * ```
91
+ * context.db.object("_user").where({age: kunlun.operator.eq(20)})
92
+ * ```
93
+ */
94
+ eq<T>(value: UserDataType): _BooleanCond<T>;
95
+ /**
96
+ * 不等于
97
+ * @param value 判定是否不相等的值
98
+ * @example
99
+ * ```
100
+ * context.db.object("_user").where({age: kunlun.operator.neq(20)})
101
+ * ```
102
+ */
103
+ neq<T>(value: UserDataType): _BooleanCond<T>;
104
+ /**
105
+ * 大于或晚于
106
+ * @param value 判定是否大于或晚于的值
107
+ * @example
108
+ * ```
109
+ * kunlun.operator.gt(new Date("2020-11-26").getTime())
110
+ * ```
111
+ */
112
+ gt<T>(value: number | Date): _BooleanCond<T>;
113
+ /**
114
+ * 大于等于或晚于等于
115
+ * @param value 判定是否大于等于或晚于等于的值
116
+ * @example
117
+ * ```
118
+ * kunlun.operator.gte(new Date("2020-11-26").getTime())
119
+ * ```
120
+ */
121
+ gte<T>(value: number | Date): _BooleanCond<T>;
122
+ /**
123
+ * 小于或早于
124
+ * @param value 判定是否小于或早于的值
125
+ * @example
126
+ * ```
127
+ * kunlun.operator.lt(new Date("2020-11-26").getTime())
128
+ * ```
129
+ */
130
+ lt<T>(value: number | Date): _BooleanCond<T>;
131
+ /**
132
+ * 小于等于或早于等于
133
+ * @param value 判定是否小于等于或早于等于的值
134
+ * @example
135
+ * ```
136
+ * kunlun.operator.lte(new Date("2020-11-26").getTime())
137
+ * ```
138
+ */
139
+ lte<T>(value: number | Date): _BooleanCond<T>;
140
+ /**
141
+ * 存在于给定的数组内
142
+ * @param values 判定是否存在于的一组值,用数组传递
143
+ */
144
+ in<T>(values: T[]): _BooleanCond<T>;
145
+ /**
146
+ * 存在于给定的数组内
147
+ * @param values 判定是否存在于的一组值,用逗号分隔
148
+ */
149
+ in<T>(...values: T[]): _BooleanCond<T>;
150
+ /**
151
+ * 不存在于给定的数组内
152
+ * @param values 判定是否不存在于的一组值,用数组传递
153
+ */
154
+ notIn<T>(values: T[]): _BooleanCond<T>;
155
+ /**
156
+ * 不存在于给定的数组内
157
+ * @param values 判定是否不存在于的一组值,用逗号分隔
158
+ */
159
+ notIn<T>(...values: T[]): _BooleanCond<T>;
160
+ /**
161
+ * 存在给定的多个值中的任何一个值
162
+ * @param values 判定是否不存在于的一组值,用逗号分隔
163
+ */
164
+ hasAnyOf<T>(values: number[] | string[]): _BooleanCond<T>;
165
+ /**
166
+ * 存在给定的多个值中的任何一个值
167
+ * @param values 判定是否不存在于的一组值,用逗号分隔
168
+ */
169
+ hasAnyOf<T>(...values: (number | string)[]): _BooleanCond<T>;
170
+ /**
171
+ * 不存在给定的多个值中的任何值
172
+ * @param values 判定是否不存在于的一组值,用逗号分隔
173
+ */
174
+ hasNoneOf<T>(values: number[] | string[]): _BooleanCond<T>;
175
+ /**
176
+ * 不存在给定的多个值中的任何值
177
+ * @param values 判定是否不存在于的一组值,用逗号分隔
178
+ */
179
+ hasNoneOf<T>(...values: (number | string)[]): _BooleanCond<T>;
180
+ }