@byted-apaas/server-sdk-node 1.1.23 → 1.1.24-beta.0

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 (131) hide show
  1. package/application/application.d.ts +33 -0
  2. package/application/application.js +2 -0
  3. package/application/function/function.d.ts +14 -0
  4. package/application/function/function.js +20 -0
  5. package/application/impl/common.d.ts +2 -0
  6. package/application/impl/common.js +52 -0
  7. package/application/impl/impl.d.ts +19 -0
  8. package/application/impl/impl.js +45 -0
  9. package/common/structs.d.ts +15 -0
  10. package/common/structs.js +21 -0
  11. package/constants/constants.d.ts +13 -0
  12. package/constants/constants.js +18 -0
  13. package/context/context.d.ts +44 -0
  14. package/context/context.js +25 -0
  15. package/context/db/db.d.ts +110 -0
  16. package/context/db/db.js +2 -0
  17. package/context/db/impl/IObject.d.ts +303 -0
  18. package/context/db/impl/IObject.js +5 -0
  19. package/context/db/impl/IObjectV3.d.ts +239 -0
  20. package/context/db/impl/IObjectV3.js +5 -0
  21. package/context/db/impl/db.d.ts +62 -0
  22. package/context/db/impl/db.js +84 -0
  23. package/context/db/impl/dbV3.d.ts +35 -0
  24. package/context/db/impl/dbV3.js +50 -0
  25. package/context/db/impl/object.d.ts +123 -0
  26. package/context/db/impl/object.js +1008 -0
  27. package/context/db/impl/oql/ioql.d.ts +14 -0
  28. package/context/db/impl/oql/ioql.js +4 -0
  29. package/context/db/impl/oql/oql.d.ts +14 -0
  30. package/context/db/impl/oql/oql.js +39 -0
  31. package/context/db/impl/order.d.ts +9 -0
  32. package/context/db/impl/order.js +15 -0
  33. package/context/db/impl/propertiesStore.d.ts +8 -0
  34. package/context/db/impl/propertiesStore.js +29 -0
  35. package/context/db/impl/queryBuilder.d.ts +33 -0
  36. package/context/db/impl/queryBuilder.js +72 -0
  37. package/context/db/impl/transaction/index.d.ts +25 -0
  38. package/context/db/impl/transaction/index.js +300 -0
  39. package/context/db/impl/transaction/operation.d.ts +27 -0
  40. package/context/db/impl/transaction/operation.js +69 -0
  41. package/context/db/impl/transaction.d.ts +70 -0
  42. package/context/db/impl/transaction.js +4 -0
  43. package/context/globalConfig/globalConfig.d.ts +7 -0
  44. package/context/globalConfig/globalConfig.js +16 -0
  45. package/context/integration/IIntegration.d.ts +30 -0
  46. package/context/integration/IIntegration.js +4 -0
  47. package/context/integration/impl/integration.d.ts +16 -0
  48. package/context/integration/impl/integration.js +62 -0
  49. package/context/metadata/components/common.d.ts +6 -0
  50. package/context/metadata/components/common.js +17 -0
  51. package/context/metadata/components/components.d.ts +12 -0
  52. package/context/metadata/components/components.js +19 -0
  53. package/context/metadata/components/desktop/list.d.ts +16 -0
  54. package/context/metadata/components/desktop/list.js +402 -0
  55. package/context/metadata/components/desktop/recordDetail.d.ts +11 -0
  56. package/context/metadata/components/desktop/recordDetail.js +53 -0
  57. package/context/metadata/components/mobile/list.d.ts +24 -0
  58. package/context/metadata/components/mobile/list.js +145 -0
  59. package/context/metadata/metadata.d.ts +63 -0
  60. package/context/metadata/metadata.js +125 -0
  61. package/context/metadata/objects/fields.d.ts +158 -0
  62. package/context/metadata/objects/fields.js +369 -0
  63. package/context/metadata/objects/fields.util.d.ts +52 -0
  64. package/context/metadata/objects/fields.util.js +420 -0
  65. package/context/metadata/objects/fieldsV3.d.ts +159 -0
  66. package/context/metadata/objects/fieldsV3.js +369 -0
  67. package/context/metadata/objects/objects.d.ts +11 -0
  68. package/context/metadata/objects/objects.js +20 -0
  69. package/context/metadata/types/common.d.ts +11 -0
  70. package/context/metadata/types/common.js +33 -0
  71. package/context/metadata/types/components.d.ts +90 -0
  72. package/context/metadata/types/components.js +4 -0
  73. package/context/metadata/types/objects.d.ts +246 -0
  74. package/context/metadata/types/objects.js +4 -0
  75. package/context/metadata/types/objectsV3.d.ts +128 -0
  76. package/context/metadata/types/objectsV3.js +4 -0
  77. package/context/msg/msg.d.ts +38 -0
  78. package/context/msg/msg.js +35 -0
  79. package/context/resources/IResources.d.ts +68 -0
  80. package/context/resources/IResources.js +2 -0
  81. package/context/resources/impl/resources.d.ts +42 -0
  82. package/context/resources/impl/resources.js +161 -0
  83. package/context/tasks/tasks.d.ts +33 -0
  84. package/context/tasks/tasks.js +139 -0
  85. package/data/index.d.ts +27 -0
  86. package/data/index.js +4 -0
  87. package/global/application/flow/flow.d.ts +99 -0
  88. package/global/application/flow/flow.js +8 -0
  89. package/global/application/flow/impl/flow.d.ts +20 -0
  90. package/global/application/flow/impl/flow.js +56 -0
  91. package/global/application/globalVar/globalVar.d.ts +7 -0
  92. package/global/application/globalVar/globalVar.js +2 -0
  93. package/global/global.d.ts +70 -0
  94. package/global/global.js +3 -0
  95. package/hooks/api.d.ts +65 -0
  96. package/hooks/api.js +347 -0
  97. package/hooks/hooks.d.ts +1 -0
  98. package/hooks/hooks.js +107 -0
  99. package/kunlun/kunlun.d.ts +55 -0
  100. package/kunlun/kunlun.js +58 -0
  101. package/kunlun/operator/IOperator.d.ts +158 -0
  102. package/kunlun/operator/IOperator.js +4 -0
  103. package/kunlun/operator/impl/expression.d.ts +75 -0
  104. package/kunlun/operator/impl/expression.js +96 -0
  105. package/kunlun/operator/impl/logic.d.ts +68 -0
  106. package/kunlun/operator/impl/logic.js +573 -0
  107. package/kunlun/operator/impl/logicV2.d.ts +59 -0
  108. package/kunlun/operator/impl/logicV2.js +197 -0
  109. package/kunlun/operator/impl/operator.d.ts +179 -0
  110. package/kunlun/operator/impl/operator.js +222 -0
  111. package/kunlun/operator/impl/operatorV2.d.ts +180 -0
  112. package/kunlun/operator/impl/operatorV2.js +216 -0
  113. package/lib/core.d.ts +4 -0
  114. package/lib/core.js +19 -0
  115. package/package.json +1 -1
  116. package/request/common.d.ts +13 -0
  117. package/request/common.js +88 -0
  118. package/request/constants.d.ts +12 -0
  119. package/request/constants.js +29 -0
  120. package/request/faasinfra.d.ts +8 -0
  121. package/request/faasinfra.js +146 -0
  122. package/request/interface.d.ts +121 -0
  123. package/request/interface.js +30 -0
  124. package/request/openapi.d.ts +84 -0
  125. package/request/openapi.js +1533 -0
  126. package/request/structs.d.ts +99 -0
  127. package/request/structs.js +15 -0
  128. package/types/types.d.ts +79 -0
  129. package/types/types.js +4 -0
  130. package/version/version.d.ts +2 -0
  131. package/version/version.js +8 -0
@@ -0,0 +1,70 @@
1
+ import { _Cond } from '../../../types/types';
2
+ export type ITransactionGetter<T, mt> = T extends {
3
+ 'objectApiName': string;
4
+ } ? ITransaction<mt> : ITransaction<mt> & ITransactionWithCurrentObject<mt>;
5
+ export interface ITransaction<mt> {
6
+ /**
7
+ * 操作指定对象的记录数据
8
+ * @param objectApiName 指定对象的 ApiName
9
+ */
10
+ object<T extends keyof mt>(objectApiName: T): TransactionObject<mt[T]>;
11
+ /**
12
+ * 提交事务
13
+ */
14
+ commit(): Promise<void>;
15
+ /**
16
+ * 用户级鉴权
17
+ */
18
+ useUserAuth(): this;
19
+ /**
20
+ * 系统级鉴权
21
+ */
22
+ useSystemAuth(): this;
23
+ }
24
+ export interface ITransactionWithCurrentObject<mt> {
25
+ }
26
+ export interface TransactionObject<T> {
27
+ /**
28
+ * 注册创建单条记录,返回仅在事务中生效的临时记录 ID,该 ID 将在事务执行完毕后更新为实际记录 ID
29
+ * @param recordMap 用于创建的一条记录
30
+ */
31
+ registerCreate(recordMap: _Cond<T>): {
32
+ _id: string | number;
33
+ };
34
+ /**
35
+ * 注册删除单条记录
36
+ * @param recordID 用于删除的一条记录的 ID
37
+ */
38
+ registerDelete(recordID: (string | number)): void;
39
+ /**
40
+ * 注册删除单条记录
41
+ * @param record 用于删除的一条完整记录
42
+ */
43
+ registerDelete(record: _Cond<T>): void;
44
+ /**
45
+ * 注册更新单条记录
46
+ * @param recordMap 用于更新的一条记录,需对 _id 赋值
47
+ */
48
+ registerUpdate(recordMap: _Cond<T>): void;
49
+ /**
50
+ * 注册更新单条记录
51
+ * @param _id 主键
52
+ * @param recordMap 用于更新的一条记录
53
+ */
54
+ registerUpdate(_id: (string | number), recordMap: _Cond<T>): void;
55
+ /**
56
+ * 注册批量创建记录,返回仅在事务中生效的临时记录 ID 数组,该 ID 将在事务执行完毕后更新为实际记录 ID
57
+ * @param recordMaps 用于批量创建的一批记录
58
+ */
59
+ registerBatchCreate(recordMaps: _Cond<T>[]): (string | number)[];
60
+ /**
61
+ * 注册批量删除记录
62
+ * @param recordIDs 用于删除的一批记录的 ID or 完整记录
63
+ */
64
+ registerBatchDelete(recordIDs: (string | number | _Cond<T>)[]): void;
65
+ /**
66
+ * 注册批量更新记录
67
+ * @param recordMaps 用于更新的一批记录,需对每个记录的 _id 赋值
68
+ */
69
+ registerBatchUpdate(recordMaps: _Cond<T>[]): void;
70
+ }
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ // Copyright 2022 ByteDance Ltd. and/or its affiliates
3
+ // SPDX-License-Identifier: MIT
4
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ export declare class GlobalConfig {
2
+ /**
3
+ * 根据 key 获取对应的全局变量
4
+ * @param key 全局变量的 key
5
+ */
6
+ getVar<valueT>(key: string): Promise<valueT>;
7
+ }
@@ -0,0 +1,16 @@
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.GlobalConfig = void 0;
6
+ const Request = require("../../request/interface");
7
+ class GlobalConfig {
8
+ /**
9
+ * 根据 key 获取对应的全局变量
10
+ * @param key 全局变量的 key
11
+ */
12
+ async getVar(key) {
13
+ return await Request.GetInstance().getGlobalConfigByKey(key);
14
+ }
15
+ }
16
+ exports.GlobalConfig = GlobalConfig;
@@ -0,0 +1,30 @@
1
+ export type AppAccessToken = {
2
+ expire: number;
3
+ appAccessToken: string;
4
+ appId: string;
5
+ };
6
+ export type TenantAccessToken = {
7
+ expire: number;
8
+ tenantAccessToken: string;
9
+ appId: string;
10
+ };
11
+ export interface _IIntegration {
12
+ /**
13
+ * 获取飞书集成 app access token
14
+ * @param apiName 飞书集成的 API Name
15
+ */
16
+ getAppAccessToken(apiName: string): Promise<AppAccessToken>;
17
+ /**
18
+ * 获取飞书集成 tenant access token
19
+ * @param apiName 飞书集成的 API Name
20
+ */
21
+ getTenantAccessToken(apiName: string): Promise<TenantAccessToken>;
22
+ /**
23
+ * 获取默认飞书集成 app access token
24
+ */
25
+ getDefaultAppAccessToken(): Promise<AppAccessToken>;
26
+ /**
27
+ * 获取默认飞书集成 tenant access token
28
+ */
29
+ getDefaultTenantAccessToken(): Promise<TenantAccessToken>;
30
+ }
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ // Copyright 2022 ByteDance Ltd. and/or its affiliates
3
+ // SPDX-License-Identifier: MIT
4
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,16 @@
1
+ import { _IIntegration, AppAccessToken, TenantAccessToken } from '../IIntegration';
2
+ import { AppCtx } from '../../../application/application';
3
+ export declare class _OpenSDKIntegration implements _IIntegration {
4
+ appCtx: AppCtx;
5
+ constructor(appCtx: AppCtx);
6
+ getAppAccessToken(apiName: string): Promise<AppAccessToken>;
7
+ getDefaultAppAccessToken(): Promise<AppAccessToken>;
8
+ getDefaultTenantAccessToken(): Promise<TenantAccessToken>;
9
+ getTenantAccessToken(apiName: string): Promise<TenantAccessToken>;
10
+ }
11
+ export declare class _Integration implements _IIntegration {
12
+ getAppAccessToken(apiName: string): Promise<AppAccessToken>;
13
+ getDefaultAppAccessToken(): Promise<AppAccessToken>;
14
+ getDefaultTenantAccessToken(): Promise<TenantAccessToken>;
15
+ getTenantAccessToken(apiName: string): Promise<TenantAccessToken>;
16
+ }
@@ -0,0 +1,62 @@
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._Integration = exports._OpenSDKIntegration = void 0;
6
+ const common = require("@byted-apaas/server-common-node");
7
+ const common_1 = require("../../../application/impl/common");
8
+ const Request = require("../../../request/interface");
9
+ const exceptions = common.exceptions;
10
+ class _OpenSDKIntegration {
11
+ constructor(appCtx) {
12
+ this.appCtx = appCtx;
13
+ }
14
+ async getAppAccessToken(apiName) {
15
+ if (!apiName) {
16
+ throw new exceptions.InvalidParamError(`apiName is null`);
17
+ }
18
+ return await (0, common_1.runCtxForOpenSDK)(this.appCtx, async () => {
19
+ return await Request.GetInstance().getIntegrationAppAccessToken(apiName);
20
+ });
21
+ }
22
+ async getDefaultAppAccessToken() {
23
+ return await (0, common_1.runCtxForOpenSDK)(this.appCtx, async () => {
24
+ return await Request.GetInstance().getDefaultIntegrationAppAccessToken();
25
+ });
26
+ }
27
+ async getDefaultTenantAccessToken() {
28
+ return await (0, common_1.runCtxForOpenSDK)(this.appCtx, async () => {
29
+ return await Request.GetInstance().getDefaultIntegrationTenantAccessToken();
30
+ });
31
+ }
32
+ async getTenantAccessToken(apiName) {
33
+ if (!apiName) {
34
+ throw new exceptions.InvalidParamError(`apiName is null`);
35
+ }
36
+ return await (0, common_1.runCtxForOpenSDK)(this.appCtx, async () => {
37
+ return await Request.GetInstance().getIntegrationTenantAccessToken(apiName);
38
+ });
39
+ }
40
+ }
41
+ exports._OpenSDKIntegration = _OpenSDKIntegration;
42
+ class _Integration {
43
+ async getAppAccessToken(apiName) {
44
+ if (!apiName) {
45
+ throw new exceptions.InvalidParamError(`apiName is null`);
46
+ }
47
+ return await Request.GetInstance().getIntegrationAppAccessToken(apiName);
48
+ }
49
+ async getDefaultAppAccessToken() {
50
+ return await Request.GetInstance().getDefaultIntegrationAppAccessToken();
51
+ }
52
+ async getDefaultTenantAccessToken() {
53
+ return await Request.GetInstance().getDefaultIntegrationTenantAccessToken();
54
+ }
55
+ async getTenantAccessToken(apiName) {
56
+ if (!apiName) {
57
+ throw new exceptions.InvalidParamError(`apiName is null`);
58
+ }
59
+ return await Request.GetInstance().getIntegrationTenantAccessToken(apiName);
60
+ }
61
+ }
62
+ exports._Integration = _Integration;
@@ -0,0 +1,6 @@
1
+ declare const componentTypes: Record<string, string>;
2
+ declare class Component {
3
+ private type;
4
+ constructor(type: string);
5
+ }
6
+ export { Component, componentTypes, };
@@ -0,0 +1,17 @@
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.componentTypes = exports.Component = void 0;
6
+ const componentTypes = {
7
+ desktopList: 'desktopList',
8
+ desktopRecordDetail: 'desktopRecordDetail',
9
+ mobileList: 'mobileList',
10
+ };
11
+ exports.componentTypes = componentTypes;
12
+ class Component {
13
+ constructor(type) {
14
+ this.type = type;
15
+ }
16
+ }
17
+ exports.Component = Component;
@@ -0,0 +1,12 @@
1
+ import { Component } from './common';
2
+ import { RecordDetail as DesktopRecordDetail } from './desktop/recordDetail';
3
+ import { List as DesktopList } from './desktop/list';
4
+ import { List as MobileList } from './mobile/list';
5
+ declare const desktop: {
6
+ RecordDetail: typeof DesktopRecordDetail;
7
+ List: typeof DesktopList;
8
+ };
9
+ declare const mobile: {
10
+ List: typeof MobileList;
11
+ };
12
+ export { Component, desktop, mobile, };
@@ -0,0 +1,19 @@
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.mobile = exports.desktop = exports.Component = void 0;
6
+ const common_1 = require("./common");
7
+ Object.defineProperty(exports, "Component", { enumerable: true, get: function () { return common_1.Component; } });
8
+ const recordDetail_1 = require("./desktop/recordDetail");
9
+ const list_1 = require("./desktop/list");
10
+ const list_2 = require("./mobile/list");
11
+ const desktop = {
12
+ RecordDetail: recordDetail_1.RecordDetail,
13
+ List: list_1.List,
14
+ };
15
+ exports.desktop = desktop;
16
+ const mobile = {
17
+ List: list_2.List,
18
+ };
19
+ exports.mobile = mobile;
@@ -0,0 +1,16 @@
1
+ import { Component } from '../common';
2
+ import { UIMetaFilterType, UIMetaDesktopType, DeskListDetailField, DeskListSubtitleField, DeskListTitleField } from '../../types/components';
3
+ import { I18ns } from '../../types/common';
4
+ declare class List extends Component {
5
+ titleAreaText: I18ns;
6
+ objectApiName: string;
7
+ isCompositeType: boolean;
8
+ titleFields: DeskListTitleField[];
9
+ subtitleFields: DeskListSubtitleField[];
10
+ detailFields: DeskListDetailField[];
11
+ filter: UIMetaFilterType;
12
+ sortConditions: object[];
13
+ constructor(params: UIMetaDesktopType);
14
+ static parse(input: Record<string, any>): List;
15
+ }
16
+ export { List, };
@@ -0,0 +1,402 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.List = void 0;
4
+ const common = require("@byted-apaas/server-common-node");
5
+ const commonUtils = common.utils;
6
+ const common_1 = require("../common");
7
+ const common_2 = require("../../types/common");
8
+ /*
9
+ titleAreaText: i18n;
10
+ objectApiName: string;
11
+ isCompositeType: boolean;
12
+ titleFields: [{
13
+ fieldApiName: string;
14
+ },...]
15
+ subtitleFields: [{
16
+ type: 'field'|'concatText'
17
+ fieldApiName: string;
18
+ alias: i18n;
19
+ concatText: {
20
+ zh_CN: [{
21
+ dataType: 'fieldApiName'|'text'
22
+ fieldApiName: string;
23
+ text: string;
24
+ },...]
25
+ en_US: [{
26
+ dataType: 'fieldApiName'|'text'
27
+ fieldApiName: string;
28
+ text: string;
29
+ },...]
30
+ }
31
+ },...]
32
+ detailFields: [{
33
+ fieldApiName: string;
34
+ alias: i18n;
35
+ },...]
36
+ filter: {
37
+ conditions: object[];
38
+ logic: string;
39
+ };
40
+ sortConditions: object[];
41
+ */
42
+ class List extends common_1.Component {
43
+ constructor(params) {
44
+ super(common_1.componentTypes.desktopList);
45
+ // TODO check
46
+ this.titleAreaText = params.titleAreaText;
47
+ this.objectApiName = params.objectApiName;
48
+ this.isCompositeType = params.isCompositeType;
49
+ this.titleFields = params.titleFields;
50
+ this.subtitleFields = params.subtitleFields;
51
+ this.detailFields = params.detailFields;
52
+ this.filter = params.filter;
53
+ this.sortConditions = params.sortConditions;
54
+ }
55
+ static parse(input) {
56
+ if (input.dataType === 'object') {
57
+ return convertUIMetaListObject(input);
58
+ }
59
+ else if (input.dataType === 'compositeType') {
60
+ return convertUIMetaListCompositeType(input);
61
+ }
62
+ return input;
63
+ }
64
+ }
65
+ exports.List = List;
66
+ function convertUIMetaListObject(input) {
67
+ return {
68
+ isCompositeType: false,
69
+ titleAreaText: input.titleLabel,
70
+ objectApiName: input.objectApiName,
71
+ titleFields: getListObjectTitleFields(input),
72
+ subtitleFields: getListObjectSubtitleFields(input),
73
+ detailFields: getListObjectDetailFields(input),
74
+ filter: getListFilter(input),
75
+ sortConditions: getListSort(input),
76
+ };
77
+ }
78
+ function convertUIMetaListCompositeType(input) {
79
+ return {
80
+ isCompositeType: true,
81
+ titleAreaText: input.titleLabel,
82
+ objectApiName: getListCompositeTypeObjectApiName(input),
83
+ titleFields: getListCompositeTypeTitleFields(input),
84
+ subtitleFields: getListCompositeTypeSubtitleFields(input),
85
+ detailFields: getListCompositeTypeDetailFields(input),
86
+ filter: getListCompositeTypeFilter(input),
87
+ sortConditions: getListSort(input),
88
+ };
89
+ }
90
+ function getListObjectTitleFields(input) {
91
+ if (!input || (0, common_2.isNullOrUndefined)(input.title)) {
92
+ return [];
93
+ }
94
+ let titles = [];
95
+ try {
96
+ let inputTitles = JSON.parse(input.title);
97
+ if (!inputTitles || !(inputTitles instanceof Array)) {
98
+ return [];
99
+ }
100
+ for (let inputTitle of inputTitles) {
101
+ titles.push({
102
+ fieldApiName: inputTitle.columnApiName,
103
+ });
104
+ }
105
+ }
106
+ catch (err) {
107
+ return [];
108
+ }
109
+ return titles;
110
+ }
111
+ function getListObjectSubtitleFields(input) {
112
+ if (!input || (0, common_2.isNullOrUndefined)(input.subTitle)) {
113
+ return [];
114
+ }
115
+ let subtitles = [];
116
+ try {
117
+ let inputSubtitles = JSON.parse(input.subTitle);
118
+ if (!inputSubtitles || !Array.isArray(inputSubtitles)) {
119
+ return [];
120
+ }
121
+ for (let inputSubtitle of inputSubtitles) {
122
+ subtitles.push({
123
+ fieldApiName: inputSubtitle.columnApiName,
124
+ alias: inputSubtitle.alias,
125
+ });
126
+ }
127
+ }
128
+ catch (err) {
129
+ return [];
130
+ }
131
+ return subtitles;
132
+ }
133
+ function getListObjectDetailFields(input) {
134
+ if (!input || (0, common_2.isNullOrUndefined)(input.detail)) {
135
+ return [];
136
+ }
137
+ let details = [];
138
+ try {
139
+ let inputDetails = JSON.parse(input.detail);
140
+ if (!inputDetails || !Array.isArray(inputDetails)) {
141
+ return [];
142
+ }
143
+ for (let inputDetail of inputDetails) {
144
+ details.push({
145
+ fieldApiName: inputDetail.columnApiName,
146
+ alias: inputDetail.alias,
147
+ });
148
+ }
149
+ }
150
+ catch (err) {
151
+ return [];
152
+ }
153
+ return details;
154
+ }
155
+ function getListFilter(input) {
156
+ if (!input || !input.describeFilter || (0, common_2.isNullOrUndefined)(input.describeFilter.filter)) {
157
+ return {};
158
+ }
159
+ try {
160
+ let inputFilter = JSON.parse(input.describeFilter.filter);
161
+ if (!inputFilter) {
162
+ return {};
163
+ }
164
+ return {
165
+ conditions: inputFilter.conditions,
166
+ logic: inputFilter.logic,
167
+ };
168
+ }
169
+ catch (err) {
170
+ return {};
171
+ }
172
+ }
173
+ function getListSort(input) {
174
+ if (!input || !input.sort || !Array.isArray(input.sort)) {
175
+ return [];
176
+ }
177
+ let sortFields = [];
178
+ for (let field of input.sort) {
179
+ sortFields.push({
180
+ fieldApiName: field.field,
181
+ sort: field.direction,
182
+ });
183
+ }
184
+ return sortFields;
185
+ }
186
+ function getListCompositeTypeObjectApiName(input) {
187
+ if ((0, common_2.isNullOrUndefined)(input)) {
188
+ return '';
189
+ }
190
+ let objectApiName = getObjectApiNameFromTitle(input);
191
+ if (objectApiName) {
192
+ return objectApiName;
193
+ }
194
+ objectApiName = getObjectApiNameFromSubTitle(input);
195
+ if (objectApiName) {
196
+ return objectApiName;
197
+ }
198
+ objectApiName = getObjectApiNameFromDetail(input);
199
+ if (objectApiName) {
200
+ return objectApiName;
201
+ }
202
+ return '';
203
+ }
204
+ function getObjectApiNameFromTitle(input) {
205
+ if (!input || (0, common_2.isNullOrUndefined)(input.title)) {
206
+ return '';
207
+ }
208
+ try {
209
+ return JSON.parse(input.title)[0].picker.fieldPath[0].objectApiName;
210
+ }
211
+ catch (err) {
212
+ return '';
213
+ }
214
+ }
215
+ function getObjectApiNameFromDetail(input) {
216
+ if (!input || (0, common_2.isNullOrUndefined)(input.detail)) {
217
+ return '';
218
+ }
219
+ try {
220
+ return JSON.parse(input.detail)[0].picker.fieldPath[0].objectApiName;
221
+ }
222
+ catch (err) {
223
+ return '';
224
+ }
225
+ }
226
+ function getObjectApiNameFromSubTitle(input) {
227
+ if (!input || (0, common_2.isNullOrUndefined)(input.subTitle)) {
228
+ return '';
229
+ }
230
+ try {
231
+ return JSON.parse(input.subTitle)[0].picker.fieldPath[0].objectApiName;
232
+ }
233
+ catch (err) {
234
+ return '';
235
+ }
236
+ }
237
+ function getListCompositeTypeTitleFields(input) {
238
+ if (!input || (0, common_2.isNullOrUndefined)(input.title)) {
239
+ return [];
240
+ }
241
+ let inputFields = [];
242
+ try {
243
+ let inputTitles = JSON.parse(input.title);
244
+ if (!inputTitles || !(inputTitles instanceof Array)) {
245
+ return [];
246
+ }
247
+ for (let title of inputTitles) {
248
+ try {
249
+ inputFields.push({
250
+ fieldApiName: title.picker.fieldPath[0].fieldApiName,
251
+ });
252
+ }
253
+ catch (e) {
254
+ continue;
255
+ }
256
+ }
257
+ }
258
+ catch (err) {
259
+ return [];
260
+ }
261
+ return inputFields;
262
+ }
263
+ function parsePrimitive(element) {
264
+ try {
265
+ return {
266
+ type: 'field',
267
+ fieldApiName: element.picker.fieldPath[0].fieldApiName,
268
+ alias: [],
269
+ concatText: {
270
+ zh_CN: [],
271
+ en_US: [],
272
+ }
273
+ };
274
+ }
275
+ catch (e) {
276
+ return null;
277
+ }
278
+ }
279
+ function getListCompositeTypeSubtitleFields(input) {
280
+ if (!input || (0, common_2.isNullOrUndefined)(input.subTitle)) {
281
+ return [];
282
+ }
283
+ let fields = [], subTitle;
284
+ try {
285
+ subTitle = JSON.parse(input.subTitle);
286
+ }
287
+ catch (err) {
288
+ return [];
289
+ }
290
+ if (!subTitle || !Array.isArray(subTitle)) {
291
+ return [];
292
+ }
293
+ for (let element of subTitle) {
294
+ let field = null;
295
+ if (element.type === 'primitive') {
296
+ field = parsePrimitive(element);
297
+ }
298
+ else if (element.type === 'concatenate') {
299
+ field = parseConcatenate(element);
300
+ }
301
+ if (field) {
302
+ fields.push(field);
303
+ }
304
+ }
305
+ return fields;
306
+ }
307
+ function getListCompositeTypeDetailFields(input) {
308
+ if (!input || (0, common_2.isNullOrUndefined)(input.detail)) {
309
+ return [];
310
+ }
311
+ let fields = [];
312
+ try {
313
+ let detail = JSON.parse(input.detail);
314
+ if (!detail || !(detail instanceof Array)) {
315
+ return [];
316
+ }
317
+ for (let element of detail) {
318
+ try {
319
+ fields.push({
320
+ fieldApiName: element.picker.fieldPath[0].fieldApiName,
321
+ alias: [], // TODO
322
+ });
323
+ }
324
+ catch (e) {
325
+ continue;
326
+ }
327
+ }
328
+ }
329
+ catch (err) {
330
+ return [];
331
+ }
332
+ return fields;
333
+ }
334
+ function getListCompositeTypeFilter(input) {
335
+ if (!input || !input.describeFilter || (0, common_2.isNullOrUndefined)(input.describeFilter.filter)) {
336
+ return {};
337
+ }
338
+ try {
339
+ let inputFilter = JSON.parse(input.describeFilter.filter);
340
+ if (!inputFilter) {
341
+ return {};
342
+ }
343
+ return {
344
+ conditions: inputFilter.conditions,
345
+ logic: inputFilter.logic,
346
+ };
347
+ }
348
+ catch (err) {
349
+ return {};
350
+ }
351
+ }
352
+ function parseLangValues(values) {
353
+ let lang = [];
354
+ for (let value of values) {
355
+ if (value.type === 'text') {
356
+ lang.push({
357
+ dataType: 'text',
358
+ fieldApiName: '',
359
+ text: value.value,
360
+ });
361
+ }
362
+ else if (value.type === 'field') {
363
+ if (value && value.picker && commonUtils.getArrayLength(value.picker.fieldPath) > 0
364
+ && value.picker.fieldPath[0].fieldApiName) {
365
+ lang.push({
366
+ dataType: 'fieldApiName',
367
+ fieldApiName: value.picker.fieldPath[0].fieldApiName,
368
+ text: '',
369
+ });
370
+ }
371
+ }
372
+ }
373
+ return lang;
374
+ }
375
+ function parseConcatenate(element) {
376
+ if (!element || (0, common_2.isNullOrUndefined)(element.content)) {
377
+ return null;
378
+ }
379
+ let concatEle = {
380
+ type: 'concatText',
381
+ fieldApiName: '',
382
+ alias: [],
383
+ concatText: {
384
+ zh_CN: [],
385
+ en_US: [],
386
+ }
387
+ };
388
+ for (let code of Object.keys(element.content)) {
389
+ let values = element.content[code];
390
+ if (code === '2052') {
391
+ concatEle.concatText.zh_CN = parseLangValues(values);
392
+ }
393
+ else if (code === '1033') {
394
+ concatEle.concatText.en_US = parseLangValues(values);
395
+ }
396
+ }
397
+ if (commonUtils.getArrayLength(concatEle.concatText.zh_CN) > 0 ||
398
+ commonUtils.getArrayLength(concatEle.concatText.en_US) > 0) {
399
+ return concatEle;
400
+ }
401
+ return null;
402
+ }