@byted-apaas/server-sdk-node 0.0.1-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +7 -0
- package/NOTICE +3 -0
- package/README.md +1 -0
- package/application/application.d.ts +27 -0
- package/application/application.js +2 -0
- package/application/application.ts +40 -0
- package/application/function/function.d.ts +14 -0
- package/application/function/function.js +21 -0
- package/application/function/function.ts +37 -0
- package/application/impl/common.d.ts +2 -0
- package/application/impl/common.js +50 -0
- package/application/impl/common.ts +50 -0
- package/application/impl/impl.d.ts +16 -0
- package/application/impl/impl.js +38 -0
- package/application/impl/impl.ts +48 -0
- package/constants/constants.d.ts +10 -0
- package/constants/constants.js +15 -0
- package/constants/constants.ts +15 -0
- package/context/context.d.ts +74 -0
- package/context/context.js +25 -0
- package/context/context.ts +130 -0
- package/context/db/db.d.ts +73 -0
- package/context/db/db.js +4 -0
- package/context/db/db.ts +80 -0
- package/context/db/impl/IObject.d.ts +251 -0
- package/context/db/impl/IObject.js +5 -0
- package/context/db/impl/IObject.ts +247 -0
- package/context/db/impl/db.d.ts +61 -0
- package/context/db/impl/db.js +86 -0
- package/context/db/impl/db.ts +95 -0
- package/context/db/impl/object.d.ts +92 -0
- package/context/db/impl/object.js +524 -0
- package/context/db/impl/object.ts +631 -0
- package/context/db/impl/oql/ioql.d.ts +6 -0
- package/context/db/impl/oql/ioql.js +4 -0
- package/context/db/impl/oql/ioql.ts +9 -0
- package/context/db/impl/oql/oql.d.ts +8 -0
- package/context/db/impl/oql/oql.js +21 -0
- package/context/db/impl/oql/oql.ts +25 -0
- package/context/db/impl/order.d.ts +9 -0
- package/context/db/impl/order.js +15 -0
- package/context/db/impl/order.ts +19 -0
- package/context/db/impl/propertiesStore.d.ts +8 -0
- package/context/db/impl/propertiesStore.js +29 -0
- package/context/db/impl/propertiesStore.ts +31 -0
- package/context/db/impl/queryBuilder.d.ts +29 -0
- package/context/db/impl/queryBuilder.js +78 -0
- package/context/db/impl/queryBuilder.ts +106 -0
- package/context/db/impl/transaction/index.d.ts +20 -0
- package/context/db/impl/transaction/index.js +277 -0
- package/context/db/impl/transaction/index.ts +340 -0
- package/context/db/impl/transaction/operation.d.ts +27 -0
- package/context/db/impl/transaction/operation.js +69 -0
- package/context/db/impl/transaction/operation.ts +72 -0
- package/context/db/impl/transaction.d.ts +67 -0
- package/context/db/impl/transaction.js +4 -0
- package/context/db/impl/transaction.ts +79 -0
- package/context/globalConfig/globalConfig.d.ts +7 -0
- package/context/globalConfig/globalConfig.js +16 -0
- package/context/globalConfig/globalConfig.ts +14 -0
- package/context/metadata/components/common.d.ts +6 -0
- package/context/metadata/components/common.js +17 -0
- package/context/metadata/components/common.ts +22 -0
- package/context/metadata/components/components.d.ts +12 -0
- package/context/metadata/components/components.js +19 -0
- package/context/metadata/components/components.ts +22 -0
- package/context/metadata/components/desktop/list.d.ts +16 -0
- package/context/metadata/components/desktop/list.js +402 -0
- package/context/metadata/components/desktop/list.ts +457 -0
- package/context/metadata/components/desktop/recordDetail.d.ts +11 -0
- package/context/metadata/components/desktop/recordDetail.js +53 -0
- package/context/metadata/components/desktop/recordDetail.ts +67 -0
- package/context/metadata/components/mobile/list.d.ts +24 -0
- package/context/metadata/components/mobile/list.js +145 -0
- package/context/metadata/components/mobile/list.ts +179 -0
- package/context/metadata/metadata.d.ts +61 -0
- package/context/metadata/metadata.js +103 -0
- package/context/metadata/metadata.ts +178 -0
- package/context/metadata/objects/fields.d.ts +130 -0
- package/context/metadata/objects/fields.js +334 -0
- package/context/metadata/objects/fields.ts +457 -0
- package/context/metadata/objects/fields.util.d.ts +40 -0
- package/context/metadata/objects/fields.util.js +319 -0
- package/context/metadata/objects/fields.util.ts +360 -0
- package/context/metadata/objects/objects.d.ts +11 -0
- package/context/metadata/objects/objects.js +20 -0
- package/context/metadata/objects/objects.ts +30 -0
- package/context/metadata/types/common.d.ts +6 -0
- package/context/metadata/types/common.js +9 -0
- package/context/metadata/types/common.ts +13 -0
- package/context/metadata/types/components.d.ts +90 -0
- package/context/metadata/types/components.js +4 -0
- package/context/metadata/types/components.ts +108 -0
- package/context/metadata/types/objects.d.ts +226 -0
- package/context/metadata/types/objects.js +4 -0
- package/context/metadata/types/objects.ts +254 -0
- package/context/msg/msg.d.ts +38 -0
- package/context/msg/msg.js +35 -0
- package/context/msg/msg.ts +52 -0
- package/context/resources/IResources.d.ts +66 -0
- package/context/resources/IResources.js +2 -0
- package/context/resources/IResources.ts +73 -0
- package/context/resources/impl/resources.d.ts +42 -0
- package/context/resources/impl/resources.js +150 -0
- package/context/resources/impl/resources.ts +173 -0
- package/context/tasks/tasks.d.ts +33 -0
- package/context/tasks/tasks.js +139 -0
- package/context/tasks/tasks.ts +159 -0
- package/data/index.d.ts +27 -0
- package/data/index.js +4 -0
- package/data/index.ts +30 -0
- package/hooks/api.d.ts +61 -0
- package/hooks/api.js +327 -0
- package/hooks/api.ts +341 -0
- package/hooks/hooks.d.ts +1 -0
- package/hooks/hooks.js +88 -0
- package/hooks/hooks.ts +100 -0
- package/kunlun/kunlun.d.ts +55 -0
- package/kunlun/kunlun.js +58 -0
- package/kunlun/kunlun.ts +72 -0
- package/kunlun/operator/IOperator.d.ts +158 -0
- package/kunlun/operator/IOperator.js +4 -0
- package/kunlun/operator/IOperator.ts +166 -0
- package/kunlun/operator/impl/expression.d.ts +47 -0
- package/kunlun/operator/impl/expression.js +56 -0
- package/kunlun/operator/impl/expression.ts +74 -0
- package/kunlun/operator/impl/logic.d.ts +50 -0
- package/kunlun/operator/impl/logic.js +509 -0
- package/kunlun/operator/impl/logic.ts +598 -0
- package/kunlun/operator/impl/logicV2.d.ts +58 -0
- package/kunlun/operator/impl/logicV2.js +200 -0
- package/kunlun/operator/impl/logicV2.ts +254 -0
- package/kunlun/operator/impl/operator.d.ts +179 -0
- package/kunlun/operator/impl/operator.js +222 -0
- package/kunlun/operator/impl/operator.ts +258 -0
- package/kunlun/operator/impl/operatorV2.d.ts +180 -0
- package/kunlun/operator/impl/operatorV2.js +216 -0
- package/kunlun/operator/impl/operatorV2.ts +249 -0
- package/lib/core.d.ts +4 -0
- package/lib/core.js +19 -0
- package/lib/core.ts +7 -0
- package/package.json +50 -0
- package/request/common.d.ts +13 -0
- package/request/common.js +87 -0
- package/request/common.ts +91 -0
- package/request/constants.d.ts +10 -0
- package/request/constants.js +25 -0
- package/request/constants.ts +25 -0
- package/request/faasinfra.d.ts +8 -0
- package/request/faasinfra.js +358 -0
- package/request/faasinfra.ts +393 -0
- package/request/innerapi.d.ts +67 -0
- package/request/innerapi.js +1412 -0
- package/request/innerapi.ts +1648 -0
- package/request/interface.d.ts +95 -0
- package/request/interface.js +41 -0
- package/request/interface.ts +169 -0
- package/request/openapi.d.ts +69 -0
- package/request/openapi.js +1014 -0
- package/request/openapi.ts +1223 -0
- package/types/types.d.ts +79 -0
- package/types/types.js +4 -0
- package/types/types.ts +108 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2022 ByteDance Ltd. and/or its affiliates
|
|
3
|
+
// SPDX-License-Identifier: MIT
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.List = void 0;
|
|
6
|
+
const common_1 = require("../../types/common");
|
|
7
|
+
const common_2 = require("../common");
|
|
8
|
+
/*
|
|
9
|
+
titleAreaText: i18n;
|
|
10
|
+
objectApiName: string;
|
|
11
|
+
listItems: {
|
|
12
|
+
avatar: {
|
|
13
|
+
active: boolean;
|
|
14
|
+
fieldApiName: string;
|
|
15
|
+
},
|
|
16
|
+
titleFields: [{
|
|
17
|
+
fieldApiName: string;
|
|
18
|
+
},...]
|
|
19
|
+
tagFields: [{
|
|
20
|
+
fieldApiName: string;
|
|
21
|
+
color: "grey"|"blue"|"cyan"|"green"|"yellow"|"orange"|"red"|"magenta"|"purple"|"blueMagenta";
|
|
22
|
+
},...]
|
|
23
|
+
subtitleFields: [{
|
|
24
|
+
fieldApiName: string;
|
|
25
|
+
hiddenWhenEmpty: boolean;
|
|
26
|
+
},...],
|
|
27
|
+
detailFields: [{
|
|
28
|
+
fieldApiName: string;
|
|
29
|
+
hiddenWhenEmpty: boolean;
|
|
30
|
+
},...]
|
|
31
|
+
};
|
|
32
|
+
filter: {
|
|
33
|
+
conditions: object[];
|
|
34
|
+
logic: string;
|
|
35
|
+
};
|
|
36
|
+
sortConditions: object[];
|
|
37
|
+
*/
|
|
38
|
+
class List extends common_2.Component {
|
|
39
|
+
constructor(params) {
|
|
40
|
+
super(common_2.componentTypes.mobileList);
|
|
41
|
+
// TODO prd缺少
|
|
42
|
+
this.pageApiName = params.pageApiName;
|
|
43
|
+
this.componentName = params.componentName;
|
|
44
|
+
this.pageType = params.pageType; // app | record_page
|
|
45
|
+
this.needPublish = true;
|
|
46
|
+
// TODO check params
|
|
47
|
+
this.titleAreaText = params.titleAreaText;
|
|
48
|
+
this.objectApiName = params.objectApiName;
|
|
49
|
+
this.listItems = params.listItems;
|
|
50
|
+
this.filter = params.filter;
|
|
51
|
+
this.sortConditions = params.sortConditions;
|
|
52
|
+
}
|
|
53
|
+
static parse(input) {
|
|
54
|
+
return {
|
|
55
|
+
pageApiName: input.appApiName,
|
|
56
|
+
componentName: input.componentName,
|
|
57
|
+
titleAreaText: [],
|
|
58
|
+
objectApiName: input.objectApiName,
|
|
59
|
+
listItems: {
|
|
60
|
+
avatar: {},
|
|
61
|
+
titleFields: [],
|
|
62
|
+
tagFields: [],
|
|
63
|
+
subtitleFields: [],
|
|
64
|
+
detailFields: getDetailFields(input),
|
|
65
|
+
},
|
|
66
|
+
filter: getFilter(input),
|
|
67
|
+
sortConditions: [], // TODO 下游缺少
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
getReqParam() {
|
|
71
|
+
let reqParam = {
|
|
72
|
+
appApiName: this.pageApiName,
|
|
73
|
+
componentName: this.componentName,
|
|
74
|
+
objectApiName: this.objectApiName,
|
|
75
|
+
tableColumn: this.getTableColumn(),
|
|
76
|
+
describeFilter: this.getDescribeFilter(),
|
|
77
|
+
pageType: this.pageType,
|
|
78
|
+
needPublish: this.needPublish,
|
|
79
|
+
};
|
|
80
|
+
if (this.getDescribeFilter()) {
|
|
81
|
+
reqParam.describeFilter = this.getDescribeFilter();
|
|
82
|
+
}
|
|
83
|
+
if (this.pageType) {
|
|
84
|
+
reqParam.pageType = this.pageType;
|
|
85
|
+
}
|
|
86
|
+
if (this.needPublish) {
|
|
87
|
+
reqParam.needPublish = this.needPublish;
|
|
88
|
+
}
|
|
89
|
+
return reqParam;
|
|
90
|
+
}
|
|
91
|
+
getTableColumn() {
|
|
92
|
+
if (!this.listItems || !this.listItems.detailFields || !Array.isArray(this.listItems.detailFields)) {
|
|
93
|
+
return [];
|
|
94
|
+
}
|
|
95
|
+
let values = [];
|
|
96
|
+
for (let detailField of this.listItems.detailFields) {
|
|
97
|
+
if (!detailField || !detailField.fieldApiName) {
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
values.push({ apiName: detailField.fieldApiName });
|
|
101
|
+
}
|
|
102
|
+
return values;
|
|
103
|
+
}
|
|
104
|
+
getDescribeFilter() {
|
|
105
|
+
if ((0, common_1.isNullOrUndefined)(this.filter)) {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
try {
|
|
109
|
+
return { filter: JSON.stringify(this.filter) };
|
|
110
|
+
}
|
|
111
|
+
catch (e) {
|
|
112
|
+
// TODO 抛出业务错误
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
exports.List = List;
|
|
118
|
+
function getDetailFields(input) {
|
|
119
|
+
if (!input || !input.tableColumn || !Array.isArray(input.tableColumn)) {
|
|
120
|
+
return [];
|
|
121
|
+
}
|
|
122
|
+
let values = [];
|
|
123
|
+
for (let col of input.tableColumn) {
|
|
124
|
+
if (!col || !col.apiName) {
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
values.push({ fieldApiName: col.apiName });
|
|
128
|
+
}
|
|
129
|
+
return values;
|
|
130
|
+
}
|
|
131
|
+
function getFilter(input) {
|
|
132
|
+
if (!input || !input.describeFilter || (0, common_1.isNullOrUndefined)(input.describeFilter.filter)) {
|
|
133
|
+
return {};
|
|
134
|
+
}
|
|
135
|
+
try {
|
|
136
|
+
let inputFilter = JSON.parse(input.describeFilter.filter);
|
|
137
|
+
return {
|
|
138
|
+
conditions: inputFilter.conditions,
|
|
139
|
+
logic: inputFilter.logic,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
catch (err) {
|
|
143
|
+
return {};
|
|
144
|
+
}
|
|
145
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
// Copyright 2022 ByteDance Ltd. and/or its affiliates
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
DeskListDetailField,
|
|
6
|
+
MobileListField,
|
|
7
|
+
MobileListItem,
|
|
8
|
+
UIMetaFilterType,
|
|
9
|
+
UIMetaMobileType
|
|
10
|
+
} from "../../types/components";
|
|
11
|
+
import {I18ns, isNullOrUndefined} from "../../types/common";
|
|
12
|
+
import {Component, componentTypes} from "../common";
|
|
13
|
+
|
|
14
|
+
/*
|
|
15
|
+
titleAreaText: i18n;
|
|
16
|
+
objectApiName: string;
|
|
17
|
+
listItems: {
|
|
18
|
+
avatar: {
|
|
19
|
+
active: boolean;
|
|
20
|
+
fieldApiName: string;
|
|
21
|
+
},
|
|
22
|
+
titleFields: [{
|
|
23
|
+
fieldApiName: string;
|
|
24
|
+
},...]
|
|
25
|
+
tagFields: [{
|
|
26
|
+
fieldApiName: string;
|
|
27
|
+
color: "grey"|"blue"|"cyan"|"green"|"yellow"|"orange"|"red"|"magenta"|"purple"|"blueMagenta";
|
|
28
|
+
},...]
|
|
29
|
+
subtitleFields: [{
|
|
30
|
+
fieldApiName: string;
|
|
31
|
+
hiddenWhenEmpty: boolean;
|
|
32
|
+
},...],
|
|
33
|
+
detailFields: [{
|
|
34
|
+
fieldApiName: string;
|
|
35
|
+
hiddenWhenEmpty: boolean;
|
|
36
|
+
},...]
|
|
37
|
+
};
|
|
38
|
+
filter: {
|
|
39
|
+
conditions: object[];
|
|
40
|
+
logic: string;
|
|
41
|
+
};
|
|
42
|
+
sortConditions: object[];
|
|
43
|
+
*/
|
|
44
|
+
class List extends Component {
|
|
45
|
+
titleAreaText: I18ns;
|
|
46
|
+
objectApiName: string;
|
|
47
|
+
listItems: MobileListItem;
|
|
48
|
+
filter: UIMetaFilterType;
|
|
49
|
+
sortConditions: object[];
|
|
50
|
+
|
|
51
|
+
pageApiName: string;
|
|
52
|
+
componentName: string;
|
|
53
|
+
pageType: ("app" | "record_page");
|
|
54
|
+
needPublish: boolean;
|
|
55
|
+
|
|
56
|
+
constructor(params: UIMetaMobileType) {
|
|
57
|
+
super(componentTypes.mobileList);
|
|
58
|
+
|
|
59
|
+
// TODO prd缺少
|
|
60
|
+
this.pageApiName = params.pageApiName;
|
|
61
|
+
this.componentName = params.componentName;
|
|
62
|
+
this.pageType = params.pageType; // app | record_page
|
|
63
|
+
this.needPublish = true;
|
|
64
|
+
|
|
65
|
+
// TODO check params
|
|
66
|
+
this.titleAreaText = params.titleAreaText;
|
|
67
|
+
this.objectApiName = params.objectApiName;
|
|
68
|
+
this.listItems = params.listItems as MobileListItem;
|
|
69
|
+
this.filter = params.filter;
|
|
70
|
+
this.sortConditions = params.sortConditions;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
static parse(input: Record<string, any>): List {
|
|
74
|
+
return {
|
|
75
|
+
pageApiName: input.appApiName,
|
|
76
|
+
componentName: input.componentName,
|
|
77
|
+
|
|
78
|
+
titleAreaText: [], // TODO 下游缺少
|
|
79
|
+
objectApiName: input.objectApiName,
|
|
80
|
+
listItems: {
|
|
81
|
+
avatar: {} as any, // TODO 下游缺少
|
|
82
|
+
titleFields: [], // TODO 下游缺少
|
|
83
|
+
tagFields: [], // TODO 下游缺少
|
|
84
|
+
subtitleFields: [], // TODO 下游缺少
|
|
85
|
+
detailFields: getDetailFields(input),
|
|
86
|
+
},
|
|
87
|
+
filter: getFilter(input),
|
|
88
|
+
sortConditions: [], // TODO 下游缺少
|
|
89
|
+
} as List;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
getReqParam(): Record<string, any> {
|
|
93
|
+
let reqParam = {
|
|
94
|
+
appApiName: this.pageApiName,
|
|
95
|
+
componentName: this.componentName,
|
|
96
|
+
objectApiName: this.objectApiName,
|
|
97
|
+
tableColumn: this.getTableColumn(),
|
|
98
|
+
describeFilter: this.getDescribeFilter(),
|
|
99
|
+
pageType: this.pageType,
|
|
100
|
+
needPublish: this.needPublish,
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
if (this.getDescribeFilter()) {
|
|
104
|
+
reqParam.describeFilter = this.getDescribeFilter();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (this.pageType) {
|
|
108
|
+
reqParam.pageType = this.pageType;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (this.needPublish) {
|
|
112
|
+
reqParam.needPublish = this.needPublish;
|
|
113
|
+
}
|
|
114
|
+
return reqParam;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
getTableColumn(): { apiName: string }[] {
|
|
118
|
+
if (!this.listItems || !this.listItems.detailFields || !Array.isArray(this.listItems.detailFields)) {
|
|
119
|
+
return [];
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
let values: { apiName: string }[] = [];
|
|
123
|
+
for (let detailField of this.listItems.detailFields) {
|
|
124
|
+
if (!detailField || !detailField.fieldApiName) {
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
values.push({apiName: detailField.fieldApiName});
|
|
128
|
+
}
|
|
129
|
+
return values;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
getDescribeFilter(): { filter: string } {
|
|
133
|
+
if (isNullOrUndefined(this.filter)) {
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
try {
|
|
138
|
+
return {filter: JSON.stringify(this.filter)};
|
|
139
|
+
} catch (e) {
|
|
140
|
+
// TODO 抛出业务错误
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function getDetailFields(input: Record<string, any>): MobileListField[] {
|
|
147
|
+
if (!input || !input.tableColumn || !Array.isArray(input.tableColumn)) {
|
|
148
|
+
return [];
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
let values: MobileListField[] = [];
|
|
152
|
+
for (let col of input.tableColumn) {
|
|
153
|
+
if (!col || !col.apiName) {
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
values.push({fieldApiName: col.apiName});
|
|
157
|
+
}
|
|
158
|
+
return values;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function getFilter(input: Record<string, any>): UIMetaFilterType {
|
|
162
|
+
if (!input || !input.describeFilter || isNullOrUndefined(input.describeFilter.filter)) {
|
|
163
|
+
return {} as UIMetaFilterType;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
try {
|
|
167
|
+
let inputFilter = JSON.parse(input.describeFilter.filter);
|
|
168
|
+
return {
|
|
169
|
+
conditions: inputFilter.conditions,
|
|
170
|
+
logic: inputFilter.logic,
|
|
171
|
+
}
|
|
172
|
+
} catch (err) {
|
|
173
|
+
return {} as UIMetaFilterType;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export {
|
|
178
|
+
List,
|
|
179
|
+
}
|
|
@@ -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,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2022 ByteDance Ltd. and/or its affiliates
|
|
3
|
+
// SPDX-License-Identifier: MIT
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.metaType = exports.metadata = exports.MetaData = void 0;
|
|
6
|
+
const components = require("./components/components");
|
|
7
|
+
const common = require("@byted-apaas/server-common-node");
|
|
8
|
+
const fields = require("./objects/fields");
|
|
9
|
+
const Request = require("../../request/interface");
|
|
10
|
+
const commonExceptions = common.exceptions;
|
|
11
|
+
// interface ---------------------------------------------------------------------------------------
|
|
12
|
+
class MetaData {
|
|
13
|
+
constructor(ctx) {
|
|
14
|
+
this.ctx = ctx;
|
|
15
|
+
}
|
|
16
|
+
object(objectApiName) {
|
|
17
|
+
if (!objectApiName) {
|
|
18
|
+
throw new commonExceptions.InvalidParamError("objectApiName is empty");
|
|
19
|
+
}
|
|
20
|
+
return new KObject(this.ctx, objectApiName);
|
|
21
|
+
}
|
|
22
|
+
page(apiName, objectApiName, type) {
|
|
23
|
+
if (!apiName) {
|
|
24
|
+
throw new commonExceptions.InvalidParamError("apiName is empty");
|
|
25
|
+
}
|
|
26
|
+
if (!objectApiName) {
|
|
27
|
+
throw new commonExceptions.InvalidParamError("objectApiName is empty");
|
|
28
|
+
}
|
|
29
|
+
if (!type) {
|
|
30
|
+
throw new commonExceptions.InvalidParamError("type is empty");
|
|
31
|
+
}
|
|
32
|
+
return new Page(this.ctx, apiName, objectApiName, type);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.MetaData = MetaData;
|
|
36
|
+
function metadata(ctx) {
|
|
37
|
+
return new MetaData(ctx);
|
|
38
|
+
}
|
|
39
|
+
exports.metadata = metadata;
|
|
40
|
+
class KObject {
|
|
41
|
+
constructor(ctx, objectApiName) {
|
|
42
|
+
this.ctx = ctx;
|
|
43
|
+
this.objectApiName = objectApiName;
|
|
44
|
+
}
|
|
45
|
+
async getFields() {
|
|
46
|
+
let res = await Request.GetInstance().getFields(this.objectApiName);
|
|
47
|
+
return fields.parseFields(res.fields);
|
|
48
|
+
}
|
|
49
|
+
async getField(fieldApiName) {
|
|
50
|
+
let res = await Request.GetInstance().getField(this.objectApiName, fieldApiName);
|
|
51
|
+
return fields.parseField(res);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
class Page {
|
|
55
|
+
/**
|
|
56
|
+
*
|
|
57
|
+
* @param ctx
|
|
58
|
+
* @param pageApiName: 页面apiName
|
|
59
|
+
* @param objectApiName:对象apiName
|
|
60
|
+
* @param type:app 或 record_page
|
|
61
|
+
*/
|
|
62
|
+
constructor(ctx, pageApiName, objectApiName, type) {
|
|
63
|
+
this.ctx = ctx;
|
|
64
|
+
this.pageApiName = pageApiName;
|
|
65
|
+
this.objectApiName = objectApiName;
|
|
66
|
+
this.type = type;
|
|
67
|
+
}
|
|
68
|
+
async getRecordDetail(componentName) {
|
|
69
|
+
// return await openapi.getDesktopRecordDetail(this.ctx, this.pageApiName, componentName, this.objectApiName, this.type);
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
async getList(componentName) {
|
|
73
|
+
// return await openapi.getDesktopList(this.ctx, this.pageApiName, componentName, this.objectApiName, this.type);
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
async getId() {
|
|
77
|
+
// return await openapi.getIdByApiName(this.ctx, this.objectApiName, this.pageApiName, "RecordPage");
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
async getMobileList(componentName) {
|
|
81
|
+
// return await openapi.getMobileList(this.ctx, this.pageApiName, componentName, this.objectApiName, this.type) as any;
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
async updateMobileList(componentName, params) {
|
|
85
|
+
// params.pageApiName = this.pageApiName;
|
|
86
|
+
// params.objectApiName = this.objectApiName;
|
|
87
|
+
// params.componentName = componentName;
|
|
88
|
+
// params.pageType = this.type;
|
|
89
|
+
// return await openapi.updateMobileList(this.ctx, params);
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function metaType() {
|
|
94
|
+
return {
|
|
95
|
+
pageComponent: {
|
|
96
|
+
desktop: {},
|
|
97
|
+
mobile: {
|
|
98
|
+
List: components.mobile.List,
|
|
99
|
+
},
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
exports.metaType = metaType;
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
// Copyright 2022 ByteDance Ltd. and/or its affiliates
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import * as components from './components/components'
|
|
5
|
+
import {BaseFieldType} from "./types/objects";
|
|
6
|
+
import * as common from '@byted-apaas/server-common-node'
|
|
7
|
+
import {RecordDetail} from "./components/desktop/recordDetail";
|
|
8
|
+
import {List as DesktopList} from "./components/desktop/list";
|
|
9
|
+
import {List as MobileList} from "./components/mobile/list";
|
|
10
|
+
import {metadataMap} from "../../data";
|
|
11
|
+
import * as fields from './objects/fields'
|
|
12
|
+
import * as Request from '../../request/interface'
|
|
13
|
+
|
|
14
|
+
const commonExceptions = common.exceptions;
|
|
15
|
+
|
|
16
|
+
// interface ---------------------------------------------------------------------------------------
|
|
17
|
+
|
|
18
|
+
interface IMetaData<mt> {
|
|
19
|
+
/**
|
|
20
|
+
* 操作指定对象的元数据信息
|
|
21
|
+
* @param objectApiName 指定对象的 ApiName
|
|
22
|
+
* @example
|
|
23
|
+
* ```
|
|
24
|
+
* context.metadata.object("test").getFields()
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
object<T extends keyof mt>(objectApiName: T): IKObject<mt[T]>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface IKObject<T> {
|
|
31
|
+
/**
|
|
32
|
+
* 读取对象的字段列表
|
|
33
|
+
*/
|
|
34
|
+
getFields(): Promise<BaseFieldType[]>;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* 读取某字段的元数据信息
|
|
38
|
+
* @param fieldApiName 字段的 ApiName
|
|
39
|
+
*/
|
|
40
|
+
getField<K extends keyof T>(fieldApiName: K): Promise<BaseFieldType>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
interface IPage {
|
|
44
|
+
getRecordDetail(componentName: string): Promise<RecordDetail>
|
|
45
|
+
|
|
46
|
+
getList(componentName: string): Promise<DesktopList>
|
|
47
|
+
|
|
48
|
+
getId(): Promise<number>
|
|
49
|
+
|
|
50
|
+
getMobileList(componentName: string): Promise<MobileList>
|
|
51
|
+
|
|
52
|
+
updateMobileList(componentName: string, params: any): Promise<void>
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// interface ---------------------------------------------------------------------------------------
|
|
56
|
+
|
|
57
|
+
class MetaData<mt> implements IMetaData<mt> {
|
|
58
|
+
ctx: any;
|
|
59
|
+
|
|
60
|
+
constructor(ctx: any) {
|
|
61
|
+
this.ctx = ctx;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
object<T>(objectApiName: keyof mt): IKObject<T> {
|
|
65
|
+
if (!objectApiName) {
|
|
66
|
+
throw new commonExceptions.InvalidParamError("objectApiName is empty");
|
|
67
|
+
}
|
|
68
|
+
return new KObject<T>(this.ctx, objectApiName as string);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
page(apiName: string, objectApiName: string, type: string): Page {
|
|
72
|
+
if (!apiName) {
|
|
73
|
+
throw new commonExceptions.InvalidParamError("apiName is empty");
|
|
74
|
+
}
|
|
75
|
+
if (!objectApiName) {
|
|
76
|
+
throw new commonExceptions.InvalidParamError("objectApiName is empty");
|
|
77
|
+
}
|
|
78
|
+
if (!type) {
|
|
79
|
+
throw new commonExceptions.InvalidParamError("type is empty");
|
|
80
|
+
}
|
|
81
|
+
return new Page(this.ctx, apiName, objectApiName, type);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function metadata<mt>(ctx: any): IMetaData<mt> {
|
|
86
|
+
return new MetaData<mt>(ctx);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
class KObject<T> implements IKObject<T> {
|
|
90
|
+
private ctx: any;
|
|
91
|
+
private objectApiName: string;
|
|
92
|
+
|
|
93
|
+
constructor(ctx: any, objectApiName: string) {
|
|
94
|
+
this.ctx = ctx;
|
|
95
|
+
this.objectApiName = objectApiName;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async getFields(): Promise<BaseFieldType[]> {
|
|
99
|
+
let res = await Request.GetInstance().getFields(this.objectApiName);
|
|
100
|
+
return fields.parseFields(res.fields);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
async getField<K extends keyof T>(fieldApiName: K): Promise<BaseFieldType> {
|
|
104
|
+
let res = await Request.GetInstance().getField(this.objectApiName, fieldApiName as string);
|
|
105
|
+
return fields.parseField(res);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
class Page implements IPage {
|
|
110
|
+
ctx: any;
|
|
111
|
+
pageApiName: string;
|
|
112
|
+
objectApiName: string;
|
|
113
|
+
type: 'app' | 'record_page';
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
*
|
|
117
|
+
* @param ctx
|
|
118
|
+
* @param pageApiName: 页面apiName
|
|
119
|
+
* @param objectApiName:对象apiName
|
|
120
|
+
* @param type:app 或 record_page
|
|
121
|
+
*/
|
|
122
|
+
constructor(ctx: any, pageApiName: string, objectApiName: string, type: string) {
|
|
123
|
+
this.ctx = ctx;
|
|
124
|
+
this.pageApiName = pageApiName;
|
|
125
|
+
this.objectApiName = objectApiName;
|
|
126
|
+
this.type = type as any;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
async getRecordDetail(componentName: string): Promise<RecordDetail> {
|
|
130
|
+
// return await openapi.getDesktopRecordDetail(this.ctx, this.pageApiName, componentName, this.objectApiName, this.type);
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
async getList(componentName: string): Promise<DesktopList> {
|
|
135
|
+
// return await openapi.getDesktopList(this.ctx, this.pageApiName, componentName, this.objectApiName, this.type);
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
async getId(): Promise<number> {
|
|
140
|
+
// return await openapi.getIdByApiName(this.ctx, this.objectApiName, this.pageApiName, "RecordPage");
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
async getMobileList(componentName: string): Promise<MobileList> {
|
|
145
|
+
// return await openapi.getMobileList(this.ctx, this.pageApiName, componentName, this.objectApiName, this.type) as any;
|
|
146
|
+
return null;
|
|
147
|
+
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
async updateMobileList(componentName: string, params: any): Promise<void> {
|
|
151
|
+
// params.pageApiName = this.pageApiName;
|
|
152
|
+
// params.objectApiName = this.objectApiName;
|
|
153
|
+
// params.componentName = componentName;
|
|
154
|
+
// params.pageType = this.type;
|
|
155
|
+
// return await openapi.updateMobileList(this.ctx, params);
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function metaType(): any {
|
|
161
|
+
return {
|
|
162
|
+
pageComponent: {
|
|
163
|
+
desktop: {},
|
|
164
|
+
mobile: {
|
|
165
|
+
List: components.mobile.List,
|
|
166
|
+
},
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export {
|
|
172
|
+
IMetaData,
|
|
173
|
+
IKObject,
|
|
174
|
+
IPage,
|
|
175
|
+
MetaData,
|
|
176
|
+
metadata,
|
|
177
|
+
metaType,
|
|
178
|
+
}
|