@byted-apaas/server-sdk-node 1.1.18-beta.5 → 1.1.18-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/common/structs.d.ts +2 -2
- package/context/db/db.d.ts +1 -21
- package/context/db/impl/IObject.d.ts +3 -3
- package/context/db/impl/IObjectV3.d.ts +2 -2
- package/context/db/impl/dbV3.d.ts +2 -11
- package/context/db/impl/dbV3.js +19 -6
- package/context/db/impl/object.d.ts +4 -1
- package/context/db/impl/object.js +58 -4
- package/context/db/impl/queryBuilder.d.ts +2 -0
- package/context/metadata/metadata.js +14 -3
- package/context/metadata/objects/fieldsV3.d.ts +158 -0
- package/context/metadata/objects/fieldsV3.js +370 -0
- package/context/metadata/types/common.d.ts +5 -0
- package/context/metadata/types/common.js +25 -1
- package/package.json +2 -2
- package/request/interface.d.ts +3 -1
- package/request/openapi.d.ts +2 -2
- package/request/openapi.js +5 -3
package/common/structs.d.ts
CHANGED
|
@@ -6,10 +6,10 @@ export interface BatchResult {
|
|
|
6
6
|
}
|
|
7
7
|
export interface BatchResultData {
|
|
8
8
|
success: boolean;
|
|
9
|
-
_id: number;
|
|
9
|
+
_id: number | string;
|
|
10
10
|
errors?: BatchResultDataError[];
|
|
11
11
|
}
|
|
12
12
|
export interface BatchResultDataError {
|
|
13
13
|
code: string;
|
|
14
14
|
}
|
|
15
|
-
export declare function NewBatchResult(recordIDs: number[], errMap: Record<number, string>): BatchResult;
|
|
15
|
+
export declare function NewBatchResult(recordIDs: number[] | string[], errMap: Record<number | string, string>): BatchResult;
|
package/context/db/db.d.ts
CHANGED
|
@@ -91,27 +91,7 @@ export interface IDBV3<T, mt> {
|
|
|
91
91
|
* await tx.commit();
|
|
92
92
|
* ```
|
|
93
93
|
*/
|
|
94
|
-
|
|
95
|
-
* OQL 操作
|
|
96
|
-
* @param oql OQL 语句
|
|
97
|
-
* @example
|
|
98
|
-
* ```
|
|
99
|
-
* let users = await application.data.oql('select _email from _user').execute();
|
|
100
|
-
* ```
|
|
101
|
-
*/
|
|
102
|
-
oql(oql: string): IOql;
|
|
103
|
-
/**
|
|
104
|
-
* OQL 操作
|
|
105
|
-
* @param oql OQL 语句
|
|
106
|
-
* @param nameArgs 用于替换 OQL 语句中的占位符
|
|
107
|
-
* @example
|
|
108
|
-
* ```
|
|
109
|
-
* let employees = await application.data.oql('select _email from _user where _type = $user_type',{
|
|
110
|
-
* 'user_type': '_employee',
|
|
111
|
-
* }).execute();
|
|
112
|
-
* ```
|
|
113
|
-
*/
|
|
114
|
-
oql(oql: string, nameArgs: Record<string, any>): IOql;
|
|
94
|
+
newTransaction(): ITransactionGetter<T, mt>;
|
|
115
95
|
}
|
|
116
96
|
/**
|
|
117
97
|
* IDBWithCurrentObject 经由 IDBGetter 返回,是 DB 的动态增加的接口结构
|
|
@@ -27,7 +27,7 @@ export interface _IKSyncEndpoint<T> {
|
|
|
27
27
|
* application.data.object('_user').delete(123456789123)
|
|
28
28
|
* ```
|
|
29
29
|
*/
|
|
30
|
-
delete(recordID: number
|
|
30
|
+
delete(recordID: number): Promise<void>;
|
|
31
31
|
/**
|
|
32
32
|
* 删除记录
|
|
33
33
|
* @param record 用于删除的一条完整记录
|
|
@@ -49,7 +49,7 @@ export interface _IKSyncEndpoint<T> {
|
|
|
49
49
|
* })
|
|
50
50
|
* ```
|
|
51
51
|
*/
|
|
52
|
-
update(_id: number
|
|
52
|
+
update(_id: number, recordMap: _Cond<T>): Promise<void>;
|
|
53
53
|
/**
|
|
54
54
|
* 指定 _id 后,更新对应记录
|
|
55
55
|
* @param recordMap 用于更新的一条记录,需对 _id 赋值
|
|
@@ -68,7 +68,7 @@ export interface _IKSyncEndpoint<T> {
|
|
|
68
68
|
* @param recordMapList 多条用于创建的记录数据组成的数组
|
|
69
69
|
* @paramExample [{_name: 'John', age: 19, gender: 'male'}, {_name: 'Alis', age: 16, gender: 'female'}]
|
|
70
70
|
*/
|
|
71
|
-
batchCreate(recordMapList: _Cond<T>[]): Promise<number[]>;
|
|
71
|
+
batchCreate(recordMapList: _Cond<T>[]): Promise<number[] | string[]>;
|
|
72
72
|
/**
|
|
73
73
|
* 批量删除记录
|
|
74
74
|
* @param recordIdList 多个用于删除的记录 ID 组成的数组
|
|
@@ -68,13 +68,13 @@ export interface _IKSyncEndpointV3<T> {
|
|
|
68
68
|
* @param recordMapList 多条用于创建的记录数据组成的数组
|
|
69
69
|
* @paramExample [{_name: 'John', age: 19, gender: 'male'}, {_name: 'Alis', age: 16, gender: 'female'}]
|
|
70
70
|
*/
|
|
71
|
-
batchCreate(recordMapList: _Cond<T>[]): Promise<number[]>;
|
|
71
|
+
batchCreate(recordMapList: _Cond<T>[]): Promise<number[] | string[]>;
|
|
72
72
|
/**
|
|
73
73
|
* 批量删除记录
|
|
74
74
|
* @param recordIdList 多个用于删除的记录 ID 组成的数组
|
|
75
75
|
* @paramExample [1001, 1002, 1003]
|
|
76
76
|
*/
|
|
77
|
-
batchDelete(recordIdList:
|
|
77
|
+
batchDelete(recordIdList: string[]): Promise<BatchResult>;
|
|
78
78
|
/**
|
|
79
79
|
* 批量删除记录
|
|
80
80
|
* @param recordList 多条用于删除的记录数据组成的数组,记录数据需对 _id 赋值
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { ITransactionGetter } from './transaction';
|
|
1
2
|
import { IDBV3 } from '../db';
|
|
2
3
|
import { metadataMap } from '../../../data/index';
|
|
3
|
-
import { IOql } from './oql/ioql';
|
|
4
4
|
import { _IKAllEndpointV3, _IKQueryV3 } from './IObjectV3';
|
|
5
5
|
export declare class DBV3<T, mt = metadataMap> implements IDBV3<T, mt> {
|
|
6
6
|
objectApiName: string;
|
|
@@ -31,14 +31,5 @@ export declare class DBV3<T, mt = metadataMap> implements IDBV3<T, mt> {
|
|
|
31
31
|
* await tx.commit();
|
|
32
32
|
* ```
|
|
33
33
|
*/
|
|
34
|
-
|
|
35
|
-
* OQL 操作
|
|
36
|
-
* @param oql 指定 OQL 语句
|
|
37
|
-
* @example
|
|
38
|
-
* ```
|
|
39
|
-
* let users = await context.db.oql('select _email from _user').execute();
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
oql(oql: string): IOql;
|
|
43
|
-
oql(oql: string, nameArgs: Record<string, any>): IOql;
|
|
34
|
+
newTransaction(): ITransactionGetter<T, mt>;
|
|
44
35
|
}
|
package/context/db/impl/dbV3.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DBV3 = void 0;
|
|
4
4
|
const object_1 = require("./object");
|
|
5
|
-
const
|
|
5
|
+
const index_1 = require("./transaction/index");
|
|
6
6
|
class DBV3 {
|
|
7
7
|
constructor(objectApiName) {
|
|
8
8
|
this.objectApiName = objectApiName;
|
|
@@ -24,14 +24,27 @@ class DBV3 {
|
|
|
24
24
|
return new object_1._KObject(objectApiName, appCtx);
|
|
25
25
|
}
|
|
26
26
|
;
|
|
27
|
-
|
|
27
|
+
/**
|
|
28
|
+
* 创建一个新的空事务
|
|
29
|
+
* @example
|
|
30
|
+
* ```
|
|
31
|
+
* let tx = context.db.newTransaction();
|
|
32
|
+
* let user = tx.object('_user').registerCreate({
|
|
33
|
+
* _name: new kunlun.type.Multilingual({ zh: '用户1', en: 'user1' }),
|
|
34
|
+
* });
|
|
35
|
+
* let contract = tx.object('contract').registerCreate({
|
|
36
|
+
* _name: new kunlun.type.Multilingual({ zh: '用户1的合同', en: 'user1's contract' }),
|
|
37
|
+
* user: {id: user._id}
|
|
38
|
+
* });
|
|
39
|
+
* await tx.commit();
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
newTransaction() {
|
|
28
43
|
const appCtx = {
|
|
29
44
|
dataVersion: "v3",
|
|
30
45
|
};
|
|
31
|
-
|
|
32
|
-
return new oql_1.Oql(oql, nameArgs, appCtx);
|
|
33
|
-
}
|
|
34
|
-
return new oql_1.Oql(oql, undefined, appCtx);
|
|
46
|
+
return new index_1.Transaction(this.objectApiName, appCtx);
|
|
35
47
|
}
|
|
48
|
+
;
|
|
36
49
|
}
|
|
37
50
|
exports.DBV3 = DBV3;
|
|
@@ -35,11 +35,14 @@ declare class _KObjectSync<T> implements _IKSyncEndpoint<T>, _IKSyncEndpointV3<T
|
|
|
35
35
|
update(_id: number | string, recordMap: _Cond<T>): Promise<void>;
|
|
36
36
|
update(recordMap: _Cond<T>): Promise<void>;
|
|
37
37
|
private updateV3;
|
|
38
|
-
batchCreate(recordMapList: _Cond<T>[]): Promise<number[]>;
|
|
38
|
+
batchCreate(recordMapList: _Cond<T>[]): Promise<number[] | string[]>;
|
|
39
|
+
private batchCreateV3;
|
|
39
40
|
batchDelete(recordIdList: string[]): Promise<BatchResult>;
|
|
40
41
|
batchDelete(recordIdList: number[]): Promise<BatchResult>;
|
|
41
42
|
batchDelete(recordList: _Cond<T>[]): Promise<BatchResult>;
|
|
43
|
+
private batchDeleteV3;
|
|
42
44
|
batchUpdate(recordMapList: _Cond<T>[]): Promise<BatchResult>;
|
|
45
|
+
private batchUpdateV3;
|
|
43
46
|
useUserAuth(): this;
|
|
44
47
|
useSystemAuth(): this;
|
|
45
48
|
}
|
|
@@ -212,6 +212,9 @@ class _KObjectSync {
|
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
214
|
recordMapList = permissionUtils.batchDelUnauthField(recordMapList).newRecords;
|
|
215
|
+
if (this.appCtx && this.appCtx.dataVersion === "v3") {
|
|
216
|
+
return await this.batchCreateV3(recordMapList);
|
|
217
|
+
}
|
|
215
218
|
let data = (this.appCtx && this.appCtx.mode == 'openSDK') ?
|
|
216
219
|
await (0, common_1.runCtxForOpenSDK)(this.appCtx, async () => await Request.GetInstance().openSDKCreateRecordsBySync(this.apiName, recordMapList))
|
|
217
220
|
: await Request.GetInstance().createRecordsBySync(this.apiName, recordMapList, this.authType);
|
|
@@ -222,6 +225,11 @@ class _KObjectSync {
|
|
|
222
225
|
return data;
|
|
223
226
|
}
|
|
224
227
|
;
|
|
228
|
+
async batchCreateV3(recordMapList) {
|
|
229
|
+
const dataV3 = await Request.GetInstance().createRecordsV3BySync(this.apiName, recordMapList, this.authType);
|
|
230
|
+
const ids = (dataV3.items || []).map((item) => item?._id);
|
|
231
|
+
return ids;
|
|
232
|
+
}
|
|
225
233
|
async batchDelete(idOrRecordList) {
|
|
226
234
|
// 参数校验、组装
|
|
227
235
|
if (!this.apiName) {
|
|
@@ -230,6 +238,9 @@ class _KObjectSync {
|
|
|
230
238
|
if (!(idOrRecordList instanceof Array) || idOrRecordList.length === 0) {
|
|
231
239
|
throw new server_common_node_1.exceptions.InvalidParamError('param records is not an array or an empty array');
|
|
232
240
|
}
|
|
241
|
+
if (this.appCtx && this.appCtx.dataVersion === "v3") {
|
|
242
|
+
return this.batchDeleteV3(idOrRecordList);
|
|
243
|
+
}
|
|
233
244
|
let recordIDs = [];
|
|
234
245
|
for (let record of idOrRecordList) {
|
|
235
246
|
if (typeof (record) === 'number') {
|
|
@@ -251,6 +262,25 @@ class _KObjectSync {
|
|
|
251
262
|
const errMap = await Request.GetInstance().deleteRecordsBySync(this.apiName, recordIDs, this.authType);
|
|
252
263
|
return (0, structs_1.NewBatchResult)(recordIDs, errMap);
|
|
253
264
|
}
|
|
265
|
+
async batchDeleteV3(idOrRecordList) {
|
|
266
|
+
let recordIDs = [];
|
|
267
|
+
for (let record of idOrRecordList) {
|
|
268
|
+
if (typeof (record) === 'string') {
|
|
269
|
+
recordIDs.push(record);
|
|
270
|
+
}
|
|
271
|
+
else if (typeof (record) === 'number') {
|
|
272
|
+
recordIDs.push(record.toString());
|
|
273
|
+
}
|
|
274
|
+
else if (server_common_node_1.checkUtils.isObject(record) && record._id && typeof (record._id) === 'string') {
|
|
275
|
+
recordIDs.push(record._id);
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
throw new server_common_node_1.exceptions.InvalidParamError('record must be string or number or object');
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
const errMap = await Request.GetInstance().deleteRecordsV3BySync(this.apiName, recordIDs, this.authType);
|
|
282
|
+
return (0, structs_1.NewBatchResult)(recordIDs, errMap);
|
|
283
|
+
}
|
|
254
284
|
async batchUpdate(recordMapList) {
|
|
255
285
|
// 参数校验、组装
|
|
256
286
|
if (!this.apiName) {
|
|
@@ -260,6 +290,9 @@ class _KObjectSync {
|
|
|
260
290
|
throw new server_common_node_1.exceptions.InvalidParamError('param records is not an array or an empty array');
|
|
261
291
|
}
|
|
262
292
|
recordMapList = permissionUtils.batchDelUnauthField(recordMapList).newRecords;
|
|
293
|
+
if (this.appCtx && this.appCtx.dataVersion === "v3") {
|
|
294
|
+
return await this.batchUpdateV3(recordMapList);
|
|
295
|
+
}
|
|
263
296
|
const recordIDs = [];
|
|
264
297
|
let recordMap = {};
|
|
265
298
|
for (let record of recordMapList) {
|
|
@@ -286,6 +319,25 @@ class _KObjectSync {
|
|
|
286
319
|
return (0, structs_1.NewBatchResult)(recordIDs, errMap);
|
|
287
320
|
}
|
|
288
321
|
;
|
|
322
|
+
async batchUpdateV3(recordMapList) {
|
|
323
|
+
const recordIDs = [];
|
|
324
|
+
let recordMap = {};
|
|
325
|
+
for (let record of recordMapList) {
|
|
326
|
+
let recordID;
|
|
327
|
+
if (typeof record._id === 'number') {
|
|
328
|
+
recordID = record._id.toString();
|
|
329
|
+
}
|
|
330
|
+
else if (typeof record._id === 'string') {
|
|
331
|
+
recordID = record._id;
|
|
332
|
+
}
|
|
333
|
+
if ((typeof recordID !== 'string') || recordID == "") {
|
|
334
|
+
throw new server_common_node_1.exceptions.InvalidParamError('record._id is empty');
|
|
335
|
+
}
|
|
336
|
+
recordIDs.push(recordID);
|
|
337
|
+
}
|
|
338
|
+
const errMap = await Request.GetInstance().updateRecordsV3BySync(this.apiName, recordMapList, this.authType);
|
|
339
|
+
return (0, structs_1.NewBatchResult)(recordIDs, errMap);
|
|
340
|
+
}
|
|
289
341
|
useUserAuth() {
|
|
290
342
|
this.authType = constants_1.AuthTypeUser;
|
|
291
343
|
return this;
|
|
@@ -607,7 +659,7 @@ class _KQuery {
|
|
|
607
659
|
criterion.conditions[criterion.conditions.length - 1].right.settings.data = maxId;
|
|
608
660
|
// 转换成 V3 的 criterion
|
|
609
661
|
const criterionV3 = (0, logic_1.convertCriterionToCriterionV3)(criterion);
|
|
610
|
-
rs = await Request.GetInstance().getRecordsV3OrCounByCriterion(apiName, criterionV3, queryBuilder.
|
|
662
|
+
rs = await Request.GetInstance().getRecordsV3OrCounByCriterion(apiName, criterionV3, queryBuilder.quickQuery, queryBuilder.quickQueryFields, [new order_1.Order('_id', 'asc')], queryBuilder.getSelect(), 0, newLimit, false, this.authType);
|
|
611
663
|
}
|
|
612
664
|
else {
|
|
613
665
|
// 更新 maxId
|
|
@@ -704,7 +756,7 @@ class _KQuery {
|
|
|
704
756
|
criterion.conditions[criterion.conditions.length - 1].right.settings.data = maxId;
|
|
705
757
|
// 转换成 V3 的 criterion
|
|
706
758
|
const criterionV3 = (0, logic_1.convertCriterionToCriterionV3)(criterion);
|
|
707
|
-
rs = await Request.GetInstance().getRecordsV3OrCounByCriterion(apiName, criterionV3, queryBuilder.
|
|
759
|
+
rs = await Request.GetInstance().getRecordsV3OrCounByCriterion(apiName, criterionV3, queryBuilder.quickQuery, queryBuilder.quickQueryFields, orders, selectFields, curOffset, newLimit, false, this.authType);
|
|
708
760
|
}
|
|
709
761
|
else {
|
|
710
762
|
// 更新 maxId
|
|
@@ -843,6 +895,8 @@ class _KQuery {
|
|
|
843
895
|
keyword: keyword,
|
|
844
896
|
fieldAPINames: fieldAPINames,
|
|
845
897
|
};
|
|
898
|
+
queryBuilder.quickQuery = keyword;
|
|
899
|
+
queryBuilder.quickQueryFields = fieldAPINames;
|
|
846
900
|
return this;
|
|
847
901
|
}
|
|
848
902
|
limit(limit) {
|
|
@@ -898,14 +952,14 @@ class _KQuery {
|
|
|
898
952
|
}
|
|
899
953
|
;
|
|
900
954
|
async findV3(needCount) {
|
|
901
|
-
const { apiName,
|
|
955
|
+
const { apiName, queryBuilder } = queryPropertiesStore.get(this);
|
|
902
956
|
let criterion = (0, logic_1.buildCriterion)(queryBuilder.getLogic(), apiName);
|
|
903
957
|
if (queryBuilder.getLogic().logics.length > 0) {
|
|
904
958
|
// console.log("test-----------------------", queryBuilder.getLogic().logics)
|
|
905
959
|
criterion = await (0, logic_1.handleCriterion)(criterion);
|
|
906
960
|
}
|
|
907
961
|
const criterionV3 = (0, logic_1.convertCriterionToCriterionV3)(criterion);
|
|
908
|
-
const res = await Request.GetInstance().getRecordsV3OrCounByCriterion(apiName, criterionV3, queryBuilder.
|
|
962
|
+
const res = await Request.GetInstance().getRecordsV3OrCounByCriterion(apiName, criterionV3, queryBuilder.quickQuery, queryBuilder.quickQueryFields, queryBuilder.getOrder(), queryBuilder.getSelect(), queryBuilder.getOffset(), queryBuilder.getLimit(), needCount, this.authType);
|
|
909
963
|
if (needCount) {
|
|
910
964
|
return res;
|
|
911
965
|
}
|
|
@@ -6,6 +6,7 @@ exports.metadataV3 = exports.MetaDataV3 = exports.metaType = exports.metadata =
|
|
|
6
6
|
const components = require("./components/components");
|
|
7
7
|
const common = require("@byted-apaas/server-common-node");
|
|
8
8
|
const fields = require("./objects/fields");
|
|
9
|
+
const fieldsV3 = require("./objects/fieldsV3");
|
|
9
10
|
const Request = require("../../request/interface");
|
|
10
11
|
const commonExceptions = common.exceptions;
|
|
11
12
|
// interface ---------------------------------------------------------------------------------------
|
|
@@ -43,7 +44,10 @@ class MetaDataV3 {
|
|
|
43
44
|
if (!objectApiName) {
|
|
44
45
|
throw new commonExceptions.InvalidParamError('objectApiName is empty');
|
|
45
46
|
}
|
|
46
|
-
|
|
47
|
+
const appCtx = {
|
|
48
|
+
dataVersion: "v3",
|
|
49
|
+
};
|
|
50
|
+
return new KObject(objectApiName, appCtx);
|
|
47
51
|
}
|
|
48
52
|
page(apiName, objectApiName, type) {
|
|
49
53
|
if (!apiName) {
|
|
@@ -60,19 +64,26 @@ class MetaDataV3 {
|
|
|
60
64
|
}
|
|
61
65
|
exports.MetaDataV3 = MetaDataV3;
|
|
62
66
|
function metadataV3(ctx) {
|
|
63
|
-
return new
|
|
67
|
+
return new MetaDataV3(ctx);
|
|
64
68
|
}
|
|
65
69
|
exports.metadataV3 = metadataV3;
|
|
66
70
|
class KObject {
|
|
67
|
-
constructor(objectApiName) {
|
|
71
|
+
constructor(objectApiName, appCtx) {
|
|
68
72
|
this.objectApiName = objectApiName;
|
|
73
|
+
this.appCtx = appCtx;
|
|
69
74
|
}
|
|
70
75
|
async getFields() {
|
|
71
76
|
let res = await Request.GetInstance().getFields(this.objectApiName);
|
|
77
|
+
if (this.appCtx && this.appCtx.dataVersion === "v3") {
|
|
78
|
+
return fieldsV3.parseFieldsV3(res);
|
|
79
|
+
}
|
|
72
80
|
return fields.parseFields(res);
|
|
73
81
|
}
|
|
74
82
|
async getField(fieldApiName) {
|
|
75
83
|
let res = await Request.GetInstance().getField(this.objectApiName, fieldApiName);
|
|
84
|
+
if (this.appCtx && this.appCtx.dataVersion === "v3") {
|
|
85
|
+
return fieldsV3.parseFieldV3(res);
|
|
86
|
+
}
|
|
76
87
|
return fields.parseField(res);
|
|
77
88
|
}
|
|
78
89
|
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { BaseFieldType, CriterionType, FieldType, FilterType, RegionFilterType, SortConditionType, SubOptionType } from '../types/objects';
|
|
2
|
+
import { I18ns, MultilingualTypeV3 } from '../types/common';
|
|
3
|
+
declare class MetadataFieldV3 {
|
|
4
|
+
type: string;
|
|
5
|
+
apiName: string;
|
|
6
|
+
label: MultilingualTypeV3;
|
|
7
|
+
constructor(type: string, field: FieldType);
|
|
8
|
+
}
|
|
9
|
+
declare class KTextV3 extends MetadataFieldV3 {
|
|
10
|
+
required: boolean;
|
|
11
|
+
unique: boolean;
|
|
12
|
+
caseSensitive: boolean;
|
|
13
|
+
multiline: boolean;
|
|
14
|
+
maxLength: number;
|
|
15
|
+
validationRegex: string;
|
|
16
|
+
errorMsg: MultilingualTypeV3;
|
|
17
|
+
constructor(field: FieldType);
|
|
18
|
+
}
|
|
19
|
+
declare class RichTextV3 extends MetadataFieldV3 {
|
|
20
|
+
maxLength: number;
|
|
21
|
+
required: boolean;
|
|
22
|
+
constructor(field: FieldType);
|
|
23
|
+
}
|
|
24
|
+
declare class MultilingualV3 extends MetadataFieldV3 {
|
|
25
|
+
required: boolean;
|
|
26
|
+
unique: boolean;
|
|
27
|
+
caseSensitive: boolean;
|
|
28
|
+
multiline: boolean;
|
|
29
|
+
maxLength: number;
|
|
30
|
+
constructor(field: FieldType);
|
|
31
|
+
}
|
|
32
|
+
declare class NumberV3 extends MetadataFieldV3 {
|
|
33
|
+
required: boolean;
|
|
34
|
+
unique: boolean;
|
|
35
|
+
displayAsPercentage: boolean;
|
|
36
|
+
decimalPlacesNumber: number;
|
|
37
|
+
constructor(field: FieldType);
|
|
38
|
+
}
|
|
39
|
+
declare class BigintV3 extends MetadataFieldV3 {
|
|
40
|
+
required: boolean;
|
|
41
|
+
unique: boolean;
|
|
42
|
+
constructor(field: FieldType);
|
|
43
|
+
}
|
|
44
|
+
declare class DecimalV3 extends MetadataFieldV3 {
|
|
45
|
+
required: boolean;
|
|
46
|
+
unique: boolean;
|
|
47
|
+
displayAsPercentage: boolean;
|
|
48
|
+
decimalPlacesNumber: number;
|
|
49
|
+
constructor(field: FieldType);
|
|
50
|
+
}
|
|
51
|
+
declare class KDateV3 extends MetadataFieldV3 {
|
|
52
|
+
required: boolean;
|
|
53
|
+
constructor(field: FieldType);
|
|
54
|
+
}
|
|
55
|
+
declare class DateTimeV3 extends MetadataFieldV3 {
|
|
56
|
+
required: boolean;
|
|
57
|
+
constructor(field: FieldType);
|
|
58
|
+
}
|
|
59
|
+
declare class OptionV3 extends MetadataFieldV3 {
|
|
60
|
+
required: boolean;
|
|
61
|
+
multiple: boolean;
|
|
62
|
+
optionSource: ('custom' | 'global');
|
|
63
|
+
globalOptionApiName: string;
|
|
64
|
+
optionList: SubOptionType[];
|
|
65
|
+
constructor(field: FieldType);
|
|
66
|
+
}
|
|
67
|
+
declare class EmailV3 extends MetadataFieldV3 {
|
|
68
|
+
required: boolean;
|
|
69
|
+
unique: boolean;
|
|
70
|
+
constructor(field: FieldType);
|
|
71
|
+
}
|
|
72
|
+
declare class MobileNumberV3 extends MetadataFieldV3 {
|
|
73
|
+
required: boolean;
|
|
74
|
+
unique: boolean;
|
|
75
|
+
constructor(field: FieldType);
|
|
76
|
+
}
|
|
77
|
+
declare class BooleanV3 extends MetadataFieldV3 {
|
|
78
|
+
descriptionWhenTrue: I18ns;
|
|
79
|
+
descriptionWhenFalse: I18ns;
|
|
80
|
+
defaultValue: boolean;
|
|
81
|
+
unique: boolean;
|
|
82
|
+
constructor(field: FieldType);
|
|
83
|
+
}
|
|
84
|
+
declare class AvatarOrLogoV3 extends MetadataFieldV3 {
|
|
85
|
+
displayStyle: ('square' | 'round');
|
|
86
|
+
constructor(field: FieldType);
|
|
87
|
+
}
|
|
88
|
+
declare class LookupV3 extends MetadataFieldV3 {
|
|
89
|
+
required: boolean;
|
|
90
|
+
multiple: boolean;
|
|
91
|
+
objectApiName: string;
|
|
92
|
+
hierarchy: boolean;
|
|
93
|
+
displayStyle: ('search' | 'dropDown' | 'tree');
|
|
94
|
+
sortConditions: SortConditionType[];
|
|
95
|
+
filter: FilterType[];
|
|
96
|
+
constructor(field: FieldType);
|
|
97
|
+
}
|
|
98
|
+
declare class FormulaV3 extends MetadataFieldV3 {
|
|
99
|
+
returnType: string;
|
|
100
|
+
formula: MultilingualTypeV3;
|
|
101
|
+
constructor(field: FieldType);
|
|
102
|
+
}
|
|
103
|
+
declare class AutoIDV3 extends MetadataFieldV3 {
|
|
104
|
+
generateMethod: ('random' | 'incremental');
|
|
105
|
+
digitsNumber: number;
|
|
106
|
+
prefix: string;
|
|
107
|
+
suffix: string;
|
|
108
|
+
constructor(field: FieldType);
|
|
109
|
+
}
|
|
110
|
+
declare class ReferenceFieldV3 extends MetadataFieldV3 {
|
|
111
|
+
guideFieldApiName: string;
|
|
112
|
+
fieldApiName: string;
|
|
113
|
+
constructor(field: FieldType);
|
|
114
|
+
}
|
|
115
|
+
declare class RollupV3 extends MetadataFieldV3 {
|
|
116
|
+
rollupType: string;
|
|
117
|
+
rollupObjectApiName: string;
|
|
118
|
+
rollupFieldApiName: string;
|
|
119
|
+
rollupLookupFieldApiName: string;
|
|
120
|
+
filter: CriterionType;
|
|
121
|
+
constructor(field: FieldType);
|
|
122
|
+
}
|
|
123
|
+
declare class RegionV3 extends MetadataFieldV3 {
|
|
124
|
+
required: boolean;
|
|
125
|
+
multiple: boolean;
|
|
126
|
+
optionLevel: boolean;
|
|
127
|
+
strictLevel: number;
|
|
128
|
+
filter: RegionFilterType[];
|
|
129
|
+
constructor(field: FieldType);
|
|
130
|
+
}
|
|
131
|
+
declare class FileV3 extends MetadataFieldV3 {
|
|
132
|
+
required: boolean;
|
|
133
|
+
multiple: boolean;
|
|
134
|
+
fileTypes: string[];
|
|
135
|
+
constructor(field: FieldType);
|
|
136
|
+
}
|
|
137
|
+
declare class BackLookupV3 extends MetadataFieldV3 {
|
|
138
|
+
constructor(field: FieldType);
|
|
139
|
+
}
|
|
140
|
+
declare class CompositeTypeV3 extends MetadataFieldV3 {
|
|
141
|
+
compositeTypeApiName: string;
|
|
142
|
+
subFields: BaseFieldType[];
|
|
143
|
+
required: boolean;
|
|
144
|
+
multiple: boolean;
|
|
145
|
+
constructor(field: FieldType);
|
|
146
|
+
}
|
|
147
|
+
declare class ExtractSingleRecordV3 extends MetadataFieldV3 {
|
|
148
|
+
compositeTypeApiName: string;
|
|
149
|
+
subFields: BaseFieldType[];
|
|
150
|
+
filter: FilterType[];
|
|
151
|
+
sortConditions: SortConditionType[];
|
|
152
|
+
recordPosition: number;
|
|
153
|
+
constructor(field: FieldType);
|
|
154
|
+
}
|
|
155
|
+
declare function parseFieldsV3(inputFields: Record<string, any>): BaseFieldType[];
|
|
156
|
+
declare function parseFieldV3(field: FieldType): BaseFieldType;
|
|
157
|
+
declare function getFieldClassV3(field: FieldType): any;
|
|
158
|
+
export { KTextV3 as TextV3, MultilingualV3, NumberV3, KDateV3 as DateV3, DateTimeV3, OptionV3, EmailV3, MobileNumberV3, BooleanV3, AvatarOrLogoV3, LookupV3, FormulaV3, AutoIDV3, ReferenceFieldV3, FileV3, BackLookupV3, CompositeTypeV3, ExtractSingleRecordV3, RichTextV3, BigintV3, DecimalV3, RegionV3, RollupV3, parseFieldsV3, parseFieldV3, getFieldClassV3, };
|
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2022 ByteDance Ltd. and/or its affiliates
|
|
3
|
+
// SPDX-License-Identifier: MIT
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.getFieldClassV3 = exports.parseFieldV3 = exports.parseFieldsV3 = exports.RollupV3 = exports.RegionV3 = exports.DecimalV3 = exports.BigintV3 = exports.RichTextV3 = exports.ExtractSingleRecordV3 = exports.CompositeTypeV3 = exports.BackLookupV3 = exports.FileV3 = exports.ReferenceFieldV3 = exports.AutoIDV3 = exports.FormulaV3 = exports.LookupV3 = exports.AvatarOrLogoV3 = exports.BooleanV3 = exports.MobileNumberV3 = exports.EmailV3 = exports.OptionV3 = exports.DateTimeV3 = exports.DateV3 = exports.NumberV3 = exports.MultilingualV3 = exports.TextV3 = void 0;
|
|
6
|
+
const fieldsUtil = require("./fields.util");
|
|
7
|
+
const common_1 = require("../types/common");
|
|
8
|
+
class MetadataFieldV3 {
|
|
9
|
+
constructor(type, field) {
|
|
10
|
+
this.type = type;
|
|
11
|
+
this.apiName = field.api_name;
|
|
12
|
+
this.label = (0, common_1.transI18nsToMultilingualV3)(field.label);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
class KTextV3 extends MetadataFieldV3 {
|
|
16
|
+
constructor(field) {
|
|
17
|
+
if (!field) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
super('text', field);
|
|
21
|
+
this.required = field.required;
|
|
22
|
+
this.unique = fieldsUtil.getUnique(field);
|
|
23
|
+
this.caseSensitive = fieldsUtil.getCaseSensitive(field);
|
|
24
|
+
this.multiline = fieldsUtil.getMultiline(field);
|
|
25
|
+
this.maxLength = fieldsUtil.getMaxLength(field);
|
|
26
|
+
this.validationRegex = fieldsUtil.getRegexpExpression(field);
|
|
27
|
+
this.errorMsg = (0, common_1.transI18nsToMultilingualV3)(fieldsUtil.getRegexpErrMsg(field));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.TextV3 = KTextV3;
|
|
31
|
+
class RichTextV3 extends MetadataFieldV3 {
|
|
32
|
+
constructor(field) {
|
|
33
|
+
if (!field) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
super('richText', field);
|
|
37
|
+
this.maxLength = fieldsUtil.getMaxLength(field);
|
|
38
|
+
this.required = field.required;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.RichTextV3 = RichTextV3;
|
|
42
|
+
class MultilingualV3 extends MetadataFieldV3 {
|
|
43
|
+
constructor(field) {
|
|
44
|
+
if (!field) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
super('multilingual', field);
|
|
48
|
+
this.required = field.required;
|
|
49
|
+
this.unique = fieldsUtil.getUnique(field);
|
|
50
|
+
this.caseSensitive = fieldsUtil.getCaseSensitive(field);
|
|
51
|
+
this.multiline = fieldsUtil.getMultiline(field);
|
|
52
|
+
this.maxLength = fieldsUtil.getMaxLength(field);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.MultilingualV3 = MultilingualV3;
|
|
56
|
+
class NumberV3 extends MetadataFieldV3 {
|
|
57
|
+
constructor(field) {
|
|
58
|
+
if (!field) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
super('number', field);
|
|
62
|
+
this.required = field.required;
|
|
63
|
+
this.unique = fieldsUtil.getUnique(field);
|
|
64
|
+
this.displayAsPercentage = fieldsUtil.getDisplayAsPercentage(field);
|
|
65
|
+
this.decimalPlacesNumber = fieldsUtil.getDecimalPlaces(field);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.NumberV3 = NumberV3;
|
|
69
|
+
class BigintV3 extends MetadataFieldV3 {
|
|
70
|
+
constructor(field) {
|
|
71
|
+
if (!field) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
super('bigint', field);
|
|
75
|
+
this.required = field.required;
|
|
76
|
+
this.unique = fieldsUtil.getUnique(field);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports.BigintV3 = BigintV3;
|
|
80
|
+
class DecimalV3 extends MetadataFieldV3 {
|
|
81
|
+
constructor(field) {
|
|
82
|
+
if (!field) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
super('decimal', field);
|
|
86
|
+
this.required = field.required;
|
|
87
|
+
this.unique = fieldsUtil.getUnique(field);
|
|
88
|
+
this.displayAsPercentage = fieldsUtil.getDisplayAsPercentage(field);
|
|
89
|
+
this.decimalPlacesNumber = fieldsUtil.getDecimalPlaces(field);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.DecimalV3 = DecimalV3;
|
|
93
|
+
class KDateV3 extends MetadataFieldV3 {
|
|
94
|
+
constructor(field) {
|
|
95
|
+
if (!field) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
super('date', field);
|
|
99
|
+
this.required = field.required;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.DateV3 = KDateV3;
|
|
103
|
+
class DateTimeV3 extends MetadataFieldV3 {
|
|
104
|
+
constructor(field) {
|
|
105
|
+
if (!field) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
super('dateTime', field);
|
|
109
|
+
this.required = field.required;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
exports.DateTimeV3 = DateTimeV3;
|
|
113
|
+
class OptionV3 extends MetadataFieldV3 {
|
|
114
|
+
constructor(field) {
|
|
115
|
+
if (!field) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
super('option', field);
|
|
119
|
+
this.required = field.required;
|
|
120
|
+
this.multiple = fieldsUtil.getMultiple(field);
|
|
121
|
+
this.optionSource = fieldsUtil.getOptionSource(field);
|
|
122
|
+
this.globalOptionApiName = fieldsUtil.getGlobalOptionApiName(field);
|
|
123
|
+
this.optionList = fieldsUtil.getOptionList(field);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
exports.OptionV3 = OptionV3;
|
|
127
|
+
class EmailV3 extends MetadataFieldV3 {
|
|
128
|
+
constructor(field) {
|
|
129
|
+
if (!field) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
super('email', field);
|
|
133
|
+
this.required = field.required;
|
|
134
|
+
this.unique = fieldsUtil.getUnique(field);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
exports.EmailV3 = EmailV3;
|
|
138
|
+
class MobileNumberV3 extends MetadataFieldV3 {
|
|
139
|
+
constructor(field) {
|
|
140
|
+
if (!field) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
super('mobileNumber', field);
|
|
144
|
+
this.required = field.required;
|
|
145
|
+
this.unique = fieldsUtil.getUnique(field);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
exports.MobileNumberV3 = MobileNumberV3;
|
|
149
|
+
class BooleanV3 extends MetadataFieldV3 {
|
|
150
|
+
constructor(field) {
|
|
151
|
+
if (!field) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
super('boolean', field);
|
|
155
|
+
this.unique = fieldsUtil.getUnique(field);
|
|
156
|
+
this.descriptionWhenTrue = fieldsUtil.getDescriptionWhenTrue(field);
|
|
157
|
+
this.descriptionWhenFalse = fieldsUtil.getDescriptionWhenFalse(field);
|
|
158
|
+
this.defaultValue = fieldsUtil.getDefaultValue(field);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
exports.BooleanV3 = BooleanV3;
|
|
162
|
+
class AvatarOrLogoV3 extends MetadataFieldV3 {
|
|
163
|
+
constructor(field) {
|
|
164
|
+
if (!field) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
super('avatarOrLogo', field);
|
|
168
|
+
this.displayStyle = fieldsUtil.getDisplayStyle(field);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
exports.AvatarOrLogoV3 = AvatarOrLogoV3;
|
|
172
|
+
class LookupV3 extends MetadataFieldV3 {
|
|
173
|
+
constructor(field) {
|
|
174
|
+
if (!field) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
super('lookup', field);
|
|
178
|
+
this.required = field.required;
|
|
179
|
+
this.multiple = fieldsUtil.getMultiple(field);
|
|
180
|
+
this.objectApiName = fieldsUtil.getLookupRefObjectApiName(field);
|
|
181
|
+
this.hierarchy = fieldsUtil.getLookupIsHierarchy(field);
|
|
182
|
+
this.displayStyle = fieldsUtil.getLookupDisplayStyle(field);
|
|
183
|
+
// TODO
|
|
184
|
+
this.sortConditions = fieldsUtil.getSettingsSort(field);
|
|
185
|
+
this.filter = [];
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
exports.LookupV3 = LookupV3;
|
|
189
|
+
class FormulaV3 extends MetadataFieldV3 {
|
|
190
|
+
constructor(field) {
|
|
191
|
+
if (!field) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
super('formula', field);
|
|
195
|
+
this.returnType = fieldsUtil.getReturnType(field);
|
|
196
|
+
// TODO 由于下游提供仍是 api ID 版本,因此禁用
|
|
197
|
+
this.formula = null; //fieldsUtil.getFormula(field);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
exports.FormulaV3 = FormulaV3;
|
|
201
|
+
class AutoIDV3 extends MetadataFieldV3 {
|
|
202
|
+
constructor(field) {
|
|
203
|
+
if (!field) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
super('autoId', field);
|
|
207
|
+
this.generateMethod = fieldsUtil.getGenerateMethod(field);
|
|
208
|
+
this.digitsNumber = fieldsUtil.getDigitsNumber(field);
|
|
209
|
+
this.prefix = fieldsUtil.getPrefix(field);
|
|
210
|
+
this.suffix = fieldsUtil.getSuffix(field);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
exports.AutoIDV3 = AutoIDV3;
|
|
214
|
+
class ReferenceFieldV3 extends MetadataFieldV3 {
|
|
215
|
+
constructor(field) {
|
|
216
|
+
if (!field) {
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
super('referenceField', field);
|
|
220
|
+
// TODO: check objectApiName to guideFieldApiName
|
|
221
|
+
this.guideFieldApiName = fieldsUtil.getReferenceObjectApiName(field);
|
|
222
|
+
this.fieldApiName = fieldsUtil.getReferenceFieldApiName(field);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
exports.ReferenceFieldV3 = ReferenceFieldV3;
|
|
226
|
+
class RollupV3 extends MetadataFieldV3 {
|
|
227
|
+
constructor(field) {
|
|
228
|
+
if (!field) {
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
super('rollup', field);
|
|
232
|
+
this.rollupType = fieldsUtil.getRollupType(field);
|
|
233
|
+
this.rollupObjectApiName = fieldsUtil.getRollupObjectApiName(field);
|
|
234
|
+
this.rollupFieldApiName = fieldsUtil.getRollupFieldApiName(field);
|
|
235
|
+
this.rollupLookupFieldApiName = fieldsUtil.getRollupLookupFieldApiName(field);
|
|
236
|
+
this.filter = fieldsUtil.getRollupFilter(field);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
exports.RollupV3 = RollupV3;
|
|
240
|
+
class RegionV3 extends MetadataFieldV3 {
|
|
241
|
+
constructor(field) {
|
|
242
|
+
if (!field) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
super('region', field);
|
|
246
|
+
this.required = field.required;
|
|
247
|
+
this.multiple = fieldsUtil.getSettingsMultiple(field);
|
|
248
|
+
this.optionLevel = fieldsUtil.getRegionOptionLevel(field);
|
|
249
|
+
this.strictLevel = fieldsUtil.getRegionStrictLeve(field);
|
|
250
|
+
this.filter = fieldsUtil.getRegionSettingsFilter(field);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
exports.RegionV3 = RegionV3;
|
|
254
|
+
class FileV3 extends MetadataFieldV3 {
|
|
255
|
+
constructor(field) {
|
|
256
|
+
if (!field) {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
super('file', field);
|
|
260
|
+
this.required = field.required;
|
|
261
|
+
this.multiple = fieldsUtil.getFileMultiple(field);
|
|
262
|
+
this.fileTypes = fieldsUtil.getFileTypes(field);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
exports.FileV3 = FileV3;
|
|
266
|
+
class BackLookupV3 extends MetadataFieldV3 {
|
|
267
|
+
// objectApiName: string; // TODO 由于下游提供仍是 api ID 版本,因此禁用
|
|
268
|
+
// fieldApiName: string; // 由于下游提供仍是 api ID 版本,因此禁用
|
|
269
|
+
constructor(field) {
|
|
270
|
+
if (!field) {
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
super('backLookup', field);
|
|
274
|
+
// TODO 由于下游提供仍是 api ID 版本,因此禁用
|
|
275
|
+
// this.objectApiName = fieldsUtil.getBackLookupObjectApiName(field);
|
|
276
|
+
// this.fieldApiName = fieldsUtil.getBackLookupFieldApiName(field); // TODO metadata返回值为空
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
exports.BackLookupV3 = BackLookupV3;
|
|
280
|
+
class CompositeTypeV3 extends MetadataFieldV3 {
|
|
281
|
+
constructor(field) {
|
|
282
|
+
if (!field) {
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
super('compositeType', field);
|
|
286
|
+
this.required = field.required;
|
|
287
|
+
this.multiple = fieldsUtil.getSettingsMultiple(field);
|
|
288
|
+
this.compositeTypeApiName = fieldsUtil.getCompositeTypeApiName(field);
|
|
289
|
+
// TODO 字段类型转换
|
|
290
|
+
this.subFields = parseFieldsV3(fieldsUtil.getCompositeTypeSubFields(field));
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
exports.CompositeTypeV3 = CompositeTypeV3;
|
|
294
|
+
class ExtractSingleRecordV3 extends MetadataFieldV3 {
|
|
295
|
+
constructor(field) {
|
|
296
|
+
if (!field) {
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
super('extractSingleRecord', field);
|
|
300
|
+
this.compositeTypeApiName = fieldsUtil.getCompositeTypeApiName(field);
|
|
301
|
+
// TODO 字段类型转换
|
|
302
|
+
this.subFields = parseFieldsV3(fieldsUtil.getCompositeTypeSubFields(field));
|
|
303
|
+
this.filter = fieldsUtil.getSettingsFilter(field);
|
|
304
|
+
this.sortConditions = fieldsUtil.getSettingsSort(field);
|
|
305
|
+
this.recordPosition = fieldsUtil.getRecordPosition(field);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
exports.ExtractSingleRecordV3 = ExtractSingleRecordV3;
|
|
309
|
+
function getCompositeTypeClass(field) {
|
|
310
|
+
if (field && field.type && field.type.settings && field.type.settings.is_extract) {
|
|
311
|
+
return ExtractSingleRecordV3;
|
|
312
|
+
}
|
|
313
|
+
return CompositeTypeV3;
|
|
314
|
+
}
|
|
315
|
+
function parseFieldsV3(inputFields) {
|
|
316
|
+
if (!inputFields || !Array.isArray(inputFields)) {
|
|
317
|
+
return [];
|
|
318
|
+
}
|
|
319
|
+
let fields = [];
|
|
320
|
+
for (let field of inputFields) {
|
|
321
|
+
let FieldClass = getFieldClassV3(field);
|
|
322
|
+
if (!FieldClass) {
|
|
323
|
+
continue;
|
|
324
|
+
}
|
|
325
|
+
fields.push(new FieldClass(field));
|
|
326
|
+
}
|
|
327
|
+
return fields;
|
|
328
|
+
}
|
|
329
|
+
exports.parseFieldsV3 = parseFieldsV3;
|
|
330
|
+
function parseFieldV3(field) {
|
|
331
|
+
let FieldClass = getFieldClassV3(field);
|
|
332
|
+
if (FieldClass) {
|
|
333
|
+
return new FieldClass(field);
|
|
334
|
+
}
|
|
335
|
+
return null;
|
|
336
|
+
}
|
|
337
|
+
exports.parseFieldV3 = parseFieldV3;
|
|
338
|
+
function getFieldClassV3(field) {
|
|
339
|
+
if (field && field.type && field.type.name) {
|
|
340
|
+
if (field.type.name === 'compositeType') {
|
|
341
|
+
return getCompositeTypeClass(field);
|
|
342
|
+
}
|
|
343
|
+
return type2fieldTypeV3[field.type.name];
|
|
344
|
+
}
|
|
345
|
+
return null;
|
|
346
|
+
}
|
|
347
|
+
exports.getFieldClassV3 = getFieldClassV3;
|
|
348
|
+
const type2fieldTypeV3 = {
|
|
349
|
+
'text': KTextV3,
|
|
350
|
+
'multilingual': MultilingualV3,
|
|
351
|
+
'float': NumberV3,
|
|
352
|
+
'date': KDateV3,
|
|
353
|
+
'datetime': DateTimeV3,
|
|
354
|
+
'enum': OptionV3,
|
|
355
|
+
'email': EmailV3,
|
|
356
|
+
'phone': MobileNumberV3,
|
|
357
|
+
'boolean': BooleanV3,
|
|
358
|
+
'avatar': AvatarOrLogoV3,
|
|
359
|
+
'lookup': LookupV3,
|
|
360
|
+
'formula': FormulaV3,
|
|
361
|
+
'auto_number': AutoIDV3,
|
|
362
|
+
'reference_field': ReferenceFieldV3,
|
|
363
|
+
'attachment': FileV3,
|
|
364
|
+
'back_lookup': BackLookupV3,
|
|
365
|
+
'richText': RichTextV3,
|
|
366
|
+
'bigint': BigintV3,
|
|
367
|
+
'decimal': DecimalV3,
|
|
368
|
+
'rollup': RollupV3,
|
|
369
|
+
'region': RegionV3,
|
|
370
|
+
};
|
|
@@ -4,3 +4,8 @@ export type I18n = {
|
|
|
4
4
|
};
|
|
5
5
|
export type I18ns = I18n[];
|
|
6
6
|
export declare function isNullOrUndefined(param: any): boolean;
|
|
7
|
+
export declare function transI18nsToMultilingualV3(i18ns: I18ns): MultilingualTypeV3;
|
|
8
|
+
export type MultilingualTypeV3 = {
|
|
9
|
+
zh_CN: string;
|
|
10
|
+
en_US: string;
|
|
11
|
+
};
|
|
@@ -2,8 +2,32 @@
|
|
|
2
2
|
// Copyright 2022 ByteDance Ltd. and/or its affiliates
|
|
3
3
|
// SPDX-License-Identifier: MIT
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.isNullOrUndefined = void 0;
|
|
5
|
+
exports.transI18nsToMultilingualV3 = exports.isNullOrUndefined = void 0;
|
|
6
6
|
function isNullOrUndefined(param) {
|
|
7
7
|
return param === null || param === undefined;
|
|
8
8
|
}
|
|
9
9
|
exports.isNullOrUndefined = isNullOrUndefined;
|
|
10
|
+
function transI18nsToMultilingualV3(i18ns) {
|
|
11
|
+
if (i18ns === null || i18ns === undefined) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
let multilingual = { zh_CN: "", en_US: "" };
|
|
15
|
+
for (const i18n of i18ns) {
|
|
16
|
+
switch (i18n.language_code) {
|
|
17
|
+
case languageCode.zh_CN:
|
|
18
|
+
multilingual.zh_CN = i18n.text;
|
|
19
|
+
break;
|
|
20
|
+
case languageCode.en_US:
|
|
21
|
+
multilingual.en_US = i18n.text;
|
|
22
|
+
break;
|
|
23
|
+
default:
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return multilingual;
|
|
28
|
+
}
|
|
29
|
+
exports.transI18nsToMultilingualV3 = transI18nsToMultilingualV3;
|
|
30
|
+
const languageCode = {
|
|
31
|
+
zh_CN: 2052,
|
|
32
|
+
en_US: 1033
|
|
33
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@byted-apaas/server-sdk-node",
|
|
3
|
-
"version": "1.1.18-beta.
|
|
3
|
+
"version": "1.1.18-beta.7",
|
|
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.
|
|
16
|
+
"@byted-apaas/server-common-node": "2.0.12-beta.4",
|
|
17
17
|
"@jorgeferrero/stream-to-buffer": "^2.0.6",
|
|
18
18
|
"dayjs": "^1.9.6",
|
|
19
19
|
"form-data": "^3.0.0",
|
package/request/interface.d.ts
CHANGED
|
@@ -55,9 +55,11 @@ export interface IInnerAPIBaseRequest {
|
|
|
55
55
|
createRecordsBySync: (objectApiName: string, records: object[], authType: string) => any;
|
|
56
56
|
createRecordsV3BySync: (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
59
|
deleteRecordsBySync: (objectApiName: string, recordIDs: number[], authType: string) => Promise<Record<number, string>>;
|
|
60
|
+
deleteRecordsV3BySync: (objectApiName: string, recordIDs: string[], authType: string) => Promise<Record<string, string>>;
|
|
59
61
|
getRecordsOrCountByCriterion: (objectApiName: string, criterion: string | Criterion, fuzzySearch: any, order: Order[], ignoreBackLookupField: boolean, fieldApiNames: string[], offset: number, limit: number, needCount: boolean, authType: string) => any;
|
|
60
|
-
getRecordsV3OrCounByCriterion: (objectApiName: string, criterion: string | CriterionV3,
|
|
62
|
+
getRecordsV3OrCounByCriterion: (objectApiName: string, criterion: string | CriterionV3, quickQuery: string, quickQueryFields: string[], order: Order[], fieldApiNames: string[], offset: number, limit: number, needCount: boolean, authType: string) => any;
|
|
61
63
|
updateWorkflowVariables: (ctx: any, instanceId: number, variables: object, variableTypes: object) => Promise<void>;
|
|
62
64
|
uploadFile: (data: Stream, expire: number, fileName?: string) => Promise<UploadFileResp>;
|
|
63
65
|
downloadFileByID: (fileID: string, filePath?: string) => Promise<Buffer | undefined>;
|
package/request/openapi.d.ts
CHANGED
|
@@ -25,9 +25,9 @@ export declare class RequestHttp implements IInnerAPIRequest {
|
|
|
25
25
|
updateRecordsBySync(objectApiName: string, recordMap: Record<number, object>, authType: string): Promise<Record<number, string>>;
|
|
26
26
|
updateRecordsV3BySync(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:
|
|
28
|
+
deleteRecordsV3BySync(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
|
-
getRecordsV3OrCounByCriterion(objectApiName: string, criterion: string | CriterionV3,
|
|
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>;
|
|
32
32
|
downloadFileByID(fileID: string, filePath?: string): Promise<undefined | Buffer>;
|
|
33
33
|
downloadFileByToken(fileToken: string, filePath?: string): Promise<Buffer | undefined>;
|
package/request/openapi.js
CHANGED
|
@@ -345,7 +345,7 @@ async function updateRecordsV3BySync(objectApiName, records, authType) {
|
|
|
345
345
|
// todo wby 待确认返回值
|
|
346
346
|
const errMap = {};
|
|
347
347
|
for (let recordID of Object.keys(resp.err_map)) {
|
|
348
|
-
errMap[
|
|
348
|
+
errMap[String(recordID)] = resp.err_map[recordID];
|
|
349
349
|
}
|
|
350
350
|
return errMap;
|
|
351
351
|
}
|
|
@@ -470,7 +470,7 @@ async function getRecordsOrCountByCriterion(objectApiName, criterion, fuzzySearc
|
|
|
470
470
|
let data = await openapi.doRequest(null, urlPath, options);
|
|
471
471
|
return handleResponse(objectApiName, data, needCount);
|
|
472
472
|
}
|
|
473
|
-
async function getRecordsV3OrCountByCriterion(objectApiName, criterion,
|
|
473
|
+
async function getRecordsV3OrCountByCriterion(objectApiName, criterion, quickQuery, quickQueryFields, order, fieldApiNames, offset, limit, needCount, authType) {
|
|
474
474
|
// 1.check
|
|
475
475
|
if (!objectApiName) {
|
|
476
476
|
throw new exceptions.InternalError('objectApiName is empty');
|
|
@@ -493,6 +493,8 @@ async function getRecordsV3OrCountByCriterion(objectApiName, criterion, order, f
|
|
|
493
493
|
'order_by': order,
|
|
494
494
|
'need_total_count': needCount,
|
|
495
495
|
'filter': criterion,
|
|
496
|
+
'quick_query': quickQuery,
|
|
497
|
+
'quick_query_fields': quickQueryFields,
|
|
496
498
|
// fuzzySearch, // todo wby
|
|
497
499
|
// 只返回 slice 结果,使用 SliceResult
|
|
498
500
|
// 只返回 map 结果,使用 MapResult
|
|
@@ -1049,7 +1051,7 @@ class RequestHttp {
|
|
|
1049
1051
|
}
|
|
1050
1052
|
getRecordsOrCountByCriterion(objectApiName, criterion, order, fuzzySearch, ignoreBackLookupField, fieldApiNames, offset, limit, needCount, authType) {
|
|
1051
1053
|
}
|
|
1052
|
-
getRecordsV3OrCounByCriterion(objectApiName, criterion,
|
|
1054
|
+
getRecordsV3OrCounByCriterion(objectApiName, criterion, quickQuery, quickQueryFields, order, fieldApiNames, offset, limit, needCount, authType) {
|
|
1053
1055
|
}
|
|
1054
1056
|
uploadFile(data, expire, fileName) {
|
|
1055
1057
|
return null;
|