@byted-apaas/server-sdk-node 1.1.18-beta.8 → 1.1.18

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.
@@ -75,7 +75,7 @@ export interface IDBV3<T, mt> {
75
75
  * }).find()
76
76
  * ```
77
77
  */
78
- object<T extends keyof mt>(objectApiName: T): _IKAllEndpointV3<mt[T]> & _IKQueryV3<mt[T]>;
78
+ object: <T extends keyof mt>(objectApiName: T) => _IKAllEndpointV3<mt[T]> & _IKQueryV3<mt[T]>;
79
79
  /**
80
80
  * 创建一个新的空事务
81
81
  * @example
package/context/db/db.js CHANGED
@@ -1,4 +1,2 @@
1
1
  "use strict";
2
- // Copyright 2022 ByteDance Ltd. and/or its affiliates
3
- // SPDX-License-Identifier: MIT
4
2
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,5 +1,5 @@
1
1
  import { _Cond, _Record, _WhereCond } from '../../../types/types';
2
- import { BatchResult } from "../../../common/structs";
2
+ import { BatchResult } from '../../../common/structs';
3
3
  export interface _IKAllEndpoint<T> extends _IKSyncEndpoint<T>, _IKAsyncEndpoint<T> {
4
4
  }
5
5
  export interface _IKSyncEndpoint<T> {
@@ -1,5 +1,5 @@
1
1
  import { _Cond, _Record, _WhereCond } from '../../../types/types';
2
- import { BatchResult } from "../../../common/structs";
2
+ import { BatchResult } from '../../../common/structs';
3
3
  export interface _IKAllEndpointV3<T> extends _IKSyncEndpointV3<T>, _IKAsyncEndpointV3<T> {
4
4
  }
5
5
  export interface _IKSyncEndpointV3<T> {
@@ -21,22 +21,17 @@ export interface _IKSyncEndpointV3<T> {
21
21
  }>;
22
22
  /**
23
23
  * 删除记录
24
- * @param recordID 用于删除的一条记录的 ID
25
- * @example
24
+ * @param recordID 用于删除的一条完整记录
25
+ * @example 传 id
26
26
  * ```
27
- * application.data.object('_user').delete(123456789123)
27
+ * application.data.object('_user').delete("123456789123")
28
28
  * ```
29
- */
30
- delete(recordID: number | string): Promise<void>;
31
- /**
32
- * 删除记录
33
- * @param record 用于删除的一条完整记录
34
- * @example
29
+ * @example 传记录
35
30
  * ```
36
31
  * application.data.object('_user').delete(context.targetRecord.original)
37
32
  * ```
38
33
  */
39
- delete(record: _Cond<T>): Promise<void>;
34
+ delete(recordID: number | string | _Cond<T>): Promise<void>;
40
35
  /**
41
36
  * 指定 _id 后,更新对应记录
42
37
  * @param _id 主键
@@ -71,16 +66,11 @@ export interface _IKSyncEndpointV3<T> {
71
66
  batchCreate(recordMapList: _Cond<T>[]): Promise<number[] | string[]>;
72
67
  /**
73
68
  * 批量删除记录
74
- * @param recordIdList 多个用于删除的记录 ID 组成的数组
75
- * @paramExample [1001, 1002, 1003]
76
- */
77
- batchDelete(recordIdList: string[]): Promise<BatchResult>;
78
- /**
79
- * 批量删除记录
80
- * @param recordList 多条用于删除的记录数据组成的数组,记录数据需对 _id 赋值
69
+ * @param recordList 多个用于删除的记录 ID 组成的数组,或者多条用于删除的记录数据组成的数组,记录数据需对 _id 赋值
81
70
  * @paramExample [{_id: 1001, _name: 'John', gender: 'male'}, {_id: 1002, _name: 'Alis', gender: 'female'}]
71
+ * @paramExample [1001, 1002, 1003]
82
72
  */
83
- batchDelete(recordList: _Cond<T>[]): Promise<BatchResult>;
73
+ batchDelete(recordList: string[] | _Cond<T>[]): Promise<BatchResult>;
84
74
  /**
85
75
  * 根据 _id 批量更新记录
86
76
  * @param recordMapList 多条用于更新的记录数据组成的数组,记录数据需对 _id 赋值
@@ -199,11 +189,7 @@ export interface _IKQueryV3<T> {
199
189
  * }).find()
200
190
  * ```
201
191
  */
202
- where(conditionMap: _WhereCond<T>): Omit<_IKQueryV3<T>, 'findAll'>;
203
- /**
204
- * 设置查询条件
205
- */
206
- where(): Omit<_IKQueryV3<T>, 'findAll'>;
192
+ where(conditionMap?: _WhereCond<T>): Omit<_IKQueryV3<T>, 'findAll'>;
207
193
  /**
208
194
  * 模糊查询:与 where 之间是与关系
209
195
  * @param keyword 模糊查询的关键字,必填且不可以为空串
@@ -39,7 +39,10 @@ class DB {
39
39
  * ```
40
40
  */
41
41
  newTransaction() {
42
- return new index_1.Transaction(this.objectApiName);
42
+ const appCtx = {
43
+ dataVersion: 'v1',
44
+ };
45
+ return new index_1.Transaction(this.objectApiName, appCtx);
43
46
  }
44
47
  ;
45
48
  oql(oql, nameArgs) {
@@ -19,7 +19,7 @@ class DBV3 {
19
19
  */
20
20
  object(objectApiName) {
21
21
  const appCtx = {
22
- dataVersion: "v3",
22
+ dataVersion: 'v3',
23
23
  };
24
24
  return new object_1._KObject(objectApiName, appCtx);
25
25
  }
@@ -41,7 +41,7 @@ class DBV3 {
41
41
  */
42
42
  newTransaction() {
43
43
  const appCtx = {
44
- dataVersion: "v3",
44
+ dataVersion: 'v3',
45
45
  };
46
46
  return new index_1.Transaction(this.objectApiName, appCtx);
47
47
  }
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ // nolint: cognitive_complexity
2
3
  // Copyright 2022 ByteDance Ltd. and/or its affiliates
3
4
  // SPDX-License-Identifier: MIT
4
5
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -58,13 +59,13 @@ class _KObjectSync {
58
59
  });
59
60
  }
60
61
  else if (this.appCtx && this.appCtx.dataVersion === 'v3') {
61
- return await Request.GetInstance().createRecordV3BySync(this.apiName, recordMap, this.authType);
62
+ return await Request.GetInstance().createRecordBySyncV3(this.apiName, recordMap, this.authType);
62
63
  }
63
64
  return await Request.GetInstance().createRecordBySync(this.apiName, recordMap, this.authType);
64
65
  }
65
66
  ;
66
67
  async delete(recordOrRecordID) {
67
- if (this.appCtx && this.appCtx.dataVersion === "v3") {
68
+ if (this.appCtx && this.appCtx.dataVersion === 'v3') {
68
69
  return this.deleteV3(recordOrRecordID);
69
70
  }
70
71
  let recordID;
@@ -126,10 +127,10 @@ class _KObjectSync {
126
127
  if (recordIDStr.length <= 0) {
127
128
  throw new server_common_node_1.exceptions.InvalidParamError('record._id must greater than 0');
128
129
  }
129
- return await Request.GetInstance().deleteRecordV3BySync(this.apiName, recordIDStr, this.authType);
130
+ return await Request.GetInstance().deleteRecordBySyncV3(this.apiName, recordIDStr, this.authType);
130
131
  }
131
132
  async update(_idOrRecordMap, recordMap) {
132
- if (this.appCtx && this.appCtx.dataVersion === "v3") {
133
+ if (this.appCtx && this.appCtx.dataVersion === 'v3') {
133
134
  return this.updateV3(_idOrRecordMap, recordMap);
134
135
  }
135
136
  // record 必须包含 _id
@@ -195,7 +196,7 @@ class _KObjectSync {
195
196
  if (recordIDStr.length <= 0) {
196
197
  throw new server_common_node_1.exceptions.InvalidParamError('record._id must greater than 0');
197
198
  }
198
- return await Request.GetInstance().updateRecordV3BySync(this.apiName, recordIDStr, record, this.authType);
199
+ return await Request.GetInstance().updateRecordBySyncV3(this.apiName, recordIDStr, record, this.authType);
199
200
  }
200
201
  // batch sync
201
202
  async batchCreate(recordMapList) {
@@ -212,7 +213,7 @@ class _KObjectSync {
212
213
  }
213
214
  }
214
215
  recordMapList = permissionUtils.batchDelUnauthField(recordMapList).newRecords;
215
- if (this.appCtx && this.appCtx.dataVersion === "v3") {
216
+ if (this.appCtx && this.appCtx.dataVersion === 'v3') {
216
217
  return await this.batchCreateV3(recordMapList);
217
218
  }
218
219
  let data = (this.appCtx && this.appCtx.mode == 'openSDK') ?
@@ -226,7 +227,7 @@ class _KObjectSync {
226
227
  }
227
228
  ;
228
229
  async batchCreateV3(recordMapList) {
229
- const dataV3 = await Request.GetInstance().createRecordsV3BySync(this.apiName, recordMapList, this.authType);
230
+ const dataV3 = await Request.GetInstance().createRecordsBySyncV3(this.apiName, recordMapList, this.authType);
230
231
  const ids = (dataV3.items || []).map((item) => item?._id);
231
232
  return ids;
232
233
  }
@@ -238,7 +239,7 @@ class _KObjectSync {
238
239
  if (!(idOrRecordList instanceof Array) || idOrRecordList.length === 0) {
239
240
  throw new server_common_node_1.exceptions.InvalidParamError('param records is not an array or an empty array');
240
241
  }
241
- if (this.appCtx && this.appCtx.dataVersion === "v3") {
242
+ if (this.appCtx && this.appCtx.dataVersion === 'v3') {
242
243
  return this.batchDeleteV3(idOrRecordList);
243
244
  }
244
245
  let recordIDs = [];
@@ -278,7 +279,7 @@ class _KObjectSync {
278
279
  throw new server_common_node_1.exceptions.InvalidParamError('record must be string or number or object');
279
280
  }
280
281
  }
281
- const errMap = await Request.GetInstance().deleteRecordsV3BySync(this.apiName, recordIDs, this.authType);
282
+ const errMap = await Request.GetInstance().deleteRecordsBySyncV3(this.apiName, recordIDs, this.authType);
282
283
  return (0, structs_1.NewBatchResult)(recordIDs, errMap);
283
284
  }
284
285
  async batchUpdate(recordMapList) {
@@ -290,7 +291,7 @@ class _KObjectSync {
290
291
  throw new server_common_node_1.exceptions.InvalidParamError('param records is not an array or an empty array');
291
292
  }
292
293
  recordMapList = permissionUtils.batchDelUnauthField(recordMapList).newRecords;
293
- if (this.appCtx && this.appCtx.dataVersion === "v3") {
294
+ if (this.appCtx && this.appCtx.dataVersion === 'v3') {
294
295
  return await this.batchUpdateV3(recordMapList);
295
296
  }
296
297
  const recordIDs = [];
@@ -330,12 +331,12 @@ class _KObjectSync {
330
331
  else if (typeof record._id === 'string') {
331
332
  recordID = record._id;
332
333
  }
333
- if ((typeof recordID !== 'string') || recordID == "") {
334
+ if ((typeof recordID !== 'string') || recordID === '') {
334
335
  throw new server_common_node_1.exceptions.InvalidParamError('record._id is empty');
335
336
  }
336
337
  recordIDs.push(recordID);
337
338
  }
338
- const errMap = await Request.GetInstance().updateRecordsV3BySync(this.apiName, recordMapList, this.authType);
339
+ const errMap = await Request.GetInstance().updateRecordsBySyncV3(this.apiName, recordMapList, this.authType);
339
340
  return (0, structs_1.NewBatchResult)(recordIDs, errMap);
340
341
  }
341
342
  useUserAuth() {
@@ -528,13 +529,13 @@ class _KQuery {
528
529
  apiName: objectApiName,
529
530
  appCtx: appCtx,
530
531
  queryBuilder: new queryBuilder_1.QueryBuilder(objectApiName),
531
- queryV2: appCtx && appCtx.mode === "openSDK" ? new logicV2_1.QueryV2(objectApiName) : null, // QueryV2 是提供给 openSDK 使用的
532
+ queryV2: appCtx && appCtx.mode === 'openSDK' ? new logicV2_1.QueryV2(objectApiName) : null, // QueryV2 是提供给 openSDK 使用的
532
533
  });
533
534
  }
534
535
  async find() {
535
536
  this.findPreCheck();
536
537
  const { apiName, appCtx, queryBuilder, queryV2 } = queryPropertiesStore.get(this);
537
- if (appCtx && appCtx.dataVersion === "v3") {
538
+ if (appCtx && appCtx.dataVersion === 'v3') {
538
539
  return await this.findV3(false);
539
540
  }
540
541
  if (queryV2) {
@@ -654,7 +655,7 @@ class _KQuery {
654
655
  return await Request.GetInstance().openSDKGetRecords(apiName, param);
655
656
  });
656
657
  }
657
- else if (appCtx && appCtx.dataVersion === "v3") {
658
+ else if (appCtx && appCtx.dataVersion === 'v3') {
658
659
  // 更新 maxId
659
660
  criterion.conditions[criterion.conditions.length - 1].right.settings.data = maxId;
660
661
  // 转换成 V3 的 criterion
@@ -751,7 +752,7 @@ class _KQuery {
751
752
  return await Request.GetInstance().openSDKGetRecords(apiName, param);
752
753
  });
753
754
  }
754
- else if (appCtx && appCtx.dataVersion === "v3") {
755
+ else if (appCtx && appCtx.dataVersion === 'v3') {
755
756
  // 更新 maxId
756
757
  criterion.conditions[criterion.conditions.length - 1].right.settings.data = maxId;
757
758
  // 转换成 V3 的 criterion
@@ -925,7 +926,7 @@ class _KQuery {
925
926
  ;
926
927
  async count() {
927
928
  const { apiName, appCtx, queryBuilder, queryV2 } = queryPropertiesStore.get(this);
928
- if (appCtx && appCtx.dataVersion == "v3") {
929
+ if (appCtx && appCtx.dataVersion === 'v3') {
929
930
  return await this.findV3(true);
930
931
  }
931
932
  if (queryV2) {
@@ -955,7 +956,6 @@ class _KQuery {
955
956
  const { apiName, queryBuilder } = queryPropertiesStore.get(this);
956
957
  let criterion = (0, logic_1.buildCriterion)(queryBuilder.getLogic(), apiName);
957
958
  if (queryBuilder.getLogic().logics.length > 0) {
958
- // console.log("test-----------------------", queryBuilder.getLogic().logics)
959
959
  criterion = await (0, logic_1.handleCriterion)(criterion);
960
960
  }
961
961
  const criterionV3 = (0, logic_1.convertCriterionToCriterionV3)(criterion);
@@ -18,7 +18,7 @@ class Oql {
18
18
  this.appCtx = appCtx;
19
19
  }
20
20
  async execute() {
21
- if (this.appCtx && this.appCtx.dataVersion === "v3") {
21
+ if (this.appCtx && this.appCtx.dataVersion === 'v3') {
22
22
  // todo wby
23
23
  }
24
24
  let records = await Request.GetInstance().oql(this.oql, this.params, this.namedParams, this.authType);
@@ -224,10 +224,6 @@ class Transaction {
224
224
  };
225
225
  }
226
226
  async commit() {
227
- if (this.appCtx && this.appCtx.dataVersion === "v3") {
228
- // todo wby
229
- console.log("==========wby test= commit");
230
- }
231
227
  if (this.isCommit) {
232
228
  throw new server_common_node_1.exceptions.InvalidParamError('The transaction cannot be committed repeatedly');
233
229
  }
@@ -235,7 +231,7 @@ class Transaction {
235
231
  if (!this.operations || this.operations.length === 0) {
236
232
  return;
237
233
  }
238
- let uuid2recordId = await Request.GetInstance().modifyRecordsWithTransaction(this.placeholders, this.operations, this.authType);
234
+ let uuid2recordId = await Request.GetInstance().modifyRecordsWithTransaction(this.placeholders, this.operations, this.authType, this.appCtx.dataVersion);
239
235
  if (!uuid2recordId) {
240
236
  throw new server_common_node_1.exceptions.InternalError('uuid2recordId is empty');
241
237
  }
@@ -45,7 +45,7 @@ class MetaDataV3 {
45
45
  throw new commonExceptions.InvalidParamError('objectApiName is empty');
46
46
  }
47
47
  const appCtx = {
48
- dataVersion: "v3",
48
+ dataVersion: 'v3',
49
49
  };
50
50
  return new KObject(objectApiName, appCtx);
51
51
  }
@@ -62,14 +62,14 @@ class KObject {
62
62
  }
63
63
  async getFields() {
64
64
  let res = await Request.GetInstance().getFields(this.objectApiName);
65
- if (this.appCtx && this.appCtx.dataVersion === "v3") {
65
+ if (this.appCtx && this.appCtx.dataVersion === 'v3') {
66
66
  return fieldsV3.parseFieldsV3(res);
67
67
  }
68
68
  return fields.parseFields(res);
69
69
  }
70
70
  async getField(fieldApiName) {
71
71
  let res = await Request.GetInstance().getField(this.objectApiName, fieldApiName);
72
- if (this.appCtx && this.appCtx.dataVersion === "v3") {
72
+ if (this.appCtx && this.appCtx.dataVersion === 'v3') {
73
73
  return fieldsV3.parseFieldV3(res);
74
74
  }
75
75
  return fields.parseField(res);
@@ -49,4 +49,4 @@ export declare function getRollupLookupFieldApiName(field: FieldType): string;
49
49
  export declare function getRegionOptionLevel(field: FieldType): boolean;
50
50
  export declare function getRegionStrictLeve(field: FieldType): number;
51
51
  export declare function getRollupFilter(field: FieldType): CriterionType;
52
- export { getUnique, getCaseSensitive, getMultiline, getMaxLength, getRegexpExpression, getRegexpErrMsg, getDisplayAsPercentage, getDecimalPlaces, getMultiple, getOptionSource, getGlobalOptionApiName, getOptionList, getDescriptionWhenTrue, getDescriptionWhenFalse, getDefaultValue, getDisplayStyle, getLookupRefObjectApiName, getLookupIsHierarchy, getLookupDisplayStyle, getReturnType, getFormula, getGenerateMethod, getDigitsNumber, getPrefix, getSuffix, getReferenceObjectApiName, getReferenceFieldApiName, getFileMultiple, getFileTypes, getBackLookupObjectApiName, getBackLookupFieldApiName, getSettingsMultiple, getCompositeTypeApiName, getCompositeTypeSubFields, getSettingsFilter, getSettingsSort, getRecordPosition, getOptionListV3, getSettingsFilterV3 };
52
+ export { getUnique, getCaseSensitive, getMultiline, getMaxLength, getRegexpExpression, getRegexpErrMsg, getDisplayAsPercentage, getDecimalPlaces, getMultiple, getOptionSource, getGlobalOptionApiName, getOptionList, getDescriptionWhenTrue, getDescriptionWhenFalse, getDefaultValue, getDisplayStyle, getLookupRefObjectApiName, getLookupIsHierarchy, getLookupDisplayStyle, getReturnType, getFormula, getGenerateMethod, getDigitsNumber, getPrefix, getSuffix, getReferenceObjectApiName, getReferenceFieldApiName, getFileMultiple, getFileTypes, getBackLookupObjectApiName, getBackLookupFieldApiName, getSettingsMultiple, getCompositeTypeApiName, getCompositeTypeSubFields, getSettingsFilter, getSettingsSort, getRecordPosition, getOptionListV3, getSettingsFilterV3, };
@@ -302,16 +302,7 @@ function getSettingsFilter(field) {
302
302
  exports.getSettingsFilter = getSettingsFilter;
303
303
  function getSettingsFilterV3(field) {
304
304
  if (field && field.type && field.type.settings && !(0, common_1.isNullOrUndefined)(field.type.settings.filter)) {
305
- const res = field.type.settings.filter.map(s => {
306
- let tmp;
307
- tmp.errorMsg = (0, common_1.transI18nsToMultilingualV3)(s.errorMsg);
308
- tmp.criterion = s.criterion;
309
- tmp.label = s.label;
310
- tmp.needTriggerCriterion = s.needTriggerCriterion;
311
- tmp.triggerCriterion = s.triggerCriterion;
312
- return tmp;
313
- });
314
- return res;
305
+ return field.type.settings.filter;
315
306
  }
316
307
  return [];
317
308
  }
@@ -326,13 +317,15 @@ exports.getRegionSettingsFilter = getRegionSettingsFilter;
326
317
  function getRegionSettingsFilterV3(field) {
327
318
  if (field && field.type && field.type.settings && !(0, common_1.isNullOrUndefined)(field.type.settings.filter)) {
328
319
  const res = field.type.settings.filter.map(s => {
329
- let tmp;
330
- tmp.errorMsg = (0, common_1.transI18nsToMultilingualV3)(s.errorMsg);
331
- tmp.criterion = s.criterion;
332
- tmp.label = s.label;
333
- tmp.needTriggerCriterion = s.needTriggerCriterion;
334
- tmp.triggerCriterion = s.triggerCriterion;
335
- return s;
320
+ let f = s;
321
+ const tmp = {
322
+ id: f.id,
323
+ label: f.label,
324
+ errorMessage: (0, common_1.transI18nsToMultilingualV3)(f.errorMessage),
325
+ recordFilter: f.recordFilter,
326
+ precondition: f.precondition,
327
+ };
328
+ return tmp;
336
329
  });
337
330
  return res;
338
331
  }
@@ -193,8 +193,7 @@ class FormulaV3 extends MetadataFieldV3 {
193
193
  }
194
194
  super('formula', field);
195
195
  this.returnType = fieldsUtil.getReturnType(field);
196
- // TODO 由于下游提供仍是 api ID 版本,因此禁用
197
- this.formula = null; //fieldsUtil.getFormula(field);
196
+ this.formula = (0, common_1.transI18nsToMultilingualV3)(fieldsUtil.getFormula(field));
198
197
  }
199
198
  }
200
199
  exports.FormulaV3 = FormulaV3;
@@ -318,19 +317,19 @@ function parseFieldsV3(inputFields) {
318
317
  }
319
318
  let fields = [];
320
319
  for (let field of inputFields) {
321
- let FieldClass = getFieldClassV3(field);
322
- if (!FieldClass) {
320
+ const fieldClass = getFieldClassV3(field);
321
+ if (!fieldClass) {
323
322
  continue;
324
323
  }
325
- fields.push(new FieldClass(field));
324
+ fields.push(new fieldClass(field));
326
325
  }
327
326
  return fields;
328
327
  }
329
328
  exports.parseFieldsV3 = parseFieldsV3;
330
329
  function parseFieldV3(field) {
331
- let FieldClass = getFieldClassV3(field);
332
- if (FieldClass) {
333
- return new FieldClass(field);
330
+ const fieldClass = getFieldClassV3(field);
331
+ if (fieldClass) {
332
+ return new fieldClass(field);
334
333
  }
335
334
  return null;
336
335
  }
@@ -5,7 +5,7 @@ export type I18n = {
5
5
  export type I18ns = I18n[];
6
6
  export declare function isNullOrUndefined(param: any): boolean;
7
7
  export declare function transI18nsToMultilingualV3(i18ns: I18ns): MultilingualTypeV3;
8
- export type MultilingualTypeV3 = {
8
+ export interface MultilingualTypeV3 {
9
9
  zh_CN: string;
10
10
  en_US: string;
11
- };
11
+ }
@@ -11,7 +11,7 @@ function transI18nsToMultilingualV3(i18ns) {
11
11
  if (i18ns === null || i18ns === undefined) {
12
12
  return null;
13
13
  }
14
- let multilingual = { zh_CN: "", en_US: "" };
14
+ let multilingual = { zh_CN: '', en_US: '' };
15
15
  for (const i18n of i18ns) {
16
16
  switch (i18n.language_code) {
17
17
  case languageCode.zh_CN:
@@ -29,5 +29,5 @@ function transI18nsToMultilingualV3(i18ns) {
29
29
  exports.transI18nsToMultilingualV3 = transI18nsToMultilingualV3;
30
30
  const languageCode = {
31
31
  zh_CN: 2052,
32
- en_US: 1033
32
+ en_US: 1033,
33
33
  };
@@ -37,13 +37,13 @@ export interface KDateTypeV3 extends BaseFieldTypeV3 {
37
37
  export interface DateTimeTypeV3 extends BaseFieldTypeV3 {
38
38
  required: boolean;
39
39
  }
40
- export type SubOptionTypeV3 = {
40
+ export interface SubOptionTypeV3 {
41
41
  label: MultilingualTypeV3;
42
42
  apiName: string;
43
43
  description: MultilingualTypeV3;
44
44
  color: ('grey' | 'blue' | 'cyan' | 'green' | 'yellow' | 'orange' | 'red' | 'magenta' | 'purple' | 'blueMagenta');
45
45
  active: boolean;
46
- };
46
+ }
47
47
  export interface OptionTypeV3 extends BaseFieldTypeV3 {
48
48
  required: boolean;
49
49
  multiple: boolean;
@@ -74,13 +74,13 @@ export type FilterTypeV3 = {
74
74
  criterion: CriterionType;
75
75
  errorMsg: MultilingualTypeV3;
76
76
  };
77
- export type RegionFilterTypeV3 = {
77
+ export interface RegionFilterTypeV3 {
78
78
  id: string;
79
79
  label: string;
80
80
  errorMessage: MultilingualTypeV3;
81
81
  recordFilter: CriterionType;
82
82
  precondition: object;
83
- };
83
+ }
84
84
  export interface LookupV3 extends BaseFieldTypeV3 {
85
85
  required: boolean;
86
86
  multiple: boolean;
package/hooks/hooks.js CHANGED
@@ -11,7 +11,6 @@ const common_1 = require("../request/common");
11
11
  const integration_1 = require("../context/integration/impl/integration");
12
12
  const metadataApi = require("../context/metadata/metadata");
13
13
  const flow_1 = require("../global/application/flow/flow");
14
- const dbV3_1 = require("../context/db/impl/dbV3");
15
14
  /**
16
15
  * 根据 key 获取对应的全局变量
17
16
  * @param key 全局变量的 key
@@ -74,7 +73,7 @@ function mountApplication(context) {
74
73
  global.application = {};
75
74
  }
76
75
  global.application.data = new db_1.DB();
77
- global.application.dataV3 = new dbV3_1.DBV3();
76
+ // (global as any).application.dataV3 = new DBV3<IGfCtx>();
78
77
  // publicAPI
79
78
  if (!global.application.publicAPI) {
80
79
  global.application.publicAPI = {};
@@ -86,7 +85,7 @@ function mountApplication(context) {
86
85
  global.application.msg = new msg_1.Message();
87
86
  global.application.resources = new resources_1._Resources();
88
87
  global.application.metadata = metadataApi.metadata(context);
89
- global.application.metadataV3 = metadataApi.metadataV3(context);
88
+ // (global as any).application.metadataV3 = metadataApi.metadataV3(context);
90
89
  // globalVar
91
90
  if (!global.application.globalVar) {
92
91
  global.application.globalVar = {};
@@ -194,7 +194,7 @@ exports.addIDCriterion = addIDCriterion;
194
194
  function convertCriterionToCriterionV3(criterion) {
195
195
  let criterionV3 = {
196
196
  conditions: [],
197
- expression: criterion.logic
197
+ expression: criterion.logic,
198
198
  };
199
199
  // const criterionCopy = {...criterion}; // 创造一个v1Data的拷贝
200
200
  criterionV3.conditions = criterion.conditions.map(condition => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@byted-apaas/server-sdk-node",
3
- "version": "1.1.18-beta.8",
3
+ "version": "1.1.18",
4
4
  "description": "aPaaS Server SDK",
5
5
  "author": "zhouwexin <zhouwexin@bytedance.com>",
6
6
  "homepage": "",
@@ -13,7 +13,7 @@
13
13
  "clean": "tsc --build --clean && rm -rf **/*.js.map"
14
14
  },
15
15
  "dependencies": {
16
- "@byted-apaas/server-common-node": "2.0.12-beta.4",
16
+ "@byted-apaas/server-common-node": "2.0.12-beta.6",
17
17
  "@jorgeferrero/stream-to-buffer": "^2.0.6",
18
18
  "dayjs": "^1.9.6",
19
19
  "form-data": "^3.0.0",
@@ -44,20 +44,20 @@ export interface IInnerAPIRequest extends IInnerAPIBaseRequest, IInnerAPIOpenSDK
44
44
  }
45
45
  export interface IInnerAPIBaseRequest {
46
46
  createRecordBySync: (objectApiName: string, record: object, authType: string) => any;
47
- createRecordV3BySync: (objectApiName: string, record: object, authType: string) => any;
47
+ createRecordBySyncV3: (objectApiName: string, record: object, authType: string) => any;
48
48
  updateRecordBySync: (objectApiName: string, recordID: number, record: object, authType: string) => any;
49
- updateRecordV3BySync: (objectApiName: string, recordID: string, record: object, authType: string) => any;
49
+ updateRecordBySyncV3: (objectApiName: string, recordID: string, record: object, authType: string) => any;
50
50
  deleteRecordBySync: (objectApiName: string, recordID: number, authType: string) => any;
51
- deleteRecordV3BySync: (objectApiName: string, recordID: string, authType: string) => any;
51
+ deleteRecordBySyncV3: (objectApiName: string, recordID: string, authType: string) => any;
52
52
  createRecordsByAsync: (objectApiName: string, records: object[], authType: string) => any;
53
53
  updateRecordsByAsync: (objectApiName: string, recordMap: Record<number, object>, authType: string) => any;
54
54
  deleteRecordsByAsync: (objectApiName: string, recordIDs: number[], authType: string) => any;
55
55
  createRecordsBySync: (objectApiName: string, records: object[], authType: string) => any;
56
- createRecordsV3BySync: (objectApiName: string, records: object[], authType: string) => any;
56
+ createRecordsBySyncV3: (objectApiName: string, records: object[], authType: string) => any;
57
57
  updateRecordsBySync: (objectApiName: string, recordMap: Record<number, object>, authType: string) => Promise<Record<number, string>>;
58
- updateRecordsV3BySync: (objectApiName: string, recordMap: object[], authType: string) => Promise<Record<string, string>>;
58
+ updateRecordsBySyncV3: (objectApiName: string, recordMap: object[], authType: string) => Promise<Record<string, string>>;
59
59
  deleteRecordsBySync: (objectApiName: string, recordIDs: number[], authType: string) => Promise<Record<number, string>>;
60
- deleteRecordsV3BySync: (objectApiName: string, recordIDs: string[], authType: string) => Promise<Record<string, string>>;
60
+ deleteRecordsBySyncV3: (objectApiName: string, recordIDs: string[], authType: string) => Promise<Record<string, string>>;
61
61
  getRecordsOrCountByCriterion: (objectApiName: string, criterion: string | Criterion, fuzzySearch: any, order: Order[], ignoreBackLookupField: boolean, fieldApiNames: string[], offset: number, limit: number, needCount: boolean, authType: string) => any;
62
62
  getRecordsV3OrCounByCriterion: (objectApiName: string, criterion: string | CriterionV3, quickQuery: string, quickQueryFields: string[], order: Order[], fieldApiNames: string[], offset: number, limit: number, needCount: boolean, authType: string) => any;
63
63
  updateWorkflowVariables: (ctx: any, instanceId: number, variables: object, variableTypes: object) => Promise<void>;
@@ -69,7 +69,7 @@ export interface IInnerAPIBaseRequest {
69
69
  getFields: (objectApiName: string) => Promise<any>;
70
70
  getField: (objectApiName: string, fieldApiName: string) => Promise<any>;
71
71
  terminateWorkflowInstance: (workflowInstanceId: number, operator: number, reason: string) => Promise<void>;
72
- modifyRecordsWithTransaction: (placeholders: Record<string, number>, operations: object[], authType: string) => Promise<Map<string, number>>;
72
+ modifyRecordsWithTransaction: (placeholders: Record<string, number>, operations: object[], authType: string, version: string) => Promise<Map<string, number>>;
73
73
  getGlobalConfigByKey: <valueT>(key: string) => Promise<valueT>;
74
74
  oql: (oql: string, args: any[], namedArgs: Record<string, any>, authType: string) => Promise<string | any[]>;
75
75
  invokeFuncSync: (idOrName: {
@@ -12,20 +12,20 @@ export declare class RequestHttp implements IInnerAPIRequest {
12
12
  constructor();
13
13
  updateWorkflowVariables(ctx: any, instanceId: number, variables: object, variableTypes: object): any;
14
14
  createRecordBySync(objectApiName: string, record: object, authType: string): any;
15
- createRecordV3BySync(objectApiName: string, record: object, authType: string): any;
15
+ createRecordBySyncV3(objectApiName: string, record: object, authType: string): any;
16
16
  updateRecordBySync(objectApiName: string, recordID: number, record: object, authType: string): any;
17
- updateRecordV3BySync(objectApiName: string, recordID: string, record: object, authType: string): any;
17
+ updateRecordBySyncV3(objectApiName: string, recordID: string, record: object, authType: string): any;
18
18
  deleteRecordBySync(objectApiName: string, recordID: number, authType: string): any;
19
- deleteRecordV3BySync(objectApiName: string, recordID: string, authType: string): any;
19
+ deleteRecordBySyncV3(objectApiName: string, recordID: string, authType: string): any;
20
20
  createRecordsByAsync(objectApiName: string, records: object[], authType: string): any;
21
21
  updateRecordsByAsync(objectApiName: string, recordMap: Record<number, object>, authType: string): any;
22
22
  deleteRecordsByAsync(objectApiName: string, recordIDs: number[], authType: string): any;
23
23
  createRecordsBySync(objectApiName: string, records: object[], authType: string): any;
24
- createRecordsV3BySync(objectApiName: string, records: object[], authType: string): any;
24
+ createRecordsBySyncV3(objectApiName: string, records: object[], authType: string): any;
25
25
  updateRecordsBySync(objectApiName: string, recordMap: Record<number, object>, authType: string): Promise<Record<number, string>>;
26
- updateRecordsV3BySync(objectApiName: string, records: object[], authType: string): Promise<Record<string, string>>;
26
+ updateRecordsBySyncV3(objectApiName: string, records: object[], authType: string): Promise<Record<string, string>>;
27
27
  deleteRecordsBySync(objectApiName: string, recordIDs: number[], authType: string): Promise<Record<number, string>>;
28
- deleteRecordsV3BySync(objectApiName: string, recordIDs: string[], authType: string): Promise<Record<string, string>>;
28
+ deleteRecordsBySyncV3(objectApiName: string, recordIDs: string[], authType: string): Promise<Record<string, string>>;
29
29
  getRecordsOrCountByCriterion(objectApiName: string, criterion: string | Criterion, order: Order[], fuzzySearch: any, ignoreBackLookupField: boolean, fieldApiNames: string[], offset: number, limit: number, needCount: boolean, authType: string): any;
30
30
  getRecordsV3OrCounByCriterion(objectApiName: string, criterion: string | CriterionV3, quickQuery: string, quickQueryFields: string[], order: Order[], fieldApiNames: string[], offset: number, limit: number, needCount: boolean, authType: string): any;
31
31
  uploadFile(data: Stream, expire: number, fileName?: string): Promise<UploadFileResp>;
@@ -36,7 +36,7 @@ export declare class RequestHttp implements IInnerAPIRequest {
36
36
  getFields(objectApiName: string): any;
37
37
  getField(objectApiName: string, fieldApiName: string): any;
38
38
  terminateWorkflowInstance(workflowInstanceId: number, operator: number, reason: string): any;
39
- modifyRecordsWithTransaction(placeholders: Record<string, number>, operations: object[], authType: string): Promise<Map<string, number>>;
39
+ modifyRecordsWithTransaction(placeholders: Record<string, number>, operations: object[], authType: string, version: string): Promise<Map<string, number>>;
40
40
  getGlobalConfigByKey<valueT>(key: string): Promise<valueT>;
41
41
  oql(oql: string, args: any[], namedArgs: Record<string, any>, authType: string): any;
42
42
  invokeFuncSync(idOrName: {
@@ -56,7 +56,7 @@ async function createRecordBySync(objectApiName, record, authType) {
56
56
  if (authType) {
57
57
  options.headers[constants_3.AuthTypeHttpHeader] = authType;
58
58
  }
59
- let task_id = utils.getTriggerTaskID();
59
+ const task_id = utils.getTriggerTaskID();
60
60
  if (task_id) {
61
61
  options.json.task_id = task_id;
62
62
  }
@@ -69,31 +69,30 @@ async function createRecordBySync(objectApiName, record, authType) {
69
69
  }
70
70
  return data;
71
71
  }
72
- // todo wby
73
- async function createRecordV3BySync(objectApiName, record, authType) {
72
+ async function createRecordBySyncV3(objectApiName, record, authType) {
74
73
  // 1.check
75
74
  if (!objectApiName) {
76
75
  throw new exceptions.InvalidParamError('objectApiName is empty');
77
76
  }
78
77
  // 2.获取 options
79
- let options = commonHttp.getOptions(null, openapiHttpPath.createRecordV3BySync);
78
+ let options = commonHttp.getOptions(null, openapiHttpPath.createRecordBySyncV3);
80
79
  let urlPath = options._reqPath.replace(replaceKeys.namespace, await (0, common_1.getNamespaceForOpenAndFaaSSDK)());
81
80
  urlPath = urlPath.replace(replaceKeys.objectApiName, objectApiName);
82
81
  // 3.请求
83
82
  options.json = {
84
- 'data_version': "v3",
85
- 'record': record,
83
+ 'data_version': 'v3',
84
+ record,
86
85
  };
87
86
  authType = (0, utils_1.formatAuthType)(authType);
88
87
  options.headers.User = String(utils.getUserIDFromCtx());
89
88
  if (authType) {
90
89
  options.headers[constants_3.AuthTypeHttpHeader] = authType;
91
90
  }
92
- let task_id = utils.getTriggerTaskID();
91
+ const task_id = utils.getTriggerTaskID();
93
92
  if (task_id) {
94
93
  options.json.task_id = task_id;
95
94
  }
96
- let data = await openapi.doRequest(null, urlPath, options);
95
+ const data = await openapi.doRequest(null, urlPath, options);
97
96
  if (data && data.record_id) {
98
97
  return { _id: data.record_id };
99
98
  }
@@ -122,34 +121,33 @@ async function updateRecordBySync(objectApiName, recordID, record, authType) {
122
121
  if (authType) {
123
122
  options.headers[constants_3.AuthTypeHttpHeader] = authType;
124
123
  }
125
- let task_id = utils.getTriggerTaskID();
124
+ const task_id = utils.getTriggerTaskID();
126
125
  if (task_id) {
127
126
  options.json.task_id = task_id;
128
127
  }
129
128
  return openapi.doRequest(null, urlPath, options);
130
129
  }
131
- // todo wby
132
- async function updateRecordV3BySync(objectApiName, recordID, record, authType) {
130
+ async function updateRecordBySyncV3(objectApiName, recordID, record, authType) {
133
131
  // 1.check
134
132
  if (!objectApiName) {
135
133
  throw new exceptions.InvalidParamError('objectApiName is empty');
136
134
  }
137
135
  // 2.获取 options
138
- let options = commonHttp.getOptions(null, openapiHttpPath.updateRecordV3BySync);
136
+ let options = commonHttp.getOptions(null, openapiHttpPath.updateRecordBySyncV3);
139
137
  let urlPath = options._reqPath.replace(replaceKeys.namespace, await (0, common_1.getNamespaceForOpenAndFaaSSDK)());
140
138
  urlPath = urlPath.replace(replaceKeys.objectApiName, objectApiName);
141
139
  urlPath = urlPath.replace(replaceKeys.recordID, recordID);
142
140
  // 3.请求
143
141
  options.json = {
144
- "record": record,
145
- "data_version": "v3"
142
+ 'record': record,
143
+ "data_version": 'v3',
146
144
  };
147
145
  authType = (0, utils_1.formatAuthType)(authType);
148
146
  options.headers.User = String(utils.getUserIDFromCtx());
149
147
  if (authType) {
150
148
  options.headers[constants_3.AuthTypeHttpHeader] = authType;
151
149
  }
152
- let task_id = utils.getTriggerTaskID();
150
+ const task_id = utils.getTriggerTaskID();
153
151
  if (task_id) {
154
152
  options.json.task_id = task_id;
155
153
  }
@@ -174,14 +172,32 @@ async function deleteRecordBySync(objectApiName, recordID, authType) {
174
172
  if (authType) {
175
173
  options.headers[constants_3.AuthTypeHttpHeader] = authType;
176
174
  }
177
- let task_id = utils.getTriggerTaskID();
175
+ const task_id = utils.getTriggerTaskID();
178
176
  if (task_id) {
179
177
  options.json.task_id = task_id;
180
178
  }
181
179
  return openapi.doRequest(null, urlPath, options);
182
180
  }
183
- // todo wby
184
- async function deleteRecordV3BySync(objectApiName, recordID, authType) {
181
+ async function deleteRecordBySyncV3(objectApiName, recordID, authType) {
182
+ // 1.check
183
+ if (!objectApiName) {
184
+ throw new exceptions.InvalidParamError('objectApiName is empty');
185
+ }
186
+ // 2.获取 options
187
+ let options = commonHttp.getOptions(null, openapiHttpPath.deleteRecordBySyncV3);
188
+ let urlPath = options._reqPath.replace(replaceKeys.namespace, await (0, common_1.getNamespaceForOpenAndFaaSSDK)());
189
+ urlPath = urlPath.replace(replaceKeys.objectApiName, objectApiName);
190
+ urlPath = urlPath.replace(replaceKeys.recordID, recordID);
191
+ authType = (0, utils_1.formatAuthType)(authType);
192
+ options.headers.User = String(utils.getUserIDFromCtx());
193
+ if (authType) {
194
+ options.headers[constants_3.AuthTypeHttpHeader] = authType;
195
+ }
196
+ const task_id = utils.getTriggerTaskID();
197
+ if (task_id) {
198
+ options.json.task_id = task_id;
199
+ }
200
+ return openapi.doRequest(null, urlPath, options);
185
201
  }
186
202
  async function createRecordsByAsync(objectApiName, records, authType) {
187
203
  // 1.获取 options
@@ -198,7 +214,7 @@ async function createRecordsByAsync(objectApiName, records, authType) {
198
214
  if (authType) {
199
215
  options.headers[constants_3.AuthTypeHttpHeader] = authType;
200
216
  }
201
- let task_id = utils.getTriggerTaskID();
217
+ const task_id = utils.getTriggerTaskID();
202
218
  if (task_id) {
203
219
  options.json.automation_task_id = task_id;
204
220
  }
@@ -219,7 +235,7 @@ async function updateRecordsByAsync(objectApiName, recordMap, authType) {
219
235
  if (authType) {
220
236
  options.headers[constants_3.AuthTypeHttpHeader] = authType;
221
237
  }
222
- let task_id = utils.getTriggerTaskID();
238
+ const task_id = utils.getTriggerTaskID();
223
239
  if (task_id) {
224
240
  options.json.automation_task_id = task_id;
225
241
  }
@@ -240,7 +256,7 @@ async function deleteRecordsByAsync(objectApiName, recordIDs, authType) {
240
256
  if (authType) {
241
257
  options.headers[constants_3.AuthTypeHttpHeader] = authType;
242
258
  }
243
- let task_id = utils.getTriggerTaskID();
259
+ const task_id = utils.getTriggerTaskID();
244
260
  if (task_id) {
245
261
  options.json.automation_task_id = task_id;
246
262
  }
@@ -262,20 +278,20 @@ async function createRecordsBySync(objectApiName, records, authType) {
262
278
  if (authType) {
263
279
  options.headers[constants_3.AuthTypeHttpHeader] = authType;
264
280
  }
265
- let task_id = utils.getTriggerTaskID();
281
+ const task_id = utils.getTriggerTaskID();
266
282
  if (task_id) {
267
283
  options.json.automation_task_id = task_id;
268
284
  }
269
285
  return openapi.doRequest(null, urlPath, options);
270
286
  }
271
- async function createRecordsV3BySync(objectApiName, records, authType) {
287
+ async function createRecordsBySyncV3(objectApiName, records, authType) {
272
288
  // 1.获取 options
273
- let options = commonHttp.getOptions(null, openapiHttpPath.createRecordsV3BySync);
289
+ const options = commonHttp.getOptions(null, openapiHttpPath.createRecordsBySyncV3);
274
290
  let urlPath = options._reqPath.replace(replaceKeys.namespace, await (0, common_1.getNamespaceForOpenAndFaaSSDK)());
275
291
  urlPath = urlPath.replace(replaceKeys.objectApiName, objectApiName);
276
292
  // 2.请求
277
293
  options.json = {
278
- 'records': records,
294
+ records,
279
295
  'data_version': 'v3',
280
296
  };
281
297
  authType = (0, utils_1.formatAuthType)(authType);
@@ -283,7 +299,7 @@ async function createRecordsV3BySync(objectApiName, records, authType) {
283
299
  if (authType) {
284
300
  options.headers[constants_3.AuthTypeHttpHeader] = authType;
285
301
  }
286
- let task_id = utils.getTriggerTaskID();
302
+ const task_id = utils.getTriggerTaskID();
287
303
  if (task_id) {
288
304
  options.json.automation_task_id = task_id;
289
305
  }
@@ -305,7 +321,7 @@ async function updateRecordsBySync(objectApiName, recordMap, authType) {
305
321
  if (authType) {
306
322
  options.headers[constants_3.AuthTypeHttpHeader] = authType;
307
323
  }
308
- let task_id = utils.getTriggerTaskID();
324
+ const task_id = utils.getTriggerTaskID();
309
325
  if (task_id) {
310
326
  options.json.automation_task_id = task_id;
311
327
  }
@@ -319,14 +335,14 @@ async function updateRecordsBySync(objectApiName, recordMap, authType) {
319
335
  }
320
336
  return errMap;
321
337
  }
322
- async function updateRecordsV3BySync(objectApiName, records, authType) {
338
+ async function updateRecordsBySyncV3(objectApiName, records, authType) {
323
339
  // 1.获取 options
324
- let options = commonHttp.getOptions(null, openapiHttpPath.updateRecordsV3BySync);
340
+ let options = commonHttp.getOptions(null, openapiHttpPath.updateRecordsBySyncV3);
325
341
  let urlPath = options._reqPath.replace(replaceKeys.namespace, await (0, common_1.getNamespaceForOpenAndFaaSSDK)());
326
342
  urlPath = urlPath.replace(replaceKeys.objectApiName, objectApiName);
327
343
  // 2.请求
328
344
  options.json = {
329
- 'records': records,
345
+ records,
330
346
  'data_version': 'v3',
331
347
  };
332
348
  authType = (0, utils_1.formatAuthType)(authType);
@@ -334,7 +350,7 @@ async function updateRecordsV3BySync(objectApiName, records, authType) {
334
350
  if (authType) {
335
351
  options.headers[constants_3.AuthTypeHttpHeader] = authType;
336
352
  }
337
- let task_id = utils.getTriggerTaskID();
353
+ const task_id = utils.getTriggerTaskID();
338
354
  if (task_id) {
339
355
  options.json.automation_task_id = task_id;
340
356
  }
@@ -342,7 +358,6 @@ async function updateRecordsV3BySync(objectApiName, records, authType) {
342
358
  if (!resp || !resp.err_map) {
343
359
  return undefined;
344
360
  }
345
- // todo wby 待确认返回值
346
361
  const errMap = {};
347
362
  for (let recordID of Object.keys(resp.err_map)) {
348
363
  errMap[String(recordID)] = resp.err_map[recordID];
@@ -365,7 +380,7 @@ async function deleteRecordsBySync(objectApiName, recordIDs, authType) {
365
380
  if (authType) {
366
381
  options.headers[constants_3.AuthTypeHttpHeader] = authType;
367
382
  }
368
- let task_id = utils.getTriggerTaskID();
383
+ const task_id = utils.getTriggerTaskID();
369
384
  if (task_id) {
370
385
  options.json.automation_task_id = task_id;
371
386
  }
@@ -379,9 +394,9 @@ async function deleteRecordsBySync(objectApiName, recordIDs, authType) {
379
394
  }
380
395
  return errMap;
381
396
  }
382
- async function deleteRecordsV3BySync(objectApiName, recordIDs, authType) {
397
+ async function deleteRecordsBySyncV3(objectApiName, recordIDs, authType) {
383
398
  // 1.获取 options
384
- let options = commonHttp.getOptions(null, openapiHttpPath.deleteRecordsV3BySync);
399
+ const options = commonHttp.getOptions(null, openapiHttpPath.deleteRecordsBySyncV3);
385
400
  let urlPath = options._reqPath.replace(replaceKeys.namespace, await (0, common_1.getNamespaceForOpenAndFaaSSDK)());
386
401
  urlPath = urlPath.replace(replaceKeys.objectApiName, objectApiName);
387
402
  // 2.请求
@@ -394,7 +409,7 @@ async function deleteRecordsV3BySync(objectApiName, recordIDs, authType) {
394
409
  if (authType) {
395
410
  options.headers[constants_3.AuthTypeHttpHeader] = authType;
396
411
  }
397
- let task_id = utils.getTriggerTaskID();
412
+ const task_id = utils.getTriggerTaskID();
398
413
  if (task_id) {
399
414
  options.json.automation_task_id = task_id;
400
415
  }
@@ -425,6 +440,9 @@ function handleResponse(objectAPIName, data, needCount) {
425
440
  if (data.unauthPermissionInfo && data.unauthPermissionInfo.UnauthFieldSlice) {
426
441
  permissionUtils.appendUnauthFieldRecordList(objectAPIName, records, data.unauthPermissionInfo.UnauthFieldSlice, true);
427
442
  }
443
+ if (data.unauth_permission_info && data.unauth_permission_info.unauth_field_slice) {
444
+ permissionUtils.appendUnauthFieldRecordList(objectAPIName, records, data.unauth_permission_info.unauth_field_slice, true);
445
+ }
428
446
  return records;
429
447
  }
430
448
  return [];
@@ -467,7 +485,7 @@ async function getRecordsOrCountByCriterion(objectApiName, criterion, fuzzySearc
467
485
  if (authType) {
468
486
  options.headers[constants_3.AuthTypeHttpHeader] = authType;
469
487
  }
470
- let data = await openapi.doRequest(null, urlPath, options);
488
+ const data = await openapi.doRequest(null, urlPath, options);
471
489
  return handleResponse(objectApiName, data, needCount);
472
490
  }
473
491
  async function getRecordsV3OrCountByCriterion(objectApiName, criterion, quickQuery, quickQueryFields, order, fieldApiNames, offset, limit, needCount, authType) {
@@ -495,20 +513,19 @@ async function getRecordsV3OrCountByCriterion(objectApiName, criterion, quickQue
495
513
  'filter': criterion,
496
514
  'quick_query': quickQuery,
497
515
  'quick_query_fields': quickQueryFields,
498
- // fuzzySearch, // todo wby
499
516
  // 只返回 slice 结果,使用 SliceResult
500
517
  // 只返回 map 结果,使用 MapResult
501
518
  // 分不清场景可以用 BothResult,性能较差,建议区分场景
502
519
  // 0 表示不返回 unauth field 任何数据; 1 表示两者都返回;2 表示仅返回 slice;3 表示仅返回 map
503
520
  'process_auth_field_type': 2,
504
- 'date_version': 'v3',
521
+ 'data_version': 'v3',
505
522
  };
506
523
  authType = (0, utils_1.formatAuthType)(authType);
507
524
  options.headers.User = String(utils.getUserIDFromCtx());
508
525
  if (authType) {
509
526
  options.headers[constants_3.AuthTypeHttpHeader] = authType;
510
527
  }
511
- let data = await openapi.doRequest(null, urlPath, options);
528
+ const data = await openapi.doRequest(null, urlPath, options);
512
529
  return handleResponse(objectApiName, data, needCount);
513
530
  }
514
531
  /**
@@ -759,7 +776,7 @@ async function terminateWorkflowInstance(workflowInstanceId, operator, reason) {
759
776
  };
760
777
  await openapi.doRequest(null, urlPath, options);
761
778
  }
762
- async function modifyRecordsWithTransaction(placeholders, operations, authType) {
779
+ async function modifyRecordsWithTransaction(placeholders, operations, authType, version) {
763
780
  // 1.获取 options
764
781
  let options = commonHttp.getOptions(null, openapiHttpPath.modifyRecordsWithTransaction);
765
782
  let urlPath = options._reqPath.replace(replaceKeys.namespace, await (0, common_1.getNamespaceForOpenAndFaaSSDK)());
@@ -770,6 +787,9 @@ async function modifyRecordsWithTransaction(placeholders, operations, authType)
770
787
  'operatorId': utils.getUserIDFromCtx(),
771
788
  'setSystemField': 1,
772
789
  };
790
+ if (version === 'v3') {
791
+ options.json['dataVersion'] = version;
792
+ }
773
793
  authType = (0, utils_1.formatAuthType)(authType);
774
794
  options.headers.User = String(utils.getUserIDFromCtx());
775
795
  if (authType) {
@@ -836,10 +856,17 @@ async function oql(oql, args, namedArgs, authType) {
836
856
  }
837
857
  options.headers[constants_3.AuthTypeHttpHeader] = authType;
838
858
  }
839
- let result = await openapi.doRequest(null, urlPath, options);
840
- if (result && result.rows) {
841
- permissionUtils.appendUnauthFieldRecordList("", result.rows, result.unauth_field_slice, true);
842
- return result.rows;
859
+ try {
860
+ let result = await openapi.doRequest(null, urlPath, options);
861
+ if (result && result.rows) {
862
+ permissionUtils.appendUnauthFieldRecordList("", result.rows, result.unauth_field_slice, true);
863
+ return result.rows;
864
+ }
865
+ }
866
+ catch (e) {
867
+ if (e.message.includes("TimeoutError")) {
868
+ throw new exceptions.CallOpenapiError(`OQL timeout, please check the query statement and the execution time of the query statement.`);
869
+ }
843
870
  }
844
871
  return [];
845
872
  }
@@ -969,20 +996,20 @@ class RequestHttp {
969
996
  constructor() {
970
997
  this.updateWorkflowVariables = updateWorkflowVariables;
971
998
  this.createRecordBySync = createRecordBySync;
972
- this.createRecordV3BySync = createRecordV3BySync;
999
+ this.createRecordBySyncV3 = createRecordBySyncV3;
973
1000
  this.updateRecordBySync = updateRecordBySync;
974
- this.updateRecordV3BySync = updateRecordV3BySync;
1001
+ this.updateRecordBySyncV3 = updateRecordBySyncV3;
975
1002
  this.deleteRecordBySync = deleteRecordBySync;
976
- this.deleteRecordV3BySync = deleteRecordV3BySync;
1003
+ this.deleteRecordBySyncV3 = deleteRecordBySyncV3;
977
1004
  this.createRecordsByAsync = createRecordsByAsync;
978
1005
  this.updateRecordsByAsync = updateRecordsByAsync;
979
1006
  this.deleteRecordsByAsync = deleteRecordsByAsync;
980
1007
  this.createRecordsBySync = createRecordsBySync;
981
- this.createRecordsV3BySync = createRecordsV3BySync;
1008
+ this.createRecordsBySyncV3 = createRecordsBySyncV3;
982
1009
  this.updateRecordsBySync = updateRecordsBySync;
983
- this.updateRecordsV3BySync = updateRecordsV3BySync;
1010
+ this.updateRecordsBySyncV3 = updateRecordsBySyncV3;
984
1011
  this.deleteRecordsBySync = deleteRecordsBySync;
985
- this.deleteRecordsV3BySync = deleteRecordsV3BySync;
1012
+ this.deleteRecordsBySyncV3 = deleteRecordsBySyncV3;
986
1013
  this.getRecordsOrCountByCriterion = getRecordsOrCountByCriterion;
987
1014
  this.getRecordsV3OrCounByCriterion = getRecordsV3OrCountByCriterion;
988
1015
  this.uploadFile = uploadFile;
@@ -1017,15 +1044,15 @@ class RequestHttp {
1017
1044
  }
1018
1045
  createRecordBySync(objectApiName, record, authType) {
1019
1046
  }
1020
- createRecordV3BySync(objectApiName, record, authType) {
1047
+ createRecordBySyncV3(objectApiName, record, authType) {
1021
1048
  }
1022
1049
  updateRecordBySync(objectApiName, recordID, record, authType) {
1023
1050
  }
1024
- updateRecordV3BySync(objectApiName, recordID, record, authType) {
1051
+ updateRecordBySyncV3(objectApiName, recordID, record, authType) {
1025
1052
  }
1026
1053
  deleteRecordBySync(objectApiName, recordID, authType) {
1027
1054
  }
1028
- deleteRecordV3BySync(objectApiName, recordID, authType) {
1055
+ deleteRecordBySyncV3(objectApiName, recordID, authType) {
1029
1056
  }
1030
1057
  createRecordsByAsync(objectApiName, records, authType) {
1031
1058
  }
@@ -1035,18 +1062,18 @@ class RequestHttp {
1035
1062
  }
1036
1063
  createRecordsBySync(objectApiName, records, authType) {
1037
1064
  }
1038
- createRecordsV3BySync(objectApiName, records, authType) {
1065
+ createRecordsBySyncV3(objectApiName, records, authType) {
1039
1066
  }
1040
1067
  updateRecordsBySync(objectApiName, recordMap, authType) {
1041
1068
  return new Promise(undefined);
1042
1069
  }
1043
- updateRecordsV3BySync(objectApiName, records, authType) {
1070
+ updateRecordsBySyncV3(objectApiName, records, authType) {
1044
1071
  return new Promise(undefined);
1045
1072
  }
1046
1073
  deleteRecordsBySync(objectApiName, recordIDs, authType) {
1047
1074
  return new Promise(undefined);
1048
1075
  }
1049
- deleteRecordsV3BySync(objectApiName, recordIDs, authType) {
1076
+ deleteRecordsBySyncV3(objectApiName, recordIDs, authType) {
1050
1077
  return new Promise(undefined);
1051
1078
  }
1052
1079
  getRecordsOrCountByCriterion(objectApiName, criterion, order, fuzzySearch, ignoreBackLookupField, fieldApiNames, offset, limit, needCount, authType) {
@@ -1076,7 +1103,7 @@ class RequestHttp {
1076
1103
  }
1077
1104
  terminateWorkflowInstance(workflowInstanceId, operator, reason) {
1078
1105
  }
1079
- async modifyRecordsWithTransaction(placeholders, operations, authType) {
1106
+ async modifyRecordsWithTransaction(placeholders, operations, authType, version) {
1080
1107
  return new Promise(undefined);
1081
1108
  }
1082
1109
  getGlobalConfigByKey(key) {