@dev-fastn-ai/react-core 1.0.13 → 1.0.15

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.
@@ -6,6 +6,7 @@ export declare class Fastn {
6
6
  getConfigurationForm(input: GetConfigurationFormInput): Promise<import("./types").ConfigurationForm>;
7
7
  registerRefetchFunction(input: RegisterRefetchFunctionInput): void;
8
8
  onEvent(event: Event, callback: () => void): void;
9
+ offEvent(event: Event, callback: () => void): void;
9
10
  }
10
11
  export * from './types';
11
12
  export { FastnError, MissingConfigError, AuthenticationError, MissingAuthTokenError, MissingSpaceIdError, MissingTenantIdError } from './utils/errors';
package/dist/index.cjs.js CHANGED
@@ -1036,6 +1036,11 @@ const onEvent = (event, callback) => {
1036
1036
  var _a;
1037
1037
  (_a = listeners[event]) === null || _a === void 0 ? void 0 : _a.add(callback);
1038
1038
  };
1039
+ // Unregister a callback
1040
+ const offEvent = (event, callback) => {
1041
+ var _a;
1042
+ (_a = listeners[event]) === null || _a === void 0 ? void 0 : _a.delete(callback);
1043
+ };
1039
1044
  // Internal postMessage listener
1040
1045
  const handleMessage = (e) => {
1041
1046
  const data = e.data;
@@ -1107,10 +1112,8 @@ async function getConnectors({ disabled = false, status = "ALL", refetch } = {})
1107
1112
  else {
1108
1113
  response = await executeActionHandler(action === null || action === void 0 ? void 0 : action.handler);
1109
1114
  }
1110
- sendEvent("INVALIDATE_CONNECTORS");
1111
- sendEvent("REFETCH_CONNECTORS");
1112
- sendEvent("INVALIDATE_CONFIGURATIONS");
1113
1115
  sendEvent("REFETCH_CONFIGURATIONS");
1116
+ sendEvent("REFETCH_CONNECTORS");
1114
1117
  return response;
1115
1118
  }
1116
1119
  catch (e) {
@@ -1165,7 +1168,6 @@ const handleDisableConfiguration = async ({ id, connectorId, }) => {
1165
1168
  },
1166
1169
  });
1167
1170
  sendEvent("REFETCH_CONFIGURATIONS");
1168
- sendEvent("INVALIDATE_CONFIGURATIONS");
1169
1171
  }
1170
1172
  catch (error) {
1171
1173
  throw new Error(formatApolloErrors(error));
@@ -1175,18 +1177,15 @@ const handleDeleteConfiguration = async ({ id, connectorId, }) => {
1175
1177
  try {
1176
1178
  const config = getConfig();
1177
1179
  await deleteTenantConfiguration({
1178
- variables: {
1179
- input: {
1180
- clientId: config.spaceId,
1181
- tenantId: config.tenantId,
1182
- id: id,
1183
- connectorId,
1184
- widgetConnectorId: connectorId,
1185
- },
1180
+ input: {
1181
+ clientId: config.spaceId,
1182
+ tenantId: config.tenantId,
1183
+ id: id,
1184
+ connectorId,
1185
+ widgetConnectorId: connectorId,
1186
1186
  },
1187
1187
  });
1188
1188
  sendEvent("REFETCH_CONFIGURATIONS");
1189
- sendEvent("INVALIDATE_CONFIGURATIONS");
1190
1189
  }
1191
1190
  catch (error) {
1192
1191
  throw new Error(formatApolloErrors(error));
@@ -1216,8 +1215,6 @@ async function getConfigurations({ configurationId, status = "ALL", }) {
1216
1215
  actionType: ConnectorActionType.DISABLE,
1217
1216
  onClick: async () => {
1218
1217
  await handleDisableConfiguration({ connectorId: configSubscription.connector.id, id: configurationId });
1219
- sendEvent("INVALIDATE_CONFIGURATIONS");
1220
- sendEvent("REFETCH_CONFIGURATIONS");
1221
1218
  return { data: null, status: "SUCCESS" };
1222
1219
  },
1223
1220
  });
@@ -1226,8 +1223,6 @@ async function getConfigurations({ configurationId, status = "ALL", }) {
1226
1223
  actionType: ConnectorActionType.DELETE,
1227
1224
  onClick: async () => {
1228
1225
  await handleDeleteConfiguration({ connectorId: configSubscription.connector.id, id: configurationId });
1229
- sendEvent("INVALIDATE_CONFIGURATIONS");
1230
- sendEvent("REFETCH_CONFIGURATIONS");
1231
1226
  return { data: null, status: "SUCCESS" };
1232
1227
  },
1233
1228
  });
@@ -1245,9 +1240,7 @@ async function getConfigurations({ configurationId, status = "ALL", }) {
1245
1240
  authMethod: (_h = (_g = (_f = configSubscription === null || configSubscription === void 0 ? void 0 : configSubscription.connector) === null || _f === void 0 ? void 0 : _f.connectedConnectors) === null || _g === void 0 ? void 0 : _g[0]) === null || _h === void 0 ? void 0 : _h.authMethods[0],
1246
1241
  input: formData,
1247
1242
  });
1248
- sendEvent("INVALIDATE_CONFIGURATIONS");
1249
1243
  sendEvent("REFETCH_CONFIGURATIONS");
1250
- sendEvent("INVALIDATE_CONNECTORS");
1251
1244
  sendEvent("REFETCH_CONNECTORS");
1252
1245
  return { data: result, status: "SUCCESS" };
1253
1246
  };
@@ -1280,13 +1273,6 @@ async function getConfigurations({ configurationId, status = "ALL", }) {
1280
1273
  }
1281
1274
  }
1282
1275
 
1283
- const refetchFunctions = {};
1284
- const registerRefetchFunction = (input) => {
1285
- console.log("registering refetch function", input);
1286
- const { refetchFunction, refetchKey } = input;
1287
- refetchFunctions[refetchKey] = refetchFunction;
1288
- };
1289
-
1290
1276
  function loadGapiClient() {
1291
1277
  return new Promise((resolve, reject) => {
1292
1278
  const script = document.createElement('script');
@@ -1352,7 +1338,6 @@ async function createGooglePicker(developerKey, accessToken) {
1352
1338
  });
1353
1339
  }
1354
1340
 
1355
- const REFETCH_KEY = "configuration-form";
1356
1341
  function openGoogleFilesPicker(parentArgs) {
1357
1342
  return async (args) => {
1358
1343
  var _a, _b;
@@ -1405,7 +1390,6 @@ function openGoogleFilesPicker(parentArgs) {
1405
1390
  */
1406
1391
  function getSubmitHandler({ configuration, configurationId, connectorId, }) {
1407
1392
  return async ({ formData }) => {
1408
- var _a;
1409
1393
  const config = getConfig();
1410
1394
  const uiCode = populateFormDataInUiCode(configuration.uiCode, formData);
1411
1395
  try {
@@ -1422,7 +1406,6 @@ function getSubmitHandler({ configuration, configurationId, connectorId, }) {
1422
1406
  configurations: formData,
1423
1407
  }),
1424
1408
  });
1425
- await ((_a = refetchFunctions[REFETCH_KEY]) === null || _a === void 0 ? void 0 : _a.call(refetchFunctions));
1426
1409
  }
1427
1410
  else {
1428
1411
  await createTenantConfiguration({
@@ -1439,7 +1422,7 @@ function getSubmitHandler({ configuration, configurationId, connectorId, }) {
1439
1422
  });
1440
1423
  }
1441
1424
  sendEvent("REFRESH_CONFIGURATION_FORM");
1442
- sendEvent("REFETCH_CONNECTORS");
1425
+ sendEvent("REFETCH_CONFIGURATIONS");
1443
1426
  }
1444
1427
  catch (error) {
1445
1428
  throw new Error(formatApolloErrors(error));
@@ -1565,6 +1548,11 @@ async function getConfigurationForm(input) {
1565
1548
  }
1566
1549
  }
1567
1550
 
1551
+ const registerRefetchFunction = (input) => {
1552
+ console.log("registering refetch function", input);
1553
+ const { refetchFunction, refetchKey } = input;
1554
+ };
1555
+
1568
1556
  class Fastn {
1569
1557
  constructor(config) {
1570
1558
  setConfig(config);
@@ -1584,6 +1572,9 @@ class Fastn {
1584
1572
  onEvent(event, callback) {
1585
1573
  return onEvent(event, callback);
1586
1574
  }
1575
+ offEvent(event, callback) {
1576
+ return offEvent(event, callback);
1577
+ }
1587
1578
  }
1588
1579
 
1589
1580
  const FastnContext = react.createContext(null);
@@ -1603,7 +1594,6 @@ const useFastn = () => {
1603
1594
 
1604
1595
  const useConfigurations = (input) => {
1605
1596
  const fastn = useFastn();
1606
- const queryClient = reactQuery.useQueryClient();
1607
1597
  const query = reactQuery.useQuery({
1608
1598
  queryKey: ["configurations", input],
1609
1599
  queryFn: () => fastn.getConfigurations(input),
@@ -1611,10 +1601,12 @@ const useConfigurations = (input) => {
1611
1601
  });
1612
1602
  react.useEffect(() => {
1613
1603
  const invalidate = () => {
1614
- queryClient.invalidateQueries({ queryKey: ["configurations"] });
1615
1604
  query.refetch();
1616
1605
  };
1617
1606
  fastn.onEvent("REFETCH_CONFIGURATIONS", invalidate);
1607
+ return () => {
1608
+ fastn.offEvent("REFETCH_CONFIGURATIONS", invalidate);
1609
+ };
1618
1610
  }, [query.data]);
1619
1611
  return query;
1620
1612
  };
@@ -1622,7 +1614,6 @@ const useConfigurations = (input) => {
1622
1614
  const useConfigurationForm = (input) => {
1623
1615
  var _a;
1624
1616
  const fastn = useFastn();
1625
- const queryClient = reactQuery.useQueryClient();
1626
1617
  const configurations = useConfigurations({
1627
1618
  configurationId: input.configurationId,
1628
1619
  });
@@ -1636,22 +1627,18 @@ const useConfigurationForm = (input) => {
1636
1627
  });
1637
1628
  react.useEffect(() => {
1638
1629
  const invalidate = () => {
1639
- queryClient.invalidateQueries({
1640
- queryKey: ["configuration-form", input],
1641
- });
1642
- queryClient.invalidateQueries({
1643
- queryKey: ["configurations"],
1644
- });
1645
1630
  query.refetch();
1646
1631
  };
1647
1632
  fastn.onEvent("REFRESH_CONFIGURATION_FORM", invalidate);
1633
+ return () => {
1634
+ fastn.offEvent("REFRESH_CONFIGURATION_FORM", invalidate);
1635
+ };
1648
1636
  }, [query.data]);
1649
1637
  return query;
1650
1638
  };
1651
1639
 
1652
1640
  const useConnectors = () => {
1653
1641
  const fastn = useFastn();
1654
- const queryClient = reactQuery.useQueryClient();
1655
1642
  const query = reactQuery.useQuery({
1656
1643
  queryKey: ["connectors"],
1657
1644
  queryFn: () => fastn.getConnectors(),
@@ -1659,10 +1646,12 @@ const useConnectors = () => {
1659
1646
  });
1660
1647
  react.useEffect(() => {
1661
1648
  const invalidate = () => {
1662
- queryClient.invalidateQueries({ queryKey: ["connectors"] });
1663
1649
  query.refetch();
1664
1650
  };
1665
1651
  fastn.onEvent("REFETCH_CONNECTORS", invalidate);
1652
+ return () => {
1653
+ fastn.offEvent("REFETCH_CONNECTORS", invalidate);
1654
+ };
1666
1655
  }, [query.data]);
1667
1656
  return query;
1668
1657
  };
@@ -1788,19 +1777,30 @@ function useFieldOptions(field) {
1788
1777
  setSearchQuery("");
1789
1778
  // Invalidate and refetch initial query
1790
1779
  if ((_a = field.optionsSource) === null || _a === void 0 ? void 0 : _a.getOptions) {
1791
- await queryClient.invalidateQueries({ queryKey: [...queryKey, "initial"] });
1780
+ await queryClient.invalidateQueries({
1781
+ queryKey: [...queryKey, "initial"],
1782
+ });
1792
1783
  await initialQuery.refetch();
1793
1784
  }
1794
1785
  // Invalidate and refetch infinite query
1795
1786
  if ((_b = field.optionsSource) === null || _b === void 0 ? void 0 : _b.loadMore) {
1796
- await queryClient.invalidateQueries({ queryKey: [...queryKey, "infinite"] });
1787
+ await queryClient.invalidateQueries({
1788
+ queryKey: [...queryKey, "infinite"],
1789
+ });
1797
1790
  await infiniteQuery.refetch();
1798
1791
  }
1799
1792
  }
1800
1793
  catch (error) {
1801
1794
  console.error("Error in refresh:", error);
1802
1795
  }
1803
- }, [queryClient, queryKey, initialQuery, infiniteQuery, field.optionsSource, field]);
1796
+ }, [
1797
+ queryClient,
1798
+ queryKey,
1799
+ initialQuery,
1800
+ infiniteQuery,
1801
+ field.optionsSource,
1802
+ field,
1803
+ ]);
1804
1804
  return {
1805
1805
  options: filteredOptions,
1806
1806
  loading: initialQuery.isLoading || infiniteQuery.isLoading,
package/dist/index.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
2
  import { createContext, useMemo, useContext, useEffect, useState, useCallback } from 'react';
3
- import { QueryClientProvider, QueryClient, useQueryClient, useQuery, useInfiniteQuery } from '@tanstack/react-query';
3
+ import { QueryClientProvider, QueryClient, useQuery, useQueryClient, useInfiniteQuery } from '@tanstack/react-query';
4
4
  export * from '@dev-fastn-ai/core';
5
5
 
6
6
  const REQUEST_TRACE_ID_HEADER_KEY = 'x-fastn-request-trace-id';
@@ -1034,6 +1034,11 @@ const onEvent = (event, callback) => {
1034
1034
  var _a;
1035
1035
  (_a = listeners[event]) === null || _a === void 0 ? void 0 : _a.add(callback);
1036
1036
  };
1037
+ // Unregister a callback
1038
+ const offEvent = (event, callback) => {
1039
+ var _a;
1040
+ (_a = listeners[event]) === null || _a === void 0 ? void 0 : _a.delete(callback);
1041
+ };
1037
1042
  // Internal postMessage listener
1038
1043
  const handleMessage = (e) => {
1039
1044
  const data = e.data;
@@ -1105,10 +1110,8 @@ async function getConnectors({ disabled = false, status = "ALL", refetch } = {})
1105
1110
  else {
1106
1111
  response = await executeActionHandler(action === null || action === void 0 ? void 0 : action.handler);
1107
1112
  }
1108
- sendEvent("INVALIDATE_CONNECTORS");
1109
- sendEvent("REFETCH_CONNECTORS");
1110
- sendEvent("INVALIDATE_CONFIGURATIONS");
1111
1113
  sendEvent("REFETCH_CONFIGURATIONS");
1114
+ sendEvent("REFETCH_CONNECTORS");
1112
1115
  return response;
1113
1116
  }
1114
1117
  catch (e) {
@@ -1163,7 +1166,6 @@ const handleDisableConfiguration = async ({ id, connectorId, }) => {
1163
1166
  },
1164
1167
  });
1165
1168
  sendEvent("REFETCH_CONFIGURATIONS");
1166
- sendEvent("INVALIDATE_CONFIGURATIONS");
1167
1169
  }
1168
1170
  catch (error) {
1169
1171
  throw new Error(formatApolloErrors(error));
@@ -1173,18 +1175,15 @@ const handleDeleteConfiguration = async ({ id, connectorId, }) => {
1173
1175
  try {
1174
1176
  const config = getConfig();
1175
1177
  await deleteTenantConfiguration({
1176
- variables: {
1177
- input: {
1178
- clientId: config.spaceId,
1179
- tenantId: config.tenantId,
1180
- id: id,
1181
- connectorId,
1182
- widgetConnectorId: connectorId,
1183
- },
1178
+ input: {
1179
+ clientId: config.spaceId,
1180
+ tenantId: config.tenantId,
1181
+ id: id,
1182
+ connectorId,
1183
+ widgetConnectorId: connectorId,
1184
1184
  },
1185
1185
  });
1186
1186
  sendEvent("REFETCH_CONFIGURATIONS");
1187
- sendEvent("INVALIDATE_CONFIGURATIONS");
1188
1187
  }
1189
1188
  catch (error) {
1190
1189
  throw new Error(formatApolloErrors(error));
@@ -1214,8 +1213,6 @@ async function getConfigurations({ configurationId, status = "ALL", }) {
1214
1213
  actionType: ConnectorActionType.DISABLE,
1215
1214
  onClick: async () => {
1216
1215
  await handleDisableConfiguration({ connectorId: configSubscription.connector.id, id: configurationId });
1217
- sendEvent("INVALIDATE_CONFIGURATIONS");
1218
- sendEvent("REFETCH_CONFIGURATIONS");
1219
1216
  return { data: null, status: "SUCCESS" };
1220
1217
  },
1221
1218
  });
@@ -1224,8 +1221,6 @@ async function getConfigurations({ configurationId, status = "ALL", }) {
1224
1221
  actionType: ConnectorActionType.DELETE,
1225
1222
  onClick: async () => {
1226
1223
  await handleDeleteConfiguration({ connectorId: configSubscription.connector.id, id: configurationId });
1227
- sendEvent("INVALIDATE_CONFIGURATIONS");
1228
- sendEvent("REFETCH_CONFIGURATIONS");
1229
1224
  return { data: null, status: "SUCCESS" };
1230
1225
  },
1231
1226
  });
@@ -1243,9 +1238,7 @@ async function getConfigurations({ configurationId, status = "ALL", }) {
1243
1238
  authMethod: (_h = (_g = (_f = configSubscription === null || configSubscription === void 0 ? void 0 : configSubscription.connector) === null || _f === void 0 ? void 0 : _f.connectedConnectors) === null || _g === void 0 ? void 0 : _g[0]) === null || _h === void 0 ? void 0 : _h.authMethods[0],
1244
1239
  input: formData,
1245
1240
  });
1246
- sendEvent("INVALIDATE_CONFIGURATIONS");
1247
1241
  sendEvent("REFETCH_CONFIGURATIONS");
1248
- sendEvent("INVALIDATE_CONNECTORS");
1249
1242
  sendEvent("REFETCH_CONNECTORS");
1250
1243
  return { data: result, status: "SUCCESS" };
1251
1244
  };
@@ -1278,13 +1271,6 @@ async function getConfigurations({ configurationId, status = "ALL", }) {
1278
1271
  }
1279
1272
  }
1280
1273
 
1281
- const refetchFunctions = {};
1282
- const registerRefetchFunction = (input) => {
1283
- console.log("registering refetch function", input);
1284
- const { refetchFunction, refetchKey } = input;
1285
- refetchFunctions[refetchKey] = refetchFunction;
1286
- };
1287
-
1288
1274
  function loadGapiClient() {
1289
1275
  return new Promise((resolve, reject) => {
1290
1276
  const script = document.createElement('script');
@@ -1350,7 +1336,6 @@ async function createGooglePicker(developerKey, accessToken) {
1350
1336
  });
1351
1337
  }
1352
1338
 
1353
- const REFETCH_KEY = "configuration-form";
1354
1339
  function openGoogleFilesPicker(parentArgs) {
1355
1340
  return async (args) => {
1356
1341
  var _a, _b;
@@ -1403,7 +1388,6 @@ function openGoogleFilesPicker(parentArgs) {
1403
1388
  */
1404
1389
  function getSubmitHandler({ configuration, configurationId, connectorId, }) {
1405
1390
  return async ({ formData }) => {
1406
- var _a;
1407
1391
  const config = getConfig();
1408
1392
  const uiCode = populateFormDataInUiCode(configuration.uiCode, formData);
1409
1393
  try {
@@ -1420,7 +1404,6 @@ function getSubmitHandler({ configuration, configurationId, connectorId, }) {
1420
1404
  configurations: formData,
1421
1405
  }),
1422
1406
  });
1423
- await ((_a = refetchFunctions[REFETCH_KEY]) === null || _a === void 0 ? void 0 : _a.call(refetchFunctions));
1424
1407
  }
1425
1408
  else {
1426
1409
  await createTenantConfiguration({
@@ -1437,7 +1420,7 @@ function getSubmitHandler({ configuration, configurationId, connectorId, }) {
1437
1420
  });
1438
1421
  }
1439
1422
  sendEvent("REFRESH_CONFIGURATION_FORM");
1440
- sendEvent("REFETCH_CONNECTORS");
1423
+ sendEvent("REFETCH_CONFIGURATIONS");
1441
1424
  }
1442
1425
  catch (error) {
1443
1426
  throw new Error(formatApolloErrors(error));
@@ -1563,6 +1546,11 @@ async function getConfigurationForm(input) {
1563
1546
  }
1564
1547
  }
1565
1548
 
1549
+ const registerRefetchFunction = (input) => {
1550
+ console.log("registering refetch function", input);
1551
+ const { refetchFunction, refetchKey } = input;
1552
+ };
1553
+
1566
1554
  class Fastn {
1567
1555
  constructor(config) {
1568
1556
  setConfig(config);
@@ -1582,6 +1570,9 @@ class Fastn {
1582
1570
  onEvent(event, callback) {
1583
1571
  return onEvent(event, callback);
1584
1572
  }
1573
+ offEvent(event, callback) {
1574
+ return offEvent(event, callback);
1575
+ }
1585
1576
  }
1586
1577
 
1587
1578
  const FastnContext = createContext(null);
@@ -1601,7 +1592,6 @@ const useFastn = () => {
1601
1592
 
1602
1593
  const useConfigurations = (input) => {
1603
1594
  const fastn = useFastn();
1604
- const queryClient = useQueryClient();
1605
1595
  const query = useQuery({
1606
1596
  queryKey: ["configurations", input],
1607
1597
  queryFn: () => fastn.getConfigurations(input),
@@ -1609,10 +1599,12 @@ const useConfigurations = (input) => {
1609
1599
  });
1610
1600
  useEffect(() => {
1611
1601
  const invalidate = () => {
1612
- queryClient.invalidateQueries({ queryKey: ["configurations"] });
1613
1602
  query.refetch();
1614
1603
  };
1615
1604
  fastn.onEvent("REFETCH_CONFIGURATIONS", invalidate);
1605
+ return () => {
1606
+ fastn.offEvent("REFETCH_CONFIGURATIONS", invalidate);
1607
+ };
1616
1608
  }, [query.data]);
1617
1609
  return query;
1618
1610
  };
@@ -1620,7 +1612,6 @@ const useConfigurations = (input) => {
1620
1612
  const useConfigurationForm = (input) => {
1621
1613
  var _a;
1622
1614
  const fastn = useFastn();
1623
- const queryClient = useQueryClient();
1624
1615
  const configurations = useConfigurations({
1625
1616
  configurationId: input.configurationId,
1626
1617
  });
@@ -1634,22 +1625,18 @@ const useConfigurationForm = (input) => {
1634
1625
  });
1635
1626
  useEffect(() => {
1636
1627
  const invalidate = () => {
1637
- queryClient.invalidateQueries({
1638
- queryKey: ["configuration-form", input],
1639
- });
1640
- queryClient.invalidateQueries({
1641
- queryKey: ["configurations"],
1642
- });
1643
1628
  query.refetch();
1644
1629
  };
1645
1630
  fastn.onEvent("REFRESH_CONFIGURATION_FORM", invalidate);
1631
+ return () => {
1632
+ fastn.offEvent("REFRESH_CONFIGURATION_FORM", invalidate);
1633
+ };
1646
1634
  }, [query.data]);
1647
1635
  return query;
1648
1636
  };
1649
1637
 
1650
1638
  const useConnectors = () => {
1651
1639
  const fastn = useFastn();
1652
- const queryClient = useQueryClient();
1653
1640
  const query = useQuery({
1654
1641
  queryKey: ["connectors"],
1655
1642
  queryFn: () => fastn.getConnectors(),
@@ -1657,10 +1644,12 @@ const useConnectors = () => {
1657
1644
  });
1658
1645
  useEffect(() => {
1659
1646
  const invalidate = () => {
1660
- queryClient.invalidateQueries({ queryKey: ["connectors"] });
1661
1647
  query.refetch();
1662
1648
  };
1663
1649
  fastn.onEvent("REFETCH_CONNECTORS", invalidate);
1650
+ return () => {
1651
+ fastn.offEvent("REFETCH_CONNECTORS", invalidate);
1652
+ };
1664
1653
  }, [query.data]);
1665
1654
  return query;
1666
1655
  };
@@ -1786,19 +1775,30 @@ function useFieldOptions(field) {
1786
1775
  setSearchQuery("");
1787
1776
  // Invalidate and refetch initial query
1788
1777
  if ((_a = field.optionsSource) === null || _a === void 0 ? void 0 : _a.getOptions) {
1789
- await queryClient.invalidateQueries({ queryKey: [...queryKey, "initial"] });
1778
+ await queryClient.invalidateQueries({
1779
+ queryKey: [...queryKey, "initial"],
1780
+ });
1790
1781
  await initialQuery.refetch();
1791
1782
  }
1792
1783
  // Invalidate and refetch infinite query
1793
1784
  if ((_b = field.optionsSource) === null || _b === void 0 ? void 0 : _b.loadMore) {
1794
- await queryClient.invalidateQueries({ queryKey: [...queryKey, "infinite"] });
1785
+ await queryClient.invalidateQueries({
1786
+ queryKey: [...queryKey, "infinite"],
1787
+ });
1795
1788
  await infiniteQuery.refetch();
1796
1789
  }
1797
1790
  }
1798
1791
  catch (error) {
1799
1792
  console.error("Error in refresh:", error);
1800
1793
  }
1801
- }, [queryClient, queryKey, initialQuery, infiniteQuery, field.optionsSource, field]);
1794
+ }, [
1795
+ queryClient,
1796
+ queryKey,
1797
+ initialQuery,
1798
+ infiniteQuery,
1799
+ field.optionsSource,
1800
+ field,
1801
+ ]);
1802
1802
  return {
1803
1803
  options: filteredOptions,
1804
1804
  loading: initialQuery.isLoading || infiniteQuery.isLoading,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dev-fastn-ai/react-core",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "React hooks and components for integrating Fastn AI connector marketplace into your applications. Built on top of @fastn-ai/core with React Query for optimal performance.",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -59,7 +59,7 @@
59
59
  },
60
60
  "homepage": "https://docs.fastn.ai",
61
61
  "dependencies": {
62
- "@dev-fastn-ai/core": "^1.0.9"
62
+ "@dev-fastn-ai/core": "^1.0.10"
63
63
  },
64
64
  "peerDependencies": {
65
65
  "@tanstack/react-query": "^5.0.0",