@or-sdk/views 0.13.1 → 0.17.1

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 (39) hide show
  1. package/dist/cjs/Views.js +97 -45
  2. package/dist/cjs/Views.js.map +1 -1
  3. package/dist/cjs/constants.js +5 -1
  4. package/dist/cjs/constants.js.map +1 -1
  5. package/dist/cjs/utils/addTagsIds.js +20 -0
  6. package/dist/cjs/utils/addTagsIds.js.map +1 -0
  7. package/dist/cjs/utils/filterTagIds.js +25 -0
  8. package/dist/cjs/utils/filterTagIds.js.map +1 -0
  9. package/dist/cjs/utils/index.js +13 -0
  10. package/dist/cjs/utils/index.js.map +1 -0
  11. package/dist/cjs/utils/removeTagIds.js +11 -0
  12. package/dist/cjs/utils/removeTagIds.js.map +1 -0
  13. package/dist/esm/Views.js +68 -41
  14. package/dist/esm/Views.js.map +1 -1
  15. package/dist/esm/constants.js +161 -0
  16. package/dist/esm/constants.js.map +1 -1
  17. package/dist/esm/utils/addTagsIds.js +9 -0
  18. package/dist/esm/utils/addTagsIds.js.map +1 -0
  19. package/dist/esm/utils/filterTagIds.js +23 -0
  20. package/dist/esm/utils/filterTagIds.js.map +1 -0
  21. package/dist/esm/utils/index.js +4 -0
  22. package/dist/esm/utils/index.js.map +1 -0
  23. package/dist/esm/utils/removeTagIds.js +9 -0
  24. package/dist/esm/utils/removeTagIds.js.map +1 -0
  25. package/dist/types/Views.d.ts +5 -1
  26. package/dist/types/constants.d.ts +4 -0
  27. package/dist/types/types.d.ts +1 -0
  28. package/dist/types/utils/addTagsIds.d.ts +3 -0
  29. package/dist/types/utils/filterTagIds.d.ts +6 -0
  30. package/dist/types/utils/index.d.ts +3 -0
  31. package/dist/types/utils/removeTagIds.d.ts +3 -0
  32. package/package.json +5 -4
  33. package/src/Views.ts +118 -23
  34. package/src/constants.ts +165 -0
  35. package/src/types.ts +4 -0
  36. package/src/utils/addTagsIds.ts +15 -0
  37. package/src/utils/filterTagIds.ts +27 -0
  38. package/src/utils/index.ts +6 -0
  39. package/src/utils/removeTagIds.ts +15 -0
package/src/constants.ts CHANGED
@@ -31,6 +31,39 @@ export const QUERY_LIST = `query list($entity: EntityType!, $params: ListInput!,
31
31
  }
32
32
  `;
33
33
 
34
+ export const QUERY_LIST_CROSSACCOUNT = `query listCrossAccount($entity: EntityType!, $params: ListInput!, $accountId: String!) {
35
+ listCrossAccount(entity: $entity, params: $params, accountId: $accountId) {
36
+ records {
37
+ ... on View {
38
+ id
39
+ data {
40
+ data
41
+ }
42
+ cardIds
43
+ mirrorCardIds
44
+ linkId
45
+ linkType
46
+ template {
47
+ category
48
+ description
49
+ help
50
+ icon
51
+ iconUrl
52
+ implicitly
53
+ label
54
+ publishedBy
55
+ tags
56
+ type
57
+ version
58
+ }
59
+ reference
60
+ }
61
+ }
62
+ last
63
+ }
64
+ }
65
+ `;
66
+
34
67
  export const QUERY_GET = `query get($entity: EntityType!, $params: GetInput!) {
35
68
  get(entity: $entity, params: $params) {
36
69
  ... on View {
@@ -75,6 +108,50 @@ export const QUERY_GET = `query get($entity: EntityType!, $params: GetInput!) {
75
108
  }
76
109
  }`;
77
110
 
111
+ export const QUERY_GET_CROSSACCOUNT = `query getCrossAccount($entity: EntityType!, $params: GetInput!, $accountId: String!) {
112
+ getCrossAccount(entity: $entity, params: $params, accountId: $accountId) {
113
+ ... on View {
114
+ id
115
+ cardIds
116
+ linkId
117
+ mirrorCardIds
118
+ schemaVersion
119
+ dateCreated
120
+ dateModified
121
+ data {
122
+ data
123
+ form {
124
+ code
125
+ data
126
+ style
127
+ template
128
+ }
129
+ presentation {
130
+ code
131
+ data
132
+ style
133
+ template
134
+ }
135
+ }
136
+ linkType
137
+ reference
138
+ template {
139
+ category
140
+ description
141
+ help
142
+ icon
143
+ iconUrl
144
+ implicitly
145
+ label
146
+ publishedBy
147
+ tags
148
+ type
149
+ version
150
+ }
151
+ }
152
+ }
153
+ }`;
154
+
78
155
  export const QUERY_CREATE = `mutation create($entity: EntityType!, $data: CreateInput!) {
79
156
  create(entity: $entity, data: $data) {
80
157
  ... on View {
@@ -119,6 +196,50 @@ export const QUERY_CREATE = `mutation create($entity: EntityType!, $data: Create
119
196
  }
120
197
  }`;
121
198
 
199
+ export const QUERY_CREATE_CROSSACCOUNT = `mutation createCrossAccount($entity: EntityType!, $data: CreateInput!, $accountId: String!) {
200
+ createCrossAccount(entity: $entity, data: $data, accountId: $accountId) {
201
+ ... on View {
202
+ id
203
+ cardIds
204
+ linkId
205
+ mirrorCardIds
206
+ schemaVersion
207
+ dateCreated
208
+ dateModified
209
+ data {
210
+ data
211
+ form {
212
+ code
213
+ data
214
+ style
215
+ template
216
+ }
217
+ presentation {
218
+ code
219
+ data
220
+ style
221
+ template
222
+ }
223
+ }
224
+ linkType
225
+ reference
226
+ template {
227
+ category
228
+ description
229
+ help
230
+ icon
231
+ iconUrl
232
+ implicitly
233
+ label
234
+ publishedBy
235
+ tags
236
+ type
237
+ version
238
+ }
239
+ }
240
+ }
241
+ }`;
242
+
122
243
  export const QUERY_UPDATE = `mutation update($entity: EntityType!, $data: UpdateInput!) {
123
244
  update(entity: $entity, data: $data) {
124
245
  ... on View {
@@ -163,6 +284,50 @@ export const QUERY_UPDATE = `mutation update($entity: EntityType!, $data: Update
163
284
  }
164
285
  }`;
165
286
 
287
+ export const QUERY_UPDATE_CROSSACCOUNT = `mutation updateCrossAccount($entity: EntityType!, $data: UpdateInput!, $accountId: String!) {
288
+ updateCrossAccount(entity: $entity, data: $data, accountId: $accountId) {
289
+ ... on View {
290
+ id
291
+ cardIds
292
+ linkId
293
+ mirrorCardIds
294
+ schemaVersion
295
+ dateCreated
296
+ dateModified
297
+ data {
298
+ data
299
+ form {
300
+ code
301
+ data
302
+ style
303
+ template
304
+ }
305
+ presentation {
306
+ code
307
+ data
308
+ style
309
+ template
310
+ }
311
+ }
312
+ linkType
313
+ reference
314
+ template {
315
+ category
316
+ description
317
+ help
318
+ icon
319
+ iconUrl
320
+ implicitly
321
+ label
322
+ publishedBy
323
+ tags
324
+ type
325
+ version
326
+ }
327
+ }
328
+ }
329
+ }`;
330
+
166
331
  export const QUERY_DELETE = `mutation deleteTemporarily($entity: EntityType!, $data: DeleteInput!) {
167
332
  deleteTemporarily(entity: $entity, data: $data) {
168
333
  ... on AsyncRequest {
package/src/types.ts CHANGED
@@ -9,6 +9,10 @@ export type ViewsConfig = {
9
9
  * Url of OneReach service discovery api
10
10
  */
11
11
  discoveryUrl: string;
12
+ /**
13
+ * Account ID for cross-account requests (super admin only)
14
+ */
15
+ accountId?: string;
12
16
  };
13
17
 
14
18
  export type View = {
@@ -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,6 @@
1
+ /**
2
+ * @internal
3
+ */
4
+ export { default as filterTagIds } from './filterTagIds';
5
+ export { default as addTagsIds } from './addTagsIds';
6
+ export { default as removeTagIds } from './removeTagIds';
@@ -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;