@byted-apaas/server-sdk-node 1.1.23 → 1.1.24
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/application/application.d.ts +33 -0
- package/application/application.js +2 -0
- package/application/function/function.d.ts +14 -0
- package/application/function/function.js +20 -0
- package/application/impl/common.d.ts +2 -0
- package/application/impl/common.js +52 -0
- package/application/impl/impl.d.ts +19 -0
- package/application/impl/impl.js +45 -0
- package/common/structs.d.ts +15 -0
- package/common/structs.js +21 -0
- package/constants/constants.d.ts +13 -0
- package/constants/constants.js +18 -0
- package/context/context.d.ts +44 -0
- package/context/context.js +25 -0
- package/context/db/db.d.ts +110 -0
- package/context/db/db.js +2 -0
- package/context/db/impl/IObject.d.ts +303 -0
- package/context/db/impl/IObject.js +5 -0
- package/context/db/impl/IObjectV3.d.ts +239 -0
- package/context/db/impl/IObjectV3.js +5 -0
- package/context/db/impl/db.d.ts +62 -0
- package/context/db/impl/db.js +84 -0
- package/context/db/impl/dbV3.d.ts +35 -0
- package/context/db/impl/dbV3.js +50 -0
- package/context/db/impl/object.d.ts +123 -0
- package/context/db/impl/object.js +1008 -0
- package/context/db/impl/oql/ioql.d.ts +14 -0
- package/context/db/impl/oql/ioql.js +4 -0
- package/context/db/impl/oql/oql.d.ts +14 -0
- package/context/db/impl/oql/oql.js +39 -0
- package/context/db/impl/order.d.ts +9 -0
- package/context/db/impl/order.js +15 -0
- package/context/db/impl/propertiesStore.d.ts +8 -0
- package/context/db/impl/propertiesStore.js +29 -0
- package/context/db/impl/queryBuilder.d.ts +33 -0
- package/context/db/impl/queryBuilder.js +72 -0
- package/context/db/impl/transaction/index.d.ts +25 -0
- package/context/db/impl/transaction/index.js +300 -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.d.ts +70 -0
- package/context/db/impl/transaction.js +4 -0
- package/context/globalConfig/globalConfig.d.ts +7 -0
- package/context/globalConfig/globalConfig.js +16 -0
- package/context/integration/IIntegration.d.ts +30 -0
- package/context/integration/IIntegration.js +4 -0
- package/context/integration/impl/integration.d.ts +16 -0
- package/context/integration/impl/integration.js +62 -0
- package/context/metadata/components/common.d.ts +6 -0
- package/context/metadata/components/common.js +17 -0
- package/context/metadata/components/components.d.ts +12 -0
- package/context/metadata/components/components.js +19 -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/recordDetail.d.ts +11 -0
- package/context/metadata/components/desktop/recordDetail.js +53 -0
- package/context/metadata/components/mobile/list.d.ts +24 -0
- package/context/metadata/components/mobile/list.js +145 -0
- package/context/metadata/metadata.d.ts +63 -0
- package/context/metadata/metadata.js +125 -0
- package/context/metadata/objects/fields.d.ts +158 -0
- package/context/metadata/objects/fields.js +369 -0
- package/context/metadata/objects/fields.util.d.ts +52 -0
- package/context/metadata/objects/fields.util.js +420 -0
- package/context/metadata/objects/fieldsV3.d.ts +159 -0
- package/context/metadata/objects/fieldsV3.js +369 -0
- package/context/metadata/objects/objects.d.ts +11 -0
- package/context/metadata/objects/objects.js +20 -0
- package/context/metadata/types/common.d.ts +11 -0
- package/context/metadata/types/common.js +33 -0
- package/context/metadata/types/components.d.ts +90 -0
- package/context/metadata/types/components.js +4 -0
- package/context/metadata/types/objects.d.ts +246 -0
- package/context/metadata/types/objects.js +4 -0
- package/context/metadata/types/objectsV3.d.ts +128 -0
- package/context/metadata/types/objectsV3.js +4 -0
- package/context/msg/msg.d.ts +38 -0
- package/context/msg/msg.js +35 -0
- package/context/resources/IResources.d.ts +68 -0
- package/context/resources/IResources.js +2 -0
- package/context/resources/impl/resources.d.ts +42 -0
- package/context/resources/impl/resources.js +161 -0
- package/context/tasks/tasks.d.ts +33 -0
- package/context/tasks/tasks.js +139 -0
- package/data/index.d.ts +27 -0
- package/data/index.js +4 -0
- package/global/application/flow/flow.d.ts +99 -0
- package/global/application/flow/flow.js +8 -0
- package/global/application/flow/impl/flow.d.ts +20 -0
- package/global/application/flow/impl/flow.js +56 -0
- package/global/application/globalVar/globalVar.d.ts +7 -0
- package/global/application/globalVar/globalVar.js +2 -0
- package/global/global.d.ts +70 -0
- package/global/global.js +3 -0
- package/hooks/api.d.ts +65 -0
- package/hooks/api.js +347 -0
- package/hooks/hooks.d.ts +1 -0
- package/hooks/hooks.js +107 -0
- package/kunlun/kunlun.d.ts +55 -0
- package/kunlun/kunlun.js +58 -0
- package/kunlun/operator/IOperator.d.ts +158 -0
- package/kunlun/operator/IOperator.js +4 -0
- package/kunlun/operator/impl/expression.d.ts +75 -0
- package/kunlun/operator/impl/expression.js +96 -0
- package/kunlun/operator/impl/logic.d.ts +68 -0
- package/kunlun/operator/impl/logic.js +573 -0
- package/kunlun/operator/impl/logicV2.d.ts +59 -0
- package/kunlun/operator/impl/logicV2.js +197 -0
- package/kunlun/operator/impl/operator.d.ts +179 -0
- package/kunlun/operator/impl/operator.js +222 -0
- package/kunlun/operator/impl/operatorV2.d.ts +180 -0
- package/kunlun/operator/impl/operatorV2.js +216 -0
- package/lib/core.d.ts +4 -0
- package/lib/core.js +19 -0
- package/package.json +1 -1
- package/request/common.d.ts +13 -0
- package/request/common.js +88 -0
- package/request/constants.d.ts +12 -0
- package/request/constants.js +29 -0
- package/request/faasinfra.d.ts +8 -0
- package/request/faasinfra.js +146 -0
- package/request/interface.d.ts +121 -0
- package/request/interface.js +30 -0
- package/request/openapi.d.ts +84 -0
- package/request/openapi.js +1529 -0
- package/request/structs.d.ts +99 -0
- package/request/structs.js +15 -0
- package/types/types.d.ts +79 -0
- package/types/types.js +4 -0
- package/version/version.d.ts +2 -0
- package/version/version.js +8 -0
|
@@ -0,0 +1,161 @@
|
|
|
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._Resources = exports._OpenSDKResources = exports._KunlunFile = exports._KunlunOpenSDKFile = void 0;
|
|
6
|
+
const stream_1 = require("stream");
|
|
7
|
+
const Request = require("../../../request/interface");
|
|
8
|
+
const common_1 = require("../../../application/impl/common");
|
|
9
|
+
const common = require("@byted-apaas/server-common-node");
|
|
10
|
+
const stream_to_buffer_1 = require("@jorgeferrero/stream-to-buffer");
|
|
11
|
+
const exceptions = common.exceptions;
|
|
12
|
+
const fs = require('fs');
|
|
13
|
+
class _KunlunOpenSDKFile {
|
|
14
|
+
constructor(appCtx) {
|
|
15
|
+
this.appCtx = appCtx;
|
|
16
|
+
}
|
|
17
|
+
async Upload(fileName, source) {
|
|
18
|
+
// 1. check parameters type
|
|
19
|
+
if (typeof fileName !== 'string') {
|
|
20
|
+
throw new exceptions.InvalidParamError('upload method parameter fileName must be string. ');
|
|
21
|
+
}
|
|
22
|
+
if (typeof source !== 'string' && !(source instanceof stream_1.Stream) && !(source instanceof Buffer)) {
|
|
23
|
+
throw new exceptions.InvalidParamError('upload method parameter source must be string or stream or buffer. ');
|
|
24
|
+
}
|
|
25
|
+
// 2. divide by source type
|
|
26
|
+
if (typeof source === 'string') {
|
|
27
|
+
// upload from path
|
|
28
|
+
if (!fs.existsSync(source)) {
|
|
29
|
+
throw new exceptions.InvalidParamError(`no such file '${source}'`);
|
|
30
|
+
}
|
|
31
|
+
source = fs.createReadStream(source);
|
|
32
|
+
}
|
|
33
|
+
if (source instanceof stream_1.Stream) {
|
|
34
|
+
// upload from stream
|
|
35
|
+
source = await (0, stream_to_buffer_1.streamToBuffer)(source);
|
|
36
|
+
}
|
|
37
|
+
if (source instanceof Buffer) {
|
|
38
|
+
return await (0, common_1.runCtxForOpenSDK)(this.appCtx, async () => {
|
|
39
|
+
return await Request.GetInstance().openSDKUploadFile(fileName, source);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
;
|
|
45
|
+
async UploadAvatar(fileName, source) {
|
|
46
|
+
// 1. check parameters type
|
|
47
|
+
if (typeof fileName !== 'string') {
|
|
48
|
+
throw new exceptions.InvalidParamError('upload method parameter fileName must be string. ');
|
|
49
|
+
}
|
|
50
|
+
if (typeof source !== 'string' && !(source instanceof stream_1.Stream) && !(source instanceof Buffer)) {
|
|
51
|
+
throw new exceptions.InvalidParamError('upload method parameter source must be string or stream or buffer. ');
|
|
52
|
+
}
|
|
53
|
+
// 2. divide by source type
|
|
54
|
+
if (typeof source === 'string') {
|
|
55
|
+
// upload from path
|
|
56
|
+
if (!fs.existsSync(source)) {
|
|
57
|
+
throw new exceptions.InvalidParamError(`no such file '${source}'`);
|
|
58
|
+
}
|
|
59
|
+
source = fs.createReadStream(source);
|
|
60
|
+
}
|
|
61
|
+
if (source instanceof stream_1.Stream) {
|
|
62
|
+
// upload from stream
|
|
63
|
+
source = await (0, stream_to_buffer_1.streamToBuffer)(source);
|
|
64
|
+
}
|
|
65
|
+
if (source instanceof Buffer) {
|
|
66
|
+
// upload from buffer
|
|
67
|
+
return await (0, common_1.runCtxForOpenSDK)(this.appCtx, async () => {
|
|
68
|
+
return await Request.GetInstance().openSDKUploadAvatar(fileName, source);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
;
|
|
74
|
+
async Download(fileID) {
|
|
75
|
+
// 1. check parameters type
|
|
76
|
+
if (typeof fileID !== 'string') {
|
|
77
|
+
throw new exceptions.InvalidParamError('download method parameter fileID must be string. ');
|
|
78
|
+
}
|
|
79
|
+
return await (0, common_1.runCtxForOpenSDK)(this.appCtx, async () => {
|
|
80
|
+
return await Request.GetInstance().downloadFileByID(fileID);
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
;
|
|
84
|
+
async DownloadAvatar(imageID) {
|
|
85
|
+
// 1. check parameters type
|
|
86
|
+
if (typeof imageID !== 'string') {
|
|
87
|
+
throw new exceptions.InvalidParamError('download method parameter imageID must be string. ');
|
|
88
|
+
}
|
|
89
|
+
return await (0, common_1.runCtxForOpenSDK)(this.appCtx, async () => {
|
|
90
|
+
return await Request.GetInstance().openSDKDownloadAvatar(imageID);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
;
|
|
94
|
+
}
|
|
95
|
+
exports._KunlunOpenSDKFile = _KunlunOpenSDKFile;
|
|
96
|
+
class _KunlunFile {
|
|
97
|
+
async download(fileTokenOrInfo, filePath) {
|
|
98
|
+
if (typeof (fileTokenOrInfo) === 'string') {
|
|
99
|
+
return await Request.GetInstance().downloadFileByToken(fileTokenOrInfo, filePath);
|
|
100
|
+
}
|
|
101
|
+
else if (typeof (fileTokenOrInfo) === 'object') {
|
|
102
|
+
if (!fileTokenOrInfo.id) {
|
|
103
|
+
throw new exceptions.InvalidParamError(`The value of fileInfo.id is empty`);
|
|
104
|
+
}
|
|
105
|
+
if (typeof (fileTokenOrInfo.id) !== 'string') {
|
|
106
|
+
throw new exceptions.InvalidParamError(`The type of fileInfo.id should be string, but ${typeof (fileTokenOrInfo)}`);
|
|
107
|
+
}
|
|
108
|
+
let tokenListStr = await Request.GetInstance().mGetFileToken([fileTokenOrInfo.id]);
|
|
109
|
+
let id2token;
|
|
110
|
+
try {
|
|
111
|
+
id2token = JSON.parse(tokenListStr);
|
|
112
|
+
}
|
|
113
|
+
catch (err) {
|
|
114
|
+
throw new exceptions.InternalError(`parse mGetFileToken resp failed: ${err.message}`);
|
|
115
|
+
}
|
|
116
|
+
if (!id2token[fileTokenOrInfo.id]) {
|
|
117
|
+
throw new exceptions.InternalError(`id (${fileTokenOrInfo.id})'s token is empty`);
|
|
118
|
+
}
|
|
119
|
+
return await Request.GetInstance().downloadFileByToken(id2token[fileTokenOrInfo.id], filePath);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
throw new exceptions.InvalidParamError(`The type of first param should be string or object, but ${typeof (fileTokenOrInfo)}`);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
async upload(data, expire, fileName, ...ret) {
|
|
126
|
+
if (ret.length > 0) {
|
|
127
|
+
throw new exceptions.InvalidParamError(`params is too many, as ${ret.length + 2}`);
|
|
128
|
+
}
|
|
129
|
+
if (!data) {
|
|
130
|
+
throw new exceptions.InvalidParamError(`params is null`);
|
|
131
|
+
}
|
|
132
|
+
// 1. data is filePath, read it from disk, convert it to Steam.
|
|
133
|
+
if (typeof (data) === 'string') {
|
|
134
|
+
if (!fs.existsSync(data)) {
|
|
135
|
+
throw new exceptions.InvalidParamError(`no such file '${data}'`);
|
|
136
|
+
}
|
|
137
|
+
data = fs.createReadStream(data);
|
|
138
|
+
}
|
|
139
|
+
// 2. data must be Stream at here.
|
|
140
|
+
return await Request.GetHttpInstance().uploadFile(data, expire, fileName);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
exports._KunlunFile = _KunlunFile;
|
|
144
|
+
/**
|
|
145
|
+
* OpenSDK 静态资源操作类
|
|
146
|
+
*/
|
|
147
|
+
class _OpenSDKResources {
|
|
148
|
+
constructor(appCtx) {
|
|
149
|
+
this.file = new _KunlunOpenSDKFile(appCtx);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
exports._OpenSDKResources = _OpenSDKResources;
|
|
153
|
+
/**
|
|
154
|
+
* 静态资源操作类
|
|
155
|
+
*/
|
|
156
|
+
class _Resources {
|
|
157
|
+
constructor() {
|
|
158
|
+
this.file = new _KunlunFile();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
exports._Resources = _Resources;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export declare class _Options {
|
|
2
|
+
/**
|
|
3
|
+
* 并发数量,默认值为 5,最大可设置值为 10
|
|
4
|
+
*/
|
|
5
|
+
concurrency?: number;
|
|
6
|
+
/**
|
|
7
|
+
* 单个子任务的最大数据量,默认值为 5,最大可设置值为 100
|
|
8
|
+
*/
|
|
9
|
+
maxSliceNumber?: number;
|
|
10
|
+
/**
|
|
11
|
+
* 触发进度回调函数的步长,以百分比为单位,每当发生大于等于步长的进度变化时,便触发进度回调函数。默认为每当有进度变化时,便触发进度回调函数(进度变化精度为 1%)
|
|
12
|
+
*/
|
|
13
|
+
progressCallbackStep?: number;
|
|
14
|
+
}
|
|
15
|
+
export declare class Tasks<cf> {
|
|
16
|
+
private f;
|
|
17
|
+
constructor(_f?: Function);
|
|
18
|
+
/**
|
|
19
|
+
* 创建异步任务
|
|
20
|
+
* @param apiName 函数的 apiName
|
|
21
|
+
* @param params 参数
|
|
22
|
+
*/
|
|
23
|
+
createAsyncTask(apiName: cf, params: object): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* 创建分布式任务
|
|
26
|
+
* @param dataset 待处理数据组成的数组
|
|
27
|
+
* @param handlerFunc 用于处理数据集的全局函数的 API name
|
|
28
|
+
* @param progressCallbackFunc 任务进度发生变化时回调的全局函数的 API name,可通过传入 '' / null / undefined 跳过此步骤
|
|
29
|
+
* @param completedCallbackFunc 任务完成时回调的全局函数的 API name,可通过传入 '' / null / undefined 跳过此步骤
|
|
30
|
+
* @param options 高级配置参数,可选
|
|
31
|
+
*/
|
|
32
|
+
createDistributedTask(dataset: any[], handlerFunc: cf, progressCallbackFunc: cf | '' | null | undefined, completedCallbackFunc: cf | '' | null | undefined, options?: _Options): Promise<number>;
|
|
33
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Tasks = exports._Options = void 0;
|
|
4
|
+
const common = require("@byted-apaas/server-common-node");
|
|
5
|
+
const Request = require("../../request/interface");
|
|
6
|
+
const utils = common.utils;
|
|
7
|
+
const exceptions = common.exceptions;
|
|
8
|
+
class _Options {
|
|
9
|
+
}
|
|
10
|
+
exports._Options = _Options;
|
|
11
|
+
// export async function asyncTaskV1(apiName: string, params: any, oldFuncName: string, isSync: boolean) {
|
|
12
|
+
// return await invokeFuncSync(apiName, params, oldFuncName, false);
|
|
13
|
+
// }
|
|
14
|
+
class Tasks {
|
|
15
|
+
constructor(_f) {
|
|
16
|
+
this.f = _f;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 创建异步任务
|
|
20
|
+
* @param apiName 函数的 apiName
|
|
21
|
+
* @param params 参数
|
|
22
|
+
*/
|
|
23
|
+
async createAsyncTask(apiName, params) {
|
|
24
|
+
if (apiName && params) {
|
|
25
|
+
// low_code 1.0
|
|
26
|
+
if (utils.isOnlineDev()) {
|
|
27
|
+
// 1.debug模式
|
|
28
|
+
if (utils.isDebug()) {
|
|
29
|
+
return await this.f(apiName).invoke(params);
|
|
30
|
+
}
|
|
31
|
+
// 2.运行时
|
|
32
|
+
let newApiName = utils.handleFuncName(null, apiName);
|
|
33
|
+
if (!newApiName) {
|
|
34
|
+
throw new exceptions.InvalidParamError(`The function (${apiName}) does not exist, please confirm ${apiName} exists and has been deployed.`);
|
|
35
|
+
}
|
|
36
|
+
let idOrName = {};
|
|
37
|
+
if (newApiName === (apiName)) {
|
|
38
|
+
idOrName = {
|
|
39
|
+
APIName: newApiName,
|
|
40
|
+
isInvokeByAPIName: true,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
else if (utils.isMicroservice()) {
|
|
44
|
+
idOrName = {
|
|
45
|
+
APIName: apiName,
|
|
46
|
+
isInvokeByAPIName: true,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
idOrName = {
|
|
51
|
+
APIId: newApiName,
|
|
52
|
+
isInvokeByAPIName: false,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
task_id: await Request.GetInstance().createAsyncTaskV1(idOrName, params),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
// low_code 2.0
|
|
60
|
+
// 如果是本地调试模式,则直接异步执行
|
|
61
|
+
if (utils.isLocalDebug()) {
|
|
62
|
+
this.f(apiName).invoke(params);
|
|
63
|
+
return { task_id: 1234567890123456 };
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
task_id: await Request.GetInstance().createAsyncTaskV2(apiName, params),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
throw new exceptions.InvalidParamError(`context.tasks.createAsyncTask params is error`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
;
|
|
74
|
+
/**
|
|
75
|
+
* 创建分布式任务
|
|
76
|
+
* @param dataset 待处理数据组成的数组
|
|
77
|
+
* @param handlerFunc 用于处理数据集的全局函数的 API name
|
|
78
|
+
* @param progressCallbackFunc 任务进度发生变化时回调的全局函数的 API name,可通过传入 '' / null / undefined 跳过此步骤
|
|
79
|
+
* @param completedCallbackFunc 任务完成时回调的全局函数的 API name,可通过传入 '' / null / undefined 跳过此步骤
|
|
80
|
+
* @param options 高级配置参数,可选
|
|
81
|
+
*/
|
|
82
|
+
async createDistributedTask(dataset, handlerFunc, progressCallbackFunc, completedCallbackFunc, options) {
|
|
83
|
+
if (utils.isLocalDebug()) {
|
|
84
|
+
throw new exceptions.InvalidParamError("Local debugging isn't supported for distributed tasks. You can only deploy them to the cloud");
|
|
85
|
+
}
|
|
86
|
+
if (utils.getDistributedHandleMask()) {
|
|
87
|
+
throw new exceptions.InvalidParamError('Does not support creating distributed tasks in handler function and progress callback function');
|
|
88
|
+
}
|
|
89
|
+
// dataset
|
|
90
|
+
if (!(dataset instanceof Array)) {
|
|
91
|
+
throw new exceptions.InvalidParamError(`parameter dataset is not list`);
|
|
92
|
+
}
|
|
93
|
+
// handlerFunc
|
|
94
|
+
if (!handlerFunc || typeof handlerFunc !== 'string') {
|
|
95
|
+
throw new exceptions.InvalidParamError(`parameter handlerFunc is not string or handlerFunc is empty`);
|
|
96
|
+
}
|
|
97
|
+
// progressCallbackFunc
|
|
98
|
+
if (progressCallbackFunc === null || progressCallbackFunc === undefined) {
|
|
99
|
+
progressCallbackFunc = '';
|
|
100
|
+
}
|
|
101
|
+
if (typeof progressCallbackFunc !== 'string') {
|
|
102
|
+
throw new exceptions.InvalidParamError(`parameter progressCallbackFunc is not string`);
|
|
103
|
+
}
|
|
104
|
+
// completedCallbackFunc
|
|
105
|
+
if (completedCallbackFunc === null || completedCallbackFunc === undefined) {
|
|
106
|
+
completedCallbackFunc = '';
|
|
107
|
+
}
|
|
108
|
+
if (typeof completedCallbackFunc !== 'string') {
|
|
109
|
+
throw new exceptions.InvalidParamError(`parameter completedCallbackFunc is not string`);
|
|
110
|
+
}
|
|
111
|
+
// option.concurrency
|
|
112
|
+
if (options.concurrency === null || options.concurrency === undefined) {
|
|
113
|
+
options.concurrency = 5;
|
|
114
|
+
}
|
|
115
|
+
if ((typeof options.concurrency !== 'number') || options.concurrency <= 0) {
|
|
116
|
+
throw new exceptions.InvalidParamError(`parameter option.concurrency is not Number or not graterThan 0`);
|
|
117
|
+
}
|
|
118
|
+
// option.maxSliceNumber
|
|
119
|
+
if (options.maxSliceNumber === null || options.maxSliceNumber === undefined) {
|
|
120
|
+
options.maxSliceNumber = 5;
|
|
121
|
+
}
|
|
122
|
+
if ((typeof options.maxSliceNumber !== 'number') || options.maxSliceNumber <= 0) {
|
|
123
|
+
throw new exceptions.InvalidParamError(`parameter option.maxSliceNumber is not Number or not graterThan 0`);
|
|
124
|
+
}
|
|
125
|
+
// option.notifyStep
|
|
126
|
+
if (options.progressCallbackStep === null || options.progressCallbackStep === undefined) {
|
|
127
|
+
options.progressCallbackStep = 1;
|
|
128
|
+
}
|
|
129
|
+
if ((typeof options.progressCallbackStep !== 'number') || options.progressCallbackStep <= 0 || options.progressCallbackStep > 100) {
|
|
130
|
+
throw new exceptions.InvalidParamError(`parameter option.progressCallbackStep is not Number or not between 0 and 100`);
|
|
131
|
+
}
|
|
132
|
+
if (utils.isOnlineDev()) {
|
|
133
|
+
return Request.GetFaaSInfraInstance().createDistributeTaskV1([dataset], handlerFunc, progressCallbackFunc, completedCallbackFunc, options);
|
|
134
|
+
}
|
|
135
|
+
return Request.GetFaaSInfraInstance().createDistributeTaskV2([dataset], handlerFunc, progressCallbackFunc, completedCallbackFunc, options);
|
|
136
|
+
}
|
|
137
|
+
;
|
|
138
|
+
}
|
|
139
|
+
exports.Tasks = Tasks;
|
package/data/index.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface workflowVariables {
|
|
2
|
+
}
|
|
3
|
+
export type globalFuncNames = 'a' | 'b';
|
|
4
|
+
export interface globalVariablesMap {
|
|
5
|
+
a: string;
|
|
6
|
+
b: string;
|
|
7
|
+
}
|
|
8
|
+
export type globalVariables = keyof globalVariablesMap;
|
|
9
|
+
export interface metadataMap {
|
|
10
|
+
/**
|
|
11
|
+
* @description 用户
|
|
12
|
+
*/
|
|
13
|
+
_user: User;
|
|
14
|
+
_department: Department;
|
|
15
|
+
}
|
|
16
|
+
export type currentObjApiName = '_user';
|
|
17
|
+
interface User {
|
|
18
|
+
_name: string;
|
|
19
|
+
_id: number;
|
|
20
|
+
_department: Department;
|
|
21
|
+
}
|
|
22
|
+
interface Department {
|
|
23
|
+
_id: number;
|
|
24
|
+
_name: string;
|
|
25
|
+
_superior: Department;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
package/data/index.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { IApprovalInstance, IApprovalInstanceListOptions, IApprovalInstanceList, IGetApprovalInstanceOptions } from '../../../request/structs';
|
|
2
|
+
export declare function newFlow(context: any): Flow;
|
|
3
|
+
export interface Flow {
|
|
4
|
+
/**
|
|
5
|
+
* 获取流程实例人工任务详情列表
|
|
6
|
+
* @param executionId
|
|
7
|
+
*/
|
|
8
|
+
getExecutionUserTaskInfo: (executionId: number) => Promise<FlowTaskInfo[]>;
|
|
9
|
+
/**
|
|
10
|
+
* 执行流程
|
|
11
|
+
* @param apiName 流程的 APIName
|
|
12
|
+
* @param options 流程执行选项
|
|
13
|
+
* @param async 是否异步执行
|
|
14
|
+
* - params 流程入参
|
|
15
|
+
* @constructor
|
|
16
|
+
*/
|
|
17
|
+
execute: (apiName: string, options?: ExecuteOptions, async?: boolean) => Promise<ExecutionResult>;
|
|
18
|
+
/**
|
|
19
|
+
* 撤销流程实例 (仅支持撤销包含人工任务的流程实例)
|
|
20
|
+
* @param executionId 流程实例 Id
|
|
21
|
+
* @param options 撤销选项 reason: 多语原因
|
|
22
|
+
* @constructor
|
|
23
|
+
*/
|
|
24
|
+
revokeExecution: (executionId: number, options: RevokeExecutionOptions) => Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* 获取流程实例信息
|
|
27
|
+
* @param executionId 流程实例 Id
|
|
28
|
+
* @constructor
|
|
29
|
+
*/
|
|
30
|
+
getExecutionInfo: (executionId: number) => Promise<ExecutionInfo>;
|
|
31
|
+
/**
|
|
32
|
+
* 获取审批实例列表
|
|
33
|
+
* @param options 请求参数,可选
|
|
34
|
+
*/
|
|
35
|
+
getApprovalInstanceList: (options?: IApprovalInstanceListOptions) => Promise<IApprovalInstanceList>;
|
|
36
|
+
/**
|
|
37
|
+
* 获取审批实例详情
|
|
38
|
+
* @param approvalInstanceId 实例ID
|
|
39
|
+
* @param option 请求参数,可选
|
|
40
|
+
*/
|
|
41
|
+
getApprovalInstance: (options: IGetApprovalInstanceOptions) => Promise<IApprovalInstance>;
|
|
42
|
+
}
|
|
43
|
+
export interface Execution {
|
|
44
|
+
/**
|
|
45
|
+
* 流程实例 id (函数被流程调用时有值)
|
|
46
|
+
*/
|
|
47
|
+
id: number;
|
|
48
|
+
}
|
|
49
|
+
export interface ExecuteOptions {
|
|
50
|
+
params: Record<string, any>;
|
|
51
|
+
}
|
|
52
|
+
export interface ExecutionResult {
|
|
53
|
+
executionId: number;
|
|
54
|
+
status: ExecutionStatusType;
|
|
55
|
+
data: Record<string, any>;
|
|
56
|
+
errCode?: string;
|
|
57
|
+
errMsg?: string;
|
|
58
|
+
}
|
|
59
|
+
export type ExecutionStatusType = 'wait' | 'in_process' | 'end' | 'rejected' | 'canceled' | 'failed' | 'agreed';
|
|
60
|
+
export interface RevokeExecutionOptions {
|
|
61
|
+
reason?: NewMultilingual;
|
|
62
|
+
}
|
|
63
|
+
export interface ExecutionInfo {
|
|
64
|
+
status: ExecutionStatusType;
|
|
65
|
+
data: Record<string, any>;
|
|
66
|
+
errCode?: string;
|
|
67
|
+
errMsg?: string;
|
|
68
|
+
}
|
|
69
|
+
export interface FlowTaskInfo {
|
|
70
|
+
taskId: number;
|
|
71
|
+
label: NewMultilingual;
|
|
72
|
+
taskType: TaskType;
|
|
73
|
+
taskStatus: TaskStatus;
|
|
74
|
+
opinionList: TaskOpinion[];
|
|
75
|
+
assigneeList: FlowUser[];
|
|
76
|
+
startedTime: number;
|
|
77
|
+
completedTime?: number;
|
|
78
|
+
}
|
|
79
|
+
export type TaskType = 'form' | 'approval' | 'CC';
|
|
80
|
+
export type TaskStatus = 'in_process' | 'completed' | 'canceled' | 'failed' | 'auto_end' | 'agreed' | 'rejected';
|
|
81
|
+
export interface NewMultilingual {
|
|
82
|
+
en_US?: string;
|
|
83
|
+
zh_CN?: string;
|
|
84
|
+
}
|
|
85
|
+
export interface FlowUserAvatar {
|
|
86
|
+
url: string;
|
|
87
|
+
}
|
|
88
|
+
export interface FlowUser {
|
|
89
|
+
userId: number;
|
|
90
|
+
feishuOpenId: string;
|
|
91
|
+
userName: NewMultilingual;
|
|
92
|
+
}
|
|
93
|
+
export interface TaskOpinion {
|
|
94
|
+
user: FlowUser;
|
|
95
|
+
feishuOpenId: number;
|
|
96
|
+
opinionResult?: string;
|
|
97
|
+
submitTime: number;
|
|
98
|
+
opinionContent?: string;
|
|
99
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Flow as IFlow, ExecuteOptions, ExecutionResult, ExecutionInfo, FlowTaskInfo, RevokeExecutionOptions, Execution } from '../flow';
|
|
2
|
+
import { IApprovalInstance, IApprovalInstanceList, IApprovalInstanceListOptions, IGetApprovalInstanceOptions } from "../../../../request/structs";
|
|
3
|
+
export declare class Flow implements IFlow {
|
|
4
|
+
execution: Execution;
|
|
5
|
+
/**
|
|
6
|
+
* 工作流的 API name
|
|
7
|
+
*/
|
|
8
|
+
apiName: string;
|
|
9
|
+
/**
|
|
10
|
+
* 工作流实例的 ID
|
|
11
|
+
*/
|
|
12
|
+
instanceId: number;
|
|
13
|
+
constructor(flowParams: any);
|
|
14
|
+
execute(apiName: string, options: ExecuteOptions | undefined, async?: boolean | undefined): Promise<ExecutionResult>;
|
|
15
|
+
getExecutionInfo(executionId: number): Promise<ExecutionInfo>;
|
|
16
|
+
getExecutionUserTaskInfo(executionId: number): Promise<FlowTaskInfo[]>;
|
|
17
|
+
revokeExecution(executionId: number, options: RevokeExecutionOptions): Promise<void>;
|
|
18
|
+
getApprovalInstanceList(options?: IApprovalInstanceListOptions): Promise<IApprovalInstanceList>;
|
|
19
|
+
getApprovalInstance(options: IGetApprovalInstanceOptions): Promise<IApprovalInstance>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Flow = void 0;
|
|
4
|
+
const exceptions_1 = require("@byted-apaas/server-common-node/utils/exceptions");
|
|
5
|
+
const Request = require("../../../../request/interface");
|
|
6
|
+
const server_common_node_1 = require("@byted-apaas/server-common-node");
|
|
7
|
+
class Flow {
|
|
8
|
+
constructor(flowParams) {
|
|
9
|
+
this.execution = flowParams?.execution;
|
|
10
|
+
this.apiName = flowParams?.apiName;
|
|
11
|
+
this.instanceId = flowParams?.instanceId;
|
|
12
|
+
}
|
|
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
|
+
}
|
|
17
|
+
if (options && options.params && server_common_node_1.checkUtils.isNotObject(options.params)) {
|
|
18
|
+
throw new exceptions_1.InvalidParamError(`options.params's type (${options}) need object, but is ${Array.isArray(options) ? 'array' : typeof options.params}`);
|
|
19
|
+
}
|
|
20
|
+
if (!options) {
|
|
21
|
+
options = {};
|
|
22
|
+
}
|
|
23
|
+
return await Request.GetInstance().executeFlow(apiName, options, async);
|
|
24
|
+
}
|
|
25
|
+
async getExecutionInfo(executionId) {
|
|
26
|
+
if (!executionId || typeof executionId !== 'number') {
|
|
27
|
+
throw new exceptions_1.InvalidParamError(`param's type (${executionId}) is not matched to number, but is ${typeof executionId}`);
|
|
28
|
+
}
|
|
29
|
+
return await Request.GetInstance().getExecutionInfo(executionId);
|
|
30
|
+
}
|
|
31
|
+
async getExecutionUserTaskInfo(executionId) {
|
|
32
|
+
if (!executionId || typeof executionId !== 'number') {
|
|
33
|
+
throw new exceptions_1.InvalidParamError(`param's type (${executionId}) need number, but is ${typeof executionId}`);
|
|
34
|
+
}
|
|
35
|
+
return await Request.GetInstance().getExecutionUserTaskInfo(BigInt(executionId));
|
|
36
|
+
}
|
|
37
|
+
async revokeExecution(executionId, options) {
|
|
38
|
+
if (!executionId || typeof executionId !== 'number') {
|
|
39
|
+
throw new exceptions_1.InvalidParamError(`param's type (${executionId}) is need number, but is ${typeof executionId}`);
|
|
40
|
+
}
|
|
41
|
+
return await Request.GetInstance().revokeExecution(executionId, options);
|
|
42
|
+
}
|
|
43
|
+
async getApprovalInstanceList(options) {
|
|
44
|
+
return await Request.GetInstance().getApprovalInstanceList(options);
|
|
45
|
+
}
|
|
46
|
+
async getApprovalInstance(options) {
|
|
47
|
+
if (!options || !options.approvalInstanceId) {
|
|
48
|
+
throw new exceptions_1.InvalidParamError(`required parameter approvalInstanceId is empty`);
|
|
49
|
+
}
|
|
50
|
+
if (typeof options.approvalInstanceId !== 'number') {
|
|
51
|
+
throw new exceptions_1.InvalidParamError(`param's type (${options.approvalInstanceId}) is need number, but is ${typeof options.approvalInstanceId}`);
|
|
52
|
+
}
|
|
53
|
+
return await Request.GetInstance().getApprovalInstance(options);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.Flow = Flow;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { IOperator } from '../kunlun/operator/IOperator';
|
|
2
|
+
import { GMTOffset as GMT } from '@byted-apaas/server-common-node/constants/timeZone';
|
|
3
|
+
import { area2code } from '@byted-apaas/server-common-node/constants/countryCode';
|
|
4
|
+
import * as common from '@byted-apaas/server-common-node';
|
|
5
|
+
import { Flow } from './application/flow/flow';
|
|
6
|
+
import { _Resources } from '../context/resources/impl/resources';
|
|
7
|
+
import { Message } from '../context/msg/msg';
|
|
8
|
+
import { _IIntegration } from '../context/integration/IIntegration';
|
|
9
|
+
declare global {
|
|
10
|
+
export namespace application {
|
|
11
|
+
/**
|
|
12
|
+
* 操作 flow
|
|
13
|
+
*/
|
|
14
|
+
let flow: Flow;
|
|
15
|
+
/**
|
|
16
|
+
* 静态资源类操作
|
|
17
|
+
*/
|
|
18
|
+
let resources: _Resources;
|
|
19
|
+
/**
|
|
20
|
+
* 向消息中心推送及更新消息
|
|
21
|
+
*/
|
|
22
|
+
let msg: Message;
|
|
23
|
+
/**
|
|
24
|
+
* 指令操作符
|
|
25
|
+
*/
|
|
26
|
+
let operator: IOperator;
|
|
27
|
+
/**
|
|
28
|
+
* dataV3 接口
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* metadataV3 接口
|
|
32
|
+
*/
|
|
33
|
+
/**
|
|
34
|
+
* 常量
|
|
35
|
+
*/
|
|
36
|
+
namespace constants {
|
|
37
|
+
/**
|
|
38
|
+
* 引用时区信息
|
|
39
|
+
*/
|
|
40
|
+
let GMTOffset: typeof GMT;
|
|
41
|
+
/**
|
|
42
|
+
* 引用国际区号
|
|
43
|
+
*/
|
|
44
|
+
let countryCode: typeof area2code;
|
|
45
|
+
/**
|
|
46
|
+
* 错误码
|
|
47
|
+
*/
|
|
48
|
+
const errorCode: {
|
|
49
|
+
RATE_LIMIT_ERROR: string;
|
|
50
|
+
Flows_NoPermission: string;
|
|
51
|
+
Flows_NotExist: string;
|
|
52
|
+
Flows_ExecutionNotExist: string;
|
|
53
|
+
Flows_NotSupportCallFlowType: string;
|
|
54
|
+
Flows_NotSupportRevokeFlow: string;
|
|
55
|
+
Flows_NoReqInputParamErr: string;
|
|
56
|
+
Flows_InvalidParamErr: string;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* 生成复杂数据结构
|
|
60
|
+
*/
|
|
61
|
+
namespace type {
|
|
62
|
+
export import Multilingual = common.fieldType.Multilingual;
|
|
63
|
+
export import Phone = common.fieldType.Phone;
|
|
64
|
+
export import Date = common.fieldType.Date;
|
|
65
|
+
export import DateTime = common.fieldType.DateTime;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const integration: _IIntegration;
|
|
69
|
+
}
|
|
70
|
+
}
|
package/global/global.js
ADDED