@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.
- package/LICENSE +7 -0
- package/NOTICE +3 -0
- package/README.md +1 -0
- package/application/application.d.ts +27 -0
- package/application/application.js +2 -0
- package/application/application.ts +40 -0
- package/application/function/function.d.ts +14 -0
- package/application/function/function.js +21 -0
- package/application/function/function.ts +37 -0
- package/application/impl/common.d.ts +2 -0
- package/application/impl/common.js +50 -0
- package/application/impl/common.ts +50 -0
- package/application/impl/impl.d.ts +16 -0
- package/application/impl/impl.js +38 -0
- package/application/impl/impl.ts +48 -0
- package/constants/constants.d.ts +10 -0
- package/constants/constants.js +15 -0
- package/constants/constants.ts +15 -0
- package/context/context.d.ts +74 -0
- package/context/context.js +25 -0
- package/context/context.ts +130 -0
- package/context/db/db.d.ts +73 -0
- package/context/db/db.js +4 -0
- package/context/db/db.ts +80 -0
- package/context/db/impl/IObject.d.ts +251 -0
- package/context/db/impl/IObject.js +5 -0
- package/context/db/impl/IObject.ts +247 -0
- package/context/db/impl/db.d.ts +61 -0
- package/context/db/impl/db.js +86 -0
- package/context/db/impl/db.ts +95 -0
- package/context/db/impl/object.d.ts +92 -0
- package/context/db/impl/object.js +524 -0
- package/context/db/impl/object.ts +631 -0
- package/context/db/impl/oql/ioql.d.ts +6 -0
- package/context/db/impl/oql/ioql.js +4 -0
- package/context/db/impl/oql/ioql.ts +9 -0
- package/context/db/impl/oql/oql.d.ts +8 -0
- package/context/db/impl/oql/oql.js +21 -0
- package/context/db/impl/oql/oql.ts +25 -0
- package/context/db/impl/order.d.ts +9 -0
- package/context/db/impl/order.js +15 -0
- package/context/db/impl/order.ts +19 -0
- package/context/db/impl/propertiesStore.d.ts +8 -0
- package/context/db/impl/propertiesStore.js +29 -0
- package/context/db/impl/propertiesStore.ts +31 -0
- package/context/db/impl/queryBuilder.d.ts +29 -0
- package/context/db/impl/queryBuilder.js +78 -0
- package/context/db/impl/queryBuilder.ts +106 -0
- package/context/db/impl/transaction/index.d.ts +20 -0
- package/context/db/impl/transaction/index.js +277 -0
- package/context/db/impl/transaction/index.ts +340 -0
- package/context/db/impl/transaction/operation.d.ts +27 -0
- package/context/db/impl/transaction/operation.js +69 -0
- package/context/db/impl/transaction/operation.ts +72 -0
- package/context/db/impl/transaction.d.ts +67 -0
- package/context/db/impl/transaction.js +4 -0
- package/context/db/impl/transaction.ts +79 -0
- package/context/globalConfig/globalConfig.d.ts +7 -0
- package/context/globalConfig/globalConfig.js +16 -0
- package/context/globalConfig/globalConfig.ts +14 -0
- package/context/metadata/components/common.d.ts +6 -0
- package/context/metadata/components/common.js +17 -0
- package/context/metadata/components/common.ts +22 -0
- package/context/metadata/components/components.d.ts +12 -0
- package/context/metadata/components/components.js +19 -0
- package/context/metadata/components/components.ts +22 -0
- package/context/metadata/components/desktop/list.d.ts +16 -0
- package/context/metadata/components/desktop/list.js +402 -0
- package/context/metadata/components/desktop/list.ts +457 -0
- package/context/metadata/components/desktop/recordDetail.d.ts +11 -0
- package/context/metadata/components/desktop/recordDetail.js +53 -0
- package/context/metadata/components/desktop/recordDetail.ts +67 -0
- package/context/metadata/components/mobile/list.d.ts +24 -0
- package/context/metadata/components/mobile/list.js +145 -0
- package/context/metadata/components/mobile/list.ts +179 -0
- package/context/metadata/metadata.d.ts +61 -0
- package/context/metadata/metadata.js +103 -0
- package/context/metadata/metadata.ts +178 -0
- package/context/metadata/objects/fields.d.ts +130 -0
- package/context/metadata/objects/fields.js +334 -0
- package/context/metadata/objects/fields.ts +457 -0
- package/context/metadata/objects/fields.util.d.ts +40 -0
- package/context/metadata/objects/fields.util.js +319 -0
- package/context/metadata/objects/fields.util.ts +360 -0
- package/context/metadata/objects/objects.d.ts +11 -0
- package/context/metadata/objects/objects.js +20 -0
- package/context/metadata/objects/objects.ts +30 -0
- package/context/metadata/types/common.d.ts +6 -0
- package/context/metadata/types/common.js +9 -0
- package/context/metadata/types/common.ts +13 -0
- package/context/metadata/types/components.d.ts +90 -0
- package/context/metadata/types/components.js +4 -0
- package/context/metadata/types/components.ts +108 -0
- package/context/metadata/types/objects.d.ts +226 -0
- package/context/metadata/types/objects.js +4 -0
- package/context/metadata/types/objects.ts +254 -0
- package/context/msg/msg.d.ts +38 -0
- package/context/msg/msg.js +35 -0
- package/context/msg/msg.ts +52 -0
- package/context/resources/IResources.d.ts +66 -0
- package/context/resources/IResources.js +2 -0
- package/context/resources/IResources.ts +73 -0
- package/context/resources/impl/resources.d.ts +42 -0
- package/context/resources/impl/resources.js +150 -0
- package/context/resources/impl/resources.ts +173 -0
- package/context/tasks/tasks.d.ts +33 -0
- package/context/tasks/tasks.js +139 -0
- package/context/tasks/tasks.ts +159 -0
- package/data/index.d.ts +27 -0
- package/data/index.js +4 -0
- package/data/index.ts +30 -0
- package/hooks/api.d.ts +61 -0
- package/hooks/api.js +327 -0
- package/hooks/api.ts +341 -0
- package/hooks/hooks.d.ts +1 -0
- package/hooks/hooks.js +88 -0
- package/hooks/hooks.ts +100 -0
- package/kunlun/kunlun.d.ts +55 -0
- package/kunlun/kunlun.js +58 -0
- package/kunlun/kunlun.ts +72 -0
- package/kunlun/operator/IOperator.d.ts +158 -0
- package/kunlun/operator/IOperator.js +4 -0
- package/kunlun/operator/IOperator.ts +166 -0
- package/kunlun/operator/impl/expression.d.ts +47 -0
- package/kunlun/operator/impl/expression.js +56 -0
- package/kunlun/operator/impl/expression.ts +74 -0
- package/kunlun/operator/impl/logic.d.ts +50 -0
- package/kunlun/operator/impl/logic.js +509 -0
- package/kunlun/operator/impl/logic.ts +598 -0
- package/kunlun/operator/impl/logicV2.d.ts +58 -0
- package/kunlun/operator/impl/logicV2.js +200 -0
- package/kunlun/operator/impl/logicV2.ts +254 -0
- package/kunlun/operator/impl/operator.d.ts +179 -0
- package/kunlun/operator/impl/operator.js +222 -0
- package/kunlun/operator/impl/operator.ts +258 -0
- package/kunlun/operator/impl/operatorV2.d.ts +180 -0
- package/kunlun/operator/impl/operatorV2.js +216 -0
- package/kunlun/operator/impl/operatorV2.ts +249 -0
- package/lib/core.d.ts +4 -0
- package/lib/core.js +19 -0
- package/lib/core.ts +7 -0
- package/package.json +50 -0
- package/request/common.d.ts +13 -0
- package/request/common.js +87 -0
- package/request/common.ts +91 -0
- package/request/constants.d.ts +10 -0
- package/request/constants.js +25 -0
- package/request/constants.ts +25 -0
- package/request/faasinfra.d.ts +8 -0
- package/request/faasinfra.js +358 -0
- package/request/faasinfra.ts +393 -0
- package/request/innerapi.d.ts +67 -0
- package/request/innerapi.js +1412 -0
- package/request/innerapi.ts +1648 -0
- package/request/interface.d.ts +95 -0
- package/request/interface.js +41 -0
- package/request/interface.ts +169 -0
- package/request/openapi.d.ts +69 -0
- package/request/openapi.js +1014 -0
- package/request/openapi.ts +1223 -0
- package/types/types.d.ts +79 -0
- package/types/types.js +4 -0
- package/types/types.ts +108 -0
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OperatorV2 = exports.operates = void 0;
|
|
4
|
+
const server_common_node_1 = require("@byted-apaas/server-common-node");
|
|
5
|
+
const logicV2_1 = require("./logicV2");
|
|
6
|
+
exports.operates = {
|
|
7
|
+
AND: "and",
|
|
8
|
+
OR: "or",
|
|
9
|
+
EMPTY: "isEmpty",
|
|
10
|
+
NOT_EMPTY: "isNotEmpty",
|
|
11
|
+
EQ: "equals",
|
|
12
|
+
NEQ: "notEquals",
|
|
13
|
+
LT: "lessThan",
|
|
14
|
+
LTE: "lessThanOrEquals",
|
|
15
|
+
GT: "greaterThan",
|
|
16
|
+
GTE: "greaterThanOrEquals",
|
|
17
|
+
CONTAIN: "contains",
|
|
18
|
+
NOT_CONTAIN: "notContains",
|
|
19
|
+
IN: "isAnyOf",
|
|
20
|
+
NIN: "isNoneOf",
|
|
21
|
+
HAS_ANY_OF: "hasAnyOf",
|
|
22
|
+
HAS_NONE_OF: "hasNoneOf",
|
|
23
|
+
isOnOrBefore: "lt",
|
|
24
|
+
isOnOrAfter: "gt",
|
|
25
|
+
};
|
|
26
|
+
class OperatorV2 {
|
|
27
|
+
/**
|
|
28
|
+
* 逻辑且
|
|
29
|
+
* @param conditions 多个条件,用逗号分隔
|
|
30
|
+
* @example
|
|
31
|
+
* ```
|
|
32
|
+
* context.db.object("_user").where(kunlun.operator.and({
|
|
33
|
+
* age: "22"
|
|
34
|
+
* },{
|
|
35
|
+
* gender: "male"
|
|
36
|
+
* }))
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
and(...exps) {
|
|
40
|
+
const { logicalExps, arithmeticExps } = (0, logicV2_1.logical)(exps);
|
|
41
|
+
return new logicV2_1.LogicalExpression(exports.operates.AND, arithmeticExps, logicalExps);
|
|
42
|
+
}
|
|
43
|
+
;
|
|
44
|
+
/**
|
|
45
|
+
* 逻辑或
|
|
46
|
+
* @param conditions 多个条件,用逗号分隔
|
|
47
|
+
* @example
|
|
48
|
+
* ```
|
|
49
|
+
* context.db.object("_user").where(kunlun.operator.or({
|
|
50
|
+
* age: "22"
|
|
51
|
+
* },{
|
|
52
|
+
* age: "25"
|
|
53
|
+
* }))
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
or(...exps) {
|
|
57
|
+
const { logicalExps, arithmeticExps } = (0, logicV2_1.logical)(exps);
|
|
58
|
+
return new logicV2_1.LogicalExpression(exports.operates.OR, arithmeticExps, logicalExps);
|
|
59
|
+
}
|
|
60
|
+
;
|
|
61
|
+
/**
|
|
62
|
+
* 包含
|
|
63
|
+
* @param value 判定是否包含的文本值
|
|
64
|
+
* @example
|
|
65
|
+
* ```
|
|
66
|
+
* context.db.object("_user").where({_name: kunlun.operator.contain("a")})
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
contain(value) {
|
|
70
|
+
return new logicV2_1.ArithmeticExpression(null, exports.operates.CONTAIN, value);
|
|
71
|
+
}
|
|
72
|
+
;
|
|
73
|
+
/**
|
|
74
|
+
* 不包含
|
|
75
|
+
* @param value 判定是否不包含的文本值
|
|
76
|
+
* @example
|
|
77
|
+
* ```
|
|
78
|
+
* context.db.object("_user").where({_name: kunlun.operator.notContain("a")})
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
notContain(value) {
|
|
82
|
+
return new logicV2_1.ArithmeticExpression(null, exports.operates.NOT_CONTAIN, value);
|
|
83
|
+
}
|
|
84
|
+
;
|
|
85
|
+
/**
|
|
86
|
+
* 无需入参,判断是否为空
|
|
87
|
+
* @example
|
|
88
|
+
* ```
|
|
89
|
+
* context.db.object("_user").where({employeeType: kunlun.operator.empty()})
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
empty() {
|
|
93
|
+
return new logicV2_1.ArithmeticExpression(null, exports.operates.EMPTY, null);
|
|
94
|
+
}
|
|
95
|
+
;
|
|
96
|
+
/**
|
|
97
|
+
* 无需入参,判断是否为空
|
|
98
|
+
* @example
|
|
99
|
+
* ```
|
|
100
|
+
* context.db.object("_user").where({employeeType: kunlun.operator.notEmpty()})
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
notEmpty() {
|
|
104
|
+
return new logicV2_1.ArithmeticExpression(null, exports.operates.NOT_EMPTY, null);
|
|
105
|
+
}
|
|
106
|
+
;
|
|
107
|
+
/**
|
|
108
|
+
* 等于
|
|
109
|
+
* @param value 判定是否相等的值
|
|
110
|
+
* @example
|
|
111
|
+
* ```
|
|
112
|
+
* context.db.object("_user").where({age: kunlun.operator.eq(20)})
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
eq(value) {
|
|
116
|
+
return new logicV2_1.ArithmeticExpression(null, exports.operates.EQ, value);
|
|
117
|
+
}
|
|
118
|
+
;
|
|
119
|
+
/**
|
|
120
|
+
* 不等于
|
|
121
|
+
* @param value 判定是否不相等的值
|
|
122
|
+
* @example
|
|
123
|
+
* ```
|
|
124
|
+
* context.db.object("_user").where({age: kunlun.operator.neq(20)})
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
neq(value) {
|
|
128
|
+
return new logicV2_1.ArithmeticExpression(null, exports.operates.NEQ, value);
|
|
129
|
+
}
|
|
130
|
+
;
|
|
131
|
+
/**
|
|
132
|
+
* 大于或晚于
|
|
133
|
+
* @param value 判定是否大于或晚于的值
|
|
134
|
+
* @example
|
|
135
|
+
* ```
|
|
136
|
+
* kunlun.operator.gt(new Date("2020-11-26").getTime())
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
gt(value) {
|
|
140
|
+
return new logicV2_1.ArithmeticExpression(null, exports.operates.GT, value);
|
|
141
|
+
}
|
|
142
|
+
;
|
|
143
|
+
/**
|
|
144
|
+
* 大于等于或晚于等于
|
|
145
|
+
* @param value 判定是否大于等于或晚于等于的值
|
|
146
|
+
* @example
|
|
147
|
+
* ```
|
|
148
|
+
* kunlun.operator.gte(new Date("2020-11-26").getTime())
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
gte(value) {
|
|
152
|
+
return new logicV2_1.ArithmeticExpression(null, exports.operates.GTE, value);
|
|
153
|
+
}
|
|
154
|
+
;
|
|
155
|
+
/**
|
|
156
|
+
* 小于或早于
|
|
157
|
+
* @param value 判定是否小于或早于的值
|
|
158
|
+
* @example
|
|
159
|
+
* ```
|
|
160
|
+
* kunlun.operator.lt(new Date("2020-11-26").getTime())
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
lt(value) {
|
|
164
|
+
return new logicV2_1.ArithmeticExpression(null, exports.operates.LT, value);
|
|
165
|
+
}
|
|
166
|
+
;
|
|
167
|
+
/**
|
|
168
|
+
* 小于等于或早于等于
|
|
169
|
+
* @param value 判定是否小于等于或早于等于的值
|
|
170
|
+
* @example
|
|
171
|
+
* ```
|
|
172
|
+
* kunlun.operator.lte(new Date("2020-11-26").getTime())
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
lte(value) {
|
|
176
|
+
return new logicV2_1.ArithmeticExpression(null, exports.operates.LTE, value);
|
|
177
|
+
}
|
|
178
|
+
;
|
|
179
|
+
in(value, ...restValues) {
|
|
180
|
+
value = !value ? [] : value;
|
|
181
|
+
const argList = server_common_node_1.utils.argsToList(value, restValues);
|
|
182
|
+
if (argList.length === 0) {
|
|
183
|
+
throw new server_common_node_1.exceptions.InvalidParamError("can not IN empty list");
|
|
184
|
+
}
|
|
185
|
+
return new logicV2_1.ArithmeticExpression(null, exports.operates.IN, argList);
|
|
186
|
+
}
|
|
187
|
+
;
|
|
188
|
+
notIn(value, ...restValues) {
|
|
189
|
+
value = !value ? [] : value;
|
|
190
|
+
const argList = server_common_node_1.utils.argsToList(value, restValues);
|
|
191
|
+
if (argList.length === 0) {
|
|
192
|
+
throw new server_common_node_1.exceptions.InvalidParamError("can not NOT_IN empty list");
|
|
193
|
+
}
|
|
194
|
+
return new logicV2_1.ArithmeticExpression(null, exports.operates.NIN, argList);
|
|
195
|
+
}
|
|
196
|
+
;
|
|
197
|
+
hasAnyOf(value, ...restValues) {
|
|
198
|
+
value = !value ? [] : value;
|
|
199
|
+
const argList = server_common_node_1.utils.argsToList(value, restValues);
|
|
200
|
+
if (argList.length === 0) {
|
|
201
|
+
throw new server_common_node_1.exceptions.InvalidParamError("can not HAS_ANY_OF empty list");
|
|
202
|
+
}
|
|
203
|
+
return new logicV2_1.ArithmeticExpression(null, exports.operates.HAS_ANY_OF, argList);
|
|
204
|
+
}
|
|
205
|
+
;
|
|
206
|
+
hasNoneOf(value, ...restValues) {
|
|
207
|
+
value = !value ? [] : value;
|
|
208
|
+
const argList = server_common_node_1.utils.argsToList(value, restValues);
|
|
209
|
+
if (argList.length === 0) {
|
|
210
|
+
throw new server_common_node_1.exceptions.InvalidParamError("can not HAS_NONE_OF empty list");
|
|
211
|
+
}
|
|
212
|
+
return new logicV2_1.ArithmeticExpression(null, exports.operates.HAS_NONE_OF, argList);
|
|
213
|
+
}
|
|
214
|
+
;
|
|
215
|
+
}
|
|
216
|
+
exports.OperatorV2 = OperatorV2;
|
|
@@ -0,0 +1,249 @@
|
|
|
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 { LogicalExpression, logical, ArithmeticExpression } from './logicV2';
|
|
5
|
+
import { UserDataType } from './expression';
|
|
6
|
+
|
|
7
|
+
export const operates = {
|
|
8
|
+
AND: "and", // 逻辑与
|
|
9
|
+
OR: "or", // 逻辑或
|
|
10
|
+
|
|
11
|
+
EMPTY: "isEmpty", // 为空
|
|
12
|
+
NOT_EMPTY: "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: "lt",
|
|
31
|
+
isOnOrAfter: "gt",
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export class OperatorV2<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>(...exps: (_Cond<T> | _BooleanCond<T> | LogicalExpression)[]): LogicalExpression {
|
|
48
|
+
const { logicalExps, arithmeticExps } = logical(exps as any);
|
|
49
|
+
return new LogicalExpression(operates.AND, arithmeticExps, logicalExps);
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* 逻辑或
|
|
53
|
+
* @param conditions 多个条件,用逗号分隔
|
|
54
|
+
* @example
|
|
55
|
+
* ```
|
|
56
|
+
* context.db.object("_user").where(kunlun.operator.or({
|
|
57
|
+
* age: "22"
|
|
58
|
+
* },{
|
|
59
|
+
* age: "25"
|
|
60
|
+
* }))
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
or<T>(...exps: (_Cond<T> | _BooleanCond<T> | LogicalExpression)[]): LogicalExpression {
|
|
64
|
+
const { logicalExps, arithmeticExps } = logical(exps as any);
|
|
65
|
+
return new LogicalExpression(operates.OR, arithmeticExps, logicalExps);
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* 包含
|
|
69
|
+
* @param value 判定是否包含的文本值
|
|
70
|
+
* @example
|
|
71
|
+
* ```
|
|
72
|
+
* context.db.object("_user").where({_name: kunlun.operator.contain("a")})
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
contain<T>(value: UserDataType): _BooleanCond<T> {
|
|
76
|
+
return new ArithmeticExpression(null, operates.CONTAIN, value);
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* 不包含
|
|
80
|
+
* @param value 判定是否不包含的文本值
|
|
81
|
+
* @example
|
|
82
|
+
* ```
|
|
83
|
+
* context.db.object("_user").where({_name: kunlun.operator.notContain("a")})
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
notContain<T>(value: UserDataType): _BooleanCond<T> {
|
|
87
|
+
return new ArithmeticExpression(null, operates.NOT_CONTAIN, value);
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* 无需入参,判断是否为空
|
|
91
|
+
* @example
|
|
92
|
+
* ```
|
|
93
|
+
* context.db.object("_user").where({employeeType: kunlun.operator.empty()})
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
empty(): _BooleanCond<undefined> {
|
|
97
|
+
return new ArithmeticExpression(null, operates.EMPTY, null);
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* 无需入参,判断是否为空
|
|
101
|
+
* @example
|
|
102
|
+
* ```
|
|
103
|
+
* context.db.object("_user").where({employeeType: kunlun.operator.notEmpty()})
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
notEmpty(): _BooleanCond<undefined> {
|
|
107
|
+
return new ArithmeticExpression(null, operates.NOT_EMPTY, null);
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* 等于
|
|
111
|
+
* @param value 判定是否相等的值
|
|
112
|
+
* @example
|
|
113
|
+
* ```
|
|
114
|
+
* context.db.object("_user").where({age: kunlun.operator.eq(20)})
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
eq<T>(value: UserDataType): _BooleanCond<T> {
|
|
118
|
+
return new ArithmeticExpression(null, operates.EQ, value);
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* 不等于
|
|
122
|
+
* @param value 判定是否不相等的值
|
|
123
|
+
* @example
|
|
124
|
+
* ```
|
|
125
|
+
* context.db.object("_user").where({age: kunlun.operator.neq(20)})
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
neq<T>(value: UserDataType): _BooleanCond<T> {
|
|
129
|
+
return new ArithmeticExpression(null, operates.NEQ, value);
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* 大于或晚于
|
|
133
|
+
* @param value 判定是否大于或晚于的值
|
|
134
|
+
* @example
|
|
135
|
+
* ```
|
|
136
|
+
* kunlun.operator.gt(new Date("2020-11-26").getTime())
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
gt<T>(value: number | Date): _BooleanCond<T> {
|
|
140
|
+
return new ArithmeticExpression(null, operates.GT, value);
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* 大于等于或晚于等于
|
|
144
|
+
* @param value 判定是否大于等于或晚于等于的值
|
|
145
|
+
* @example
|
|
146
|
+
* ```
|
|
147
|
+
* kunlun.operator.gte(new Date("2020-11-26").getTime())
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
gte<T>(value: number | Date): _BooleanCond<T> {
|
|
151
|
+
return new ArithmeticExpression(null, operates.GTE, value);
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* 小于或早于
|
|
155
|
+
* @param value 判定是否小于或早于的值
|
|
156
|
+
* @example
|
|
157
|
+
* ```
|
|
158
|
+
* kunlun.operator.lt(new Date("2020-11-26").getTime())
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
lt<T>(value: number | Date): _BooleanCond<T> {
|
|
162
|
+
return new ArithmeticExpression(null, operates.LT, value);
|
|
163
|
+
};
|
|
164
|
+
/**
|
|
165
|
+
* 小于等于或早于等于
|
|
166
|
+
* @param value 判定是否小于等于或早于等于的值
|
|
167
|
+
* @example
|
|
168
|
+
* ```
|
|
169
|
+
* kunlun.operator.lte(new Date("2020-11-26").getTime())
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
lte<T>(value: number | Date): _BooleanCond<T> {
|
|
173
|
+
return new ArithmeticExpression(null, operates.LTE, value);
|
|
174
|
+
};
|
|
175
|
+
/**
|
|
176
|
+
* 存在于给定的数组内
|
|
177
|
+
* @param values 判定是否存在于的一组值,用数组传递
|
|
178
|
+
*/
|
|
179
|
+
in<T>(values: T[]): _BooleanCond<T>;
|
|
180
|
+
/**
|
|
181
|
+
* 存在于给定的数组内
|
|
182
|
+
* @param values 判定是否存在于的一组值,用逗号分隔
|
|
183
|
+
*/
|
|
184
|
+
in<T>(...values: T[]): _BooleanCond<T>;
|
|
185
|
+
in<T>(value: T | T[], ...restValues: T[]): _BooleanCond<T> {
|
|
186
|
+
value = !value ? [] : value;
|
|
187
|
+
const argList = utils.argsToList(value, restValues);
|
|
188
|
+
if (argList.length === 0) {
|
|
189
|
+
throw new exceptions.InvalidParamError("can not IN empty list");
|
|
190
|
+
}
|
|
191
|
+
return new ArithmeticExpression(null, operates.IN, argList);
|
|
192
|
+
};
|
|
193
|
+
/**
|
|
194
|
+
* 不存在于给定的数组内
|
|
195
|
+
* @param values 判定是否不存在于的一组值,用数组传递
|
|
196
|
+
*/
|
|
197
|
+
notIn<T>(values: T[]): _BooleanCond<T>;
|
|
198
|
+
/**
|
|
199
|
+
* 不存在于给定的数组内
|
|
200
|
+
* @param values 判定是否不存在于的一组值,用逗号分隔
|
|
201
|
+
*/
|
|
202
|
+
notIn<T>(...values: T[]): _BooleanCond<T>;
|
|
203
|
+
notIn<T>(value: T | T[], ...restValues: T[]): _BooleanCond<T> {
|
|
204
|
+
value = !value ? [] : value;
|
|
205
|
+
const argList = utils.argsToList(value, restValues);
|
|
206
|
+
if (argList.length === 0) {
|
|
207
|
+
throw new exceptions.InvalidParamError("can not NOT_IN empty list");
|
|
208
|
+
}
|
|
209
|
+
return new ArithmeticExpression(null, operates.NIN, argList);
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* 存在给定的多个值中的任何一个值
|
|
214
|
+
* @param values 判定是否不存在于的一组值,用逗号分隔
|
|
215
|
+
*/
|
|
216
|
+
hasAnyOf<T>(values: number[] | string[]): _BooleanCond<T>;
|
|
217
|
+
/**
|
|
218
|
+
* 存在给定的多个值中的任何一个值
|
|
219
|
+
* @param values 判定是否不存在于的一组值,用逗号分隔
|
|
220
|
+
*/
|
|
221
|
+
hasAnyOf<T>(...values: (number | string)[]): _BooleanCond<T>;
|
|
222
|
+
hasAnyOf<T>(value: (number | string) | (number | string)[], ...restValues: (number | string)[]): _BooleanCond<T> {
|
|
223
|
+
value = !value ? [] : value;
|
|
224
|
+
const argList = utils.argsToList(value, restValues);
|
|
225
|
+
if (argList.length === 0) {
|
|
226
|
+
throw new exceptions.InvalidParamError("can not HAS_ANY_OF empty list");
|
|
227
|
+
}
|
|
228
|
+
return new ArithmeticExpression(null, operates.HAS_ANY_OF, argList);
|
|
229
|
+
};
|
|
230
|
+
/**
|
|
231
|
+
* 不存在给定的多个值中的任何值
|
|
232
|
+
* @param values 判定是否不存在于的一组值,用逗号分隔
|
|
233
|
+
*/
|
|
234
|
+
hasNoneOf<T>(values: number[] | string[]): _BooleanCond<T>;
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* 不存在给定的多个值中的任何值
|
|
238
|
+
* @param values 判定是否不存在于的一组值,用逗号分隔
|
|
239
|
+
*/
|
|
240
|
+
hasNoneOf<T>(...values: (number | string)[]): _BooleanCond<T>;
|
|
241
|
+
hasNoneOf<T>(value: (number | string) | (number | string)[], ...restValues: (number | string)[]): _BooleanCond<T> {
|
|
242
|
+
value = !value ? [] : value;
|
|
243
|
+
const argList = utils.argsToList(value, restValues);
|
|
244
|
+
if (argList.length === 0) {
|
|
245
|
+
throw new exceptions.InvalidParamError("can not HAS_NONE_OF empty list");
|
|
246
|
+
}
|
|
247
|
+
return new ArithmeticExpression(null, operates.HAS_NONE_OF, argList);
|
|
248
|
+
};
|
|
249
|
+
}
|
package/lib/core.d.ts
ADDED
package/lib/core.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
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.Application = exports.metaData = exports.workflow = exports.microservice = exports.cloudfunction = exports.tasks = exports.msg = exports.resources = exports.db = exports.kunlun = exports.isNewSystemProxyFunc = exports.hooks = void 0;
|
|
6
|
+
exports.hooks = require("../hooks/hooks");
|
|
7
|
+
exports.isNewSystemProxyFunc = true;
|
|
8
|
+
var kunlun_1 = require("../kunlun/kunlun");
|
|
9
|
+
Object.defineProperty(exports, "kunlun", { enumerable: true, get: function () { return kunlun_1.kunlun; } });
|
|
10
|
+
var api_1 = require("../hooks/api");
|
|
11
|
+
Object.defineProperty(exports, "db", { enumerable: true, get: function () { return api_1.db; } });
|
|
12
|
+
Object.defineProperty(exports, "resources", { enumerable: true, get: function () { return api_1.resources; } });
|
|
13
|
+
Object.defineProperty(exports, "msg", { enumerable: true, get: function () { return api_1.msg; } });
|
|
14
|
+
Object.defineProperty(exports, "tasks", { enumerable: true, get: function () { return api_1.tasks; } });
|
|
15
|
+
Object.defineProperty(exports, "cloudfunction", { enumerable: true, get: function () { return api_1.cloudfunction; } });
|
|
16
|
+
Object.defineProperty(exports, "microservice", { enumerable: true, get: function () { return api_1.microservice; } });
|
|
17
|
+
Object.defineProperty(exports, "workflow", { enumerable: true, get: function () { return api_1.workflow; } });
|
|
18
|
+
Object.defineProperty(exports, "metaData", { enumerable: true, get: function () { return api_1.metaData; } });
|
|
19
|
+
Object.defineProperty(exports, "Application", { enumerable: true, get: function () { return api_1.Application; } });
|
package/lib/core.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Copyright 2022 ByteDance Ltd. and/or its affiliates
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
export * as hooks from "../hooks/hooks"
|
|
5
|
+
export const isNewSystemProxyFunc: boolean = true;
|
|
6
|
+
export {kunlun} from "../kunlun/kunlun";
|
|
7
|
+
export {db, resources, msg, tasks, cloudfunction, microservice, workflow, metaData, Application} from "../hooks/api";
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@byted-apaas/server-sdk-node",
|
|
3
|
+
"version": "0.0.1-beta.3",
|
|
4
|
+
"description": "aPaaS Server SDK",
|
|
5
|
+
"author": "zhouwexin <zhouwexin@bytedance.com>",
|
|
6
|
+
"homepage": "",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"main": "lib/core.js",
|
|
9
|
+
"files": [
|
|
10
|
+
"constants",
|
|
11
|
+
"context",
|
|
12
|
+
"data",
|
|
13
|
+
"hooks",
|
|
14
|
+
"request",
|
|
15
|
+
"kunlun",
|
|
16
|
+
"lib",
|
|
17
|
+
"types",
|
|
18
|
+
"application"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"compile": "tsc -d",
|
|
22
|
+
"compile.local": "tsc -d --sourceMap",
|
|
23
|
+
"pre-build": "rm -rf build && tsc"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@byted-apaas/server-common-node": "0.0.2-beta.1",
|
|
27
|
+
"@jorgeferrero/stream-to-buffer": "^2.0.6",
|
|
28
|
+
"dayjs": "^1.9.6",
|
|
29
|
+
"form-data": "^3.0.0",
|
|
30
|
+
"uuid": "^8.3.2"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/mocha": "^9.0.0",
|
|
34
|
+
"axios": "^0.21.0",
|
|
35
|
+
"madge": "^3.12.0",
|
|
36
|
+
"mocha": "^9.1.3",
|
|
37
|
+
"node-cls": "^1.0.7"
|
|
38
|
+
},
|
|
39
|
+
"mocha": {
|
|
40
|
+
"color": true,
|
|
41
|
+
"recursive": [
|
|
42
|
+
"test/**/*.test.ts"
|
|
43
|
+
],
|
|
44
|
+
"require": [
|
|
45
|
+
"ts-node/register"
|
|
46
|
+
],
|
|
47
|
+
"timeout": 20000
|
|
48
|
+
},
|
|
49
|
+
"gitHead": "e2274551684797a45a4fa5e2168f1c54a7559c7e"
|
|
50
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AppCtx } from "../application/application";
|
|
2
|
+
export declare function getDebugExtraInfo(): Record<string, string>;
|
|
3
|
+
export declare function getTriggerCtx(): any;
|
|
4
|
+
export declare function transMapToFlowVariable(params: Record<string, any>): {
|
|
5
|
+
api_name: string;
|
|
6
|
+
value: any;
|
|
7
|
+
}[];
|
|
8
|
+
export declare function transFlowVariableToMap(variables: {
|
|
9
|
+
api_name: string;
|
|
10
|
+
value: any;
|
|
11
|
+
}[]): Record<string, any>;
|
|
12
|
+
export declare function getTenantInfo(appCtx: AppCtx): Promise<any>;
|
|
13
|
+
export declare function getNamespaceForOpenAndFaaSSDK(): Promise<string>;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getNamespaceForOpenAndFaaSSDK = exports.getTenantInfo = exports.transFlowVariableToMap = exports.transMapToFlowVariable = exports.getTriggerCtx = exports.getDebugExtraInfo = void 0;
|
|
4
|
+
const constants_1 = require("@byted-apaas/server-common-node/constants/constants");
|
|
5
|
+
const common = require("@byted-apaas/server-common-node");
|
|
6
|
+
const interface_1 = require("./interface");
|
|
7
|
+
const credential_1 = require("@byted-apaas/server-common-node/credential/credential");
|
|
8
|
+
const exceptions_1 = require("@byted-apaas/server-common-node/utils/exceptions");
|
|
9
|
+
const common_1 = require("../application/impl/common");
|
|
10
|
+
const utils = common.utils;
|
|
11
|
+
const checkUtils = common.checkUtils;
|
|
12
|
+
const exceptions = common.exceptions;
|
|
13
|
+
const nodeCls = require("node-cls");
|
|
14
|
+
function checkLoopCtx(reqCtx) {
|
|
15
|
+
return reqCtx && reqCtx.loopMasks && Array.isArray(reqCtx.loopMasks);
|
|
16
|
+
}
|
|
17
|
+
function getDebugExtraInfo() {
|
|
18
|
+
let extra = {
|
|
19
|
+
"FunctionFrameVersion": "FunctionFrameV2",
|
|
20
|
+
};
|
|
21
|
+
if (utils.isDebug()) {
|
|
22
|
+
extra.DebugInfo = utils.getDebugCode();
|
|
23
|
+
}
|
|
24
|
+
return extra;
|
|
25
|
+
}
|
|
26
|
+
exports.getDebugExtraInfo = getDebugExtraInfo;
|
|
27
|
+
function getTriggerCtx() {
|
|
28
|
+
let triggerCtx = {}, taskID = utils.getTriggerTaskID();
|
|
29
|
+
if (taskID) {
|
|
30
|
+
triggerCtx[constants_1.headers.triggerTaskId] = taskID;
|
|
31
|
+
}
|
|
32
|
+
let temp = utils.getDistributedHandleMask();
|
|
33
|
+
if (temp) {
|
|
34
|
+
triggerCtx[constants_1.headers.distributedHandleMask] = temp;
|
|
35
|
+
}
|
|
36
|
+
let reqCtx = nodeCls.get(constants_1.headers.loopCtxKey);
|
|
37
|
+
if (checkLoopCtx(reqCtx)) {
|
|
38
|
+
triggerCtx[constants_1.headers.loopMasks] = reqCtx.loopMasks;
|
|
39
|
+
}
|
|
40
|
+
return triggerCtx;
|
|
41
|
+
}
|
|
42
|
+
exports.getTriggerCtx = getTriggerCtx;
|
|
43
|
+
function transMapToFlowVariable(params) {
|
|
44
|
+
let variables = [];
|
|
45
|
+
if (params) {
|
|
46
|
+
if (checkUtils.isNotObject(params)) {
|
|
47
|
+
throw new exceptions.InvalidParamError(`params should be object, and not array`);
|
|
48
|
+
}
|
|
49
|
+
for (const [k, v] of Object.entries(params)) {
|
|
50
|
+
variables.push({ api_name: k, value: v });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return variables;
|
|
54
|
+
}
|
|
55
|
+
exports.transMapToFlowVariable = transMapToFlowVariable;
|
|
56
|
+
function transFlowVariableToMap(variables) {
|
|
57
|
+
let data = {};
|
|
58
|
+
if (variables && Array.isArray(variables)) {
|
|
59
|
+
for (const o of variables) {
|
|
60
|
+
data[o.api_name] = o.value;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return data;
|
|
64
|
+
}
|
|
65
|
+
exports.transFlowVariableToMap = transFlowVariableToMap;
|
|
66
|
+
async function getTenantInfo(appCtx) {
|
|
67
|
+
if (!appCtx) {
|
|
68
|
+
appCtx = {
|
|
69
|
+
mode: "faasSDK",
|
|
70
|
+
credential: new credential_1.AppCredential(utils.getClientId(), utils.getClientSecret(), true)
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
if (!appCtx.credential) {
|
|
74
|
+
throw new exceptions_1.InvalidParamError(`credential is empty`);
|
|
75
|
+
}
|
|
76
|
+
return await (0, common_1.runCtxForOpenSDK)(appCtx, async () => {
|
|
77
|
+
return await (0, interface_1.GetInstance)().getTenantInfo(appCtx);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
exports.getTenantInfo = getTenantInfo;
|
|
81
|
+
async function getNamespaceForOpenAndFaaSSDK() {
|
|
82
|
+
if (utils.isOpenSDKMode()) { // TODO check need assign?
|
|
83
|
+
return (await utils.getCredential().getTenantInfo()).namespace;
|
|
84
|
+
}
|
|
85
|
+
return utils.getNamespaceFromCtx();
|
|
86
|
+
}
|
|
87
|
+
exports.getNamespaceForOpenAndFaaSSDK = getNamespaceForOpenAndFaaSSDK;
|