@or-sdk/view-templates 1.2.1 → 1.2.2-beta.557.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.
- package/README.md +1 -1
- package/dist/cjs/ViewTemplates.js +46 -112
- package/dist/cjs/ViewTemplates.js.map +1 -1
- package/dist/cjs/constants.js +3 -58
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/utils/index.js +1 -5
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/esm/ViewTemplates.js +34 -87
- package/dist/esm/ViewTemplates.js.map +1 -1
- package/dist/esm/constants.js +1 -106
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/utils/index.js +0 -2
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/types/ViewTemplates.d.ts +6 -8
- package/dist/types/ViewTemplates.d.ts.map +1 -1
- package/dist/types/constants.d.ts +1 -6
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/types.d.ts +20 -28
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/index.d.ts +0 -2
- package/dist/types/utils/index.d.ts.map +1 -1
- package/package.json +3 -4
- package/src/ViewTemplates.ts +50 -101
- package/src/constants.ts +1 -111
- package/src/types.ts +25 -32
- package/src/utils/index.ts +0 -2
- package/dist/cjs/utils/getGetByIdQuery.js +0 -10
- package/dist/cjs/utils/getGetByIdQuery.js.map +0 -1
- package/dist/cjs/utils/getListQuery.js +0 -10
- package/dist/cjs/utils/getListQuery.js.map +0 -1
- package/dist/esm/utils/getGetByIdQuery.js +0 -12
- package/dist/esm/utils/getGetByIdQuery.js.map +0 -1
- package/dist/esm/utils/getListQuery.js +0 -15
- package/dist/esm/utils/getListQuery.js.map +0 -1
- package/dist/types/utils/getGetByIdQuery.d.ts +0 -5
- package/dist/types/utils/getGetByIdQuery.d.ts.map +0 -1
- package/dist/types/utils/getListQuery.d.ts +0 -5
- package/dist/types/utils/getListQuery.d.ts.map +0 -1
- package/src/utils/getGetByIdQuery.ts +0 -13
- package/src/utils/getListQuery.ts +0 -16
|
@@ -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,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,UAAU,CAAa;gBAE5B,MAAM,EAAE,mBAAmB;IAiB1B,iBAAiB,CAAC,MAAM,GAAE,uBAA4B,EAAE,iBAAiB,GAAE,iBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAoBvH,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAgB9C,QAAQ,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB,EAAE,OAAO,UAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAqB9F,OAAO,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;WAmB3E,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAIjC"}
|
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
export {
|
|
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";
|
|
1
|
+
export { DATA_HUB_SVC_SERVICE_KEY } from '@or-sdk/data-hub-svc';
|
|
7
2
|
//# 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,wBAAwB,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/types/types.d.ts
CHANGED
|
@@ -3,34 +3,7 @@ export declare type ViewTemplatesConfig = {
|
|
|
3
3
|
token: Token;
|
|
4
4
|
discoveryUrl?: string;
|
|
5
5
|
accountId?: string;
|
|
6
|
-
|
|
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[];
|
|
6
|
+
dataHubSvcUrl?: string;
|
|
34
7
|
};
|
|
35
8
|
export declare type View = {
|
|
36
9
|
id?: string;
|
|
@@ -114,4 +87,23 @@ export declare type View = {
|
|
|
114
87
|
template: null;
|
|
115
88
|
deletedDate?: string;
|
|
116
89
|
};
|
|
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
|
+
};
|
|
117
109
|
//# 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","sour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,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;AAEF,oBAAY,uBAAuB,GAAG;IACpC,KAAK,CAAC,EAAE;QACN,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC;IACF,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,oBAAY,iBAAiB,GAAG;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,oBAAY,eAAe,GAAG;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAEF,oBAAY,cAAc,GAAG;IAC3B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,IAAI,
|
|
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"}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.2.
|
|
2
|
+
"version": "1.2.2-beta.557.0",
|
|
3
3
|
"name": "@or-sdk/view-templates",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@or-sdk/base": "^0.26.3",
|
|
28
|
-
"@or-sdk/data-hub": "^
|
|
29
|
-
}
|
|
30
|
-
"gitHead": "602563a1b681a196a8eb625896a44faa3359b6f5"
|
|
28
|
+
"@or-sdk/data-hub-svc": "^1.1.6-beta.557.0"
|
|
29
|
+
}
|
|
31
30
|
}
|
package/src/ViewTemplates.ts
CHANGED
|
@@ -1,19 +1,26 @@
|
|
|
1
|
-
import { List } from '@or-sdk/base';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
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';
|
|
6
12
|
|
|
7
13
|
export class ViewTemplates {
|
|
8
|
-
private readonly
|
|
14
|
+
private readonly dataHubSvc: DataHubSvc;
|
|
9
15
|
|
|
10
16
|
constructor(params: ViewTemplatesConfig) {
|
|
11
|
-
const { token, discoveryUrl,
|
|
17
|
+
const { token, discoveryUrl, accountId, dataHubSvcUrl } = params;
|
|
12
18
|
|
|
13
|
-
this.
|
|
19
|
+
this.dataHubSvc = new DataHubSvc({
|
|
14
20
|
token,
|
|
15
21
|
discoveryUrl,
|
|
16
|
-
|
|
22
|
+
accountId,
|
|
23
|
+
dataHubSvcUrl,
|
|
17
24
|
});
|
|
18
25
|
}
|
|
19
26
|
|
|
@@ -23,33 +30,18 @@ export class ViewTemplates {
|
|
|
23
30
|
* const result = await viewTemplates.listViewTemplates();
|
|
24
31
|
* ```
|
|
25
32
|
*/
|
|
26
|
-
public async listViewTemplates(params: ListViewTemplatesParams = {}): Promise<List<
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
entity: ENTITY_NAME,
|
|
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',
|
|
31
37
|
params: {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
// overrides
|
|
36
|
-
...varPrams,
|
|
38
|
+
...params,
|
|
39
|
+
...paginationOptions,
|
|
40
|
+
... this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {},
|
|
37
41
|
},
|
|
38
|
-
|
|
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
|
-
};
|
|
42
|
+
});
|
|
51
43
|
|
|
52
|
-
return
|
|
44
|
+
return makeList<View>(result);
|
|
53
45
|
}
|
|
54
46
|
|
|
55
47
|
/**
|
|
@@ -58,35 +50,14 @@ export class ViewTemplates {
|
|
|
58
50
|
* const result = await viewTemplates.getViewTemplateById('card-template-id');
|
|
59
51
|
* ```
|
|
60
52
|
*/
|
|
61
|
-
async getViewTemplateById(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
53
|
+
public async getViewTemplateById(id: string): Promise<View> {
|
|
54
|
+
return this.dataHubSvc.makeRequest<View>({
|
|
55
|
+
method: 'GET',
|
|
56
|
+
route: `view-templates/${id}`,
|
|
65
57
|
params: {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
// overrides
|
|
69
|
-
...varPrams,
|
|
58
|
+
... this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {},
|
|
70
59
|
},
|
|
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
60
|
});
|
|
88
|
-
|
|
89
|
-
return result.data[operationName] as ViewTemplate;
|
|
90
61
|
}
|
|
91
62
|
|
|
92
63
|
/**
|
|
@@ -95,30 +66,19 @@ export class ViewTemplates {
|
|
|
95
66
|
* const result = await viewTemplates.download('view-template-id');
|
|
96
67
|
* ```
|
|
97
68
|
*/
|
|
98
|
-
public async download(viewTemplateId: string, options = {}): Promise<View> {
|
|
99
|
-
|
|
100
|
-
|
|
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',
|
|
101
73
|
data: {
|
|
102
|
-
|
|
103
|
-
|
|
74
|
+
viewId: viewTemplateId,
|
|
75
|
+
options,
|
|
76
|
+
sandbox,
|
|
77
|
+
},
|
|
78
|
+
params: {
|
|
79
|
+
... this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {},
|
|
104
80
|
},
|
|
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
81
|
});
|
|
120
|
-
|
|
121
|
-
return result.data[operationName] as View;
|
|
122
82
|
}
|
|
123
83
|
|
|
124
84
|
/**
|
|
@@ -127,28 +87,17 @@ export class ViewTemplates {
|
|
|
127
87
|
* const result = await viewTemplates.upgrade('view-template-id');
|
|
128
88
|
* ```
|
|
129
89
|
*/
|
|
130
|
-
public async upgrade(viewTemplateId: string, options = {}): Promise<
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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,
|
|
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
|
+
},
|
|
149
100
|
});
|
|
150
|
-
|
|
151
|
-
return result.data[operationName]!;
|
|
152
101
|
}
|
|
153
102
|
|
|
154
103
|
/**
|
package/src/constants.ts
CHANGED
|
@@ -1,111 +1 @@
|
|
|
1
|
-
export {
|
|
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';
|
|
1
|
+
export { DATA_HUB_SVC_SERVICE_KEY } from '@or-sdk/data-hub-svc';
|
package/src/types.ts
CHANGED
|
@@ -17,39 +17,9 @@ export type ViewTemplatesConfig = {
|
|
|
17
17
|
accountId?: string;
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
* Url of OneReach
|
|
20
|
+
* Url of OneReach DataHubSvc api
|
|
21
21
|
*/
|
|
22
|
-
|
|
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[];
|
|
22
|
+
dataHubSvcUrl?: string;
|
|
53
23
|
};
|
|
54
24
|
|
|
55
25
|
export type View = {
|
|
@@ -134,3 +104,26 @@ export type View = {
|
|
|
134
104
|
template: null;
|
|
135
105
|
deletedDate?: string;
|
|
136
106
|
};
|
|
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
|
+
};
|
package/src/utils/index.ts
CHANGED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var data_hub_1 = require("@or-sdk/data-hub");
|
|
4
|
-
var constants_1 = require("../constants");
|
|
5
|
-
function getGetByIdQuery(_a) {
|
|
6
|
-
var _b = _a.projection, projection = _b === void 0 ? [] : _b;
|
|
7
|
-
return "query getTemplate($entity: TemplateType!, $params: GetInput!, $sourceId: String) {\n getTemplate(entity: $entity, params: $params, sourceId: $sourceId) {\n ... on View {".concat((0, data_hub_1.getQueryProjectionPart)(projection.length ? projection : constants_1.DEFAULT_PROJECTION_GET_LIST), "\n }\n }\n}");
|
|
8
|
-
}
|
|
9
|
-
exports.default = getGetByIdQuery;
|
|
10
|
-
//# sourceMappingURL=getGetByIdQuery.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getGetByIdQuery.js","sourceRoot":"","sources":["../../../src/utils/getGetByIdQuery.ts"],"names":[],"mappings":";;AAAA,6CAA0D;AAC1D,0CAA2D;AAE3D,SAAS,eAAe,CAAC,EAA8C;QAA5C,kBAAe,EAAf,UAAU,mBAAG,EAAE,KAAA;IACxC,OAAO,uLAEU,IAAA,iCAAsB,EAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,uCAA2B,CAAC,oBAGrG,CAAC;AACH,CAAC;AAED,kBAAe,eAAe,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var data_hub_1 = require("@or-sdk/data-hub");
|
|
4
|
-
var constants_1 = require("../constants");
|
|
5
|
-
function getListQuery(_a) {
|
|
6
|
-
var _b = _a.projection, projection = _b === void 0 ? [] : _b;
|
|
7
|
-
return "query listTemplates($entity: TemplateType!, $params: ListInput!, $sourceId: String, $forceSandbox: Boolean) {\n listTemplates(entity: $entity, params: $params, sourceId: $sourceId, forceSandbox: $forceSandbox) {\n records {\n ... on View {".concat((0, data_hub_1.getQueryProjectionPart)(projection.length ? projection : constants_1.DEFAULT_PROJECTION_LIST), "\n }\n }\n last\n }\n}");
|
|
8
|
-
}
|
|
9
|
-
exports.default = getListQuery;
|
|
10
|
-
//# sourceMappingURL=getListQuery.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getListQuery.js","sourceRoot":"","sources":["../../../src/utils/getListQuery.ts"],"names":[],"mappings":";;AAAA,6CAA0D;AAC1D,0CAAuD;AAEvD,SAAS,YAAY,CAAC,EAA8C;QAA5C,kBAAe,EAAf,UAAU,mBAAG,EAAE,KAAA;IACrC,OAAO,kQAGY,IAAA,iCAAsB,EAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,mCAAuB,CAAC,uCAKnG,CAAC;AACH,CAAC;AAED,kBAAe,YAAY,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,15 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
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,13 +0,0 @@
|
|
|
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;
|
|
@@ -1,16 +0,0 @@
|
|
|
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;
|