@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
package/data/index.js ADDED
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ ;
4
+ ;
package/data/index.ts ADDED
@@ -0,0 +1,30 @@
1
+ export interface workflowVariables { };
2
+ export type globalFuncNames = "a" | "b"
3
+
4
+ export interface globalVariablesMap {
5
+ a: string,
6
+ b: string
7
+ };
8
+ export type globalVariables = keyof globalVariablesMap;
9
+
10
+ export interface metadataMap {
11
+ /**
12
+ * @description 用户
13
+ */
14
+ _user: User,
15
+ _department: Department,
16
+ }
17
+
18
+ export type currentObjApiName = "_user"
19
+
20
+ interface User {
21
+ _name: string,
22
+ _id: number
23
+ _department: Department,
24
+ }
25
+
26
+ interface Department {
27
+ _id: number,
28
+ _name: string,
29
+ _superior: Department,
30
+ }
package/hooks/api.d.ts ADDED
@@ -0,0 +1,61 @@
1
+ import * as common from "@byted-apaas/server-common-node";
2
+ import { IGfCtx } from "@byted-apaas/server-common-node/context/IContext";
3
+ import { Tasks } from "../context/tasks/tasks";
4
+ import { DB } from "../context/db/impl/db";
5
+ import { _Resources } from "../context/resources/impl/resources";
6
+ import { Message } from "../context/msg/msg";
7
+ import { IMetaData } from "../context/metadata/metadata";
8
+ declare type invokeGlobalFuncT = (funcNames: string) => {
9
+ invoke: (params?: any) => Promise<any>;
10
+ };
11
+ export declare function getFunctionSync(context?: any, logger?: common.Logger): invokeGlobalFuncT;
12
+ export declare function setRespHeader(): () => void;
13
+ export declare function toString(value: any): string;
14
+ export declare function setRedirectLocation(context: any): (location: string) => void;
15
+ export declare function method(): string;
16
+ export declare function mountMetadata(context: any): void;
17
+ export declare function mountWorkflowFeature(context: any): void;
18
+ export declare function terminateWorkflow(): (workflowInstanceId: number, options: any) => Promise<void>;
19
+ export declare function mockFlowFeature(context: any): any;
20
+ export declare function invokeMicroservice(): (apiName: string) => {
21
+ /**
22
+ * 同步调用微服务
23
+ * @param path 请求路径,如:/ping
24
+ * @param method 请求方法,默认为 GET
25
+ * @param params 请求参数,默认为 undefined
26
+ */
27
+ invoke: (path: string, method?: string, params?: any) => Promise<any>;
28
+ /**
29
+ * 异步调用微服务
30
+ * @param path 请求路径,如:/ping
31
+ * @param method 请求方法,默认为 GET
32
+ * @param params 请求参数,默认为 undefined
33
+ */
34
+ invokeAsync: (path: string, method?: string, params?: any) => Promise<any>;
35
+ };
36
+ export declare const db: DB<IGfCtx, import("../data").metadataMap>;
37
+ export declare const resources: _Resources;
38
+ export declare const msg: Message;
39
+ export declare const tasks: Tasks<unknown>;
40
+ export declare const cloudfunction: invokeGlobalFuncT;
41
+ export declare const microservice: (apiName: string) => {
42
+ /**
43
+ * 同步调用微服务
44
+ * @param path 请求路径,如:/ping
45
+ * @param method 请求方法,默认为 GET
46
+ * @param params 请求参数,默认为 undefined
47
+ */
48
+ invoke: (path: string, method?: string, params?: any) => Promise<any>;
49
+ /**
50
+ * 异步调用微服务
51
+ * @param path 请求路径,如:/ping
52
+ * @param method 请求方法,默认为 GET
53
+ * @param params 请求参数,默认为 undefined
54
+ */
55
+ invokeAsync: (path: string, method?: string, params?: any) => Promise<any>;
56
+ };
57
+ export declare const workflow: {
58
+ terminate: (workflowInstanceId: number, options: any) => Promise<void>;
59
+ };
60
+ export declare const metaData: IMetaData<{}>;
61
+ export { Application } from "../application/impl/impl";
package/hooks/api.js ADDED
@@ -0,0 +1,327 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Application = exports.metaData = exports.workflow = exports.microservice = exports.cloudfunction = exports.tasks = exports.msg = exports.resources = exports.db = exports.invokeMicroservice = exports.mockFlowFeature = exports.terminateWorkflow = exports.mountWorkflowFeature = exports.mountMetadata = exports.method = exports.setRedirectLocation = exports.toString = exports.setRespHeader = exports.getFunctionSync = void 0;
4
+ const common = require("@byted-apaas/server-common-node");
5
+ const exceptions_1 = require("@byted-apaas/server-common-node/utils/exceptions");
6
+ const api = require("../hooks/api");
7
+ const metadataApi = require("../context/metadata/metadata");
8
+ const tasks_1 = require("../context/tasks/tasks");
9
+ const db_1 = require("../context/db/impl/db");
10
+ const resources_1 = require("../context/resources/impl/resources");
11
+ const msg_1 = require("../context/msg/msg");
12
+ const Request = require("../request/interface");
13
+ const constants = require("../constants/constants");
14
+ const utils_1 = require("@byted-apaas/server-common-node/utils/utils");
15
+ const metadata_1 = require("../context/metadata/metadata");
16
+ const nodeCls = require("node-cls");
17
+ const nodeClsCtx = common.nodeClsCtx;
18
+ const exceptions = common.exceptions;
19
+ const utils = common.utils;
20
+ const checkUtils = common.checkUtils;
21
+ const functionSources = common.constants.functionSources;
22
+ // 同步调用云函数
23
+ function getFunctionSync(context, logger) {
24
+ return (funcName) => {
25
+ if (utils.isOnlineDev()) {
26
+ let oldFuncName = funcName;
27
+ if (!utils.isMicroservice()) {
28
+ funcName = utils.handleFuncName(null, funcName);
29
+ if (!funcName) {
30
+ throw new exceptions.InvalidParamError(`The function (${oldFuncName}) does not exist, please confirm ${oldFuncName} exists and has been deployed.`);
31
+ }
32
+ }
33
+ else {
34
+ funcName = undefined;
35
+ }
36
+ let idOrName = {};
37
+ // 2.0 通过 apiAlias 触发
38
+ if (funcName === oldFuncName) {
39
+ idOrName = {
40
+ APIName: funcName,
41
+ isInvokeByAPIName: true,
42
+ };
43
+ }
44
+ else if (utils.isMicroservice()) {
45
+ // 微服务
46
+ idOrName = {
47
+ APIName: oldFuncName,
48
+ isInvokeByAPIName: true,
49
+ };
50
+ }
51
+ else { // 1.0 通过 apiID 触发
52
+ idOrName = {
53
+ APIId: funcName,
54
+ isInvokeByAPIName: false,
55
+ };
56
+ }
57
+ return {
58
+ invoke: async (params) => {
59
+ // 微服务的场景
60
+ if (utils.isMicroservice()) {
61
+ return await Request.GetInstance().invokeFuncSync(idOrName, params);
62
+ }
63
+ else {
64
+ let func = utils.getGlobalFunc(null, funcName);
65
+ if (!func) {
66
+ // 改为远程调用
67
+ return await Request.GetInstance().invokeFuncSync(idOrName, params);
68
+ }
69
+ let loopMasks = [funcName];
70
+ let reqCtx = nodeCls.get("loopCtx");
71
+ if (reqCtx && reqCtx.loopMasks && Array.isArray(reqCtx.loopMasks)) {
72
+ if (reqCtx.loopMasks.includes(funcName)) {
73
+ throw new exceptions.InvalidParamError(`Task execution forms a loop.`);
74
+ }
75
+ loopMasks.push(...reqCtx.loopMasks);
76
+ }
77
+ // 修改 source 全局函数
78
+ let ctx = nodeCls.create("loopCtx");
79
+ ctx.loopMasks = loopMasks;
80
+ return await ctx.run(async () => {
81
+ const dynCtx = nodeClsCtx.getDynCtx();
82
+ dynCtx.source = functionSources.globalFunction;
83
+ return await dynCtx.run(async () => {
84
+ return await common.hooks.invoke(func, params, context, logger);
85
+ });
86
+ });
87
+ }
88
+ }
89
+ };
90
+ }
91
+ return {
92
+ invoke: async (params) => {
93
+ let func = (0, utils_1.getRequireFunc)()(funcName);
94
+ if (!func) {
95
+ throw new exceptions.InvalidParamError(`The function (${funcName}) does not exist.`);
96
+ }
97
+ let loopMasks = [funcName];
98
+ let reqCtx = nodeCls.get("loopCtx");
99
+ if (reqCtx && reqCtx.loopMasks && Array.isArray(reqCtx.loopMasks)) {
100
+ if (reqCtx.loopMasks.includes(funcName)) {
101
+ throw new exceptions.InvalidParamError(`Task execution forms a loop.`);
102
+ }
103
+ loopMasks.push(...reqCtx.loopMasks);
104
+ }
105
+ // 修改 source 全局函数
106
+ let ctx = nodeCls.create("loopCtx");
107
+ ctx.loopMasks = loopMasks;
108
+ return await ctx.run(async () => {
109
+ const dynCtx = nodeClsCtx.getDynCtx();
110
+ dynCtx.source = functionSources.globalFunction;
111
+ return await dynCtx.run(async () => {
112
+ return await common.hooks.invoke(func, params, context, logger);
113
+ });
114
+ });
115
+ }
116
+ };
117
+ };
118
+ }
119
+ exports.getFunctionSync = getFunctionSync;
120
+ // 设置请求头
121
+ function setRespHeader() {
122
+ return function () {
123
+ switch (arguments.length) {
124
+ case 1:
125
+ if (checkUtils.isObject(arguments[0])) {
126
+ try {
127
+ for (let k of Object.keys(arguments[0])) {
128
+ utils.setHttpHeaders(k, toString(arguments[0][k]));
129
+ }
130
+ }
131
+ catch (err) {
132
+ throw new exceptions.InternalError(err.message);
133
+ }
134
+ }
135
+ else {
136
+ throw new exceptions.InvalidParamError("setResponseHeaders param is not a object");
137
+ }
138
+ break;
139
+ case 2:
140
+ try {
141
+ utils.setHttpHeaders(arguments[0], toString(arguments[1]));
142
+ }
143
+ catch (err) {
144
+ throw new exceptions.InternalError(err.message);
145
+ }
146
+ break;
147
+ default:
148
+ throw new exceptions.InvalidParamError("the number of setResponseHeaders param is 1 or 2");
149
+ }
150
+ };
151
+ }
152
+ exports.setRespHeader = setRespHeader;
153
+ function toString(value) {
154
+ if (value instanceof Array) {
155
+ let arr = [];
156
+ for (let v of value) {
157
+ if (typeof v === "string") {
158
+ arr.push(v);
159
+ }
160
+ else {
161
+ arr.push(utils.stringify(v));
162
+ }
163
+ }
164
+ return arr.join(", ");
165
+ }
166
+ else if (typeof value === "string") {
167
+ return value;
168
+ }
169
+ return utils.stringify(value);
170
+ }
171
+ exports.toString = toString;
172
+ function setRedirectLocation(context) {
173
+ return function (location) {
174
+ context.setResponseHeader(constants.httpHeaderKeys.location, location);
175
+ context.setResponseHeader(constants.httpHeaderKeys.statusCode, String(constants.httpStatusCodes.redirect));
176
+ };
177
+ }
178
+ exports.setRedirectLocation = setRedirectLocation;
179
+ // 请求方法
180
+ function method() {
181
+ return utils.getHttpMethod();
182
+ }
183
+ exports.method = method;
184
+ function mountMetadata(context) {
185
+ // 1.挂载metadata
186
+ context.metadata = metadataApi.metadata(context);
187
+ // 2.挂载metaType
188
+ if (!global.kunlun) {
189
+ global.kunlun = {};
190
+ }
191
+ global.kunlun.metaType = metadataApi.metaType();
192
+ }
193
+ exports.mountMetadata = mountMetadata;
194
+ function mountWorkflowFeature(context) {
195
+ if (context && context.workflow) {
196
+ context.workflow.updateVariable = common.updateVariable(context, Request.GetInstance().updateWorkflowVariables);
197
+ }
198
+ else {
199
+ context.workflow = {};
200
+ }
201
+ // 此处挂载保证了 terminate 存在
202
+ context.workflow.terminate = terminateWorkflow();
203
+ }
204
+ exports.mountWorkflowFeature = mountWorkflowFeature;
205
+ function terminateWorkflow() {
206
+ return async (workflowInstanceId, options) => {
207
+ let operator = utils.getUser()._id, reason = null;
208
+ if (options && options.reason) {
209
+ // instanceof 改动5
210
+ // if (options.reason instanceof common.fieldType.Multilingual) {
211
+ if (common.fieldType.isKFieldTypeMultilingual(options.reason)) {
212
+ reason = options.reason.toString();
213
+ }
214
+ else {
215
+ reason = new common.fieldType.Multilingual(options.reason).toString();
216
+ }
217
+ }
218
+ await Request.GetInstance().terminateWorkflowInstance(workflowInstanceId, operator, reason);
219
+ };
220
+ }
221
+ exports.terminateWorkflow = terminateWorkflow;
222
+ function mockFlowFeature(context) {
223
+ if (!context.flow) {
224
+ context.flow = {};
225
+ }
226
+ context.flow.updateVariable = common.updateVariable(context, Request.GetInstance().updateWorkflowVariables);
227
+ context.flow.getExecutionUserTaskInfo = mockGetExecutionUserTaskInfo();
228
+ context.flow.execute = mockExecuteFlow();
229
+ context.flow.revokeExecution = mockRevokeExecution();
230
+ context.flow.getExecutionInfo = mockGetExecutionInfo();
231
+ return context.flow;
232
+ }
233
+ exports.mockFlowFeature = mockFlowFeature;
234
+ function mockGetExecutionUserTaskInfo() {
235
+ return async (executionId) => {
236
+ if (!executionId || typeof executionId !== "number") {
237
+ throw new exceptions_1.InvalidParamError(`param's type (${executionId}) need number, but is ${typeof executionId}`);
238
+ }
239
+ return await Request.GetInstance().getExecutionUserTaskInfo(executionId);
240
+ };
241
+ }
242
+ function mockExecuteFlow() {
243
+ return async (APIName, options) => {
244
+ if (!APIName || typeof APIName !== "string") {
245
+ throw new exceptions_1.InvalidParamError(`param's type (${APIName}) need string, but is ${typeof APIName}`);
246
+ }
247
+ if (options && options.params && checkUtils.isNotObject(options.params)) {
248
+ throw new exceptions_1.InvalidParamError(`options.params's type (${options}) need object, but is ${Array.isArray(options) ? "array" : typeof options.params}`);
249
+ }
250
+ if (!options) {
251
+ options = {};
252
+ }
253
+ return await Request.GetInstance().executeFlow(APIName, options);
254
+ };
255
+ }
256
+ function mockRevokeExecution() {
257
+ return async (executionId, options) => {
258
+ if (!executionId || typeof executionId !== "number") {
259
+ throw new exceptions_1.InvalidParamError(`param's type (${executionId}) is need number, but is ${typeof executionId}`);
260
+ }
261
+ return await Request.GetInstance().revokeExecution(executionId, options);
262
+ };
263
+ }
264
+ function mockGetExecutionInfo() {
265
+ return async (executionId) => {
266
+ if (!executionId || typeof executionId !== "number") {
267
+ throw new exceptions_1.InvalidParamError(`param's type (${executionId}) is not matched to number, but is ${typeof executionId}`);
268
+ }
269
+ return await Request.GetInstance().getExecutionInfo(executionId);
270
+ };
271
+ }
272
+ function invokeMicroservice() {
273
+ /**
274
+ * 微服务
275
+ * @param apiName 微服务的名称
276
+ */
277
+ return function (apiName) {
278
+ if (!apiName || typeof (apiName) !== "string") {
279
+ throw new exceptions_1.InvalidParamError(`The apiName (${apiName}) is invalid and should be a non-empty field string.`);
280
+ }
281
+ return {
282
+ /**
283
+ * 同步调用微服务
284
+ * @param path 请求路径,如:/ping
285
+ * @param method 请求方法,默认为 GET
286
+ * @param params 请求参数,默认为 undefined
287
+ */
288
+ invoke: async function (path, method = "GET", params = undefined) {
289
+ if (!path || typeof (path) !== "string") {
290
+ throw new exceptions_1.InvalidParamError(`The path (${path}) is invalid and should be a non-empty field string.`);
291
+ }
292
+ if (!method || typeof (method) !== "string") {
293
+ throw new exceptions_1.InvalidParamError(`The method (${method}) is invalid and should be a non-empty field string.`);
294
+ }
295
+ return await Request.GetFaaSInfraInstance().invokeMicroserviceSync(apiName, path, method, params);
296
+ },
297
+ /**
298
+ * 异步调用微服务
299
+ * @param path 请求路径,如:/ping
300
+ * @param method 请求方法,默认为 GET
301
+ * @param params 请求参数,默认为 undefined
302
+ */
303
+ invokeAsync: async function (path, method = "GET", params = undefined) {
304
+ if (!path || typeof (path) !== "string") {
305
+ throw new exceptions_1.InvalidParamError(`The path (${path}) is invalid and should be a non-empty field string.`);
306
+ }
307
+ if (!method || typeof (method) !== "string") {
308
+ throw new exceptions_1.InvalidParamError(`The method (${method}) is invalid and should be a non-empty field string.`);
309
+ }
310
+ return await Request.GetFaaSInfraInstance().invokeMicroserviceAsync(apiName, path, method, params);
311
+ },
312
+ };
313
+ };
314
+ }
315
+ exports.invokeMicroservice = invokeMicroservice;
316
+ exports.db = new db_1.DB();
317
+ exports.resources = new resources_1._Resources();
318
+ exports.msg = new msg_1.Message();
319
+ exports.tasks = new tasks_1.Tasks();
320
+ exports.cloudfunction = api.getFunctionSync();
321
+ exports.microservice = api.invokeMicroservice();
322
+ exports.workflow = {
323
+ terminate: terminateWorkflow(),
324
+ };
325
+ exports.metaData = new metadata_1.MetaData(null);
326
+ var impl_1 = require("../application/impl/impl");
327
+ Object.defineProperty(exports, "Application", { enumerable: true, get: function () { return impl_1.Application; } });