@dev-fastn-ai/react-core 1.0.10 → 1.0.12

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.
@@ -1,10 +1,11 @@
1
- import type { GetConfigurationFormInput, GetConfigurationsInput, FastnConfig, GetConnectorsInput, RegisterRefetchFunctionInput } from './types';
1
+ import type { GetConfigurationFormInput, GetConfigurationsInput, FastnConfig, GetConnectorsInput, RegisterRefetchFunctionInput, Event } from './types';
2
2
  export declare class Fastn {
3
3
  constructor(config: Required<FastnConfig>);
4
4
  getConnectors(input?: GetConnectorsInput): Promise<import("./types").Connector[]>;
5
5
  getConfigurations(input: GetConfigurationsInput): Promise<import("./types").Configuration[]>;
6
6
  getConfigurationForm(input: GetConfigurationFormInput): Promise<import("./types").ConfigurationForm>;
7
7
  registerRefetchFunction(input: RegisterRefetchFunctionInput): void;
8
+ onEvent(event: Event, callback: () => void): void;
8
9
  }
9
10
  export * from './types';
10
11
  export { FastnError, MissingConfigError, AuthenticationError, MissingAuthTokenError, MissingSpaceIdError, MissingTenantIdError } from './utils/errors';
@@ -121,6 +121,7 @@ export interface Configuration {
121
121
  readonly actions: readonly ConfigurationAction[];
122
122
  readonly metadata?: unknown;
123
123
  }
124
+ export type Event = "REFETCH_CONNECTORS" | "REFETCH_CONFIGURATIONS" | "REFRESH_CONFIGURATION_FORM" | "INVALIDATE_CONFIGURATION_FORM" | "INVALIDATE_CONFIGURATIONS" | "INVALIDATE_CONNECTORS";
124
125
  /**
125
126
  * Represents an action available on a configuration.
126
127
  */
@@ -0,0 +1,6 @@
1
+ import { EventEmitter } from "events";
2
+ import { Event } from "../types";
3
+ export declare const eventBus: EventEmitter<[never]>;
4
+ declare const sendEvent: (event: Event) => void;
5
+ declare const onEvent: (event: Event, callback: () => void) => void;
6
+ export { sendEvent, onEvent };
package/dist/index.cjs.js CHANGED
@@ -3,6 +3,7 @@
3
3
  var jsxRuntime = require('react/jsx-runtime');
4
4
  var react = require('react');
5
5
  var reactQuery = require('@tanstack/react-query');
6
+ var events = require('events');
6
7
  var core = require('@dev-fastn-ai/core');
7
8
 
8
9
  const REQUEST_TRACE_ID_HEADER_KEY = 'x-fastn-request-trace-id';
@@ -1017,14 +1018,14 @@ const activateConnectorCore = async ({ dependencyConnector, authMethod, formData
1017
1018
  }
1018
1019
  };
1019
1020
 
1020
- const refetchFunctions = {};
1021
- const registerRefetchFunction = (input) => {
1022
- console.log("registering refetch function", input);
1023
- const { refetchFunction, refetchKey } = input;
1024
- refetchFunctions[refetchKey] = refetchFunction;
1021
+ const eventBus = new events.EventEmitter();
1022
+ const sendEvent = (event) => {
1023
+ eventBus.emit(event);
1024
+ };
1025
+ const onEvent = (event, callback) => {
1026
+ eventBus.on(event, callback);
1025
1027
  };
1026
1028
 
1027
- const REFETCH_KEY$2 = "connectors";
1028
1029
  /**
1029
1030
  * Fetches connectors and maps their actions for use in the application.
1030
1031
  * Updates the global state store.
@@ -1063,7 +1064,7 @@ async function getConnectors({ disabled = false, status = "ALL", refetch } = {})
1063
1064
  .map((action) => {
1064
1065
  var _a, _b, _c, _d;
1065
1066
  const handler = async (formData = {}) => {
1066
- var _a, _b, _c, _d, _e;
1067
+ var _a, _b, _c, _d;
1067
1068
  try {
1068
1069
  let response = null;
1069
1070
  if ((action === null || action === void 0 ? void 0 : action.actionType) === "ACTIVATION") {
@@ -1085,7 +1086,10 @@ async function getConnectors({ disabled = false, status = "ALL", refetch } = {})
1085
1086
  else {
1086
1087
  response = await executeActionHandler(action === null || action === void 0 ? void 0 : action.handler);
1087
1088
  }
1088
- await ((_e = refetchFunctions[REFETCH_KEY$2]) === null || _e === void 0 ? void 0 : _e.call(refetchFunctions));
1089
+ sendEvent("INVALIDATE_CONNECTORS");
1090
+ sendEvent("REFETCH_CONNECTORS");
1091
+ sendEvent("INVALIDATE_CONFIGURATIONS");
1092
+ sendEvent("REFETCH_CONFIGURATIONS");
1089
1093
  return response;
1090
1094
  }
1091
1095
  catch (e) {
@@ -1127,9 +1131,7 @@ async function getConnectors({ disabled = false, status = "ALL", refetch } = {})
1127
1131
  }
1128
1132
  }
1129
1133
 
1130
- const REFETCH_KEY$1 = "configurations";
1131
1134
  const handleDisableConfiguration = async ({ id, connectorId, }) => {
1132
- var _a;
1133
1135
  try {
1134
1136
  const config = getConfig();
1135
1137
  await disableTenantConfig({
@@ -1141,14 +1143,14 @@ const handleDisableConfiguration = async ({ id, connectorId, }) => {
1141
1143
  widgetConnectorId: connectorId,
1142
1144
  },
1143
1145
  });
1144
- await ((_a = refetchFunctions[REFETCH_KEY$1]) === null || _a === void 0 ? void 0 : _a.call(refetchFunctions));
1146
+ sendEvent("REFETCH_CONFIGURATIONS");
1147
+ sendEvent("INVALIDATE_CONFIGURATIONS");
1145
1148
  }
1146
1149
  catch (error) {
1147
1150
  throw new Error(formatApolloErrors(error));
1148
1151
  }
1149
1152
  };
1150
1153
  const handleDeleteConfiguration = async ({ id, connectorId, }) => {
1151
- var _a;
1152
1154
  try {
1153
1155
  const config = getConfig();
1154
1156
  await deleteTenantConfiguration({
@@ -1162,7 +1164,8 @@ const handleDeleteConfiguration = async ({ id, connectorId, }) => {
1162
1164
  },
1163
1165
  },
1164
1166
  });
1165
- await ((_a = refetchFunctions[REFETCH_KEY$1]) === null || _a === void 0 ? void 0 : _a.call(refetchFunctions));
1167
+ sendEvent("REFETCH_CONFIGURATIONS");
1168
+ sendEvent("INVALIDATE_CONFIGURATIONS");
1166
1169
  }
1167
1170
  catch (error) {
1168
1171
  throw new Error(formatApolloErrors(error));
@@ -1191,9 +1194,9 @@ async function getConfigurations({ configurationId, status = "ALL", }) {
1191
1194
  name: "Disable",
1192
1195
  actionType: ConnectorActionType.DISABLE,
1193
1196
  onClick: async () => {
1194
- var _a;
1195
1197
  await handleDisableConfiguration({ connectorId: configSubscription.connector.id, id: configurationId });
1196
- await ((_a = refetchFunctions[REFETCH_KEY$1]) === null || _a === void 0 ? void 0 : _a.call(refetchFunctions));
1198
+ sendEvent("INVALIDATE_CONFIGURATIONS");
1199
+ sendEvent("REFETCH_CONFIGURATIONS");
1197
1200
  return { data: null, status: "SUCCESS" };
1198
1201
  },
1199
1202
  });
@@ -1201,9 +1204,9 @@ async function getConfigurations({ configurationId, status = "ALL", }) {
1201
1204
  name: "Delete",
1202
1205
  actionType: ConnectorActionType.DELETE,
1203
1206
  onClick: async () => {
1204
- var _a;
1205
1207
  await handleDeleteConfiguration({ connectorId: configSubscription.connector.id, id: configurationId });
1206
- await ((_a = refetchFunctions[REFETCH_KEY$1]) === null || _a === void 0 ? void 0 : _a.call(refetchFunctions));
1208
+ sendEvent("INVALIDATE_CONFIGURATIONS");
1209
+ sendEvent("REFETCH_CONFIGURATIONS");
1207
1210
  return { data: null, status: "SUCCESS" };
1208
1211
  },
1209
1212
  });
@@ -1221,6 +1224,10 @@ async function getConfigurations({ configurationId, status = "ALL", }) {
1221
1224
  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],
1222
1225
  input: formData,
1223
1226
  });
1227
+ sendEvent("INVALIDATE_CONFIGURATIONS");
1228
+ sendEvent("REFETCH_CONFIGURATIONS");
1229
+ sendEvent("INVALIDATE_CONNECTORS");
1230
+ sendEvent("REFETCH_CONNECTORS");
1224
1231
  return { data: result, status: "SUCCESS" };
1225
1232
  };
1226
1233
  actions.push({
@@ -1252,6 +1259,13 @@ async function getConfigurations({ configurationId, status = "ALL", }) {
1252
1259
  }
1253
1260
  }
1254
1261
 
1262
+ const refetchFunctions = {};
1263
+ const registerRefetchFunction = (input) => {
1264
+ console.log("registering refetch function", input);
1265
+ const { refetchFunction, refetchKey } = input;
1266
+ refetchFunctions[refetchKey] = refetchFunction;
1267
+ };
1268
+
1255
1269
  function loadGapiClient() {
1256
1270
  return new Promise((resolve, reject) => {
1257
1271
  const script = document.createElement('script');
@@ -1320,21 +1334,38 @@ async function createGooglePicker(developerKey, accessToken) {
1320
1334
  const REFETCH_KEY = "configuration-form";
1321
1335
  function openGoogleFilesPicker(parentArgs) {
1322
1336
  return async (args) => {
1323
- var _a, _b, _c;
1337
+ var _a, _b;
1324
1338
  try {
1325
1339
  const config = getConfig();
1326
- const { data } = await generateAccessToken({
1327
- input: {
1328
- orgId: config.spaceId,
1329
- tenantId: config.tenantId,
1330
- connectorId: parentArgs.connectorId,
1331
- refresh: true,
1332
- },
1333
- });
1334
- const accessToken = (_a = data === null || data === void 0 ? void 0 : data.connectorConnection) === null || _a === void 0 ? void 0 : _a.access_token;
1335
- if (!accessToken)
1336
- throw new Error("Missing access token from connector");
1337
- const docs = await createGooglePicker(args.apiKey || ((_c = (_b = data === null || data === void 0 ? void 0 : data.connectorConnection) === null || _b === void 0 ? void 0 : _b.metadata) === null || _c === void 0 ? void 0 : _c.google_picker_api_key), accessToken);
1340
+ let accessToken = null;
1341
+ let apiKey = null;
1342
+ const cachedToken = localStorage.getItem(config.spaceId + parentArgs.connectorId + config.tenantId + "access_token");
1343
+ if (cachedToken) {
1344
+ const token = safeParse(cachedToken);
1345
+ if ((token === null || token === void 0 ? void 0 : token.expires_at) && token.expires_at > Date.now()) {
1346
+ accessToken = token.access_token;
1347
+ }
1348
+ }
1349
+ if (!accessToken) {
1350
+ const { data } = await generateAccessToken({
1351
+ input: {
1352
+ orgId: config.spaceId,
1353
+ tenantId: config.tenantId,
1354
+ connectorId: parentArgs.connectorId,
1355
+ refresh: true,
1356
+ },
1357
+ });
1358
+ const token = data === null || data === void 0 ? void 0 : data.connectorConnection;
1359
+ // cache token in local storage
1360
+ localStorage.setItem(config.spaceId + parentArgs.connectorId + config.tenantId + "access_token", safeStringify({
1361
+ access_token: token.access_token,
1362
+ api_key: (_a = token.metadata) === null || _a === void 0 ? void 0 : _a.google_picker_api_key,
1363
+ expires_at: token.expires_at || Date.now() + token.expires_in * 1000,
1364
+ }));
1365
+ accessToken = token.access_token;
1366
+ apiKey = (_b = token.metadata) === null || _b === void 0 ? void 0 : _b.google_picker_api_key;
1367
+ }
1368
+ const docs = await createGooglePicker(args.apiKey || apiKey, accessToken);
1338
1369
  const files = (docs || []).map((doc) => ({
1339
1370
  label: doc === null || doc === void 0 ? void 0 : doc.name,
1340
1371
  value: doc === null || doc === void 0 ? void 0 : doc.id,
@@ -1353,7 +1384,7 @@ function openGoogleFilesPicker(parentArgs) {
1353
1384
  */
1354
1385
  function getSubmitHandler({ configuration, configurationId, connectorId, }) {
1355
1386
  return async ({ formData }) => {
1356
- var _a, _b;
1387
+ var _a;
1357
1388
  const config = getConfig();
1358
1389
  const uiCode = populateFormDataInUiCode(configuration.uiCode, formData);
1359
1390
  try {
@@ -1385,8 +1416,9 @@ function getSubmitHandler({ configuration, configurationId, connectorId, }) {
1385
1416
  configurations: formData,
1386
1417
  }),
1387
1418
  });
1388
- await ((_b = refetchFunctions[REFETCH_KEY]) === null || _b === void 0 ? void 0 : _b.call(refetchFunctions));
1389
1419
  }
1420
+ sendEvent("REFRESH_CONFIGURATION_FORM");
1421
+ sendEvent("REFETCH_CONNECTORS");
1390
1422
  }
1391
1423
  catch (error) {
1392
1424
  throw new Error(formatApolloErrors(error));
@@ -1528,6 +1560,9 @@ class Fastn {
1528
1560
  registerRefetchFunction(input) {
1529
1561
  return registerRefetchFunction(input);
1530
1562
  }
1563
+ onEvent(event, callback) {
1564
+ return onEvent(event, callback);
1565
+ }
1531
1566
  }
1532
1567
 
1533
1568
  const FastnContext = react.createContext(null);
@@ -1547,33 +1582,67 @@ const useFastn = () => {
1547
1582
 
1548
1583
  const useConfigurations = (input) => {
1549
1584
  const fastn = useFastn();
1585
+ const queryClient = reactQuery.useQueryClient();
1550
1586
  const query = reactQuery.useQuery({
1551
1587
  queryKey: ["configurations", input],
1552
1588
  queryFn: () => fastn.getConfigurations(input),
1553
1589
  staleTime: 1000 * 60 * 5, // 5 minutes
1554
1590
  });
1591
+ react.useEffect(() => {
1592
+ const invalidate = () => {
1593
+ queryClient.invalidateQueries({ queryKey: ["configurations"] });
1594
+ query.refetch();
1595
+ };
1596
+ fastn.onEvent("REFETCH_CONFIGURATIONS", invalidate);
1597
+ }, [query.data]);
1555
1598
  return query;
1556
1599
  };
1557
1600
 
1558
1601
  const useConfigurationForm = (input) => {
1559
1602
  var _a;
1560
1603
  const fastn = useFastn();
1561
- const configurations = useConfigurations({ configurationId: input.configurationId });
1604
+ const queryClient = reactQuery.useQueryClient();
1605
+ const configurations = useConfigurations({
1606
+ configurationId: input.configurationId,
1607
+ });
1562
1608
  const query = reactQuery.useQuery({
1563
1609
  queryKey: ["configuration-form", input],
1564
- queryFn: () => { var _a; return fastn.getConfigurationForm(Object.assign(Object.assign({}, input), { configuration: (_a = configurations === null || configurations === void 0 ? void 0 : configurations.data) === null || _a === void 0 ? void 0 : _a.find(c => c.configurationId === input.configurationId) })); },
1565
- enabled: !!((_a = configurations === null || configurations === void 0 ? void 0 : configurations.data) === null || _a === void 0 ? void 0 : _a.find(c => c.configurationId === input.configurationId)),
1610
+ queryFn: () => {
1611
+ var _a;
1612
+ return fastn.getConfigurationForm(Object.assign(Object.assign({}, input), { configuration: (_a = configurations === null || configurations === void 0 ? void 0 : configurations.data) === null || _a === void 0 ? void 0 : _a.find((c) => c.connectorId === input.connectorId) }));
1613
+ },
1614
+ enabled: !!((_a = configurations === null || configurations === void 0 ? void 0 : configurations.data) === null || _a === void 0 ? void 0 : _a.find((c) => c.connectorId === input.connectorId)),
1566
1615
  });
1616
+ react.useEffect(() => {
1617
+ const invalidate = () => {
1618
+ queryClient.invalidateQueries({
1619
+ queryKey: ["configuration-form", input],
1620
+ });
1621
+ queryClient.invalidateQueries({
1622
+ queryKey: ["configurations"],
1623
+ });
1624
+ query.refetch();
1625
+ };
1626
+ fastn.onEvent("REFRESH_CONFIGURATION_FORM", invalidate);
1627
+ }, [query.data]);
1567
1628
  return query;
1568
1629
  };
1569
1630
 
1570
1631
  const useConnectors = () => {
1571
1632
  const fastn = useFastn();
1633
+ const queryClient = reactQuery.useQueryClient();
1572
1634
  const query = reactQuery.useQuery({
1573
1635
  queryKey: ["connectors"],
1574
1636
  queryFn: () => fastn.getConnectors(),
1575
1637
  staleTime: 1000 * 60 * 5, // 5 minutes,
1576
1638
  });
1639
+ react.useEffect(() => {
1640
+ const invalidate = () => {
1641
+ queryClient.invalidateQueries({ queryKey: ["connectors"] });
1642
+ query.refetch();
1643
+ };
1644
+ fastn.onEvent("REFETCH_CONNECTORS", invalidate);
1645
+ }, [query.data]);
1577
1646
  return query;
1578
1647
  };
1579
1648
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../../core/node_modules/uuid/dist/esm-browser/rng.js","../../core/node_modules/uuid/dist/esm-browser/stringify.js","../../core/node_modules/uuid/dist/esm-browser/native.js","../../core/node_modules/uuid/dist/esm-browser/v4.js"],"sourcesContent":["// Unique ID creation requires a high quality random # generator. In the browser we therefore\n// require the crypto API and do not support built-in fallback to lower quality random number\n// generators (like Math.random()).\nlet getRandomValues;\nconst rnds8 = new Uint8Array(16);\nexport default function rng() {\n // lazy load so that environments that need to polyfill have a chance to do so\n if (!getRandomValues) {\n // getRandomValues needs to be invoked in a context where \"this\" is a Crypto implementation.\n getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);\n\n if (!getRandomValues) {\n throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');\n }\n }\n\n return getRandomValues(rnds8);\n}","import validate from './validate.js';\n/**\n * Convert array of 16 byte values to UUID string format of the form:\n * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n */\n\nconst byteToHex = [];\n\nfor (let i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).slice(1));\n}\n\nexport function unsafeStringify(arr, offset = 0) {\n // Note: Be careful editing this code! It's been tuned for performance\n // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434\n return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];\n}\n\nfunction stringify(arr, offset = 0) {\n const uuid = unsafeStringify(arr, offset); // Consistency check for valid UUID. If this throws, it's likely due to one\n // of the following:\n // - One or more input array values don't map to a hex octet (leading to\n // \"undefined\" in the uuid)\n // - Invalid input values for the RFC `version` or `variant` fields\n\n if (!validate(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n\n return uuid;\n}\n\nexport default stringify;","const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);\nexport default {\n randomUUID\n};","import native from './native.js';\nimport rng from './rng.js';\nimport { unsafeStringify } from './stringify.js';\n\nfunction v4(options, buf, offset) {\n if (native.randomUUID && !buf && !options) {\n return native.randomUUID();\n }\n\n options = options || {};\n const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`\n\n rnds[6] = rnds[6] & 0x0f | 0x40;\n rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided\n\n if (buf) {\n offset = offset || 0;\n\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = rnds[i];\n }\n\n return buf;\n }\n\n return unsafeStringify(rnds);\n}\n\nexport default v4;"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA,IAAI,eAAe;AACnB,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC;AACjB,SAAS,GAAG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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","x_google_ignoreList":[0,1,2,3]}
1
+ {"version":3,"file":"index.cjs.js","sources":["../../core/node_modules/uuid/dist/esm-browser/rng.js","../../core/node_modules/uuid/dist/esm-browser/stringify.js","../../core/node_modules/uuid/dist/esm-browser/native.js","../../core/node_modules/uuid/dist/esm-browser/v4.js"],"sourcesContent":["// Unique ID creation requires a high quality random # generator. In the browser we therefore\n// require the crypto API and do not support built-in fallback to lower quality random number\n// generators (like Math.random()).\nlet getRandomValues;\nconst rnds8 = new Uint8Array(16);\nexport default function rng() {\n // lazy load so that environments that need to polyfill have a chance to do so\n if (!getRandomValues) {\n // getRandomValues needs to be invoked in a context where \"this\" is a Crypto implementation.\n getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);\n\n if (!getRandomValues) {\n throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');\n }\n }\n\n return getRandomValues(rnds8);\n}","import validate from './validate.js';\n/**\n * Convert array of 16 byte values to UUID string format of the form:\n * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n */\n\nconst byteToHex = [];\n\nfor (let i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).slice(1));\n}\n\nexport function unsafeStringify(arr, offset = 0) {\n // Note: Be careful editing this code! It's been tuned for performance\n // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434\n return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];\n}\n\nfunction stringify(arr, offset = 0) {\n const uuid = unsafeStringify(arr, offset); // Consistency check for valid UUID. If this throws, it's likely due to one\n // of the following:\n // - One or more input array values don't map to a hex octet (leading to\n // \"undefined\" in the uuid)\n // - Invalid input values for the RFC `version` or `variant` fields\n\n if (!validate(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n\n return uuid;\n}\n\nexport default stringify;","const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);\nexport default {\n randomUUID\n};","import native from './native.js';\nimport rng from './rng.js';\nimport { unsafeStringify } from './stringify.js';\n\nfunction v4(options, buf, offset) {\n if (native.randomUUID && !buf && !options) {\n return native.randomUUID();\n }\n\n options = options || {};\n const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`\n\n rnds[6] = rnds[6] & 0x0f | 0x40;\n rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided\n\n if (buf) {\n offset = offset || 0;\n\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = rnds[i];\n }\n\n return buf;\n }\n\n return unsafeStringify(rnds);\n}\n\nexport default v4;"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA,IAAI,eAAe;AACnB,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC;AACjB,SAAS,GAAG,GAAG;AAC9B;AACA,EAAE,IAAI,CAAC,eAAe,EAAE;AACxB;AACA,IAAI,eAAe,GAAG,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,eAAe,IAAI,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC;;AAEpH,IAAI,IAAI,CAAC,eAAe,EAAE;AAC1B,MAAM,MAAM,IAAI,KAAK,CAAC,0GAA0G,CAAC;AACjI,IAAI;AACJ,EAAE;;AAEF,EAAE,OAAO,eAAe,CAAC,KAAK,CAAC;AAC/B;;AChBA;AACA;AACA;AACA;;AAEA,MAAM,SAAS,GAAG,EAAE;;AAEpB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,EAAE,CAAC,EAAE;AAC9B,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACnD;;AAEO,SAAS,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,EAAE;AACjD;AACA;AACA,EAAE,OAAO,SAAS,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,GA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,3]}
package/dist/index.esm.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
- import { createContext, useMemo, useContext, useState, useCallback } from 'react';
3
- import { QueryClientProvider, QueryClient, useQuery, useQueryClient, useInfiniteQuery } from '@tanstack/react-query';
2
+ import { createContext, useMemo, useContext, useEffect, useState, useCallback } from 'react';
3
+ import { QueryClientProvider, QueryClient, useQueryClient, useQuery, useInfiniteQuery } from '@tanstack/react-query';
4
+ import { EventEmitter } from 'events';
4
5
  export * from '@dev-fastn-ai/core';
5
6
 
6
7
  const REQUEST_TRACE_ID_HEADER_KEY = 'x-fastn-request-trace-id';
@@ -1015,14 +1016,14 @@ const activateConnectorCore = async ({ dependencyConnector, authMethod, formData
1015
1016
  }
1016
1017
  };
1017
1018
 
1018
- const refetchFunctions = {};
1019
- const registerRefetchFunction = (input) => {
1020
- console.log("registering refetch function", input);
1021
- const { refetchFunction, refetchKey } = input;
1022
- refetchFunctions[refetchKey] = refetchFunction;
1019
+ const eventBus = new EventEmitter();
1020
+ const sendEvent = (event) => {
1021
+ eventBus.emit(event);
1022
+ };
1023
+ const onEvent = (event, callback) => {
1024
+ eventBus.on(event, callback);
1023
1025
  };
1024
1026
 
1025
- const REFETCH_KEY$2 = "connectors";
1026
1027
  /**
1027
1028
  * Fetches connectors and maps their actions for use in the application.
1028
1029
  * Updates the global state store.
@@ -1061,7 +1062,7 @@ async function getConnectors({ disabled = false, status = "ALL", refetch } = {})
1061
1062
  .map((action) => {
1062
1063
  var _a, _b, _c, _d;
1063
1064
  const handler = async (formData = {}) => {
1064
- var _a, _b, _c, _d, _e;
1065
+ var _a, _b, _c, _d;
1065
1066
  try {
1066
1067
  let response = null;
1067
1068
  if ((action === null || action === void 0 ? void 0 : action.actionType) === "ACTIVATION") {
@@ -1083,7 +1084,10 @@ async function getConnectors({ disabled = false, status = "ALL", refetch } = {})
1083
1084
  else {
1084
1085
  response = await executeActionHandler(action === null || action === void 0 ? void 0 : action.handler);
1085
1086
  }
1086
- await ((_e = refetchFunctions[REFETCH_KEY$2]) === null || _e === void 0 ? void 0 : _e.call(refetchFunctions));
1087
+ sendEvent("INVALIDATE_CONNECTORS");
1088
+ sendEvent("REFETCH_CONNECTORS");
1089
+ sendEvent("INVALIDATE_CONFIGURATIONS");
1090
+ sendEvent("REFETCH_CONFIGURATIONS");
1087
1091
  return response;
1088
1092
  }
1089
1093
  catch (e) {
@@ -1125,9 +1129,7 @@ async function getConnectors({ disabled = false, status = "ALL", refetch } = {})
1125
1129
  }
1126
1130
  }
1127
1131
 
1128
- const REFETCH_KEY$1 = "configurations";
1129
1132
  const handleDisableConfiguration = async ({ id, connectorId, }) => {
1130
- var _a;
1131
1133
  try {
1132
1134
  const config = getConfig();
1133
1135
  await disableTenantConfig({
@@ -1139,14 +1141,14 @@ const handleDisableConfiguration = async ({ id, connectorId, }) => {
1139
1141
  widgetConnectorId: connectorId,
1140
1142
  },
1141
1143
  });
1142
- await ((_a = refetchFunctions[REFETCH_KEY$1]) === null || _a === void 0 ? void 0 : _a.call(refetchFunctions));
1144
+ sendEvent("REFETCH_CONFIGURATIONS");
1145
+ sendEvent("INVALIDATE_CONFIGURATIONS");
1143
1146
  }
1144
1147
  catch (error) {
1145
1148
  throw new Error(formatApolloErrors(error));
1146
1149
  }
1147
1150
  };
1148
1151
  const handleDeleteConfiguration = async ({ id, connectorId, }) => {
1149
- var _a;
1150
1152
  try {
1151
1153
  const config = getConfig();
1152
1154
  await deleteTenantConfiguration({
@@ -1160,7 +1162,8 @@ const handleDeleteConfiguration = async ({ id, connectorId, }) => {
1160
1162
  },
1161
1163
  },
1162
1164
  });
1163
- await ((_a = refetchFunctions[REFETCH_KEY$1]) === null || _a === void 0 ? void 0 : _a.call(refetchFunctions));
1165
+ sendEvent("REFETCH_CONFIGURATIONS");
1166
+ sendEvent("INVALIDATE_CONFIGURATIONS");
1164
1167
  }
1165
1168
  catch (error) {
1166
1169
  throw new Error(formatApolloErrors(error));
@@ -1189,9 +1192,9 @@ async function getConfigurations({ configurationId, status = "ALL", }) {
1189
1192
  name: "Disable",
1190
1193
  actionType: ConnectorActionType.DISABLE,
1191
1194
  onClick: async () => {
1192
- var _a;
1193
1195
  await handleDisableConfiguration({ connectorId: configSubscription.connector.id, id: configurationId });
1194
- await ((_a = refetchFunctions[REFETCH_KEY$1]) === null || _a === void 0 ? void 0 : _a.call(refetchFunctions));
1196
+ sendEvent("INVALIDATE_CONFIGURATIONS");
1197
+ sendEvent("REFETCH_CONFIGURATIONS");
1195
1198
  return { data: null, status: "SUCCESS" };
1196
1199
  },
1197
1200
  });
@@ -1199,9 +1202,9 @@ async function getConfigurations({ configurationId, status = "ALL", }) {
1199
1202
  name: "Delete",
1200
1203
  actionType: ConnectorActionType.DELETE,
1201
1204
  onClick: async () => {
1202
- var _a;
1203
1205
  await handleDeleteConfiguration({ connectorId: configSubscription.connector.id, id: configurationId });
1204
- await ((_a = refetchFunctions[REFETCH_KEY$1]) === null || _a === void 0 ? void 0 : _a.call(refetchFunctions));
1206
+ sendEvent("INVALIDATE_CONFIGURATIONS");
1207
+ sendEvent("REFETCH_CONFIGURATIONS");
1205
1208
  return { data: null, status: "SUCCESS" };
1206
1209
  },
1207
1210
  });
@@ -1219,6 +1222,10 @@ async function getConfigurations({ configurationId, status = "ALL", }) {
1219
1222
  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],
1220
1223
  input: formData,
1221
1224
  });
1225
+ sendEvent("INVALIDATE_CONFIGURATIONS");
1226
+ sendEvent("REFETCH_CONFIGURATIONS");
1227
+ sendEvent("INVALIDATE_CONNECTORS");
1228
+ sendEvent("REFETCH_CONNECTORS");
1222
1229
  return { data: result, status: "SUCCESS" };
1223
1230
  };
1224
1231
  actions.push({
@@ -1250,6 +1257,13 @@ async function getConfigurations({ configurationId, status = "ALL", }) {
1250
1257
  }
1251
1258
  }
1252
1259
 
1260
+ const refetchFunctions = {};
1261
+ const registerRefetchFunction = (input) => {
1262
+ console.log("registering refetch function", input);
1263
+ const { refetchFunction, refetchKey } = input;
1264
+ refetchFunctions[refetchKey] = refetchFunction;
1265
+ };
1266
+
1253
1267
  function loadGapiClient() {
1254
1268
  return new Promise((resolve, reject) => {
1255
1269
  const script = document.createElement('script');
@@ -1318,21 +1332,38 @@ async function createGooglePicker(developerKey, accessToken) {
1318
1332
  const REFETCH_KEY = "configuration-form";
1319
1333
  function openGoogleFilesPicker(parentArgs) {
1320
1334
  return async (args) => {
1321
- var _a, _b, _c;
1335
+ var _a, _b;
1322
1336
  try {
1323
1337
  const config = getConfig();
1324
- const { data } = await generateAccessToken({
1325
- input: {
1326
- orgId: config.spaceId,
1327
- tenantId: config.tenantId,
1328
- connectorId: parentArgs.connectorId,
1329
- refresh: true,
1330
- },
1331
- });
1332
- const accessToken = (_a = data === null || data === void 0 ? void 0 : data.connectorConnection) === null || _a === void 0 ? void 0 : _a.access_token;
1333
- if (!accessToken)
1334
- throw new Error("Missing access token from connector");
1335
- const docs = await createGooglePicker(args.apiKey || ((_c = (_b = data === null || data === void 0 ? void 0 : data.connectorConnection) === null || _b === void 0 ? void 0 : _b.metadata) === null || _c === void 0 ? void 0 : _c.google_picker_api_key), accessToken);
1338
+ let accessToken = null;
1339
+ let apiKey = null;
1340
+ const cachedToken = localStorage.getItem(config.spaceId + parentArgs.connectorId + config.tenantId + "access_token");
1341
+ if (cachedToken) {
1342
+ const token = safeParse(cachedToken);
1343
+ if ((token === null || token === void 0 ? void 0 : token.expires_at) && token.expires_at > Date.now()) {
1344
+ accessToken = token.access_token;
1345
+ }
1346
+ }
1347
+ if (!accessToken) {
1348
+ const { data } = await generateAccessToken({
1349
+ input: {
1350
+ orgId: config.spaceId,
1351
+ tenantId: config.tenantId,
1352
+ connectorId: parentArgs.connectorId,
1353
+ refresh: true,
1354
+ },
1355
+ });
1356
+ const token = data === null || data === void 0 ? void 0 : data.connectorConnection;
1357
+ // cache token in local storage
1358
+ localStorage.setItem(config.spaceId + parentArgs.connectorId + config.tenantId + "access_token", safeStringify({
1359
+ access_token: token.access_token,
1360
+ api_key: (_a = token.metadata) === null || _a === void 0 ? void 0 : _a.google_picker_api_key,
1361
+ expires_at: token.expires_at || Date.now() + token.expires_in * 1000,
1362
+ }));
1363
+ accessToken = token.access_token;
1364
+ apiKey = (_b = token.metadata) === null || _b === void 0 ? void 0 : _b.google_picker_api_key;
1365
+ }
1366
+ const docs = await createGooglePicker(args.apiKey || apiKey, accessToken);
1336
1367
  const files = (docs || []).map((doc) => ({
1337
1368
  label: doc === null || doc === void 0 ? void 0 : doc.name,
1338
1369
  value: doc === null || doc === void 0 ? void 0 : doc.id,
@@ -1351,7 +1382,7 @@ function openGoogleFilesPicker(parentArgs) {
1351
1382
  */
1352
1383
  function getSubmitHandler({ configuration, configurationId, connectorId, }) {
1353
1384
  return async ({ formData }) => {
1354
- var _a, _b;
1385
+ var _a;
1355
1386
  const config = getConfig();
1356
1387
  const uiCode = populateFormDataInUiCode(configuration.uiCode, formData);
1357
1388
  try {
@@ -1383,8 +1414,9 @@ function getSubmitHandler({ configuration, configurationId, connectorId, }) {
1383
1414
  configurations: formData,
1384
1415
  }),
1385
1416
  });
1386
- await ((_b = refetchFunctions[REFETCH_KEY]) === null || _b === void 0 ? void 0 : _b.call(refetchFunctions));
1387
1417
  }
1418
+ sendEvent("REFRESH_CONFIGURATION_FORM");
1419
+ sendEvent("REFETCH_CONNECTORS");
1388
1420
  }
1389
1421
  catch (error) {
1390
1422
  throw new Error(formatApolloErrors(error));
@@ -1526,6 +1558,9 @@ class Fastn {
1526
1558
  registerRefetchFunction(input) {
1527
1559
  return registerRefetchFunction(input);
1528
1560
  }
1561
+ onEvent(event, callback) {
1562
+ return onEvent(event, callback);
1563
+ }
1529
1564
  }
1530
1565
 
1531
1566
  const FastnContext = createContext(null);
@@ -1545,33 +1580,67 @@ const useFastn = () => {
1545
1580
 
1546
1581
  const useConfigurations = (input) => {
1547
1582
  const fastn = useFastn();
1583
+ const queryClient = useQueryClient();
1548
1584
  const query = useQuery({
1549
1585
  queryKey: ["configurations", input],
1550
1586
  queryFn: () => fastn.getConfigurations(input),
1551
1587
  staleTime: 1000 * 60 * 5, // 5 minutes
1552
1588
  });
1589
+ useEffect(() => {
1590
+ const invalidate = () => {
1591
+ queryClient.invalidateQueries({ queryKey: ["configurations"] });
1592
+ query.refetch();
1593
+ };
1594
+ fastn.onEvent("REFETCH_CONFIGURATIONS", invalidate);
1595
+ }, [query.data]);
1553
1596
  return query;
1554
1597
  };
1555
1598
 
1556
1599
  const useConfigurationForm = (input) => {
1557
1600
  var _a;
1558
1601
  const fastn = useFastn();
1559
- const configurations = useConfigurations({ configurationId: input.configurationId });
1602
+ const queryClient = useQueryClient();
1603
+ const configurations = useConfigurations({
1604
+ configurationId: input.configurationId,
1605
+ });
1560
1606
  const query = useQuery({
1561
1607
  queryKey: ["configuration-form", input],
1562
- queryFn: () => { var _a; return fastn.getConfigurationForm(Object.assign(Object.assign({}, input), { configuration: (_a = configurations === null || configurations === void 0 ? void 0 : configurations.data) === null || _a === void 0 ? void 0 : _a.find(c => c.configurationId === input.configurationId) })); },
1563
- enabled: !!((_a = configurations === null || configurations === void 0 ? void 0 : configurations.data) === null || _a === void 0 ? void 0 : _a.find(c => c.configurationId === input.configurationId)),
1608
+ queryFn: () => {
1609
+ var _a;
1610
+ return fastn.getConfigurationForm(Object.assign(Object.assign({}, input), { configuration: (_a = configurations === null || configurations === void 0 ? void 0 : configurations.data) === null || _a === void 0 ? void 0 : _a.find((c) => c.connectorId === input.connectorId) }));
1611
+ },
1612
+ enabled: !!((_a = configurations === null || configurations === void 0 ? void 0 : configurations.data) === null || _a === void 0 ? void 0 : _a.find((c) => c.connectorId === input.connectorId)),
1564
1613
  });
1614
+ useEffect(() => {
1615
+ const invalidate = () => {
1616
+ queryClient.invalidateQueries({
1617
+ queryKey: ["configuration-form", input],
1618
+ });
1619
+ queryClient.invalidateQueries({
1620
+ queryKey: ["configurations"],
1621
+ });
1622
+ query.refetch();
1623
+ };
1624
+ fastn.onEvent("REFRESH_CONFIGURATION_FORM", invalidate);
1625
+ }, [query.data]);
1565
1626
  return query;
1566
1627
  };
1567
1628
 
1568
1629
  const useConnectors = () => {
1569
1630
  const fastn = useFastn();
1631
+ const queryClient = useQueryClient();
1570
1632
  const query = useQuery({
1571
1633
  queryKey: ["connectors"],
1572
1634
  queryFn: () => fastn.getConnectors(),
1573
1635
  staleTime: 1000 * 60 * 5, // 5 minutes,
1574
1636
  });
1637
+ useEffect(() => {
1638
+ const invalidate = () => {
1639
+ queryClient.invalidateQueries({ queryKey: ["connectors"] });
1640
+ query.refetch();
1641
+ };
1642
+ fastn.onEvent("REFETCH_CONNECTORS", invalidate);
1643
+ }, [query.data]);
1575
1644
  return query;
1576
1645
  };
1577
1646
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../../core/node_modules/uuid/dist/esm-browser/rng.js","../../core/node_modules/uuid/dist/esm-browser/stringify.js","../../core/node_modules/uuid/dist/esm-browser/native.js","../../core/node_modules/uuid/dist/esm-browser/v4.js"],"sourcesContent":["// Unique ID creation requires a high quality random # generator. In the browser we therefore\n// require the crypto API and do not support built-in fallback to lower quality random number\n// generators (like Math.random()).\nlet getRandomValues;\nconst rnds8 = new Uint8Array(16);\nexport default function rng() {\n // lazy load so that environments that need to polyfill have a chance to do so\n if (!getRandomValues) {\n // getRandomValues needs to be invoked in a context where \"this\" is a Crypto implementation.\n getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);\n\n if (!getRandomValues) {\n throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');\n }\n }\n\n return getRandomValues(rnds8);\n}","import validate from './validate.js';\n/**\n * Convert array of 16 byte values to UUID string format of the form:\n * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n */\n\nconst byteToHex = [];\n\nfor (let i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).slice(1));\n}\n\nexport function unsafeStringify(arr, offset = 0) {\n // Note: Be careful editing this code! It's been tuned for performance\n // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434\n return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];\n}\n\nfunction stringify(arr, offset = 0) {\n const uuid = unsafeStringify(arr, offset); // Consistency check for valid UUID. If this throws, it's likely due to one\n // of the following:\n // - One or more input array values don't map to a hex octet (leading to\n // \"undefined\" in the uuid)\n // - Invalid input values for the RFC `version` or `variant` fields\n\n if (!validate(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n\n return uuid;\n}\n\nexport default stringify;","const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);\nexport default {\n randomUUID\n};","import native from './native.js';\nimport rng from './rng.js';\nimport { unsafeStringify } from './stringify.js';\n\nfunction v4(options, buf, offset) {\n if (native.randomUUID && !buf && !options) {\n return native.randomUUID();\n }\n\n options = options || {};\n const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`\n\n rnds[6] = rnds[6] & 0x0f | 0x40;\n rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided\n\n if (buf) {\n offset = offset || 0;\n\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = rnds[i];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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","x_google_ignoreList":[0,1,2,3]}
1
+ {"version":3,"file":"index.esm.js","sources":["../../core/node_modules/uuid/dist/esm-browser/rng.js","../../core/node_modules/uuid/dist/esm-browser/stringify.js","../../core/node_modules/uuid/dist/esm-browser/native.js","../../core/node_modules/uuid/dist/esm-browser/v4.js"],"sourcesContent":["// Unique ID creation requires a high quality random # generator. In the browser we therefore\n// require the crypto API and do not support built-in fallback to lower quality random number\n// generators (like Math.random()).\nlet getRandomValues;\nconst rnds8 = new Uint8Array(16);\nexport default function rng() {\n // lazy load so that environments that need to polyfill have a chance to do so\n if (!getRandomValues) {\n // getRandomValues needs to be invoked in a context where \"this\" is a Crypto implementation.\n getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);\n\n if (!getRandomValues) {\n throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');\n }\n }\n\n return getRandomValues(rnds8);\n}","import validate from './validate.js';\n/**\n * Convert array of 16 byte values to UUID string format of the form:\n * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n */\n\nconst byteToHex = [];\n\nfor (let i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).slice(1));\n}\n\nexport function unsafeStringify(arr, offset = 0) {\n // Note: Be careful editing this code! It's been tuned for performance\n // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434\n return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];\n}\n\nfunction stringify(arr, offset = 0) {\n const uuid = unsafeStringify(arr, offset); // Consistency check for valid UUID. If this throws, it's likely due to one\n // of the following:\n // - One or more input array values don't map to a hex octet (leading to\n // \"undefined\" in the uuid)\n // - Invalid input values for the RFC `version` or `variant` fields\n\n if (!validate(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n\n return uuid;\n}\n\nexport default stringify;","const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);\nexport default {\n randomUUID\n};","import native from './native.js';\nimport rng from './rng.js';\nimport { unsafeStringify } from './stringify.js';\n\nfunction v4(options, buf, offset) {\n if (native.randomUUID && !buf && !options) {\n return native.randomUUID();\n }\n\n options = options || {};\n const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`\n\n rnds[6] = rnds[6] & 0x0f | 0x40;\n rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided\n\n if (buf) {\n offset = offset || 0;\n\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = rnds[i];\n }\n\n return buf;\n }\n\n return unsafeStringify(rnds);\n}\n\nexport default v4;"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA,IAAI,eAAe;AACnB,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC;AACjB,SAAS,GAAG,GAAG;AAC9B;AACA,EAAE,IAAI,CAAC,eAAe,EAAE;AACxB;AACA,IAAI,eAAe,GAAG,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,eAAe,IAAI,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC;;AAEpH,IAAI,IAAI,CAAC,eAAe,EAAE;AAC1B,MAAM,MAAM,IAAI,KAAK,CAAC,0GAA0G,CAAC;AACjI,IAAI;AACJ,EAAE;;AAEF,EAAE,OAAO,eAAe,CAAC,KAAK,CAAC;AAC/B;;AChBA;AACA;AACA;AACA;;AAEA,MAAM,SAAS,GAAG,EAAE;;AAEpB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,EAAE,CAAC,EAAE;AAC9B,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACnD;;AAEO,SAAS,eAAe,CAAC,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","x_google_ignoreList":[0,1,2,3]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dev-fastn-ai/react-core",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
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.6"
62
+ "@dev-fastn-ai/core": "^1.0.8"
63
63
  },
64
64
  "peerDependencies": {
65
65
  "@tanstack/react-query": "^5.0.0",