@byted-apaas/server-sdk-node 1.1.20-beta.9 → 1.1.20
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/global/application/flow/flow.d.ts +3 -2
- package/global/application/flow/impl/flow.d.ts +1 -1
- package/global/application/flow/impl/flow.js +4 -4
- package/hooks/api.d.ts +1 -1
- package/hooks/api.js +4 -4
- package/package.json +2 -2
- package/request/interface.d.ts +1 -1
- package/request/openapi.d.ts +2 -2
- package/request/openapi.js +10 -6
|
@@ -8,12 +8,13 @@ export interface Flow {
|
|
|
8
8
|
getExecutionUserTaskInfo: (executionId: number) => Promise<FlowTaskInfo[]>;
|
|
9
9
|
/**
|
|
10
10
|
* 执行流程
|
|
11
|
-
* @param
|
|
11
|
+
* @param apiName 流程的 APIName
|
|
12
12
|
* @param options 流程执行选项
|
|
13
|
+
* @param async 是否异步执行
|
|
13
14
|
* - params 流程入参
|
|
14
15
|
* @constructor
|
|
15
16
|
*/
|
|
16
|
-
execute: (
|
|
17
|
+
execute: (apiName: string, options?: ExecuteOptions, async?: boolean) => Promise<ExecutionResult>;
|
|
17
18
|
/**
|
|
18
19
|
* 撤销流程实例 (仅支持撤销包含人工任务的流程实例)
|
|
19
20
|
* @param executionId 流程实例 Id
|
|
@@ -11,7 +11,7 @@ export declare class Flow implements IFlow {
|
|
|
11
11
|
*/
|
|
12
12
|
instanceId: number;
|
|
13
13
|
constructor(flowParams: any);
|
|
14
|
-
execute(
|
|
14
|
+
execute(apiName: string, options: ExecuteOptions | undefined, async?: boolean | undefined): Promise<ExecutionResult>;
|
|
15
15
|
getExecutionInfo(executionId: number): Promise<ExecutionInfo>;
|
|
16
16
|
getExecutionUserTaskInfo(executionId: number): Promise<FlowTaskInfo[]>;
|
|
17
17
|
revokeExecution(executionId: number, options: RevokeExecutionOptions): Promise<void>;
|
|
@@ -10,9 +10,9 @@ class Flow {
|
|
|
10
10
|
this.apiName = flowParams?.apiName;
|
|
11
11
|
this.instanceId = flowParams?.instanceId;
|
|
12
12
|
}
|
|
13
|
-
async execute(
|
|
14
|
-
if (!
|
|
15
|
-
throw new exceptions_1.InvalidParamError(`param's type (${
|
|
13
|
+
async execute(apiName, options, async) {
|
|
14
|
+
if (!apiName || typeof apiName !== 'string') {
|
|
15
|
+
throw new exceptions_1.InvalidParamError(`param's type (${apiName}) need string, but is ${typeof apiName}`);
|
|
16
16
|
}
|
|
17
17
|
if (options && options.params && server_common_node_1.checkUtils.isNotObject(options.params)) {
|
|
18
18
|
throw new exceptions_1.InvalidParamError(`options.params's type (${options}) need object, but is ${Array.isArray(options) ? 'array' : typeof options.params}`);
|
|
@@ -20,7 +20,7 @@ class Flow {
|
|
|
20
20
|
if (!options) {
|
|
21
21
|
options = {};
|
|
22
22
|
}
|
|
23
|
-
return await Request.GetInstance().executeFlow(
|
|
23
|
+
return await Request.GetInstance().executeFlow(apiName, options, async);
|
|
24
24
|
}
|
|
25
25
|
async getExecutionInfo(executionId) {
|
|
26
26
|
if (!executionId || typeof executionId !== 'number') {
|
package/hooks/api.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export declare function mountWorkflowFeature(context: any): void;
|
|
|
18
18
|
export declare function terminateWorkflow(): (workflowInstanceId: number, options: any) => Promise<void>;
|
|
19
19
|
export declare function mockFlowFeature(context: any): any;
|
|
20
20
|
export declare function mockGetExecutionUserTaskInfo(): (executionId: bigint) => Promise<FlowTaskInfo[]>;
|
|
21
|
-
export declare function mockExecuteFlow(): (
|
|
21
|
+
export declare function mockExecuteFlow(): (apiName: string, options?: ExecuteOptions) => Promise<ExecutionResult>;
|
|
22
22
|
export declare function mockRevokeExecution(): (executionId: number, options: RevokeExecutionOptions) => Promise<void>;
|
|
23
23
|
export declare function mockGetExecutionInfo(): (executionId: number) => Promise<ExecutionInfo>;
|
|
24
24
|
export declare function invokeMicroservice(): (apiName: string) => {
|
package/hooks/api.js
CHANGED
|
@@ -257,9 +257,9 @@ function mockGetExecutionUserTaskInfo() {
|
|
|
257
257
|
}
|
|
258
258
|
exports.mockGetExecutionUserTaskInfo = mockGetExecutionUserTaskInfo;
|
|
259
259
|
function mockExecuteFlow() {
|
|
260
|
-
return async (
|
|
261
|
-
if (!
|
|
262
|
-
throw new exceptions_1.InvalidParamError(`param's type (${
|
|
260
|
+
return async (apiName, options) => {
|
|
261
|
+
if (!apiName || typeof apiName !== 'string') {
|
|
262
|
+
throw new exceptions_1.InvalidParamError(`param's type (${apiName}) need string, but is ${typeof apiName}`);
|
|
263
263
|
}
|
|
264
264
|
if (options && options.params && checkUtils.isNotObject(options.params)) {
|
|
265
265
|
throw new exceptions_1.InvalidParamError(`options.params's type (${options}) need object, but is ${Array.isArray(options) ? 'array' : typeof options.params}`);
|
|
@@ -267,7 +267,7 @@ function mockExecuteFlow() {
|
|
|
267
267
|
if (!options) {
|
|
268
268
|
options = {};
|
|
269
269
|
}
|
|
270
|
-
return await Request.GetInstance().executeFlow(
|
|
270
|
+
return await Request.GetInstance().executeFlow(apiName, options, false);
|
|
271
271
|
};
|
|
272
272
|
}
|
|
273
273
|
exports.mockExecuteFlow = mockExecuteFlow;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@byted-apaas/server-sdk-node",
|
|
3
|
-
"version": "1.1.20
|
|
3
|
+
"version": "1.1.20",
|
|
4
4
|
"description": "aPaaS Server SDK",
|
|
5
5
|
"author": "zhouwexin <zhouwexin@bytedance.com>",
|
|
6
6
|
"homepage": "",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"clean": "tsc --build --clean && rm -rf **/*.js.map"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@byted-apaas/server-common-node": "2.0.
|
|
16
|
+
"@byted-apaas/server-common-node": "^2.0.13",
|
|
17
17
|
"@jorgeferrero/stream-to-buffer": "^2.0.6",
|
|
18
18
|
"dayjs": "^1.9.6",
|
|
19
19
|
"form-data": "^3.0.0",
|
package/request/interface.d.ts
CHANGED
|
@@ -84,7 +84,7 @@ export interface IInnerAPIBaseRequest {
|
|
|
84
84
|
}, params: any) => Promise<any>;
|
|
85
85
|
createAsyncTaskV2: (name: string, params: any) => Promise<any>;
|
|
86
86
|
getExecutionUserTaskInfo: (executionId: bigint) => Promise<any>;
|
|
87
|
-
executeFlow: (APIName: string, options: any) => Promise<ExecutionResult>;
|
|
87
|
+
executeFlow: (APIName: string, options: any, async: any) => Promise<ExecutionResult>;
|
|
88
88
|
revokeExecution: (executionId: number, revokeOptions: RevokeExecutionOptions) => Promise<void>;
|
|
89
89
|
getExecutionInfo: (executionId: number) => Promise<ExecutionInfo>;
|
|
90
90
|
getTenantInfo: (appCtx: AppCtx) => Promise<any>;
|
package/request/openapi.d.ts
CHANGED
|
@@ -56,7 +56,7 @@ export declare class RequestHttp implements IInnerAPIRequest {
|
|
|
56
56
|
}, params: any): Promise<any>;
|
|
57
57
|
createAsyncTaskV2(name: string, params: any): Promise<any>;
|
|
58
58
|
getExecutionUserTaskInfo(executionId: bigint): Promise<any>;
|
|
59
|
-
executeFlow(
|
|
59
|
+
executeFlow(apiName: string, options: any, async: any): Promise<ExecutionResult>;
|
|
60
60
|
revokeExecution(executionId: number, revokeOptions: RevokeExecutionOptions): Promise<void>;
|
|
61
61
|
getExecutionInfo(executionId: number): Promise<ExecutionInfo>;
|
|
62
62
|
getTenantInfo(appCtx: AppCtx): Promise<any>;
|
|
@@ -79,6 +79,6 @@ export declare class RequestHttp implements IInnerAPIRequest {
|
|
|
79
79
|
getApprovalInstance(params: IGetApprovalInstanceOptions): Promise<IApprovalInstance>;
|
|
80
80
|
}
|
|
81
81
|
export declare function getExecutionUserTaskInfo(executionId: bigint): Promise<any>;
|
|
82
|
-
export declare function executeFlow(
|
|
82
|
+
export declare function executeFlow(apiName: string, option: any, async: any): Promise<ExecutionResult>;
|
|
83
83
|
export declare function revokeExecution(executionId: number, revokeOptions: RevokeExecutionOptions): Promise<void>;
|
|
84
84
|
export declare function getExecutionInfo(executionId: number): Promise<ExecutionInfo>;
|
package/request/openapi.js
CHANGED
|
@@ -11,7 +11,8 @@ const constants_3 = require("@byted-apaas/server-common-node/constants/constants
|
|
|
11
11
|
const common_1 = require("./common");
|
|
12
12
|
const utils_1 = require("@byted-apaas/server-common-node/utils/utils");
|
|
13
13
|
const permissionUtils = require("@byted-apaas/server-common-node/utils/permissionUtils");
|
|
14
|
-
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
15
|
+
const { URLSearchParams } = require('url'); //nolint:byted_s_ts_no_require_imports
|
|
15
16
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
16
17
|
const nodeCls = require('node-cls'); //nolint:byted_s_ts_no_require_imports
|
|
17
18
|
const fs = require('fs');
|
|
@@ -1126,8 +1127,8 @@ class RequestHttp {
|
|
|
1126
1127
|
async getExecutionUserTaskInfo(executionId) {
|
|
1127
1128
|
return await getExecutionUserTaskInfo(executionId);
|
|
1128
1129
|
}
|
|
1129
|
-
async executeFlow(
|
|
1130
|
-
return await executeFlow(
|
|
1130
|
+
async executeFlow(apiName, options, async) {
|
|
1131
|
+
return await executeFlow(apiName, options, async);
|
|
1131
1132
|
}
|
|
1132
1133
|
async revokeExecution(executionId, revokeOptions) {
|
|
1133
1134
|
return await revokeExecution(executionId, revokeOptions);
|
|
@@ -1414,17 +1415,20 @@ async function getExecutionUserTaskInfo(executionId) {
|
|
|
1414
1415
|
return res.taskList;
|
|
1415
1416
|
}
|
|
1416
1417
|
exports.getExecutionUserTaskInfo = getExecutionUserTaskInfo;
|
|
1417
|
-
async function executeFlow(
|
|
1418
|
-
if (!
|
|
1418
|
+
async function executeFlow(apiName, option, async) {
|
|
1419
|
+
if (!apiName) {
|
|
1419
1420
|
throw new exceptions.InvalidParamError(`flow apiName is empty`);
|
|
1420
1421
|
}
|
|
1421
1422
|
let options = commonHttp.getOptions(null, constants_2.openapiHttpPath.executeFlow);
|
|
1422
|
-
|
|
1423
|
+
const urlPath = options._reqPath.replace(replaceKeys.namespace, await (0, common_1.getNamespaceForOpenAndFaaSSDK)()).replace(replaceKeys.apiName, apiName);
|
|
1423
1424
|
options.json = {
|
|
1424
1425
|
'operator': utils.getUserIDFromCtx(),
|
|
1425
1426
|
'variables': (0, common_1.transMapToFlowVariable)(option.params),
|
|
1426
1427
|
'loopMasks': utils.getLoopMasks(),
|
|
1427
1428
|
};
|
|
1429
|
+
if (async !== undefined) {
|
|
1430
|
+
options.json['async'] = async;
|
|
1431
|
+
}
|
|
1428
1432
|
let res = await openapi.doRequest(null, urlPath, options);
|
|
1429
1433
|
return {
|
|
1430
1434
|
executionId: res.executionId,
|