@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.
Files changed (129) hide show
  1. package/LICENSE +7 -0
  2. package/NOTICE +3 -0
  3. package/application/impl/impl.js +2 -1
  4. package/application/impl/impl.js.map +1 -1
  5. package/constants/constants.js +2 -0
  6. package/constants/constants.js.map +1 -1
  7. package/context/context.js +2 -0
  8. package/context/context.js.map +1 -1
  9. package/context/db/db.js +2 -0
  10. package/context/db/db.js.map +1 -1
  11. package/context/db/impl/IObject.js +2 -0
  12. package/context/db/impl/IObject.js.map +1 -1
  13. package/context/db/impl/object.js +2 -0
  14. package/context/db/impl/object.js.map +1 -1
  15. package/context/db/impl/oql/ioql.js +2 -0
  16. package/context/db/impl/oql/ioql.js.map +1 -1
  17. package/context/db/impl/oql/oql.js +2 -0
  18. package/context/db/impl/oql/oql.js.map +1 -1
  19. package/context/db/impl/order.js +2 -0
  20. package/context/db/impl/order.js.map +1 -1
  21. package/context/db/impl/propertiesStore.js +2 -0
  22. package/context/db/impl/propertiesStore.js.map +1 -1
  23. package/context/db/impl/queryBuilder.js +2 -0
  24. package/context/db/impl/queryBuilder.js.map +1 -1
  25. package/context/db/impl/transaction/index.js +2 -0
  26. package/context/db/impl/transaction/index.js.map +1 -1
  27. package/context/db/impl/transaction.js +2 -0
  28. package/context/db/impl/transaction.js.map +1 -1
  29. package/context/globalConfig/globalConfig.js +2 -0
  30. package/context/globalConfig/globalConfig.js.map +1 -1
  31. package/context/metadata/components/common.js +2 -0
  32. package/context/metadata/components/common.js.map +1 -1
  33. package/context/metadata/components/components.js +2 -0
  34. package/context/metadata/components/components.js.map +1 -1
  35. package/context/metadata/components/desktop/recordDetail.js +2 -0
  36. package/context/metadata/components/desktop/recordDetail.js.map +1 -1
  37. package/context/metadata/components/mobile/list.js +2 -0
  38. package/context/metadata/components/mobile/list.js.map +1 -1
  39. package/context/metadata/metadata.js +2 -0
  40. package/context/metadata/metadata.js.map +1 -1
  41. package/context/metadata/objects/fields.js +2 -0
  42. package/context/metadata/objects/fields.js.map +1 -1
  43. package/context/metadata/objects/objects.js +2 -0
  44. package/context/metadata/objects/objects.js.map +1 -1
  45. package/context/metadata/types/common.js +2 -0
  46. package/context/metadata/types/common.js.map +1 -1
  47. package/context/metadata/types/components.js +2 -0
  48. package/context/metadata/types/components.js.map +1 -1
  49. package/context/metadata/types/objects.js +2 -0
  50. package/context/metadata/types/objects.js.map +1 -1
  51. package/context/msg/msg.js +2 -0
  52. package/context/msg/msg.js.map +1 -1
  53. package/context/resources/impl/resources.js +2 -0
  54. package/context/resources/impl/resources.js.map +1 -1
  55. package/kunlun/kunlun.js +2 -0
  56. package/kunlun/kunlun.js.map +1 -1
  57. package/kunlun/operator/IOperator.js +2 -0
  58. package/kunlun/operator/IOperator.js.map +1 -1
  59. package/kunlun/operator/impl/expression.js +2 -0
  60. package/kunlun/operator/impl/expression.js.map +1 -1
  61. package/kunlun/operator/impl/logic.js +2 -0
  62. package/kunlun/operator/impl/logic.js.map +1 -1
  63. package/kunlun/operator/impl/operator.js +2 -0
  64. package/kunlun/operator/impl/operator.js.map +1 -1
  65. package/lib/core.js +2 -0
  66. package/lib/core.js.map +1 -1
  67. package/package.json +3 -14
  68. package/request/innerapi.js +4 -2
  69. package/request/innerapi.js.map +1 -1
  70. package/request/interface.js +2 -0
  71. package/request/interface.js.map +1 -1
  72. package/request/openapi.js +2 -0
  73. package/request/openapi.js.map +1 -1
  74. package/types/types.js +2 -0
  75. package/types/types.js.map +1 -1
  76. package/LICENSE.md +0 -0
  77. package/application/application.ts +0 -40
  78. package/application/function/function.ts +0 -37
  79. package/application/impl/common.ts +0 -50
  80. package/application/impl/impl.ts +0 -48
  81. package/constants/constants.ts +0 -12
  82. package/context/context.ts +0 -127
  83. package/context/db/db.ts +0 -77
  84. package/context/db/impl/IObject.ts +0 -244
  85. package/context/db/impl/db.ts +0 -95
  86. package/context/db/impl/object.ts +0 -628
  87. package/context/db/impl/oql/ioql.ts +0 -6
  88. package/context/db/impl/oql/oql.ts +0 -22
  89. package/context/db/impl/order.ts +0 -16
  90. package/context/db/impl/propertiesStore.ts +0 -28
  91. package/context/db/impl/queryBuilder.ts +0 -103
  92. package/context/db/impl/transaction/index.ts +0 -337
  93. package/context/db/impl/transaction/operation.ts +0 -72
  94. package/context/db/impl/transaction.ts +0 -76
  95. package/context/globalConfig/globalConfig.ts +0 -11
  96. package/context/metadata/components/common.ts +0 -19
  97. package/context/metadata/components/components.ts +0 -19
  98. package/context/metadata/components/desktop/list.ts +0 -457
  99. package/context/metadata/components/desktop/recordDetail.ts +0 -64
  100. package/context/metadata/components/mobile/list.ts +0 -176
  101. package/context/metadata/metadata.ts +0 -175
  102. package/context/metadata/objects/fields.ts +0 -454
  103. package/context/metadata/objects/fields.util.ts +0 -360
  104. package/context/metadata/objects/objects.ts +0 -27
  105. package/context/metadata/types/common.ts +0 -10
  106. package/context/metadata/types/components.ts +0 -105
  107. package/context/metadata/types/objects.ts +0 -251
  108. package/context/msg/msg.ts +0 -49
  109. package/context/resources/IResources.ts +0 -73
  110. package/context/resources/impl/resources.ts +0 -170
  111. package/context/tasks/tasks.ts +0 -159
  112. package/data/index.ts +0 -30
  113. package/hooks/api.ts +0 -341
  114. package/hooks/hooks.ts +0 -100
  115. package/kunlun/kunlun.ts +0 -69
  116. package/kunlun/operator/IOperator.ts +0 -163
  117. package/kunlun/operator/impl/expression.ts +0 -71
  118. package/kunlun/operator/impl/logic.ts +0 -595
  119. package/kunlun/operator/impl/logicV2.ts +0 -254
  120. package/kunlun/operator/impl/operator.ts +0 -255
  121. package/kunlun/operator/impl/operatorV2.ts +0 -249
  122. package/lib/core.ts +0 -4
  123. package/request/common.ts +0 -91
  124. package/request/constants.ts +0 -25
  125. package/request/faasinfra.ts +0 -393
  126. package/request/innerapi.ts +0 -1645
  127. package/request/interface.ts +0 -166
  128. package/request/openapi.ts +0 -1220
  129. package/types/types.ts +0 -105
@@ -1,457 +0,0 @@
1
- import * as common from '@byted-apaas/server-common-node'
2
-
3
- const commonUtils = common.utils;
4
-
5
- import {Component, componentTypes} from "../common";
6
- import {
7
- ConcatTextType,
8
- FieldApiType,
9
- UIMetaFilterType,
10
- UIMetaLangType,
11
- UIMetaSortConditionsType,
12
- UIMetaDesktopType, DeskListDetailField, DeskListSubtitleField, DeskListTitleField
13
- } from "../../types/components";
14
- import {I18ns, isNullOrUndefined} from "../../types/common";
15
-
16
- /*
17
- titleAreaText: i18n;
18
- objectApiName: string;
19
- isCompositeType: boolean;
20
- titleFields: [{
21
- fieldApiName: string;
22
- },...]
23
- subtitleFields: [{
24
- type: "field"|"concatText"
25
- fieldApiName: string;
26
- alias: i18n;
27
- concatText: {
28
- zh_CN: [{
29
- dataType: "fieldApiName"|"text"
30
- fieldApiName: string;
31
- text: string;
32
- },...]
33
- en_US: [{
34
- dataType: "fieldApiName"|"text"
35
- fieldApiName: string;
36
- text: string;
37
- },...]
38
- }
39
- },...]
40
- detailFields: [{
41
- fieldApiName: string;
42
- alias: i18n;
43
- },...]
44
- filter: {
45
- conditions: object[];
46
- logic: string;
47
- };
48
- sortConditions: object[];
49
- */
50
-
51
- class List extends Component {
52
- titleAreaText: I18ns;
53
- objectApiName: string;
54
- isCompositeType: boolean;
55
- titleFields: DeskListTitleField[];
56
- subtitleFields: DeskListSubtitleField[];
57
- detailFields: DeskListDetailField[];
58
- filter: UIMetaFilterType;
59
- sortConditions: object[];
60
-
61
- constructor(params: UIMetaDesktopType) {
62
- super(componentTypes.desktopList);
63
-
64
- // TODO check
65
- this.titleAreaText = params.titleAreaText;
66
- this.objectApiName = params.objectApiName;
67
- this.isCompositeType = params.isCompositeType;
68
- this.titleFields = params.titleFields;
69
- this.subtitleFields = params.subtitleFields as any;
70
- this.detailFields = params.detailFields as any;
71
- this.filter = params.filter;
72
- this.sortConditions = params.sortConditions;
73
- }
74
-
75
- static parse(input: Record<string, any>): List {
76
- if (input.dataType === 'object') {
77
- return convertUIMetaListObject(input);
78
- } else if (input.dataType === 'compositeType') {
79
- return convertUIMetaListCompositeType(input);
80
- }
81
- return input as List;
82
- }
83
- }
84
-
85
- function convertUIMetaListObject(input: Record<string, any>): List {
86
- return {
87
- isCompositeType: false,
88
- titleAreaText: input.titleLabel,
89
- objectApiName: input.objectApiName,
90
- titleFields: getListObjectTitleFields(input),
91
- subtitleFields: getListObjectSubtitleFields(input),
92
- detailFields: getListObjectDetailFields(input),
93
- filter: getListFilter(input),
94
- sortConditions: getListSort(input),
95
- } as List;
96
- }
97
-
98
- function convertUIMetaListCompositeType(input: Record<string, any>): List {
99
- return {
100
- isCompositeType: true,
101
- titleAreaText: input.titleLabel,
102
- objectApiName: getListCompositeTypeObjectApiName(input),
103
- titleFields: getListCompositeTypeTitleFields(input),
104
- subtitleFields: getListCompositeTypeSubtitleFields(input),
105
- detailFields: getListCompositeTypeDetailFields(input),
106
- filter: getListCompositeTypeFilter(input),
107
- sortConditions: getListSort(input),
108
- } as List;
109
- }
110
-
111
- function getListObjectTitleFields(input: Record<string, any>): DeskListTitleField[] {
112
- if (!input || isNullOrUndefined(input.title)) {
113
- return [];
114
- }
115
-
116
- let titles: DeskListTitleField[] = [];
117
- try {
118
- let inputTitles = JSON.parse(input.title)
119
- if (!inputTitles || !(inputTitles instanceof Array)) {
120
- return [];
121
- }
122
-
123
- for (let inputTitle of inputTitles) {
124
- titles.push({
125
- fieldApiName: inputTitle.columnApiName,
126
- });
127
- }
128
- } catch (err) {
129
- return [];
130
- }
131
- return titles;
132
- }
133
-
134
- function getListObjectSubtitleFields(input: Record<string, any>): DeskListSubtitleField[] {
135
- if (!input || isNullOrUndefined(input["subTitle"])) {
136
- return [];
137
- }
138
-
139
- let subtitles: DeskListSubtitleField[] = [];
140
-
141
- try {
142
- let inputSubtitles = JSON.parse(input.subTitle)
143
- if (!inputSubtitles || !Array.isArray(inputSubtitles)) {
144
- return [];
145
- }
146
- for (let inputSubtitle of inputSubtitles) {
147
- subtitles.push({
148
- fieldApiName: inputSubtitle.columnApiName,
149
- alias: inputSubtitle.alias,
150
- });
151
- }
152
- } catch (err) {
153
- return [];
154
- }
155
- return subtitles;
156
- }
157
-
158
- function getListObjectDetailFields(input: Record<string, any>): DeskListDetailField[] {
159
- if (!input || isNullOrUndefined(input.detail)) {
160
- return [];
161
- }
162
-
163
- let details: DeskListDetailField[] = [];
164
- try {
165
- let inputDetails = JSON.parse(input.detail)
166
- if (!inputDetails || !Array.isArray(inputDetails)) {
167
- return [];
168
- }
169
-
170
- for (let inputDetail of inputDetails) {
171
- details.push({
172
- fieldApiName: inputDetail.columnApiName,
173
- alias: inputDetail.alias,
174
- });
175
- }
176
- } catch (err) {
177
- return [];
178
- }
179
- return details;
180
- }
181
-
182
- function getListFilter(input: Record<string, any>): UIMetaFilterType {
183
- if (!input || !input.describeFilter || isNullOrUndefined(input.describeFilter.filter)) {
184
- return {} as UIMetaFilterType;
185
- }
186
-
187
- try {
188
- let inputFilter = JSON.parse(input.describeFilter.filter);
189
- if (!inputFilter) {
190
- return {} as UIMetaFilterType;
191
- }
192
- return {
193
- conditions: inputFilter.conditions,
194
- logic: inputFilter.logic,
195
- }
196
- } catch (err) {
197
- return {} as UIMetaFilterType;
198
- }
199
- }
200
-
201
- function getListSort(input: Record<string, any>): UIMetaSortConditionsType[] {
202
- if (!input || !input.sort || !Array.isArray(input.sort)) {
203
- return [];
204
- }
205
-
206
- let sortFields = [];
207
- for (let field of input.sort) {
208
- sortFields.push({
209
- fieldApiName: field.field,
210
- sort: field.direction,
211
- });
212
- }
213
-
214
- return sortFields;
215
- }
216
-
217
-
218
- function getListCompositeTypeObjectApiName(input: Record<string, any>): string {
219
- if (isNullOrUndefined(input)) {
220
- return "";
221
- }
222
-
223
- let objectApiName = getObjectApiNameFromTitle(input);
224
- if (objectApiName) {
225
- return objectApiName;
226
- }
227
-
228
- objectApiName = getObjectApiNameFromSubTitle(input);
229
- if (objectApiName) {
230
- return objectApiName;
231
- }
232
-
233
- objectApiName = getObjectApiNameFromDetail(input);
234
- if (objectApiName) {
235
- return objectApiName;
236
- }
237
-
238
- return "";
239
- }
240
-
241
- function getObjectApiNameFromTitle(input: Record<string, any>): string {
242
- if (!input || isNullOrUndefined(input.title)) {
243
- return "";
244
- }
245
-
246
- try {
247
- return JSON.parse(input.title)[0].picker.fieldPath[0].objectApiName;
248
- } catch (err) {
249
- return "";
250
- }
251
- }
252
-
253
- function getObjectApiNameFromDetail(input: Record<string, any>): string {
254
- if (!input || isNullOrUndefined(input.detail)) {
255
- return "";
256
- }
257
-
258
- try {
259
- return JSON.parse(input.detail)[0].picker.fieldPath[0].objectApiName;
260
- } catch (err) {
261
- return "";
262
- }
263
- }
264
-
265
- function getObjectApiNameFromSubTitle(input: Record<string, any>): string {
266
- if (!input || isNullOrUndefined(input.subTitle)) {
267
- return "";
268
- }
269
-
270
- try {
271
- return JSON.parse(input.subTitle)[0].picker.fieldPath[0].objectApiName;
272
- } catch (err) {
273
- return "";
274
- }
275
- }
276
-
277
- function getListCompositeTypeTitleFields(input: Record<string, any>): FieldApiType[] {
278
- if (!input || isNullOrUndefined(input.title)) {
279
- return [];
280
- }
281
-
282
- let inputFields: FieldApiType[] = [];
283
- try {
284
- let inputTitles = JSON.parse(input.title);
285
- if (!inputTitles || !(inputTitles instanceof Array)) {
286
- return [];
287
- }
288
-
289
- for (let title of inputTitles) {
290
- try {
291
- inputFields.push({
292
- fieldApiName: title.picker.fieldPath[0].fieldApiName,
293
- });
294
- } catch (e) {
295
- continue;
296
- }
297
- }
298
- } catch (err) {
299
- return [];
300
- }
301
- return inputFields;
302
- }
303
-
304
- function parsePrimitive(element: Record<string, any>): FieldApiType {
305
- try {
306
- return {
307
- type: "field",
308
- fieldApiName: element.picker.fieldPath[0].fieldApiName,
309
- alias: [],
310
- concatText: {
311
- zh_CN: [],
312
- en_US: [],
313
- }
314
- }
315
- } catch (e) {
316
- return null;
317
- }
318
- }
319
-
320
-
321
- function getListCompositeTypeSubtitleFields(input: Record<string, any>): FieldApiType[] {
322
- if (!input || isNullOrUndefined(input.subTitle)) {
323
- return [];
324
- }
325
-
326
- let fields: FieldApiType[] = [], subTitle;
327
- try {
328
- subTitle = JSON.parse(input.subTitle);
329
- } catch (err) {
330
- return [];
331
- }
332
-
333
- if (!subTitle || !Array.isArray(subTitle)) {
334
- return [];
335
- }
336
-
337
- for (let element of subTitle) {
338
- let field = null;
339
- if (element.type === 'primitive') {
340
- field = parsePrimitive(element);
341
- } else if (element.type === 'concatenate') {
342
- field = parseConcatenate(element);
343
- }
344
-
345
- if (field) {
346
- fields.push(field);
347
- }
348
- }
349
- return fields;
350
- }
351
-
352
- function getListCompositeTypeDetailFields(input: Record<string, any>): FieldApiType[] {
353
- if (!input || isNullOrUndefined(input.detail)) {
354
- return [];
355
- }
356
-
357
- let fields: FieldApiType[] = [];
358
- try {
359
- let detail = JSON.parse(input.detail);
360
- if (!detail || !(detail instanceof Array)) {
361
- return [];
362
- }
363
- for (let element of detail) {
364
- try {
365
- fields.push({
366
- fieldApiName: element.picker.fieldPath[0].fieldApiName,
367
- alias: [], // TODO
368
- });
369
- } catch (e) {
370
- continue;
371
- }
372
- }
373
- } catch (err) {
374
- return [];
375
- }
376
- return fields;
377
- }
378
-
379
- function getListCompositeTypeFilter(input: Record<string, any>): UIMetaFilterType {
380
- if (!input || !input.describeFilter || isNullOrUndefined(input.describeFilter.filter)) {
381
- return {} as UIMetaFilterType;
382
- }
383
-
384
- try {
385
- let inputFilter = JSON.parse(input.describeFilter.filter);
386
- if (!inputFilter) {
387
- return {} as UIMetaFilterType;
388
- }
389
-
390
- return {
391
- conditions: inputFilter.conditions,
392
- logic: inputFilter.logic,
393
- }
394
- } catch (err) {
395
- return {} as UIMetaFilterType;
396
- }
397
- }
398
-
399
- function parseLangValues(values: Record<string, any>[]): UIMetaLangType[] {
400
- let lang = [];
401
- for (let value of values) {
402
- if (value.type === "text") {
403
- lang.push({
404
- dataType: "text",
405
- fieldApiName: "",
406
- text: value.value,
407
- });
408
- } else if (value.type === "field") {
409
- if (value && value.picker && commonUtils.getArrayLength(value.picker.fieldPath) > 0
410
- && value.picker.fieldPath[0].fieldApiName) {
411
- lang.push({
412
- dataType: "fieldApiName",
413
- fieldApiName: value.picker.fieldPath[0].fieldApiName,
414
- text: ""
415
- });
416
-
417
- }
418
- }
419
- }
420
- return lang;
421
- }
422
-
423
- function parseConcatenate(element: Record<string, any>): FieldApiType {
424
- if (!element || isNullOrUndefined(element.content)) {
425
- return null;
426
- }
427
-
428
- let concatEle: FieldApiType = {
429
- type: "concatText",
430
- fieldApiName: "",
431
- alias: [],
432
- concatText: {
433
- zh_CN: [],
434
- en_US: [],
435
- }
436
- };
437
-
438
- for (let code of Object.keys(element.content)) {
439
- let values = element.content[code];
440
- if (code === "2052") {
441
- concatEle.concatText.zh_CN = parseLangValues(values);
442
- } else if (code === "1033") {
443
- concatEle.concatText.en_US = parseLangValues(values);
444
- }
445
- }
446
-
447
- if (commonUtils.getArrayLength(concatEle.concatText.zh_CN) > 0 ||
448
- commonUtils.getArrayLength(concatEle.concatText.en_US) > 0) {
449
- return concatEle;
450
- }
451
-
452
- return null;
453
- }
454
-
455
- export {
456
- List,
457
- }
@@ -1,64 +0,0 @@
1
- import {Component, componentTypes} from "../common";
2
- import {SelectFieldType} from '../../types/components'
3
- import {I18ns} from "../../types/common";
4
-
5
- /*
6
- titleAreaText: i18n;
7
- objectApiName: string;
8
- selectedFields: [{
9
- fieldPath: [{
10
- objectApiName: string;
11
- fieldApiName: string;
12
- }, ...];
13
- },...]
14
- */
15
-
16
- class RecordDetail extends Component {
17
- titleAreaText: I18ns;
18
- objectApiName: string;
19
- selectedFields: SelectFieldType[];
20
-
21
- constructor(params: Record<string, any>) {
22
- super(componentTypes.desktopRecordDetail);
23
-
24
- // TODO check
25
- this.titleAreaText = params.titleAreaText;
26
- this.objectApiName = params.objectApiName;
27
- this.selectedFields = params.selectedFields;
28
- }
29
-
30
- static parse(input: Record<string, any>): RecordDetail {
31
- return new RecordDetail({
32
- titleAreaText: input.titleLabel,
33
- objectApiName: input.objectApiName,
34
- selectedFields: getSelectedFields(input),
35
- });
36
- }
37
- }
38
-
39
- function getSelectedFields(input: Record<string, any>): SelectFieldType[] {
40
- if (!input || !input.selectedFields || !Array.isArray(input.selectedFields)) {
41
- return [];
42
- }
43
-
44
- let selectedFields = [];
45
- for (let selectedField of input.selectedFields) {
46
- if (!selectedField || !selectedField.picker || !selectedField.picker.fieldPath) {
47
- continue;
48
- }
49
-
50
- let fieldPath = [];
51
- for (let field of selectedField.picker.fieldPath) {
52
- fieldPath.push({
53
- objectApiName: field.objectApiName,
54
- fieldApiName: field.fieldApiName,
55
- });
56
- }
57
- selectedFields.push({fieldPath: fieldPath});
58
- }
59
- return selectedFields;
60
- }
61
-
62
- export {
63
- RecordDetail,
64
- }
@@ -1,176 +0,0 @@
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
- }