@byted-apaas/server-sdk-node 0.0.2-beta.1
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.md +0 -0
- package/README.md +1 -0
- package/application/application.d.ts +27 -0
- package/application/application.js +3 -0
- package/application/application.js.map +1 -0
- package/application/application.ts +40 -0
- package/application/function/function.d.ts +14 -0
- package/application/function/function.js +22 -0
- package/application/function/function.js.map +1 -0
- package/application/function/function.ts +37 -0
- package/application/impl/common.d.ts +2 -0
- package/application/impl/common.js +51 -0
- package/application/impl/common.js.map +1 -0
- package/application/impl/common.ts +50 -0
- package/application/impl/impl.d.ts +16 -0
- package/application/impl/impl.js +39 -0
- package/application/impl/impl.js.map +1 -0
- package/application/impl/impl.ts +48 -0
- package/constants/constants.d.ts +10 -0
- package/constants/constants.js +14 -0
- package/constants/constants.js.map +1 -0
- package/constants/constants.ts +12 -0
- package/context/context.d.ts +74 -0
- package/context/context.js +24 -0
- package/context/context.js.map +1 -0
- package/context/context.ts +127 -0
- package/context/db/db.d.ts +73 -0
- package/context/db/db.js +3 -0
- package/context/db/db.js.map +1 -0
- package/context/db/db.ts +77 -0
- package/context/db/impl/IObject.d.ts +251 -0
- package/context/db/impl/IObject.js +4 -0
- package/context/db/impl/IObject.js.map +1 -0
- package/context/db/impl/IObject.ts +244 -0
- package/context/db/impl/db.d.ts +61 -0
- package/context/db/impl/db.js +87 -0
- package/context/db/impl/db.js.map +1 -0
- package/context/db/impl/db.ts +95 -0
- package/context/db/impl/object.d.ts +92 -0
- package/context/db/impl/object.js +523 -0
- package/context/db/impl/object.js.map +1 -0
- package/context/db/impl/object.ts +628 -0
- package/context/db/impl/oql/ioql.d.ts +6 -0
- package/context/db/impl/oql/ioql.js +3 -0
- package/context/db/impl/oql/ioql.js.map +1 -0
- package/context/db/impl/oql/ioql.ts +6 -0
- package/context/db/impl/oql/oql.d.ts +8 -0
- package/context/db/impl/oql/oql.js +20 -0
- package/context/db/impl/oql/oql.js.map +1 -0
- package/context/db/impl/oql/oql.ts +22 -0
- package/context/db/impl/order.d.ts +9 -0
- package/context/db/impl/order.js +14 -0
- package/context/db/impl/order.js.map +1 -0
- package/context/db/impl/order.ts +16 -0
- package/context/db/impl/propertiesStore.d.ts +8 -0
- package/context/db/impl/propertiesStore.js +28 -0
- package/context/db/impl/propertiesStore.js.map +1 -0
- package/context/db/impl/propertiesStore.ts +28 -0
- package/context/db/impl/queryBuilder.d.ts +29 -0
- package/context/db/impl/queryBuilder.js +77 -0
- package/context/db/impl/queryBuilder.js.map +1 -0
- package/context/db/impl/queryBuilder.ts +103 -0
- package/context/db/impl/transaction/index.d.ts +20 -0
- package/context/db/impl/transaction/index.js +276 -0
- package/context/db/impl/transaction/index.js.map +1 -0
- package/context/db/impl/transaction/index.ts +337 -0
- package/context/db/impl/transaction/operation.d.ts +27 -0
- package/context/db/impl/transaction/operation.js +70 -0
- package/context/db/impl/transaction/operation.js.map +1 -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 +3 -0
- package/context/db/impl/transaction.js.map +1 -0
- package/context/db/impl/transaction.ts +76 -0
- package/context/globalConfig/globalConfig.d.ts +7 -0
- package/context/globalConfig/globalConfig.js +15 -0
- package/context/globalConfig/globalConfig.js.map +1 -0
- package/context/globalConfig/globalConfig.ts +11 -0
- package/context/metadata/components/common.d.ts +6 -0
- package/context/metadata/components/common.js +16 -0
- package/context/metadata/components/common.js.map +1 -0
- package/context/metadata/components/common.ts +19 -0
- package/context/metadata/components/components.d.ts +12 -0
- package/context/metadata/components/components.js +18 -0
- package/context/metadata/components/components.js.map +1 -0
- package/context/metadata/components/components.ts +19 -0
- package/context/metadata/components/desktop/list.d.ts +16 -0
- package/context/metadata/components/desktop/list.js +403 -0
- package/context/metadata/components/desktop/list.js.map +1 -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 +52 -0
- package/context/metadata/components/desktop/recordDetail.js.map +1 -0
- package/context/metadata/components/desktop/recordDetail.ts +64 -0
- package/context/metadata/components/mobile/list.d.ts +24 -0
- package/context/metadata/components/mobile/list.js +144 -0
- package/context/metadata/components/mobile/list.js.map +1 -0
- package/context/metadata/components/mobile/list.ts +176 -0
- package/context/metadata/metadata.d.ts +61 -0
- package/context/metadata/metadata.js +102 -0
- package/context/metadata/metadata.js.map +1 -0
- package/context/metadata/metadata.ts +175 -0
- package/context/metadata/objects/fields.d.ts +130 -0
- package/context/metadata/objects/fields.js +333 -0
- package/context/metadata/objects/fields.js.map +1 -0
- package/context/metadata/objects/fields.ts +454 -0
- package/context/metadata/objects/fields.util.d.ts +40 -0
- package/context/metadata/objects/fields.util.js +320 -0
- package/context/metadata/objects/fields.util.js.map +1 -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 +19 -0
- package/context/metadata/objects/objects.js.map +1 -0
- package/context/metadata/objects/objects.ts +27 -0
- package/context/metadata/types/common.d.ts +6 -0
- package/context/metadata/types/common.js +8 -0
- package/context/metadata/types/common.js.map +1 -0
- package/context/metadata/types/common.ts +10 -0
- package/context/metadata/types/components.d.ts +90 -0
- package/context/metadata/types/components.js +3 -0
- package/context/metadata/types/components.js.map +1 -0
- package/context/metadata/types/components.ts +105 -0
- package/context/metadata/types/objects.d.ts +226 -0
- package/context/metadata/types/objects.js +3 -0
- package/context/metadata/types/objects.js.map +1 -0
- package/context/metadata/types/objects.ts +251 -0
- package/context/msg/msg.d.ts +38 -0
- package/context/msg/msg.js +34 -0
- package/context/msg/msg.js.map +1 -0
- package/context/msg/msg.ts +49 -0
- package/context/resources/IResources.d.ts +66 -0
- package/context/resources/IResources.js +3 -0
- package/context/resources/IResources.js.map +1 -0
- package/context/resources/IResources.ts +73 -0
- package/context/resources/impl/resources.d.ts +42 -0
- package/context/resources/impl/resources.js +149 -0
- package/context/resources/impl/resources.js.map +1 -0
- package/context/resources/impl/resources.ts +170 -0
- package/context/tasks/tasks.d.ts +33 -0
- package/context/tasks/tasks.js +140 -0
- package/context/tasks/tasks.js.map +1 -0
- package/context/tasks/tasks.ts +159 -0
- package/data/index.d.ts +27 -0
- package/data/index.js +5 -0
- package/data/index.js.map +1 -0
- package/data/index.ts +30 -0
- package/hooks/api.d.ts +61 -0
- package/hooks/api.js +328 -0
- package/hooks/api.js.map +1 -0
- package/hooks/api.ts +341 -0
- package/hooks/hooks.d.ts +1 -0
- package/hooks/hooks.js +89 -0
- package/hooks/hooks.js.map +1 -0
- package/hooks/hooks.ts +100 -0
- package/kunlun/kunlun.d.ts +55 -0
- package/kunlun/kunlun.js +57 -0
- package/kunlun/kunlun.js.map +1 -0
- package/kunlun/kunlun.ts +69 -0
- package/kunlun/operator/IOperator.d.ts +158 -0
- package/kunlun/operator/IOperator.js +3 -0
- package/kunlun/operator/IOperator.js.map +1 -0
- package/kunlun/operator/IOperator.ts +163 -0
- package/kunlun/operator/impl/expression.d.ts +47 -0
- package/kunlun/operator/impl/expression.js +55 -0
- package/kunlun/operator/impl/expression.js.map +1 -0
- package/kunlun/operator/impl/expression.ts +71 -0
- package/kunlun/operator/impl/logic.d.ts +50 -0
- package/kunlun/operator/impl/logic.js +508 -0
- package/kunlun/operator/impl/logic.js.map +1 -0
- package/kunlun/operator/impl/logic.ts +595 -0
- package/kunlun/operator/impl/logicV2.d.ts +58 -0
- package/kunlun/operator/impl/logicV2.js +201 -0
- package/kunlun/operator/impl/logicV2.js.map +1 -0
- package/kunlun/operator/impl/logicV2.ts +254 -0
- package/kunlun/operator/impl/operator.d.ts +179 -0
- package/kunlun/operator/impl/operator.js +221 -0
- package/kunlun/operator/impl/operator.js.map +1 -0
- package/kunlun/operator/impl/operator.ts +255 -0
- package/kunlun/operator/impl/operatorV2.d.ts +180 -0
- package/kunlun/operator/impl/operatorV2.js +217 -0
- package/kunlun/operator/impl/operatorV2.js.map +1 -0
- package/kunlun/operator/impl/operatorV2.ts +249 -0
- package/lib/core.d.ts +4 -0
- package/lib/core.js +18 -0
- package/lib/core.js.map +1 -0
- package/lib/core.ts +4 -0
- package/package.json +50 -0
- package/request/common.d.ts +13 -0
- package/request/common.js +88 -0
- package/request/common.js.map +1 -0
- package/request/common.ts +91 -0
- package/request/constants.d.ts +10 -0
- package/request/constants.js +26 -0
- package/request/constants.js.map +1 -0
- package/request/constants.ts +25 -0
- package/request/faasinfra.d.ts +8 -0
- package/request/faasinfra.js +359 -0
- package/request/faasinfra.js.map +1 -0
- package/request/faasinfra.ts +393 -0
- package/request/innerapi.d.ts +67 -0
- package/request/innerapi.js +1411 -0
- package/request/innerapi.js.map +1 -0
- package/request/innerapi.ts +1645 -0
- package/request/interface.d.ts +95 -0
- package/request/interface.js +40 -0
- package/request/interface.js.map +1 -0
- package/request/interface.ts +166 -0
- package/request/openapi.d.ts +69 -0
- package/request/openapi.js +1013 -0
- package/request/openapi.js.map +1 -0
- package/request/openapi.ts +1220 -0
- package/types/types.d.ts +79 -0
- package/types/types.js +3 -0
- package/types/types.js.map +1 -0
- package/types/types.ts +105 -0
|
@@ -0,0 +1,454 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BaseFieldType,
|
|
3
|
+
FieldType, FilterType,
|
|
4
|
+
SortConditionType,
|
|
5
|
+
SubOptionType
|
|
6
|
+
} from "../types/objects";
|
|
7
|
+
import * as fieldsUtil from './fields.util'
|
|
8
|
+
import {I18ns} from "../types/common";
|
|
9
|
+
import {getSettingsSort} from "./fields.util";
|
|
10
|
+
|
|
11
|
+
class MetadataField {
|
|
12
|
+
type: string;
|
|
13
|
+
apiName: string;
|
|
14
|
+
label: I18ns;
|
|
15
|
+
|
|
16
|
+
constructor(type: string, field: FieldType) {
|
|
17
|
+
this.type = type;
|
|
18
|
+
this.apiName = field.api_name;
|
|
19
|
+
this.label = field.label;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
class KText extends MetadataField {
|
|
24
|
+
required: boolean; // 默认值:false
|
|
25
|
+
unique: boolean; // 默认值:false
|
|
26
|
+
caseSensitive: boolean; // unique 为 false 时生效,默认值:true
|
|
27
|
+
multiline: boolean; // 默认值:false
|
|
28
|
+
maxLength: number; // 默认值:1000
|
|
29
|
+
validationRegex: string; // 正则校验的表达式
|
|
30
|
+
errorMsg: I18ns;
|
|
31
|
+
|
|
32
|
+
constructor(field: FieldType) {
|
|
33
|
+
if (!field) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
super("text", field);
|
|
37
|
+
|
|
38
|
+
this.required = field["required"];
|
|
39
|
+
this.unique = fieldsUtil.getUnique(field);
|
|
40
|
+
this.caseSensitive = fieldsUtil.getCaseSensitive(field);
|
|
41
|
+
this.multiline = fieldsUtil.getMultiline(field);
|
|
42
|
+
this.maxLength = fieldsUtil.getMaxLength(field);
|
|
43
|
+
this.validationRegex = fieldsUtil.getRegexpExpression(field);
|
|
44
|
+
this.errorMsg = fieldsUtil.getRegexpErrMsg(field);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
class RichText extends MetadataField {
|
|
49
|
+
maxLength: number;
|
|
50
|
+
required: boolean;
|
|
51
|
+
|
|
52
|
+
constructor(field: FieldType) {
|
|
53
|
+
if (!field) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
super("richText", field);
|
|
57
|
+
|
|
58
|
+
this.maxLength = fieldsUtil.getMaxLength(field);
|
|
59
|
+
this.required = field.required;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
class Multilingual extends MetadataField {
|
|
64
|
+
required: boolean; // 默认值:false
|
|
65
|
+
unique: boolean; // 默认值:false
|
|
66
|
+
caseSensitive: boolean; // unique 为 ture 时生效,默认值:true
|
|
67
|
+
multiline: boolean; // 默认值:false
|
|
68
|
+
maxLength: number; // 默认值:1000
|
|
69
|
+
|
|
70
|
+
constructor(field: FieldType) {
|
|
71
|
+
if (!field) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
super("multilingual", field);
|
|
75
|
+
|
|
76
|
+
this.required = field.required;
|
|
77
|
+
this.unique = fieldsUtil.getUnique(field);
|
|
78
|
+
this.caseSensitive = fieldsUtil.getCaseSensitive(field);
|
|
79
|
+
this.multiline = fieldsUtil.getMultiline(field);
|
|
80
|
+
this.maxLength = fieldsUtil.getMaxLength(field);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
class Number extends MetadataField {
|
|
85
|
+
required: boolean; // 默认值:false
|
|
86
|
+
unique: boolean; // 默认值:false
|
|
87
|
+
displayAsPercentage: boolean; // 默认值:false
|
|
88
|
+
decimalPlacesNumber: number;
|
|
89
|
+
|
|
90
|
+
constructor(field: FieldType) {
|
|
91
|
+
if (!field) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
super("number", field);
|
|
95
|
+
|
|
96
|
+
this.required = field.required;
|
|
97
|
+
this.unique = fieldsUtil.getUnique(field);
|
|
98
|
+
this.displayAsPercentage = fieldsUtil.getDisplayAsPercentage(field);
|
|
99
|
+
this.decimalPlacesNumber = fieldsUtil.getDecimalPlaces(field);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
class KDate extends MetadataField {
|
|
104
|
+
required: boolean; // 默认值:false
|
|
105
|
+
constructor(field: FieldType) {
|
|
106
|
+
if (!field) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
super("date", field);
|
|
110
|
+
this.required = field.required;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
class DateTime extends MetadataField {
|
|
115
|
+
required: boolean; // 默认值:false
|
|
116
|
+
constructor(field: FieldType) {
|
|
117
|
+
if (!field) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
super("dateTime", field);
|
|
121
|
+
this.required = field.required;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
class Option extends MetadataField {
|
|
126
|
+
required: boolean; // 默认值:false
|
|
127
|
+
multiple: boolean; // 默认值:false
|
|
128
|
+
optionSource: ("custom" | "global"); // 对应选项字段的「选项来源」属性(分为「自定义选项」和「使用全局选项), 默认值:"custom"
|
|
129
|
+
globalOptionApiName: string; // 关联全局选项的 apiName(创建字段时,设定 optionSource 为 "custom",则无需传入,且生成的元数据中不包含该属性)
|
|
130
|
+
optionList: SubOptionType[];
|
|
131
|
+
|
|
132
|
+
constructor(field: FieldType) {
|
|
133
|
+
if (!field) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
super("option", field);
|
|
137
|
+
this.required = field.required;
|
|
138
|
+
this.multiple = fieldsUtil.getMultiple(field);
|
|
139
|
+
this.optionSource = fieldsUtil.getOptionSource(field);
|
|
140
|
+
this.globalOptionApiName = fieldsUtil.getGlobalOptionApiName(field);
|
|
141
|
+
this.optionList = fieldsUtil.getOptionList(field);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
class Email extends MetadataField {
|
|
146
|
+
required: boolean; // 默认值:false
|
|
147
|
+
unique: boolean; // 默认值:false
|
|
148
|
+
|
|
149
|
+
constructor(field: FieldType) {
|
|
150
|
+
if (!field) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
super("email", field);
|
|
154
|
+
this.required = field.required;
|
|
155
|
+
this.unique = fieldsUtil.getUnique(field);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
class MobileNumber extends MetadataField {
|
|
160
|
+
required: boolean; // 默认值:false
|
|
161
|
+
unique: boolean; // 默认值:false
|
|
162
|
+
|
|
163
|
+
constructor(field: FieldType) {
|
|
164
|
+
if (!field) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
super("mobileNumber", field);
|
|
168
|
+
this.required = field.required;
|
|
169
|
+
this.unique = fieldsUtil.getUnique(field);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
class Boolean extends MetadataField {
|
|
174
|
+
descriptionWhenTrue: I18ns;
|
|
175
|
+
descriptionWhenFalse: I18ns;
|
|
176
|
+
defaultValue: boolean;
|
|
177
|
+
unique: boolean; // 文档没有
|
|
178
|
+
|
|
179
|
+
constructor(field: FieldType) {
|
|
180
|
+
if (!field) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
super("boolean", field);
|
|
184
|
+
this.unique = fieldsUtil.getUnique(field);
|
|
185
|
+
this.descriptionWhenTrue = fieldsUtil.getDescriptionWhenTrue(field);
|
|
186
|
+
this.descriptionWhenFalse = fieldsUtil.getDescriptionWhenFalse(field);
|
|
187
|
+
this.defaultValue = fieldsUtil.getDefaultValue(field);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
class AvatarOrLogo extends MetadataField {
|
|
192
|
+
displayStyle: ("square" | "round"); // 默认值:"square"
|
|
193
|
+
constructor(field: FieldType) {
|
|
194
|
+
if (!field) {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
super("avatarOrLogo", field);
|
|
198
|
+
this.displayStyle = fieldsUtil.getDisplayStyle(field) as any;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
class Lookup extends MetadataField {
|
|
203
|
+
required: boolean; // 默认值:false
|
|
204
|
+
multiple: boolean; // 默认值:false,对应查找字段的「关联记录数」属性(分为「单条」和「多条」)
|
|
205
|
+
objectApiName: string; // 字段 look up 的对象
|
|
206
|
+
hierarchy: boolean; // 默认值:false,multiple 为 false 时生效
|
|
207
|
+
displayStyle: ("search" | "dropDown" | "tree"); // 默认值:"dropDown",对应查找字段的「关联记录展示方式」属性,仅当 hierarchy 为 true 时才可设置为 "tree"
|
|
208
|
+
sortConditions: SortConditionType[];
|
|
209
|
+
filter: FilterType[];
|
|
210
|
+
|
|
211
|
+
constructor(field: FieldType) {
|
|
212
|
+
if (!field) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
super("lookup", field);
|
|
216
|
+
this.required = field.required;
|
|
217
|
+
this.multiple = fieldsUtil.getMultiple(field);
|
|
218
|
+
this.objectApiName = fieldsUtil.getLookupRefObjectApiName(field);
|
|
219
|
+
this.hierarchy = fieldsUtil.getLookupIsHierarchy(field);
|
|
220
|
+
this.displayStyle = fieldsUtil.getLookupDisplayStyle(field) as any;
|
|
221
|
+
// TODO
|
|
222
|
+
this.sortConditions = fieldsUtil.getSettingsSort(field);
|
|
223
|
+
this.filter = [];
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
class Formula extends MetadataField {
|
|
228
|
+
returnType: string; // 对应公式字段的「公式返回值类型」属性
|
|
229
|
+
formula: I18ns;
|
|
230
|
+
|
|
231
|
+
constructor(field: FieldType) {
|
|
232
|
+
if (!field) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
super("formula", field);
|
|
236
|
+
this.returnType = fieldsUtil.getReturnType(field);
|
|
237
|
+
// TODO 由于下游提供仍是 api ID 版本,因此禁用
|
|
238
|
+
this.formula = null; //fieldsUtil.getFormula(field);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
class AutoID extends MetadataField {
|
|
243
|
+
generateMethod: ("random" | "incremental"); // 默认值: "random"
|
|
244
|
+
digitsNumber: number;
|
|
245
|
+
prefix: string;
|
|
246
|
+
suffix: string;
|
|
247
|
+
|
|
248
|
+
constructor(field: FieldType) {
|
|
249
|
+
if (!field) {
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
super("autoId", field);
|
|
253
|
+
this.generateMethod = fieldsUtil.getGenerateMethod(field) as any;
|
|
254
|
+
this.digitsNumber = fieldsUtil.getDigitsNumber(field);
|
|
255
|
+
this.prefix = fieldsUtil.getPrefix(field);
|
|
256
|
+
this.suffix = fieldsUtil.getSuffix(field);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
class ReferenceField extends MetadataField {
|
|
261
|
+
guideFieldApiName: string;
|
|
262
|
+
fieldApiName: string;
|
|
263
|
+
|
|
264
|
+
constructor(field: FieldType) {
|
|
265
|
+
if (!field) {
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
super("referenceField", field);
|
|
269
|
+
// TODO: check objectApiName to guideFieldApiName
|
|
270
|
+
this.guideFieldApiName = fieldsUtil.getReferenceObjectApiName(field);
|
|
271
|
+
this.fieldApiName = fieldsUtil.getReferenceFieldApiName(field);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
class File extends MetadataField {
|
|
276
|
+
required: boolean; // 默认值: false
|
|
277
|
+
multiple: boolean; // 默认值: false
|
|
278
|
+
fileTypes: string[]; // 支持 "jpeg"|"jpg"|"png"|"gif"|"pdf"|"docx"|"doc"|"xlsx"|"xls"|"pptx"|"ppt"|"csv"|"txt"|"json"|"mp4"|"zip"|"rar",同时支持 "*.doc" 的描述方式,当为空数组,或 null、undefined 时,默认支持「全部类型」
|
|
279
|
+
|
|
280
|
+
constructor(field: FieldType) {
|
|
281
|
+
if (!field) {
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
super("file", field);
|
|
285
|
+
this.required = field.required;
|
|
286
|
+
this.multiple = fieldsUtil.getFileMultiple(field);
|
|
287
|
+
this.fileTypes = fieldsUtil.getFileTypes(field);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
class BackLookup extends MetadataField {
|
|
292
|
+
// objectApiName: string; // TODO 由于下游提供仍是 api ID 版本,因此禁用
|
|
293
|
+
// fieldApiName: string; // 由于下游提供仍是 api ID 版本,因此禁用
|
|
294
|
+
|
|
295
|
+
constructor(field: FieldType) {
|
|
296
|
+
if (!field) {
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
super("backLookup", field);
|
|
300
|
+
// TODO 由于下游提供仍是 api ID 版本,因此禁用
|
|
301
|
+
// this.objectApiName = fieldsUtil.getBackLookupObjectApiName(field);
|
|
302
|
+
// this.fieldApiName = fieldsUtil.getBackLookupFieldApiName(field); // TODO metadata返回值为空
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
class CompositeType extends MetadataField {
|
|
307
|
+
compositeTypeApiName: string; // 关联组合类型的 apiName,「主子对象」需求调整后,将不存在该 key
|
|
308
|
+
subFields: BaseFieldType[]; // 组合类型中的子字段的元数据
|
|
309
|
+
required: boolean; // 默认值: false
|
|
310
|
+
multiple: boolean; // 默认值: false
|
|
311
|
+
|
|
312
|
+
constructor(field: FieldType) {
|
|
313
|
+
if (!field) {
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
super("compositeType", field);
|
|
317
|
+
this.required = field.required;
|
|
318
|
+
this.multiple = fieldsUtil.getSettingsMultiple(field);
|
|
319
|
+
this.compositeTypeApiName = fieldsUtil.getCompositeTypeApiName(field);
|
|
320
|
+
// TODO 字段类型转换
|
|
321
|
+
this.subFields = parseFields(fieldsUtil.getCompositeTypeSubFields(field));
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
class ExtractSingleRecord extends MetadataField {
|
|
326
|
+
compositeTypeApiName: string; // 关联组合类型的 apiName,「主子对象」需求调整后,将调整为「子表单」类型字段的 apiName
|
|
327
|
+
subFields: BaseFieldType[]; // 组合类型中的子字段的元数据
|
|
328
|
+
filter: FilterType[];
|
|
329
|
+
sortConditions: SortConditionType[];
|
|
330
|
+
recordPosition: number; // 默认值: 1,对应多值取单值字段的「返回记录」(分为「第一条」、「最后一条」和「第 {{n}} 条」),取值为正整数时为相应位置的记录,取值为 -1 时为「最后一条」记录
|
|
331
|
+
|
|
332
|
+
constructor(field: FieldType) {
|
|
333
|
+
if (!field) {
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
super("extractSingleRecord", field);
|
|
337
|
+
this.compositeTypeApiName = fieldsUtil.getCompositeTypeApiName(field);
|
|
338
|
+
// TODO 字段类型转换
|
|
339
|
+
this.subFields = parseFields(fieldsUtil.getCompositeTypeSubFields(field));
|
|
340
|
+
this.filter = fieldsUtil.getSettingsFilter(field);
|
|
341
|
+
this.sortConditions = fieldsUtil.getSettingsSort(field);
|
|
342
|
+
this.recordPosition = fieldsUtil.getRecordPosition(field);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
function getCompositeTypeClass(field: FieldType): any {
|
|
347
|
+
if (field && field.type && field.type.settings && field.type.settings.is_extract) {
|
|
348
|
+
return ExtractSingleRecord;
|
|
349
|
+
}
|
|
350
|
+
return CompositeType;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
function parseFields(inputFields: Record<string, any>): BaseFieldType[] {
|
|
354
|
+
if (!inputFields || !Array.isArray(inputFields)) {
|
|
355
|
+
return [];
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
let fields = [];
|
|
359
|
+
for (let field of inputFields) {
|
|
360
|
+
let FieldClass = getFieldClass(field);
|
|
361
|
+
if (!FieldClass) {
|
|
362
|
+
continue;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
fields.push(new FieldClass(field));
|
|
366
|
+
}
|
|
367
|
+
return fields;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
function parseField(field: FieldType): BaseFieldType {
|
|
371
|
+
let FieldClass = getFieldClass(field);
|
|
372
|
+
if (FieldClass) {
|
|
373
|
+
return new FieldClass(field);
|
|
374
|
+
}
|
|
375
|
+
return null;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
function getFieldClass(field: FieldType): any {
|
|
379
|
+
if (field && field.type && field.type.name) {
|
|
380
|
+
if (field.type.name === "compositeType") {
|
|
381
|
+
return getCompositeTypeClass(field);
|
|
382
|
+
}
|
|
383
|
+
return type2fieldType[field.type.name];
|
|
384
|
+
}
|
|
385
|
+
return null;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
const type2fieldType: Record<string, any> = {
|
|
389
|
+
"text": KText,
|
|
390
|
+
"multilingual": Multilingual,
|
|
391
|
+
"float": Number,
|
|
392
|
+
"date": KDate,
|
|
393
|
+
"datetime": DateTime,
|
|
394
|
+
"enum": Option,
|
|
395
|
+
"email": Email,
|
|
396
|
+
"phone": MobileNumber,
|
|
397
|
+
"boolean": Boolean,
|
|
398
|
+
"avatar": AvatarOrLogo,
|
|
399
|
+
"lookup": Lookup,
|
|
400
|
+
"formula": Formula,
|
|
401
|
+
"auto_number": AutoID,
|
|
402
|
+
"reference_field": ReferenceField,
|
|
403
|
+
"attachment": File,
|
|
404
|
+
"back_lookup": BackLookup,
|
|
405
|
+
"richText": RichText,
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
const fieldTypeMap: Record<string, string> = {
|
|
409
|
+
"text": "text",
|
|
410
|
+
"multilingual": "multilingual",
|
|
411
|
+
"number": "float",
|
|
412
|
+
"date": "date",
|
|
413
|
+
"dateTime": "datetime",
|
|
414
|
+
"option": "enum",
|
|
415
|
+
"email": "email",
|
|
416
|
+
"mobileNumber": "phone",
|
|
417
|
+
"boolean": "boolean",
|
|
418
|
+
"avatarOrLogo": "avatar",
|
|
419
|
+
"lookup": "lookup",
|
|
420
|
+
"formula": "formula",
|
|
421
|
+
"autoId": "auto_number",
|
|
422
|
+
"referenceField": "reference_field",
|
|
423
|
+
"file": "attachment",
|
|
424
|
+
"backLookup": "back_lookup",
|
|
425
|
+
"compositeType": "compositeType",
|
|
426
|
+
"extractSingleRecord": "compositeType",
|
|
427
|
+
"richText": "richText",
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
export {
|
|
431
|
+
KText as Text,
|
|
432
|
+
Multilingual,
|
|
433
|
+
Number,
|
|
434
|
+
KDate as Date,
|
|
435
|
+
DateTime,
|
|
436
|
+
Option,
|
|
437
|
+
Email,
|
|
438
|
+
MobileNumber,
|
|
439
|
+
Boolean,
|
|
440
|
+
AvatarOrLogo,
|
|
441
|
+
Lookup,
|
|
442
|
+
Formula,
|
|
443
|
+
AutoID,
|
|
444
|
+
ReferenceField,
|
|
445
|
+
File,
|
|
446
|
+
BackLookup,
|
|
447
|
+
CompositeType,
|
|
448
|
+
ExtractSingleRecord,
|
|
449
|
+
RichText,
|
|
450
|
+
|
|
451
|
+
parseFields,
|
|
452
|
+
parseField,
|
|
453
|
+
getFieldClass,
|
|
454
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { FieldType, FilterType, SortConditionType, SubOptionType } from "../types/objects";
|
|
2
|
+
import { I18ns } from "../types/common";
|
|
3
|
+
declare function getUnique(field: FieldType): boolean;
|
|
4
|
+
declare function getCaseSensitive(field: FieldType): boolean;
|
|
5
|
+
declare function getMultiline(field: FieldType): boolean;
|
|
6
|
+
declare function getMaxLength(field: FieldType): number;
|
|
7
|
+
declare function getRegexpExpression(field: FieldType): string;
|
|
8
|
+
declare function getRegexpErrMsg(field: FieldType): I18ns;
|
|
9
|
+
declare function getDisplayAsPercentage(field: FieldType): boolean;
|
|
10
|
+
declare function getDecimalPlaces(field: FieldType): number;
|
|
11
|
+
declare function getMultiple(field: FieldType): boolean;
|
|
12
|
+
declare function getOptionSource(field: FieldType): ("custom" | "global");
|
|
13
|
+
declare function getGlobalOptionApiName(field: FieldType): string;
|
|
14
|
+
declare function getOptionList(field: FieldType): SubOptionType[];
|
|
15
|
+
declare function getDescriptionWhenTrue(field: FieldType): I18ns;
|
|
16
|
+
declare function getDescriptionWhenFalse(field: FieldType): I18ns;
|
|
17
|
+
declare function getDefaultValue(field: FieldType): boolean;
|
|
18
|
+
declare function getDisplayStyle(field: FieldType): string;
|
|
19
|
+
declare function getLookupRefObjectApiName(field: FieldType): string;
|
|
20
|
+
declare function getLookupIsHierarchy(field: FieldType): boolean;
|
|
21
|
+
declare function getLookupDisplayStyle(field: FieldType): string;
|
|
22
|
+
declare function getReturnType(field: FieldType): string;
|
|
23
|
+
declare function getFormula(field: FieldType): I18ns;
|
|
24
|
+
declare function getGenerateMethod(field: FieldType): string;
|
|
25
|
+
declare function getDigitsNumber(field: FieldType): number;
|
|
26
|
+
declare function getPrefix(field: FieldType): string;
|
|
27
|
+
declare function getSuffix(field: FieldType): string;
|
|
28
|
+
declare function getReferenceObjectApiName(field: FieldType): string;
|
|
29
|
+
declare function getReferenceFieldApiName(field: FieldType): string;
|
|
30
|
+
declare function getFileMultiple(field: FieldType): boolean;
|
|
31
|
+
declare function getFileTypes(field: FieldType): string[];
|
|
32
|
+
declare function getBackLookupObjectApiName(field: FieldType): string;
|
|
33
|
+
declare function getBackLookupFieldApiName(field: FieldType): string;
|
|
34
|
+
declare function getSettingsMultiple(field: FieldType): boolean;
|
|
35
|
+
declare function getCompositeTypeApiName(field: FieldType): string;
|
|
36
|
+
declare function getCompositeTypeSubFields(field: FieldType): object[];
|
|
37
|
+
declare function getSettingsFilter(field: FieldType): FilterType[];
|
|
38
|
+
declare function getSettingsSort(field: FieldType): SortConditionType[];
|
|
39
|
+
declare function getRecordPosition(field: FieldType): number;
|
|
40
|
+
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, };
|