@byted-apaas/server-sdk-node 1.0.17 → 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 +11 -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
@@ -8,19 +8,22 @@ const stream_to_buffer_1 = require("@jorgeferrero/stream-to-buffer");
8
8
  const constants_1 = require("../constants/constants");
9
9
  const common_1 = require("./common");
10
10
  const exceptions_1 = require("@byted-apaas/server-common-node/utils/exceptions");
11
+ const fs = require("fs");
12
+ const path = require("path");
13
+ const permissionUtils = require("@byted-apaas/server-common-node/utils/permissionUtils");
14
+ const constants_2 = require("@byted-apaas/server-common-node/constants/constants");
15
+ const utils_1 = require("@byted-apaas/server-common-node/utils/utils");
11
16
  const rpc = common.rpc;
12
17
  const exceptions = common.exceptions;
13
18
  const utils = common.utils;
14
- const fs = require("fs");
15
19
  const checkUtils = common.checkUtils;
16
- const path = require('path');
17
20
  async function pre(isTransUser, authType) {
18
21
  let ctx;
19
22
  try {
20
23
  ctx = await rpc.rebuildRpcCtx(isTransUser, authType);
21
24
  }
22
25
  catch (err) {
23
- throw new exceptions.InternalError(`RebuildRpcCtx failed: ${err.message}`);
26
+ throw new exceptions.InternalError(`RebuildRpcCtx failed: ${err.message}: ${err.stack}`);
24
27
  }
25
28
  return ctx;
26
29
  }
@@ -28,23 +31,22 @@ function post(baseResp) {
28
31
  if (!baseResp) {
29
32
  throw new exceptions.InternalError(`Call InnerAPI resp is empty`);
30
33
  }
31
- if (baseResp.KStatusCode !== "") {
34
+ if (baseResp.KStatusCode !== '') {
35
+ let code = baseResp.KStatusCode;
32
36
  let msg = baseResp.KStatusMessage;
33
- if (baseResp.StatusMessage !== "") {
37
+ if (baseResp.StatusMessage !== '') {
34
38
  msg = baseResp.StatusMessage;
35
39
  }
36
- if (baseResp.extra.get("is_system_error") === "true") {
37
- throw new exceptions.InternalError(`${msg} [${baseResp.KStatusCode}]`);
38
- }
39
- throw new exceptions.InvalidParamError(`${msg} [${baseResp.KStatusCode}]`);
40
+ throw new exceptions.BaseError(code, msg);
40
41
  }
41
42
  }
42
43
  async function createRecordBySync(objectApiName, record, authType) {
43
44
  // 1.check
44
45
  if (!objectApiName) {
45
- throw new exceptions.InvalidParamError("objectApiName is empty");
46
+ throw new exceptions.InvalidParamError('objectApiName is empty');
46
47
  }
47
48
  // 2.前置处理
49
+ authType = (0, utils_1.formatAuthType)(authType);
48
50
  let ctx = await pre(true, authType);
49
51
  // 3.构造 params
50
52
  let param = {};
@@ -71,9 +73,10 @@ async function createRecordBySync(objectApiName, record, authType) {
71
73
  async function updateRecordBySync(objectApiName, recordID, record, authType) {
72
74
  // 1.check
73
75
  if (!objectApiName) {
74
- throw new exceptions.InvalidParamError("objectApiName is empty");
76
+ throw new exceptions.InvalidParamError('objectApiName is empty');
75
77
  }
76
78
  // 2.前置处理
79
+ authType = (0, utils_1.formatAuthType)(authType);
77
80
  let ctx = await pre(true, authType);
78
81
  // 3.构造 params
79
82
  let param = {};
@@ -101,9 +104,10 @@ async function updateRecordBySync(objectApiName, recordID, record, authType) {
101
104
  async function deleteRecordBySync(objectApiName, recordID, authType) {
102
105
  // 1.check
103
106
  if (!objectApiName) {
104
- throw new exceptions.InvalidParamError("objectApiName is empty");
107
+ throw new exceptions.InvalidParamError('objectApiName is empty');
105
108
  }
106
109
  // 2.前置处理
110
+ authType = (0, utils_1.formatAuthType)(authType);
107
111
  let ctx = await pre(true, authType);
108
112
  // 3.构造 params
109
113
  let param = {};
@@ -130,9 +134,10 @@ async function deleteRecordBySync(objectApiName, recordID, authType) {
130
134
  async function createRecordsByAsync(objectApiName, records, authType) {
131
135
  // 1.check
132
136
  if (!objectApiName) {
133
- throw new exceptions.InvalidParamError("objectApiName is empty");
137
+ throw new exceptions.InvalidParamError('objectApiName is empty');
134
138
  }
135
139
  // 2.前置处理
140
+ authType = (0, utils_1.formatAuthType)(authType);
136
141
  let ctx = await pre(true, authType);
137
142
  // 3.构造 params
138
143
  let param = {};
@@ -159,9 +164,10 @@ async function createRecordsByAsync(objectApiName, records, authType) {
159
164
  async function updateRecordsByAsync(objectApiName, recordMap, authType) {
160
165
  // 1.check
161
166
  if (!objectApiName) {
162
- throw new exceptions.InvalidParamError("objectApiName is empty");
167
+ throw new exceptions.InvalidParamError('objectApiName is empty');
163
168
  }
164
169
  // 2.前置处理
170
+ authType = (0, utils_1.formatAuthType)(authType);
165
171
  let ctx = await pre(true, authType);
166
172
  // 3.构造 params
167
173
  let param = {};
@@ -188,9 +194,10 @@ async function updateRecordsByAsync(objectApiName, recordMap, authType) {
188
194
  async function deleteRecordsByAsync(objectApiName, recordIDs, authType) {
189
195
  // 1.check
190
196
  if (!objectApiName) {
191
- throw new exceptions.InvalidParamError("objectApiName is empty");
197
+ throw new exceptions.InvalidParamError('objectApiName is empty');
192
198
  }
193
199
  // 2.前置处理
200
+ authType = (0, utils_1.formatAuthType)(authType);
194
201
  let ctx = await pre(true, authType);
195
202
  // 3.构造 params
196
203
  let param = {};
@@ -221,9 +228,10 @@ async function deleteRecordsByAsync(objectApiName, recordIDs, authType) {
221
228
  async function createRecordsBySync(objectApiName, records, authType) {
222
229
  // 1.check
223
230
  if (!objectApiName) {
224
- throw new exceptions.InvalidParamError("objectApiName is empty");
231
+ throw new exceptions.InvalidParamError('objectApiName is empty');
225
232
  }
226
233
  // 2.前置处理
234
+ authType = (0, utils_1.formatAuthType)(authType);
227
235
  let ctx = await pre(true, authType);
228
236
  // 3.构造 params
229
237
  let param = {};
@@ -247,7 +255,7 @@ async function createRecordsBySync(objectApiName, records, authType) {
247
255
  // 5.后置处理
248
256
  post(resp.BaseResp);
249
257
  let recordIDList = new Array();
250
- let errMap = {};
258
+ const errMap = {};
251
259
  resp.RecordIDs.forEach((v, idx) => {
252
260
  recordIDList.push(Number(v));
253
261
  });
@@ -262,9 +270,10 @@ async function createRecordsBySync(objectApiName, records, authType) {
262
270
  async function updateRecordsBySync(objectApiName, recordMap, authType) {
263
271
  // 1.check
264
272
  if (!objectApiName) {
265
- throw new exceptions.InvalidParamError("objectApiName is empty");
273
+ throw new exceptions.InvalidParamError('objectApiName is empty');
266
274
  }
267
275
  // 2.前置处理
276
+ authType = (0, utils_1.formatAuthType)(authType);
268
277
  let ctx = await pre(true, authType);
269
278
  // 3.构造 params
270
279
  let param = {};
@@ -287,18 +296,22 @@ async function updateRecordsBySync(objectApiName, recordMap, authType) {
287
296
  }
288
297
  // 5.后置处理
289
298
  post(resp.BaseResp);
290
- let errMap = {};
299
+ if (!resp || !resp.ErrMap) {
300
+ return undefined;
301
+ }
302
+ const errMap = {};
291
303
  resp.ErrMap.forEach((v, k) => {
292
304
  errMap[Number(k)] = v;
293
305
  });
294
- return { err_map: errMap };
306
+ return errMap;
295
307
  }
296
308
  async function deleteRecordsBySync(objectApiName, recordIDs, authType) {
297
309
  // 1.check
298
310
  if (!objectApiName) {
299
- throw new exceptions.InvalidParamError("objectApiName is empty");
311
+ throw new exceptions.InvalidParamError('objectApiName is empty');
300
312
  }
301
313
  // 2.前置处理
314
+ authType = (0, utils_1.formatAuthType)(authType);
302
315
  let ctx = await pre(true, authType);
303
316
  // 3.构造 params
304
317
  let param = {};
@@ -325,18 +338,22 @@ async function deleteRecordsBySync(objectApiName, recordIDs, authType) {
325
338
  }
326
339
  // 5.后置处理
327
340
  post(resp.BaseResp);
328
- let errMap = {};
341
+ if (!resp || !resp.ErrMap) {
342
+ return undefined;
343
+ }
344
+ const errMap = {};
329
345
  resp.ErrMap.forEach((v, k) => {
330
346
  errMap[Number(k)] = v;
331
347
  });
332
- return { err_map: errMap };
348
+ return errMap;
333
349
  }
334
350
  async function getRecordsOrCountByCriterion(objectApiName, criterion, fuzzySearch, order, ignoreBackLookupField, fieldApiNames, offset, limit, needCount, authType) {
335
351
  // 1.check
336
352
  if (!objectApiName) {
337
- throw new exceptions.InvalidParamError("objectApiName is empty");
353
+ throw new exceptions.InvalidParamError('objectApiName is empty');
338
354
  }
339
355
  // 2.前置处理
356
+ authType = (0, utils_1.formatAuthType)(authType);
340
357
  let ctx = await pre(true, authType);
341
358
  // 3.构造 params
342
359
  let param = {};
@@ -359,6 +376,11 @@ async function getRecordsOrCountByCriterion(objectApiName, criterion, fuzzySearc
359
376
  param.NeedFilterUserPermission = false;
360
377
  param.NeedTotalCount = needCount;
361
378
  param.FuzzySearch = fuzzySearch;
379
+ // 只返回 slice 结果,使用 SliceResult
380
+ // 只返回 map 结果,使用 MapResult
381
+ // 分不清场景可以用 BothResult,性能较差,建议区分场景
382
+ // 0 表示不返回 unauth field 任何数据; 1 表示两者都返回;2 表示仅返回 slice;3 表示仅返回 map
383
+ param.ProcessAuthFieldType = 2;
362
384
  // 4.发起请求
363
385
  let resp;
364
386
  try {
@@ -373,7 +395,11 @@ async function getRecordsOrCountByCriterion(objectApiName, criterion, fuzzySearc
373
395
  return Number(resp.Total);
374
396
  }
375
397
  else {
376
- return JSON.parse(resp.DataList);
398
+ const records = JSON.parse(resp.DataList);
399
+ if (resp.UnauthPermissionInfo && resp.UnauthPermissionInfo.unauth_field_slice) {
400
+ permissionUtils.appendUnauthFieldRecordList(objectApiName, records, resp.UnauthPermissionInfo.unauth_field_slice, true);
401
+ }
402
+ return records;
377
403
  }
378
404
  }
379
405
  async function updateWorkflowVariables(iCtx, instanceId, variables, variableTypes) {
@@ -396,17 +422,20 @@ async function updateWorkflowVariables(iCtx, instanceId, variables, variableType
396
422
  post(resp.BaseResp);
397
423
  return;
398
424
  }
399
- async function uploadFile(data, expire) {
425
+ async function uploadFile(data, expire, fileName) {
400
426
  // 1.前置处理
401
427
  let ctx = await pre();
402
428
  // 2.构造 params
403
429
  let param = {};
404
430
  param.Data = await (0, stream_to_buffer_1.streamToBuffer)(data);
405
- param.Name = "file";
431
+ param.Name = 'file';
432
+ if (fileName) {
433
+ param.Name = fileName;
434
+ }
406
435
  param.EncryptType = 1;
407
436
  param.PermissionConf = {
408
- PermissionType: "",
409
- PermissionInfo: "",
437
+ PermissionType: '',
438
+ PermissionInfo: '',
410
439
  IgnoreUserID: true
411
440
  };
412
441
  if (expire) {
@@ -450,7 +479,7 @@ async function downloadFileByID(fileID, filePath) {
450
479
  checkUtils.checkFile(filePath);
451
480
  utils.mkdirs(path.dirname(filePath));
452
481
  fs.writeFileSync(filePath, resp.Data);
453
- return;
482
+ return undefined;
454
483
  }
455
484
  else {
456
485
  return resp.Data;
@@ -476,7 +505,7 @@ async function downloadFileByToken(fileToken, filePath) {
476
505
  checkUtils.checkFile(filePath);
477
506
  utils.mkdirs(path.dirname(filePath));
478
507
  fs.writeFileSync(filePath, resp.Data);
479
- return;
508
+ return undefined;
480
509
  }
481
510
  else {
482
511
  return resp.Data;
@@ -503,28 +532,28 @@ async function createMessage(msg) {
503
532
  if (!msg.icon) {
504
533
  throw new exceptions.InvalidParamError(`parameter icon is required!`);
505
534
  }
506
- if (typeof (msg.icon) != 'string') {
535
+ if (typeof (msg.icon) !== 'string') {
507
536
  throw new exceptions.InvalidParamError(`Invalid format of parameter icon, icon should be string.`);
508
537
  }
509
538
  let params = {};
510
- let modelKeySearchData = new Map().set("icon_type", msg.icon);
511
- let receiverIds = msg["target_users"] || [];
539
+ const modelKeySearchData = new Map().set('icon_type', msg.icon);
540
+ const receiverIds = msg.target_users || [];
512
541
  if (!(receiverIds instanceof Array)) {
513
542
  throw new exceptions.InvalidParamError(`Invalid format of parameter target_users, target_users should be array.`);
514
543
  }
515
544
  if (receiverIds.length === 0) {
516
545
  throw new exceptions.InvalidParamError(`parameter target_users is required!`);
517
546
  }
518
- let percent = msg["percent"];
547
+ const percent = msg.percent;
519
548
  if (percent !== undefined && percent !== null) {
520
- if (typeof (percent) != 'number') {
549
+ if (typeof (percent) !== 'number') {
521
550
  throw new exceptions.InvalidParamError(`Invalid format of parameter percent, percent should be number.`);
522
551
  }
523
552
  if (percent < 0 || percent > 100) {
524
553
  throw new exceptions.InvalidParamError(`Invalid value of parameter percent, the value should be in range [0, 100].`);
525
554
  }
526
555
  else {
527
- modelKeySearchData.set("percent", JSON.stringify(percent));
556
+ modelKeySearchData.set('percent', JSON.stringify(percent));
528
557
  }
529
558
  }
530
559
  // kunlun类型
@@ -535,7 +564,7 @@ async function createMessage(msg) {
535
564
  // if (msg[key] instanceof fieldType.Multilingual) {
536
565
  if (common.fieldType.isKFieldTypeMultilingual((msg[key]))) {
537
566
  let value = JSON.stringify(msg[key].toJSON());
538
- params[key] = JSON.stringify({ "value": value });
567
+ params[key] = JSON.stringify({ value });
539
568
  }
540
569
  else {
541
570
  params[key] = JSON.stringify(msg[key].toJSON());
@@ -583,17 +612,17 @@ async function updateMessage(msgId, msg) {
583
612
  throw new exceptions.InvalidParamError(`Invalid format of parameter icon, icon should be string.`);
584
613
  }
585
614
  let params = new Map();
586
- let modelKeySearchData = new Map().set("icon_type", msg.icon);
587
- let percent = msg["percent"];
615
+ const modelKeySearchData = new Map().set('icon_type', msg.icon);
616
+ const percent = msg.percent;
588
617
  if (percent !== undefined && percent !== null) {
589
- if (typeof (percent) != 'number') {
618
+ if (typeof (percent) !== 'number') {
590
619
  throw new exceptions.InvalidParamError(`Invalid format of parameter percent, percent should be number.`);
591
620
  }
592
621
  if (percent < 0 || percent > 100) {
593
622
  throw new exceptions.InvalidParamError(`Invalid value of parameter percent in message ${msgId}, the value should be in range [0, 100].`);
594
623
  }
595
624
  else {
596
- modelKeySearchData.set("percent", JSON.stringify(percent));
625
+ modelKeySearchData.set('percent', JSON.stringify(percent));
597
626
  }
598
627
  }
599
628
  // kunlun类型
@@ -604,7 +633,7 @@ async function updateMessage(msgId, msg) {
604
633
  // if (msg[key] instanceof fieldType.Multilingual) {
605
634
  if (common.fieldType.isKFieldTypeMultilingual(msg[key])) {
606
635
  let value = JSON.stringify(msg[key].toJSON());
607
- params.set(key, JSON.stringify({ "value": value }));
636
+ params.set(key, JSON.stringify({ value }));
608
637
  }
609
638
  else {
610
639
  params.set(key, JSON.stringify(msg[key].toJSON()));
@@ -690,7 +719,7 @@ async function getField(objectApiName, fieldApiName) {
690
719
  }
691
720
  async function terminateWorkflowInstance(workflowInstanceId, operator, reason) {
692
721
  // 1. prepare args
693
- if (typeof (workflowInstanceId) !== "number") {
722
+ if (typeof (workflowInstanceId) !== 'number') {
694
723
  throw new exceptions.InvalidParamError(`The type of workflowInstanceId should be number, but ${typeof (workflowInstanceId)}.`);
695
724
  }
696
725
  // 2. prepare request
@@ -731,6 +760,7 @@ async function modifyRecordsWithTransaction(placeholders, operations, authType)
731
760
  param.TaskID = BigInt(taskID);
732
761
  }
733
762
  // 3. prepare request
763
+ authType = (0, utils_1.formatAuthType)(authType);
734
764
  let ctx = await pre(true, authType);
735
765
  // 4. do request
736
766
  let resp;
@@ -752,8 +782,8 @@ async function getGlobalConfigByKey(key) {
752
782
  for (let i = 0;; i++) {
753
783
  let param = {};
754
784
  param.NameSpace = await (0, common_1.getNamespaceForOpenAndFaaSSDK)();
755
- param.BizType = "GlobalVariables";
756
- param.UsedBy = "UsedBySystem";
785
+ param.BizType = 'GlobalVariables';
786
+ param.UsedBy = 'UsedBySystem';
757
787
  param.Filter = {
758
788
  Offset: BigInt(offset * i),
759
789
  Limit: BigInt(pageSize),
@@ -783,16 +813,21 @@ async function getGlobalConfigByKey(key) {
783
813
  async function oql(oql, args, namedArgs, authType) {
784
814
  // 1. build parameters
785
815
  const queryData = JSON.stringify({
786
- "query": oql,
787
- "args": args,
788
- "namedArgs": namedArgs,
789
- "compat": true
816
+ 'query': oql,
817
+ args,
818
+ namedArgs,
819
+ 'compat': true,
820
+ 'unauthFields': true,
790
821
  });
791
822
  // 2. prepare args
792
823
  let param = {};
793
824
  param.Namespace = await (0, common_1.getNamespaceForOpenAndFaaSSDK)();
794
825
  param.QueryData = Buffer.from(queryData);
795
826
  // 3. prepare request
827
+ authType = (0, utils_1.formatAuthType)(authType);
828
+ if (authType === constants_2.AuthTypeUser || authType == constants_2.AuthTypeMixUserSystem) {
829
+ authType = constants_2.AuthTypeMixUserSystem;
830
+ }
796
831
  let ctx = await pre(true, authType);
797
832
  // 4. do request
798
833
  let resp;
@@ -805,7 +840,9 @@ async function oql(oql, args, namedArgs, authType) {
805
840
  // 5. deal with response
806
841
  post(resp.BaseResp);
807
842
  try {
808
- return JSON.parse(resp.Rows ? resp.Rows : "[]");
843
+ const records = JSON.parse(resp.Rows ? resp.Rows : '[]');
844
+ permissionUtils.appendUnauthFieldRecordList("", records, resp.UnauthFieldSlice, true);
845
+ return records;
809
846
  }
810
847
  catch (e) {
811
848
  throw new exceptions.InternalError(`oql result parse failed: ${e.message}`);
@@ -813,7 +850,7 @@ async function oql(oql, args, namedArgs, authType) {
813
850
  }
814
851
  async function openSDKCreateRecordBySync(objectApiName, record) {
815
852
  // 1. prepare args
816
- if (typeof (objectApiName) !== "string") {
853
+ if (typeof (objectApiName) !== 'string') {
817
854
  throw new exceptions.InvalidParamError(`The type of objectApiName should be string, but ${typeof (objectApiName)}.`);
818
855
  }
819
856
  // 2. prepare request
@@ -836,10 +873,10 @@ async function openSDKCreateRecordBySync(objectApiName, record) {
836
873
  }
837
874
  async function openSDKUpdateRecordBySync(objectApiName, recordID, record) {
838
875
  // 1. prepare args
839
- if (typeof (objectApiName) !== "string") {
876
+ if (typeof (objectApiName) !== 'string') {
840
877
  throw new exceptions.InvalidParamError(`The type of objectApiName should be string, but ${typeof (objectApiName)}.`);
841
878
  }
842
- if (typeof (recordID) !== "number") {
879
+ if (typeof (recordID) !== 'number') {
843
880
  throw new exceptions.InvalidParamError(`The type of recordID should be number, but ${typeof (recordID)}.`);
844
881
  }
845
882
  // 2. prepare request
@@ -863,10 +900,10 @@ async function openSDKUpdateRecordBySync(objectApiName, recordID, record) {
863
900
  }
864
901
  async function openSDKDeleteRecordBySync(objectApiName, recordID) {
865
902
  // 1. prepare args
866
- if (typeof (objectApiName) !== "string") {
903
+ if (typeof (objectApiName) !== 'string') {
867
904
  throw new exceptions.InvalidParamError(`The type of objectApiName should be string, but ${typeof (objectApiName)}.`);
868
905
  }
869
- if (typeof (recordID) !== "number") {
906
+ if (typeof (recordID) !== 'number') {
870
907
  throw new exceptions.InvalidParamError(`The type of recordID should be number, but ${typeof (recordID)}.`);
871
908
  }
872
909
  // 2. prepare request
@@ -889,7 +926,7 @@ async function openSDKDeleteRecordBySync(objectApiName, recordID) {
889
926
  }
890
927
  async function openSDKCreateRecordsBySync(objectApiName, records) {
891
928
  // 1. prepare args
892
- if (typeof (objectApiName) !== "string") {
929
+ if (typeof (objectApiName) !== 'string') {
893
930
  throw new exceptions.InvalidParamError(`The type of objectApiName should be string, but ${typeof (objectApiName)}.`);
894
931
  }
895
932
  // 2. prepare request
@@ -912,7 +949,7 @@ async function openSDKCreateRecordsBySync(objectApiName, records) {
912
949
  }
913
950
  async function openSDKUpdateRecordsBySync(objectApiName, recordMap) {
914
951
  // 1. prepare args
915
- if (typeof (objectApiName) !== "string") {
952
+ if (typeof (objectApiName) !== 'string') {
916
953
  throw new exceptions.InvalidParamError(`The type of objectApiName should be string, but ${typeof (objectApiName)}.`);
917
954
  }
918
955
  // 2. prepare request
@@ -935,7 +972,7 @@ async function openSDKUpdateRecordsBySync(objectApiName, recordMap) {
935
972
  }
936
973
  async function openSDKDeleteRecordsBySync(objectApiName, recordIDs) {
937
974
  // 1. prepare args
938
- if (typeof (objectApiName) !== "string") {
975
+ if (typeof (objectApiName) !== 'string') {
939
976
  throw new exceptions.InvalidParamError(`The type of objectApiName should be string, but ${typeof (objectApiName)}.`);
940
977
  }
941
978
  // 2. prepare request
@@ -1082,6 +1119,10 @@ class RequestRpc {
1082
1119
  this.modifyRecordsWithTransaction = modifyRecordsWithTransaction;
1083
1120
  this.getGlobalConfigByKey = getGlobalConfigByKey;
1084
1121
  this.oql = oql;
1122
+ this.getIntegrationAppAccessToken = getIntegrationAppAccessToken;
1123
+ this.getIntegrationTenantAccessToken = getIntegrationTenantAccessToken;
1124
+ this.getDefaultIntegrationAppAccessToken = getDefaultIntegrationAppAccessToken;
1125
+ this.getDefaultIntegrationTenantAccessToken = getDefaultIntegrationTenantAccessToken;
1085
1126
  // open sdk api
1086
1127
  this.openSDKCreateRecordBySync = openSDKCreateRecordBySync;
1087
1128
  this.openSDKUpdateRecordBySync = openSDKUpdateRecordBySync;
@@ -1109,8 +1150,10 @@ class RequestRpc {
1109
1150
  createRecordsBySync(objectApiName, records, authType) {
1110
1151
  }
1111
1152
  updateRecordsBySync(objectApiName, recordMap, authType) {
1153
+ return undefined;
1112
1154
  }
1113
1155
  deleteRecordsBySync(objectApiName, recordIDs, authType) {
1156
+ return undefined;
1114
1157
  }
1115
1158
  getRecordsOrCountByCriterion(objectApiName, criterion, fuzzySearch, order, ignoreBackLookupField, fieldApiNames, offset, limit, needCount, authType) {
1116
1159
  }
@@ -1119,9 +1162,11 @@ class RequestRpc {
1119
1162
  async uploadFile(data, expire) {
1120
1163
  return null;
1121
1164
  }
1165
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1122
1166
  async downloadFileByID(fileID, filePath) {
1123
1167
  return null;
1124
1168
  }
1169
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1125
1170
  async downloadFileByToken(fileToken, filePath) {
1126
1171
  return null;
1127
1172
  }
@@ -1173,9 +1218,22 @@ class RequestRpc {
1173
1218
  async getTenantInfo(appCtx) {
1174
1219
  return await appCtx.credential.getTenantInfo();
1175
1220
  }
1221
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1176
1222
  async mGetFileToken(ids) {
1177
1223
  return null;
1178
1224
  }
1225
+ async getIntegrationAppAccessToken(apiName) {
1226
+ return null;
1227
+ }
1228
+ async getIntegrationTenantAccessToken(apiName) {
1229
+ return null;
1230
+ }
1231
+ async getDefaultIntegrationAppAccessToken() {
1232
+ return null;
1233
+ }
1234
+ async getDefaultIntegrationTenantAccessToken() {
1235
+ return null;
1236
+ }
1179
1237
  // open sdk empty implement
1180
1238
  openSDKCreateRecordBySync(objectApiName, record) {
1181
1239
  }
@@ -1236,8 +1294,8 @@ async function invokeFuncWithAuth(idOrName, params) {
1236
1294
  catch (e) {
1237
1295
  throw new exceptions.InternalError(`JSON parse failed for ${resp.result}`);
1238
1296
  }
1239
- if (!result || result.code !== "0") {
1240
- throw new exceptions.InvalidParamError(`result is invalid for code: ${result ? result.code : ""} msg: ${result ? result.msg : ""}`);
1297
+ if (!result || result.code !== '0') {
1298
+ throw new exceptions.InvalidParamError(`result is invalid for code: ${result ? result.code : ''} msg: ${result ? result.msg : ''}`);
1241
1299
  }
1242
1300
  return result.data;
1243
1301
  }
@@ -1362,12 +1420,12 @@ async function invokeFuncSync(idOrName, params) {
1362
1420
  let param = {};
1363
1421
  param.Namespace = await (0, common_1.getNamespaceForOpenAndFaaSSDK)();
1364
1422
  if (idOrName.isInvokeByAPIName) {
1365
- param.FunctionName = "";
1423
+ param.FunctionName = '';
1366
1424
  param.APIAlias = idOrName.APIName;
1367
1425
  }
1368
1426
  else {
1369
1427
  param.FunctionName = idOrName.APIId;
1370
- param.APIAlias = "";
1428
+ param.APIAlias = '';
1371
1429
  }
1372
1430
  param.Params = JSON.stringify(params);
1373
1431
  param.Context = JSON.stringify((0, common_1.getTriggerCtx)());
@@ -1388,10 +1446,10 @@ async function invokeFuncSync(idOrName, params) {
1388
1446
  catch (e) {
1389
1447
  throw new exceptions.InternalError(`Parse Result failed: ${e.message}`);
1390
1448
  }
1391
- if (result && result.code === "0") {
1449
+ if (result && result.code === '0') {
1392
1450
  return result.data;
1393
1451
  }
1394
- throw new exceptions.InternalError(`[${result.code}] ${result.msg}`);
1452
+ throw new exceptions.BaseError(result.code, result.msg);
1395
1453
  }
1396
1454
  async function createAsyncTaskV1(idOrName, params) {
1397
1455
  let ctx = await pre(true);
@@ -1399,7 +1457,7 @@ async function createAsyncTaskV1(idOrName, params) {
1399
1457
  param.Namespace = await (0, common_1.getNamespaceForOpenAndFaaSSDK)();
1400
1458
  if (idOrName.isInvokeByAPIName) {
1401
1459
  param.Alias = idOrName.APIName;
1402
- param.Name = ""; // required
1460
+ param.Name = ''; // required
1403
1461
  }
1404
1462
  else {
1405
1463
  param.Name = idOrName.APIId;
@@ -1438,3 +1496,99 @@ async function createAsyncTaskV2(APIName, params) {
1438
1496
  post(resp.BaseResp);
1439
1497
  return Number(resp.TaskID);
1440
1498
  }
1499
+ async function getIntegrationAppAccessToken(apiName) {
1500
+ // 1.check
1501
+ if (!apiName) {
1502
+ throw new exceptions.InvalidParamError('apiName is empty');
1503
+ }
1504
+ // 2.前置处理
1505
+ let ctx = await pre(true);
1506
+ // 3.构造 params
1507
+ let param = {};
1508
+ param.APIName = apiName;
1509
+ // 4.发起请求
1510
+ let resp;
1511
+ try {
1512
+ resp = await rpc.getInnerAPICli().GetIntegrationAppAccessToken(ctx, param);
1513
+ }
1514
+ catch (err) {
1515
+ throw new exceptions.InternalError(`Call InnerAPI failed: ${err.message}`);
1516
+ }
1517
+ // 5.后置处理
1518
+ post(resp.BaseResp);
1519
+ return {
1520
+ expire: resp.Expire ? resp.Expire : undefined,
1521
+ appAccessToken: resp.AppAccessToken ? resp.AppAccessToken : undefined,
1522
+ appId: resp.AppID ? resp.AppID : undefined,
1523
+ };
1524
+ }
1525
+ async function getIntegrationTenantAccessToken(apiName) {
1526
+ // 1.check
1527
+ if (!apiName) {
1528
+ throw new exceptions.InvalidParamError('apiName is empty');
1529
+ }
1530
+ // 2.前置处理
1531
+ let ctx = await pre(true);
1532
+ // 3.构造 params
1533
+ let param = {};
1534
+ param.APIName = apiName;
1535
+ // 4.发起请求
1536
+ let resp;
1537
+ try {
1538
+ resp = await rpc.getInnerAPICli().GetIntegrationTenantAccessToken(ctx, param);
1539
+ }
1540
+ catch (err) {
1541
+ throw new exceptions.InternalError(`Call InnerAPI failed: ${err.message}`);
1542
+ }
1543
+ // 5.后置处理
1544
+ post(resp.BaseResp);
1545
+ return {
1546
+ expire: resp.Expire ? resp.Expire : undefined,
1547
+ tenantAccessToken: resp.TenantAccessToken ? resp.TenantAccessToken : undefined,
1548
+ appId: resp.AppID ? resp.AppID : undefined,
1549
+ };
1550
+ }
1551
+ async function getDefaultIntegrationAppAccessToken() {
1552
+ // 1.check
1553
+ // 2.前置处理
1554
+ let ctx = await pre(true);
1555
+ // 3.构造 params
1556
+ let param = {};
1557
+ // 4.发起请求
1558
+ let resp;
1559
+ try {
1560
+ resp = await rpc.getInnerAPICli().GetDefaultIntegrationAppAccessToken(ctx, param);
1561
+ }
1562
+ catch (err) {
1563
+ throw new exceptions.InternalError(`Call InnerAPI failed: ${err.message}`);
1564
+ }
1565
+ // 5.后置处理
1566
+ post(resp.BaseResp);
1567
+ return {
1568
+ expire: resp.Expire ? resp.Expire : undefined,
1569
+ appAccessToken: resp.AppAccessToken ? resp.AppAccessToken : undefined,
1570
+ appId: resp.AppID ? resp.AppID : undefined,
1571
+ };
1572
+ }
1573
+ async function getDefaultIntegrationTenantAccessToken() {
1574
+ // 1.check
1575
+ // 2.前置处理
1576
+ let ctx = await pre(true);
1577
+ // 3.构造 params
1578
+ let param = {};
1579
+ // 4.发起请求
1580
+ let resp;
1581
+ try {
1582
+ resp = await rpc.getInnerAPICli().GetDefaultIntegrationTenantAccessToken(ctx, param);
1583
+ }
1584
+ catch (err) {
1585
+ throw new exceptions.InternalError(`Call InnerAPI failed: ${err.message}`);
1586
+ }
1587
+ // 5.后置处理
1588
+ post(resp.BaseResp);
1589
+ return {
1590
+ expire: resp.Expire ? resp.Expire : undefined,
1591
+ tenantAccessToken: resp.TenantAccessToken ? resp.TenantAccessToken : undefined,
1592
+ appId: resp.AppID ? resp.AppID : undefined,
1593
+ };
1594
+ }