@availity/mui-spaces 1.0.30 → 1.1.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 +9 -0
- package/dist/index.d.mts +9 -2
- package/dist/index.d.ts +9 -2
- package/dist/index.js +12 -9
- package/dist/index.mjs +12 -9
- package/package.json +1 -1
- package/src/lib/Spaces.test.tsx +93 -0
- package/src/lib/Spaces.tsx +5 -4
- package/src/lib/spaces-data.tsx +5 -3
- package/src/lib/spaces-types.tsx +22 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [1.1.0](https://github.com/Availity/element/compare/@availity/mui-spaces@1.0.31...@availity/mui-spaces@1.1.0) (2025-09-25)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **mui-spaces:** add operationName support ([f33f02b](https://github.com/Availity/element/commit/f33f02b2ef3cacee17a48a86849e2b4c96fac722))
|
|
11
|
+
|
|
12
|
+
## [1.0.31](https://github.com/Availity/element/compare/@availity/mui-spaces@1.0.30...@availity/mui-spaces@1.0.31) (2025-09-22)
|
|
13
|
+
|
|
5
14
|
## [1.0.30](https://github.com/Availity/element/compare/@availity/mui-spaces@1.0.29...@availity/mui-spaces@1.0.30) (2025-08-21)
|
|
6
15
|
|
|
7
16
|
|
package/dist/index.d.mts
CHANGED
|
@@ -85,6 +85,13 @@ type SpacesProps = {
|
|
|
85
85
|
/** Override the default variables used in the thanos query. Default: { types: [PAYERSPACE] }.
|
|
86
86
|
* If the spaces provider should contain configurations of a type other than PAYERSPACE, you must override this prop */
|
|
87
87
|
variables?: object;
|
|
88
|
+
/**
|
|
89
|
+
* Name for the GraphQL operation, used for debugging and monitoring.
|
|
90
|
+
*
|
|
91
|
+
* Format: `{ValueStream || PayerName}{AbbreviatedAppName}{Description}{Type}` (PascalCase)
|
|
92
|
+
* @example "OnbPsFavoritesQuery"
|
|
93
|
+
*/
|
|
94
|
+
operationName?: string;
|
|
88
95
|
/** The Client ID obtained from APIConnect. */
|
|
89
96
|
clientId?: string;
|
|
90
97
|
/** Children can be a react child or render prop. */
|
|
@@ -101,14 +108,14 @@ type SpacesProps = {
|
|
|
101
108
|
* Useful for if you already have the spaces in your app and don't want the spaces provider to have to fetch them again. */
|
|
102
109
|
spaces?: Space[];
|
|
103
110
|
};
|
|
104
|
-
type UseSpaces = (...ids: string[]) =>
|
|
111
|
+
type UseSpaces = (...ids: string[]) => Space[] | undefined;
|
|
105
112
|
|
|
106
113
|
declare const INITIAL_STATE: {
|
|
107
114
|
loading: boolean;
|
|
108
115
|
};
|
|
109
116
|
declare const SpacesContext: react.Context<SpacesContextType>;
|
|
110
117
|
declare const useSpacesContext: () => SpacesContextType;
|
|
111
|
-
declare const Spaces: ({ query, variables, clientId, children, payerIds, spaceIds, spaces: spacesFromProps, }: SpacesProps) => JSX.Element;
|
|
118
|
+
declare const Spaces: ({ query, variables, operationName, clientId, children, payerIds, spaceIds, spaces: spacesFromProps, }: SpacesProps) => JSX.Element;
|
|
112
119
|
declare const useSpaces: UseSpaces;
|
|
113
120
|
|
|
114
121
|
type SpacesLinkVariants = 'card' | 'list' | 'default' | undefined;
|
package/dist/index.d.ts
CHANGED
|
@@ -85,6 +85,13 @@ type SpacesProps = {
|
|
|
85
85
|
/** Override the default variables used in the thanos query. Default: { types: [PAYERSPACE] }.
|
|
86
86
|
* If the spaces provider should contain configurations of a type other than PAYERSPACE, you must override this prop */
|
|
87
87
|
variables?: object;
|
|
88
|
+
/**
|
|
89
|
+
* Name for the GraphQL operation, used for debugging and monitoring.
|
|
90
|
+
*
|
|
91
|
+
* Format: `{ValueStream || PayerName}{AbbreviatedAppName}{Description}{Type}` (PascalCase)
|
|
92
|
+
* @example "OnbPsFavoritesQuery"
|
|
93
|
+
*/
|
|
94
|
+
operationName?: string;
|
|
88
95
|
/** The Client ID obtained from APIConnect. */
|
|
89
96
|
clientId?: string;
|
|
90
97
|
/** Children can be a react child or render prop. */
|
|
@@ -101,14 +108,14 @@ type SpacesProps = {
|
|
|
101
108
|
* Useful for if you already have the spaces in your app and don't want the spaces provider to have to fetch them again. */
|
|
102
109
|
spaces?: Space[];
|
|
103
110
|
};
|
|
104
|
-
type UseSpaces = (...ids: string[]) =>
|
|
111
|
+
type UseSpaces = (...ids: string[]) => Space[] | undefined;
|
|
105
112
|
|
|
106
113
|
declare const INITIAL_STATE: {
|
|
107
114
|
loading: boolean;
|
|
108
115
|
};
|
|
109
116
|
declare const SpacesContext: react.Context<SpacesContextType>;
|
|
110
117
|
declare const useSpacesContext: () => SpacesContextType;
|
|
111
|
-
declare const Spaces: ({ query, variables, clientId, children, payerIds, spaceIds, spaces: spacesFromProps, }: SpacesProps) => JSX.Element;
|
|
118
|
+
declare const Spaces: ({ query, variables, operationName, clientId, children, payerIds, spaceIds, spaces: spacesFromProps, }: SpacesProps) => JSX.Element;
|
|
112
119
|
declare const useSpaces: UseSpaces;
|
|
113
120
|
|
|
114
121
|
type SpacesLinkVariants = 'card' | 'list' | 'default' | undefined;
|
package/dist/index.js
CHANGED
|
@@ -118,7 +118,7 @@ var spacesReducer = (state, action) => {
|
|
|
118
118
|
const { type } = action;
|
|
119
119
|
return actions[type](state, action);
|
|
120
120
|
};
|
|
121
|
-
var fetchSpaces = (_0) => __async(null, [_0], function* ({ query, clientId, variables }) {
|
|
121
|
+
var fetchSpaces = (_0) => __async(null, [_0], function* ({ query, clientId, variables, operationName }) {
|
|
122
122
|
const headers = {};
|
|
123
123
|
if (clientId) {
|
|
124
124
|
headers["X-Client-ID"] = clientId;
|
|
@@ -130,7 +130,8 @@ var fetchSpaces = (_0) => __async(null, [_0], function* ({ query, clientId, vari
|
|
|
130
130
|
} = yield import_api_axios.avWebQLApi.create(
|
|
131
131
|
{
|
|
132
132
|
query,
|
|
133
|
-
variables: __spreadValues({}, variables)
|
|
133
|
+
variables: __spreadValues({}, variables),
|
|
134
|
+
operationName: operationName || "PuiSpacesCmpAnonymousOperation"
|
|
134
135
|
},
|
|
135
136
|
{ headers: __spreadValues({}, headers) }
|
|
136
137
|
);
|
|
@@ -148,15 +149,16 @@ var fetchAllSpaces = (_0) => __async(null, [_0], function* ({
|
|
|
148
149
|
query,
|
|
149
150
|
clientId,
|
|
150
151
|
variables,
|
|
151
|
-
_spaces = []
|
|
152
|
+
_spaces = [],
|
|
153
|
+
operationName
|
|
152
154
|
}) {
|
|
153
|
-
const { items, currentPage, hasNextPage } = yield fetchSpaces({ query, clientId, variables });
|
|
155
|
+
const { items, currentPage, hasNextPage } = yield fetchSpaces({ query, clientId, variables, operationName });
|
|
154
156
|
_spaces.push(...items);
|
|
155
157
|
if (hasNextPage) {
|
|
156
158
|
const vars = __spreadProps(__spreadValues({}, variables), {
|
|
157
159
|
page: currentPage + 1
|
|
158
160
|
});
|
|
159
|
-
return fetchAllSpaces({ query, clientId, variables: vars, _spaces });
|
|
161
|
+
return fetchAllSpaces({ query, clientId, variables: vars, _spaces, operationName });
|
|
160
162
|
}
|
|
161
163
|
return _spaces;
|
|
162
164
|
});
|
|
@@ -582,6 +584,7 @@ var useSpacesContext = () => (0, import_react3.useContext)(SpacesContext);
|
|
|
582
584
|
var Spaces = ({
|
|
583
585
|
query = configurationFindMany_default,
|
|
584
586
|
variables = { types: ["PAYERSPACE"] },
|
|
587
|
+
operationName,
|
|
585
588
|
clientId,
|
|
586
589
|
children,
|
|
587
590
|
payerIds,
|
|
@@ -616,14 +619,14 @@ var Spaces = ({
|
|
|
616
619
|
}
|
|
617
620
|
if (spaceIds && spaceIds.length > 0) {
|
|
618
621
|
for (const id of spaceIds) {
|
|
619
|
-
if (!(spacesMap.has(id) || configIdsMap.has(id))) {
|
|
622
|
+
if (id && typeof id === "string" && id.trim() && !(spacesMap.has(id) || configIdsMap.has(id))) {
|
|
620
623
|
spaceIdsToQuery.add(id);
|
|
621
624
|
}
|
|
622
625
|
}
|
|
623
626
|
}
|
|
624
627
|
if (payerIds && payerIds.length > 0) {
|
|
625
628
|
for (const pid of payerIds) {
|
|
626
|
-
if (!payerIdsMap.has(pid)) {
|
|
629
|
+
if (pid && typeof pid === "string" && pid.trim() && !payerIdsMap.has(pid)) {
|
|
627
630
|
payerIdsToQuery.add(pid);
|
|
628
631
|
}
|
|
629
632
|
}
|
|
@@ -637,12 +640,12 @@ var Spaces = ({
|
|
|
637
640
|
queries: [
|
|
638
641
|
{
|
|
639
642
|
queryKey: ["id", spaceIdVars],
|
|
640
|
-
queryFn: () => fetchAllSpaces({ query, clientId, variables: spaceIdVars }),
|
|
643
|
+
queryFn: () => fetchAllSpaces({ query, clientId, variables: spaceIdVars, operationName }),
|
|
641
644
|
enabled: spaceIdsToQuery.size > 0
|
|
642
645
|
},
|
|
643
646
|
{
|
|
644
647
|
queryKey: ["id", payerIdVars],
|
|
645
|
-
queryFn: () => fetchAllSpaces({ query, clientId, variables: payerIdVars }),
|
|
648
|
+
queryFn: () => fetchAllSpaces({ query, clientId, variables: payerIdVars, operationName }),
|
|
646
649
|
enabled: payerIdsToQuery.size > 0
|
|
647
650
|
}
|
|
648
651
|
]
|
package/dist/index.mjs
CHANGED
|
@@ -76,7 +76,7 @@ var spacesReducer = (state, action) => {
|
|
|
76
76
|
const { type } = action;
|
|
77
77
|
return actions[type](state, action);
|
|
78
78
|
};
|
|
79
|
-
var fetchSpaces = (_0) => __async(null, [_0], function* ({ query, clientId, variables }) {
|
|
79
|
+
var fetchSpaces = (_0) => __async(null, [_0], function* ({ query, clientId, variables, operationName }) {
|
|
80
80
|
const headers = {};
|
|
81
81
|
if (clientId) {
|
|
82
82
|
headers["X-Client-ID"] = clientId;
|
|
@@ -88,7 +88,8 @@ var fetchSpaces = (_0) => __async(null, [_0], function* ({ query, clientId, vari
|
|
|
88
88
|
} = yield avWebQLApi.create(
|
|
89
89
|
{
|
|
90
90
|
query,
|
|
91
|
-
variables: __spreadValues({}, variables)
|
|
91
|
+
variables: __spreadValues({}, variables),
|
|
92
|
+
operationName: operationName || "PuiSpacesCmpAnonymousOperation"
|
|
92
93
|
},
|
|
93
94
|
{ headers: __spreadValues({}, headers) }
|
|
94
95
|
);
|
|
@@ -106,15 +107,16 @@ var fetchAllSpaces = (_0) => __async(null, [_0], function* ({
|
|
|
106
107
|
query,
|
|
107
108
|
clientId,
|
|
108
109
|
variables,
|
|
109
|
-
_spaces = []
|
|
110
|
+
_spaces = [],
|
|
111
|
+
operationName
|
|
110
112
|
}) {
|
|
111
|
-
const { items, currentPage, hasNextPage } = yield fetchSpaces({ query, clientId, variables });
|
|
113
|
+
const { items, currentPage, hasNextPage } = yield fetchSpaces({ query, clientId, variables, operationName });
|
|
112
114
|
_spaces.push(...items);
|
|
113
115
|
if (hasNextPage) {
|
|
114
116
|
const vars = __spreadProps(__spreadValues({}, variables), {
|
|
115
117
|
page: currentPage + 1
|
|
116
118
|
});
|
|
117
|
-
return fetchAllSpaces({ query, clientId, variables: vars, _spaces });
|
|
119
|
+
return fetchAllSpaces({ query, clientId, variables: vars, _spaces, operationName });
|
|
118
120
|
}
|
|
119
121
|
return _spaces;
|
|
120
122
|
});
|
|
@@ -540,6 +542,7 @@ var useSpacesContext = () => useContext2(SpacesContext);
|
|
|
540
542
|
var Spaces = ({
|
|
541
543
|
query = configurationFindMany_default,
|
|
542
544
|
variables = { types: ["PAYERSPACE"] },
|
|
545
|
+
operationName,
|
|
543
546
|
clientId,
|
|
544
547
|
children,
|
|
545
548
|
payerIds,
|
|
@@ -574,14 +577,14 @@ var Spaces = ({
|
|
|
574
577
|
}
|
|
575
578
|
if (spaceIds && spaceIds.length > 0) {
|
|
576
579
|
for (const id of spaceIds) {
|
|
577
|
-
if (!(spacesMap.has(id) || configIdsMap.has(id))) {
|
|
580
|
+
if (id && typeof id === "string" && id.trim() && !(spacesMap.has(id) || configIdsMap.has(id))) {
|
|
578
581
|
spaceIdsToQuery.add(id);
|
|
579
582
|
}
|
|
580
583
|
}
|
|
581
584
|
}
|
|
582
585
|
if (payerIds && payerIds.length > 0) {
|
|
583
586
|
for (const pid of payerIds) {
|
|
584
|
-
if (!payerIdsMap.has(pid)) {
|
|
587
|
+
if (pid && typeof pid === "string" && pid.trim() && !payerIdsMap.has(pid)) {
|
|
585
588
|
payerIdsToQuery.add(pid);
|
|
586
589
|
}
|
|
587
590
|
}
|
|
@@ -595,12 +598,12 @@ var Spaces = ({
|
|
|
595
598
|
queries: [
|
|
596
599
|
{
|
|
597
600
|
queryKey: ["id", spaceIdVars],
|
|
598
|
-
queryFn: () => fetchAllSpaces({ query, clientId, variables: spaceIdVars }),
|
|
601
|
+
queryFn: () => fetchAllSpaces({ query, clientId, variables: spaceIdVars, operationName }),
|
|
599
602
|
enabled: spaceIdsToQuery.size > 0
|
|
600
603
|
},
|
|
601
604
|
{
|
|
602
605
|
queryKey: ["id", payerIdVars],
|
|
603
|
-
queryFn: () => fetchAllSpaces({ query, clientId, variables: payerIdVars }),
|
|
606
|
+
queryFn: () => fetchAllSpaces({ query, clientId, variables: payerIdVars, operationName }),
|
|
604
607
|
enabled: payerIdsToQuery.size > 0
|
|
605
608
|
}
|
|
606
609
|
]
|
package/package.json
CHANGED
package/src/lib/Spaces.test.tsx
CHANGED
|
@@ -3,6 +3,7 @@ import { useState } from 'react';
|
|
|
3
3
|
import { render, waitFor, fireEvent } from '@testing-library/react';
|
|
4
4
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
5
5
|
import { Spaces, useSpaces, useSpacesContext } from '..';
|
|
6
|
+
import { fetchAllSpaces } from './spaces-data';
|
|
6
7
|
|
|
7
8
|
// eslint-disable-next-line @nx/enforce-module-boundaries
|
|
8
9
|
import { server } from '../../../mock/src/lib/server';
|
|
@@ -258,3 +259,95 @@ it('returns first payer space with when no spaceId passed', async () => {
|
|
|
258
259
|
expect(spc1).toBeDefined();
|
|
259
260
|
expect(spc2).toBeDefined();
|
|
260
261
|
});
|
|
262
|
+
describe('ID validation', () => {
|
|
263
|
+
let mockFetchAllSpaces: jest.SpyInstance;
|
|
264
|
+
|
|
265
|
+
beforeEach(() => {
|
|
266
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
267
|
+
mockFetchAllSpaces = jest.spyOn(require('./spaces-data'), 'fetchAllSpaces').mockResolvedValue([]);
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
afterEach(() => {
|
|
271
|
+
mockFetchAllSpaces.mockRestore();
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
it('filters invalid spaceIds before querying', async () => {
|
|
275
|
+
mockFetchAllSpaces.mockResolvedValue([]);
|
|
276
|
+
const queryClient = new QueryClient();
|
|
277
|
+
|
|
278
|
+
render(
|
|
279
|
+
<QueryClientProvider client={queryClient}>
|
|
280
|
+
<Spaces spaceIds={['valid-id', null, undefined, '', ' ', 123 as any] as any}>
|
|
281
|
+
<div>test</div>
|
|
282
|
+
</Spaces>
|
|
283
|
+
</QueryClientProvider>
|
|
284
|
+
);
|
|
285
|
+
|
|
286
|
+
await waitFor(() => {
|
|
287
|
+
expect(mockFetchAllSpaces).toHaveBeenCalledWith(
|
|
288
|
+
expect.objectContaining({
|
|
289
|
+
variables: expect.objectContaining({
|
|
290
|
+
ids: ['valid-id'],
|
|
291
|
+
}),
|
|
292
|
+
})
|
|
293
|
+
);
|
|
294
|
+
});
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
it('avoids querying if no valid spaceIds exist', async () => {
|
|
298
|
+
mockFetchAllSpaces.mockResolvedValue([]);
|
|
299
|
+
const queryClient = new QueryClient();
|
|
300
|
+
|
|
301
|
+
render(
|
|
302
|
+
<QueryClientProvider client={queryClient}>
|
|
303
|
+
<Spaces spaceIds={[null, undefined, '', ' ', 123 as any] as any}>
|
|
304
|
+
<div>test</div>
|
|
305
|
+
</Spaces>
|
|
306
|
+
</QueryClientProvider>
|
|
307
|
+
);
|
|
308
|
+
|
|
309
|
+
await waitFor(() => {
|
|
310
|
+
expect(mockFetchAllSpaces).not.toHaveBeenCalled();
|
|
311
|
+
});
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
it('filters invalid payerIds before querying', async () => {
|
|
315
|
+
mockFetchAllSpaces.mockResolvedValue([]);
|
|
316
|
+
const queryClient = new QueryClient();
|
|
317
|
+
|
|
318
|
+
render(
|
|
319
|
+
<QueryClientProvider client={queryClient}>
|
|
320
|
+
<Spaces payerIds={['valid-payer', null, undefined, '', ' ', 456 as any] as any}>
|
|
321
|
+
<div>test</div>
|
|
322
|
+
</Spaces>
|
|
323
|
+
</QueryClientProvider>
|
|
324
|
+
);
|
|
325
|
+
|
|
326
|
+
await waitFor(() => {
|
|
327
|
+
expect(mockFetchAllSpaces).toHaveBeenCalledWith(
|
|
328
|
+
expect.objectContaining({
|
|
329
|
+
variables: expect.objectContaining({
|
|
330
|
+
payerIDs: ['valid-payer'],
|
|
331
|
+
}),
|
|
332
|
+
})
|
|
333
|
+
);
|
|
334
|
+
});
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
it('avoids querying if no valid payerIds exist', async () => {
|
|
338
|
+
mockFetchAllSpaces.mockResolvedValue([]);
|
|
339
|
+
const queryClient = new QueryClient();
|
|
340
|
+
|
|
341
|
+
render(
|
|
342
|
+
<QueryClientProvider client={queryClient}>
|
|
343
|
+
<Spaces payerIds={[null, undefined, '', ' ', 456 as any] as any}>
|
|
344
|
+
<div>test</div>
|
|
345
|
+
</Spaces>
|
|
346
|
+
</QueryClientProvider>
|
|
347
|
+
);
|
|
348
|
+
|
|
349
|
+
await waitFor(() => {
|
|
350
|
+
expect(mockFetchAllSpaces).not.toHaveBeenCalled();
|
|
351
|
+
});
|
|
352
|
+
});
|
|
353
|
+
});
|
package/src/lib/Spaces.tsx
CHANGED
|
@@ -17,6 +17,7 @@ export const useSpacesContext = () => useContext(SpacesContext);
|
|
|
17
17
|
export const Spaces = ({
|
|
18
18
|
query = configurationFindMany,
|
|
19
19
|
variables = { types: ['PAYERSPACE'] },
|
|
20
|
+
operationName,
|
|
20
21
|
clientId,
|
|
21
22
|
children,
|
|
22
23
|
payerIds,
|
|
@@ -57,7 +58,7 @@ export const Spaces = ({
|
|
|
57
58
|
|
|
58
59
|
if (spaceIds && spaceIds.length > 0) {
|
|
59
60
|
for (const id of spaceIds) {
|
|
60
|
-
if (!(spacesMap.has(id) || configIdsMap.has(id))) {
|
|
61
|
+
if (id && typeof id === 'string' && id.trim() && !(spacesMap.has(id) || configIdsMap.has(id))) {
|
|
61
62
|
spaceIdsToQuery.add(id);
|
|
62
63
|
}
|
|
63
64
|
}
|
|
@@ -65,7 +66,7 @@ export const Spaces = ({
|
|
|
65
66
|
|
|
66
67
|
if (payerIds && payerIds.length > 0) {
|
|
67
68
|
for (const pid of payerIds) {
|
|
68
|
-
if (!payerIdsMap.has(pid)) {
|
|
69
|
+
if (pid && typeof pid === 'string' && pid.trim() && !payerIdsMap.has(pid)) {
|
|
69
70
|
payerIdsToQuery.add(pid);
|
|
70
71
|
}
|
|
71
72
|
}
|
|
@@ -82,12 +83,12 @@ export const Spaces = ({
|
|
|
82
83
|
queries: [
|
|
83
84
|
{
|
|
84
85
|
queryKey: ['id', spaceIdVars],
|
|
85
|
-
queryFn: () => fetchAllSpaces({ query, clientId, variables: spaceIdVars }),
|
|
86
|
+
queryFn: () => fetchAllSpaces({ query, clientId, variables: spaceIdVars, operationName }),
|
|
86
87
|
enabled: spaceIdsToQuery.size > 0,
|
|
87
88
|
},
|
|
88
89
|
{
|
|
89
90
|
queryKey: ['id', payerIdVars],
|
|
90
|
-
queryFn: () => fetchAllSpaces({ query, clientId, variables: payerIdVars }),
|
|
91
|
+
queryFn: () => fetchAllSpaces({ query, clientId, variables: payerIdVars, operationName }),
|
|
91
92
|
enabled: payerIdsToQuery.size > 0,
|
|
92
93
|
},
|
|
93
94
|
],
|
package/src/lib/spaces-data.tsx
CHANGED
|
@@ -28,7 +28,7 @@ export const spacesReducer = (state: SpacesContextType, action: SpacesReducerAct
|
|
|
28
28
|
return actions[type](state, action);
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
export const fetchSpaces = async ({ query, clientId, variables }: FetchSpacesProps) => {
|
|
31
|
+
export const fetchSpaces = async ({ query, clientId, variables, operationName }: FetchSpacesProps) => {
|
|
32
32
|
const headers: Record<string, string> = {};
|
|
33
33
|
|
|
34
34
|
if (clientId) {
|
|
@@ -43,6 +43,7 @@ export const fetchSpaces = async ({ query, clientId, variables }: FetchSpacesPro
|
|
|
43
43
|
{
|
|
44
44
|
query,
|
|
45
45
|
variables: { ...variables },
|
|
46
|
+
operationName: operationName || 'PuiSpacesCmpAnonymousOperation',
|
|
46
47
|
},
|
|
47
48
|
{ headers: { ...headers } }
|
|
48
49
|
);
|
|
@@ -64,8 +65,9 @@ export const fetchAllSpaces = async ({
|
|
|
64
65
|
clientId,
|
|
65
66
|
variables,
|
|
66
67
|
_spaces = [],
|
|
68
|
+
operationName,
|
|
67
69
|
}: FetchAllSpacesProps): Promise<Space[]> => {
|
|
68
|
-
const { items, currentPage, hasNextPage } = await fetchSpaces({ query, clientId, variables });
|
|
70
|
+
const { items, currentPage, hasNextPage } = await fetchSpaces({ query, clientId, variables, operationName });
|
|
69
71
|
|
|
70
72
|
_spaces.push(...items);
|
|
71
73
|
|
|
@@ -74,7 +76,7 @@ export const fetchAllSpaces = async ({
|
|
|
74
76
|
...variables,
|
|
75
77
|
page: currentPage + 1,
|
|
76
78
|
};
|
|
77
|
-
return fetchAllSpaces({ query, clientId, variables: vars, _spaces });
|
|
79
|
+
return fetchAllSpaces({ query, clientId, variables: vars, _spaces, operationName });
|
|
78
80
|
}
|
|
79
81
|
|
|
80
82
|
return _spaces;
|
package/src/lib/spaces-types.tsx
CHANGED
|
@@ -66,6 +66,13 @@ export type FetchSpacesProps = {
|
|
|
66
66
|
variables?: object;
|
|
67
67
|
/** The page sent to the avWebQL endpoint. */
|
|
68
68
|
page?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Name for the GraphQL operation, used for debugging and monitoring.
|
|
71
|
+
*
|
|
72
|
+
* Format: `{ValueStream || PayerName}{AbbreviatedAppName}{Description}{Type}` (PascalCase)
|
|
73
|
+
* @example "OnbPsFavoritesQuery"
|
|
74
|
+
*/
|
|
75
|
+
operationName?: string;
|
|
69
76
|
};
|
|
70
77
|
|
|
71
78
|
export type FetchAllSpacesProps = {
|
|
@@ -77,6 +84,13 @@ export type FetchAllSpacesProps = {
|
|
|
77
84
|
variables?: Record<string, any>;
|
|
78
85
|
/** Array of spaces to be passed into the Spaces provider. */
|
|
79
86
|
_spaces?: Space[];
|
|
87
|
+
/**
|
|
88
|
+
* Name for the GraphQL operation, used for debugging and monitoring.
|
|
89
|
+
*
|
|
90
|
+
* Format: `{ValueStream || PayerName}{AbbreviatedAppName}{Description}{Type}` (PascalCase)
|
|
91
|
+
* @example "OnbPsFavoritesQuery"
|
|
92
|
+
*/
|
|
93
|
+
operationName?: string;
|
|
80
94
|
};
|
|
81
95
|
|
|
82
96
|
export type SpacesContextType = {
|
|
@@ -116,6 +130,13 @@ export type SpacesProps = {
|
|
|
116
130
|
/** Override the default variables used in the thanos query. Default: { types: [PAYERSPACE] }.
|
|
117
131
|
* If the spaces provider should contain configurations of a type other than PAYERSPACE, you must override this prop */
|
|
118
132
|
variables?: object;
|
|
133
|
+
/**
|
|
134
|
+
* Name for the GraphQL operation, used for debugging and monitoring.
|
|
135
|
+
*
|
|
136
|
+
* Format: `{ValueStream || PayerName}{AbbreviatedAppName}{Description}{Type}` (PascalCase)
|
|
137
|
+
* @example "OnbPsFavoritesQuery"
|
|
138
|
+
*/
|
|
139
|
+
operationName?: string;
|
|
119
140
|
/** The Client ID obtained from APIConnect. */
|
|
120
141
|
clientId?: string;
|
|
121
142
|
/** Children can be a react child or render prop. */
|
|
@@ -133,4 +154,4 @@ export type SpacesProps = {
|
|
|
133
154
|
spaces?: Space[];
|
|
134
155
|
};
|
|
135
156
|
|
|
136
|
-
export type UseSpaces = (...ids: string[]) =>
|
|
157
|
+
export type UseSpaces = (...ids: string[]) => Space[] | undefined;
|