@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,393 @@
1
+ import * as common from "@byted-apaas/server-common-node"
2
+
3
+ const headers = common.constants.headers;
4
+ const commonHttp = common.http;
5
+ const faasinfra = common.http.faasinfra;
6
+ const faasinfraHttpPath = common.http.faasinfraHttpPath;
7
+ const replaceKeys = common.http.replaceKeys;
8
+ const exceptions = common.exceptions;
9
+ const utils = common.utils;
10
+ const nodeCls = require("node-cls");
11
+ const distributedHandleMask = headers.distributedHandleMask;
12
+ const loopMasks = headers.loopMasks;
13
+ const loopMasksKey = headers.loopMasksKey;
14
+ const loopCtxKey = headers.loopCtxKey;
15
+
16
+ import {URL} from "url";
17
+ import {InternalError} from "@byted-apaas/server-common-node/utils/exceptions";
18
+ import {IFaaSInfraRequest} from "./interface";
19
+
20
+ export class FaaSInfraRequest implements IFaaSInfraRequest {
21
+ constructor() {
22
+ }
23
+
24
+ async createDistributeTaskV1(dataset: any, handlerFunc: string, progressCallbackFunc: string, completedCallbackFunc: string, options: any): Promise<any> {
25
+ // 1.获取 options
26
+ let config = commonHttp.getOptions(null, faasinfraHttpPath.createDistributedTask);
27
+
28
+ // 2.构造url
29
+ let urlPath = config._reqPath.replace(replaceKeys.namespace, utils.getNamespaceFromCtx());
30
+
31
+ // 3.请求
32
+ config.json = {
33
+ "domainName": utils.getTenantNameFromCtx(),
34
+ "namespace": utils.getNamespaceFromCtx(),
35
+ "userId": utils.getUserIDFromCtx(),
36
+
37
+ "dataset": dataset,
38
+ "handlerFunc": handlerFunc,
39
+ "progressCallbackFunc": progressCallbackFunc,
40
+ "completedCallbackFunc": completedCallbackFunc,
41
+ "options": options
42
+ }
43
+
44
+ let task_id = utils.getTriggerTaskID();
45
+ if (task_id) {
46
+ config.json[headers.triggerTaskId] = task_id;
47
+ }
48
+
49
+ let loopCtx = nodeCls.get(loopCtxKey);
50
+ if (checkLoopCtx(loopCtx)) {
51
+ config.json[loopMasksKey] = loopCtx.loopMasks;
52
+ if (!utils.isMicroservice() && (handlerFunc !== "" && config.json[loopMasksKey].includes(utils.handleFuncName({}, handlerFunc))) ||
53
+ (progressCallbackFunc != "" && config.json[loopMasksKey].includes(utils.handleFuncName({}, progressCallbackFunc))) ||
54
+ (completedCallbackFunc != "" && config.json[loopMasksKey].includes(utils.handleFuncName({}, completedCallbackFunc)))) {
55
+ throw new exceptions.InvalidParamError(`Task execution forms a loop.`);
56
+ }
57
+ }
58
+
59
+ return await faasinfra.doRequest(null, urlPath, config);
60
+ }
61
+
62
+ async createDistributeTaskV2(dataset: any, handlerFunc: string, progressCallbackFunc: string, completedCallbackFunc: string, options: any): Promise<any> {
63
+ // 检查函数是否存在
64
+ utils.requireFunction(handlerFunc);
65
+
66
+ // 1.获取 options
67
+ let config = commonHttp.getOptions(null, faasinfraHttpPath.createDistributedTaskV2);
68
+
69
+ // 2.构造url
70
+ let urlPath = config._reqPath.replace(replaceKeys.namespace, utils.getNamespaceFromCtx());
71
+
72
+ // 3.请求
73
+ config.json = {
74
+ "domainName": utils.getTenantNameFromCtx(),
75
+ "namespace": utils.getNamespaceFromCtx(),
76
+ "userId": utils.getUserIDFromCtx(),
77
+
78
+ "dataset": dataset,
79
+ "handlerFunc": handlerFunc,
80
+ "progressCallbackFunc": progressCallbackFunc,
81
+ "completedCallbackFunc": completedCallbackFunc,
82
+ "options": options,
83
+ "extra": getDebugExtraInfo()
84
+ }
85
+
86
+ let task_id = utils.getTriggerTaskID();
87
+ if (task_id) {
88
+ config.json[headers.triggerTaskId] = task_id;
89
+ }
90
+
91
+ let loopCtx = nodeCls.get(loopCtxKey);
92
+ if (checkLoopCtx(loopCtx)) {
93
+ config.json[loopMasksKey] = loopCtx.loopMasks;
94
+ if ((handlerFunc !== "" && config.json[loopMasksKey].includes(handlerFunc)) ||
95
+ (progressCallbackFunc != "" && config.json[loopMasksKey].includes(progressCallbackFunc)) ||
96
+ (completedCallbackFunc != "" && config.json[loopMasksKey].includes(completedCallbackFunc))) {
97
+ throw new exceptions.InvalidParamError(`Task execution forms a loop.`);
98
+ }
99
+ }
100
+
101
+ return await faasinfra.doRequest(null, urlPath, config);
102
+ }
103
+
104
+ async invokeMicroserviceSync(apiName: string, path: string, method: string, body: any): Promise<any> {
105
+ let reqPath = faasinfraHttpPath.invokeMicroserviceSync;
106
+
107
+ let options = commonHttp.getOptions(null, reqPath);
108
+ let urlPath = options._reqPath.replace(replaceKeys.namespace, utils.getNamespaceFromCtx());
109
+
110
+ options.json = {
111
+ "microserviceId": apiName,
112
+ "path": path,
113
+ "method": method,
114
+ "query": parseQueryParams(path),
115
+ }
116
+
117
+ // 处理 body 参数
118
+ if (method.toUpperCase() !== "GET") {
119
+ options.json.body = JSON.stringify(body);
120
+ }
121
+
122
+ return await faasinfra.doRequest(null, urlPath, options);
123
+ }
124
+
125
+ async invokeMicroserviceAsync(apiName: string, path: string, method: string, body: any): Promise<any> {
126
+ let reqPath = faasinfraHttpPath.invokeMicroserviceAsync;
127
+
128
+ let options = commonHttp.getOptions(null, reqPath);
129
+ let urlPath = options._reqPath.replace(replaceKeys.namespace, utils.getNamespaceFromCtx());
130
+
131
+ options.json = {
132
+ "microserviceId": apiName,
133
+ "path": path,
134
+ "method": method,
135
+ "query": parseQueryParams(path),
136
+ }
137
+
138
+ // 处理 body 参数
139
+ if (method.toUpperCase() !== "GET") {
140
+ options.json.body = JSON.stringify(body);
141
+ }
142
+
143
+ return await faasinfra.doRequest(null, urlPath, options);
144
+ }
145
+
146
+ }
147
+
148
+
149
+ function getDebugExtraInfo() {
150
+ let extra: Record<string, string> = {
151
+ "FunctionFrameVersion": "FunctionFrameV2",
152
+ };
153
+ if (utils.isDebug()) {
154
+ extra.DebugInfo = utils.getDebugCode();
155
+ }
156
+
157
+ return extra
158
+ }
159
+
160
+ function checkLoopCtx(reqCtx: any): any {
161
+ return reqCtx && reqCtx.loopMasks && Array.isArray(reqCtx.loopMasks)
162
+ }
163
+
164
+ function parseQueryParams(path: string): Record<string, string[]> {
165
+ let params: Record<string, string[]> = {};
166
+
167
+ let url = new URL(path, "https://aa.bb.cc");
168
+ for (let [k, v] of url.searchParams.entries()) {
169
+ if (typeof (k) !== "string") {
170
+ throw new InternalError(`The type of k should be string, but ${typeof (k)}`);
171
+ }
172
+ if (typeof (v) !== "string") {
173
+ throw new InternalError(`The type of v should be string, but ${typeof (v)}`);
174
+ }
175
+
176
+ params[k] = v.split(",");
177
+ }
178
+
179
+ if (Object.keys(params).length === 0) {
180
+ return undefined;
181
+ }
182
+ return params;
183
+ }
184
+
185
+ /*
186
+ export async function invokeFuncSync(apiName: string, params: any, oldFuncName: string, isSync: boolean) {
187
+ let result = await invokeFunc(apiName, params, oldFuncName, isSync);
188
+ if (result && result.code === "0") {
189
+ return result.data;
190
+ }
191
+ return result;
192
+ }
193
+
194
+ async function invokeFunc(apiName: string, params: any, oldFuncName: string, isSync = false) {
195
+ let reqPath = faasinfraHttpPath.createAsyncTask;
196
+ if (isSync) {
197
+ reqPath = faasinfraHttpPath.invokeFuncSync;
198
+ }
199
+
200
+ let options = commonHttp.getOptions(null, reqPath);
201
+ let urlPath = options._reqPath.replace(replaceKeys.namespace, utils.getNamespaceFromCtx());
202
+
203
+ let triggerCtx: Record<string, any> = {};
204
+ let task_id = utils.getTriggerTaskID();
205
+ if (task_id) {
206
+ triggerCtx[headers.triggerTaskId] = task_id;
207
+ }
208
+
209
+ let temp = utils.getDistributedHandleMask();
210
+ if (temp) {
211
+ triggerCtx[distributedHandleMask] = temp;
212
+ }
213
+
214
+ let reqCtx = nodeCls.get(loopCtxKey);
215
+ if (checkLoopCtx(reqCtx)) {
216
+ triggerCtx[loopMasks] = reqCtx.loopMasks
217
+ }
218
+
219
+ // 相等时,表示是新版本函数的场景
220
+ if (apiName === oldFuncName) {
221
+ options.json = {
222
+ "apiAlias": apiName,
223
+ "params": JSON.stringify(params),
224
+ "context": JSON.stringify(triggerCtx),
225
+ "triggerType": utils.getTriggerType(),
226
+ }
227
+ } else {
228
+ options.json = {
229
+ "function_name": apiName,
230
+ "params": JSON.stringify(params),
231
+ "context": JSON.stringify(triggerCtx),
232
+ "triggerType": utils.getTriggerType(),
233
+ }
234
+ }
235
+
236
+ if (utils.isMicroservice()) {
237
+ options.json.apiAlias = oldFuncName;
238
+ }
239
+
240
+ return await faasinfra.doRequest(null, urlPath, options);
241
+ }
242
+
243
+ export async function asyncTask(apiName: string, params: any) {
244
+ // 检查函数是否存在
245
+ utils.requireFunction(apiName);
246
+
247
+ let reqPath = faasinfraHttpPath.createAsyncTaskV2;
248
+ let options = commonHttp.getOptions(null, reqPath);
249
+ let urlPath = options._reqPath.replace(replaceKeys.namespace, utils.getNamespaceFromCtx());
250
+
251
+ let triggerCtx: Record<string, any> = {};
252
+ let task_id = utils.getTriggerTaskID();
253
+ if (task_id) {
254
+ triggerCtx[headers.triggerTaskId] = task_id;
255
+ }
256
+
257
+ let temp = utils.getDistributedHandleMask();
258
+ if (temp) {
259
+ triggerCtx[distributedHandleMask] = temp;
260
+ }
261
+
262
+ let reqCtx = nodeCls.get(loopCtxKey);
263
+ if (checkLoopCtx(reqCtx)) {
264
+ triggerCtx[loopMasks] = reqCtx.loopMasks
265
+ }
266
+
267
+ options.json = {
268
+ "api_name": apiName,
269
+ "params": JSON.stringify(params),
270
+ "context": JSON.stringify(triggerCtx),
271
+ "triggerType": utils.getTriggerType(),
272
+ "extra": getDebugExtraInfo()
273
+ }
274
+
275
+ return await faasinfra.doRequest(null, urlPath, options);
276
+ }
277
+
278
+ export async function createDistributedTaskV1(dataset: any, handlerFunc: string, progressCallbackFunc: string, completedCallbackFunc: string, options: _Options):
279
+ Promise<number> {
280
+ // 1.获取 options
281
+ let config = commonHttp.getOptions(null, faasinfraHttpPath.createDistributedTask);
282
+
283
+ // 2.构造url
284
+ let urlPath = config._reqPath.replace(replaceKeys.namespace, utils.getNamespaceFromCtx());
285
+
286
+ // 3.请求
287
+ config.json = {
288
+ "domainName": utils.getTenantNameFromCtx(),
289
+ "namespace": utils.getNamespaceFromCtx(),
290
+ "userId": utils.getUserIDFromCtx(),
291
+
292
+ "dataset": dataset,
293
+ "handlerFunc": handlerFunc,
294
+ "progressCallbackFunc": progressCallbackFunc,
295
+ "completedCallbackFunc": completedCallbackFunc,
296
+ "options": options
297
+ }
298
+
299
+ let task_id = utils.getTriggerTaskID();
300
+ if (task_id) {
301
+ config.json[headers.triggerTaskId] = task_id;
302
+ }
303
+
304
+ let loopCtx = nodeCls.get(loopCtxKey);
305
+ if (checkLoopCtx(loopCtx)) {
306
+ config.json[loopMasksKey] = loopCtx.loopMasks;
307
+ if (!utils.isMicroservice() && (handlerFunc !== "" && config.json[loopMasksKey].includes(utils.handleFuncName({}, handlerFunc))) ||
308
+ (progressCallbackFunc != "" && config.json[loopMasksKey].includes(utils.handleFuncName({}, progressCallbackFunc))) ||
309
+ (completedCallbackFunc != "" && config.json[loopMasksKey].includes(utils.handleFuncName({}, completedCallbackFunc)))) {
310
+ throw new exceptions.InvalidParamError(`Task execution forms a loop.`);
311
+ }
312
+ }
313
+
314
+ return await faasinfra.doRequest(null, urlPath, config);
315
+ }
316
+
317
+ export async function createDistributedTask(dataset: any, handlerFunc: string, progressCallbackFunc: string, completedCallbackFunc: string, options: _Options): Promise<number> {
318
+ if (utils.isOnlineDev()) {
319
+ return await createDistributedTaskV1(dataset, handlerFunc, progressCallbackFunc, completedCallbackFunc, options);
320
+ }
321
+ // 检查函数是否存在
322
+ utils.requireFunction(handlerFunc);
323
+
324
+ // 1.获取 options
325
+ let config = commonHttp.getOptions(null, faasinfraHttpPath.createDistributedTaskV2);
326
+
327
+ // 2.构造url
328
+ let urlPath = config._reqPath.replace(replaceKeys.namespace, utils.getNamespaceFromCtx());
329
+
330
+ // 3.请求
331
+ config.json = {
332
+ "domainName": utils.getTenantNameFromCtx(),
333
+ "namespace": utils.getNamespaceFromCtx(),
334
+ "userId": utils.getUserIDFromCtx(),
335
+
336
+ "dataset": dataset,
337
+ "handlerFunc": handlerFunc,
338
+ "progressCallbackFunc": progressCallbackFunc,
339
+ "completedCallbackFunc": completedCallbackFunc,
340
+ "options": options,
341
+ "extra": getDebugExtraInfo()
342
+ }
343
+
344
+ let task_id = utils.getTriggerTaskID();
345
+ if (task_id) {
346
+ config.json[headers.triggerTaskId] = task_id;
347
+ }
348
+
349
+ let loopCtx = nodeCls.get(loopCtxKey);
350
+ if (checkLoopCtx(loopCtx)) {
351
+ config.json[loopMasksKey] = loopCtx.loopMasks;
352
+ if ((handlerFunc !== "" && config.json[loopMasksKey].includes(handlerFunc)) ||
353
+ (progressCallbackFunc != "" && config.json[loopMasksKey].includes(progressCallbackFunc)) ||
354
+ (completedCallbackFunc != "" && config.json[loopMasksKey].includes(completedCallbackFunc))) {
355
+ throw new exceptions.InvalidParamError(`Task execution forms a loop.`);
356
+ }
357
+ }
358
+
359
+ return await faasinfra.doRequest(null, urlPath, config);
360
+ }
361
+
362
+ export async function invokeMicroserviceSync(apiName: string, path: string, method: string, body: any) {
363
+ return await invokeMicroservice(apiName, path, method, body, true);
364
+ }
365
+
366
+ export async function invokeMicroserviceAsync(apiName: string, path: string, method: string, body: any) {
367
+ return await invokeMicroservice(apiName, path, method, body, false);
368
+ }
369
+
370
+ async function invokeMicroservice(apiName: string, path: string, method: string, body: any, isSync = false) {
371
+ let reqPath = faasinfraHttpPath.invokeMicroserviceAsync;
372
+ if (isSync) {
373
+ reqPath = faasinfraHttpPath.invokeMicroserviceSync;
374
+ }
375
+
376
+ let options = commonHttp.getOptions(null, reqPath);
377
+ let urlPath = options._reqPath.replace(replaceKeys.namespace, utils.getNamespaceFromCtx());
378
+
379
+ options.json = {
380
+ "microserviceId": apiName,
381
+ "path": path,
382
+ "method": method,
383
+ "query": parseQueryParams(path),
384
+ }
385
+
386
+ // 处理 body 参数
387
+ if (method.toUpperCase() !== "GET") {
388
+ options.json.body = JSON.stringify(body);
389
+ }
390
+
391
+ return await faasinfra.doRequest(null, urlPath, options);
392
+ }
393
+ */
@@ -0,0 +1,67 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import { Stream } from "stream";
4
+ import { Order } from "../context/db/impl/order";
5
+ import { Criterion } from "../kunlun/operator/impl/logic";
6
+ import { IInnerAPIRequest, OpenSDKGetRecordsReq, UploadFileResp } from "./interface";
7
+ import { ExecutionInfo, ExecutionResult, RevokeExecutionOptions } from "@byted-apaas/server-common-node/context/workflow/workflow";
8
+ import { AppCtx } from "../application/application";
9
+ export declare class RequestRpc implements IInnerAPIRequest {
10
+ constructor();
11
+ createRecordBySync(objectApiName: string, record: object): any;
12
+ updateRecordBySync(objectApiName: string, recordID: number, record: object): any;
13
+ deleteRecordBySync(objectApiName: string, recordID: number): any;
14
+ createRecordsByAsync(objectApiName: string, records: object[]): any;
15
+ updateRecordsByAsync(objectApiName: string, recordMap: Record<number, object>): any;
16
+ deleteRecordsByAsync(objectApiName: string, recordIDs: number[]): any;
17
+ createRecordsBySync(objectApiName: string, records: object[]): any;
18
+ updateRecordsBySync(objectApiName: string, recordMap: Record<number, object>): any;
19
+ deleteRecordsBySync(objectApiName: string, recordIDs: number[]): any;
20
+ getRecordsOrCountByCriterion(objectApiName: string, criterion: string | Criterion, order: Order[], ignoreBackLookupField: boolean, fieldApiNames: string[], offset: number, limit: number, needCount: boolean): any;
21
+ updateWorkflowVariables(ctx: any, instanceId: number, variables: object, variableTypes: object): Promise<void>;
22
+ uploadFile(data: Stream, expire: number): Promise<UploadFileResp>;
23
+ downloadFileByID(fileID: string, filePath?: string): Promise<Buffer | void>;
24
+ downloadFileByToken(fileToken: string, filePath?: string): Promise<Buffer | void>;
25
+ createMessage(msg: any): Promise<number>;
26
+ updateMessage(msgId: number, msg: any): Promise<void>;
27
+ getFields(objectApiName: string): Promise<any>;
28
+ getField(objectApiName: string, fieldApiName: string): Promise<any>;
29
+ terminateWorkflowInstance(workflowInstanceId: number, operator: number, reason: string): Promise<void>;
30
+ modifyRecordsWithTransaction(placeholders: Record<string, number>, operations: object[]): Promise<Map<string, number>>;
31
+ getGlobalConfigByKey<valueT>(key: string): Promise<valueT>;
32
+ oql(oql: string, args: any[], namedArgs: Record<string, any>): Promise<string | any[]>;
33
+ invokeFuncSync(idOrName: {
34
+ APIId?: string;
35
+ APIName?: string;
36
+ isInvokeByAPIName: boolean;
37
+ }, params: any): Promise<any>;
38
+ invokeFuncWithAuth(idOrName: {
39
+ APIId?: string;
40
+ APIName?: string;
41
+ isInvokeByAPIName: boolean;
42
+ }, params: any): Promise<any>;
43
+ createAsyncTaskV1(idOrName: {
44
+ APIId?: string;
45
+ APIName?: string;
46
+ isInvokeByAPIName: boolean;
47
+ }, params: any): Promise<any>;
48
+ createAsyncTaskV2(name: string, params: any): Promise<any>;
49
+ getExecutionUserTaskInfo(executionId: bigint): Promise<any>;
50
+ executeFlow(APIName: string, options: any): Promise<ExecutionResult>;
51
+ revokeExecution(executionId: number, revokeOptions: RevokeExecutionOptions): Promise<void>;
52
+ getExecutionInfo(executionId: number): Promise<ExecutionInfo>;
53
+ getTenantInfo(appCtx: AppCtx): Promise<any>;
54
+ openSDKCreateRecordBySync(objectApiName: string, record: object): any;
55
+ openSDKUpdateRecordBySync(objectApiName: string, recordID: number, record: object): any;
56
+ openSDKDeleteRecordBySync(objectApiName: string, recordID: number): any;
57
+ openSDKCreateRecordsBySync(objectApiName: string, records: object[]): any;
58
+ openSDKUpdateRecordsBySync(objectApiName: string, recordMap: Record<number, object>): any;
59
+ openSDKDeleteRecordsBySync(objectApiName: string, recordIDs: number[]): any;
60
+ openSDKGetRecords(objectApiName: string, param: OpenSDKGetRecordsReq): void;
61
+ openSDKUploadFile(fileName: string, data: Buffer): any;
62
+ openSDKUploadAvatar(fileName: string, data: Buffer): any;
63
+ openSDKDownloadAvatar(imageID: string): any;
64
+ }
65
+ export declare function revokeExecution(executionId: number, revokeOptions: RevokeExecutionOptions): Promise<void>;
66
+ export declare function getExecutionInfo(executionId: number): Promise<ExecutionInfo>;
67
+ export declare function getExecutionUserTaskInfo(executionId: bigint): Promise<any>;