@availity/mui-spaces 1.0.31 → 1.1.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,24 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [1.1.1](https://github.com/Availity/element/compare/@availity/mui-spaces@1.1.0...@availity/mui-spaces@1.1.1) (2025-10-09)
6
+
7
+ ### Dependency Updates
8
+
9
+ * `mui-favorites` updated to version `1.1.0`
10
+ * `@availity/mock` updated to version `1.1.0`
11
+
12
+ ### Bug Fixes
13
+
14
+ * **mui-spaces:** try to parse operationName ([8189c94](https://github.com/Availity/element/commit/8189c94dd6b8fef981266d121b3a2893639fa482))
15
+
16
+ ## [1.1.0](https://github.com/Availity/element/compare/@availity/mui-spaces@1.0.31...@availity/mui-spaces@1.1.0) (2025-09-25)
17
+
18
+
19
+ ### Features
20
+
21
+ * **mui-spaces:** add operationName support ([f33f02b](https://github.com/Availity/element/commit/f33f02b2ef3cacee17a48a86849e2b4c96fac722))
22
+
5
23
  ## [1.0.31](https://github.com/Availity/element/compare/@availity/mui-spaces@1.0.30...@availity/mui-spaces@1.0.31) (2025-09-22)
6
24
 
7
25
  ## [1.0.30](https://github.com/Availity/element/compare/@availity/mui-spaces@1.0.29...@availity/mui-spaces@1.0.30) (2025-08-21)
package/dist/index.d.mts CHANGED
@@ -85,6 +85,18 @@ 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
+ * If an operation name exists in the query string, leave this undefined or
92
+ * ensure it matches what is in the query string.
93
+ *
94
+ * If no operation name exists in the query string, it can be defined here.
95
+ *
96
+ * Format: `{ValueStream || PayerName}{AbbreviatedAppName}{Description}{Type}` (PascalCase)
97
+ * @example "OnbPsFavoritesQuery"
98
+ */
99
+ operationName?: string;
88
100
  /** The Client ID obtained from APIConnect. */
89
101
  clientId?: string;
90
102
  /** Children can be a react child or render prop. */
@@ -101,14 +113,14 @@ type SpacesProps = {
101
113
  * 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
114
  spaces?: Space[];
103
115
  };
104
- type UseSpaces = (...ids: string[]) => (Space)[] | undefined;
116
+ type UseSpaces = (...ids: string[]) => Space[] | undefined;
105
117
 
106
118
  declare const INITIAL_STATE: {
107
119
  loading: boolean;
108
120
  };
109
121
  declare const SpacesContext: react.Context<SpacesContextType>;
110
122
  declare const useSpacesContext: () => SpacesContextType;
111
- declare const Spaces: ({ query, variables, clientId, children, payerIds, spaceIds, spaces: spacesFromProps, }: SpacesProps) => JSX.Element;
123
+ declare const Spaces: ({ query, variables, operationName, clientId, children, payerIds, spaceIds, spaces: spacesFromProps, }: SpacesProps) => JSX.Element;
112
124
  declare const useSpaces: UseSpaces;
113
125
 
114
126
  type SpacesLinkVariants = 'card' | 'list' | 'default' | undefined;
package/dist/index.d.ts CHANGED
@@ -85,6 +85,18 @@ 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
+ * If an operation name exists in the query string, leave this undefined or
92
+ * ensure it matches what is in the query string.
93
+ *
94
+ * If no operation name exists in the query string, it can be defined here.
95
+ *
96
+ * Format: `{ValueStream || PayerName}{AbbreviatedAppName}{Description}{Type}` (PascalCase)
97
+ * @example "OnbPsFavoritesQuery"
98
+ */
99
+ operationName?: string;
88
100
  /** The Client ID obtained from APIConnect. */
89
101
  clientId?: string;
90
102
  /** Children can be a react child or render prop. */
@@ -101,14 +113,14 @@ type SpacesProps = {
101
113
  * 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
114
  spaces?: Space[];
103
115
  };
104
- type UseSpaces = (...ids: string[]) => (Space)[] | undefined;
116
+ type UseSpaces = (...ids: string[]) => Space[] | undefined;
105
117
 
106
118
  declare const INITIAL_STATE: {
107
119
  loading: boolean;
108
120
  };
109
121
  declare const SpacesContext: react.Context<SpacesContextType>;
110
122
  declare const useSpacesContext: () => SpacesContextType;
111
- declare const Spaces: ({ query, variables, clientId, children, payerIds, spaceIds, spaces: spacesFromProps, }: SpacesProps) => JSX.Element;
123
+ declare const Spaces: ({ query, variables, operationName, clientId, children, payerIds, spaceIds, spaces: spacesFromProps, }: SpacesProps) => JSX.Element;
112
124
  declare const useSpaces: UseSpaces;
113
125
 
114
126
  type SpacesLinkVariants = 'card' | 'list' | 'default' | undefined;
package/dist/index.js CHANGED
@@ -98,6 +98,10 @@ var import_react_query = require("@tanstack/react-query");
98
98
 
99
99
  // src/lib/spaces-data.tsx
100
100
  var import_api_axios = require("@availity/api-axios");
101
+ var parseOperationName = (query) => {
102
+ const match = query.match(/(?:query|mutation|subscription)\s+([a-zA-Z_][a-zA-Z0-9_]*)/i);
103
+ return match == null ? void 0 : match[1];
104
+ };
101
105
  var actions = {
102
106
  SPACES: (currentState, { spaces, spacesByConfig, spacesByPayer }) => ({
103
107
  previousSpacesMap: spaces,
@@ -118,7 +122,7 @@ var spacesReducer = (state, action) => {
118
122
  const { type } = action;
119
123
  return actions[type](state, action);
120
124
  };
121
- var fetchSpaces = (_0) => __async(null, [_0], function* ({ query, clientId, variables }) {
125
+ var fetchSpaces = (_0) => __async(null, [_0], function* ({ query, clientId, variables, operationName }) {
122
126
  const headers = {};
123
127
  if (clientId) {
124
128
  headers["X-Client-ID"] = clientId;
@@ -130,7 +134,8 @@ var fetchSpaces = (_0) => __async(null, [_0], function* ({ query, clientId, vari
130
134
  } = yield import_api_axios.avWebQLApi.create(
131
135
  {
132
136
  query,
133
- variables: __spreadValues({}, variables)
137
+ variables: __spreadValues({}, variables),
138
+ operationName: operationName || parseOperationName(query) || "PuiSpacesCmpAnonymousOperation"
134
139
  },
135
140
  { headers: __spreadValues({}, headers) }
136
141
  );
@@ -148,21 +153,22 @@ var fetchAllSpaces = (_0) => __async(null, [_0], function* ({
148
153
  query,
149
154
  clientId,
150
155
  variables,
151
- _spaces = []
156
+ _spaces = [],
157
+ operationName
152
158
  }) {
153
- const { items, currentPage, hasNextPage } = yield fetchSpaces({ query, clientId, variables });
159
+ const { items, currentPage, hasNextPage } = yield fetchSpaces({ query, clientId, variables, operationName });
154
160
  _spaces.push(...items);
155
161
  if (hasNextPage) {
156
162
  const vars = __spreadProps(__spreadValues({}, variables), {
157
163
  page: currentPage + 1
158
164
  });
159
- return fetchAllSpaces({ query, clientId, variables: vars, _spaces });
165
+ return fetchAllSpaces({ query, clientId, variables: vars, _spaces, operationName });
160
166
  }
161
167
  return _spaces;
162
168
  });
163
169
 
164
170
  // src/lib/configurationFindMany.tsx
165
- var configurationFindMany_default = `query configurationFindMany($ids: [String!], $payerIDs: [ID!], $types: [TypeEnum!], $page: Int) {
171
+ var configurationFindMany_default = `query PuiSpacesCmpConfigurationFindMany($ids: [String!], $payerIDs: [ID!], $types: [TypeEnum!], $page: Int) {
166
172
  configurationPagination(filter: { ids: $ids, payerIds: $payerIDs, types: $types }, page: $page) {
167
173
  pageInfo {
168
174
  hasNextPage
@@ -582,6 +588,7 @@ var useSpacesContext = () => (0, import_react3.useContext)(SpacesContext);
582
588
  var Spaces = ({
583
589
  query = configurationFindMany_default,
584
590
  variables = { types: ["PAYERSPACE"] },
591
+ operationName,
585
592
  clientId,
586
593
  children,
587
594
  payerIds,
@@ -637,12 +644,12 @@ var Spaces = ({
637
644
  queries: [
638
645
  {
639
646
  queryKey: ["id", spaceIdVars],
640
- queryFn: () => fetchAllSpaces({ query, clientId, variables: spaceIdVars }),
647
+ queryFn: () => fetchAllSpaces({ query, clientId, variables: spaceIdVars, operationName }),
641
648
  enabled: spaceIdsToQuery.size > 0
642
649
  },
643
650
  {
644
651
  queryKey: ["id", payerIdVars],
645
- queryFn: () => fetchAllSpaces({ query, clientId, variables: payerIdVars }),
652
+ queryFn: () => fetchAllSpaces({ query, clientId, variables: payerIdVars, operationName }),
646
653
  enabled: payerIdsToQuery.size > 0
647
654
  }
648
655
  ]
package/dist/index.mjs CHANGED
@@ -56,6 +56,10 @@ import { useQueries } from "@tanstack/react-query";
56
56
 
57
57
  // src/lib/spaces-data.tsx
58
58
  import { avWebQLApi } from "@availity/api-axios";
59
+ var parseOperationName = (query) => {
60
+ const match = query.match(/(?:query|mutation|subscription)\s+([a-zA-Z_][a-zA-Z0-9_]*)/i);
61
+ return match == null ? void 0 : match[1];
62
+ };
59
63
  var actions = {
60
64
  SPACES: (currentState, { spaces, spacesByConfig, spacesByPayer }) => ({
61
65
  previousSpacesMap: spaces,
@@ -76,7 +80,7 @@ var spacesReducer = (state, action) => {
76
80
  const { type } = action;
77
81
  return actions[type](state, action);
78
82
  };
79
- var fetchSpaces = (_0) => __async(null, [_0], function* ({ query, clientId, variables }) {
83
+ var fetchSpaces = (_0) => __async(null, [_0], function* ({ query, clientId, variables, operationName }) {
80
84
  const headers = {};
81
85
  if (clientId) {
82
86
  headers["X-Client-ID"] = clientId;
@@ -88,7 +92,8 @@ var fetchSpaces = (_0) => __async(null, [_0], function* ({ query, clientId, vari
88
92
  } = yield avWebQLApi.create(
89
93
  {
90
94
  query,
91
- variables: __spreadValues({}, variables)
95
+ variables: __spreadValues({}, variables),
96
+ operationName: operationName || parseOperationName(query) || "PuiSpacesCmpAnonymousOperation"
92
97
  },
93
98
  { headers: __spreadValues({}, headers) }
94
99
  );
@@ -106,21 +111,22 @@ var fetchAllSpaces = (_0) => __async(null, [_0], function* ({
106
111
  query,
107
112
  clientId,
108
113
  variables,
109
- _spaces = []
114
+ _spaces = [],
115
+ operationName
110
116
  }) {
111
- const { items, currentPage, hasNextPage } = yield fetchSpaces({ query, clientId, variables });
117
+ const { items, currentPage, hasNextPage } = yield fetchSpaces({ query, clientId, variables, operationName });
112
118
  _spaces.push(...items);
113
119
  if (hasNextPage) {
114
120
  const vars = __spreadProps(__spreadValues({}, variables), {
115
121
  page: currentPage + 1
116
122
  });
117
- return fetchAllSpaces({ query, clientId, variables: vars, _spaces });
123
+ return fetchAllSpaces({ query, clientId, variables: vars, _spaces, operationName });
118
124
  }
119
125
  return _spaces;
120
126
  });
121
127
 
122
128
  // src/lib/configurationFindMany.tsx
123
- var configurationFindMany_default = `query configurationFindMany($ids: [String!], $payerIDs: [ID!], $types: [TypeEnum!], $page: Int) {
129
+ var configurationFindMany_default = `query PuiSpacesCmpConfigurationFindMany($ids: [String!], $payerIDs: [ID!], $types: [TypeEnum!], $page: Int) {
124
130
  configurationPagination(filter: { ids: $ids, payerIds: $payerIDs, types: $types }, page: $page) {
125
131
  pageInfo {
126
132
  hasNextPage
@@ -540,6 +546,7 @@ var useSpacesContext = () => useContext2(SpacesContext);
540
546
  var Spaces = ({
541
547
  query = configurationFindMany_default,
542
548
  variables = { types: ["PAYERSPACE"] },
549
+ operationName,
543
550
  clientId,
544
551
  children,
545
552
  payerIds,
@@ -595,12 +602,12 @@ var Spaces = ({
595
602
  queries: [
596
603
  {
597
604
  queryKey: ["id", spaceIdVars],
598
- queryFn: () => fetchAllSpaces({ query, clientId, variables: spaceIdVars }),
605
+ queryFn: () => fetchAllSpaces({ query, clientId, variables: spaceIdVars, operationName }),
599
606
  enabled: spaceIdsToQuery.size > 0
600
607
  },
601
608
  {
602
609
  queryKey: ["id", payerIdVars],
603
- queryFn: () => fetchAllSpaces({ query, clientId, variables: payerIdVars }),
610
+ queryFn: () => fetchAllSpaces({ query, clientId, variables: payerIdVars, operationName }),
604
611
  enabled: payerIdsToQuery.size > 0
605
612
  }
606
613
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@availity/mui-spaces",
3
- "version": "1.0.31",
3
+ "version": "1.1.1",
4
4
  "description": "Availity MUI Spaces Component - part of the @availity/element design system",
5
5
  "keywords": [
6
6
  "react",
@@ -45,7 +45,7 @@
45
45
  "@availity/mui-chip": "^1.0.4",
46
46
  "@availity/mui-dialog": "^1.0.15",
47
47
  "@availity/mui-disclaimer": "^1.0.5",
48
- "@availity/mui-favorites": "^1.1.6",
48
+ "@availity/mui-favorites": "^1.1.7",
49
49
  "@availity/mui-icon": "^1.1.0",
50
50
  "@availity/mui-layout": "^1.0.2",
51
51
  "@availity/mui-list": "^1.0.7",
@@ -66,7 +66,7 @@
66
66
  "@availity/mui-chip": "^1.0.4",
67
67
  "@availity/mui-dialog": "^1.0.15",
68
68
  "@availity/mui-disclaimer": "^1.0.5",
69
- "@availity/mui-favorites": "^1.1.6",
69
+ "@availity/mui-favorites": "^1.1.7",
70
70
  "@availity/mui-icon": "^1.1.0",
71
71
  "@availity/mui-layout": "^1.0.2",
72
72
  "@availity/mui-list": "^1.0.7",
@@ -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,
@@ -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
  ],
@@ -1,4 +1,4 @@
1
- export default `query configurationFindMany($ids: [String!], $payerIDs: [ID!], $types: [TypeEnum!], $page: Int) {
1
+ export default `query PuiSpacesCmpConfigurationFindMany($ids: [String!], $payerIDs: [ID!], $types: [TypeEnum!], $page: Int) {
2
2
  configurationPagination(filter: { ids: $ids, payerIds: $payerIDs, types: $types }, page: $page) {
3
3
  pageInfo {
4
4
  hasNextPage
@@ -1,4 +1,4 @@
1
- import { fetchAllSpaces } from './spaces-data';
1
+ import { fetchAllSpaces, parseOperationName } from './spaces-data';
2
2
  import configurationFindMany from './configurationFindMany';
3
3
  // eslint-disable-next-line @nx/enforce-module-boundaries
4
4
  import { server } from '../../../mock/src/lib/server';
@@ -38,3 +38,42 @@ describe('getAllSpaces', () => {
38
38
  expect(apiCalls).toBe(2);
39
39
  });
40
40
  });
41
+
42
+ describe('parseQueryName', () => {
43
+ it('should return the query name if one exists in the query', async () => {
44
+ const opName = parseOperationName(configurationFindMany);
45
+
46
+ expect(opName).toBe('PuiSpacesCmpConfigurationFindMany');
47
+ });
48
+
49
+ it('should return the mutation name if one exists in the mutation', async () => {
50
+ const opName = parseOperationName(`
51
+ mutation FakeMutation($ids: [String!]) {
52
+ fakeMutation({ ids: $ids }) {
53
+ id
54
+ }
55
+ }`);
56
+
57
+ expect(opName).toBe('FakeMutation');
58
+ });
59
+
60
+ it('should return the subscription name if one exists in the subscription', async () => {
61
+ const opName = parseOperationName(`
62
+ subscription FakeSubscription($ids: [String!]) {
63
+ fakeSubscription({ ids: $ids }) {
64
+ id
65
+ }
66
+ }`);
67
+
68
+ expect(opName).toBe('FakeSubscription');
69
+ });
70
+
71
+ it('should return undefined if an opeation does not exist on the query', async () => {
72
+ const opName = parseOperationName(`
73
+ fakeQuery({ ids: $ids }) {
74
+ id
75
+ }`);
76
+
77
+ expect(opName).toBe(undefined);
78
+ });
79
+ });
@@ -1,6 +1,11 @@
1
1
  import { avWebQLApi } from '@availity/api-axios';
2
2
  import { Space, FetchSpacesProps, FetchAllSpacesProps, SpacesContextType, SpacesReducerAction } from './spaces-types';
3
3
 
4
+ export const parseOperationName = (query: string): string | undefined => {
5
+ const match = query.match(/(?:query|mutation|subscription)\s+([a-zA-Z_][a-zA-Z0-9_]*)/i);
6
+ return match?.[1];
7
+ };
8
+
4
9
  export const actions = {
5
10
  SPACES: (
6
11
  currentState: SpacesContextType,
@@ -28,7 +33,7 @@ export const spacesReducer = (state: SpacesContextType, action: SpacesReducerAct
28
33
  return actions[type](state, action);
29
34
  };
30
35
 
31
- export const fetchSpaces = async ({ query, clientId, variables }: FetchSpacesProps) => {
36
+ export const fetchSpaces = async ({ query, clientId, variables, operationName }: FetchSpacesProps) => {
32
37
  const headers: Record<string, string> = {};
33
38
 
34
39
  if (clientId) {
@@ -43,6 +48,7 @@ export const fetchSpaces = async ({ query, clientId, variables }: FetchSpacesPro
43
48
  {
44
49
  query,
45
50
  variables: { ...variables },
51
+ operationName: operationName || parseOperationName(query) || 'PuiSpacesCmpAnonymousOperation',
46
52
  },
47
53
  { headers: { ...headers } }
48
54
  );
@@ -64,8 +70,9 @@ export const fetchAllSpaces = async ({
64
70
  clientId,
65
71
  variables,
66
72
  _spaces = [],
73
+ operationName,
67
74
  }: FetchAllSpacesProps): Promise<Space[]> => {
68
- const { items, currentPage, hasNextPage } = await fetchSpaces({ query, clientId, variables });
75
+ const { items, currentPage, hasNextPage } = await fetchSpaces({ query, clientId, variables, operationName });
69
76
 
70
77
  _spaces.push(...items);
71
78
 
@@ -74,7 +81,7 @@ export const fetchAllSpaces = async ({
74
81
  ...variables,
75
82
  page: currentPage + 1,
76
83
  };
77
- return fetchAllSpaces({ query, clientId, variables: vars, _spaces });
84
+ return fetchAllSpaces({ query, clientId, variables: vars, _spaces, operationName });
78
85
  }
79
86
 
80
87
  return _spaces;
@@ -66,6 +66,18 @@ 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
+ * If an operation name exists in the query string, leave this undefined or
73
+ * ensure it matches what is in the query string.
74
+ *
75
+ * If no operation name exists in the query string, it can be defined here.
76
+ *
77
+ * Format: `{ValueStream || PayerName}{AbbreviatedAppName}{Description}{Type}` (PascalCase)
78
+ * @example "OnbPsFavoritesQuery"
79
+ */
80
+ operationName?: string;
69
81
  };
70
82
 
71
83
  export type FetchAllSpacesProps = {
@@ -77,6 +89,18 @@ export type FetchAllSpacesProps = {
77
89
  variables?: Record<string, any>;
78
90
  /** Array of spaces to be passed into the Spaces provider. */
79
91
  _spaces?: Space[];
92
+ /**
93
+ * Name for the GraphQL operation, used for debugging and monitoring.
94
+ *
95
+ * If an operation name exists in the query string, leave this undefined or
96
+ * ensure it matches what is in the query string.
97
+ *
98
+ * If no operation name exists in the query string, it can be defined here.
99
+ *
100
+ * Format: `{ValueStream || PayerName}{AbbreviatedAppName}{Description}{Type}` (PascalCase)
101
+ * @example "OnbPsFavoritesQuery"
102
+ */
103
+ operationName?: string;
80
104
  };
81
105
 
82
106
  export type SpacesContextType = {
@@ -116,6 +140,18 @@ export type SpacesProps = {
116
140
  /** Override the default variables used in the thanos query. Default: { types: [PAYERSPACE] }.
117
141
  * If the spaces provider should contain configurations of a type other than PAYERSPACE, you must override this prop */
118
142
  variables?: object;
143
+ /**
144
+ * Name for the GraphQL operation, used for debugging and monitoring.
145
+ *
146
+ * If an operation name exists in the query string, leave this undefined or
147
+ * ensure it matches what is in the query string.
148
+ *
149
+ * If no operation name exists in the query string, it can be defined here.
150
+ *
151
+ * Format: `{ValueStream || PayerName}{AbbreviatedAppName}{Description}{Type}` (PascalCase)
152
+ * @example "OnbPsFavoritesQuery"
153
+ */
154
+ operationName?: string;
119
155
  /** The Client ID obtained from APIConnect. */
120
156
  clientId?: string;
121
157
  /** Children can be a react child or render prop. */
@@ -133,4 +169,4 @@ export type SpacesProps = {
133
169
  spaces?: Space[];
134
170
  };
135
171
 
136
- export type UseSpaces = (...ids: string[]) => (Space)[] | undefined;
172
+ export type UseSpaces = (...ids: string[]) => Space[] | undefined;