@trackunit/react-core-contexts 0.4.503 → 0.4.505

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/index.cjs.js CHANGED
@@ -107,7 +107,7 @@ const createApolloClient = ({ graphqlManagerUrl, graphqlPublicUrl, graphqlManage
107
107
  };
108
108
  }));
109
109
  const errorLink = error.onError((errorResponse) => {
110
- var _a, _b, _c, _d;
110
+ var _a, _b;
111
111
  const traceIds = []; // Used to hold id's for use in Sentry
112
112
  if (errorResponse.graphQLErrors) {
113
113
  const code = (_b = (_a = errorResponse.graphQLErrors[0]) === null || _a === void 0 ? void 0 : _a.extensions) === null || _b === void 0 ? void 0 : _b.code;
@@ -116,10 +116,10 @@ const createApolloClient = ({ graphqlManagerUrl, graphqlPublicUrl, graphqlManage
116
116
  }
117
117
  // eslint-disable-next-line no-console
118
118
  console.error(`Error calling: '${errorResponse.operation.getContext().clientAwareness.name}' fetching Data for: ${errorResponse.operation.operationName}`, errorResponse.graphQLErrors);
119
- (_c = errorResponse.graphQLErrors) === null || _c === void 0 ? void 0 : _c.forEach(error => {
120
- var _a, _b;
121
- if (error === null || error === void 0 ? void 0 : error.extensions) {
122
- error.extensions.traceId = (_b = (_a = errorResponse.response) === null || _a === void 0 ? void 0 : _a.extensions) === null || _b === void 0 ? void 0 : _b.traceId;
119
+ errorResponse.graphQLErrors.forEach(error => {
120
+ var _a;
121
+ if ("extensions" in error) {
122
+ error.extensions.traceId = (_a = errorResponse.response.extensions) === null || _a === void 0 ? void 0 : _a.traceId;
123
123
  traceIds.push(error.extensions.traceId);
124
124
  }
125
125
  });
@@ -128,24 +128,21 @@ const createApolloClient = ({ graphqlManagerUrl, graphqlPublicUrl, graphqlManage
128
128
  * it contains extra details like the query/mutation
129
129
  * name.
130
130
  */
131
- if (Sentry__namespace) {
132
- if (traceIds.length) {
133
- Sentry__namespace.setTag("traceIds", traceIds.join(", "));
134
- }
135
- Sentry__namespace.addBreadcrumb({
136
- category: "GraphQL",
137
- message: "GraphQL Error",
138
- level: "error",
139
- data: {
140
- log: JSON.stringify(errorResponse.graphQLErrors),
141
- },
142
- });
131
+ if (traceIds.length) {
132
+ Sentry__namespace.setTag("traceIds", traceIds.join(", "));
143
133
  }
144
- const invalidToken = (_d = errorResponse.graphQLErrors) === null || _d === void 0 ? void 0 : _d.some(x => {
145
- var _a, _b, _c;
146
- return (((_a = x === null || x === void 0 ? void 0 : x.extensions) === null || _a === void 0 ? void 0 : _a.code) === "UNAUTHENTICATED" ||
147
- ((_b = x === null || x === void 0 ? void 0 : x.message) === null || _b === void 0 ? void 0 : _b.includes("Invalid token specified")) ||
148
- ((_c = x === null || x === void 0 ? void 0 : x.message) === null || _c === void 0 ? void 0 : _c.includes("Access denied! You need to be authorized to perform this action!")));
134
+ Sentry__namespace.addBreadcrumb({
135
+ category: "GraphQL",
136
+ message: "GraphQL Error",
137
+ level: "error",
138
+ data: {
139
+ log: JSON.stringify(errorResponse.graphQLErrors),
140
+ },
141
+ });
142
+ const invalidToken = errorResponse.graphQLErrors.some(x => {
143
+ return (x.extensions.code === "UNAUTHENTICATED" ||
144
+ x.message.includes("Invalid token specified") ||
145
+ x.message.includes("Access denied! You need to be authorized to perform this action!"));
149
146
  });
150
147
  if (invalidToken && token) {
151
148
  Sentry__namespace.captureException(new Error(JSON.stringify({
@@ -202,7 +199,6 @@ const createApolloClient = ({ graphqlManagerUrl, graphqlPublicUrl, graphqlManage
202
199
  };
203
200
  };
204
201
  const useApolloClient = () => {
205
- var _a;
206
202
  const { graphqlManagerUrl, graphqlPublicUrl, graphqlInternalUrl, graphqlManagerImageUploadUrl, graphqlReportUrl, isDev, tracingHeaders, } = reactCoreHooks.useEnvironment();
207
203
  const { token } = reactCoreHooks.useToken();
208
204
  const clientRef = React.useRef(null);
@@ -224,7 +220,7 @@ const useApolloClient = () => {
224
220
  if (clientRef.current.getToken() !== token) {
225
221
  clientRef.current.setToken(token);
226
222
  }
227
- return (_a = clientRef.current) === null || _a === void 0 ? void 0 : _a.client;
223
+ return clientRef.current.client;
228
224
  };
229
225
  /**
230
226
  * This is a provider for the ManagerApolloContext.
@@ -309,8 +305,8 @@ const ConfirmationDialogProviderIrisApp = ({ children }) => {
309
305
  * This is a provider for the EnvironmentContext.
310
306
  */
311
307
  const EnvironmentProviderIrisApp = ({ children }) => {
312
- const [environment, setEnvironment] = React__namespace.useState(null);
313
- React__namespace.useEffect(() => {
308
+ const [environment, setEnvironment] = React.useState(null);
309
+ React.useEffect(() => {
314
310
  const updateEnv = () => __awaiter(void 0, void 0, void 0, function* () {
315
311
  try {
316
312
  setEnvironment(yield irisAppRuntimeCore.EnvironmentRuntime.getEnvironmentContext());
@@ -338,7 +334,7 @@ const FilterBarProviderIrisApp = ({ children }) => {
338
334
  irisAppRuntimeCore.FilterBarRuntime.getFilterBarValues()
339
335
  .catch(() => null)
340
336
  .then(filterBarValues => {
341
- if (filterBarValues !== null && filterBarValues !== undefined) {
337
+ if (filterBarValues) {
342
338
  setFilterBarContext({ filterBarValues });
343
339
  }
344
340
  });
package/index.esm.js CHANGED
@@ -83,7 +83,7 @@ const createApolloClient = ({ graphqlManagerUrl, graphqlPublicUrl, graphqlManage
83
83
  };
84
84
  }));
85
85
  const errorLink = onError((errorResponse) => {
86
- var _a, _b, _c, _d;
86
+ var _a, _b;
87
87
  const traceIds = []; // Used to hold id's for use in Sentry
88
88
  if (errorResponse.graphQLErrors) {
89
89
  const code = (_b = (_a = errorResponse.graphQLErrors[0]) === null || _a === void 0 ? void 0 : _a.extensions) === null || _b === void 0 ? void 0 : _b.code;
@@ -92,10 +92,10 @@ const createApolloClient = ({ graphqlManagerUrl, graphqlPublicUrl, graphqlManage
92
92
  }
93
93
  // eslint-disable-next-line no-console
94
94
  console.error(`Error calling: '${errorResponse.operation.getContext().clientAwareness.name}' fetching Data for: ${errorResponse.operation.operationName}`, errorResponse.graphQLErrors);
95
- (_c = errorResponse.graphQLErrors) === null || _c === void 0 ? void 0 : _c.forEach(error => {
96
- var _a, _b;
97
- if (error === null || error === void 0 ? void 0 : error.extensions) {
98
- error.extensions.traceId = (_b = (_a = errorResponse.response) === null || _a === void 0 ? void 0 : _a.extensions) === null || _b === void 0 ? void 0 : _b.traceId;
95
+ errorResponse.graphQLErrors.forEach(error => {
96
+ var _a;
97
+ if ("extensions" in error) {
98
+ error.extensions.traceId = (_a = errorResponse.response.extensions) === null || _a === void 0 ? void 0 : _a.traceId;
99
99
  traceIds.push(error.extensions.traceId);
100
100
  }
101
101
  });
@@ -104,24 +104,21 @@ const createApolloClient = ({ graphqlManagerUrl, graphqlPublicUrl, graphqlManage
104
104
  * it contains extra details like the query/mutation
105
105
  * name.
106
106
  */
107
- if (Sentry) {
108
- if (traceIds.length) {
109
- Sentry.setTag("traceIds", traceIds.join(", "));
110
- }
111
- Sentry.addBreadcrumb({
112
- category: "GraphQL",
113
- message: "GraphQL Error",
114
- level: "error",
115
- data: {
116
- log: JSON.stringify(errorResponse.graphQLErrors),
117
- },
118
- });
107
+ if (traceIds.length) {
108
+ Sentry.setTag("traceIds", traceIds.join(", "));
119
109
  }
120
- const invalidToken = (_d = errorResponse.graphQLErrors) === null || _d === void 0 ? void 0 : _d.some(x => {
121
- var _a, _b, _c;
122
- return (((_a = x === null || x === void 0 ? void 0 : x.extensions) === null || _a === void 0 ? void 0 : _a.code) === "UNAUTHENTICATED" ||
123
- ((_b = x === null || x === void 0 ? void 0 : x.message) === null || _b === void 0 ? void 0 : _b.includes("Invalid token specified")) ||
124
- ((_c = x === null || x === void 0 ? void 0 : x.message) === null || _c === void 0 ? void 0 : _c.includes("Access denied! You need to be authorized to perform this action!")));
110
+ Sentry.addBreadcrumb({
111
+ category: "GraphQL",
112
+ message: "GraphQL Error",
113
+ level: "error",
114
+ data: {
115
+ log: JSON.stringify(errorResponse.graphQLErrors),
116
+ },
117
+ });
118
+ const invalidToken = errorResponse.graphQLErrors.some(x => {
119
+ return (x.extensions.code === "UNAUTHENTICATED" ||
120
+ x.message.includes("Invalid token specified") ||
121
+ x.message.includes("Access denied! You need to be authorized to perform this action!"));
125
122
  });
126
123
  if (invalidToken && token) {
127
124
  Sentry.captureException(new Error(JSON.stringify({
@@ -178,7 +175,6 @@ const createApolloClient = ({ graphqlManagerUrl, graphqlPublicUrl, graphqlManage
178
175
  };
179
176
  };
180
177
  const useApolloClient = () => {
181
- var _a;
182
178
  const { graphqlManagerUrl, graphqlPublicUrl, graphqlInternalUrl, graphqlManagerImageUploadUrl, graphqlReportUrl, isDev, tracingHeaders, } = useEnvironment();
183
179
  const { token } = useToken();
184
180
  const clientRef = useRef(null);
@@ -200,7 +196,7 @@ const useApolloClient = () => {
200
196
  if (clientRef.current.getToken() !== token) {
201
197
  clientRef.current.setToken(token);
202
198
  }
203
- return (_a = clientRef.current) === null || _a === void 0 ? void 0 : _a.client;
199
+ return clientRef.current.client;
204
200
  };
205
201
  /**
206
202
  * This is a provider for the ManagerApolloContext.
@@ -285,8 +281,8 @@ const ConfirmationDialogProviderIrisApp = ({ children }) => {
285
281
  * This is a provider for the EnvironmentContext.
286
282
  */
287
283
  const EnvironmentProviderIrisApp = ({ children }) => {
288
- const [environment, setEnvironment] = React.useState(null);
289
- React.useEffect(() => {
284
+ const [environment, setEnvironment] = useState(null);
285
+ useEffect(() => {
290
286
  const updateEnv = () => __awaiter(void 0, void 0, void 0, function* () {
291
287
  try {
292
288
  setEnvironment(yield EnvironmentRuntime.getEnvironmentContext());
@@ -314,7 +310,7 @@ const FilterBarProviderIrisApp = ({ children }) => {
314
310
  FilterBarRuntime.getFilterBarValues()
315
311
  .catch(() => null)
316
312
  .then(filterBarValues => {
317
- if (filterBarValues !== null && filterBarValues !== undefined) {
313
+ if (filterBarValues) {
318
314
  setFilterBarContext({ filterBarValues });
319
315
  }
320
316
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-core-contexts",
3
- "version": "0.4.503",
3
+ "version": "0.4.505",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -1,10 +1,5 @@
1
- import { ReactNode } from "react";
2
- interface Props {
3
- children: ReactNode;
4
- allowAnalytics?: boolean;
5
- }
1
+ import { type PropsWithChildren } from "react";
6
2
  /**
7
3
  * This is a provider for the AnalyticsProvider.
8
4
  */
9
- export declare const AnalyticsProviderIrisApp: ({ children }: Props) => JSX.Element;
10
- export {};
5
+ export declare const AnalyticsProviderIrisApp: ({ children }: PropsWithChildren) => JSX.Element;
@@ -1,9 +1,5 @@
1
- import * as React from "react";
2
- interface IProps {
3
- children: React.ReactNode;
4
- }
1
+ import { type PropsWithChildren } from "react";
5
2
  /**
6
3
  * This is a provider for the EnvironmentContext.
7
4
  */
8
- export declare const EnvironmentProviderIrisApp: ({ children }: IProps) => JSX.Element | null;
9
- export {};
5
+ export declare const EnvironmentProviderIrisApp: ({ children }: PropsWithChildren) => JSX.Element | null;
@@ -1,9 +1,5 @@
1
- /// <reference types="react" />
2
- interface IProps {
3
- children: React.ReactNode;
4
- }
1
+ import { type PropsWithChildren } from "react";
5
2
  /**
6
3
  * This is a provider for the FilterBarContext.
7
4
  */
8
- export declare const FilterBarProviderIrisApp: ({ children }: IProps) => JSX.Element | null;
9
- export {};
5
+ export declare const FilterBarProviderIrisApp: ({ children }: PropsWithChildren) => JSX.Element | null;