@byted-apaas/server-sdk-node 1.0.10 → 1.0.11
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.
|
@@ -105,7 +105,18 @@ class _KunlunFile {
|
|
|
105
105
|
if (typeof (fileTokenOrInfo.id) !== "string") {
|
|
106
106
|
throw new exceptions.InvalidParamError(`The type of fileInfo.id should be string, but ${typeof (fileTokenOrInfo)}`);
|
|
107
107
|
}
|
|
108
|
-
|
|
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);
|
|
109
120
|
}
|
|
110
121
|
else {
|
|
111
122
|
throw new exceptions.InvalidParamError(`The type of first param should be string or object, but ${typeof (fileTokenOrInfo)}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@byted-apaas/server-sdk-node",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.11",
|
|
4
4
|
"description": "aPaaS Server SDK",
|
|
5
5
|
"author": "zhouwexin <zhouwexin@bytedance.com>",
|
|
6
6
|
"homepage": "",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"pre-build": "rm -rf build && tsc"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@byted-apaas/server-common-node": "^1.0.
|
|
15
|
+
"@byted-apaas/server-common-node": "^1.0.12",
|
|
16
16
|
"@jorgeferrero/stream-to-buffer": "^2.0.6",
|
|
17
17
|
"dayjs": "^1.9.6",
|
|
18
18
|
"form-data": "^3.0.0",
|
package/request/innerapi.d.ts
CHANGED
|
@@ -51,6 +51,7 @@ export declare class RequestRpc implements IInnerAPIRequest {
|
|
|
51
51
|
revokeExecution(executionId: number, revokeOptions: RevokeExecutionOptions): Promise<void>;
|
|
52
52
|
getExecutionInfo(executionId: number): Promise<ExecutionInfo>;
|
|
53
53
|
getTenantInfo(appCtx: AppCtx): Promise<any>;
|
|
54
|
+
mGetFileToken(ids: string[]): Promise<string>;
|
|
54
55
|
openSDKCreateRecordBySync(objectApiName: string, record: object): any;
|
|
55
56
|
openSDKUpdateRecordBySync(objectApiName: string, recordID: number, record: object): any;
|
|
56
57
|
openSDKDeleteRecordBySync(objectApiName: string, recordID: number): any;
|
package/request/innerapi.js
CHANGED
|
@@ -481,6 +481,22 @@ async function downloadFileByToken(fileToken, filePath) {
|
|
|
481
481
|
return resp.Data;
|
|
482
482
|
}
|
|
483
483
|
}
|
|
484
|
+
async function mGetFileToken(ids) {
|
|
485
|
+
// 1. params
|
|
486
|
+
let param = {};
|
|
487
|
+
param.AttachmentIDs = ids;
|
|
488
|
+
// 2. prepare request
|
|
489
|
+
let ctx = await pre();
|
|
490
|
+
// 3. do request
|
|
491
|
+
let resp;
|
|
492
|
+
try {
|
|
493
|
+
resp = await rpc.getInnerAPICli().GetAttachmentTokens(ctx, param);
|
|
494
|
+
}
|
|
495
|
+
catch (err) {
|
|
496
|
+
throw new exceptions.InternalError(`Call InnerAPI failed: ${err.message}`);
|
|
497
|
+
}
|
|
498
|
+
return resp.Tokens;
|
|
499
|
+
}
|
|
484
500
|
async function createMessage(msg) {
|
|
485
501
|
// 1. prepare args
|
|
486
502
|
if (!msg.icon) {
|
|
@@ -1055,6 +1071,7 @@ class RequestRpc {
|
|
|
1055
1071
|
this.uploadFile = uploadFile;
|
|
1056
1072
|
this.downloadFileByID = downloadFileByID;
|
|
1057
1073
|
this.downloadFileByToken = downloadFileByToken;
|
|
1074
|
+
this.mGetFileToken = mGetFileToken;
|
|
1058
1075
|
this.createMessage = createMessage;
|
|
1059
1076
|
this.updateMessage = updateMessage;
|
|
1060
1077
|
this.getFields = getFields;
|
|
@@ -1154,6 +1171,9 @@ class RequestRpc {
|
|
|
1154
1171
|
async getTenantInfo(appCtx) {
|
|
1155
1172
|
return await appCtx.credential.getTenantInfo();
|
|
1156
1173
|
}
|
|
1174
|
+
async mGetFileToken(ids) {
|
|
1175
|
+
return null;
|
|
1176
|
+
}
|
|
1157
1177
|
// open sdk empty implement
|
|
1158
1178
|
openSDKCreateRecordBySync(objectApiName, record) {
|
|
1159
1179
|
}
|
|
@@ -1333,6 +1353,10 @@ async function getExecutionUserTaskInfo(executionId) {
|
|
|
1333
1353
|
exports.getExecutionUserTaskInfo = getExecutionUserTaskInfo;
|
|
1334
1354
|
async function invokeFuncSync(idOrName, params) {
|
|
1335
1355
|
let ctx = await pre(true);
|
|
1356
|
+
// 兼容 params 不传的情况
|
|
1357
|
+
if (params === undefined) {
|
|
1358
|
+
params = {};
|
|
1359
|
+
}
|
|
1336
1360
|
let param = {};
|
|
1337
1361
|
param.Namespace = await (0, common_1.getNamespaceForOpenAndFaaSSDK)();
|
|
1338
1362
|
if (idOrName.isInvokeByAPIName) {
|
package/request/interface.d.ts
CHANGED
|
@@ -70,6 +70,7 @@ export interface IInnerAPIBaseRequest {
|
|
|
70
70
|
revokeExecution(executionId: number, revokeOptions: RevokeExecutionOptions): Promise<void>;
|
|
71
71
|
getExecutionInfo(executionId: number): Promise<ExecutionInfo>;
|
|
72
72
|
getTenantInfo(appCtx: AppCtx): Promise<any>;
|
|
73
|
+
mGetFileToken(ids: string[]): Promise<string>;
|
|
73
74
|
}
|
|
74
75
|
export interface IInnerAPIOpenSDKRequest {
|
|
75
76
|
openSDKCreateRecordBySync(objectApiName: string, record: object): any;
|
package/request/openapi.d.ts
CHANGED
|
@@ -52,6 +52,7 @@ export declare class RequestHttp implements IInnerAPIRequest {
|
|
|
52
52
|
revokeExecution(executionId: number, revokeOptions: RevokeExecutionOptions): Promise<void>;
|
|
53
53
|
getExecutionInfo(executionId: number): Promise<ExecutionInfo>;
|
|
54
54
|
getTenantInfo(appCtx: AppCtx): Promise<any>;
|
|
55
|
+
mGetFileToken(ids: string[]): Promise<string>;
|
|
55
56
|
openSDKCreateRecordBySync(objectApiName: string, record: object): any;
|
|
56
57
|
openSDKUpdateRecordBySync(objectApiName: string, recordID: number, record: object): any;
|
|
57
58
|
openSDKDeleteRecordBySync(objectApiName: string, recordID: number): any;
|
package/request/openapi.js
CHANGED
|
@@ -305,7 +305,11 @@ async function mGetFileToken(ids) {
|
|
|
305
305
|
options.json = {
|
|
306
306
|
attachmentIds: ids
|
|
307
307
|
};
|
|
308
|
-
|
|
308
|
+
let res = await openapi.doRequest(null, urlPath, options);
|
|
309
|
+
if (!res || !res.tokens) {
|
|
310
|
+
throw new exceptions.InternalError(`mGetFileToken result is empty`);
|
|
311
|
+
}
|
|
312
|
+
return res.tokens;
|
|
309
313
|
}
|
|
310
314
|
async function createMessage(msg) {
|
|
311
315
|
// 1.解析参数 icon/receiverIds/percent
|
|
@@ -684,6 +688,7 @@ class RequestHttp {
|
|
|
684
688
|
this.uploadFile = uploadFile;
|
|
685
689
|
this.downloadFileByID = downloadFileByID;
|
|
686
690
|
this.downloadFileByToken = downloadFileByToken;
|
|
691
|
+
this.mGetFileToken = mGetFileToken;
|
|
687
692
|
this.createMessage = createMessage;
|
|
688
693
|
this.updateMessage = updateMessage;
|
|
689
694
|
this.getFields = getFields;
|
|
@@ -782,6 +787,9 @@ class RequestHttp {
|
|
|
782
787
|
async getTenantInfo(appCtx) {
|
|
783
788
|
return await appCtx.credential.getTenantInfo();
|
|
784
789
|
}
|
|
790
|
+
mGetFileToken(ids) {
|
|
791
|
+
return null;
|
|
792
|
+
}
|
|
785
793
|
// open sdk empty implement
|
|
786
794
|
openSDKCreateRecordBySync(objectApiName, record) {
|
|
787
795
|
}
|