@or-sdk/views 0.26.0 → 0.27.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/CHANGELOG.md +0 -13
- package/README.md +1 -1
- package/dist/cjs/Views.js +121 -64
- package/dist/cjs/Views.js.map +1 -1
- package/dist/cjs/constants.js +13 -3
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/utils/addTagsIds.js +20 -0
- package/dist/cjs/utils/addTagsIds.js.map +1 -0
- package/dist/cjs/utils/filterTagIds.js +25 -0
- package/dist/cjs/utils/filterTagIds.js.map +1 -0
- package/dist/cjs/utils/index.js +13 -0
- package/dist/cjs/utils/index.js.map +1 -0
- package/dist/cjs/utils/removeTagIds.js +11 -0
- package/dist/cjs/utils/removeTagIds.js.map +1 -0
- package/dist/esm/Views.js +92 -47
- package/dist/esm/Views.js.map +1 -1
- package/dist/esm/constants.js +331 -1
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/utils/addTagsIds.js +9 -0
- package/dist/esm/utils/addTagsIds.js.map +1 -0
- package/dist/esm/utils/filterTagIds.js +23 -0
- package/dist/esm/utils/filterTagIds.js.map +1 -0
- package/dist/esm/utils/index.js +4 -0
- package/dist/esm/utils/index.js.map +1 -0
- package/dist/esm/utils/removeTagIds.js +9 -0
- package/dist/esm/utils/removeTagIds.js.map +1 -0
- package/dist/types/Views.d.ts +6 -5
- package/dist/types/Views.d.ts.map +1 -1
- package/dist/types/constants.d.ts +11 -1
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/types.d.ts +1 -13
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/addTagsIds.d.ts +4 -0
- package/dist/types/utils/addTagsIds.d.ts.map +1 -0
- package/dist/types/utils/filterTagIds.d.ts +7 -0
- package/dist/types/utils/filterTagIds.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +4 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/dist/types/utils/removeTagIds.d.ts +4 -0
- package/dist/types/utils/removeTagIds.d.ts.map +1 -0
- package/package.json +4 -4
- package/src/Views.ts +131 -64
- package/src/constants.ts +341 -1
- package/src/types.ts +2 -16
- package/src/utils/addTagsIds.ts +15 -0
- package/src/utils/filterTagIds.ts +27 -0
- package/src/utils/index.ts +6 -0
- package/src/utils/removeTagIds.ts +15 -0
package/src/Views.ts
CHANGED
|
@@ -1,47 +1,75 @@
|
|
|
1
|
-
import { List
|
|
2
|
-
import {
|
|
3
|
-
import { ViewsConfig, View
|
|
1
|
+
import { List } from '@or-sdk/base';
|
|
2
|
+
import { DataHub, GraphqlResponse, GraphqlResponseCheckExecution, GraphqlResponseDelete, OperationNames } from '@or-sdk/data-hub';
|
|
3
|
+
import { ViewsConfig, View } from './types';
|
|
4
|
+
import {
|
|
5
|
+
ENTITY_NAME,
|
|
6
|
+
QUERY_LIST,
|
|
7
|
+
QUERY_GET,
|
|
8
|
+
QUERY_CREATE,
|
|
9
|
+
QUERY_UPDATE,
|
|
10
|
+
QUERY_DELETE,
|
|
11
|
+
QUERY_GET_CROSSACCOUNT,
|
|
12
|
+
QUERY_LIST_CROSSACCOUNT,
|
|
13
|
+
QUERY_CREATE_CROSSACCOUNT,
|
|
14
|
+
QUERY_UPDATE_CROSSACCOUNT,
|
|
15
|
+
} from './constants';
|
|
4
16
|
import { Tags, Taggable, filterTagIds, addTagsIds, removeTagIds } from '@or-sdk/tags';
|
|
5
17
|
|
|
6
18
|
export class Views implements Taggable<View> {
|
|
7
|
-
private readonly
|
|
19
|
+
private readonly dataHub: DataHub;
|
|
8
20
|
private readonly tags: Tags;
|
|
9
21
|
|
|
10
22
|
constructor(params: ViewsConfig) {
|
|
11
|
-
const { token, discoveryUrl, accountId,
|
|
23
|
+
const { token, discoveryUrl, accountId, dataHubUrl } = params;
|
|
12
24
|
|
|
13
|
-
this.
|
|
25
|
+
this.dataHub = new DataHub({
|
|
14
26
|
token,
|
|
15
27
|
discoveryUrl,
|
|
16
28
|
accountId,
|
|
17
|
-
|
|
29
|
+
dataHubUrl,
|
|
18
30
|
});
|
|
19
31
|
this.tags = new Tags({
|
|
20
32
|
token,
|
|
21
33
|
discoveryUrl,
|
|
22
34
|
accountId,
|
|
23
|
-
|
|
35
|
+
dataHubUrl,
|
|
24
36
|
});
|
|
25
37
|
}
|
|
26
38
|
|
|
39
|
+
async init() {
|
|
40
|
+
await Promise.all([
|
|
41
|
+
this.dataHub.init(),
|
|
42
|
+
this.tags.init(),
|
|
43
|
+
]);
|
|
44
|
+
}
|
|
45
|
+
|
|
27
46
|
/**
|
|
28
47
|
* List views
|
|
29
48
|
* ```typescript
|
|
30
49
|
* const viewList = await views.listViews();
|
|
31
50
|
* ```
|
|
32
51
|
*/
|
|
33
|
-
public async listViews(
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
route: 'views',
|
|
52
|
+
public async listViews(): Promise<List<View>> {
|
|
53
|
+
const variables = {
|
|
54
|
+
entity: ENTITY_NAME,
|
|
37
55
|
params: {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
56
|
+
queryParams: {},
|
|
57
|
+
includeDeleted: false,
|
|
58
|
+
includeExisting: true,
|
|
59
|
+
limit: 30,
|
|
41
60
|
},
|
|
42
|
-
|
|
61
|
+
... this.dataHub.isCrossAccount ? { accountId: this.dataHub.currentAccountId } : { sandbox: false },
|
|
62
|
+
};
|
|
43
63
|
|
|
44
|
-
|
|
64
|
+
const operationName = this.dataHub.getOperationName(OperationNames.LIST);
|
|
65
|
+
|
|
66
|
+
const data = {
|
|
67
|
+
operationName,
|
|
68
|
+
query: this.dataHub.isCrossAccount ? QUERY_LIST_CROSSACCOUNT : QUERY_LIST,
|
|
69
|
+
variables,
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
return this.dataHub.getFullList<View>('POST', '/graphql', data);
|
|
45
73
|
}
|
|
46
74
|
|
|
47
75
|
/**
|
|
@@ -51,13 +79,31 @@ export class Views implements Taggable<View> {
|
|
|
51
79
|
* ```
|
|
52
80
|
*/
|
|
53
81
|
public async getView(id: string): Promise<View> {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
route: `views/${id}`,
|
|
82
|
+
const variables = {
|
|
83
|
+
entity: ENTITY_NAME,
|
|
57
84
|
params: {
|
|
58
|
-
|
|
85
|
+
id,
|
|
86
|
+
includeDeleted: false,
|
|
87
|
+
includeExisting: true,
|
|
59
88
|
},
|
|
89
|
+
... this.dataHub.isCrossAccount ? { accountId: this.dataHub.currentAccountId } : {},
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const operationName = this.dataHub.getOperationName(OperationNames.GET);
|
|
93
|
+
|
|
94
|
+
const data = {
|
|
95
|
+
operationName,
|
|
96
|
+
query: this.dataHub.isCrossAccount ? QUERY_GET_CROSSACCOUNT : QUERY_GET,
|
|
97
|
+
variables,
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const result = await this.dataHub.makeRequest<GraphqlResponse<View>>({
|
|
101
|
+
method: 'POST',
|
|
102
|
+
route: '/graphql',
|
|
103
|
+
data,
|
|
60
104
|
});
|
|
105
|
+
|
|
106
|
+
return result.data[operationName] as View;
|
|
61
107
|
}
|
|
62
108
|
|
|
63
109
|
/**
|
|
@@ -69,7 +115,7 @@ export class Views implements Taggable<View> {
|
|
|
69
115
|
* ```
|
|
70
116
|
*/
|
|
71
117
|
public async saveView(source: View): Promise<View> {
|
|
72
|
-
return
|
|
118
|
+
return source.id ? this.updateView(source) : this.createView(source);
|
|
73
119
|
}
|
|
74
120
|
|
|
75
121
|
/**
|
|
@@ -79,21 +125,29 @@ export class Views implements Taggable<View> {
|
|
|
79
125
|
* ```
|
|
80
126
|
*/
|
|
81
127
|
public async createView(source: View): Promise<View> {
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
route: 'views/new',
|
|
128
|
+
const variables = {
|
|
129
|
+
entity: ENTITY_NAME,
|
|
85
130
|
data: {
|
|
86
|
-
|
|
87
|
-
...source,
|
|
88
|
-
id: 'new', //TODO: remove later
|
|
89
|
-
},
|
|
90
|
-
},
|
|
91
|
-
params: {
|
|
92
|
-
... this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {},
|
|
131
|
+
body: source,
|
|
93
132
|
},
|
|
133
|
+
... this.dataHub.isCrossAccount ? { accountId: this.dataHub.currentAccountId } : {},
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const operationName = this.dataHub.getOperationName(OperationNames.CREATE);
|
|
137
|
+
|
|
138
|
+
const data = {
|
|
139
|
+
operationName,
|
|
140
|
+
query: this.dataHub.isCrossAccount ? QUERY_CREATE_CROSSACCOUNT : QUERY_CREATE,
|
|
141
|
+
variables,
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const result = await this.dataHub.makeRequest<GraphqlResponse<View>>({
|
|
145
|
+
method: 'POST',
|
|
146
|
+
route: '/graphql',
|
|
147
|
+
data,
|
|
94
148
|
});
|
|
95
149
|
|
|
96
|
-
return
|
|
150
|
+
return result.data[operationName] as View;
|
|
97
151
|
}
|
|
98
152
|
|
|
99
153
|
/**
|
|
@@ -103,18 +157,30 @@ export class Views implements Taggable<View> {
|
|
|
103
157
|
* ```
|
|
104
158
|
*/
|
|
105
159
|
public async updateView(source: View): Promise<View> {
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
route: `views/${source.id}`,
|
|
160
|
+
const variables = {
|
|
161
|
+
entity: ENTITY_NAME,
|
|
109
162
|
data: {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
params: {
|
|
113
|
-
... this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {},
|
|
163
|
+
id: source.id,
|
|
164
|
+
body: source,
|
|
114
165
|
},
|
|
166
|
+
... this.dataHub.isCrossAccount ? { accountId: this.dataHub.currentAccountId } : {},
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
const operationName = this.dataHub.getOperationName(OperationNames.UPDATE);
|
|
170
|
+
|
|
171
|
+
const data = {
|
|
172
|
+
operationName,
|
|
173
|
+
query: this.dataHub.isCrossAccount ? QUERY_UPDATE_CROSSACCOUNT : QUERY_UPDATE,
|
|
174
|
+
variables,
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
const result = await this.dataHub.makeRequest<GraphqlResponse<View>>({
|
|
178
|
+
method: 'POST',
|
|
179
|
+
route: '/graphql',
|
|
180
|
+
data,
|
|
115
181
|
});
|
|
116
182
|
|
|
117
|
-
return
|
|
183
|
+
return result.data[operationName] as View;
|
|
118
184
|
}
|
|
119
185
|
|
|
120
186
|
/**
|
|
@@ -123,33 +189,34 @@ export class Views implements Taggable<View> {
|
|
|
123
189
|
* await views.deleteView('view-id');
|
|
124
190
|
* ```
|
|
125
191
|
*/
|
|
126
|
-
public async deleteView(viewId: string
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
192
|
+
public async deleteView(viewId: string): Promise<GraphqlResponseCheckExecution> {
|
|
193
|
+
if (this.dataHub.isCrossAccount) {
|
|
194
|
+
throw Error('Cross-account deleting is not implemented.');
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const variables = {
|
|
198
|
+
entity: ENTITY_NAME,
|
|
130
199
|
data: {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
params: {
|
|
134
|
-
... this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {},
|
|
200
|
+
id: viewId,
|
|
201
|
+
subscribe: true,
|
|
135
202
|
},
|
|
136
|
-
}
|
|
137
|
-
}
|
|
203
|
+
};
|
|
138
204
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
},
|
|
205
|
+
const operationName = this.dataHub.getOperationName(OperationNames.DELETE_TEMPORARILY);
|
|
206
|
+
|
|
207
|
+
const data = {
|
|
208
|
+
operationName,
|
|
209
|
+
query: QUERY_DELETE,
|
|
210
|
+
variables,
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
const result = await this.dataHub.makeRequest<GraphqlResponse<void>>({
|
|
214
|
+
method: 'POST',
|
|
215
|
+
route: '/graphql',
|
|
216
|
+
data,
|
|
152
217
|
});
|
|
218
|
+
|
|
219
|
+
return this.dataHub.subscribe((result.data[operationName] as GraphqlResponseDelete).requestId);
|
|
153
220
|
}
|
|
154
221
|
|
|
155
222
|
/**
|
package/src/constants.ts
CHANGED
|
@@ -1 +1,341 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { DATA_HUB_SERVICE_KEY } from '@or-sdk/data-hub';
|
|
2
|
+
|
|
3
|
+
export const QUERY_LIST = `query list($entity: EntityType!, $params: ListInput!, $sandbox: Boolean) {
|
|
4
|
+
list(entity: $entity, params: $params, sandbox: $sandbox) {
|
|
5
|
+
records {
|
|
6
|
+
... on View {
|
|
7
|
+
id
|
|
8
|
+
data {
|
|
9
|
+
data
|
|
10
|
+
}
|
|
11
|
+
cardIds
|
|
12
|
+
mirrorCardIds
|
|
13
|
+
linkId
|
|
14
|
+
linkType
|
|
15
|
+
template {
|
|
16
|
+
category
|
|
17
|
+
description
|
|
18
|
+
help
|
|
19
|
+
icon
|
|
20
|
+
iconUrl
|
|
21
|
+
implicitly
|
|
22
|
+
label
|
|
23
|
+
publishedBy
|
|
24
|
+
tags
|
|
25
|
+
type
|
|
26
|
+
version
|
|
27
|
+
}
|
|
28
|
+
reference
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
last
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
`;
|
|
35
|
+
|
|
36
|
+
export const QUERY_LIST_CROSSACCOUNT = `query listCrossAccount($entity: EntityType!, $params: ListInput!, $accountId: String!) {
|
|
37
|
+
listCrossAccount(entity: $entity, params: $params, accountId: $accountId) {
|
|
38
|
+
records {
|
|
39
|
+
... on View {
|
|
40
|
+
id
|
|
41
|
+
data {
|
|
42
|
+
data
|
|
43
|
+
}
|
|
44
|
+
cardIds
|
|
45
|
+
mirrorCardIds
|
|
46
|
+
linkId
|
|
47
|
+
linkType
|
|
48
|
+
template {
|
|
49
|
+
category
|
|
50
|
+
description
|
|
51
|
+
help
|
|
52
|
+
icon
|
|
53
|
+
iconUrl
|
|
54
|
+
implicitly
|
|
55
|
+
label
|
|
56
|
+
publishedBy
|
|
57
|
+
tags
|
|
58
|
+
type
|
|
59
|
+
version
|
|
60
|
+
}
|
|
61
|
+
reference
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
last
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
`;
|
|
68
|
+
|
|
69
|
+
export const QUERY_GET = `query get($entity: EntityType!, $params: GetInput!) {
|
|
70
|
+
get(entity: $entity, params: $params) {
|
|
71
|
+
... on View {
|
|
72
|
+
id
|
|
73
|
+
cardIds
|
|
74
|
+
linkId
|
|
75
|
+
mirrorCardIds
|
|
76
|
+
schemaVersion
|
|
77
|
+
dateCreated
|
|
78
|
+
dateModified
|
|
79
|
+
data {
|
|
80
|
+
data
|
|
81
|
+
form {
|
|
82
|
+
code
|
|
83
|
+
data
|
|
84
|
+
style
|
|
85
|
+
template
|
|
86
|
+
}
|
|
87
|
+
presentation {
|
|
88
|
+
code
|
|
89
|
+
data
|
|
90
|
+
style
|
|
91
|
+
template
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
linkType
|
|
95
|
+
reference
|
|
96
|
+
template {
|
|
97
|
+
category
|
|
98
|
+
description
|
|
99
|
+
help
|
|
100
|
+
icon
|
|
101
|
+
iconUrl
|
|
102
|
+
implicitly
|
|
103
|
+
label
|
|
104
|
+
publishedBy
|
|
105
|
+
tags
|
|
106
|
+
type
|
|
107
|
+
version
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}`;
|
|
112
|
+
|
|
113
|
+
export const QUERY_GET_CROSSACCOUNT = `query getCrossAccount($entity: EntityType!, $params: GetInput!, $accountId: String!) {
|
|
114
|
+
getCrossAccount(entity: $entity, params: $params, accountId: $accountId) {
|
|
115
|
+
... on View {
|
|
116
|
+
id
|
|
117
|
+
cardIds
|
|
118
|
+
linkId
|
|
119
|
+
mirrorCardIds
|
|
120
|
+
schemaVersion
|
|
121
|
+
dateCreated
|
|
122
|
+
dateModified
|
|
123
|
+
data {
|
|
124
|
+
data
|
|
125
|
+
form {
|
|
126
|
+
code
|
|
127
|
+
data
|
|
128
|
+
style
|
|
129
|
+
template
|
|
130
|
+
}
|
|
131
|
+
presentation {
|
|
132
|
+
code
|
|
133
|
+
data
|
|
134
|
+
style
|
|
135
|
+
template
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
linkType
|
|
139
|
+
reference
|
|
140
|
+
template {
|
|
141
|
+
category
|
|
142
|
+
description
|
|
143
|
+
help
|
|
144
|
+
icon
|
|
145
|
+
iconUrl
|
|
146
|
+
implicitly
|
|
147
|
+
label
|
|
148
|
+
publishedBy
|
|
149
|
+
tags
|
|
150
|
+
type
|
|
151
|
+
version
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}`;
|
|
156
|
+
|
|
157
|
+
export const QUERY_CREATE = `mutation create($entity: EntityType!, $data: CreateInput!) {
|
|
158
|
+
create(entity: $entity, data: $data) {
|
|
159
|
+
... on View {
|
|
160
|
+
id
|
|
161
|
+
cardIds
|
|
162
|
+
linkId
|
|
163
|
+
mirrorCardIds
|
|
164
|
+
schemaVersion
|
|
165
|
+
dateCreated
|
|
166
|
+
dateModified
|
|
167
|
+
data {
|
|
168
|
+
data
|
|
169
|
+
form {
|
|
170
|
+
code
|
|
171
|
+
data
|
|
172
|
+
style
|
|
173
|
+
template
|
|
174
|
+
}
|
|
175
|
+
presentation {
|
|
176
|
+
code
|
|
177
|
+
data
|
|
178
|
+
style
|
|
179
|
+
template
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
linkType
|
|
183
|
+
reference
|
|
184
|
+
template {
|
|
185
|
+
category
|
|
186
|
+
description
|
|
187
|
+
help
|
|
188
|
+
icon
|
|
189
|
+
iconUrl
|
|
190
|
+
implicitly
|
|
191
|
+
label
|
|
192
|
+
publishedBy
|
|
193
|
+
tags
|
|
194
|
+
type
|
|
195
|
+
version
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}`;
|
|
200
|
+
|
|
201
|
+
export const QUERY_CREATE_CROSSACCOUNT = `mutation createCrossAccount($entity: EntityType!, $data: CreateInput!, $accountId: String!) {
|
|
202
|
+
createCrossAccount(entity: $entity, data: $data, accountId: $accountId) {
|
|
203
|
+
... on View {
|
|
204
|
+
id
|
|
205
|
+
cardIds
|
|
206
|
+
linkId
|
|
207
|
+
mirrorCardIds
|
|
208
|
+
schemaVersion
|
|
209
|
+
dateCreated
|
|
210
|
+
dateModified
|
|
211
|
+
data {
|
|
212
|
+
data
|
|
213
|
+
form {
|
|
214
|
+
code
|
|
215
|
+
data
|
|
216
|
+
style
|
|
217
|
+
template
|
|
218
|
+
}
|
|
219
|
+
presentation {
|
|
220
|
+
code
|
|
221
|
+
data
|
|
222
|
+
style
|
|
223
|
+
template
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
linkType
|
|
227
|
+
reference
|
|
228
|
+
template {
|
|
229
|
+
category
|
|
230
|
+
description
|
|
231
|
+
help
|
|
232
|
+
icon
|
|
233
|
+
iconUrl
|
|
234
|
+
implicitly
|
|
235
|
+
label
|
|
236
|
+
publishedBy
|
|
237
|
+
tags
|
|
238
|
+
type
|
|
239
|
+
version
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}`;
|
|
244
|
+
|
|
245
|
+
export const QUERY_UPDATE = `mutation update($entity: EntityType!, $data: UpdateInput!) {
|
|
246
|
+
update(entity: $entity, data: $data) {
|
|
247
|
+
... on View {
|
|
248
|
+
id
|
|
249
|
+
cardIds
|
|
250
|
+
linkId
|
|
251
|
+
mirrorCardIds
|
|
252
|
+
schemaVersion
|
|
253
|
+
dateCreated
|
|
254
|
+
dateModified
|
|
255
|
+
data {
|
|
256
|
+
data
|
|
257
|
+
form {
|
|
258
|
+
code
|
|
259
|
+
data
|
|
260
|
+
style
|
|
261
|
+
template
|
|
262
|
+
}
|
|
263
|
+
presentation {
|
|
264
|
+
code
|
|
265
|
+
data
|
|
266
|
+
style
|
|
267
|
+
template
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
linkType
|
|
271
|
+
reference
|
|
272
|
+
template {
|
|
273
|
+
category
|
|
274
|
+
description
|
|
275
|
+
help
|
|
276
|
+
icon
|
|
277
|
+
iconUrl
|
|
278
|
+
implicitly
|
|
279
|
+
label
|
|
280
|
+
publishedBy
|
|
281
|
+
tags
|
|
282
|
+
type
|
|
283
|
+
version
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}`;
|
|
288
|
+
|
|
289
|
+
export const QUERY_UPDATE_CROSSACCOUNT = `mutation updateCrossAccount($entity: EntityType!, $data: UpdateInput!, $accountId: String!) {
|
|
290
|
+
updateCrossAccount(entity: $entity, data: $data, accountId: $accountId) {
|
|
291
|
+
... on View {
|
|
292
|
+
id
|
|
293
|
+
cardIds
|
|
294
|
+
linkId
|
|
295
|
+
mirrorCardIds
|
|
296
|
+
schemaVersion
|
|
297
|
+
dateCreated
|
|
298
|
+
dateModified
|
|
299
|
+
data {
|
|
300
|
+
data
|
|
301
|
+
form {
|
|
302
|
+
code
|
|
303
|
+
data
|
|
304
|
+
style
|
|
305
|
+
template
|
|
306
|
+
}
|
|
307
|
+
presentation {
|
|
308
|
+
code
|
|
309
|
+
data
|
|
310
|
+
style
|
|
311
|
+
template
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
linkType
|
|
315
|
+
reference
|
|
316
|
+
template {
|
|
317
|
+
category
|
|
318
|
+
description
|
|
319
|
+
help
|
|
320
|
+
icon
|
|
321
|
+
iconUrl
|
|
322
|
+
implicitly
|
|
323
|
+
label
|
|
324
|
+
publishedBy
|
|
325
|
+
tags
|
|
326
|
+
type
|
|
327
|
+
version
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}`;
|
|
332
|
+
|
|
333
|
+
export const QUERY_DELETE = `mutation deleteTemporarily($entity: EntityType!, $data: DeleteInput!) {
|
|
334
|
+
deleteTemporarily(entity: $entity, data: $data) {
|
|
335
|
+
... on AsyncRequest {
|
|
336
|
+
requestId
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}`;
|
|
340
|
+
|
|
341
|
+
export const ENTITY_NAME = 'VIEW';
|
package/src/types.ts
CHANGED
|
@@ -17,9 +17,9 @@ export type ViewsConfig = {
|
|
|
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
23
|
};
|
|
24
24
|
|
|
25
25
|
export type View = {
|
|
@@ -104,17 +104,3 @@ export type View = {
|
|
|
104
104
|
template: null;
|
|
105
105
|
deletedDate?: string;
|
|
106
106
|
};
|
|
107
|
-
|
|
108
|
-
export type ListViewParams = {
|
|
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
|
-
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
View,
|
|
3
|
+
} from '../types';
|
|
4
|
+
|
|
5
|
+
function addTagIds(source: View, tagIds: string[]): View {
|
|
6
|
+
if (!Array.isArray(source.data.data.filterByTagIds)) {
|
|
7
|
+
source.data.data.filterByTagIds = [];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
source.data.data.filterByTagIds = [...source.data.data.filterByTagIds, ...tagIds];
|
|
11
|
+
|
|
12
|
+
return source;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default addTagIds;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
View,
|
|
3
|
+
} from '../types';
|
|
4
|
+
|
|
5
|
+
function filterTagIds(source: View, tagIdsToFilter: string[]): { newIds: string[]; existingIds: string[]; } {
|
|
6
|
+
let newIds: string[] = [];
|
|
7
|
+
const existingIds: string[] = [];
|
|
8
|
+
|
|
9
|
+
if (!Array.isArray(source.data.data.filterByTagIds)) {
|
|
10
|
+
newIds = tagIdsToFilter;
|
|
11
|
+
} else {
|
|
12
|
+
tagIdsToFilter.forEach(tagId => {
|
|
13
|
+
if (source.data.data.filterByTagIds!.indexOf(tagId) !== -1) {
|
|
14
|
+
existingIds.push(tagId);
|
|
15
|
+
} else {
|
|
16
|
+
newIds.push(tagId);
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
newIds,
|
|
23
|
+
existingIds,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default filterTagIds;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
View,
|
|
3
|
+
} from '../types';
|
|
4
|
+
|
|
5
|
+
function removeTagIds(source: View, tagIds: string[]): View {
|
|
6
|
+
if (!Array.isArray(source.data.data.filterByTagIds)) {
|
|
7
|
+
source.data.data.filterByTagIds = [];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
source.data.data.filterByTagIds = source.data.data.filterByTagIds.filter((id: string) => tagIds.indexOf(id) === -1);
|
|
11
|
+
|
|
12
|
+
return source;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default removeTagIds;
|