@or-sdk/view-templates 1.2.4-next.600.0 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/README.md +1 -1
- package/dist/cjs/ViewTemplates.js +112 -46
- package/dist/cjs/ViewTemplates.js.map +1 -1
- package/dist/cjs/constants.js +58 -3
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/utils/getGetByIdQuery.js +10 -0
- package/dist/cjs/utils/getGetByIdQuery.js.map +1 -0
- package/dist/cjs/utils/getListQuery.js +10 -0
- package/dist/cjs/utils/getListQuery.js.map +1 -0
- package/dist/cjs/utils/index.js +5 -1
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/esm/ViewTemplates.js +87 -34
- package/dist/esm/ViewTemplates.js.map +1 -1
- package/dist/esm/constants.js +106 -1
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/utils/getGetByIdQuery.js +12 -0
- package/dist/esm/utils/getGetByIdQuery.js.map +1 -0
- package/dist/esm/utils/getListQuery.js +15 -0
- package/dist/esm/utils/getListQuery.js.map +1 -0
- package/dist/esm/utils/index.js +2 -0
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/types/ViewTemplates.d.ts +8 -6
- package/dist/types/ViewTemplates.d.ts.map +1 -1
- package/dist/types/constants.d.ts +6 -1
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/types.d.ts +28 -20
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/getGetByIdQuery.d.ts +5 -0
- package/dist/types/utils/getGetByIdQuery.d.ts.map +1 -0
- package/dist/types/utils/getListQuery.d.ts +5 -0
- package/dist/types/utils/getListQuery.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +2 -0
- package/dist/types/utils/index.d.ts.map +1 -1
- package/package.json +5 -4
- package/src/ViewTemplates.ts +101 -50
- package/src/constants.ts +111 -1
- package/src/types.ts +32 -25
- package/src/utils/getGetByIdQuery.ts +13 -0
- package/src/utils/getListQuery.ts +16 -0
- package/src/utils/index.ts +2 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
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"}
|
package/dist/esm/utils/index.js
CHANGED
|
@@ -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 {
|
|
2
|
+
import { GetViewTemplateByIdParams, ListViewTemplatesParams, View, ViewTemplate, ViewTemplatesConfig } from './types';
|
|
3
3
|
export declare class ViewTemplates {
|
|
4
|
-
private readonly
|
|
4
|
+
private readonly dataHub;
|
|
5
5
|
constructor(params: ViewTemplatesConfig);
|
|
6
|
-
listViewTemplates(params?: ListViewTemplatesParams
|
|
7
|
-
getViewTemplateById(
|
|
8
|
-
download(viewTemplateId: string, options?:
|
|
9
|
-
upgrade(viewTemplateId: string, options?:
|
|
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,
|
|
1
|
+
{"version":3,"file":"ViewTemplates.d.ts","sourceRoot":"","sources":["../../src/ViewTemplates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,OAAO,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,IAAI,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAItH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;gBAEtB,MAAM,EAAE,mBAAmB;IAgB1B,iBAAiB,CAAC,MAAM,GAAE,uBAA4B,GAAG,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAmC3F,mBAAmB,CAAC,cAAc,EAAE,MAAM,EAAE,MAAM,GAAE,yBAA8B,GAAG,OAAO,CAAC,YAAY,CAAC;IAqCnG,QAAQ,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC;IAgC7D,OAAO,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,KAAK,GAAG,OAAO,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;KAAE,CAAC;WA8BtE,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAIjC"}
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
export {
|
|
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,
|
|
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"}
|
package/dist/types/types.d.ts
CHANGED
|
@@ -3,7 +3,34 @@ export declare type ViewTemplatesConfig = {
|
|
|
3
3
|
token: Token;
|
|
4
4
|
discoveryUrl?: string;
|
|
5
5
|
accountId?: string;
|
|
6
|
-
|
|
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,EAAE,MAAM,CAAC;IAKtB,SAAS,CAAC,EAAE,MAAM,CAAC;IAKnB,
|
|
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,EAAE,MAAM,CAAC;IAKtB,SAAS,CAAC,EAAE,MAAM,CAAC;IAKnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,oBAAY,YAAY,GAAG;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE;QACR,QAAQ,EAAE,MAAM,CAAC;QACjB,WAAW,EAAE,MAAM,CAAC;QACpB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;QACpB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;QACpB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;QACvB,UAAU,EAAE,OA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AAC;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 @@
|
|
|
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 @@
|
|
|
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 +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.4
|
|
2
|
+
"version": "1.2.4",
|
|
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.
|
|
28
|
-
"@or-sdk/data-hub
|
|
29
|
-
}
|
|
27
|
+
"@or-sdk/base": "^0.26.6",
|
|
28
|
+
"@or-sdk/data-hub": "^0.25.4"
|
|
29
|
+
},
|
|
30
|
+
"gitHead": "e32b91cf15c7de088421f6c95eeca54958555694"
|
|
30
31
|
}
|
package/src/ViewTemplates.ts
CHANGED
|
@@ -1,26 +1,19 @@
|
|
|
1
|
-
import { List
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
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
|
|
8
|
+
private readonly dataHub: DataHub;
|
|
15
9
|
|
|
16
10
|
constructor(params: ViewTemplatesConfig) {
|
|
17
|
-
const { token, discoveryUrl,
|
|
11
|
+
const { token, discoveryUrl, dataHubUrl } = params;
|
|
18
12
|
|
|
19
|
-
this.
|
|
13
|
+
this.dataHub = new DataHub({
|
|
20
14
|
token,
|
|
21
15
|
discoveryUrl,
|
|
22
|
-
|
|
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 = {}
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
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
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
-
|
|
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
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
route: 'view-templates',
|
|
98
|
+
public async download(viewTemplateId: string, options = {}): Promise<View> {
|
|
99
|
+
const variables = {
|
|
100
|
+
entity: ENTITY_NAME,
|
|
73
101
|
data: {
|
|
74
|
-
|
|
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
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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 {
|
|
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';
|
package/src/types.ts
CHANGED
|
@@ -17,9 +17,39 @@ export type ViewTemplatesConfig = {
|
|
|
17
17
|
accountId?: string;
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
* Url of OneReach
|
|
20
|
+
* Url of OneReach DataHub api
|
|
21
21
|
*/
|
|
22
|
-
|
|
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[];
|
|
23
53
|
};
|
|
24
54
|
|
|
25
55
|
export type View = {
|
|
@@ -104,26 +134,3 @@ export type View = {
|
|
|
104
134
|
template: null;
|
|
105
135
|
deletedDate?: string;
|
|
106
136
|
};
|
|
107
|
-
|
|
108
|
-
export type ListViewTemplatesParams = {
|
|
109
|
-
query?: {
|
|
110
|
-
[key: string]: unknown;
|
|
111
|
-
};
|
|
112
|
-
projection?: string[];
|
|
113
|
-
group?: string[];
|
|
114
|
-
sandbox?: boolean;
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
export type PaginationOptions = {
|
|
118
|
-
limit?: number;
|
|
119
|
-
offset?: number;
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
export type DownloadOptions = {
|
|
123
|
-
accountId?: string;
|
|
124
|
-
[key: string]: unknown;
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
export type UpgradeOptions = {
|
|
128
|
-
[key: string]: unknown;
|
|
129
|
-
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { getQueryProjectionPart } from '@or-sdk/data-hub';
|
|
2
|
+
import { DEFAULT_PROJECTION_GET_LIST } from '../constants';
|
|
3
|
+
|
|
4
|
+
function getGetByIdQuery({ projection = [] }: { projection: string[]; }): string {
|
|
5
|
+
return `query getTemplate($entity: TemplateType!, $params: GetInput!, $sourceId: String) {
|
|
6
|
+
getTemplate(entity: $entity, params: $params, sourceId: $sourceId) {
|
|
7
|
+
... on View {${getQueryProjectionPart(projection.length ? projection : DEFAULT_PROJECTION_GET_LIST)}
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}`;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default getGetByIdQuery;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { getQueryProjectionPart } from '@or-sdk/data-hub';
|
|
2
|
+
import { DEFAULT_PROJECTION_LIST } from '../constants';
|
|
3
|
+
|
|
4
|
+
function getListQuery({ projection = [] }: { projection: string[]; }): string {
|
|
5
|
+
return `query listTemplates($entity: TemplateType!, $params: ListInput!, $sourceId: String, $forceSandbox: Boolean) {
|
|
6
|
+
listTemplates(entity: $entity, params: $params, sourceId: $sourceId, forceSandbox: $forceSandbox) {
|
|
7
|
+
records {
|
|
8
|
+
... on View {${getQueryProjectionPart(projection.length ? projection : DEFAULT_PROJECTION_LIST)}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
last
|
|
12
|
+
}
|
|
13
|
+
}`;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default getListQuery;
|