@byted-apaas/server-sdk-node 0.0.1-beta.3
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/LICENSE +7 -0
- package/NOTICE +3 -0
- package/README.md +1 -0
- package/application/application.d.ts +27 -0
- package/application/application.js +2 -0
- package/application/application.ts +40 -0
- package/application/function/function.d.ts +14 -0
- package/application/function/function.js +21 -0
- package/application/function/function.ts +37 -0
- package/application/impl/common.d.ts +2 -0
- package/application/impl/common.js +50 -0
- package/application/impl/common.ts +50 -0
- package/application/impl/impl.d.ts +16 -0
- package/application/impl/impl.js +38 -0
- package/application/impl/impl.ts +48 -0
- package/constants/constants.d.ts +10 -0
- package/constants/constants.js +15 -0
- package/constants/constants.ts +15 -0
- package/context/context.d.ts +74 -0
- package/context/context.js +25 -0
- package/context/context.ts +130 -0
- package/context/db/db.d.ts +73 -0
- package/context/db/db.js +4 -0
- package/context/db/db.ts +80 -0
- package/context/db/impl/IObject.d.ts +251 -0
- package/context/db/impl/IObject.js +5 -0
- package/context/db/impl/IObject.ts +247 -0
- package/context/db/impl/db.d.ts +61 -0
- package/context/db/impl/db.js +86 -0
- package/context/db/impl/db.ts +95 -0
- package/context/db/impl/object.d.ts +92 -0
- package/context/db/impl/object.js +524 -0
- package/context/db/impl/object.ts +631 -0
- package/context/db/impl/oql/ioql.d.ts +6 -0
- package/context/db/impl/oql/ioql.js +4 -0
- package/context/db/impl/oql/ioql.ts +9 -0
- package/context/db/impl/oql/oql.d.ts +8 -0
- package/context/db/impl/oql/oql.js +21 -0
- package/context/db/impl/oql/oql.ts +25 -0
- package/context/db/impl/order.d.ts +9 -0
- package/context/db/impl/order.js +15 -0
- package/context/db/impl/order.ts +19 -0
- package/context/db/impl/propertiesStore.d.ts +8 -0
- package/context/db/impl/propertiesStore.js +29 -0
- package/context/db/impl/propertiesStore.ts +31 -0
- package/context/db/impl/queryBuilder.d.ts +29 -0
- package/context/db/impl/queryBuilder.js +78 -0
- package/context/db/impl/queryBuilder.ts +106 -0
- package/context/db/impl/transaction/index.d.ts +20 -0
- package/context/db/impl/transaction/index.js +277 -0
- package/context/db/impl/transaction/index.ts +340 -0
- package/context/db/impl/transaction/operation.d.ts +27 -0
- package/context/db/impl/transaction/operation.js +69 -0
- package/context/db/impl/transaction/operation.ts +72 -0
- package/context/db/impl/transaction.d.ts +67 -0
- package/context/db/impl/transaction.js +4 -0
- package/context/db/impl/transaction.ts +79 -0
- package/context/globalConfig/globalConfig.d.ts +7 -0
- package/context/globalConfig/globalConfig.js +16 -0
- package/context/globalConfig/globalConfig.ts +14 -0
- package/context/metadata/components/common.d.ts +6 -0
- package/context/metadata/components/common.js +17 -0
- package/context/metadata/components/common.ts +22 -0
- package/context/metadata/components/components.d.ts +12 -0
- package/context/metadata/components/components.js +19 -0
- package/context/metadata/components/components.ts +22 -0
- package/context/metadata/components/desktop/list.d.ts +16 -0
- package/context/metadata/components/desktop/list.js +402 -0
- package/context/metadata/components/desktop/list.ts +457 -0
- package/context/metadata/components/desktop/recordDetail.d.ts +11 -0
- package/context/metadata/components/desktop/recordDetail.js +53 -0
- package/context/metadata/components/desktop/recordDetail.ts +67 -0
- package/context/metadata/components/mobile/list.d.ts +24 -0
- package/context/metadata/components/mobile/list.js +145 -0
- package/context/metadata/components/mobile/list.ts +179 -0
- package/context/metadata/metadata.d.ts +61 -0
- package/context/metadata/metadata.js +103 -0
- package/context/metadata/metadata.ts +178 -0
- package/context/metadata/objects/fields.d.ts +130 -0
- package/context/metadata/objects/fields.js +334 -0
- package/context/metadata/objects/fields.ts +457 -0
- package/context/metadata/objects/fields.util.d.ts +40 -0
- package/context/metadata/objects/fields.util.js +319 -0
- package/context/metadata/objects/fields.util.ts +360 -0
- package/context/metadata/objects/objects.d.ts +11 -0
- package/context/metadata/objects/objects.js +20 -0
- package/context/metadata/objects/objects.ts +30 -0
- package/context/metadata/types/common.d.ts +6 -0
- package/context/metadata/types/common.js +9 -0
- package/context/metadata/types/common.ts +13 -0
- package/context/metadata/types/components.d.ts +90 -0
- package/context/metadata/types/components.js +4 -0
- package/context/metadata/types/components.ts +108 -0
- package/context/metadata/types/objects.d.ts +226 -0
- package/context/metadata/types/objects.js +4 -0
- package/context/metadata/types/objects.ts +254 -0
- package/context/msg/msg.d.ts +38 -0
- package/context/msg/msg.js +35 -0
- package/context/msg/msg.ts +52 -0
- package/context/resources/IResources.d.ts +66 -0
- package/context/resources/IResources.js +2 -0
- package/context/resources/IResources.ts +73 -0
- package/context/resources/impl/resources.d.ts +42 -0
- package/context/resources/impl/resources.js +150 -0
- package/context/resources/impl/resources.ts +173 -0
- package/context/tasks/tasks.d.ts +33 -0
- package/context/tasks/tasks.js +139 -0
- package/context/tasks/tasks.ts +159 -0
- package/data/index.d.ts +27 -0
- package/data/index.js +4 -0
- package/data/index.ts +30 -0
- package/hooks/api.d.ts +61 -0
- package/hooks/api.js +327 -0
- package/hooks/api.ts +341 -0
- package/hooks/hooks.d.ts +1 -0
- package/hooks/hooks.js +88 -0
- package/hooks/hooks.ts +100 -0
- package/kunlun/kunlun.d.ts +55 -0
- package/kunlun/kunlun.js +58 -0
- package/kunlun/kunlun.ts +72 -0
- package/kunlun/operator/IOperator.d.ts +158 -0
- package/kunlun/operator/IOperator.js +4 -0
- package/kunlun/operator/IOperator.ts +166 -0
- package/kunlun/operator/impl/expression.d.ts +47 -0
- package/kunlun/operator/impl/expression.js +56 -0
- package/kunlun/operator/impl/expression.ts +74 -0
- package/kunlun/operator/impl/logic.d.ts +50 -0
- package/kunlun/operator/impl/logic.js +509 -0
- package/kunlun/operator/impl/logic.ts +598 -0
- package/kunlun/operator/impl/logicV2.d.ts +58 -0
- package/kunlun/operator/impl/logicV2.js +200 -0
- package/kunlun/operator/impl/logicV2.ts +254 -0
- package/kunlun/operator/impl/operator.d.ts +179 -0
- package/kunlun/operator/impl/operator.js +222 -0
- package/kunlun/operator/impl/operator.ts +258 -0
- package/kunlun/operator/impl/operatorV2.d.ts +180 -0
- package/kunlun/operator/impl/operatorV2.js +216 -0
- package/kunlun/operator/impl/operatorV2.ts +249 -0
- package/lib/core.d.ts +4 -0
- package/lib/core.js +19 -0
- package/lib/core.ts +7 -0
- package/package.json +50 -0
- package/request/common.d.ts +13 -0
- package/request/common.js +87 -0
- package/request/common.ts +91 -0
- package/request/constants.d.ts +10 -0
- package/request/constants.js +25 -0
- package/request/constants.ts +25 -0
- package/request/faasinfra.d.ts +8 -0
- package/request/faasinfra.js +358 -0
- package/request/faasinfra.ts +393 -0
- package/request/innerapi.d.ts +67 -0
- package/request/innerapi.js +1412 -0
- package/request/innerapi.ts +1648 -0
- package/request/interface.d.ts +95 -0
- package/request/interface.js +41 -0
- package/request/interface.ts +169 -0
- package/request/openapi.d.ts +69 -0
- package/request/openapi.js +1014 -0
- package/request/openapi.ts +1223 -0
- package/types/types.d.ts +79 -0
- package/types/types.js +4 -0
- package/types/types.ts +108 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { BaseFieldType, FieldType, FilterType, SortConditionType, SubOptionType } from "../types/objects";
|
|
2
|
+
import { I18ns } from "../types/common";
|
|
3
|
+
declare class MetadataField {
|
|
4
|
+
type: string;
|
|
5
|
+
apiName: string;
|
|
6
|
+
label: I18ns;
|
|
7
|
+
constructor(type: string, field: FieldType);
|
|
8
|
+
}
|
|
9
|
+
declare class KText extends MetadataField {
|
|
10
|
+
required: boolean;
|
|
11
|
+
unique: boolean;
|
|
12
|
+
caseSensitive: boolean;
|
|
13
|
+
multiline: boolean;
|
|
14
|
+
maxLength: number;
|
|
15
|
+
validationRegex: string;
|
|
16
|
+
errorMsg: I18ns;
|
|
17
|
+
constructor(field: FieldType);
|
|
18
|
+
}
|
|
19
|
+
declare class RichText extends MetadataField {
|
|
20
|
+
maxLength: number;
|
|
21
|
+
required: boolean;
|
|
22
|
+
constructor(field: FieldType);
|
|
23
|
+
}
|
|
24
|
+
declare class Multilingual extends MetadataField {
|
|
25
|
+
required: boolean;
|
|
26
|
+
unique: boolean;
|
|
27
|
+
caseSensitive: boolean;
|
|
28
|
+
multiline: boolean;
|
|
29
|
+
maxLength: number;
|
|
30
|
+
constructor(field: FieldType);
|
|
31
|
+
}
|
|
32
|
+
declare class Number extends MetadataField {
|
|
33
|
+
required: boolean;
|
|
34
|
+
unique: boolean;
|
|
35
|
+
displayAsPercentage: boolean;
|
|
36
|
+
decimalPlacesNumber: number;
|
|
37
|
+
constructor(field: FieldType);
|
|
38
|
+
}
|
|
39
|
+
declare class KDate extends MetadataField {
|
|
40
|
+
required: boolean;
|
|
41
|
+
constructor(field: FieldType);
|
|
42
|
+
}
|
|
43
|
+
declare class DateTime extends MetadataField {
|
|
44
|
+
required: boolean;
|
|
45
|
+
constructor(field: FieldType);
|
|
46
|
+
}
|
|
47
|
+
declare class Option extends MetadataField {
|
|
48
|
+
required: boolean;
|
|
49
|
+
multiple: boolean;
|
|
50
|
+
optionSource: ("custom" | "global");
|
|
51
|
+
globalOptionApiName: string;
|
|
52
|
+
optionList: SubOptionType[];
|
|
53
|
+
constructor(field: FieldType);
|
|
54
|
+
}
|
|
55
|
+
declare class Email extends MetadataField {
|
|
56
|
+
required: boolean;
|
|
57
|
+
unique: boolean;
|
|
58
|
+
constructor(field: FieldType);
|
|
59
|
+
}
|
|
60
|
+
declare class MobileNumber extends MetadataField {
|
|
61
|
+
required: boolean;
|
|
62
|
+
unique: boolean;
|
|
63
|
+
constructor(field: FieldType);
|
|
64
|
+
}
|
|
65
|
+
declare class Boolean extends MetadataField {
|
|
66
|
+
descriptionWhenTrue: I18ns;
|
|
67
|
+
descriptionWhenFalse: I18ns;
|
|
68
|
+
defaultValue: boolean;
|
|
69
|
+
unique: boolean;
|
|
70
|
+
constructor(field: FieldType);
|
|
71
|
+
}
|
|
72
|
+
declare class AvatarOrLogo extends MetadataField {
|
|
73
|
+
displayStyle: ("square" | "round");
|
|
74
|
+
constructor(field: FieldType);
|
|
75
|
+
}
|
|
76
|
+
declare class Lookup extends MetadataField {
|
|
77
|
+
required: boolean;
|
|
78
|
+
multiple: boolean;
|
|
79
|
+
objectApiName: string;
|
|
80
|
+
hierarchy: boolean;
|
|
81
|
+
displayStyle: ("search" | "dropDown" | "tree");
|
|
82
|
+
sortConditions: SortConditionType[];
|
|
83
|
+
filter: FilterType[];
|
|
84
|
+
constructor(field: FieldType);
|
|
85
|
+
}
|
|
86
|
+
declare class Formula extends MetadataField {
|
|
87
|
+
returnType: string;
|
|
88
|
+
formula: I18ns;
|
|
89
|
+
constructor(field: FieldType);
|
|
90
|
+
}
|
|
91
|
+
declare class AutoID extends MetadataField {
|
|
92
|
+
generateMethod: ("random" | "incremental");
|
|
93
|
+
digitsNumber: number;
|
|
94
|
+
prefix: string;
|
|
95
|
+
suffix: string;
|
|
96
|
+
constructor(field: FieldType);
|
|
97
|
+
}
|
|
98
|
+
declare class ReferenceField extends MetadataField {
|
|
99
|
+
guideFieldApiName: string;
|
|
100
|
+
fieldApiName: string;
|
|
101
|
+
constructor(field: FieldType);
|
|
102
|
+
}
|
|
103
|
+
declare class File extends MetadataField {
|
|
104
|
+
required: boolean;
|
|
105
|
+
multiple: boolean;
|
|
106
|
+
fileTypes: string[];
|
|
107
|
+
constructor(field: FieldType);
|
|
108
|
+
}
|
|
109
|
+
declare class BackLookup extends MetadataField {
|
|
110
|
+
constructor(field: FieldType);
|
|
111
|
+
}
|
|
112
|
+
declare class CompositeType extends MetadataField {
|
|
113
|
+
compositeTypeApiName: string;
|
|
114
|
+
subFields: BaseFieldType[];
|
|
115
|
+
required: boolean;
|
|
116
|
+
multiple: boolean;
|
|
117
|
+
constructor(field: FieldType);
|
|
118
|
+
}
|
|
119
|
+
declare class ExtractSingleRecord extends MetadataField {
|
|
120
|
+
compositeTypeApiName: string;
|
|
121
|
+
subFields: BaseFieldType[];
|
|
122
|
+
filter: FilterType[];
|
|
123
|
+
sortConditions: SortConditionType[];
|
|
124
|
+
recordPosition: number;
|
|
125
|
+
constructor(field: FieldType);
|
|
126
|
+
}
|
|
127
|
+
declare function parseFields(inputFields: Record<string, any>): BaseFieldType[];
|
|
128
|
+
declare function parseField(field: FieldType): BaseFieldType;
|
|
129
|
+
declare function getFieldClass(field: FieldType): any;
|
|
130
|
+
export { KText as Text, Multilingual, Number, KDate as Date, DateTime, Option, Email, MobileNumber, Boolean, AvatarOrLogo, Lookup, Formula, AutoID, ReferenceField, File, BackLookup, CompositeType, ExtractSingleRecord, RichText, parseFields, parseField, getFieldClass, };
|
|
@@ -0,0 +1,334 @@
|
|
|
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.getFieldClass = exports.parseField = exports.parseFields = exports.RichText = exports.ExtractSingleRecord = exports.CompositeType = exports.BackLookup = exports.File = exports.ReferenceField = exports.AutoID = exports.Formula = exports.Lookup = exports.AvatarOrLogo = exports.Boolean = exports.MobileNumber = exports.Email = exports.Option = exports.DateTime = exports.Date = exports.Number = exports.Multilingual = exports.Text = void 0;
|
|
6
|
+
const fieldsUtil = require("./fields.util");
|
|
7
|
+
class MetadataField {
|
|
8
|
+
constructor(type, field) {
|
|
9
|
+
this.type = type;
|
|
10
|
+
this.apiName = field.api_name;
|
|
11
|
+
this.label = field.label;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
class KText extends MetadataField {
|
|
15
|
+
constructor(field) {
|
|
16
|
+
if (!field) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
super("text", field);
|
|
20
|
+
this.required = field["required"];
|
|
21
|
+
this.unique = fieldsUtil.getUnique(field);
|
|
22
|
+
this.caseSensitive = fieldsUtil.getCaseSensitive(field);
|
|
23
|
+
this.multiline = fieldsUtil.getMultiline(field);
|
|
24
|
+
this.maxLength = fieldsUtil.getMaxLength(field);
|
|
25
|
+
this.validationRegex = fieldsUtil.getRegexpExpression(field);
|
|
26
|
+
this.errorMsg = fieldsUtil.getRegexpErrMsg(field);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.Text = KText;
|
|
30
|
+
class RichText extends MetadataField {
|
|
31
|
+
constructor(field) {
|
|
32
|
+
if (!field) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
super("richText", field);
|
|
36
|
+
this.maxLength = fieldsUtil.getMaxLength(field);
|
|
37
|
+
this.required = field.required;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.RichText = RichText;
|
|
41
|
+
class Multilingual extends MetadataField {
|
|
42
|
+
constructor(field) {
|
|
43
|
+
if (!field) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
super("multilingual", field);
|
|
47
|
+
this.required = field.required;
|
|
48
|
+
this.unique = fieldsUtil.getUnique(field);
|
|
49
|
+
this.caseSensitive = fieldsUtil.getCaseSensitive(field);
|
|
50
|
+
this.multiline = fieldsUtil.getMultiline(field);
|
|
51
|
+
this.maxLength = fieldsUtil.getMaxLength(field);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.Multilingual = Multilingual;
|
|
55
|
+
class Number extends MetadataField {
|
|
56
|
+
constructor(field) {
|
|
57
|
+
if (!field) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
super("number", field);
|
|
61
|
+
this.required = field.required;
|
|
62
|
+
this.unique = fieldsUtil.getUnique(field);
|
|
63
|
+
this.displayAsPercentage = fieldsUtil.getDisplayAsPercentage(field);
|
|
64
|
+
this.decimalPlacesNumber = fieldsUtil.getDecimalPlaces(field);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.Number = Number;
|
|
68
|
+
class KDate extends MetadataField {
|
|
69
|
+
constructor(field) {
|
|
70
|
+
if (!field) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
super("date", field);
|
|
74
|
+
this.required = field.required;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.Date = KDate;
|
|
78
|
+
class DateTime extends MetadataField {
|
|
79
|
+
constructor(field) {
|
|
80
|
+
if (!field) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
super("dateTime", field);
|
|
84
|
+
this.required = field.required;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.DateTime = DateTime;
|
|
88
|
+
class Option extends MetadataField {
|
|
89
|
+
constructor(field) {
|
|
90
|
+
if (!field) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
super("option", field);
|
|
94
|
+
this.required = field.required;
|
|
95
|
+
this.multiple = fieldsUtil.getMultiple(field);
|
|
96
|
+
this.optionSource = fieldsUtil.getOptionSource(field);
|
|
97
|
+
this.globalOptionApiName = fieldsUtil.getGlobalOptionApiName(field);
|
|
98
|
+
this.optionList = fieldsUtil.getOptionList(field);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
exports.Option = Option;
|
|
102
|
+
class Email extends MetadataField {
|
|
103
|
+
constructor(field) {
|
|
104
|
+
if (!field) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
super("email", field);
|
|
108
|
+
this.required = field.required;
|
|
109
|
+
this.unique = fieldsUtil.getUnique(field);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
exports.Email = Email;
|
|
113
|
+
class MobileNumber extends MetadataField {
|
|
114
|
+
constructor(field) {
|
|
115
|
+
if (!field) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
super("mobileNumber", field);
|
|
119
|
+
this.required = field.required;
|
|
120
|
+
this.unique = fieldsUtil.getUnique(field);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
exports.MobileNumber = MobileNumber;
|
|
124
|
+
class Boolean extends MetadataField {
|
|
125
|
+
constructor(field) {
|
|
126
|
+
if (!field) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
super("boolean", field);
|
|
130
|
+
this.unique = fieldsUtil.getUnique(field);
|
|
131
|
+
this.descriptionWhenTrue = fieldsUtil.getDescriptionWhenTrue(field);
|
|
132
|
+
this.descriptionWhenFalse = fieldsUtil.getDescriptionWhenFalse(field);
|
|
133
|
+
this.defaultValue = fieldsUtil.getDefaultValue(field);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
exports.Boolean = Boolean;
|
|
137
|
+
class AvatarOrLogo extends MetadataField {
|
|
138
|
+
constructor(field) {
|
|
139
|
+
if (!field) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
super("avatarOrLogo", field);
|
|
143
|
+
this.displayStyle = fieldsUtil.getDisplayStyle(field);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
exports.AvatarOrLogo = AvatarOrLogo;
|
|
147
|
+
class Lookup extends MetadataField {
|
|
148
|
+
constructor(field) {
|
|
149
|
+
if (!field) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
super("lookup", field);
|
|
153
|
+
this.required = field.required;
|
|
154
|
+
this.multiple = fieldsUtil.getMultiple(field);
|
|
155
|
+
this.objectApiName = fieldsUtil.getLookupRefObjectApiName(field);
|
|
156
|
+
this.hierarchy = fieldsUtil.getLookupIsHierarchy(field);
|
|
157
|
+
this.displayStyle = fieldsUtil.getLookupDisplayStyle(field);
|
|
158
|
+
// TODO
|
|
159
|
+
this.sortConditions = fieldsUtil.getSettingsSort(field);
|
|
160
|
+
this.filter = [];
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
exports.Lookup = Lookup;
|
|
164
|
+
class Formula extends MetadataField {
|
|
165
|
+
constructor(field) {
|
|
166
|
+
if (!field) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
super("formula", field);
|
|
170
|
+
this.returnType = fieldsUtil.getReturnType(field);
|
|
171
|
+
// TODO 由于下游提供仍是 api ID 版本,因此禁用
|
|
172
|
+
this.formula = null; //fieldsUtil.getFormula(field);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
exports.Formula = Formula;
|
|
176
|
+
class AutoID extends MetadataField {
|
|
177
|
+
constructor(field) {
|
|
178
|
+
if (!field) {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
super("autoId", field);
|
|
182
|
+
this.generateMethod = fieldsUtil.getGenerateMethod(field);
|
|
183
|
+
this.digitsNumber = fieldsUtil.getDigitsNumber(field);
|
|
184
|
+
this.prefix = fieldsUtil.getPrefix(field);
|
|
185
|
+
this.suffix = fieldsUtil.getSuffix(field);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
exports.AutoID = AutoID;
|
|
189
|
+
class ReferenceField extends MetadataField {
|
|
190
|
+
constructor(field) {
|
|
191
|
+
if (!field) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
super("referenceField", field);
|
|
195
|
+
// TODO: check objectApiName to guideFieldApiName
|
|
196
|
+
this.guideFieldApiName = fieldsUtil.getReferenceObjectApiName(field);
|
|
197
|
+
this.fieldApiName = fieldsUtil.getReferenceFieldApiName(field);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
exports.ReferenceField = ReferenceField;
|
|
201
|
+
class File extends MetadataField {
|
|
202
|
+
constructor(field) {
|
|
203
|
+
if (!field) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
super("file", field);
|
|
207
|
+
this.required = field.required;
|
|
208
|
+
this.multiple = fieldsUtil.getFileMultiple(field);
|
|
209
|
+
this.fileTypes = fieldsUtil.getFileTypes(field);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
exports.File = File;
|
|
213
|
+
class BackLookup extends MetadataField {
|
|
214
|
+
// objectApiName: string; // TODO 由于下游提供仍是 api ID 版本,因此禁用
|
|
215
|
+
// fieldApiName: string; // 由于下游提供仍是 api ID 版本,因此禁用
|
|
216
|
+
constructor(field) {
|
|
217
|
+
if (!field) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
super("backLookup", field);
|
|
221
|
+
// TODO 由于下游提供仍是 api ID 版本,因此禁用
|
|
222
|
+
// this.objectApiName = fieldsUtil.getBackLookupObjectApiName(field);
|
|
223
|
+
// this.fieldApiName = fieldsUtil.getBackLookupFieldApiName(field); // TODO metadata返回值为空
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
exports.BackLookup = BackLookup;
|
|
227
|
+
class CompositeType extends MetadataField {
|
|
228
|
+
constructor(field) {
|
|
229
|
+
if (!field) {
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
super("compositeType", field);
|
|
233
|
+
this.required = field.required;
|
|
234
|
+
this.multiple = fieldsUtil.getSettingsMultiple(field);
|
|
235
|
+
this.compositeTypeApiName = fieldsUtil.getCompositeTypeApiName(field);
|
|
236
|
+
// TODO 字段类型转换
|
|
237
|
+
this.subFields = parseFields(fieldsUtil.getCompositeTypeSubFields(field));
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
exports.CompositeType = CompositeType;
|
|
241
|
+
class ExtractSingleRecord extends MetadataField {
|
|
242
|
+
constructor(field) {
|
|
243
|
+
if (!field) {
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
super("extractSingleRecord", field);
|
|
247
|
+
this.compositeTypeApiName = fieldsUtil.getCompositeTypeApiName(field);
|
|
248
|
+
// TODO 字段类型转换
|
|
249
|
+
this.subFields = parseFields(fieldsUtil.getCompositeTypeSubFields(field));
|
|
250
|
+
this.filter = fieldsUtil.getSettingsFilter(field);
|
|
251
|
+
this.sortConditions = fieldsUtil.getSettingsSort(field);
|
|
252
|
+
this.recordPosition = fieldsUtil.getRecordPosition(field);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
exports.ExtractSingleRecord = ExtractSingleRecord;
|
|
256
|
+
function getCompositeTypeClass(field) {
|
|
257
|
+
if (field && field.type && field.type.settings && field.type.settings.is_extract) {
|
|
258
|
+
return ExtractSingleRecord;
|
|
259
|
+
}
|
|
260
|
+
return CompositeType;
|
|
261
|
+
}
|
|
262
|
+
function parseFields(inputFields) {
|
|
263
|
+
if (!inputFields || !Array.isArray(inputFields)) {
|
|
264
|
+
return [];
|
|
265
|
+
}
|
|
266
|
+
let fields = [];
|
|
267
|
+
for (let field of inputFields) {
|
|
268
|
+
let FieldClass = getFieldClass(field);
|
|
269
|
+
if (!FieldClass) {
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
fields.push(new FieldClass(field));
|
|
273
|
+
}
|
|
274
|
+
return fields;
|
|
275
|
+
}
|
|
276
|
+
exports.parseFields = parseFields;
|
|
277
|
+
function parseField(field) {
|
|
278
|
+
let FieldClass = getFieldClass(field);
|
|
279
|
+
if (FieldClass) {
|
|
280
|
+
return new FieldClass(field);
|
|
281
|
+
}
|
|
282
|
+
return null;
|
|
283
|
+
}
|
|
284
|
+
exports.parseField = parseField;
|
|
285
|
+
function getFieldClass(field) {
|
|
286
|
+
if (field && field.type && field.type.name) {
|
|
287
|
+
if (field.type.name === "compositeType") {
|
|
288
|
+
return getCompositeTypeClass(field);
|
|
289
|
+
}
|
|
290
|
+
return type2fieldType[field.type.name];
|
|
291
|
+
}
|
|
292
|
+
return null;
|
|
293
|
+
}
|
|
294
|
+
exports.getFieldClass = getFieldClass;
|
|
295
|
+
const type2fieldType = {
|
|
296
|
+
"text": KText,
|
|
297
|
+
"multilingual": Multilingual,
|
|
298
|
+
"float": Number,
|
|
299
|
+
"date": KDate,
|
|
300
|
+
"datetime": DateTime,
|
|
301
|
+
"enum": Option,
|
|
302
|
+
"email": Email,
|
|
303
|
+
"phone": MobileNumber,
|
|
304
|
+
"boolean": Boolean,
|
|
305
|
+
"avatar": AvatarOrLogo,
|
|
306
|
+
"lookup": Lookup,
|
|
307
|
+
"formula": Formula,
|
|
308
|
+
"auto_number": AutoID,
|
|
309
|
+
"reference_field": ReferenceField,
|
|
310
|
+
"attachment": File,
|
|
311
|
+
"back_lookup": BackLookup,
|
|
312
|
+
"richText": RichText,
|
|
313
|
+
};
|
|
314
|
+
const fieldTypeMap = {
|
|
315
|
+
"text": "text",
|
|
316
|
+
"multilingual": "multilingual",
|
|
317
|
+
"number": "float",
|
|
318
|
+
"date": "date",
|
|
319
|
+
"dateTime": "datetime",
|
|
320
|
+
"option": "enum",
|
|
321
|
+
"email": "email",
|
|
322
|
+
"mobileNumber": "phone",
|
|
323
|
+
"boolean": "boolean",
|
|
324
|
+
"avatarOrLogo": "avatar",
|
|
325
|
+
"lookup": "lookup",
|
|
326
|
+
"formula": "formula",
|
|
327
|
+
"autoId": "auto_number",
|
|
328
|
+
"referenceField": "reference_field",
|
|
329
|
+
"file": "attachment",
|
|
330
|
+
"backLookup": "back_lookup",
|
|
331
|
+
"compositeType": "compositeType",
|
|
332
|
+
"extractSingleRecord": "compositeType",
|
|
333
|
+
"richText": "richText",
|
|
334
|
+
};
|