@byted-apaas/server-sdk-node 0.0.2-beta.2 → 0.0.2-beta.5

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