@bunnyapp/components 1.8.0-beta.3 → 1.8.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/dist/cjs/index.js CHANGED
@@ -1310,12 +1310,7 @@ const gqlRequest = async ({ query, apiHost, token, vars, isInPreviewMode, }) =>
1310
1310
  const requestHeaders = {
1311
1311
  ...baseHeaders,
1312
1312
  };
1313
- try {
1314
- return await request$1(`${apiHost}${graphqlEndpoint}`, query, vars, requestHeaders);
1315
- }
1316
- catch (error) {
1317
- throw error;
1318
- }
1313
+ return await request$1(`${apiHost}${graphqlEndpoint}`, query, vars, requestHeaders);
1319
1314
  };
1320
1315
  const createClientDevHeaders = ({ token, componentsVersion, additionalHeaders, }) => {
1321
1316
  const headers = {
@@ -1548,12 +1543,8 @@ const useAllErrorFormats = ({ onUserUnavailable, onInvalidOrMissingAuthorization
1548
1543
  };
1549
1544
 
1550
1545
  const useCreateQueryClient = () => {
1551
- const { onUserUnavailable, onInvalidOrMissingAuthorization, suppressUserUnavailableErrorNotification, } = useBunnyProviderCallbacks();
1552
- const handleAllErrorFormats = useAllErrorFormats({
1553
- onUserUnavailable,
1554
- onInvalidOrMissingAuthorization,
1555
- suppressUserUnavailableErrorNotification,
1556
- });
1546
+ const { onUserUnavailable, onInvalidOrMissingAuthorization, suppressUserUnavailableErrorNotification } = useBunnyProviderCallbacks();
1547
+ const handleAllErrorFormats = useAllErrorFormats({ onUserUnavailable, onInvalidOrMissingAuthorization, suppressUserUnavailableErrorNotification });
1557
1548
  const onError = (error, _query) => {
1558
1549
  // Extract mutation name from query string
1559
1550
  // const mutationName = query?.mutation?.match(/mutation\s+(\w+)/)?.[1];
@@ -1563,6 +1554,9 @@ const useCreateQueryClient = () => {
1563
1554
  };
1564
1555
  return () => new reactQuery.QueryClient({
1565
1556
  defaultOptions: {
1557
+ mutations: {
1558
+ onError,
1559
+ },
1566
1560
  queries: {
1567
1561
  gcTime: Number.POSITIVE_INFINITY,
1568
1562
  refetchIntervalInBackground: false,
@@ -1571,9 +1565,6 @@ const useCreateQueryClient = () => {
1571
1565
  refetchOnWindowFocus: false,
1572
1566
  },
1573
1567
  },
1574
- mutationCache: new reactQuery.MutationCache({
1575
- onError,
1576
- }),
1577
1568
  queryCache: new reactQuery.QueryCache({
1578
1569
  onError,
1579
1570
  }),
@@ -24445,9 +24436,12 @@ const mutation$c = t(`
24445
24436
  }
24446
24437
  `, [QuoteContext_QuoteFragment]);
24447
24438
  const quoteChargeUpdate$1 = async (quoteChargeId, quantity, apiHost, token) => {
24448
- var _a;
24439
+ var _a, _b;
24449
24440
  const response = await execute(mutation$c, { apiHost, token }, { quoteChargeId, quantity });
24450
- return (_a = response.quoteChargeUpdate) === null || _a === void 0 ? void 0 : _a.quoteCharge;
24441
+ if ((_a = response.quoteChargeUpdate) === null || _a === void 0 ? void 0 : _a.errors) {
24442
+ throw new Error(response.quoteChargeUpdate.errors[0]);
24443
+ }
24444
+ return (_b = response.quoteChargeUpdate) === null || _b === void 0 ? void 0 : _b.quoteCharge;
24451
24445
  };
24452
24446
 
24453
24447
  /**
@@ -24490,9 +24484,12 @@ const mutation$b = t(`
24490
24484
  }
24491
24485
  `, [QuoteContext_QuoteFragment]);
24492
24486
  const quoteChargeDelete = async ({ quoteChargeId, token, apiHost }) => {
24493
- var _a;
24487
+ var _a, _b, _c, _d;
24494
24488
  const response = await execute(mutation$b, { apiHost, token }, { quoteChargeId });
24495
- return (_a = response.quoteChargeDelete) === null || _a === void 0 ? void 0 : _a.quoteCharge;
24489
+ if ((_a = response.quoteChargeDelete) === null || _a === void 0 ? void 0 : _a.errors) {
24490
+ throw new Error((_c = (_b = response.quoteChargeDelete) === null || _b === void 0 ? void 0 : _b.errors) === null || _c === void 0 ? void 0 : _c[0]);
24491
+ }
24492
+ return (_d = response.quoteChargeDelete) === null || _d === void 0 ? void 0 : _d.quoteCharge;
24496
24493
  };
24497
24494
 
24498
24495
  const showErrorNotification$1 = useErrorNotification();
@@ -28225,9 +28222,12 @@ const mutation$6 = t(`
28225
28222
  }
28226
28223
  `, [QuantityDrawer_QuoteFragment]);
28227
28224
  const quoteChargeUpdate = async (quoteChargeId, quantity, apiHost, token) => {
28228
- var _a;
28225
+ var _a, _b;
28229
28226
  const response = await execute(mutation$6, { apiHost, token }, { quoteChargeId, quantity });
28230
- return (_a = response.quoteChargeUpdate) === null || _a === void 0 ? void 0 : _a.quoteCharge;
28227
+ if ((_a = response.quoteChargeUpdate) === null || _a === void 0 ? void 0 : _a.errors) {
28228
+ throw new Error(response.quoteChargeUpdate.errors[0]);
28229
+ }
28230
+ return (_b = response.quoteChargeUpdate) === null || _b === void 0 ? void 0 : _b.quoteCharge;
28231
28231
  };
28232
28232
 
28233
28233
  const mutation$5 = t(`
@@ -28273,9 +28273,12 @@ const mutation$4 = t(`
28273
28273
  }
28274
28274
  `, [QuantityDrawer_QuoteFragment]);
28275
28275
  const quoteSubscriptionUpdate = async (subscriptionIds, apiHost, token) => {
28276
- var _a;
28276
+ var _a, _b;
28277
28277
  const response = await execute(mutation$4, { apiHost, token }, { subscriptionIds });
28278
- return (_a = response.quoteSubscriptionUpdate) === null || _a === void 0 ? void 0 : _a.quote;
28278
+ if ((_a = response.quoteSubscriptionUpdate) === null || _a === void 0 ? void 0 : _a.errors) {
28279
+ throw new Error(response.quoteSubscriptionUpdate.errors[0]);
28280
+ }
28281
+ return (_b = response.quoteSubscriptionUpdate) === null || _b === void 0 ? void 0 : _b.quote;
28279
28282
  };
28280
28283
 
28281
28284
  const formatDateForApi = (date) => {
package/dist/esm/index.js CHANGED
@@ -2,7 +2,7 @@ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
2
2
  import { useState, useEffect, isValidElement, createContext, useContext, useMemo, createElement, useRef, useCallback, Fragment as Fragment$1 } from 'react';
3
3
  import { WarningOutlined, CheckCircleOutlined, CreditCardOutlined, EllipsisOutlined, BankOutlined, DownloadOutlined, SearchOutlined, CheckCircleFilled, LoadingOutlined, CloseOutlined, InfoCircleOutlined } from '@ant-design/icons';
4
4
  import { notification, theme, ConfigProvider, Tag, Button, Dropdown, Typography, Input, Modal, Checkbox, Skeleton, Collapse, Spin, Form, Tooltip as Tooltip$1, Drawer, Card as Card$1, Divider, Select, Popconfirm, Table, Radio, Space, Switch } from 'antd';
5
- import { QueryClient, MutationCache, QueryCache, QueryClientProvider, useQuery, useMutation, useQueryClient, keepPreviousData, useIsMutating, useIsFetching } from '@tanstack/react-query';
5
+ import { QueryClient, QueryCache, QueryClientProvider, useQuery, useMutation, useQueryClient, keepPreviousData, useIsMutating, useIsFetching } from '@tanstack/react-query';
6
6
  import request$1 from 'graphql-request';
7
7
  import { RecoilRoot } from 'recoil';
8
8
  import { print } from 'graphql';
@@ -1308,12 +1308,7 @@ const gqlRequest = async ({ query, apiHost, token, vars, isInPreviewMode, }) =>
1308
1308
  const requestHeaders = {
1309
1309
  ...baseHeaders,
1310
1310
  };
1311
- try {
1312
- return await request$1(`${apiHost}${graphqlEndpoint}`, query, vars, requestHeaders);
1313
- }
1314
- catch (error) {
1315
- throw error;
1316
- }
1311
+ return await request$1(`${apiHost}${graphqlEndpoint}`, query, vars, requestHeaders);
1317
1312
  };
1318
1313
  const createClientDevHeaders = ({ token, componentsVersion, additionalHeaders, }) => {
1319
1314
  const headers = {
@@ -1546,12 +1541,8 @@ const useAllErrorFormats = ({ onUserUnavailable, onInvalidOrMissingAuthorization
1546
1541
  };
1547
1542
 
1548
1543
  const useCreateQueryClient = () => {
1549
- const { onUserUnavailable, onInvalidOrMissingAuthorization, suppressUserUnavailableErrorNotification, } = useBunnyProviderCallbacks();
1550
- const handleAllErrorFormats = useAllErrorFormats({
1551
- onUserUnavailable,
1552
- onInvalidOrMissingAuthorization,
1553
- suppressUserUnavailableErrorNotification,
1554
- });
1544
+ const { onUserUnavailable, onInvalidOrMissingAuthorization, suppressUserUnavailableErrorNotification } = useBunnyProviderCallbacks();
1545
+ const handleAllErrorFormats = useAllErrorFormats({ onUserUnavailable, onInvalidOrMissingAuthorization, suppressUserUnavailableErrorNotification });
1555
1546
  const onError = (error, _query) => {
1556
1547
  // Extract mutation name from query string
1557
1548
  // const mutationName = query?.mutation?.match(/mutation\s+(\w+)/)?.[1];
@@ -1561,6 +1552,9 @@ const useCreateQueryClient = () => {
1561
1552
  };
1562
1553
  return () => new QueryClient({
1563
1554
  defaultOptions: {
1555
+ mutations: {
1556
+ onError,
1557
+ },
1564
1558
  queries: {
1565
1559
  gcTime: Number.POSITIVE_INFINITY,
1566
1560
  refetchIntervalInBackground: false,
@@ -1569,9 +1563,6 @@ const useCreateQueryClient = () => {
1569
1563
  refetchOnWindowFocus: false,
1570
1564
  },
1571
1565
  },
1572
- mutationCache: new MutationCache({
1573
- onError,
1574
- }),
1575
1566
  queryCache: new QueryCache({
1576
1567
  onError,
1577
1568
  }),
@@ -24443,9 +24434,12 @@ const mutation$c = t(`
24443
24434
  }
24444
24435
  `, [QuoteContext_QuoteFragment]);
24445
24436
  const quoteChargeUpdate$1 = async (quoteChargeId, quantity, apiHost, token) => {
24446
- var _a;
24437
+ var _a, _b;
24447
24438
  const response = await execute(mutation$c, { apiHost, token }, { quoteChargeId, quantity });
24448
- return (_a = response.quoteChargeUpdate) === null || _a === void 0 ? void 0 : _a.quoteCharge;
24439
+ if ((_a = response.quoteChargeUpdate) === null || _a === void 0 ? void 0 : _a.errors) {
24440
+ throw new Error(response.quoteChargeUpdate.errors[0]);
24441
+ }
24442
+ return (_b = response.quoteChargeUpdate) === null || _b === void 0 ? void 0 : _b.quoteCharge;
24449
24443
  };
24450
24444
 
24451
24445
  /**
@@ -24488,9 +24482,12 @@ const mutation$b = t(`
24488
24482
  }
24489
24483
  `, [QuoteContext_QuoteFragment]);
24490
24484
  const quoteChargeDelete = async ({ quoteChargeId, token, apiHost }) => {
24491
- var _a;
24485
+ var _a, _b, _c, _d;
24492
24486
  const response = await execute(mutation$b, { apiHost, token }, { quoteChargeId });
24493
- return (_a = response.quoteChargeDelete) === null || _a === void 0 ? void 0 : _a.quoteCharge;
24487
+ if ((_a = response.quoteChargeDelete) === null || _a === void 0 ? void 0 : _a.errors) {
24488
+ throw new Error((_c = (_b = response.quoteChargeDelete) === null || _b === void 0 ? void 0 : _b.errors) === null || _c === void 0 ? void 0 : _c[0]);
24489
+ }
24490
+ return (_d = response.quoteChargeDelete) === null || _d === void 0 ? void 0 : _d.quoteCharge;
24494
24491
  };
24495
24492
 
24496
24493
  const showErrorNotification$1 = useErrorNotification();
@@ -28223,9 +28220,12 @@ const mutation$6 = t(`
28223
28220
  }
28224
28221
  `, [QuantityDrawer_QuoteFragment]);
28225
28222
  const quoteChargeUpdate = async (quoteChargeId, quantity, apiHost, token) => {
28226
- var _a;
28223
+ var _a, _b;
28227
28224
  const response = await execute(mutation$6, { apiHost, token }, { quoteChargeId, quantity });
28228
- return (_a = response.quoteChargeUpdate) === null || _a === void 0 ? void 0 : _a.quoteCharge;
28225
+ if ((_a = response.quoteChargeUpdate) === null || _a === void 0 ? void 0 : _a.errors) {
28226
+ throw new Error(response.quoteChargeUpdate.errors[0]);
28227
+ }
28228
+ return (_b = response.quoteChargeUpdate) === null || _b === void 0 ? void 0 : _b.quoteCharge;
28229
28229
  };
28230
28230
 
28231
28231
  const mutation$5 = t(`
@@ -28271,9 +28271,12 @@ const mutation$4 = t(`
28271
28271
  }
28272
28272
  `, [QuantityDrawer_QuoteFragment]);
28273
28273
  const quoteSubscriptionUpdate = async (subscriptionIds, apiHost, token) => {
28274
- var _a;
28274
+ var _a, _b;
28275
28275
  const response = await execute(mutation$4, { apiHost, token }, { subscriptionIds });
28276
- return (_a = response.quoteSubscriptionUpdate) === null || _a === void 0 ? void 0 : _a.quote;
28276
+ if ((_a = response.quoteSubscriptionUpdate) === null || _a === void 0 ? void 0 : _a.errors) {
28277
+ throw new Error(response.quoteSubscriptionUpdate.errors[0]);
28278
+ }
28279
+ return (_b = response.quoteSubscriptionUpdate) === null || _b === void 0 ? void 0 : _b.quote;
28277
28280
  };
28278
28281
 
28279
28282
  const formatDateForApi = (date) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bunnyapp/components",
3
- "version": "1.8.0-beta.3",
3
+ "version": "1.8.0",
4
4
  "description": "Components from the Bunny portal to embed Bunny UI functionality into your application.",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",