@byted-apaas/server-sdk-node 1.0.16 → 1.1.0-beta.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.
Files changed (88) hide show
  1. package/README.md +22 -0
  2. package/application/application.d.ts +9 -7
  3. package/application/function/function.d.ts +1 -1
  4. package/application/function/function.js +0 -1
  5. package/application/impl/common.d.ts +1 -1
  6. package/application/impl/common.js +13 -12
  7. package/application/impl/impl.d.ts +8 -6
  8. package/application/impl/impl.js +6 -4
  9. package/common/structs.d.ts +15 -0
  10. package/common/structs.js +21 -0
  11. package/constants/constants.js +4 -4
  12. package/context/context.d.ts +8 -38
  13. package/context/context.js +2 -2
  14. package/context/db/db.d.ts +11 -19
  15. package/context/db/impl/IObject.d.ts +41 -40
  16. package/context/db/impl/db.d.ts +9 -9
  17. package/context/db/impl/db.js +6 -6
  18. package/context/db/impl/object.d.ts +4 -3
  19. package/context/db/impl/object.js +62 -50
  20. package/context/db/impl/oql/oql.d.ts +1 -1
  21. package/context/db/impl/oql/oql.js +1 -1
  22. package/context/db/impl/order.js +1 -1
  23. package/context/db/impl/propertiesStore.js +1 -1
  24. package/context/db/impl/transaction/index.d.ts +1 -1
  25. package/context/db/impl/transaction/index.js +51 -46
  26. package/context/db/impl/transaction.d.ts +0 -5
  27. package/context/integration/IIntegration.d.ts +30 -0
  28. package/context/integration/IIntegration.js +4 -0
  29. package/context/integration/impl/integration.d.ts +16 -0
  30. package/context/integration/impl/integration.js +62 -0
  31. package/context/metadata/components/common.js +3 -3
  32. package/context/metadata/components/components.d.ts +4 -4
  33. package/context/metadata/components/desktop/list.d.ts +3 -3
  34. package/context/metadata/components/desktop/list.js +23 -23
  35. package/context/metadata/components/desktop/recordDetail.d.ts +2 -2
  36. package/context/metadata/components/mobile/list.d.ts +4 -4
  37. package/context/metadata/components/mobile/list.js +1 -1
  38. package/context/metadata/metadata.d.ts +5 -6
  39. package/context/metadata/metadata.js +5 -6
  40. package/context/metadata/objects/fields.d.ts +6 -6
  41. package/context/metadata/objects/fields.js +57 -57
  42. package/context/metadata/objects/fields.util.d.ts +3 -3
  43. package/context/metadata/objects/fields.util.js +21 -21
  44. package/context/metadata/objects/objects.d.ts +1 -1
  45. package/context/metadata/objects/objects.js +1 -1
  46. package/context/metadata/types/components.d.ts +5 -5
  47. package/context/metadata/types/objects.d.ts +88 -88
  48. package/context/msg/msg.d.ts +2 -2
  49. package/context/resources/IResources.d.ts +6 -4
  50. package/context/resources/impl/resources.d.ts +6 -6
  51. package/context/resources/impl/resources.js +5 -5
  52. package/context/tasks/tasks.d.ts +3 -3
  53. package/context/tasks/tasks.js +5 -5
  54. package/data/index.d.ts +2 -2
  55. package/global/application/flow/flow.d.ts +85 -0
  56. package/global/application/flow/flow.js +2 -0
  57. package/global/application/globalVar/globalVar.d.ts +7 -0
  58. package/global/application/globalVar/globalVar.js +2 -0
  59. package/global/global.d.ts +64 -0
  60. package/global/global.js +3 -0
  61. package/hooks/api.d.ts +12 -7
  62. package/hooks/api.js +28 -23
  63. package/hooks/hooks.js +41 -0
  64. package/kunlun/kunlun.d.ts +5 -5
  65. package/kunlun/operator/IOperator.d.ts +16 -16
  66. package/kunlun/operator/impl/expression.d.ts +2 -2
  67. package/kunlun/operator/impl/expression.js +5 -5
  68. package/kunlun/operator/impl/logic.js +48 -31
  69. package/kunlun/operator/impl/logicV2.d.ts +2 -2
  70. package/kunlun/operator/impl/logicV2.js +12 -13
  71. package/kunlun/operator/impl/operator.d.ts +17 -17
  72. package/kunlun/operator/impl/operator.js +38 -38
  73. package/kunlun/operator/impl/operatorV2.d.ts +17 -17
  74. package/kunlun/operator/impl/operatorV2.js +38 -38
  75. package/lib/core.d.ts +3 -3
  76. package/package.json +2 -2
  77. package/request/common.d.ts +1 -1
  78. package/request/common.js +4 -3
  79. package/request/constants.d.ts +1 -1
  80. package/request/constants.js +6 -6
  81. package/request/faasinfra.d.ts +1 -1
  82. package/request/faasinfra.js +41 -253
  83. package/request/innerapi.d.ts +14 -10
  84. package/request/innerapi.js +220 -66
  85. package/request/interface.d.ts +68 -54
  86. package/request/interface.js +8 -9
  87. package/request/openapi.d.ts +15 -11
  88. package/request/openapi.js +266 -158
@@ -10,7 +10,9 @@ const constants_2 = require("./constants");
10
10
  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
- const nodeCls = require("node-cls");
13
+ const permissionUtils = require("@byted-apaas/server-common-node/utils/permissionUtils");
14
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
15
+ const nodeCls = require('node-cls'); //nolint:byted_s_ts_no_require_imports
14
16
  const fs = require('fs');
15
17
  const path = require('path');
16
18
  const commonHttp = common.http;
@@ -26,10 +28,10 @@ async function updateWorkflowVariables(ctx, instanceId, variables, variableTypes
26
28
  let urlPath = options._reqPath.replace(replaceKeys.namespace, await (0, common_1.getNamespaceForOpenAndFaaSSDK)());
27
29
  // 2.请求
28
30
  options.json = {
29
- "operator": -1,
30
- "workflowInstanceID": instanceId,
31
- "variables": JSON.parse(variables),
32
- "variableTypes": JSON.parse(variableTypes),
31
+ 'operator': -1,
32
+ 'workflowInstanceID': instanceId,
33
+ 'variables': JSON.parse(variables),
34
+ 'variableTypes': JSON.parse(variableTypes),
33
35
  };
34
36
  await openapi.doRequest(null, urlPath, options);
35
37
  }
@@ -37,7 +39,7 @@ exports.updateWorkflowVariables = updateWorkflowVariables;
37
39
  async function createRecordBySync(objectApiName, record, authType) {
38
40
  // 1.check
39
41
  if (!objectApiName) {
40
- throw new exceptions.InvalidParamError("objectApiName is empty");
42
+ throw new exceptions.InvalidParamError('objectApiName is empty');
41
43
  }
42
44
  // 2.获取 options
43
45
  let options = commonHttp.getOptions(null, openapiHttpPath.createRecordBySyncV2);
@@ -45,17 +47,17 @@ async function createRecordBySync(objectApiName, record, authType) {
45
47
  urlPath = urlPath.replace(replaceKeys.objectApiName, objectApiName);
46
48
  // 3.请求
47
49
  options.json = {
48
- "operator": utils.getUserIDFromCtx(),
49
- "data": record,
50
+ 'operator': utils.getUserIDFromCtx(),
51
+ 'data': record,
50
52
  };
51
53
  authType = (0, utils_1.formatAuthType)(authType);
52
- options.headers["User"] = utils.getUserIDFromCtx() + "";
54
+ options.headers.User = String(utils.getUserIDFromCtx());
53
55
  if (authType) {
54
56
  options.headers[constants_3.AuthTypeHttpHeader] = authType;
55
57
  }
56
58
  let task_id = utils.getTriggerTaskID();
57
59
  if (task_id) {
58
- options.json["task_id"] = task_id;
60
+ options.json.task_id = task_id;
59
61
  }
60
62
  let data = await openapi.doRequest(null, urlPath, options);
61
63
  if (data && data.record_id) {
@@ -69,7 +71,7 @@ async function createRecordBySync(objectApiName, record, authType) {
69
71
  async function updateRecordBySync(objectApiName, recordID, record, authType) {
70
72
  // 1.check
71
73
  if (!objectApiName) {
72
- throw new exceptions.InvalidParamError("objectApiName is empty");
74
+ throw new exceptions.InvalidParamError('objectApiName is empty');
73
75
  }
74
76
  // 2.获取 options
75
77
  let options = commonHttp.getOptions(null, openapiHttpPath.updateRecordBySyncV2);
@@ -77,25 +79,25 @@ async function updateRecordBySync(objectApiName, recordID, record, authType) {
77
79
  urlPath = urlPath.replace(replaceKeys.objectApiName, objectApiName);
78
80
  // 3.请求
79
81
  options.json = {
80
- "operator": utils.getUserIDFromCtx(),
81
- "record_id": recordID,
82
- "data": record,
82
+ 'operator': utils.getUserIDFromCtx(),
83
+ 'record_id': recordID,
84
+ 'data': record,
83
85
  };
84
86
  authType = (0, utils_1.formatAuthType)(authType);
85
- options.headers["User"] = utils.getUserIDFromCtx() + "";
87
+ options.headers.User = String(utils.getUserIDFromCtx());
86
88
  if (authType) {
87
89
  options.headers[constants_3.AuthTypeHttpHeader] = authType;
88
90
  }
89
91
  let task_id = utils.getTriggerTaskID();
90
92
  if (task_id) {
91
- options.json["task_id"] = task_id;
93
+ options.json.task_id = task_id;
92
94
  }
93
95
  return openapi.doRequest(null, urlPath, options);
94
96
  }
95
97
  async function deleteRecordBySync(objectApiName, recordID, authType) {
96
98
  // 1.check
97
99
  if (!objectApiName) {
98
- throw new exceptions.InvalidParamError("objectApiName is empty");
100
+ throw new exceptions.InvalidParamError('objectApiName is empty');
99
101
  }
100
102
  // 2.获取 options
101
103
  let options = commonHttp.getOptions(null, openapiHttpPath.deleteRecordBySyncV2);
@@ -103,17 +105,17 @@ async function deleteRecordBySync(objectApiName, recordID, authType) {
103
105
  urlPath = urlPath.replace(replaceKeys.objectApiName, objectApiName);
104
106
  // 3.请求
105
107
  options.json = {
106
- "operator": utils.getUserIDFromCtx(),
107
- "record_id": recordID,
108
+ 'operator': utils.getUserIDFromCtx(),
109
+ 'record_id': recordID,
108
110
  };
109
111
  authType = (0, utils_1.formatAuthType)(authType);
110
- options.headers["User"] = utils.getUserIDFromCtx() + "";
112
+ options.headers.User = String(utils.getUserIDFromCtx());
111
113
  if (authType) {
112
114
  options.headers[constants_3.AuthTypeHttpHeader] = authType;
113
115
  }
114
116
  let task_id = utils.getTriggerTaskID();
115
117
  if (task_id) {
116
- options.json["task_id"] = task_id;
118
+ options.json.task_id = task_id;
117
119
  }
118
120
  return openapi.doRequest(null, urlPath, options);
119
121
  }
@@ -124,17 +126,17 @@ async function createRecordsByAsync(objectApiName, records, authType) {
124
126
  urlPath = urlPath.replace(replaceKeys.objectApiName, objectApiName);
125
127
  // 2.请求
126
128
  options.json = {
127
- "operator": utils.getUserIDFromCtx(),
128
- "data": records,
129
+ 'operator': utils.getUserIDFromCtx(),
130
+ 'data': records,
129
131
  };
130
132
  authType = (0, utils_1.formatAuthType)(authType);
131
- options.headers["User"] = utils.getUserIDFromCtx() + "";
133
+ options.headers.User = String(utils.getUserIDFromCtx());
132
134
  if (authType) {
133
135
  options.headers[constants_3.AuthTypeHttpHeader] = authType;
134
136
  }
135
137
  let task_id = utils.getTriggerTaskID();
136
138
  if (task_id) {
137
- options.json["automation_task_id"] = task_id;
139
+ options.json.automation_task_id = task_id;
138
140
  }
139
141
  return openapi.doRequest(null, urlPath, options);
140
142
  }
@@ -145,17 +147,17 @@ async function updateRecordsByAsync(objectApiName, recordMap, authType) {
145
147
  urlPath = urlPath.replace(replaceKeys.objectApiName, objectApiName);
146
148
  // 2.请求
147
149
  options.json = {
148
- "operator": utils.getUserIDFromCtx(),
149
- "data": recordMap,
150
+ 'operator': utils.getUserIDFromCtx(),
151
+ 'data': recordMap,
150
152
  };
151
153
  authType = (0, utils_1.formatAuthType)(authType);
152
- options.headers["User"] = utils.getUserIDFromCtx() + "";
154
+ options.headers.User = String(utils.getUserIDFromCtx());
153
155
  if (authType) {
154
156
  options.headers[constants_3.AuthTypeHttpHeader] = authType;
155
157
  }
156
158
  let task_id = utils.getTriggerTaskID();
157
159
  if (task_id) {
158
- options.json["automation_task_id"] = task_id;
160
+ options.json.automation_task_id = task_id;
159
161
  }
160
162
  return openapi.doRequest(null, urlPath, options);
161
163
  }
@@ -166,17 +168,17 @@ async function deleteRecordsByAsync(objectApiName, recordIDs, authType) {
166
168
  urlPath = urlPath.replace(replaceKeys.objectApiName, objectApiName);
167
169
  // 2.请求
168
170
  options.json = {
169
- "operator": utils.getUserIDFromCtx(),
170
- "record_id_list": recordIDs,
171
+ 'operator': utils.getUserIDFromCtx(),
172
+ 'record_id_list': recordIDs,
171
173
  };
172
174
  authType = (0, utils_1.formatAuthType)(authType);
173
- options.headers["User"] = utils.getUserIDFromCtx() + "";
175
+ options.headers.User = String(utils.getUserIDFromCtx());
174
176
  if (authType) {
175
177
  options.headers[constants_3.AuthTypeHttpHeader] = authType;
176
178
  }
177
179
  let task_id = utils.getTriggerTaskID();
178
180
  if (task_id) {
179
- options.json["automation_task_id"] = task_id;
181
+ options.json.automation_task_id = task_id;
180
182
  }
181
183
  return openapi.doRequest(null, urlPath, options);
182
184
  }
@@ -187,18 +189,18 @@ async function createRecordsBySync(objectApiName, records, authType) {
187
189
  urlPath = urlPath.replace(replaceKeys.objectApiName, objectApiName);
188
190
  // 2.请求
189
191
  options.json = {
190
- "operator": utils.getUserIDFromCtx(),
191
- "set_system_mod": 2,
192
- "data": records,
192
+ 'operator': utils.getUserIDFromCtx(),
193
+ 'set_system_mod': 2,
194
+ 'data': records,
193
195
  };
194
196
  authType = (0, utils_1.formatAuthType)(authType);
195
- options.headers["User"] = utils.getUserIDFromCtx() + "";
197
+ options.headers.User = String(utils.getUserIDFromCtx());
196
198
  if (authType) {
197
199
  options.headers[constants_3.AuthTypeHttpHeader] = authType;
198
200
  }
199
201
  let task_id = utils.getTriggerTaskID();
200
202
  if (task_id) {
201
- options.json["automation_task_id"] = task_id;
203
+ options.json.automation_task_id = task_id;
202
204
  }
203
205
  return openapi.doRequest(null, urlPath, options);
204
206
  }
@@ -209,20 +211,28 @@ async function updateRecordsBySync(objectApiName, recordMap, authType) {
209
211
  urlPath = urlPath.replace(replaceKeys.objectApiName, objectApiName);
210
212
  // 2.请求
211
213
  options.json = {
212
- "operator": utils.getUserIDFromCtx(),
213
- "set_system_mod": 2,
214
- "data": recordMap,
214
+ 'operator': utils.getUserIDFromCtx(),
215
+ 'set_system_mod': 2,
216
+ 'data': recordMap,
215
217
  };
216
218
  authType = (0, utils_1.formatAuthType)(authType);
217
- options.headers["User"] = utils.getUserIDFromCtx() + "";
219
+ options.headers.User = String(utils.getUserIDFromCtx());
218
220
  if (authType) {
219
221
  options.headers[constants_3.AuthTypeHttpHeader] = authType;
220
222
  }
221
223
  let task_id = utils.getTriggerTaskID();
222
224
  if (task_id) {
223
- options.json["automation_task_id"] = task_id;
225
+ options.json.automation_task_id = task_id;
224
226
  }
225
- return openapi.doRequest(null, urlPath, options);
227
+ const resp = await openapi.doRequest(null, urlPath, options);
228
+ if (!resp || !resp.err_map) {
229
+ return undefined;
230
+ }
231
+ const errMap = {};
232
+ for (let recordID of Object.keys(resp.err_map)) {
233
+ errMap[Number(recordID)] = resp.err_map[recordID];
234
+ }
235
+ return errMap;
226
236
  }
227
237
  async function deleteRecordsBySync(objectApiName, recordIDs, authType) {
228
238
  // 1.获取 options
@@ -231,32 +241,44 @@ async function deleteRecordsBySync(objectApiName, recordIDs, authType) {
231
241
  urlPath = urlPath.replace(replaceKeys.objectApiName, objectApiName);
232
242
  // 2.请求
233
243
  options.json = {
234
- "operator": utils.getUserIDFromCtx(),
235
- "set_system_mod": 2,
236
- "record_id_list": recordIDs,
244
+ 'operator': utils.getUserIDFromCtx(),
245
+ 'set_system_mod': 2,
246
+ 'record_id_list': recordIDs,
237
247
  };
238
248
  authType = (0, utils_1.formatAuthType)(authType);
239
- options.headers["User"] = utils.getUserIDFromCtx() + "";
249
+ options.headers.User = String(utils.getUserIDFromCtx());
240
250
  if (authType) {
241
251
  options.headers[constants_3.AuthTypeHttpHeader] = authType;
242
252
  }
243
253
  let task_id = utils.getTriggerTaskID();
244
254
  if (task_id) {
245
- options.json["automation_task_id"] = task_id;
255
+ options.json.automation_task_id = task_id;
246
256
  }
247
- return openapi.doRequest(null, urlPath, options);
257
+ const resp = await openapi.doRequest(null, urlPath, options);
258
+ if (!resp || !resp.err_map) {
259
+ return undefined;
260
+ }
261
+ const errMap = {};
262
+ for (let recordID of Object.keys(resp.err_map)) {
263
+ errMap[Number(recordID)] = resp.err_map[recordID];
264
+ }
265
+ return errMap;
248
266
  }
249
- function handleResponse(data, needCount) {
267
+ function handleResponse(objectAPIName, data, needCount) {
250
268
  // 返回数据的特殊处理
251
269
  if (needCount) {
252
- if (checkUtils.isObject(data) && data["total"]) {
253
- return data["total"];
270
+ if (checkUtils.isObject(data) && data.total) {
271
+ return data.total;
254
272
  }
255
273
  return 0;
256
274
  }
257
275
  else {
258
- if (checkUtils.isObject(data) && data["data_list"]) {
259
- return data["data_list"];
276
+ if (checkUtils.isObject(data) && data.data_list) {
277
+ const records = data.data_list;
278
+ if (data.unauthPermissionInfo && data.unauthPermissionInfo.UnauthFieldSlice) {
279
+ permissionUtils.appendUnauthFieldRecordList(objectAPIName, records, data.unauthPermissionInfo.UnauthFieldSlice, true);
280
+ }
281
+ return records;
260
282
  }
261
283
  return [];
262
284
  }
@@ -264,7 +286,7 @@ function handleResponse(data, needCount) {
264
286
  async function getRecordsOrCountByCriterion(objectApiName, criterion, fuzzySearch, order, ignoreBackLookupField, fieldApiNames, offset, limit, needCount, authType) {
265
287
  // 1.check
266
288
  if (!objectApiName) {
267
- throw new exceptions.InternalError("objectApiName is empty");
289
+ throw new exceptions.InternalError('objectApiName is empty');
268
290
  }
269
291
  // 2.获取 options
270
292
  let options = commonHttp.getOptions(null, needCount ? openapiHttpPath.mGetCountByCriterionV2 : openapiHttpPath.mGetRecordByCriterionV2);
@@ -272,35 +294,45 @@ async function getRecordsOrCountByCriterion(objectApiName, criterion, fuzzySearc
272
294
  urlPath = urlPath.replace(replaceKeys.objectApiName, objectApiName);
273
295
  // 3.请求
274
296
  options.json = {
275
- "criterion": JSON.parse(criterion),
276
- "order": order,
277
- "ignore_back_lookup_field": ignoreBackLookupField,
278
- "field_api_names": fieldApiNames,
279
- "offset": offset,
280
- "limit": limit,
281
- "need_filter_user_permission": false,
282
- "need_total_count": needCount,
283
- "fuzzySearch": fuzzySearch,
297
+ 'criterion': JSON.parse(criterion),
298
+ order,
299
+ 'ignore_back_lookup_field': ignoreBackLookupField,
300
+ 'field_api_names': fieldApiNames,
301
+ offset,
302
+ limit,
303
+ 'need_filter_user_permission': false,
304
+ 'need_total_count': needCount,
305
+ fuzzySearch,
306
+ // 只返回 slice 结果,使用 SliceResult
307
+ // 只返回 map 结果,使用 MapResult
308
+ // 分不清场景可以用 BothResult,性能较差,建议区分场景
309
+ // 0 表示不返回 unauth field 任何数据; 1 表示两者都返回;2 表示仅返回 slice;3 表示仅返回 map
310
+ 'process_auth_field_type': 2,
284
311
  };
285
312
  authType = (0, utils_1.formatAuthType)(authType);
286
- options.headers["User"] = utils.getUserIDFromCtx() + "";
313
+ options.headers.User = String(utils.getUserIDFromCtx());
287
314
  if (authType) {
288
315
  options.headers[constants_3.AuthTypeHttpHeader] = authType;
289
316
  }
290
317
  let data = await openapi.doRequest(null, urlPath, options);
291
- return handleResponse(data, needCount);
318
+ return handleResponse(objectApiName, data, needCount);
292
319
  }
293
320
  /**
294
321
  * 上传文件
295
322
  *
296
- * @param ctx
297
323
  * @param datas:filePath;Stream
298
- * @param expire(seconds)
324
+ * @param expire:过期时间,单位秒
325
+ * @param fileName:文件名
299
326
  * @returns {Promise<*|string>}
300
327
  */
301
- async function uploadFile(datas, expire = 0) {
328
+ async function uploadFile(datas, expire = 0, fileName) {
302
329
  let formData = new FormData();
303
- formData.append('file', datas);
330
+ if (fileName) {
331
+ formData.append('file', datas, fileName);
332
+ }
333
+ else {
334
+ formData.append('file', datas);
335
+ }
304
336
  formData.append('expireSeconds', expire.toString());
305
337
  formData.append('ignoreUserId', 'true');
306
338
  let formHeaders = formData.getHeaders();
@@ -319,7 +351,7 @@ async function downloadFileByID(id, filePath) {
319
351
  // 1.获取 options
320
352
  let options = commonHttp.getOptions(null, openapiHttpPath.downloadFile);
321
353
  let urlPath = options._reqPath.replace(replaceKeys.fileID, id);
322
- options.responseType = "buffer";
354
+ options.responseType = 'buffer';
323
355
  // 2.请求
324
356
  let data = await openapi.doRequest(null, urlPath, options);
325
357
  // 3.写入文件
@@ -328,7 +360,7 @@ async function downloadFileByID(id, filePath) {
328
360
  checkUtils.checkFile(filePath);
329
361
  utils.mkdirs(path.dirname(filePath));
330
362
  fs.writeFileSync(filePath, data);
331
- return;
363
+ return undefined;
332
364
  }
333
365
  return data;
334
366
  }
@@ -336,7 +368,7 @@ async function downloadFileByToken(fileToken, filePath) {
336
368
  // 1.获取 options
337
369
  let options = commonHttp.getOptions(null, openapiHttpPath.downloadAttachment);
338
370
  let urlPath = options._reqPath + `?token=${fileToken}`;
339
- options.responseType = "buffer";
371
+ options.responseType = 'buffer';
340
372
  // 2.请求
341
373
  let data = await openapi.doRequest(null, urlPath, options);
342
374
  // 3.写入文件
@@ -345,7 +377,7 @@ async function downloadFileByToken(fileToken, filePath) {
345
377
  checkUtils.checkFile(filePath);
346
378
  utils.mkdirs(path.dirname(filePath));
347
379
  fs.writeFileSync(filePath, data);
348
- return;
380
+ return undefined;
349
381
  }
350
382
  return data;
351
383
  }
@@ -372,24 +404,24 @@ async function createMessage(msg) {
372
404
  throw new exceptions.InvalidParamError(`Invalid format of parameter icon, icon should be string.`);
373
405
  }
374
406
  let params = {};
375
- let modelKeySearchData = { "icon_type": msg.icon };
376
- let receiverIds = msg["target_users"] || [];
407
+ const modelKeySearchData = { 'icon_type': msg.icon };
408
+ const receiverIds = msg.target_users || [];
377
409
  if (!(receiverIds instanceof Array)) {
378
410
  throw new exceptions.InvalidParamError(`Invalid format of parameter target_users, target_users should be array.`);
379
411
  }
380
412
  if (receiverIds.length === 0) {
381
413
  throw new exceptions.InvalidParamError(`parameter target_users is required!`);
382
414
  }
383
- let percent = msg["percent"];
415
+ const percent = msg.percent;
384
416
  if (percent !== undefined && percent !== null) {
385
- if (typeof (percent) != 'number') {
386
- throw new exceptions.InvalidParamError(`Invalid format of parameter percent, percent should be number.`);
417
+ if (typeof (percent) !== 'number') {
418
+ throw new exceptions.InvalidParamError('Invalid format of parameter percent, percent should be number.');
387
419
  }
388
420
  if (percent < 0 || percent > 100) {
389
- throw new exceptions.InvalidParamError(`Invalid value of parameter percent, the value should be in range [0, 100].`);
421
+ throw new exceptions.InvalidParamError('Invalid value of parameter percent, the value should be in range [0, 100].');
390
422
  }
391
423
  else {
392
- modelKeySearchData["percent"] = JSON.stringify(percent);
424
+ modelKeySearchData.percent = JSON.stringify(percent);
393
425
  }
394
426
  }
395
427
  // kunlun类型
@@ -400,7 +432,7 @@ async function createMessage(msg) {
400
432
  // if (msg[key] instanceof fieldType.Multilingual) {
401
433
  if (fieldType.isKFieldTypeMultilingual((msg[key]))) {
402
434
  let value = JSON.stringify(msg[key].toJSON());
403
- params[key] = JSON.stringify({ "value": value });
435
+ params[key] = JSON.stringify({ value });
404
436
  }
405
437
  else {
406
438
  params[key] = JSON.stringify(msg[key].toJSON());
@@ -416,11 +448,11 @@ async function createMessage(msg) {
416
448
  let urlPath = options._reqPath.replace(replaceKeys.namespace, await (0, common_1.getNamespaceForOpenAndFaaSSDK)());
417
449
  // 3.请求
418
450
  options.json = {
419
- "NotifyModelKey": constants_1.notifyModel.key,
420
- "ReceiverIDs": receiverIds,
421
- "ParamsRawData": params,
422
- "Percent": percent,
423
- "ModelKeySearchData": modelKeySearchData
451
+ 'NotifyModelKey': constants_1.notifyModel.key,
452
+ 'ReceiverIDs': receiverIds,
453
+ 'ParamsRawData': params,
454
+ 'Percent': percent,
455
+ 'ModelKeySearchData': modelKeySearchData,
424
456
  };
425
457
  let res = await openapi.doRequest(null, urlPath, options);
426
458
  return Number(res.taskID);
@@ -440,17 +472,17 @@ async function updateMessage(msgId, msg) {
440
472
  throw new exceptions.InvalidParamError(`Invalid format of parameter icon, icon should be string.`);
441
473
  }
442
474
  let params = {};
443
- let modelKeySearchData = { "icon_type": msg.icon };
444
- let percent = msg["percent"];
475
+ const modelKeySearchData = { 'icon_type': msg.icon };
476
+ const percent = msg.percent;
445
477
  if (percent !== undefined && percent !== null) {
446
- if (typeof (percent) != 'number') {
447
- throw new exceptions.InvalidParamError(`Invalid format of parameter percent, percent should be number.`);
478
+ if (typeof (percent) !== 'number') {
479
+ throw new exceptions.InvalidParamError('Invalid format of parameter percent, percent should be number.');
448
480
  }
449
481
  if (percent < 0 || percent > 100) {
450
- throw new exceptions.InvalidParamError(`Invalid value of parameter percent in message ${msgId}, the value should be in range [0, 100].`);
482
+ throw new exceptions.InvalidParamError('Invalid value of parameter percent in message ${msgId}, the value should be in range [0, 100].');
451
483
  }
452
484
  else {
453
- modelKeySearchData["percent"] = JSON.stringify(percent);
485
+ modelKeySearchData.percent = JSON.stringify(percent);
454
486
  }
455
487
  }
456
488
  // kunlun类型
@@ -461,7 +493,7 @@ async function updateMessage(msgId, msg) {
461
493
  // if (msg[key] instanceof fieldType.Multilingual) {
462
494
  if (fieldType.isKFieldTypeMultilingual(msg[key])) {
463
495
  let value = JSON.stringify(msg[key].toJSON());
464
- params[key] = JSON.stringify({ "value": value });
496
+ params[key] = JSON.stringify({ value });
465
497
  }
466
498
  else {
467
499
  params[key] = JSON.stringify(msg[key].toJSON());
@@ -477,19 +509,19 @@ async function updateMessage(msgId, msg) {
477
509
  let urlPath = options._reqPath.replace(replaceKeys.namespace, await (0, common_1.getNamespaceForOpenAndFaaSSDK)());
478
510
  // 3.请求
479
511
  options.json = {
480
- "TaskID": msgId,
481
- "Percent": percent,
482
- "NotifyModelKey": constants_1.notifyModel.key,
483
- "ParamsRawData": params,
484
- "IsBackground": true,
485
- "ModelKeySearchData": modelKeySearchData
512
+ 'TaskID': msgId,
513
+ 'Percent': percent,
514
+ 'NotifyModelKey': constants_1.notifyModel.key,
515
+ 'ParamsRawData': params,
516
+ 'IsBackground': true,
517
+ 'ModelKeySearchData': modelKeySearchData,
486
518
  };
487
519
  return await openapi.doRequest(null, urlPath, options);
488
520
  }
489
521
  async function getFields(objectApiName) {
490
522
  // 1.check
491
523
  if (!objectApiName) {
492
- throw new exceptions.InvalidParamError("objectApiName is empty");
524
+ throw new exceptions.InvalidParamError('objectApiName is empty');
493
525
  }
494
526
  // 2.获取config
495
527
  let options = commonHttp.getOptions(null, openapiHttpPath.getFieldsV5);
@@ -504,10 +536,10 @@ async function getFields(objectApiName) {
504
536
  async function getField(objectApiName, fieldApiName) {
505
537
  // 1.check
506
538
  if (!objectApiName) {
507
- throw new exceptions.InternalError("objectApiName is empty");
539
+ throw new exceptions.InternalError('objectApiName is empty');
508
540
  }
509
541
  if (!fieldApiName) {
510
- throw new exceptions.InternalError("fieldApiName is empty");
542
+ throw new exceptions.InternalError('fieldApiName is empty');
511
543
  }
512
544
  // 2.获取 options
513
545
  let options = commonHttp.getOptions(null, openapiHttpPath.getFieldV5);
@@ -519,7 +551,7 @@ async function getField(objectApiName, fieldApiName) {
519
551
  }
520
552
  async function terminateWorkflowInstance(workflowInstanceId, operator, reason) {
521
553
  // 1.check
522
- if (typeof (workflowInstanceId) !== "number") {
554
+ if (typeof (workflowInstanceId) !== 'number') {
523
555
  throw new exceptions.InvalidParamError(`The type of workflowInstanceId should be number, but ${typeof (workflowInstanceId)}.`);
524
556
  }
525
557
  // 2.获取 options
@@ -527,9 +559,9 @@ async function terminateWorkflowInstance(workflowInstanceId, operator, reason) {
527
559
  let urlPath = options._reqPath;
528
560
  // 3.请求
529
561
  options.json = {
530
- "workflowInstanceID": workflowInstanceId,
531
- "operator": operator,
532
- "reason": reason,
562
+ 'workflowInstanceID': workflowInstanceId,
563
+ operator,
564
+ reason,
533
565
  };
534
566
  await openapi.doRequest(null, urlPath, options);
535
567
  }
@@ -539,19 +571,19 @@ async function modifyRecordsWithTransaction(placeholders, operations, authType)
539
571
  let urlPath = options._reqPath.replace(replaceKeys.namespace, await (0, common_1.getNamespaceForOpenAndFaaSSDK)());
540
572
  // 2.请求
541
573
  options.json = {
542
- "placeholders": placeholders,
543
- "operations": operations,
544
- "operatorId": utils.getUserIDFromCtx(),
545
- "setSystemField": 1,
574
+ placeholders,
575
+ operations,
576
+ 'operatorId': utils.getUserIDFromCtx(),
577
+ 'setSystemField': 1,
546
578
  };
547
579
  authType = (0, utils_1.formatAuthType)(authType);
548
- options.headers["User"] = utils.getUserIDFromCtx() + "";
580
+ options.headers.User = String(utils.getUserIDFromCtx());
549
581
  if (authType) {
550
582
  options.headers[constants_3.AuthTypeHttpHeader] = authType;
551
583
  }
552
584
  let taskId = utils.getTriggerTaskID();
553
585
  if (taskId) {
554
- options.json["taskId"] = taskId;
586
+ options.json.taskId = taskId;
555
587
  }
556
588
  let result = await openapi.doRequest(null, urlPath, options);
557
589
  let retPlaceholders = new Map();
@@ -570,11 +602,11 @@ async function getGlobalConfigByKey(key) {
570
602
  let pageSize = 100, offset = 0;
571
603
  for (let i = 0;; i++) {
572
604
  options.json = {
573
- "biz_type": "GlobalVariables",
574
- "used_by": "UsedBySystem",
575
- "filter": {
576
- "offset": offset * i,
577
- "limit": pageSize
605
+ 'biz_type': 'GlobalVariables',
606
+ 'used_by': 'UsedBySystem',
607
+ 'filter': {
608
+ 'offset': offset * i,
609
+ 'limit': pageSize,
578
610
  },
579
611
  };
580
612
  let data = await openapi.doRequest(null, urlPath, options);
@@ -595,18 +627,24 @@ async function oql(oql, args, namedArgs, authType) {
595
627
  let urlPath = options._reqPath.replace(replaceKeys.namespace, await (0, common_1.getNamespaceForOpenAndFaaSSDK)());
596
628
  // 2.请求
597
629
  options.json = {
598
- "query": oql,
599
- "args": args,
600
- "namedArgs": namedArgs,
601
- "compat": true,
630
+ 'query': oql,
631
+ args,
632
+ namedArgs,
633
+ 'compat': true,
634
+ 'unauthFields': true,
602
635
  };
603
636
  authType = (0, utils_1.formatAuthType)(authType);
604
- options.headers["User"] = utils.getUserIDFromCtx() + "";
637
+ options.headers.User = String(utils.getUserIDFromCtx());
605
638
  if (authType) {
639
+ if (authType === constants_3.AuthTypeUser || authType === constants_3.AuthTypeMixUserSystem) {
640
+ // select 鉴权,where、groupBy、orderBy 不鉴权
641
+ authType = constants_3.AuthTypeMixUserSystem;
642
+ }
606
643
  options.headers[constants_3.AuthTypeHttpHeader] = authType;
607
644
  }
608
645
  let result = await openapi.doRequest(null, urlPath, options);
609
646
  if (result && result.rows) {
647
+ permissionUtils.appendUnauthFieldRecordList("", result.rows, result.unauth_field_slice, true);
610
648
  return result.rows;
611
649
  }
612
650
  return [];
@@ -620,7 +658,6 @@ async function openSDKCreateRecordBySync(objectApiName, record) {
620
658
  options.json = record;
621
659
  return await openapi.doRequest(null, urlPath, options);
622
660
  }
623
- ;
624
661
  async function openSDKUpdateRecordBySync(objectApiName, recordID, record) {
625
662
  // 1.获取 options
626
663
  let options = commonHttp.getOptions(null, openapiHttpPath.openSDKUpdateRecord);
@@ -727,7 +764,7 @@ async function openSDKDownloadAvatar(imageID) {
727
764
  let options = commonHttp.getOptions(null, openapiHttpPath.openSDKDownloadAvatar);
728
765
  let urlPath = options._reqPath.replace(replaceKeys.namespace, await (0, common_1.getNamespaceForOpenAndFaaSSDK)());
729
766
  urlPath = urlPath.replace(replaceKeys.fileID, imageID);
730
- options.responseType = "buffer";
767
+ options.responseType = 'buffer';
731
768
  // 2.请求
732
769
  let data = await openapi.doRequest(null, urlPath, options);
733
770
  // 3.写入文件
@@ -759,6 +796,10 @@ class RequestHttp {
759
796
  this.modifyRecordsWithTransaction = modifyRecordsWithTransaction;
760
797
  this.getGlobalConfigByKey = getGlobalConfigByKey;
761
798
  this.oql = oql;
799
+ this.getIntegrationAppAccessToken = getIntegrationAppAccessToken;
800
+ this.getIntegrationTenantAccessToken = getIntegrationTenantAccessToken;
801
+ this.getDefaultIntegrationAppAccessToken = getDefaultIntegrationAppAccessToken;
802
+ this.getDefaultIntegrationTenantAccessToken = getDefaultIntegrationTenantAccessToken;
762
803
  // TODO: open sdk api test
763
804
  this.openSDKCreateRecordBySync = openSDKCreateRecordBySync;
764
805
  this.openSDKUpdateRecordBySync = openSDKUpdateRecordBySync;
@@ -788,17 +829,21 @@ class RequestHttp {
788
829
  createRecordsBySync(objectApiName, records, authType) {
789
830
  }
790
831
  updateRecordsBySync(objectApiName, recordMap, authType) {
832
+ return undefined;
791
833
  }
792
834
  deleteRecordsBySync(objectApiName, recordIDs, authType) {
835
+ return undefined;
793
836
  }
794
837
  getRecordsOrCountByCriterion(objectApiName, criterion, order, fuzzySearch, ignoreBackLookupField, fieldApiNames, offset, limit, needCount, authType) {
795
838
  }
796
- uploadFile(data, expire) {
839
+ uploadFile(data, expire, fileName) {
797
840
  return null;
798
841
  }
842
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
799
843
  downloadFileByID(fileID, filePath) {
800
844
  return null;
801
845
  }
846
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
802
847
  downloadFileByToken(fileToken, filePath) {
803
848
  return null;
804
849
  }
@@ -852,6 +897,18 @@ class RequestHttp {
852
897
  mGetFileToken(ids) {
853
898
  return null;
854
899
  }
900
+ async getIntegrationAppAccessToken(apiName) {
901
+ return null;
902
+ }
903
+ async getIntegrationTenantAccessToken(apiName) {
904
+ return null;
905
+ }
906
+ async getDefaultIntegrationAppAccessToken() {
907
+ return null;
908
+ }
909
+ async getDefaultIntegrationTenantAccessToken() {
910
+ return null;
911
+ }
855
912
  // open sdk empty implement
856
913
  openSDKCreateRecordBySync(objectApiName, record) {
857
914
  }
@@ -891,10 +948,10 @@ async function invokeFuncWithAuth(idOrName, params) {
891
948
  let options = commonHttp.getOptions(null, openapiHttpPath.invokeFuncWithAuthInnerAPI);
892
949
  let urlPath = options._reqPath.replace(replaceKeys.namespace, await (0, common_1.getNamespaceForOpenAndFaaSSDK)());
893
950
  urlPath = urlPath.replace(replaceKeys.apiName, idOrName.APIName);
894
- options.headers["User"] = utils.getUserIDFromCtx();
951
+ options.headers.User = utils.getUserIDFromCtx();
895
952
  options.json = {
896
- "params": params,
897
- "context": getTriggerCtx(),
953
+ params,
954
+ 'context': getTriggerCtx(),
898
955
  };
899
956
  if (!idOrName.isInvokeByAPIName) {
900
957
  options.json.apiID = idOrName.APIId;
@@ -910,49 +967,52 @@ async function invokeFuncWithAuth(idOrName, params) {
910
967
  catch (e) {
911
968
  throw new exceptions.InternalError(`JSON parse failed for ${res.result}`);
912
969
  }
913
- if (!result || result.code !== "0") {
914
- throw new exceptions.InvalidParamError(`result is invalid for code: ${result ? result.code : ""} msg: ${result ? result.msg : ""}`);
970
+ if (!result || result.code !== '0') {
971
+ throw new exceptions.InvalidParamError(`result is invalid for code: ${result ? result.code : ''} msg: ${result ? result.msg : ''}`);
915
972
  }
916
973
  return result.data;
917
974
  }
918
975
  async function invokeFuncSync(idOrName, params) {
919
976
  let options = commonHttp.getOptions(null, openapiHttpPath.invokeFuncSyncInnerAPI);
920
977
  let urlPath = options._reqPath.replace(replaceKeys.namespace, await (0, common_1.getNamespaceForOpenAndFaaSSDK)());
921
- options.headers["User"] = utils.getUserIDFromCtx();
978
+ options.headers.User = utils.getUserIDFromCtx();
922
979
  options.json = {
923
- "params": JSON.stringify(params),
924
- "context": JSON.stringify(getTriggerCtx()),
925
- "triggerType": utils.getTriggerType(),
980
+ 'params': JSON.stringify(params),
981
+ 'context': JSON.stringify(getTriggerCtx()),
982
+ 'triggerType': utils.getTriggerType(),
926
983
  };
927
984
  // 相等时,表示是新版本函数的场景
928
985
  if (idOrName.isInvokeByAPIName) {
929
986
  options.json.apiAlias = idOrName.APIName;
930
- options.json.function_name = "";
987
+ options.json.function_name = '';
931
988
  }
932
989
  else {
933
990
  options.json.function_name = idOrName.APIId;
934
- options.json.apiAlias = "";
991
+ options.json.apiAlias = '';
935
992
  }
936
993
  let res = await openapi.doRequest(null, urlPath, options);
937
- if (res && res.code === "0") {
994
+ if (!res) {
995
+ throw new exceptions.InternalError(`InvokeFuncSync result is empty`);
996
+ }
997
+ if (res && res.code === '0') {
938
998
  return res.data;
939
999
  }
940
- throw new exceptions.InternalError(`invokeFuncSync result.code(${res.code}) is invalid`);
1000
+ throw new exceptions.BaseError(res.code, res.msg);
941
1001
  }
942
1002
  async function createAsyncTaskV1(idOrName, params) {
943
1003
  // attention: 异步任务接口存在先后区别,接口版本号不一致需 check,v1->v2
944
1004
  let options = commonHttp.getOptions(null, openapiHttpPath.createAsyncTaskInnerAPIV2);
945
1005
  let urlPath = options._reqPath.replace(replaceKeys.namespace, await (0, common_1.getNamespaceForOpenAndFaaSSDK)());
946
- options.headers["User"] = utils.getUserIDFromCtx();
1006
+ options.headers.User = utils.getUserIDFromCtx();
947
1007
  options.json = {
948
- "params": JSON.stringify(params),
949
- "context": JSON.stringify(getTriggerCtx()),
950
- "triggerType": utils.getTriggerType(),
1008
+ 'params': JSON.stringify(params),
1009
+ 'context': JSON.stringify(getTriggerCtx()),
1010
+ 'triggerType': utils.getTriggerType(),
951
1011
  };
952
1012
  // 相等时,表示是新版本函数的场景
953
1013
  if (idOrName.isInvokeByAPIName) {
954
1014
  options.json.apiAlias = idOrName.APIName;
955
- options.json.function_name = ""; // required
1015
+ options.json.function_name = ''; // required
956
1016
  }
957
1017
  else {
958
1018
  options.json.function_name = idOrName.APIId;
@@ -979,13 +1039,13 @@ async function createAsyncTaskV2(APIName, params) {
979
1039
  if (checkLoopCtx(reqCtx)) {
980
1040
  triggerCtx[constants_3.headers.loopMasks] = reqCtx.loopMasks;
981
1041
  }
982
- options.headers["User"] = utils.getUserIDFromCtx();
1042
+ options.headers.User = utils.getUserIDFromCtx();
983
1043
  options.json = {
984
- "apiAlias": APIName,
985
- "params": JSON.stringify(params),
986
- "context": JSON.stringify(getTriggerCtx()),
987
- "triggerType": utils.getTriggerType(),
988
- "extra": (0, common_1.getDebugExtraInfo)()
1044
+ 'apiAlias': APIName,
1045
+ 'params': JSON.stringify(params),
1046
+ 'context': JSON.stringify(getTriggerCtx()),
1047
+ 'triggerType': utils.getTriggerType(),
1048
+ 'extra': (0, common_1.getDebugExtraInfo)(),
989
1049
  };
990
1050
  let res = await openapi.doRequest(null, urlPath, options);
991
1051
  if (res && res.task_id) {
@@ -1013,14 +1073,14 @@ function getTriggerCtx() {
1013
1073
  }
1014
1074
  async function getExecutionUserTaskInfo(executionId) {
1015
1075
  if (!executionId) {
1016
- throw new exceptions.InvalidParamError(`executionId is empty`);
1076
+ throw new exceptions.InvalidParamError('executionId is empty');
1017
1077
  }
1018
1078
  let options = commonHttp.getOptions(null, constants_2.openapiHttpPath.getExecutionUserTaskInfo);
1019
1079
  let urlPath = options._reqPath.replace(replaceKeys.namespace, await (0, common_1.getNamespaceForOpenAndFaaSSDK)()).replace(replaceKeys.id, `${executionId}`);
1020
1080
  urlPath += `?operator=${utils.getUserIDFromCtx()}`;
1021
1081
  let res = await openapi.doRequest(null, urlPath, options);
1022
1082
  if (!res) {
1023
- throw new exceptions.InternalError(`getExecutionUserTaskInfo result is empty`);
1083
+ throw new exceptions.InternalError('getExecutionUserTaskInfo result is empty');
1024
1084
  }
1025
1085
  return res.taskList;
1026
1086
  }
@@ -1032,9 +1092,9 @@ async function executeFlow(APIName, option) {
1032
1092
  let options = commonHttp.getOptions(null, constants_2.openapiHttpPath.executeFlow);
1033
1093
  let urlPath = options._reqPath.replace(replaceKeys.namespace, await (0, common_1.getNamespaceForOpenAndFaaSSDK)()).replace(replaceKeys.apiName, APIName);
1034
1094
  options.json = {
1035
- "operator": utils.getUserIDFromCtx(),
1036
- "variables": (0, common_1.transMapToFlowVariable)(option.params),
1037
- "loopMasks": utils.getLoopMasks(),
1095
+ 'operator': utils.getUserIDFromCtx(),
1096
+ 'variables': (0, common_1.transMapToFlowVariable)(option.params),
1097
+ 'loopMasks': utils.getLoopMasks(),
1038
1098
  };
1039
1099
  let res = await openapi.doRequest(null, urlPath, options);
1040
1100
  return {
@@ -1060,8 +1120,8 @@ async function revokeExecution(executionId, revokeOptions) {
1060
1120
  };
1061
1121
  }
1062
1122
  options.json = {
1063
- "operator": utils.getUserIDFromCtx(),
1064
- "reason": reason,
1123
+ 'operator': utils.getUserIDFromCtx(),
1124
+ reason,
1065
1125
  };
1066
1126
  return await openapi.doRequest(null, urlPath, options);
1067
1127
  }
@@ -1085,3 +1145,51 @@ async function getExecutionInfo(executionId) {
1085
1145
  };
1086
1146
  }
1087
1147
  exports.getExecutionInfo = getExecutionInfo;
1148
+ async function getIntegrationAppAccessToken(apiName) {
1149
+ // 1.check
1150
+ if (!apiName) {
1151
+ throw new exceptions.InvalidParamError('apiName is empty');
1152
+ }
1153
+ let options = commonHttp.getOptions(null, openapiHttpPath.getIntegrationAppAccessTokenAPI);
1154
+ let urlPath = options._reqPath.replace(replaceKeys.namespace, await (0, common_1.getNamespaceForOpenAndFaaSSDK)()).replace(replaceKeys.apiName, `${apiName}`);
1155
+ let res = await openapi.doRequest(null, urlPath, options);
1156
+ return {
1157
+ expire: res.expire,
1158
+ appAccessToken: res.appAccessToken,
1159
+ appId: res.appId,
1160
+ };
1161
+ }
1162
+ async function getIntegrationTenantAccessToken(apiName) {
1163
+ // 1.check
1164
+ if (!apiName) {
1165
+ throw new exceptions.InvalidParamError('apiName is empty');
1166
+ }
1167
+ let options = commonHttp.getOptions(null, openapiHttpPath.getIntegrationTenantAccessTokenAPI);
1168
+ let urlPath = options._reqPath.replace(replaceKeys.namespace, await (0, common_1.getNamespaceForOpenAndFaaSSDK)()).replace(replaceKeys.apiName, `${apiName}`);
1169
+ let res = await openapi.doRequest(null, urlPath, options);
1170
+ return {
1171
+ expire: res.expire,
1172
+ tenantAccessToken: res.tenantAccessToken,
1173
+ appId: res.appId,
1174
+ };
1175
+ }
1176
+ async function getDefaultIntegrationAppAccessToken() {
1177
+ let options = commonHttp.getOptions(null, openapiHttpPath.getDefaultIntegrationAppAccessTokenAPI);
1178
+ let urlPath = options._reqPath.replace(replaceKeys.namespace, await (0, common_1.getNamespaceForOpenAndFaaSSDK)());
1179
+ let res = await openapi.doRequest(null, urlPath, options);
1180
+ return {
1181
+ expire: res.expire,
1182
+ appAccessToken: res.appAccessToken,
1183
+ appId: res.appId,
1184
+ };
1185
+ }
1186
+ async function getDefaultIntegrationTenantAccessToken() {
1187
+ let options = commonHttp.getOptions(null, openapiHttpPath.getDefaultIntegrationTenantAccessTokenAPI);
1188
+ let urlPath = options._reqPath.replace(replaceKeys.namespace, await (0, common_1.getNamespaceForOpenAndFaaSSDK)());
1189
+ let res = await openapi.doRequest(null, urlPath, options);
1190
+ return {
1191
+ expire: res.expire,
1192
+ tenantAccessToken: res.tenantAccessToken,
1193
+ appId: res.appId,
1194
+ };
1195
+ }