@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,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.List = void 0;
|
|
4
|
+
const common_1 = require("../../types/common");
|
|
5
|
+
const common_2 = require("../common");
|
|
6
|
+
/*
|
|
7
|
+
titleAreaText: i18n;
|
|
8
|
+
objectApiName: string;
|
|
9
|
+
listItems: {
|
|
10
|
+
avatar: {
|
|
11
|
+
active: boolean;
|
|
12
|
+
fieldApiName: string;
|
|
13
|
+
},
|
|
14
|
+
titleFields: [{
|
|
15
|
+
fieldApiName: string;
|
|
16
|
+
},...]
|
|
17
|
+
tagFields: [{
|
|
18
|
+
fieldApiName: string;
|
|
19
|
+
color: "grey"|"blue"|"cyan"|"green"|"yellow"|"orange"|"red"|"magenta"|"purple"|"blueMagenta";
|
|
20
|
+
},...]
|
|
21
|
+
subtitleFields: [{
|
|
22
|
+
fieldApiName: string;
|
|
23
|
+
hiddenWhenEmpty: boolean;
|
|
24
|
+
},...],
|
|
25
|
+
detailFields: [{
|
|
26
|
+
fieldApiName: string;
|
|
27
|
+
hiddenWhenEmpty: boolean;
|
|
28
|
+
},...]
|
|
29
|
+
};
|
|
30
|
+
filter: {
|
|
31
|
+
conditions: object[];
|
|
32
|
+
logic: string;
|
|
33
|
+
};
|
|
34
|
+
sortConditions: object[];
|
|
35
|
+
*/
|
|
36
|
+
class List extends common_2.Component {
|
|
37
|
+
constructor(params) {
|
|
38
|
+
super(common_2.componentTypes.mobileList);
|
|
39
|
+
// TODO prd缺少
|
|
40
|
+
this.pageApiName = params.pageApiName;
|
|
41
|
+
this.componentName = params.componentName;
|
|
42
|
+
this.pageType = params.pageType; // app | record_page
|
|
43
|
+
this.needPublish = true;
|
|
44
|
+
// TODO check params
|
|
45
|
+
this.titleAreaText = params.titleAreaText;
|
|
46
|
+
this.objectApiName = params.objectApiName;
|
|
47
|
+
this.listItems = params.listItems;
|
|
48
|
+
this.filter = params.filter;
|
|
49
|
+
this.sortConditions = params.sortConditions;
|
|
50
|
+
}
|
|
51
|
+
static parse(input) {
|
|
52
|
+
return {
|
|
53
|
+
pageApiName: input.appApiName,
|
|
54
|
+
componentName: input.componentName,
|
|
55
|
+
titleAreaText: [],
|
|
56
|
+
objectApiName: input.objectApiName,
|
|
57
|
+
listItems: {
|
|
58
|
+
avatar: {},
|
|
59
|
+
titleFields: [],
|
|
60
|
+
tagFields: [],
|
|
61
|
+
subtitleFields: [],
|
|
62
|
+
detailFields: getDetailFields(input),
|
|
63
|
+
},
|
|
64
|
+
filter: getFilter(input),
|
|
65
|
+
sortConditions: [], // TODO 下游缺少
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
getReqParam() {
|
|
69
|
+
let reqParam = {
|
|
70
|
+
appApiName: this.pageApiName,
|
|
71
|
+
componentName: this.componentName,
|
|
72
|
+
objectApiName: this.objectApiName,
|
|
73
|
+
tableColumn: this.getTableColumn(),
|
|
74
|
+
describeFilter: this.getDescribeFilter(),
|
|
75
|
+
pageType: this.pageType,
|
|
76
|
+
needPublish: this.needPublish,
|
|
77
|
+
};
|
|
78
|
+
if (this.getDescribeFilter()) {
|
|
79
|
+
reqParam.describeFilter = this.getDescribeFilter();
|
|
80
|
+
}
|
|
81
|
+
if (this.pageType) {
|
|
82
|
+
reqParam.pageType = this.pageType;
|
|
83
|
+
}
|
|
84
|
+
if (this.needPublish) {
|
|
85
|
+
reqParam.needPublish = this.needPublish;
|
|
86
|
+
}
|
|
87
|
+
return reqParam;
|
|
88
|
+
}
|
|
89
|
+
getTableColumn() {
|
|
90
|
+
if (!this.listItems || !this.listItems.detailFields || !Array.isArray(this.listItems.detailFields)) {
|
|
91
|
+
return [];
|
|
92
|
+
}
|
|
93
|
+
let values = [];
|
|
94
|
+
for (let detailField of this.listItems.detailFields) {
|
|
95
|
+
if (!detailField || !detailField.fieldApiName) {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
values.push({ apiName: detailField.fieldApiName });
|
|
99
|
+
}
|
|
100
|
+
return values;
|
|
101
|
+
}
|
|
102
|
+
getDescribeFilter() {
|
|
103
|
+
if ((0, common_1.isNullOrUndefined)(this.filter)) {
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
try {
|
|
107
|
+
return { filter: JSON.stringify(this.filter) };
|
|
108
|
+
}
|
|
109
|
+
catch (e) {
|
|
110
|
+
// TODO 抛出业务错误
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
exports.List = List;
|
|
116
|
+
function getDetailFields(input) {
|
|
117
|
+
if (!input || !input.tableColumn || !Array.isArray(input.tableColumn)) {
|
|
118
|
+
return [];
|
|
119
|
+
}
|
|
120
|
+
let values = [];
|
|
121
|
+
for (let col of input.tableColumn) {
|
|
122
|
+
if (!col || !col.apiName) {
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
values.push({ fieldApiName: col.apiName });
|
|
126
|
+
}
|
|
127
|
+
return values;
|
|
128
|
+
}
|
|
129
|
+
function getFilter(input) {
|
|
130
|
+
if (!input || !input.describeFilter || (0, common_1.isNullOrUndefined)(input.describeFilter.filter)) {
|
|
131
|
+
return {};
|
|
132
|
+
}
|
|
133
|
+
try {
|
|
134
|
+
let inputFilter = JSON.parse(input.describeFilter.filter);
|
|
135
|
+
return {
|
|
136
|
+
conditions: inputFilter.conditions,
|
|
137
|
+
logic: inputFilter.logic,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
catch (err) {
|
|
141
|
+
return {};
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["list.ts"],"names":[],"mappings":";;;AAOA,+CAA4D;AAC5D,sCAAoD;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,IAAK,SAAQ,kBAAS;IAYxB,YAAY,MAAwB;QAChC,KAAK,CAAC,uBAAc,CAAC,UAAU,CAAC,CAAC;QAEjC,aAAa;QACb,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;QACtC,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC,aAAa,CAAC;QAC1C,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,oBAAoB;QACrD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QAExB,oBAAoB;QACpB,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC,aAAa,CAAC;QAC1C,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC,aAAa,CAAC;QAC1C,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAA2B,CAAC;QACpD,IAAI,CAAC,MAAM,GAAG,MAAM,CAA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AClB,CAAC;AAED,SAAS,SAAS,CAAC,KAA0B;IACzC,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,cAAc,IAAI,IAAA,0BAAiB,EAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE;QACnF,OAAO,EAAsB,CAAC;KACjC;IAED,IAAI;QACA,IAAI,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QAC1D,OAAO;YACH,UAAU,EAAE,WAAW,CAAC,UAAU;YAClC,KAAK,EAAE,WAAW,CAAC,KAAK;SAC3B,CAAA;KACJ;IAAC,OAAO,GAAG,EAAE;QACV,OAAO,EAAsB,CAAC;KACjC;AACL,CAAC"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DeskListDetailField,
|
|
3
|
+
MobileListField,
|
|
4
|
+
MobileListItem,
|
|
5
|
+
UIMetaFilterType,
|
|
6
|
+
UIMetaMobileType
|
|
7
|
+
} from "../../types/components";
|
|
8
|
+
import {I18ns, isNullOrUndefined} from "../../types/common";
|
|
9
|
+
import {Component, componentTypes} from "../common";
|
|
10
|
+
|
|
11
|
+
/*
|
|
12
|
+
titleAreaText: i18n;
|
|
13
|
+
objectApiName: string;
|
|
14
|
+
listItems: {
|
|
15
|
+
avatar: {
|
|
16
|
+
active: boolean;
|
|
17
|
+
fieldApiName: string;
|
|
18
|
+
},
|
|
19
|
+
titleFields: [{
|
|
20
|
+
fieldApiName: string;
|
|
21
|
+
},...]
|
|
22
|
+
tagFields: [{
|
|
23
|
+
fieldApiName: string;
|
|
24
|
+
color: "grey"|"blue"|"cyan"|"green"|"yellow"|"orange"|"red"|"magenta"|"purple"|"blueMagenta";
|
|
25
|
+
},...]
|
|
26
|
+
subtitleFields: [{
|
|
27
|
+
fieldApiName: string;
|
|
28
|
+
hiddenWhenEmpty: boolean;
|
|
29
|
+
},...],
|
|
30
|
+
detailFields: [{
|
|
31
|
+
fieldApiName: string;
|
|
32
|
+
hiddenWhenEmpty: boolean;
|
|
33
|
+
},...]
|
|
34
|
+
};
|
|
35
|
+
filter: {
|
|
36
|
+
conditions: object[];
|
|
37
|
+
logic: string;
|
|
38
|
+
};
|
|
39
|
+
sortConditions: object[];
|
|
40
|
+
*/
|
|
41
|
+
class List extends Component {
|
|
42
|
+
titleAreaText: I18ns;
|
|
43
|
+
objectApiName: string;
|
|
44
|
+
listItems: MobileListItem;
|
|
45
|
+
filter: UIMetaFilterType;
|
|
46
|
+
sortConditions: object[];
|
|
47
|
+
|
|
48
|
+
pageApiName: string;
|
|
49
|
+
componentName: string;
|
|
50
|
+
pageType: ("app" | "record_page");
|
|
51
|
+
needPublish: boolean;
|
|
52
|
+
|
|
53
|
+
constructor(params: UIMetaMobileType) {
|
|
54
|
+
super(componentTypes.mobileList);
|
|
55
|
+
|
|
56
|
+
// TODO prd缺少
|
|
57
|
+
this.pageApiName = params.pageApiName;
|
|
58
|
+
this.componentName = params.componentName;
|
|
59
|
+
this.pageType = params.pageType; // app | record_page
|
|
60
|
+
this.needPublish = true;
|
|
61
|
+
|
|
62
|
+
// TODO check params
|
|
63
|
+
this.titleAreaText = params.titleAreaText;
|
|
64
|
+
this.objectApiName = params.objectApiName;
|
|
65
|
+
this.listItems = params.listItems as MobileListItem;
|
|
66
|
+
this.filter = params.filter;
|
|
67
|
+
this.sortConditions = params.sortConditions;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
static parse(input: Record<string, any>): List {
|
|
71
|
+
return {
|
|
72
|
+
pageApiName: input.appApiName,
|
|
73
|
+
componentName: input.componentName,
|
|
74
|
+
|
|
75
|
+
titleAreaText: [], // TODO 下游缺少
|
|
76
|
+
objectApiName: input.objectApiName,
|
|
77
|
+
listItems: {
|
|
78
|
+
avatar: {} as any, // TODO 下游缺少
|
|
79
|
+
titleFields: [], // TODO 下游缺少
|
|
80
|
+
tagFields: [], // TODO 下游缺少
|
|
81
|
+
subtitleFields: [], // TODO 下游缺少
|
|
82
|
+
detailFields: getDetailFields(input),
|
|
83
|
+
},
|
|
84
|
+
filter: getFilter(input),
|
|
85
|
+
sortConditions: [], // TODO 下游缺少
|
|
86
|
+
} as List;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
getReqParam(): Record<string, any> {
|
|
90
|
+
let reqParam = {
|
|
91
|
+
appApiName: this.pageApiName,
|
|
92
|
+
componentName: this.componentName,
|
|
93
|
+
objectApiName: this.objectApiName,
|
|
94
|
+
tableColumn: this.getTableColumn(),
|
|
95
|
+
describeFilter: this.getDescribeFilter(),
|
|
96
|
+
pageType: this.pageType,
|
|
97
|
+
needPublish: this.needPublish,
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
if (this.getDescribeFilter()) {
|
|
101
|
+
reqParam.describeFilter = this.getDescribeFilter();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (this.pageType) {
|
|
105
|
+
reqParam.pageType = this.pageType;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (this.needPublish) {
|
|
109
|
+
reqParam.needPublish = this.needPublish;
|
|
110
|
+
}
|
|
111
|
+
return reqParam;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
getTableColumn(): { apiName: string }[] {
|
|
115
|
+
if (!this.listItems || !this.listItems.detailFields || !Array.isArray(this.listItems.detailFields)) {
|
|
116
|
+
return [];
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
let values: { apiName: string }[] = [];
|
|
120
|
+
for (let detailField of this.listItems.detailFields) {
|
|
121
|
+
if (!detailField || !detailField.fieldApiName) {
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
values.push({apiName: detailField.fieldApiName});
|
|
125
|
+
}
|
|
126
|
+
return values;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
getDescribeFilter(): { filter: string } {
|
|
130
|
+
if (isNullOrUndefined(this.filter)) {
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
try {
|
|
135
|
+
return {filter: JSON.stringify(this.filter)};
|
|
136
|
+
} catch (e) {
|
|
137
|
+
// TODO 抛出业务错误
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function getDetailFields(input: Record<string, any>): MobileListField[] {
|
|
144
|
+
if (!input || !input.tableColumn || !Array.isArray(input.tableColumn)) {
|
|
145
|
+
return [];
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
let values: MobileListField[] = [];
|
|
149
|
+
for (let col of input.tableColumn) {
|
|
150
|
+
if (!col || !col.apiName) {
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
values.push({fieldApiName: col.apiName});
|
|
154
|
+
}
|
|
155
|
+
return values;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function getFilter(input: Record<string, any>): UIMetaFilterType {
|
|
159
|
+
if (!input || !input.describeFilter || isNullOrUndefined(input.describeFilter.filter)) {
|
|
160
|
+
return {} as UIMetaFilterType;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
try {
|
|
164
|
+
let inputFilter = JSON.parse(input.describeFilter.filter);
|
|
165
|
+
return {
|
|
166
|
+
conditions: inputFilter.conditions,
|
|
167
|
+
logic: inputFilter.logic,
|
|
168
|
+
}
|
|
169
|
+
} catch (err) {
|
|
170
|
+
return {} as UIMetaFilterType;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export {
|
|
175
|
+
List,
|
|
176
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { BaseFieldType } from "./types/objects";
|
|
2
|
+
import { RecordDetail } from "./components/desktop/recordDetail";
|
|
3
|
+
import { List as DesktopList } from "./components/desktop/list";
|
|
4
|
+
import { List as MobileList } from "./components/mobile/list";
|
|
5
|
+
interface IMetaData<mt> {
|
|
6
|
+
/**
|
|
7
|
+
* 操作指定对象的元数据信息
|
|
8
|
+
* @param objectApiName 指定对象的 ApiName
|
|
9
|
+
* @example
|
|
10
|
+
* ```
|
|
11
|
+
* context.metadata.object("test").getFields()
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
object<T extends keyof mt>(objectApiName: T): IKObject<mt[T]>;
|
|
15
|
+
}
|
|
16
|
+
interface IKObject<T> {
|
|
17
|
+
/**
|
|
18
|
+
* 读取对象的字段列表
|
|
19
|
+
*/
|
|
20
|
+
getFields(): Promise<BaseFieldType[]>;
|
|
21
|
+
/**
|
|
22
|
+
* 读取某字段的元数据信息
|
|
23
|
+
* @param fieldApiName 字段的 ApiName
|
|
24
|
+
*/
|
|
25
|
+
getField<K extends keyof T>(fieldApiName: K): Promise<BaseFieldType>;
|
|
26
|
+
}
|
|
27
|
+
interface IPage {
|
|
28
|
+
getRecordDetail(componentName: string): Promise<RecordDetail>;
|
|
29
|
+
getList(componentName: string): Promise<DesktopList>;
|
|
30
|
+
getId(): Promise<number>;
|
|
31
|
+
getMobileList(componentName: string): Promise<MobileList>;
|
|
32
|
+
updateMobileList(componentName: string, params: any): Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
declare class MetaData<mt> implements IMetaData<mt> {
|
|
35
|
+
ctx: any;
|
|
36
|
+
constructor(ctx: any);
|
|
37
|
+
object<T>(objectApiName: keyof mt): IKObject<T>;
|
|
38
|
+
page(apiName: string, objectApiName: string, type: string): Page;
|
|
39
|
+
}
|
|
40
|
+
declare function metadata<mt>(ctx: any): IMetaData<mt>;
|
|
41
|
+
declare class Page implements IPage {
|
|
42
|
+
ctx: any;
|
|
43
|
+
pageApiName: string;
|
|
44
|
+
objectApiName: string;
|
|
45
|
+
type: 'app' | 'record_page';
|
|
46
|
+
/**
|
|
47
|
+
*
|
|
48
|
+
* @param ctx
|
|
49
|
+
* @param pageApiName: 页面apiName
|
|
50
|
+
* @param objectApiName:对象apiName
|
|
51
|
+
* @param type:app 或 record_page
|
|
52
|
+
*/
|
|
53
|
+
constructor(ctx: any, pageApiName: string, objectApiName: string, type: string);
|
|
54
|
+
getRecordDetail(componentName: string): Promise<RecordDetail>;
|
|
55
|
+
getList(componentName: string): Promise<DesktopList>;
|
|
56
|
+
getId(): Promise<number>;
|
|
57
|
+
getMobileList(componentName: string): Promise<MobileList>;
|
|
58
|
+
updateMobileList(componentName: string, params: any): Promise<void>;
|
|
59
|
+
}
|
|
60
|
+
declare function metaType(): any;
|
|
61
|
+
export { IMetaData, IKObject, IPage, MetaData, metadata, metaType, };
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.metaType = exports.metadata = exports.MetaData = void 0;
|
|
4
|
+
const components = require("./components/components");
|
|
5
|
+
const common = require("@byted-apaas/server-common-node");
|
|
6
|
+
const fields = require("./objects/fields");
|
|
7
|
+
const Request = require("../../request/interface");
|
|
8
|
+
const commonExceptions = common.exceptions;
|
|
9
|
+
// interface ---------------------------------------------------------------------------------------
|
|
10
|
+
class MetaData {
|
|
11
|
+
constructor(ctx) {
|
|
12
|
+
this.ctx = ctx;
|
|
13
|
+
}
|
|
14
|
+
object(objectApiName) {
|
|
15
|
+
if (!objectApiName) {
|
|
16
|
+
throw new commonExceptions.InvalidParamError("objectApiName is empty");
|
|
17
|
+
}
|
|
18
|
+
return new KObject(this.ctx, objectApiName);
|
|
19
|
+
}
|
|
20
|
+
page(apiName, objectApiName, type) {
|
|
21
|
+
if (!apiName) {
|
|
22
|
+
throw new commonExceptions.InvalidParamError("apiName is empty");
|
|
23
|
+
}
|
|
24
|
+
if (!objectApiName) {
|
|
25
|
+
throw new commonExceptions.InvalidParamError("objectApiName is empty");
|
|
26
|
+
}
|
|
27
|
+
if (!type) {
|
|
28
|
+
throw new commonExceptions.InvalidParamError("type is empty");
|
|
29
|
+
}
|
|
30
|
+
return new Page(this.ctx, apiName, objectApiName, type);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.MetaData = MetaData;
|
|
34
|
+
function metadata(ctx) {
|
|
35
|
+
return new MetaData(ctx);
|
|
36
|
+
}
|
|
37
|
+
exports.metadata = metadata;
|
|
38
|
+
class KObject {
|
|
39
|
+
constructor(ctx, objectApiName) {
|
|
40
|
+
this.ctx = ctx;
|
|
41
|
+
this.objectApiName = objectApiName;
|
|
42
|
+
}
|
|
43
|
+
async getFields() {
|
|
44
|
+
let res = await Request.GetInstance().getFields(this.objectApiName);
|
|
45
|
+
return fields.parseFields(res.fields);
|
|
46
|
+
}
|
|
47
|
+
async getField(fieldApiName) {
|
|
48
|
+
let res = await Request.GetInstance().getField(this.objectApiName, fieldApiName);
|
|
49
|
+
return fields.parseField(res);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
class Page {
|
|
53
|
+
/**
|
|
54
|
+
*
|
|
55
|
+
* @param ctx
|
|
56
|
+
* @param pageApiName: 页面apiName
|
|
57
|
+
* @param objectApiName:对象apiName
|
|
58
|
+
* @param type:app 或 record_page
|
|
59
|
+
*/
|
|
60
|
+
constructor(ctx, pageApiName, objectApiName, type) {
|
|
61
|
+
this.ctx = ctx;
|
|
62
|
+
this.pageApiName = pageApiName;
|
|
63
|
+
this.objectApiName = objectApiName;
|
|
64
|
+
this.type = type;
|
|
65
|
+
}
|
|
66
|
+
async getRecordDetail(componentName) {
|
|
67
|
+
// return await openapi.getDesktopRecordDetail(this.ctx, this.pageApiName, componentName, this.objectApiName, this.type);
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
async getList(componentName) {
|
|
71
|
+
// return await openapi.getDesktopList(this.ctx, this.pageApiName, componentName, this.objectApiName, this.type);
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
async getId() {
|
|
75
|
+
// return await openapi.getIdByApiName(this.ctx, this.objectApiName, this.pageApiName, "RecordPage");
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
async getMobileList(componentName) {
|
|
79
|
+
// return await openapi.getMobileList(this.ctx, this.pageApiName, componentName, this.objectApiName, this.type) as any;
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
async updateMobileList(componentName, params) {
|
|
83
|
+
// params.pageApiName = this.pageApiName;
|
|
84
|
+
// params.objectApiName = this.objectApiName;
|
|
85
|
+
// params.componentName = componentName;
|
|
86
|
+
// params.pageType = this.type;
|
|
87
|
+
// return await openapi.updateMobileList(this.ctx, params);
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function metaType() {
|
|
92
|
+
return {
|
|
93
|
+
pageComponent: {
|
|
94
|
+
desktop: {},
|
|
95
|
+
mobile: {
|
|
96
|
+
List: components.mobile.List,
|
|
97
|
+
},
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
exports.metaType = metaType;
|
|
102
|
+
//# sourceMappingURL=metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata.js","sourceRoot":"","sources":["metadata.ts"],"names":[],"mappings":";;;AAAA,sDAAqD;AAErD,0DAAyD;AAKzD,2CAA0C;AAC1C,mDAAkD;AAElD,MAAM,gBAAgB,GAAG,MAAM,CAAC,UAAU,CAAC;AAyC3C,oGAAoG;AAEpG,MAAM,QAAQ;IAGV,YAAY,GAAQ;QAChB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACnB,CAAC;IAED,MAAM,CAAI,aAAuB;QAC7B,IAAI,CAAC,aAAa,EAAE;YAChB,MAAM,IAAI,gBAAgB,CAAC,iBAAiB,CAAC,wBAAwB,CAAC,CAAC;SAC1E;QACD,OAAO,IAAI,OAAO,CAAI,IAAI,CAAC,GAAG,EAAE,aAAuB,CAAC,CAAC;IAC7D,CAAC;IAED,IAAI,CAAC,OAAe,EAAE,aAAqB,EAAE,IAAY;QACrD,IAAI,CAAC,OAAO,EAAE;YACV,MAAM,IAAI,gBAAgB,CAAC,iBAAiB,CAAC,kBAAkB,CAAC,CAAC;SACpE;QACD,IAAI,CAAC,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,IAAI,CAAC,IAAI,GAAG,IAAW,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,aAAqB;QACvC,yHAAyH;QACzH,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,aAAqB;QAC/B,iHAAiH;QACjH,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,KAAK,CAAC,KAAK;QACP,qGAAqG;QACrG,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,aAAqB;QACrC,uHAAuH;QACvH,OAAO,IAAI,CAAC;IAEhB,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,aAAqB,EAAE,MAAW;QACrD,yCAAyC;QACzC,6CAA6C;QAC7C,wCAAwC;QACxC,+BAA+B;QAC/B,2DAA2D;QAC3D,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAED,SAAS,QAAQ;IACb,OAAO;QACH,aAAa,EAAE;YACX,OAAO,EAAE,EAAE;YACX,MAAM,EAAE;gBACJ,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,IAAI;aAC/B;SACJ;KACJ,CAAA;AACL,CAAC;AAQG,4BAAQ"}
|
|
@@ -0,0 +1,175 @@
|
|
|
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
|
+
}
|