@or-sdk/view-templates 1.0.1-beta.497.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 (62) hide show
  1. package/README.md +23 -0
  2. package/dist/cjs/ViewTemplates.js +199 -0
  3. package/dist/cjs/ViewTemplates.js.map +1 -0
  4. package/dist/cjs/constants.js +59 -0
  5. package/dist/cjs/constants.js.map +1 -0
  6. package/dist/cjs/index.js +21 -0
  7. package/dist/cjs/index.js.map +1 -0
  8. package/dist/cjs/types.js +3 -0
  9. package/dist/cjs/types.js.map +1 -0
  10. package/dist/cjs/utils/getGetByIdQuery.js +10 -0
  11. package/dist/cjs/utils/getGetByIdQuery.js.map +1 -0
  12. package/dist/cjs/utils/getListQuery.js +10 -0
  13. package/dist/cjs/utils/getListQuery.js.map +1 -0
  14. package/dist/cjs/utils/getNewViewTemplate.js +132 -0
  15. package/dist/cjs/utils/getNewViewTemplate.js.map +1 -0
  16. package/dist/cjs/utils/index.js +13 -0
  17. package/dist/cjs/utils/index.js.map +1 -0
  18. package/dist/esm/ViewTemplates.js +125 -0
  19. package/dist/esm/ViewTemplates.js.map +1 -0
  20. package/dist/esm/constants.js +106 -0
  21. package/dist/esm/constants.js.map +1 -0
  22. package/dist/esm/index.js +3 -0
  23. package/dist/esm/index.js.map +1 -0
  24. package/dist/esm/types.js +2 -0
  25. package/dist/esm/types.js.map +1 -0
  26. package/dist/esm/utils/getGetByIdQuery.js +12 -0
  27. package/dist/esm/utils/getGetByIdQuery.js.map +1 -0
  28. package/dist/esm/utils/getListQuery.js +15 -0
  29. package/dist/esm/utils/getListQuery.js.map +1 -0
  30. package/dist/esm/utils/getNewViewTemplate.js +132 -0
  31. package/dist/esm/utils/getNewViewTemplate.js.map +1 -0
  32. package/dist/esm/utils/index.js +4 -0
  33. package/dist/esm/utils/index.js.map +1 -0
  34. package/dist/types/ViewTemplates.d.ts +103 -0
  35. package/dist/types/ViewTemplates.d.ts.map +1 -0
  36. package/dist/types/constants.d.ts +6 -0
  37. package/dist/types/constants.d.ts.map +1 -0
  38. package/dist/types/index.d.ts +3 -0
  39. package/dist/types/index.d.ts.map +1 -0
  40. package/dist/types/types.d.ts +117 -0
  41. package/dist/types/types.d.ts.map +1 -0
  42. package/dist/types/utils/getGetByIdQuery.d.ts +5 -0
  43. package/dist/types/utils/getGetByIdQuery.d.ts.map +1 -0
  44. package/dist/types/utils/getListQuery.d.ts +5 -0
  45. package/dist/types/utils/getListQuery.d.ts.map +1 -0
  46. package/dist/types/utils/getNewViewTemplate.d.ts +92 -0
  47. package/dist/types/utils/getNewViewTemplate.d.ts.map +1 -0
  48. package/dist/types/utils/index.d.ts +4 -0
  49. package/dist/types/utils/index.d.ts.map +1 -0
  50. package/package.json +30 -0
  51. package/src/ViewTemplates.ts +164 -0
  52. package/src/constants.ts +109 -0
  53. package/src/index.ts +2 -0
  54. package/src/types.ts +136 -0
  55. package/src/utils/getGetByIdQuery.ts +13 -0
  56. package/src/utils/getListQuery.ts +16 -0
  57. package/src/utils/getNewViewTemplate.ts +132 -0
  58. package/src/utils/index.ts +7 -0
  59. package/tsconfig.dev.json +8 -0
  60. package/tsconfig.esm.json +12 -0
  61. package/tsconfig.json +7 -0
  62. package/tsconfig.types.json +10 -0
@@ -0,0 +1,117 @@
1
+ import { Token } from '@or-sdk/base';
2
+ export declare type ViewTemplatesConfig = {
3
+ token: Token;
4
+ discoveryUrl?: string;
5
+ accountId?: string;
6
+ dataHubUrl?: string;
7
+ };
8
+ export declare type ViewTemplate = {
9
+ id: string;
10
+ template: {
11
+ category: string;
12
+ description: string;
13
+ help: string | null;
14
+ icon: string | null;
15
+ iconUrl: string | null;
16
+ implicitly: unknown | null;
17
+ label: string;
18
+ publishedBy: string;
19
+ tags: string[] | null;
20
+ type: unknown | null;
21
+ version: string;
22
+ };
23
+ cardIds: string[];
24
+ };
25
+ export declare type ListViewTemplatesParams = {
26
+ projection?: string[];
27
+ limit?: number;
28
+ queryParams?: {
29
+ sourceId: string;
30
+ };
31
+ };
32
+ export declare type GetViewTemplateByIdParams = {
33
+ projection?: string[];
34
+ };
35
+ export declare type View = {
36
+ id?: string;
37
+ cardIds: string[];
38
+ linkId: string | null;
39
+ mirrorCardIds: string[] | null;
40
+ schemaVersion: number;
41
+ dateCreated: number;
42
+ dateModified: number;
43
+ data: {
44
+ data: {
45
+ filterByTagIds: string[];
46
+ label: string;
47
+ description: string;
48
+ isDefaultView: boolean;
49
+ destroyRejectedCards?: boolean;
50
+ allowCardsDragging?: boolean;
51
+ customBackgroundColor?: {
52
+ hex?: string;
53
+ source?: string;
54
+ fill?: string;
55
+ opacity?: number;
56
+ stroke?: string;
57
+ };
58
+ filters?: {
59
+ queryParams?: {
60
+ [key: string]: unknown;
61
+ };
62
+ timezone?: {
63
+ uiLabel?: string;
64
+ text?: string;
65
+ value?: string;
66
+ };
67
+ dates?: {
68
+ rangeName?: string;
69
+ };
70
+ };
71
+ navigationSection?: {
72
+ name?: string;
73
+ link?: {
74
+ name: string;
75
+ };
76
+ };
77
+ showViewLoadingStatus?: boolean;
78
+ useCustomBackgroundColor?: boolean;
79
+ viewClasses?: string[];
80
+ 'background-color'?: string;
81
+ viewLoadingStatus?: {
82
+ progressType?: string;
83
+ slots?: string[];
84
+ flat?: boolean;
85
+ showProgress?: boolean;
86
+ errorOptionIds?: string[];
87
+ message?: string;
88
+ title?: string;
89
+ };
90
+ allowCardsDraggingWhenReadOnly?: boolean;
91
+ loadEntities?: {
92
+ [key: string]: unknown;
93
+ };
94
+ };
95
+ form: {
96
+ code: string;
97
+ data?: {
98
+ [key: string]: unknown;
99
+ };
100
+ style: string;
101
+ template: string;
102
+ };
103
+ presentation: {
104
+ code: string;
105
+ data?: {
106
+ [key: string]: unknown;
107
+ };
108
+ style: string;
109
+ template: string;
110
+ };
111
+ };
112
+ linkType: null;
113
+ reference: null;
114
+ template: null;
115
+ deletedDate?: string;
116
+ };
117
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@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,EAAE,MAAM,CAAC;YAC5B,iBAAiB,CAAC,EAAE;gBAClB,YAAY,CAAC,EAAE,MAAM,CAAC;gBACtB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;gBACjB,IAAI,CAAC,EAAE,OAAO,CAAC;gBACf,YAAY,CAAC,EAAE,OAAO,CAAC;gBACvB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;gBAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;gBACjB,KAAK,CAAC,EAAE,MAAM,CAAC;aAChB,CAAC;YACF,8BAA8B,CAAC,EAAE,OAAO,CAAC;YACzC,YAAY,CAAC,EAAE;gBACb,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;aACxB,CAAC;SACH,CAAC;QACF,IAAI,EAAE;YACJ,IAAI,EAAE,MAAM,CAAC;YACb,IAAI,CAAC,EAAE;gBACL,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;aACxB,CAAC;YACF,KAAK,EAAE,MAAM,CAAC;YACd,QAAQ,EAAE,MAAM,CAAC;SAClB,CAAC;QACF,YAAY,EAAE;YACZ,IAAI,EAAE,MAAM,CAAC;YACb,IAAI,CAAC,EAAE;gBACL,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;aACxB,CAAC;YACF,KAAK,EAAE,MAAM,CAAC;YACd,QAAQ,EAAE,MAAM,CAAC;SAClB,CAAC;KACH,CAAC;IACF,QAAQ,EAAE,IAAI,CAAC;IACf,SAAS,EAAE,IAAI,CAAC;IAChB,QAAQ,EAAE,IAAI,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC"}
@@ -0,0 +1,5 @@
1
+ declare function getGetByIdQuery({ projection }: {
2
+ projection: string[];
3
+ }): string;
4
+ export default getGetByIdQuery;
5
+ //# sourceMappingURL=getGetByIdQuery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getGetByIdQuery.d.ts","sourceRoot":"","sources":["../../../src/utils/getGetByIdQuery.ts"],"names":[],"mappings":"AAGA,iBAAS,eAAe,CAAC,EAAE,UAAe,EAAE,EAAE;IAAE,UAAU,EAAE,MAAM,EAAE,CAAC;CAAE,GAAG,MAAM,CAO/E;AAED,eAAe,eAAe,CAAC"}
@@ -0,0 +1,5 @@
1
+ declare function getListQuery({ projection }: {
2
+ projection: string[];
3
+ }): string;
4
+ export default getListQuery;
5
+ //# sourceMappingURL=getListQuery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getListQuery.d.ts","sourceRoot":"","sources":["../../../src/utils/getListQuery.ts"],"names":[],"mappings":"AAGA,iBAAS,YAAY,CAAC,EAAE,UAAe,EAAE,EAAE;IAAE,UAAU,EAAE,MAAM,EAAE,CAAC;CAAE,GAAG,MAAM,CAU5E;AAED,eAAe,YAAY,CAAC"}
@@ -0,0 +1,92 @@
1
+ declare function getNewViewTemplate(): {
2
+ cardIds: never[];
3
+ data: {
4
+ data: {
5
+ allowCardsDragging: boolean;
6
+ allowCardsDraggingWhenReadOnly: boolean;
7
+ 'background-color': string;
8
+ customBackgroundColor: {
9
+ fill: string;
10
+ hex: string;
11
+ opacity: number;
12
+ source: string;
13
+ stroke: string;
14
+ };
15
+ description: string;
16
+ destroyRejectedCards: boolean;
17
+ filterByTagIds: never[];
18
+ filters: {
19
+ dates: {
20
+ rangeName: string;
21
+ };
22
+ queryParams: {};
23
+ timezone: {
24
+ text: string;
25
+ uiLabel: string;
26
+ value: string;
27
+ };
28
+ };
29
+ label: string;
30
+ loadEntities: {};
31
+ navigationSection: {
32
+ name: string;
33
+ link: {
34
+ name: string;
35
+ };
36
+ };
37
+ showFilterByTagsButton: boolean;
38
+ showFilterByTagsButtonWhenReadOnly: boolean;
39
+ showViewLoadingStatus: boolean;
40
+ style: string;
41
+ useCustomBackgroundColor: boolean;
42
+ viewClasses: never[];
43
+ viewLoadingStatus: {
44
+ progressType: string;
45
+ slots: string[];
46
+ message: string;
47
+ title: string;
48
+ flat: boolean;
49
+ showProgress: boolean;
50
+ errorOptionIds: never[];
51
+ };
52
+ };
53
+ form: {
54
+ code: string;
55
+ data: {
56
+ layoutSlotOptions: {
57
+ value: string;
58
+ label: string;
59
+ }[];
60
+ loadingStatusErrorOptions: {
61
+ value: string;
62
+ label: string;
63
+ }[];
64
+ progressElementTypeOptions: {
65
+ value: string;
66
+ label: string;
67
+ }[];
68
+ };
69
+ style: string;
70
+ template: string;
71
+ };
72
+ presentation: {
73
+ code: string;
74
+ data: null;
75
+ style: string;
76
+ template: string;
77
+ };
78
+ };
79
+ template: {
80
+ category: string;
81
+ description: string;
82
+ help: string;
83
+ icon: string;
84
+ iconUrl: string;
85
+ label: string;
86
+ publishedBy: string;
87
+ tags: string;
88
+ version: string;
89
+ };
90
+ };
91
+ export default getNewViewTemplate;
92
+ //# sourceMappingURL=getNewViewTemplate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getNewViewTemplate.d.ts","sourceRoot":"","sources":["../../../src/utils/getNewViewTemplate.ts"],"names":[],"mappings":"AAAA,iBAAS,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiI1B;AAED,eAAe,kBAAkB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { default as getListQuery } from './getListQuery';
2
+ export { default as getGetByIdQuery } from './getGetByIdQuery';
3
+ export { default as getNewViewTemplate } from './getNewViewTemplate';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "version": "1.0.1-beta.497.0",
3
+ "name": "@or-sdk/view-templates",
4
+ "main": "dist/cjs/index.js",
5
+ "module": "dist/esm/index.js",
6
+ "types": "dist/types/index.d.ts",
7
+ "scripts": {
8
+ "build": "pnpm clean && pnpm build:esm && pnpm build:cjs",
9
+ "build:cjs": "tsc --project tsconfig.json",
10
+ "build:esm": "tsc --project tsconfig.esm.json",
11
+ "build:types": "tsc --project tsconfig.types.json",
12
+ "build:watch": "concurrently -r --hide 1,2 \"pnpm build:watch:cjs\" \"pnpm build:watch:esm\" \"pnpm build:watch:types\"",
13
+ "build:watch:cjs": "tsc --project tsconfig.json -w",
14
+ "build:watch:esm": "tsc --project tsconfig.esm.json -w",
15
+ "build:watch:types": "tsc --project tsconfig.types.json -w",
16
+ "clean": "rm -rf ./dist",
17
+ "dev": "pnpm build:watch:esm"
18
+ },
19
+ "devDependencies": {
20
+ "concurrently": "^6.4.0",
21
+ "typescript": "^4.4.4"
22
+ },
23
+ "publishConfig": {
24
+ "access": "public"
25
+ },
26
+ "dependencies": {
27
+ "@or-sdk/base": "^0.26.3",
28
+ "@or-sdk/data-hub": "^0.24.0"
29
+ }
30
+ }
@@ -0,0 +1,164 @@
1
+ import { List } from '@or-sdk/base';
2
+ import { DataHub, GraphqlResponse, OperationNames } from '@or-sdk/data-hub';
3
+ import { GetViewTemplateByIdParams, ListViewTemplatesParams, View, ViewTemplate, ViewTemplatesConfig } from './types';
4
+ import { getGetByIdQuery, getListQuery, getNewViewTemplate } from './utils';
5
+ import { ENTITY_NAME, QUERY_DOWNLOAD_TO, QUERY_UPGRADE } from './constants';
6
+
7
+ export class ViewTemplates {
8
+ private readonly dataHub: DataHub;
9
+
10
+ constructor(params: ViewTemplatesConfig) {
11
+ const { token, discoveryUrl, dataHubUrl } = params;
12
+
13
+ this.dataHub = new DataHub({
14
+ token,
15
+ discoveryUrl,
16
+ dataHubUrl,
17
+ });
18
+ }
19
+
20
+ /**
21
+ * List view templates
22
+ * ```typescript
23
+ * const result = await viewTemplates.listViewTemplates();
24
+ * ```
25
+ */
26
+ public async listViewTemplates(params: ListViewTemplatesParams = {}): Promise<List<ViewTemplate>> {
27
+ const { projection = [], ...varPrams } = params;
28
+
29
+ const variables = {
30
+ entity: ENTITY_NAME,
31
+ params: {
32
+ queryParams: {},
33
+ limit: 30,
34
+
35
+ // overrides
36
+ ...varPrams,
37
+ },
38
+ forceSandbox: false,
39
+ sourceId: varPrams?.queryParams?.sourceId,
40
+ };
41
+
42
+ const operationName = this.dataHub.getOperationName(OperationNames.LIST_TEMPLATES);
43
+
44
+ const data = {
45
+ operationName,
46
+ query: getListQuery({
47
+ projection,
48
+ }),
49
+ variables,
50
+ };
51
+
52
+ return this.dataHub.getFullList<ViewTemplate>('POST', '/graphql', data);
53
+ }
54
+
55
+ /**
56
+ * Get view template by id
57
+ * ```typescript
58
+ * const result = await viewTemplates.getViewTemplateById('card-template-id');
59
+ * ```
60
+ */
61
+ async getViewTemplateById(viewTemplateId: string, params: GetViewTemplateByIdParams = {}): Promise<ViewTemplate> {
62
+ const { projection = [], ...varPrams } = params;
63
+ const variables = {
64
+ entity: ENTITY_NAME,
65
+ params: {
66
+ id: viewTemplateId,
67
+
68
+ // overrides
69
+ ...varPrams,
70
+ },
71
+ };
72
+
73
+ const operationName = 'getTemplate';
74
+
75
+ const data = {
76
+ operationName,
77
+ query: getGetByIdQuery({
78
+ projection,
79
+ }),
80
+ variables,
81
+ };
82
+
83
+ const result = await this.dataHub.makeRequest<GraphqlResponse<ViewTemplate>>({
84
+ method: 'POST',
85
+ route: '/graphql',
86
+ data,
87
+ });
88
+
89
+ return result.data[operationName] as ViewTemplate;
90
+ }
91
+
92
+ /**
93
+ * Download view template
94
+ * ```typescript
95
+ * const result = await viewTemplates.download('view-template-id');
96
+ * ```
97
+ */
98
+ public async download(viewTemplateId: string, options = {}): Promise<View> {
99
+ const variables = {
100
+ entity: ENTITY_NAME,
101
+ data: {
102
+ id: viewTemplateId,
103
+ body: { ...options },
104
+ },
105
+ };
106
+
107
+ const operationName = 'downloadTo';
108
+
109
+ const data = {
110
+ operationName,
111
+ query: QUERY_DOWNLOAD_TO,
112
+ variables,
113
+ };
114
+
115
+ const result = await this.dataHub.makeRequest<GraphqlResponse<View>>({
116
+ method: 'POST',
117
+ route: '/graphql',
118
+ data,
119
+ });
120
+
121
+ return result.data[operationName] as View;
122
+ }
123
+
124
+ /**
125
+ * Upgrade view template
126
+ * ```typescript
127
+ * const result = await viewTemplates.upgrade('view-template-id');
128
+ * ```
129
+ */
130
+ public async upgrade(viewTemplateId: string, options = {}): Promise<{ id: string; }> {
131
+ const variables = {
132
+ entity: ENTITY_NAME,
133
+ id: viewTemplateId,
134
+ options,
135
+ };
136
+
137
+ const operationName = 'upgrade';
138
+
139
+ const data = {
140
+ operationName,
141
+ query: QUERY_UPGRADE,
142
+ variables,
143
+ };
144
+
145
+ const result = await this.dataHub.makeRequest<GraphqlResponse<{ id: string; }>>({
146
+ method: 'POST',
147
+ route: '/graphql',
148
+ data,
149
+ });
150
+
151
+ return result.data[operationName]!;
152
+ }
153
+
154
+ /**
155
+ * Generate new view template
156
+ * ```typescript
157
+ * const result = ViewTemplates.getNewViewTemplate();
158
+ * ```
159
+ */
160
+ public static getNewViewTemplate() {
161
+ return getNewViewTemplate();
162
+ }
163
+
164
+ }
@@ -0,0 +1,109 @@
1
+ export const DEFAULT_PROJECTION_LIST = [
2
+ 'id',
3
+ 'template',
4
+ 'template.category',
5
+ 'template.description',
6
+ 'template.help',
7
+ 'template.icon',
8
+ 'template.iconUrl',
9
+ 'template.implicitly',
10
+ 'template.label',
11
+ 'template.publishedBy',
12
+ 'template.tags',
13
+ 'template.type',
14
+ 'template.version',
15
+ 'cardIds',
16
+ ];
17
+
18
+ export const DEFAULT_PROJECTION_GET_LIST = [
19
+ 'id',
20
+ 'cardIds',
21
+ 'linkId',
22
+ 'mirrorCardIds',
23
+ 'schemaVersion',
24
+ 'dateCreated',
25
+ 'dateModified',
26
+ 'data',
27
+ 'data.data',
28
+ 'data.form',
29
+ 'data.form.code',
30
+ 'data.form.data',
31
+ 'data.form.style',
32
+ 'data.form.template',
33
+ 'data.presentation',
34
+ 'data.presentation.code',
35
+ 'data.presentation.data',
36
+ 'data.presentation.style',
37
+ 'data.presentation.template',
38
+ 'linkType',
39
+ 'reference',
40
+ 'template',
41
+ 'template.category',
42
+ 'template.description',
43
+ 'template.help',
44
+ 'template.icon',
45
+ 'template.iconUrl',
46
+ 'template.implicitly',
47
+ 'template.label',
48
+ 'template.publishedBy',
49
+ 'template.tags',
50
+ 'template.type',
51
+ 'template.version',
52
+ 'deletedDate @include(if: false)',
53
+ ];
54
+
55
+ export const QUERY_DOWNLOAD_TO = `mutation downloadTo($entity: TemplateType!, $data: DownloadInput!) {
56
+ downloadTo(entity: $entity, data: $data) {
57
+ ... on View {
58
+ id
59
+ cardIds
60
+ linkId
61
+ mirrorCardIds
62
+ schemaVersion
63
+ dateCreated
64
+ dateModified
65
+ data {
66
+ data
67
+ form {
68
+ code
69
+ data
70
+ style
71
+ template
72
+ }
73
+ presentation {
74
+ code
75
+ data
76
+ style
77
+ template
78
+ }
79
+ }
80
+ linkType
81
+ reference
82
+ template {
83
+ category
84
+ description
85
+ help
86
+ icon
87
+ iconUrl
88
+ implicitly
89
+ label
90
+ publishedBy
91
+ tags
92
+ type
93
+ version
94
+ }
95
+ deletedDate @include(if: false)
96
+ }
97
+ }
98
+ }`;
99
+
100
+ export const QUERY_UPGRADE = `mutation upgrade($entity: TemplateType!, $id: String!, $options: UpgradeOptions) {
101
+ upgrade(entity: $entity, id: $id, options: $options) {
102
+ ... on View {
103
+ id
104
+ }
105
+ }
106
+ }
107
+ `;
108
+
109
+ export const ENTITY_NAME = 'VIEW';
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { ViewTemplates } from './ViewTemplates';
2
+ export * from './types';
package/src/types.ts ADDED
@@ -0,0 +1,136 @@
1
+ import { Token } from '@or-sdk/base';
2
+
3
+ export type ViewTemplatesConfig = {
4
+ /**
5
+ * token
6
+ */
7
+ token: Token;
8
+
9
+ /**
10
+ * Url of OneReach service discovery api
11
+ */
12
+ discoveryUrl?: string;
13
+
14
+ /**
15
+ * Account ID for cross-account requests (super admin only)
16
+ */
17
+ accountId?: string;
18
+
19
+ /**
20
+ * Url of OneReach DataHub api
21
+ */
22
+ dataHubUrl?: string;
23
+ };
24
+
25
+ export type ViewTemplate = {
26
+ id: string;
27
+ template: {
28
+ category: string;
29
+ description: string;
30
+ help: string | null;
31
+ icon: string | null;
32
+ iconUrl: string | null;
33
+ implicitly: unknown | null;
34
+ label: string;
35
+ publishedBy: string;
36
+ tags: string[] | null;
37
+ type: unknown | null;
38
+ version: string;
39
+ };
40
+ cardIds: string[];
41
+ };
42
+
43
+ export type ListViewTemplatesParams = {
44
+ projection?: string[];
45
+ limit?: number;
46
+ queryParams?: {
47
+ sourceId: string;
48
+ };
49
+ };
50
+
51
+ export type GetViewTemplateByIdParams = {
52
+ projection?: string[];
53
+ };
54
+
55
+ export type View = {
56
+ id?: string;
57
+ cardIds: string[];
58
+ linkId: string | null;
59
+ mirrorCardIds: string[] | null;
60
+ schemaVersion: number;
61
+ dateCreated: number;
62
+ dateModified: number;
63
+ data: {
64
+ data: {
65
+ filterByTagIds: string[];
66
+ label: string;
67
+ description: string;
68
+ isDefaultView: boolean;
69
+ destroyRejectedCards?: boolean;
70
+ allowCardsDragging?: boolean;
71
+ customBackgroundColor?: {
72
+ hex?: string;
73
+ source?: string;
74
+ fill?: string;
75
+ opacity?: number;
76
+ stroke?: string;
77
+ };
78
+ filters?: {
79
+ queryParams?: {
80
+ [key: string]: unknown;
81
+ };
82
+ timezone?: {
83
+ uiLabel?: string;
84
+ text?: string;
85
+ value?: string;
86
+ };
87
+ dates?: {
88
+ rangeName?: string;
89
+ };
90
+ };
91
+ navigationSection?: {
92
+ name?: string;
93
+ link?: {
94
+ name: string;
95
+ };
96
+ };
97
+ showViewLoadingStatus?: boolean;
98
+ useCustomBackgroundColor?: boolean;
99
+ viewClasses?: string[];
100
+ 'background-color'?: string;
101
+ viewLoadingStatus?: {
102
+ progressType?: string;
103
+ slots?: string[];
104
+ flat?: boolean;
105
+ showProgress?: boolean;
106
+ errorOptionIds?: string[];
107
+ message?: string;
108
+ title?: string;
109
+ };
110
+ allowCardsDraggingWhenReadOnly?: boolean;
111
+ loadEntities?: {
112
+ [key: string]: unknown;
113
+ };
114
+ };
115
+ form: {
116
+ code: string;
117
+ data?: {
118
+ [key: string]: unknown;
119
+ };
120
+ style: string;
121
+ template: string;
122
+ };
123
+ presentation: {
124
+ code: string;
125
+ data?: {
126
+ [key: string]: unknown;
127
+ };
128
+ style: string;
129
+ template: string;
130
+ };
131
+ };
132
+ linkType: null;
133
+ reference: null;
134
+ template: null;
135
+ deletedDate?: string;
136
+ };