@or-sdk/view-templates 1.2.2-next.578.0 → 1.2.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.
Files changed (41) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +1 -1
  3. package/dist/cjs/ViewTemplates.js +112 -46
  4. package/dist/cjs/ViewTemplates.js.map +1 -1
  5. package/dist/cjs/constants.js +58 -3
  6. package/dist/cjs/constants.js.map +1 -1
  7. package/dist/cjs/utils/getGetByIdQuery.js +10 -0
  8. package/dist/cjs/utils/getGetByIdQuery.js.map +1 -0
  9. package/dist/cjs/utils/getListQuery.js +10 -0
  10. package/dist/cjs/utils/getListQuery.js.map +1 -0
  11. package/dist/cjs/utils/index.js +5 -1
  12. package/dist/cjs/utils/index.js.map +1 -1
  13. package/dist/esm/ViewTemplates.js +87 -34
  14. package/dist/esm/ViewTemplates.js.map +1 -1
  15. package/dist/esm/constants.js +106 -1
  16. package/dist/esm/constants.js.map +1 -1
  17. package/dist/esm/utils/getGetByIdQuery.js +12 -0
  18. package/dist/esm/utils/getGetByIdQuery.js.map +1 -0
  19. package/dist/esm/utils/getListQuery.js +15 -0
  20. package/dist/esm/utils/getListQuery.js.map +1 -0
  21. package/dist/esm/utils/index.js +2 -0
  22. package/dist/esm/utils/index.js.map +1 -1
  23. package/dist/types/ViewTemplates.d.ts +8 -6
  24. package/dist/types/ViewTemplates.d.ts.map +1 -1
  25. package/dist/types/constants.d.ts +6 -1
  26. package/dist/types/constants.d.ts.map +1 -1
  27. package/dist/types/types.d.ts +28 -20
  28. package/dist/types/types.d.ts.map +1 -1
  29. package/dist/types/utils/getGetByIdQuery.d.ts +5 -0
  30. package/dist/types/utils/getGetByIdQuery.d.ts.map +1 -0
  31. package/dist/types/utils/getListQuery.d.ts +5 -0
  32. package/dist/types/utils/getListQuery.d.ts.map +1 -0
  33. package/dist/types/utils/index.d.ts +2 -0
  34. package/dist/types/utils/index.d.ts.map +1 -1
  35. package/package.json +5 -4
  36. package/src/ViewTemplates.ts +101 -50
  37. package/src/constants.ts +111 -1
  38. package/src/types.ts +32 -25
  39. package/src/utils/getGetByIdQuery.ts +13 -0
  40. package/src/utils/getListQuery.ts +16 -0
  41. package/src/utils/index.ts +2 -0
@@ -1,2 +1,107 @@
1
- export { DATA_HUB_SVC_SERVICE_KEY } from '@or-sdk/data-hub-svc';
1
+ export { DATA_HUB_SERVICE_KEY } from '@or-sdk/data-hub';
2
+ export const DEFAULT_PROJECTION_LIST = [
3
+ 'id',
4
+ 'template',
5
+ 'template.category',
6
+ 'template.description',
7
+ 'template.help',
8
+ 'template.icon',
9
+ 'template.iconUrl',
10
+ 'template.implicitly',
11
+ 'template.label',
12
+ 'template.publishedBy',
13
+ 'template.tags',
14
+ 'template.type',
15
+ 'template.version',
16
+ 'cardIds',
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
+ export const QUERY_DOWNLOAD_TO = `mutation downloadTo($entity: TemplateType!, $data: DownloadInput!) {
55
+ downloadTo(entity: $entity, data: $data) {
56
+ ... on View {
57
+ id
58
+ cardIds
59
+ linkId
60
+ mirrorCardIds
61
+ schemaVersion
62
+ dateCreated
63
+ dateModified
64
+ data {
65
+ data
66
+ form {
67
+ code
68
+ data
69
+ style
70
+ template
71
+ }
72
+ presentation {
73
+ code
74
+ data
75
+ style
76
+ template
77
+ }
78
+ }
79
+ linkType
80
+ reference
81
+ template {
82
+ category
83
+ description
84
+ help
85
+ icon
86
+ iconUrl
87
+ implicitly
88
+ label
89
+ publishedBy
90
+ tags
91
+ type
92
+ version
93
+ }
94
+ deletedDate @include(if: false)
95
+ }
96
+ }
97
+ }`;
98
+ export const QUERY_UPGRADE = `mutation upgrade($entity: TemplateType!, $id: String!, $options: UpgradeOptions) {
99
+ upgrade(entity: $entity, id: $id, options: $options) {
100
+ ... on View {
101
+ id
102
+ }
103
+ }
104
+ }
105
+ `;
106
+ export const ENTITY_NAME = 'VIEW';
2
107
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,IAAI;IACJ,UAAU;IACV,mBAAmB;IACnB,sBAAsB;IACtB,eAAe;IACf,eAAe;IACf,kBAAkB;IAClB,qBAAqB;IACrB,gBAAgB;IAChB,sBAAsB;IACtB,eAAe;IACf,eAAe;IACf,kBAAkB;IAClB,SAAS;CACV,CAAC;AAEF,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,IAAI;IACJ,SAAS;IACT,QAAQ;IACR,eAAe;IACf,eAAe;IACf,aAAa;IACb,cAAc;IACd,MAAM;IACN,WAAW;IACX,WAAW;IACX,gBAAgB;IAChB,gBAAgB;IAChB,iBAAiB;IACjB,oBAAoB;IACpB,mBAAmB;IACnB,wBAAwB;IACxB,wBAAwB;IACxB,yBAAyB;IACzB,4BAA4B;IAC5B,UAAU;IACV,WAAW;IACX,UAAU;IACV,mBAAmB;IACnB,sBAAsB;IACtB,eAAe;IACf,eAAe;IACf,kBAAkB;IAClB,qBAAqB;IACrB,gBAAgB;IAChB,sBAAsB;IACtB,eAAe;IACf,eAAe;IACf,kBAAkB;IAClB,iCAAiC;CAClC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2C/B,CAAC;AAEH,MAAM,CAAC,MAAM,aAAa,GAAG;;;;;;;CAO5B,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { getQueryProjectionPart } from '@or-sdk/data-hub';
2
+ import { DEFAULT_PROJECTION_GET_LIST } from '../constants';
3
+ function getGetByIdQuery({ projection = [] }) {
4
+ return `query getTemplate($entity: TemplateType!, $params: GetInput!, $sourceId: String) {
5
+ getTemplate(entity: $entity, params: $params, sourceId: $sourceId) {
6
+ ... on View {${getQueryProjectionPart(projection.length ? projection : DEFAULT_PROJECTION_GET_LIST)}
7
+ }
8
+ }
9
+ }`;
10
+ }
11
+ export default getGetByIdQuery;
12
+ //# sourceMappingURL=getGetByIdQuery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getGetByIdQuery.js","sourceRoot":"","sources":["../../../src/utils/getGetByIdQuery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAE3D,SAAS,eAAe,CAAC,EAAE,UAAU,GAAG,EAAE,EAA6B;IACrE,OAAO;;mBAEU,sBAAsB,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,2BAA2B,CAAC;;;EAGrG,CAAC;AACH,CAAC;AAED,eAAe,eAAe,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { getQueryProjectionPart } from '@or-sdk/data-hub';
2
+ import { DEFAULT_PROJECTION_LIST } from '../constants';
3
+ function getListQuery({ projection = [] }) {
4
+ return `query listTemplates($entity: TemplateType!, $params: ListInput!, $sourceId: String, $forceSandbox: Boolean) {
5
+ listTemplates(entity: $entity, params: $params, sourceId: $sourceId, forceSandbox: $forceSandbox) {
6
+ records {
7
+ ... on View {${getQueryProjectionPart(projection.length ? projection : DEFAULT_PROJECTION_LIST)}
8
+ }
9
+ }
10
+ last
11
+ }
12
+ }`;
13
+ }
14
+ export default getListQuery;
15
+ //# sourceMappingURL=getListQuery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getListQuery.js","sourceRoot":"","sources":["../../../src/utils/getListQuery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAEvD,SAAS,YAAY,CAAC,EAAE,UAAU,GAAG,EAAE,EAA6B;IAClE,OAAO;;;qBAGY,sBAAsB,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,uBAAuB,CAAC;;;;;EAKnG,CAAC;AACH,CAAC;AAED,eAAe,YAAY,CAAC"}
@@ -1,2 +1,4 @@
1
+ export { default as getListQuery } from './getListQuery';
2
+ export { default as getGetByIdQuery } from './getGetByIdQuery';
1
3
  export { default as getNewViewTemplate } from './getNewViewTemplate';
2
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.js","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"}
@@ -1,12 +1,14 @@
1
1
  import { List } from '@or-sdk/base';
2
- import { DownloadOptions, ListViewTemplatesParams, PaginationOptions, UpgradeOptions, View, ViewTemplatesConfig } from './types';
2
+ import { GetViewTemplateByIdParams, ListViewTemplatesParams, View, ViewTemplate, ViewTemplatesConfig } from './types';
3
3
  export declare class ViewTemplates {
4
- private readonly dataHubSvc;
4
+ private readonly dataHub;
5
5
  constructor(params: ViewTemplatesConfig);
6
- listViewTemplates(params?: ListViewTemplatesParams, paginationOptions?: PaginationOptions): Promise<List<View>>;
7
- getViewTemplateById(id: string): Promise<View>;
8
- download(viewTemplateId: string, options?: DownloadOptions, sandbox?: boolean): Promise<View>;
9
- upgrade(viewTemplateId: string, options?: UpgradeOptions): Promise<View>;
6
+ listViewTemplates(params?: ListViewTemplatesParams): Promise<List<ViewTemplate>>;
7
+ getViewTemplateById(viewTemplateId: string, params?: GetViewTemplateByIdParams): Promise<ViewTemplate>;
8
+ download(viewTemplateId: string, options?: {}): Promise<View>;
9
+ upgrade(viewTemplateId: string, options?: {}): Promise<{
10
+ id: string;
11
+ }>;
10
12
  static getNewViewTemplate(): {
11
13
  cardIds: never[];
12
14
  data: {
@@ -1 +1 @@
1
- {"version":3,"file":"ViewTemplates.d.ts","sourceRoot":"","sources":["../../src/ViewTemplates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAY,MAAM,cAAc,CAAC;AAE9C,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,iBAAiB,EACjB,cAAc,EACd,IAAI,EACJ,mBAAmB,EACpB,MAAM,SAAS,CAAC;AAGjB,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,U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AG,OAAO,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;KAAE,CAAC;WA8BtE,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAIjC"}
@@ -1,2 +1,7 @@
1
- export { DATA_HUB_SVC_SERVICE_KEY } from '@or-sdk/data-hub-svc';
1
+ export { DATA_HUB_SERVICE_KEY } from '@or-sdk/data-hub';
2
+ export declare const DEFAULT_PROJECTION_LIST: string[];
3
+ export declare const DEFAULT_PROJECTION_GET_LIST: string[];
4
+ export declare const QUERY_DOWNLOAD_TO = "mutation downloadTo($entity: TemplateType!, $data: DownloadInput!) {\n downloadTo(entity: $entity, data: $data) {\n ... on View {\n id\n cardIds\n linkId\n mirrorCardIds\n schemaVersion\n dateCreated\n dateModified\n data {\n data\n form {\n code\n data\n style\n template\n }\n presentation {\n code\n data\n style\n template\n }\n }\n linkType\n reference\n template {\n category\n description\n help\n icon\n iconUrl\n implicitly\n label\n publishedBy\n tags\n type\n version\n }\n deletedDate @include(if: false)\n }\n }\n}";
5
+ export declare const QUERY_UPGRADE = "mutation upgrade($entity: TemplateType!, $id: String!, $options: UpgradeOptions) {\n upgrade(entity: $entity, id: $id, options: $options) {\n ... on View {\n id\n }\n }\n}\n";
6
+ export declare const ENTITY_NAME = "VIEW";
2
7
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,eAAO,MAAM,uBAAuB,UAenC,CAAC;AAEF,eAAO,MAAM,2BAA2B,UAmCvC,CAAC;AAEF,eAAO,MAAM,iBAAiB,0xBA2C5B,CAAC;AAEH,eAAO,MAAM,aAAa,uMAOzB,CAAC;AAEF,eAAO,MAAM,WAAW,SAAS,CAAC"}
@@ -3,7 +3,34 @@ export declare type ViewTemplatesConfig = {
3
3
  token: Token;
4
4
  discoveryUrl?: string;
5
5
  accountId?: string;
6
- dataHubSvcUrl?: 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[];
7
34
  };
8
35
  export declare type View = {
9
36
  id?: string;
@@ -87,23 +114,4 @@ export declare type View = {
87
114
  template: null;
88
115
  deletedDate?: string;
89
116
  };
90
- export declare type ListViewTemplatesParams = {
91
- query?: {
92
- [key: string]: unknown;
93
- };
94
- projection?: string[];
95
- group?: string[];
96
- sandbox?: boolean;
97
- };
98
- export declare type PaginationOptions = {
99
- limit?: number;
100
- offset?: number;
101
- };
102
- export declare type DownloadOptions = {
103
- accountId?: string;
104
- [key: string]: unknown;
105
- };
106
- export declare type UpgradeOptions = {
107
- [key: string]: unknown;
108
- };
109
117
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAErC,oBAAY,mBAAmB,GAAG;IAIhC,KAAK,EAAE,KAAK,CAAC;IAKb,YAAY,CAAC,EAA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ClB,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"}
@@ -1,2 +1,4 @@
1
+ export { default as getListQuery } from './getListQuery';
2
+ export { default as getGetByIdQuery } from './getGetByIdQuery';
1
3
  export { default as getNewViewTemplate } from './getNewViewTemplate';
2
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAC"}
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 CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.2.2-next.578.0",
2
+ "version": "1.2.3",
3
3
  "name": "@or-sdk/view-templates",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
@@ -24,7 +24,8 @@
24
24
  "access": "public"
25
25
  },
26
26
  "dependencies": {
27
- "@or-sdk/base": "^0.26.3",
28
- "@or-sdk/data-hub-svc": "^1.1.6-next.578.0"
29
- }
27
+ "@or-sdk/base": "^0.26.5",
28
+ "@or-sdk/data-hub": "^0.25.3"
29
+ },
30
+ "gitHead": "62be75910db5696b35b6546b4164c8bcc10fe421"
30
31
  }
@@ -1,26 +1,19 @@
1
- import { List, makeList } from '@or-sdk/base';
2
- import { DataHubSvc } from '@or-sdk/data-hub-svc';
3
- import {
4
- DownloadOptions,
5
- ListViewTemplatesParams,
6
- PaginationOptions,
7
- UpgradeOptions,
8
- View,
9
- ViewTemplatesConfig,
10
- } from './types';
11
- import { getNewViewTemplate } from './utils';
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';
12
6
 
13
7
  export class ViewTemplates {
14
- private readonly dataHubSvc: DataHubSvc;
8
+ private readonly dataHub: DataHub;
15
9
 
16
10
  constructor(params: ViewTemplatesConfig) {
17
- const { token, discoveryUrl, accountId, dataHubSvcUrl } = params;
11
+ const { token, discoveryUrl, dataHubUrl } = params;
18
12
 
19
- this.dataHubSvc = new DataHubSvc({
13
+ this.dataHub = new DataHub({
20
14
  token,
21
15
  discoveryUrl,
22
- accountId,
23
- dataHubSvcUrl,
16
+ dataHubUrl,
24
17
  });
25
18
  }
26
19
 
@@ -30,18 +23,33 @@ export class ViewTemplates {
30
23
  * const result = await viewTemplates.listViewTemplates();
31
24
  * ```
32
25
  */
33
- public async listViewTemplates(params: ListViewTemplatesParams = {}, paginationOptions: PaginationOptions = {}): Promise<List<View>> {
34
- const result = await this.dataHubSvc.makeRequest<View[]>({
35
- method: 'GET',
36
- route: 'view-templates',
26
+ public async listViewTemplates(params: ListViewTemplatesParams = {}): Promise<List<ViewTemplate>> {
27
+ const { projection = [], ...varPrams } = params;
28
+
29
+ const variables = {
30
+ entity: ENTITY_NAME,
37
31
  params: {
38
- ...params,
39
- ...paginationOptions,
40
- ... this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {},
32
+ queryParams: {},
33
+ limit: 30,
34
+
35
+ // overrides
36
+ ...varPrams,
41
37
  },
42
- });
38
+ forceSandbox: false,
39
+ sourceId: varPrams?.queryParams?.sourceId,
40
+ };
43
41
 
44
- return makeList<View>(result);
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);
45
53
  }
46
54
 
47
55
  /**
@@ -50,14 +58,35 @@ export class ViewTemplates {
50
58
  * const result = await viewTemplates.getViewTemplateById('card-template-id');
51
59
  * ```
52
60
  */
53
- public async getViewTemplateById(id: string): Promise<View> {
54
- return this.dataHubSvc.makeRequest<View>({
55
- method: 'GET',
56
- route: `view-templates/${id}`,
61
+ async getViewTemplateById(viewTemplateId: string, params: GetViewTemplateByIdParams = {}): Promise<ViewTemplate> {
62
+ const { projection = [], ...varPrams } = params;
63
+ const variables = {
64
+ entity: ENTITY_NAME,
57
65
  params: {
58
- ... this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {},
66
+ id: viewTemplateId,
67
+
68
+ // overrides
69
+ ...varPrams,
59
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,
60
87
  });
88
+
89
+ return result.data[operationName] as ViewTemplate;
61
90
  }
62
91
 
63
92
  /**
@@ -66,19 +95,30 @@ export class ViewTemplates {
66
95
  * const result = await viewTemplates.download('view-template-id');
67
96
  * ```
68
97
  */
69
- public async download(viewTemplateId: string, options: DownloadOptions = {}, sandbox = true): Promise<View> {
70
- return this.dataHubSvc.makeRequest<View>({
71
- method: 'PUT',
72
- route: 'view-templates',
98
+ public async download(viewTemplateId: string, options = {}): Promise<View> {
99
+ const variables = {
100
+ entity: ENTITY_NAME,
73
101
  data: {
74
- viewId: viewTemplateId,
75
- options,
76
- sandbox,
77
- },
78
- params: {
79
- ... this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {},
102
+ id: viewTemplateId,
103
+ body: { ...options },
80
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,
81
119
  });
120
+
121
+ return result.data[operationName] as View;
82
122
  }
83
123
 
84
124
  /**
@@ -87,17 +127,28 @@ export class ViewTemplates {
87
127
  * const result = await viewTemplates.upgrade('view-template-id');
88
128
  * ```
89
129
  */
90
- public async upgrade(viewTemplateId: string, options: UpgradeOptions = {}): Promise<View> {
91
- return this.dataHubSvc.makeRequest<View>({
92
- method: 'PATCH',
93
- route: `view-templates/${viewTemplateId}`,
94
- data: {
95
- options,
96
- },
97
- params: {
98
- ... this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {},
99
- },
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,
100
149
  });
150
+
151
+ return result.data[operationName]!;
101
152
  }
102
153
 
103
154
  /**
package/src/constants.ts CHANGED
@@ -1 +1,111 @@
1
- export { DATA_HUB_SVC_SERVICE_KEY } from '@or-sdk/data-hub-svc';
1
+ export { DATA_HUB_SERVICE_KEY } from '@or-sdk/data-hub';
2
+
3
+ export const DEFAULT_PROJECTION_LIST = [
4
+ 'id',
5
+ 'template',
6
+ 'template.category',
7
+ 'template.description',
8
+ 'template.help',
9
+ 'template.icon',
10
+ 'template.iconUrl',
11
+ 'template.implicitly',
12
+ 'template.label',
13
+ 'template.publishedBy',
14
+ 'template.tags',
15
+ 'template.type',
16
+ 'template.version',
17
+ 'cardIds',
18
+ ];
19
+
20
+ export const DEFAULT_PROJECTION_GET_LIST = [
21
+ 'id',
22
+ 'cardIds',
23
+ 'linkId',
24
+ 'mirrorCardIds',
25
+ 'schemaVersion',
26
+ 'dateCreated',
27
+ 'dateModified',
28
+ 'data',
29
+ 'data.data',
30
+ 'data.form',
31
+ 'data.form.code',
32
+ 'data.form.data',
33
+ 'data.form.style',
34
+ 'data.form.template',
35
+ 'data.presentation',
36
+ 'data.presentation.code',
37
+ 'data.presentation.data',
38
+ 'data.presentation.style',
39
+ 'data.presentation.template',
40
+ 'linkType',
41
+ 'reference',
42
+ 'template',
43
+ 'template.category',
44
+ 'template.description',
45
+ 'template.help',
46
+ 'template.icon',
47
+ 'template.iconUrl',
48
+ 'template.implicitly',
49
+ 'template.label',
50
+ 'template.publishedBy',
51
+ 'template.tags',
52
+ 'template.type',
53
+ 'template.version',
54
+ 'deletedDate @include(if: false)',
55
+ ];
56
+
57
+ export const QUERY_DOWNLOAD_TO = `mutation downloadTo($entity: TemplateType!, $data: DownloadInput!) {
58
+ downloadTo(entity: $entity, data: $data) {
59
+ ... on View {
60
+ id
61
+ cardIds
62
+ linkId
63
+ mirrorCardIds
64
+ schemaVersion
65
+ dateCreated
66
+ dateModified
67
+ data {
68
+ data
69
+ form {
70
+ code
71
+ data
72
+ style
73
+ template
74
+ }
75
+ presentation {
76
+ code
77
+ data
78
+ style
79
+ template
80
+ }
81
+ }
82
+ linkType
83
+ reference
84
+ template {
85
+ category
86
+ description
87
+ help
88
+ icon
89
+ iconUrl
90
+ implicitly
91
+ label
92
+ publishedBy
93
+ tags
94
+ type
95
+ version
96
+ }
97
+ deletedDate @include(if: false)
98
+ }
99
+ }
100
+ }`;
101
+
102
+ export const QUERY_UPGRADE = `mutation upgrade($entity: TemplateType!, $id: String!, $options: UpgradeOptions) {
103
+ upgrade(entity: $entity, id: $id, options: $options) {
104
+ ... on View {
105
+ id
106
+ }
107
+ }
108
+ }
109
+ `;
110
+
111
+ export const ENTITY_NAME = 'VIEW';