@byted-apaas/server-sdk-node 0.0.2-beta.2 → 0.0.2-beta.5
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/application/impl/impl.js +2 -1
- package/application/impl/impl.js.map +1 -1
- package/constants/constants.js +2 -0
- package/constants/constants.js.map +1 -1
- package/context/context.js +2 -0
- package/context/context.js.map +1 -1
- package/context/db/db.js +2 -0
- package/context/db/db.js.map +1 -1
- package/context/db/impl/IObject.js +2 -0
- package/context/db/impl/IObject.js.map +1 -1
- package/context/db/impl/object.js +2 -0
- package/context/db/impl/object.js.map +1 -1
- package/context/db/impl/oql/ioql.js +2 -0
- package/context/db/impl/oql/ioql.js.map +1 -1
- package/context/db/impl/oql/oql.js +2 -0
- package/context/db/impl/oql/oql.js.map +1 -1
- package/context/db/impl/order.js +2 -0
- package/context/db/impl/order.js.map +1 -1
- package/context/db/impl/propertiesStore.js +2 -0
- package/context/db/impl/propertiesStore.js.map +1 -1
- package/context/db/impl/queryBuilder.js +2 -0
- package/context/db/impl/queryBuilder.js.map +1 -1
- package/context/db/impl/transaction/index.js +2 -0
- package/context/db/impl/transaction/index.js.map +1 -1
- package/context/db/impl/transaction.js +2 -0
- package/context/db/impl/transaction.js.map +1 -1
- package/context/globalConfig/globalConfig.js +2 -0
- package/context/globalConfig/globalConfig.js.map +1 -1
- package/context/metadata/components/common.js +2 -0
- package/context/metadata/components/common.js.map +1 -1
- package/context/metadata/components/components.js +2 -0
- package/context/metadata/components/components.js.map +1 -1
- package/context/metadata/components/desktop/recordDetail.js +2 -0
- package/context/metadata/components/desktop/recordDetail.js.map +1 -1
- package/context/metadata/components/mobile/list.js +2 -0
- package/context/metadata/components/mobile/list.js.map +1 -1
- package/context/metadata/metadata.js +2 -0
- package/context/metadata/metadata.js.map +1 -1
- package/context/metadata/objects/fields.js +2 -0
- package/context/metadata/objects/fields.js.map +1 -1
- package/context/metadata/objects/objects.js +2 -0
- package/context/metadata/objects/objects.js.map +1 -1
- package/context/metadata/types/common.js +2 -0
- package/context/metadata/types/common.js.map +1 -1
- package/context/metadata/types/components.js +2 -0
- package/context/metadata/types/components.js.map +1 -1
- package/context/metadata/types/objects.js +2 -0
- package/context/metadata/types/objects.js.map +1 -1
- package/context/msg/msg.js +2 -0
- package/context/msg/msg.js.map +1 -1
- package/context/resources/impl/resources.js +2 -0
- package/context/resources/impl/resources.js.map +1 -1
- package/kunlun/kunlun.js +2 -0
- package/kunlun/kunlun.js.map +1 -1
- package/kunlun/operator/IOperator.js +2 -0
- package/kunlun/operator/IOperator.js.map +1 -1
- package/kunlun/operator/impl/expression.js +2 -0
- package/kunlun/operator/impl/expression.js.map +1 -1
- package/kunlun/operator/impl/logic.js +2 -0
- package/kunlun/operator/impl/logic.js.map +1 -1
- package/kunlun/operator/impl/operator.js +2 -0
- package/kunlun/operator/impl/operator.js.map +1 -1
- package/lib/core.js +2 -0
- package/lib/core.js.map +1 -1
- package/package.json +3 -14
- package/request/innerapi.js +4 -2
- package/request/innerapi.js.map +1 -1
- package/request/interface.js +2 -0
- package/request/interface.js.map +1 -1
- package/request/openapi.js +2 -0
- package/request/openapi.js.map +1 -1
- package/types/types.js +2 -0
- package/types/types.js.map +1 -1
- package/LICENSE.md +0 -0
- package/application/application.ts +0 -40
- package/application/function/function.ts +0 -37
- package/application/impl/common.ts +0 -50
- package/application/impl/impl.ts +0 -48
- package/constants/constants.ts +0 -12
- package/context/context.ts +0 -127
- package/context/db/db.ts +0 -77
- package/context/db/impl/IObject.ts +0 -244
- package/context/db/impl/db.ts +0 -95
- package/context/db/impl/object.ts +0 -628
- package/context/db/impl/oql/ioql.ts +0 -6
- package/context/db/impl/oql/oql.ts +0 -22
- package/context/db/impl/order.ts +0 -16
- package/context/db/impl/propertiesStore.ts +0 -28
- package/context/db/impl/queryBuilder.ts +0 -103
- package/context/db/impl/transaction/index.ts +0 -337
- package/context/db/impl/transaction/operation.ts +0 -72
- package/context/db/impl/transaction.ts +0 -76
- package/context/globalConfig/globalConfig.ts +0 -11
- package/context/metadata/components/common.ts +0 -19
- package/context/metadata/components/components.ts +0 -19
- package/context/metadata/components/desktop/list.ts +0 -457
- package/context/metadata/components/desktop/recordDetail.ts +0 -64
- package/context/metadata/components/mobile/list.ts +0 -176
- package/context/metadata/metadata.ts +0 -175
- package/context/metadata/objects/fields.ts +0 -454
- package/context/metadata/objects/fields.util.ts +0 -360
- package/context/metadata/objects/objects.ts +0 -27
- package/context/metadata/types/common.ts +0 -10
- package/context/metadata/types/components.ts +0 -105
- package/context/metadata/types/objects.ts +0 -251
- package/context/msg/msg.ts +0 -49
- package/context/resources/IResources.ts +0 -73
- package/context/resources/impl/resources.ts +0 -170
- package/context/tasks/tasks.ts +0 -159
- package/data/index.ts +0 -30
- package/hooks/api.ts +0 -341
- package/hooks/hooks.ts +0 -100
- package/kunlun/kunlun.ts +0 -69
- package/kunlun/operator/IOperator.ts +0 -163
- package/kunlun/operator/impl/expression.ts +0 -71
- package/kunlun/operator/impl/logic.ts +0 -595
- package/kunlun/operator/impl/logicV2.ts +0 -254
- package/kunlun/operator/impl/operator.ts +0 -255
- package/kunlun/operator/impl/operatorV2.ts +0 -249
- package/lib/core.ts +0 -4
- package/request/common.ts +0 -91
- package/request/constants.ts +0 -25
- package/request/faasinfra.ts +0 -393
- package/request/innerapi.ts +0 -1645
- package/request/interface.ts +0 -166
- package/request/openapi.ts +0 -1220
- package/types/types.ts +0 -105
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import * as components from './components/components'
|
|
2
|
-
import {BaseFieldType} from "./types/objects";
|
|
3
|
-
import * as common from '@byted-apaas/server-common-node'
|
|
4
|
-
import {RecordDetail} from "./components/desktop/recordDetail";
|
|
5
|
-
import {List as DesktopList} from "./components/desktop/list";
|
|
6
|
-
import {List as MobileList} from "./components/mobile/list";
|
|
7
|
-
import {metadataMap} from "../../data";
|
|
8
|
-
import * as fields from './objects/fields'
|
|
9
|
-
import * as Request from '../../request/interface'
|
|
10
|
-
|
|
11
|
-
const commonExceptions = common.exceptions;
|
|
12
|
-
|
|
13
|
-
// interface ---------------------------------------------------------------------------------------
|
|
14
|
-
|
|
15
|
-
interface IMetaData<mt> {
|
|
16
|
-
/**
|
|
17
|
-
* 操作指定对象的元数据信息
|
|
18
|
-
* @param objectApiName 指定对象的 ApiName
|
|
19
|
-
* @example
|
|
20
|
-
* ```
|
|
21
|
-
* context.metadata.object("test").getFields()
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
object<T extends keyof mt>(objectApiName: T): IKObject<mt[T]>;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
interface IKObject<T> {
|
|
28
|
-
/**
|
|
29
|
-
* 读取对象的字段列表
|
|
30
|
-
*/
|
|
31
|
-
getFields(): Promise<BaseFieldType[]>;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* 读取某字段的元数据信息
|
|
35
|
-
* @param fieldApiName 字段的 ApiName
|
|
36
|
-
*/
|
|
37
|
-
getField<K extends keyof T>(fieldApiName: K): Promise<BaseFieldType>;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
interface IPage {
|
|
41
|
-
getRecordDetail(componentName: string): Promise<RecordDetail>
|
|
42
|
-
|
|
43
|
-
getList(componentName: string): Promise<DesktopList>
|
|
44
|
-
|
|
45
|
-
getId(): Promise<number>
|
|
46
|
-
|
|
47
|
-
getMobileList(componentName: string): Promise<MobileList>
|
|
48
|
-
|
|
49
|
-
updateMobileList(componentName: string, params: any): Promise<void>
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// interface ---------------------------------------------------------------------------------------
|
|
53
|
-
|
|
54
|
-
class MetaData<mt> implements IMetaData<mt> {
|
|
55
|
-
ctx: any;
|
|
56
|
-
|
|
57
|
-
constructor(ctx: any) {
|
|
58
|
-
this.ctx = ctx;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
object<T>(objectApiName: keyof mt): IKObject<T> {
|
|
62
|
-
if (!objectApiName) {
|
|
63
|
-
throw new commonExceptions.InvalidParamError("objectApiName is empty");
|
|
64
|
-
}
|
|
65
|
-
return new KObject<T>(this.ctx, objectApiName as string);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
page(apiName: string, objectApiName: string, type: string): Page {
|
|
69
|
-
if (!apiName) {
|
|
70
|
-
throw new commonExceptions.InvalidParamError("apiName is empty");
|
|
71
|
-
}
|
|
72
|
-
if (!objectApiName) {
|
|
73
|
-
throw new commonExceptions.InvalidParamError("objectApiName is empty");
|
|
74
|
-
}
|
|
75
|
-
if (!type) {
|
|
76
|
-
throw new commonExceptions.InvalidParamError("type is empty");
|
|
77
|
-
}
|
|
78
|
-
return new Page(this.ctx, apiName, objectApiName, type);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function metadata<mt>(ctx: any): IMetaData<mt> {
|
|
83
|
-
return new MetaData<mt>(ctx);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
class KObject<T> implements IKObject<T> {
|
|
87
|
-
private ctx: any;
|
|
88
|
-
private objectApiName: string;
|
|
89
|
-
|
|
90
|
-
constructor(ctx: any, objectApiName: string) {
|
|
91
|
-
this.ctx = ctx;
|
|
92
|
-
this.objectApiName = objectApiName;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
async getFields(): Promise<BaseFieldType[]> {
|
|
96
|
-
let res = await Request.GetInstance().getFields(this.objectApiName);
|
|
97
|
-
return fields.parseFields(res.fields);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
async getField<K extends keyof T>(fieldApiName: K): Promise<BaseFieldType> {
|
|
101
|
-
let res = await Request.GetInstance().getField(this.objectApiName, fieldApiName as string);
|
|
102
|
-
return fields.parseField(res);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
class Page implements IPage {
|
|
107
|
-
ctx: any;
|
|
108
|
-
pageApiName: string;
|
|
109
|
-
objectApiName: string;
|
|
110
|
-
type: 'app' | 'record_page';
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
*
|
|
114
|
-
* @param ctx
|
|
115
|
-
* @param pageApiName: 页面apiName
|
|
116
|
-
* @param objectApiName:对象apiName
|
|
117
|
-
* @param type:app 或 record_page
|
|
118
|
-
*/
|
|
119
|
-
constructor(ctx: any, pageApiName: string, objectApiName: string, type: string) {
|
|
120
|
-
this.ctx = ctx;
|
|
121
|
-
this.pageApiName = pageApiName;
|
|
122
|
-
this.objectApiName = objectApiName;
|
|
123
|
-
this.type = type as any;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
async getRecordDetail(componentName: string): Promise<RecordDetail> {
|
|
127
|
-
// return await openapi.getDesktopRecordDetail(this.ctx, this.pageApiName, componentName, this.objectApiName, this.type);
|
|
128
|
-
return null;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
async getList(componentName: string): Promise<DesktopList> {
|
|
132
|
-
// return await openapi.getDesktopList(this.ctx, this.pageApiName, componentName, this.objectApiName, this.type);
|
|
133
|
-
return null;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
async getId(): Promise<number> {
|
|
137
|
-
// return await openapi.getIdByApiName(this.ctx, this.objectApiName, this.pageApiName, "RecordPage");
|
|
138
|
-
return null;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
async getMobileList(componentName: string): Promise<MobileList> {
|
|
142
|
-
// return await openapi.getMobileList(this.ctx, this.pageApiName, componentName, this.objectApiName, this.type) as any;
|
|
143
|
-
return null;
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
async updateMobileList(componentName: string, params: any): Promise<void> {
|
|
148
|
-
// params.pageApiName = this.pageApiName;
|
|
149
|
-
// params.objectApiName = this.objectApiName;
|
|
150
|
-
// params.componentName = componentName;
|
|
151
|
-
// params.pageType = this.type;
|
|
152
|
-
// return await openapi.updateMobileList(this.ctx, params);
|
|
153
|
-
return null;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
function metaType(): any {
|
|
158
|
-
return {
|
|
159
|
-
pageComponent: {
|
|
160
|
-
desktop: {},
|
|
161
|
-
mobile: {
|
|
162
|
-
List: components.mobile.List,
|
|
163
|
-
},
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
export {
|
|
169
|
-
IMetaData,
|
|
170
|
-
IKObject,
|
|
171
|
-
IPage,
|
|
172
|
-
MetaData,
|
|
173
|
-
metadata,
|
|
174
|
-
metaType,
|
|
175
|
-
}
|
|
@@ -1,454 +0,0 @@
|
|
|
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
|
-
}
|