@byted-apaas/server-sdk-node 0.0.2-beta.1

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 (215) hide show
  1. package/LICENSE.md +0 -0
  2. package/README.md +1 -0
  3. package/application/application.d.ts +27 -0
  4. package/application/application.js +3 -0
  5. package/application/application.js.map +1 -0
  6. package/application/application.ts +40 -0
  7. package/application/function/function.d.ts +14 -0
  8. package/application/function/function.js +22 -0
  9. package/application/function/function.js.map +1 -0
  10. package/application/function/function.ts +37 -0
  11. package/application/impl/common.d.ts +2 -0
  12. package/application/impl/common.js +51 -0
  13. package/application/impl/common.js.map +1 -0
  14. package/application/impl/common.ts +50 -0
  15. package/application/impl/impl.d.ts +16 -0
  16. package/application/impl/impl.js +39 -0
  17. package/application/impl/impl.js.map +1 -0
  18. package/application/impl/impl.ts +48 -0
  19. package/constants/constants.d.ts +10 -0
  20. package/constants/constants.js +14 -0
  21. package/constants/constants.js.map +1 -0
  22. package/constants/constants.ts +12 -0
  23. package/context/context.d.ts +74 -0
  24. package/context/context.js +24 -0
  25. package/context/context.js.map +1 -0
  26. package/context/context.ts +127 -0
  27. package/context/db/db.d.ts +73 -0
  28. package/context/db/db.js +3 -0
  29. package/context/db/db.js.map +1 -0
  30. package/context/db/db.ts +77 -0
  31. package/context/db/impl/IObject.d.ts +251 -0
  32. package/context/db/impl/IObject.js +4 -0
  33. package/context/db/impl/IObject.js.map +1 -0
  34. package/context/db/impl/IObject.ts +244 -0
  35. package/context/db/impl/db.d.ts +61 -0
  36. package/context/db/impl/db.js +87 -0
  37. package/context/db/impl/db.js.map +1 -0
  38. package/context/db/impl/db.ts +95 -0
  39. package/context/db/impl/object.d.ts +92 -0
  40. package/context/db/impl/object.js +523 -0
  41. package/context/db/impl/object.js.map +1 -0
  42. package/context/db/impl/object.ts +628 -0
  43. package/context/db/impl/oql/ioql.d.ts +6 -0
  44. package/context/db/impl/oql/ioql.js +3 -0
  45. package/context/db/impl/oql/ioql.js.map +1 -0
  46. package/context/db/impl/oql/ioql.ts +6 -0
  47. package/context/db/impl/oql/oql.d.ts +8 -0
  48. package/context/db/impl/oql/oql.js +20 -0
  49. package/context/db/impl/oql/oql.js.map +1 -0
  50. package/context/db/impl/oql/oql.ts +22 -0
  51. package/context/db/impl/order.d.ts +9 -0
  52. package/context/db/impl/order.js +14 -0
  53. package/context/db/impl/order.js.map +1 -0
  54. package/context/db/impl/order.ts +16 -0
  55. package/context/db/impl/propertiesStore.d.ts +8 -0
  56. package/context/db/impl/propertiesStore.js +28 -0
  57. package/context/db/impl/propertiesStore.js.map +1 -0
  58. package/context/db/impl/propertiesStore.ts +28 -0
  59. package/context/db/impl/queryBuilder.d.ts +29 -0
  60. package/context/db/impl/queryBuilder.js +77 -0
  61. package/context/db/impl/queryBuilder.js.map +1 -0
  62. package/context/db/impl/queryBuilder.ts +103 -0
  63. package/context/db/impl/transaction/index.d.ts +20 -0
  64. package/context/db/impl/transaction/index.js +276 -0
  65. package/context/db/impl/transaction/index.js.map +1 -0
  66. package/context/db/impl/transaction/index.ts +337 -0
  67. package/context/db/impl/transaction/operation.d.ts +27 -0
  68. package/context/db/impl/transaction/operation.js +70 -0
  69. package/context/db/impl/transaction/operation.js.map +1 -0
  70. package/context/db/impl/transaction/operation.ts +72 -0
  71. package/context/db/impl/transaction.d.ts +67 -0
  72. package/context/db/impl/transaction.js +3 -0
  73. package/context/db/impl/transaction.js.map +1 -0
  74. package/context/db/impl/transaction.ts +76 -0
  75. package/context/globalConfig/globalConfig.d.ts +7 -0
  76. package/context/globalConfig/globalConfig.js +15 -0
  77. package/context/globalConfig/globalConfig.js.map +1 -0
  78. package/context/globalConfig/globalConfig.ts +11 -0
  79. package/context/metadata/components/common.d.ts +6 -0
  80. package/context/metadata/components/common.js +16 -0
  81. package/context/metadata/components/common.js.map +1 -0
  82. package/context/metadata/components/common.ts +19 -0
  83. package/context/metadata/components/components.d.ts +12 -0
  84. package/context/metadata/components/components.js +18 -0
  85. package/context/metadata/components/components.js.map +1 -0
  86. package/context/metadata/components/components.ts +19 -0
  87. package/context/metadata/components/desktop/list.d.ts +16 -0
  88. package/context/metadata/components/desktop/list.js +403 -0
  89. package/context/metadata/components/desktop/list.js.map +1 -0
  90. package/context/metadata/components/desktop/list.ts +457 -0
  91. package/context/metadata/components/desktop/recordDetail.d.ts +11 -0
  92. package/context/metadata/components/desktop/recordDetail.js +52 -0
  93. package/context/metadata/components/desktop/recordDetail.js.map +1 -0
  94. package/context/metadata/components/desktop/recordDetail.ts +64 -0
  95. package/context/metadata/components/mobile/list.d.ts +24 -0
  96. package/context/metadata/components/mobile/list.js +144 -0
  97. package/context/metadata/components/mobile/list.js.map +1 -0
  98. package/context/metadata/components/mobile/list.ts +176 -0
  99. package/context/metadata/metadata.d.ts +61 -0
  100. package/context/metadata/metadata.js +102 -0
  101. package/context/metadata/metadata.js.map +1 -0
  102. package/context/metadata/metadata.ts +175 -0
  103. package/context/metadata/objects/fields.d.ts +130 -0
  104. package/context/metadata/objects/fields.js +333 -0
  105. package/context/metadata/objects/fields.js.map +1 -0
  106. package/context/metadata/objects/fields.ts +454 -0
  107. package/context/metadata/objects/fields.util.d.ts +40 -0
  108. package/context/metadata/objects/fields.util.js +320 -0
  109. package/context/metadata/objects/fields.util.js.map +1 -0
  110. package/context/metadata/objects/fields.util.ts +360 -0
  111. package/context/metadata/objects/objects.d.ts +11 -0
  112. package/context/metadata/objects/objects.js +19 -0
  113. package/context/metadata/objects/objects.js.map +1 -0
  114. package/context/metadata/objects/objects.ts +27 -0
  115. package/context/metadata/types/common.d.ts +6 -0
  116. package/context/metadata/types/common.js +8 -0
  117. package/context/metadata/types/common.js.map +1 -0
  118. package/context/metadata/types/common.ts +10 -0
  119. package/context/metadata/types/components.d.ts +90 -0
  120. package/context/metadata/types/components.js +3 -0
  121. package/context/metadata/types/components.js.map +1 -0
  122. package/context/metadata/types/components.ts +105 -0
  123. package/context/metadata/types/objects.d.ts +226 -0
  124. package/context/metadata/types/objects.js +3 -0
  125. package/context/metadata/types/objects.js.map +1 -0
  126. package/context/metadata/types/objects.ts +251 -0
  127. package/context/msg/msg.d.ts +38 -0
  128. package/context/msg/msg.js +34 -0
  129. package/context/msg/msg.js.map +1 -0
  130. package/context/msg/msg.ts +49 -0
  131. package/context/resources/IResources.d.ts +66 -0
  132. package/context/resources/IResources.js +3 -0
  133. package/context/resources/IResources.js.map +1 -0
  134. package/context/resources/IResources.ts +73 -0
  135. package/context/resources/impl/resources.d.ts +42 -0
  136. package/context/resources/impl/resources.js +149 -0
  137. package/context/resources/impl/resources.js.map +1 -0
  138. package/context/resources/impl/resources.ts +170 -0
  139. package/context/tasks/tasks.d.ts +33 -0
  140. package/context/tasks/tasks.js +140 -0
  141. package/context/tasks/tasks.js.map +1 -0
  142. package/context/tasks/tasks.ts +159 -0
  143. package/data/index.d.ts +27 -0
  144. package/data/index.js +5 -0
  145. package/data/index.js.map +1 -0
  146. package/data/index.ts +30 -0
  147. package/hooks/api.d.ts +61 -0
  148. package/hooks/api.js +328 -0
  149. package/hooks/api.js.map +1 -0
  150. package/hooks/api.ts +341 -0
  151. package/hooks/hooks.d.ts +1 -0
  152. package/hooks/hooks.js +89 -0
  153. package/hooks/hooks.js.map +1 -0
  154. package/hooks/hooks.ts +100 -0
  155. package/kunlun/kunlun.d.ts +55 -0
  156. package/kunlun/kunlun.js +57 -0
  157. package/kunlun/kunlun.js.map +1 -0
  158. package/kunlun/kunlun.ts +69 -0
  159. package/kunlun/operator/IOperator.d.ts +158 -0
  160. package/kunlun/operator/IOperator.js +3 -0
  161. package/kunlun/operator/IOperator.js.map +1 -0
  162. package/kunlun/operator/IOperator.ts +163 -0
  163. package/kunlun/operator/impl/expression.d.ts +47 -0
  164. package/kunlun/operator/impl/expression.js +55 -0
  165. package/kunlun/operator/impl/expression.js.map +1 -0
  166. package/kunlun/operator/impl/expression.ts +71 -0
  167. package/kunlun/operator/impl/logic.d.ts +50 -0
  168. package/kunlun/operator/impl/logic.js +508 -0
  169. package/kunlun/operator/impl/logic.js.map +1 -0
  170. package/kunlun/operator/impl/logic.ts +595 -0
  171. package/kunlun/operator/impl/logicV2.d.ts +58 -0
  172. package/kunlun/operator/impl/logicV2.js +201 -0
  173. package/kunlun/operator/impl/logicV2.js.map +1 -0
  174. package/kunlun/operator/impl/logicV2.ts +254 -0
  175. package/kunlun/operator/impl/operator.d.ts +179 -0
  176. package/kunlun/operator/impl/operator.js +221 -0
  177. package/kunlun/operator/impl/operator.js.map +1 -0
  178. package/kunlun/operator/impl/operator.ts +255 -0
  179. package/kunlun/operator/impl/operatorV2.d.ts +180 -0
  180. package/kunlun/operator/impl/operatorV2.js +217 -0
  181. package/kunlun/operator/impl/operatorV2.js.map +1 -0
  182. package/kunlun/operator/impl/operatorV2.ts +249 -0
  183. package/lib/core.d.ts +4 -0
  184. package/lib/core.js +18 -0
  185. package/lib/core.js.map +1 -0
  186. package/lib/core.ts +4 -0
  187. package/package.json +50 -0
  188. package/request/common.d.ts +13 -0
  189. package/request/common.js +88 -0
  190. package/request/common.js.map +1 -0
  191. package/request/common.ts +91 -0
  192. package/request/constants.d.ts +10 -0
  193. package/request/constants.js +26 -0
  194. package/request/constants.js.map +1 -0
  195. package/request/constants.ts +25 -0
  196. package/request/faasinfra.d.ts +8 -0
  197. package/request/faasinfra.js +359 -0
  198. package/request/faasinfra.js.map +1 -0
  199. package/request/faasinfra.ts +393 -0
  200. package/request/innerapi.d.ts +67 -0
  201. package/request/innerapi.js +1411 -0
  202. package/request/innerapi.js.map +1 -0
  203. package/request/innerapi.ts +1645 -0
  204. package/request/interface.d.ts +95 -0
  205. package/request/interface.js +40 -0
  206. package/request/interface.js.map +1 -0
  207. package/request/interface.ts +166 -0
  208. package/request/openapi.d.ts +69 -0
  209. package/request/openapi.js +1013 -0
  210. package/request/openapi.js.map +1 -0
  211. package/request/openapi.ts +1220 -0
  212. package/types/types.d.ts +79 -0
  213. package/types/types.js +3 -0
  214. package/types/types.js.map +1 -0
  215. package/types/types.ts +105 -0
@@ -0,0 +1,201 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildCriterionV2 = exports.logical = exports.QueryV2 = exports.LogicalExpression = exports.ArithmeticExpression = exports.NewConstantExpressionField = exports.NewMetadataExpressionField = void 0;
4
+ const operator_1 = require("./operator");
5
+ function NewMetadataExpressionField(objectApiName, fieldApiName) {
6
+ return {
7
+ type: "metadataVariable",
8
+ settings: {
9
+ fieldPath: [{
10
+ objectApiName: objectApiName,
11
+ fieldApiName: fieldApiName,
12
+ extendLogicTags: []
13
+ }]
14
+ }
15
+ };
16
+ }
17
+ exports.NewMetadataExpressionField = NewMetadataExpressionField;
18
+ function NewConstantExpressionField(data) {
19
+ return {
20
+ type: "constant",
21
+ settings: {
22
+ data: data
23
+ }
24
+ };
25
+ }
26
+ exports.NewConstantExpressionField = NewConstantExpressionField;
27
+ class ArithmeticExpression {
28
+ constructor(leftValue, op, rightValue) {
29
+ let fieldPaths = [];
30
+ leftValue.split('.').forEach((fieldApiName) => {
31
+ fieldPaths.push({
32
+ fieldApiName: fieldApiName,
33
+ objectApiName: "",
34
+ extendLogicTags: []
35
+ });
36
+ });
37
+ const left = {
38
+ type: "metadataVariable",
39
+ settings: {
40
+ fieldPath: fieldPaths,
41
+ data: null
42
+ }
43
+ };
44
+ let right = {
45
+ type: "constant",
46
+ settings: {
47
+ fieldPath: [],
48
+ data: rightValue
49
+ }
50
+ };
51
+ if (op == "isEmpty" || op == "isNotEmpty") {
52
+ right = null;
53
+ }
54
+ this.operator = op;
55
+ this.left = left;
56
+ this.right = right;
57
+ this.expr = {
58
+ leftValue: leftValue,
59
+ operator: op,
60
+ rightValue: rightValue
61
+ };
62
+ }
63
+ }
64
+ exports.ArithmeticExpression = ArithmeticExpression;
65
+ ;
66
+ class LogicalExpression {
67
+ constructor(logicType, expressions, logics) {
68
+ this.type = logicType;
69
+ this.arithmeticExpressions = expressions;
70
+ this.logicalExpressions = logics;
71
+ }
72
+ }
73
+ exports.LogicalExpression = LogicalExpression;
74
+ class QueryV2 {
75
+ constructor(objectApiName) {
76
+ this.objectApiName = objectApiName;
77
+ this._limit = 200;
78
+ this._offset = 0;
79
+ this.fields = [];
80
+ this._order = [];
81
+ this.filter = {
82
+ type: "and",
83
+ arithmeticExpressions: null,
84
+ logicalExpressions: null,
85
+ };
86
+ }
87
+ buildCriterion(filter) {
88
+ if (!filter || filter.arithmeticExpressions.length == 0 && filter.logicalExpressions.length == 0) {
89
+ return null;
90
+ }
91
+ var conditions = [];
92
+ filter.logicalExpressions.forEach((logicalExpression) => {
93
+ conditions.push({
94
+ [logicalExpression.type]: this.buildCriterion(logicalExpression),
95
+ });
96
+ });
97
+ filter.arithmeticExpressions.forEach((arithmeticExpression) => {
98
+ conditions.push(arithmeticExpression.expr);
99
+ });
100
+ return conditions;
101
+ }
102
+ where(condition) {
103
+ if (!condition) {
104
+ return this;
105
+ }
106
+ const { logicalExps, arithmeticExps } = logical([condition]);
107
+ logicalExps.forEach((logicalExpression) => {
108
+ if (this.filter) {
109
+ this.filter.logicalExpressions.push(logicalExpression);
110
+ }
111
+ });
112
+ const logicalExpBuiltByArithmeticExps = new LogicalExpression(operator_1.operates.AND, arithmeticExps, []);
113
+ this.filter.logicalExpressions.push(logicalExpBuiltByArithmeticExps);
114
+ return this;
115
+ }
116
+ offset(offset) {
117
+ if (offset < 0) {
118
+ throw new Error("offset must be greater than or equal to 0");
119
+ }
120
+ this._offset = offset;
121
+ return this;
122
+ }
123
+ limit(limit) {
124
+ if (limit <= 0 || limit > 200) {
125
+ throw new Error("limit must be greater than 0 and less than or equal to 200");
126
+ }
127
+ this._limit = limit;
128
+ return this;
129
+ }
130
+ orderBy(fieldApiNames) {
131
+ fieldApiNames.forEach((fieldApiName) => {
132
+ this._order.push({
133
+ field: fieldApiName,
134
+ direction: "asc",
135
+ type: "",
136
+ });
137
+ });
138
+ return this;
139
+ }
140
+ orderByDesc(fieldApiNames) {
141
+ fieldApiNames.forEach((fieldApiName) => {
142
+ this._order.push({
143
+ field: fieldApiName,
144
+ direction: "desc",
145
+ type: "",
146
+ });
147
+ });
148
+ return this;
149
+ }
150
+ select(fieldApiNames) {
151
+ fieldApiNames.forEach((fieldApiName) => {
152
+ this.fields.push(fieldApiName);
153
+ });
154
+ return this;
155
+ }
156
+ }
157
+ exports.QueryV2 = QueryV2;
158
+ function logical(exps) {
159
+ if (!exps || exps.length == 0) {
160
+ return null;
161
+ }
162
+ var logicalExps = [];
163
+ var arithmeticExps = [];
164
+ exps.forEach((exp) => {
165
+ if (!exp) {
166
+ return;
167
+ }
168
+ if (exp instanceof LogicalExpression) {
169
+ logicalExps.push(exp);
170
+ }
171
+ else {
172
+ for (var key in exp) {
173
+ if (exp[key]) {
174
+ arithmeticExps.push(new ArithmeticExpression(key, exp[key].operator, exp[key].right));
175
+ }
176
+ }
177
+ }
178
+ });
179
+ return {
180
+ logicalExps: logicalExps,
181
+ arithmeticExps: arithmeticExps,
182
+ };
183
+ }
184
+ exports.logical = logical;
185
+ function buildCriterionV2(filter) {
186
+ if (!filter || filter.logicalExpressions.length == 0 && filter.arithmeticExpressions.length == 0) {
187
+ return null;
188
+ }
189
+ var conditions = [];
190
+ filter.logicalExpressions.forEach((logicalExp) => {
191
+ conditions.push({
192
+ [logicalExp.type]: buildCriterionV2(logicalExp),
193
+ });
194
+ });
195
+ filter.arithmeticExpressions.forEach((arithmeticExp) => {
196
+ conditions.push(arithmeticExp.expr);
197
+ });
198
+ return conditions;
199
+ }
200
+ exports.buildCriterionV2 = buildCriterionV2;
201
+ //# sourceMappingURL=logicV2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logicV2.js","sourceRoot":"","sources":["logicV2.ts"],"names":[],"mappings":";;;AAEA,yCAAsC;AAkBtC,SAAgB,0BAA0B,CAAC,aAAqB,EAAE,YAAoB;IAClF,OAAO;QACH,IAAI,EAAE,kBAAkB;QACxB,QAAQ,EAAE;YACN,SAAS,EAAE,CAAC;oBAC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;aACJ;SACJ;IACL,CAAC,CAAC,CAAC;IACH,OAAO;QACH,WAAW,EAAE,WAAW;QACxB,cAAc,EAAE,cAAc;KACjC,CAAA;AACL,CAAC;AAxBD,0BAwBC;AAID,SAAgB,gBAAgB,CAAC,MAAyB;IACtD,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,kBAAkB,CAAC,MAAM,IAAI,CAAC,IAAI,MAAM,CAAC,qBAAqB,CAAC,MAAM,IAAI,CAAC,EAAE;QAC9F,OAAO,IAAI,CAAC;KACf;IACD,IAAI,UAAU,GAAU,EAAE,CAAC;IAC3B,MAAM,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;QAC7C,UAAU,CAAC,IAAI,CAAC;YACZ,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,gBAAgB,CAAC,UAAU,CAAC;SAClD,CAAC,CAAA;IACN,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,EAAE;QACnD,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;IACH,OAAO,UAAU,CAAC;AACtB,CAAC;AAdD,4CAcC"}
@@ -0,0 +1,254 @@
1
+ import { OrderV2 } from "../../../request/interface";
2
+ import { UserDataType } from "./expression";
3
+ import { operates } from "./operator";
4
+
5
+ export type FieldPath = {
6
+ objectApiName: string;
7
+ fieldApiName: string;
8
+ extendLogicTags: string[];
9
+ }
10
+
11
+ export type SettingType = {
12
+ data?: any;
13
+ fieldPath?: FieldPath[];
14
+ }
15
+
16
+ export type Expression = {
17
+ type: string;
18
+ settings: SettingType;
19
+ }
20
+
21
+ export function NewMetadataExpressionField(objectApiName: string, fieldApiName: string): Expression {
22
+ return {
23
+ type: "metadataVariable",
24
+ settings: {
25
+ fieldPath: [{
26
+ objectApiName: objectApiName,
27
+ fieldApiName: fieldApiName,
28
+ extendLogicTags: []
29
+ }]
30
+ }
31
+ }
32
+ }
33
+
34
+ export function NewConstantExpressionField(data: UserDataType): Expression {
35
+ return {
36
+ type: "constant",
37
+ settings: {
38
+ data: data
39
+ }
40
+ }
41
+ }
42
+
43
+ export type ExpressionV2 = {
44
+ leftValue: string;
45
+ operator: string;
46
+ rightValue: any;
47
+ }
48
+
49
+ export class ArithmeticExpression {
50
+ left: Expression;
51
+ operator: string;
52
+ right: Expression;
53
+ expr: ExpressionV2;
54
+
55
+ constructor(leftValue: string, op: string, rightValue: any) {
56
+ let fieldPaths: FieldPath[] = [];
57
+ leftValue.split('.').forEach((fieldApiName) => {
58
+ fieldPaths.push({
59
+ fieldApiName: fieldApiName,
60
+ objectApiName: "",
61
+ extendLogicTags: []
62
+ });
63
+ })
64
+ const left: Expression = {
65
+ type: "metadataVariable",
66
+ settings: {
67
+ fieldPath: fieldPaths,
68
+ data: null
69
+ }
70
+ };
71
+ let right: Expression = {
72
+ type: "constant",
73
+ settings: {
74
+ fieldPath: [],
75
+ data: rightValue
76
+ }
77
+ };
78
+ if (op == "isEmpty" || op == "isNotEmpty") {
79
+ right = null;
80
+ }
81
+ this.operator = op;
82
+ this.left = left;
83
+ this.right = right;
84
+ this.expr = {
85
+ leftValue: leftValue,
86
+ operator: op,
87
+ rightValue: rightValue
88
+ }
89
+ }
90
+ };
91
+
92
+
93
+ export class LogicalExpression {
94
+ type: string;
95
+ arithmeticExpressions: ArithmeticExpression[];
96
+ logicalExpressions: LogicalExpression[];
97
+
98
+ constructor(logicType: string, expressions: ArithmeticExpression[], logics: LogicalExpression[]) {
99
+ this.type = logicType;
100
+ this.arithmeticExpressions = expressions;
101
+ this.logicalExpressions = logics;
102
+ }
103
+ }
104
+
105
+ export class QueryV2 {
106
+ objectApiName: string;
107
+ _limit: number;
108
+ _offset: number;
109
+ fields: string[];
110
+ _order: OrderV2[];
111
+ filter: LogicalExpression;
112
+
113
+ buildCriterion(filter: LogicalExpression): any[] {
114
+ if (!filter || filter.arithmeticExpressions.length == 0 && filter.logicalExpressions.length == 0) {
115
+ return null;
116
+ }
117
+ var conditions: any[] = [];
118
+
119
+ filter.logicalExpressions.forEach((logicalExpression) => {
120
+ conditions.push({
121
+ [logicalExpression.type]: this.buildCriterion(logicalExpression),
122
+ });
123
+ })
124
+
125
+ filter.arithmeticExpressions.forEach((arithmeticExpression) => {
126
+ conditions.push(arithmeticExpression.expr);
127
+ });
128
+ return conditions;
129
+ }
130
+
131
+ where(condition: LogicalExpression | Record<string, ArithmeticExpression>): QueryV2 {
132
+ if (!condition) {
133
+ return this;
134
+ }
135
+
136
+ const { logicalExps, arithmeticExps } = logical([condition]);
137
+ logicalExps.forEach((logicalExpression) => {
138
+ if (this.filter) {
139
+ this.filter.logicalExpressions.push(logicalExpression);
140
+ }
141
+ });
142
+ const logicalExpBuiltByArithmeticExps = new LogicalExpression(operates.AND, arithmeticExps, []);
143
+ this.filter.logicalExpressions.push(logicalExpBuiltByArithmeticExps);
144
+
145
+ return this;
146
+ }
147
+
148
+ offset(offset: number): QueryV2 {
149
+ if (offset < 0) {
150
+ throw new Error("offset must be greater than or equal to 0");
151
+ }
152
+ this._offset = offset;
153
+ return this;
154
+ }
155
+
156
+ limit(limit: number): QueryV2 {
157
+ if (limit <= 0 || limit > 200) {
158
+ throw new Error("limit must be greater than 0 and less than or equal to 200");
159
+ }
160
+ this._limit = limit;
161
+ return this;
162
+ }
163
+
164
+ orderBy(fieldApiNames: string[]): QueryV2 {
165
+ fieldApiNames.forEach((fieldApiName) => {
166
+ this._order.push({
167
+ field: fieldApiName,
168
+ direction: "asc",
169
+ type: "",
170
+ });
171
+ });
172
+ return this;
173
+ }
174
+
175
+ orderByDesc(fieldApiNames: string[]): QueryV2 {
176
+ fieldApiNames.forEach((fieldApiName) => {
177
+ this._order.push({
178
+ field: fieldApiName,
179
+ direction: "desc",
180
+ type: "",
181
+ });
182
+ });
183
+ return this;
184
+ }
185
+
186
+ select(fieldApiNames: string[]): QueryV2 {
187
+ fieldApiNames.forEach((fieldApiName) => {
188
+ this.fields.push(fieldApiName);
189
+ });
190
+ return this;
191
+ }
192
+
193
+ constructor(objectApiName: string) {
194
+ this.objectApiName = objectApiName;
195
+ this._limit = 200;
196
+ this._offset = 0;
197
+ this.fields = [];
198
+ this._order = [];
199
+ this.filter = {
200
+ type: "and",
201
+ arithmeticExpressions: null,
202
+ logicalExpressions: null,
203
+ };
204
+ }
205
+ }
206
+
207
+ export type logicalRet = {
208
+ logicalExps: LogicalExpression[];
209
+ arithmeticExps: ArithmeticExpression[];
210
+ }
211
+
212
+ export function logical(exps: (LogicalExpression | Record<string, ArithmeticExpression>)[]): logicalRet {
213
+ if (!exps || exps.length == 0) {
214
+ return null;
215
+ }
216
+ var logicalExps: LogicalExpression[] = [];
217
+ var arithmeticExps: ArithmeticExpression[] = [];
218
+ exps.forEach((exp) => {
219
+ if (!exp) {
220
+ return;
221
+ }
222
+ if (exp instanceof LogicalExpression) {
223
+ logicalExps.push(exp);
224
+ } else {
225
+ for (var key in exp) {
226
+ if (exp[key]) {
227
+ arithmeticExps.push(new ArithmeticExpression(key, exp[key].operator, exp[key].right));
228
+ }
229
+ }
230
+ }
231
+ });
232
+ return {
233
+ logicalExps: logicalExps,
234
+ arithmeticExps: arithmeticExps,
235
+ }
236
+ }
237
+
238
+ export type CriterionV2 = (Record<string, CriterionV2> | ExpressionV2)[];
239
+
240
+ export function buildCriterionV2(filter: LogicalExpression): CriterionV2 {
241
+ if (!filter || filter.logicalExpressions.length == 0 && filter.arithmeticExpressions.length == 0) {
242
+ return null;
243
+ }
244
+ var conditions: any[] = [];
245
+ filter.logicalExpressions.forEach((logicalExp) => {
246
+ conditions.push({
247
+ [logicalExp.type]: buildCriterionV2(logicalExp),
248
+ })
249
+ });
250
+ filter.arithmeticExpressions.forEach((arithmeticExp) => {
251
+ conditions.push(arithmeticExp.expr);
252
+ });
253
+ return conditions;
254
+ }
@@ -0,0 +1,179 @@
1
+ import { _Cond, _BooleanCond, _LogicalCond } from '../../../types/types';
2
+ import { IOperator } from "../IOperator";
3
+ import { UserDataType } from './expression';
4
+ export declare const operates: {
5
+ AND: string;
6
+ OR: string;
7
+ EMTPY: string;
8
+ NOT_EMTPY: string;
9
+ EQ: string;
10
+ NEQ: string;
11
+ LT: string;
12
+ LTE: string;
13
+ GT: string;
14
+ GTE: string;
15
+ CONTAIN: string;
16
+ NOT_CONTAIN: string;
17
+ IN: string;
18
+ NIN: string;
19
+ HAS_ANY_OF: string;
20
+ HAS_NONE_OF: string;
21
+ isOnOrBefore: string;
22
+ isOnOrAfter: string;
23
+ };
24
+ export declare class Operator<T> implements IOperator {
25
+ /**
26
+ * 逻辑且
27
+ * @param conditions 多个条件,用逗号分隔
28
+ * @example
29
+ * ```
30
+ * context.db.object("_user").where(kunlun.operator.and({
31
+ * age: "22"
32
+ * },{
33
+ * gender: "male"
34
+ * }))
35
+ * ```
36
+ */
37
+ and<T>(...conditions: (_Cond<T> | _BooleanCond<T>)[]): _LogicalCond<T>;
38
+ /**
39
+ * 逻辑或
40
+ * @param conditions 多个条件,用逗号分隔
41
+ * @example
42
+ * ```
43
+ * context.db.object("_user").where(kunlun.operator.or({
44
+ * age: "22"
45
+ * },{
46
+ * age: "25"
47
+ * }))
48
+ * ```
49
+ */
50
+ or<T>(...conditions: (_Cond<T> | _BooleanCond<T>)[]): _LogicalCond<T>;
51
+ /**
52
+ * 包含
53
+ * @param value 判定是否包含的文本值
54
+ * @example
55
+ * ```
56
+ * context.db.object("_user").where({_name: kunlun.operator.contain("a")})
57
+ * ```
58
+ */
59
+ contain<T>(value: UserDataType): _BooleanCond<T>;
60
+ /**
61
+ * 不包含
62
+ * @param value 判定是否不包含的文本值
63
+ * @example
64
+ * ```
65
+ * context.db.object("_user").where({_name: kunlun.operator.notContain("a")})
66
+ * ```
67
+ */
68
+ notContain<T>(value: UserDataType): _BooleanCond<T>;
69
+ /**
70
+ * 无需入参,判断是否为空
71
+ * @example
72
+ * ```
73
+ * context.db.object("_user").where({employeeType: kunlun.operator.empty()})
74
+ * ```
75
+ */
76
+ empty(): _BooleanCond<undefined>;
77
+ /**
78
+ * 无需入参,判断是否为空
79
+ * @example
80
+ * ```
81
+ * context.db.object("_user").where({employeeType: kunlun.operator.notEmpty()})
82
+ * ```
83
+ */
84
+ notEmpty(): _BooleanCond<undefined>;
85
+ /**
86
+ * 等于
87
+ * @param value 判定是否相等的值
88
+ * @example
89
+ * ```
90
+ * context.db.object("_user").where({age: kunlun.operator.eq(20)})
91
+ * ```
92
+ */
93
+ eq<T>(value: UserDataType): _BooleanCond<T>;
94
+ /**
95
+ * 不等于
96
+ * @param value 判定是否不相等的值
97
+ * @example
98
+ * ```
99
+ * context.db.object("_user").where({age: kunlun.operator.neq(20)})
100
+ * ```
101
+ */
102
+ neq<T>(value: UserDataType): _BooleanCond<T>;
103
+ /**
104
+ * 大于或晚于
105
+ * @param value 判定是否大于或晚于的值
106
+ * @example
107
+ * ```
108
+ * kunlun.operator.gt(new Date("2020-11-26").getTime())
109
+ * ```
110
+ */
111
+ gt<T>(value: number | Date): _BooleanCond<T>;
112
+ /**
113
+ * 大于等于或晚于等于
114
+ * @param value 判定是否大于等于或晚于等于的值
115
+ * @example
116
+ * ```
117
+ * kunlun.operator.gte(new Date("2020-11-26").getTime())
118
+ * ```
119
+ */
120
+ gte<T>(value: number | Date): _BooleanCond<T>;
121
+ /**
122
+ * 小于或早于
123
+ * @param value 判定是否小于或早于的值
124
+ * @example
125
+ * ```
126
+ * kunlun.operator.lt(new Date("2020-11-26").getTime())
127
+ * ```
128
+ */
129
+ lt<T>(value: number | Date): _BooleanCond<T>;
130
+ /**
131
+ * 小于等于或早于等于
132
+ * @param value 判定是否小于等于或早于等于的值
133
+ * @example
134
+ * ```
135
+ * kunlun.operator.lte(new Date("2020-11-26").getTime())
136
+ * ```
137
+ */
138
+ lte<T>(value: number | Date): _BooleanCond<T>;
139
+ /**
140
+ * 存在于给定的数组内
141
+ * @param values 判定是否存在于的一组值,用数组传递
142
+ */
143
+ in<T>(values: T[]): _BooleanCond<T>;
144
+ /**
145
+ * 存在于给定的数组内
146
+ * @param values 判定是否存在于的一组值,用逗号分隔
147
+ */
148
+ in<T>(...values: T[]): _BooleanCond<T>;
149
+ /**
150
+ * 不存在于给定的数组内
151
+ * @param values 判定是否不存在于的一组值,用数组传递
152
+ */
153
+ notIn<T>(values: T[]): _BooleanCond<T>;
154
+ /**
155
+ * 不存在于给定的数组内
156
+ * @param values 判定是否不存在于的一组值,用逗号分隔
157
+ */
158
+ notIn<T>(...values: T[]): _BooleanCond<T>;
159
+ /**
160
+ * 存在给定的多个值中的任何一个值
161
+ * @param values 判定是否不存在于的一组值,用逗号分隔
162
+ */
163
+ hasAnyOf<T>(values: number[] | string[]): _BooleanCond<T>;
164
+ /**
165
+ * 存在给定的多个值中的任何一个值
166
+ * @param values 判定是否不存在于的一组值,用逗号分隔
167
+ */
168
+ hasAnyOf<T>(...values: (number | string)[]): _BooleanCond<T>;
169
+ /**
170
+ * 不存在给定的多个值中的任何值
171
+ * @param values 判定是否不存在于的一组值,用逗号分隔
172
+ */
173
+ hasNoneOf<T>(values: number[] | string[]): _BooleanCond<T>;
174
+ /**
175
+ * 不存在给定的多个值中的任何值
176
+ * @param values 判定是否不存在于的一组值,用逗号分隔
177
+ */
178
+ hasNoneOf<T>(...values: (number | string)[]): _BooleanCond<T>;
179
+ }