@dev-fastn-ai/react-core 1.0.12 → 1.0.14
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/core/src/index.d.ts +1 -0
- package/dist/core/src/utils/event-bus.d.ts +5 -5
- package/dist/index.cjs.js +49 -37
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +50 -38
- package/dist/index.esm.js.map +1 -1
- package/package.json +2 -2
package/dist/core/src/index.d.ts
CHANGED
|
@@ -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';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { EventEmitter } from "events";
|
|
2
1
|
import { Event } from "../types";
|
|
3
|
-
|
|
4
|
-
declare const sendEvent: (event: Event) => void;
|
|
5
|
-
declare const onEvent: (event: Event, callback:
|
|
6
|
-
export
|
|
2
|
+
type EventCallback = () => void;
|
|
3
|
+
export declare const sendEvent: (event: Event) => void;
|
|
4
|
+
export declare const onEvent: (event: Event, callback: EventCallback) => void;
|
|
5
|
+
export declare const offEvent: (event: Event, callback: EventCallback) => void;
|
|
6
|
+
export {};
|
package/dist/index.cjs.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
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');
|
|
7
6
|
var core = require('@dev-fastn-ai/core');
|
|
8
7
|
|
|
9
8
|
const REQUEST_TRACE_ID_HEADER_KEY = 'x-fastn-request-trace-id';
|
|
@@ -1018,13 +1017,40 @@ const activateConnectorCore = async ({ dependencyConnector, authMethod, formData
|
|
|
1018
1017
|
}
|
|
1019
1018
|
};
|
|
1020
1019
|
|
|
1021
|
-
|
|
1020
|
+
// eventBus.ts
|
|
1021
|
+
// Internal listener registry
|
|
1022
|
+
const listeners = {
|
|
1023
|
+
'REFETCH_CONNECTORS': new Set(),
|
|
1024
|
+
'REFETCH_CONFIGURATIONS': new Set(),
|
|
1025
|
+
'REFRESH_CONFIGURATION_FORM': new Set(),
|
|
1026
|
+
'INVALIDATE_CONFIGURATION_FORM': new Set(),
|
|
1027
|
+
'INVALIDATE_CONFIGURATIONS': new Set(),
|
|
1028
|
+
'INVALIDATE_CONNECTORS': new Set(),
|
|
1029
|
+
};
|
|
1030
|
+
// Send a cross-context-safe event
|
|
1022
1031
|
const sendEvent = (event) => {
|
|
1023
|
-
|
|
1032
|
+
window.postMessage({ __eventBus: true, event }, '*');
|
|
1024
1033
|
};
|
|
1034
|
+
// Register a callback for a specific event
|
|
1025
1035
|
const onEvent = (event, callback) => {
|
|
1026
|
-
|
|
1036
|
+
var _a;
|
|
1037
|
+
(_a = listeners[event]) === null || _a === void 0 ? void 0 : _a.add(callback);
|
|
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);
|
|
1027
1043
|
};
|
|
1044
|
+
// Internal postMessage listener
|
|
1045
|
+
const handleMessage = (e) => {
|
|
1046
|
+
const data = e.data;
|
|
1047
|
+
if (!data || !data.__eventBus || !data.event)
|
|
1048
|
+
return;
|
|
1049
|
+
const callbacks = listeners[data.event];
|
|
1050
|
+
callbacks === null || callbacks === void 0 ? void 0 : callbacks.forEach((cb) => cb());
|
|
1051
|
+
};
|
|
1052
|
+
// Register listener once
|
|
1053
|
+
window.addEventListener('message', handleMessage);
|
|
1028
1054
|
|
|
1029
1055
|
/**
|
|
1030
1056
|
* Fetches connectors and maps their actions for use in the application.
|
|
@@ -1086,10 +1112,8 @@ async function getConnectors({ disabled = false, status = "ALL", refetch } = {})
|
|
|
1086
1112
|
else {
|
|
1087
1113
|
response = await executeActionHandler(action === null || action === void 0 ? void 0 : action.handler);
|
|
1088
1114
|
}
|
|
1089
|
-
sendEvent("INVALIDATE_CONNECTORS");
|
|
1090
|
-
sendEvent("REFETCH_CONNECTORS");
|
|
1091
|
-
sendEvent("INVALIDATE_CONFIGURATIONS");
|
|
1092
1115
|
sendEvent("REFETCH_CONFIGURATIONS");
|
|
1116
|
+
sendEvent("REFETCH_CONNECTORS");
|
|
1093
1117
|
return response;
|
|
1094
1118
|
}
|
|
1095
1119
|
catch (e) {
|
|
@@ -1144,7 +1168,6 @@ const handleDisableConfiguration = async ({ id, connectorId, }) => {
|
|
|
1144
1168
|
},
|
|
1145
1169
|
});
|
|
1146
1170
|
sendEvent("REFETCH_CONFIGURATIONS");
|
|
1147
|
-
sendEvent("INVALIDATE_CONFIGURATIONS");
|
|
1148
1171
|
}
|
|
1149
1172
|
catch (error) {
|
|
1150
1173
|
throw new Error(formatApolloErrors(error));
|
|
@@ -1165,7 +1188,6 @@ const handleDeleteConfiguration = async ({ id, connectorId, }) => {
|
|
|
1165
1188
|
},
|
|
1166
1189
|
});
|
|
1167
1190
|
sendEvent("REFETCH_CONFIGURATIONS");
|
|
1168
|
-
sendEvent("INVALIDATE_CONFIGURATIONS");
|
|
1169
1191
|
}
|
|
1170
1192
|
catch (error) {
|
|
1171
1193
|
throw new Error(formatApolloErrors(error));
|
|
@@ -1195,8 +1217,6 @@ async function getConfigurations({ configurationId, status = "ALL", }) {
|
|
|
1195
1217
|
actionType: ConnectorActionType.DISABLE,
|
|
1196
1218
|
onClick: async () => {
|
|
1197
1219
|
await handleDisableConfiguration({ connectorId: configSubscription.connector.id, id: configurationId });
|
|
1198
|
-
sendEvent("INVALIDATE_CONFIGURATIONS");
|
|
1199
|
-
sendEvent("REFETCH_CONFIGURATIONS");
|
|
1200
1220
|
return { data: null, status: "SUCCESS" };
|
|
1201
1221
|
},
|
|
1202
1222
|
});
|
|
@@ -1205,8 +1225,6 @@ async function getConfigurations({ configurationId, status = "ALL", }) {
|
|
|
1205
1225
|
actionType: ConnectorActionType.DELETE,
|
|
1206
1226
|
onClick: async () => {
|
|
1207
1227
|
await handleDeleteConfiguration({ connectorId: configSubscription.connector.id, id: configurationId });
|
|
1208
|
-
sendEvent("INVALIDATE_CONFIGURATIONS");
|
|
1209
|
-
sendEvent("REFETCH_CONFIGURATIONS");
|
|
1210
1228
|
return { data: null, status: "SUCCESS" };
|
|
1211
1229
|
},
|
|
1212
1230
|
});
|
|
@@ -1224,9 +1242,7 @@ async function getConfigurations({ configurationId, status = "ALL", }) {
|
|
|
1224
1242
|
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],
|
|
1225
1243
|
input: formData,
|
|
1226
1244
|
});
|
|
1227
|
-
sendEvent("INVALIDATE_CONFIGURATIONS");
|
|
1228
1245
|
sendEvent("REFETCH_CONFIGURATIONS");
|
|
1229
|
-
sendEvent("INVALIDATE_CONNECTORS");
|
|
1230
1246
|
sendEvent("REFETCH_CONNECTORS");
|
|
1231
1247
|
return { data: result, status: "SUCCESS" };
|
|
1232
1248
|
};
|
|
@@ -1259,13 +1275,6 @@ async function getConfigurations({ configurationId, status = "ALL", }) {
|
|
|
1259
1275
|
}
|
|
1260
1276
|
}
|
|
1261
1277
|
|
|
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
|
-
|
|
1269
1278
|
function loadGapiClient() {
|
|
1270
1279
|
return new Promise((resolve, reject) => {
|
|
1271
1280
|
const script = document.createElement('script');
|
|
@@ -1331,7 +1340,6 @@ async function createGooglePicker(developerKey, accessToken) {
|
|
|
1331
1340
|
});
|
|
1332
1341
|
}
|
|
1333
1342
|
|
|
1334
|
-
const REFETCH_KEY = "configuration-form";
|
|
1335
1343
|
function openGoogleFilesPicker(parentArgs) {
|
|
1336
1344
|
return async (args) => {
|
|
1337
1345
|
var _a, _b;
|
|
@@ -1384,7 +1392,6 @@ function openGoogleFilesPicker(parentArgs) {
|
|
|
1384
1392
|
*/
|
|
1385
1393
|
function getSubmitHandler({ configuration, configurationId, connectorId, }) {
|
|
1386
1394
|
return async ({ formData }) => {
|
|
1387
|
-
var _a;
|
|
1388
1395
|
const config = getConfig();
|
|
1389
1396
|
const uiCode = populateFormDataInUiCode(configuration.uiCode, formData);
|
|
1390
1397
|
try {
|
|
@@ -1401,7 +1408,6 @@ function getSubmitHandler({ configuration, configurationId, connectorId, }) {
|
|
|
1401
1408
|
configurations: formData,
|
|
1402
1409
|
}),
|
|
1403
1410
|
});
|
|
1404
|
-
await ((_a = refetchFunctions[REFETCH_KEY]) === null || _a === void 0 ? void 0 : _a.call(refetchFunctions));
|
|
1405
1411
|
}
|
|
1406
1412
|
else {
|
|
1407
1413
|
await createTenantConfiguration({
|
|
@@ -1418,7 +1424,7 @@ function getSubmitHandler({ configuration, configurationId, connectorId, }) {
|
|
|
1418
1424
|
});
|
|
1419
1425
|
}
|
|
1420
1426
|
sendEvent("REFRESH_CONFIGURATION_FORM");
|
|
1421
|
-
sendEvent("
|
|
1427
|
+
sendEvent("REFETCH_CONFIGURATIONS");
|
|
1422
1428
|
}
|
|
1423
1429
|
catch (error) {
|
|
1424
1430
|
throw new Error(formatApolloErrors(error));
|
|
@@ -1544,6 +1550,11 @@ async function getConfigurationForm(input) {
|
|
|
1544
1550
|
}
|
|
1545
1551
|
}
|
|
1546
1552
|
|
|
1553
|
+
const registerRefetchFunction = (input) => {
|
|
1554
|
+
console.log("registering refetch function", input);
|
|
1555
|
+
const { refetchFunction, refetchKey } = input;
|
|
1556
|
+
};
|
|
1557
|
+
|
|
1547
1558
|
class Fastn {
|
|
1548
1559
|
constructor(config) {
|
|
1549
1560
|
setConfig(config);
|
|
@@ -1563,6 +1574,9 @@ class Fastn {
|
|
|
1563
1574
|
onEvent(event, callback) {
|
|
1564
1575
|
return onEvent(event, callback);
|
|
1565
1576
|
}
|
|
1577
|
+
offEvent(event, callback) {
|
|
1578
|
+
return offEvent(event, callback);
|
|
1579
|
+
}
|
|
1566
1580
|
}
|
|
1567
1581
|
|
|
1568
1582
|
const FastnContext = react.createContext(null);
|
|
@@ -1582,7 +1596,6 @@ const useFastn = () => {
|
|
|
1582
1596
|
|
|
1583
1597
|
const useConfigurations = (input) => {
|
|
1584
1598
|
const fastn = useFastn();
|
|
1585
|
-
const queryClient = reactQuery.useQueryClient();
|
|
1586
1599
|
const query = reactQuery.useQuery({
|
|
1587
1600
|
queryKey: ["configurations", input],
|
|
1588
1601
|
queryFn: () => fastn.getConfigurations(input),
|
|
@@ -1590,10 +1603,12 @@ const useConfigurations = (input) => {
|
|
|
1590
1603
|
});
|
|
1591
1604
|
react.useEffect(() => {
|
|
1592
1605
|
const invalidate = () => {
|
|
1593
|
-
queryClient.invalidateQueries({ queryKey: ["configurations"] });
|
|
1594
1606
|
query.refetch();
|
|
1595
1607
|
};
|
|
1596
1608
|
fastn.onEvent("REFETCH_CONFIGURATIONS", invalidate);
|
|
1609
|
+
return () => {
|
|
1610
|
+
fastn.offEvent("REFETCH_CONFIGURATIONS", invalidate);
|
|
1611
|
+
};
|
|
1597
1612
|
}, [query.data]);
|
|
1598
1613
|
return query;
|
|
1599
1614
|
};
|
|
@@ -1601,7 +1616,6 @@ const useConfigurations = (input) => {
|
|
|
1601
1616
|
const useConfigurationForm = (input) => {
|
|
1602
1617
|
var _a;
|
|
1603
1618
|
const fastn = useFastn();
|
|
1604
|
-
const queryClient = reactQuery.useQueryClient();
|
|
1605
1619
|
const configurations = useConfigurations({
|
|
1606
1620
|
configurationId: input.configurationId,
|
|
1607
1621
|
});
|
|
@@ -1615,22 +1629,18 @@ const useConfigurationForm = (input) => {
|
|
|
1615
1629
|
});
|
|
1616
1630
|
react.useEffect(() => {
|
|
1617
1631
|
const invalidate = () => {
|
|
1618
|
-
queryClient.invalidateQueries({
|
|
1619
|
-
queryKey: ["configuration-form", input],
|
|
1620
|
-
});
|
|
1621
|
-
queryClient.invalidateQueries({
|
|
1622
|
-
queryKey: ["configurations"],
|
|
1623
|
-
});
|
|
1624
1632
|
query.refetch();
|
|
1625
1633
|
};
|
|
1626
1634
|
fastn.onEvent("REFRESH_CONFIGURATION_FORM", invalidate);
|
|
1635
|
+
return () => {
|
|
1636
|
+
fastn.offEvent("REFRESH_CONFIGURATION_FORM", invalidate);
|
|
1637
|
+
};
|
|
1627
1638
|
}, [query.data]);
|
|
1628
1639
|
return query;
|
|
1629
1640
|
};
|
|
1630
1641
|
|
|
1631
1642
|
const useConnectors = () => {
|
|
1632
1643
|
const fastn = useFastn();
|
|
1633
|
-
const queryClient = reactQuery.useQueryClient();
|
|
1634
1644
|
const query = reactQuery.useQuery({
|
|
1635
1645
|
queryKey: ["connectors"],
|
|
1636
1646
|
queryFn: () => fastn.getConnectors(),
|
|
@@ -1638,10 +1648,12 @@ const useConnectors = () => {
|
|
|
1638
1648
|
});
|
|
1639
1649
|
react.useEffect(() => {
|
|
1640
1650
|
const invalidate = () => {
|
|
1641
|
-
queryClient.invalidateQueries({ queryKey: ["connectors"] });
|
|
1642
1651
|
query.refetch();
|
|
1643
1652
|
};
|
|
1644
1653
|
fastn.onEvent("REFETCH_CONNECTORS", invalidate);
|
|
1654
|
+
return () => {
|
|
1655
|
+
fastn.offEvent("REFETCH_CONNECTORS", invalidate);
|
|
1656
|
+
};
|
|
1645
1657
|
}, [query.data]);
|
|
1646
1658
|
return query;
|
|
1647
1659
|
};
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -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":"
|
|
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,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","x_google_ignoreList":[0,1,2,3]}
|
package/dist/index.esm.js
CHANGED
|
@@ -1,7 +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,
|
|
4
|
-
import { EventEmitter } from 'events';
|
|
3
|
+
import { QueryClientProvider, QueryClient, useQuery, useQueryClient, useInfiniteQuery } from '@tanstack/react-query';
|
|
5
4
|
export * from '@dev-fastn-ai/core';
|
|
6
5
|
|
|
7
6
|
const REQUEST_TRACE_ID_HEADER_KEY = 'x-fastn-request-trace-id';
|
|
@@ -1016,13 +1015,40 @@ const activateConnectorCore = async ({ dependencyConnector, authMethod, formData
|
|
|
1016
1015
|
}
|
|
1017
1016
|
};
|
|
1018
1017
|
|
|
1019
|
-
|
|
1018
|
+
// eventBus.ts
|
|
1019
|
+
// Internal listener registry
|
|
1020
|
+
const listeners = {
|
|
1021
|
+
'REFETCH_CONNECTORS': new Set(),
|
|
1022
|
+
'REFETCH_CONFIGURATIONS': new Set(),
|
|
1023
|
+
'REFRESH_CONFIGURATION_FORM': new Set(),
|
|
1024
|
+
'INVALIDATE_CONFIGURATION_FORM': new Set(),
|
|
1025
|
+
'INVALIDATE_CONFIGURATIONS': new Set(),
|
|
1026
|
+
'INVALIDATE_CONNECTORS': new Set(),
|
|
1027
|
+
};
|
|
1028
|
+
// Send a cross-context-safe event
|
|
1020
1029
|
const sendEvent = (event) => {
|
|
1021
|
-
|
|
1030
|
+
window.postMessage({ __eventBus: true, event }, '*');
|
|
1022
1031
|
};
|
|
1032
|
+
// Register a callback for a specific event
|
|
1023
1033
|
const onEvent = (event, callback) => {
|
|
1024
|
-
|
|
1034
|
+
var _a;
|
|
1035
|
+
(_a = listeners[event]) === null || _a === void 0 ? void 0 : _a.add(callback);
|
|
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);
|
|
1025
1041
|
};
|
|
1042
|
+
// Internal postMessage listener
|
|
1043
|
+
const handleMessage = (e) => {
|
|
1044
|
+
const data = e.data;
|
|
1045
|
+
if (!data || !data.__eventBus || !data.event)
|
|
1046
|
+
return;
|
|
1047
|
+
const callbacks = listeners[data.event];
|
|
1048
|
+
callbacks === null || callbacks === void 0 ? void 0 : callbacks.forEach((cb) => cb());
|
|
1049
|
+
};
|
|
1050
|
+
// Register listener once
|
|
1051
|
+
window.addEventListener('message', handleMessage);
|
|
1026
1052
|
|
|
1027
1053
|
/**
|
|
1028
1054
|
* Fetches connectors and maps their actions for use in the application.
|
|
@@ -1084,10 +1110,8 @@ async function getConnectors({ disabled = false, status = "ALL", refetch } = {})
|
|
|
1084
1110
|
else {
|
|
1085
1111
|
response = await executeActionHandler(action === null || action === void 0 ? void 0 : action.handler);
|
|
1086
1112
|
}
|
|
1087
|
-
sendEvent("INVALIDATE_CONNECTORS");
|
|
1088
|
-
sendEvent("REFETCH_CONNECTORS");
|
|
1089
|
-
sendEvent("INVALIDATE_CONFIGURATIONS");
|
|
1090
1113
|
sendEvent("REFETCH_CONFIGURATIONS");
|
|
1114
|
+
sendEvent("REFETCH_CONNECTORS");
|
|
1091
1115
|
return response;
|
|
1092
1116
|
}
|
|
1093
1117
|
catch (e) {
|
|
@@ -1142,7 +1166,6 @@ const handleDisableConfiguration = async ({ id, connectorId, }) => {
|
|
|
1142
1166
|
},
|
|
1143
1167
|
});
|
|
1144
1168
|
sendEvent("REFETCH_CONFIGURATIONS");
|
|
1145
|
-
sendEvent("INVALIDATE_CONFIGURATIONS");
|
|
1146
1169
|
}
|
|
1147
1170
|
catch (error) {
|
|
1148
1171
|
throw new Error(formatApolloErrors(error));
|
|
@@ -1163,7 +1186,6 @@ const handleDeleteConfiguration = async ({ id, connectorId, }) => {
|
|
|
1163
1186
|
},
|
|
1164
1187
|
});
|
|
1165
1188
|
sendEvent("REFETCH_CONFIGURATIONS");
|
|
1166
|
-
sendEvent("INVALIDATE_CONFIGURATIONS");
|
|
1167
1189
|
}
|
|
1168
1190
|
catch (error) {
|
|
1169
1191
|
throw new Error(formatApolloErrors(error));
|
|
@@ -1193,8 +1215,6 @@ async function getConfigurations({ configurationId, status = "ALL", }) {
|
|
|
1193
1215
|
actionType: ConnectorActionType.DISABLE,
|
|
1194
1216
|
onClick: async () => {
|
|
1195
1217
|
await handleDisableConfiguration({ connectorId: configSubscription.connector.id, id: configurationId });
|
|
1196
|
-
sendEvent("INVALIDATE_CONFIGURATIONS");
|
|
1197
|
-
sendEvent("REFETCH_CONFIGURATIONS");
|
|
1198
1218
|
return { data: null, status: "SUCCESS" };
|
|
1199
1219
|
},
|
|
1200
1220
|
});
|
|
@@ -1203,8 +1223,6 @@ async function getConfigurations({ configurationId, status = "ALL", }) {
|
|
|
1203
1223
|
actionType: ConnectorActionType.DELETE,
|
|
1204
1224
|
onClick: async () => {
|
|
1205
1225
|
await handleDeleteConfiguration({ connectorId: configSubscription.connector.id, id: configurationId });
|
|
1206
|
-
sendEvent("INVALIDATE_CONFIGURATIONS");
|
|
1207
|
-
sendEvent("REFETCH_CONFIGURATIONS");
|
|
1208
1226
|
return { data: null, status: "SUCCESS" };
|
|
1209
1227
|
},
|
|
1210
1228
|
});
|
|
@@ -1222,9 +1240,7 @@ async function getConfigurations({ configurationId, status = "ALL", }) {
|
|
|
1222
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],
|
|
1223
1241
|
input: formData,
|
|
1224
1242
|
});
|
|
1225
|
-
sendEvent("INVALIDATE_CONFIGURATIONS");
|
|
1226
1243
|
sendEvent("REFETCH_CONFIGURATIONS");
|
|
1227
|
-
sendEvent("INVALIDATE_CONNECTORS");
|
|
1228
1244
|
sendEvent("REFETCH_CONNECTORS");
|
|
1229
1245
|
return { data: result, status: "SUCCESS" };
|
|
1230
1246
|
};
|
|
@@ -1257,13 +1273,6 @@ async function getConfigurations({ configurationId, status = "ALL", }) {
|
|
|
1257
1273
|
}
|
|
1258
1274
|
}
|
|
1259
1275
|
|
|
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
|
-
|
|
1267
1276
|
function loadGapiClient() {
|
|
1268
1277
|
return new Promise((resolve, reject) => {
|
|
1269
1278
|
const script = document.createElement('script');
|
|
@@ -1329,7 +1338,6 @@ async function createGooglePicker(developerKey, accessToken) {
|
|
|
1329
1338
|
});
|
|
1330
1339
|
}
|
|
1331
1340
|
|
|
1332
|
-
const REFETCH_KEY = "configuration-form";
|
|
1333
1341
|
function openGoogleFilesPicker(parentArgs) {
|
|
1334
1342
|
return async (args) => {
|
|
1335
1343
|
var _a, _b;
|
|
@@ -1382,7 +1390,6 @@ function openGoogleFilesPicker(parentArgs) {
|
|
|
1382
1390
|
*/
|
|
1383
1391
|
function getSubmitHandler({ configuration, configurationId, connectorId, }) {
|
|
1384
1392
|
return async ({ formData }) => {
|
|
1385
|
-
var _a;
|
|
1386
1393
|
const config = getConfig();
|
|
1387
1394
|
const uiCode = populateFormDataInUiCode(configuration.uiCode, formData);
|
|
1388
1395
|
try {
|
|
@@ -1399,7 +1406,6 @@ function getSubmitHandler({ configuration, configurationId, connectorId, }) {
|
|
|
1399
1406
|
configurations: formData,
|
|
1400
1407
|
}),
|
|
1401
1408
|
});
|
|
1402
|
-
await ((_a = refetchFunctions[REFETCH_KEY]) === null || _a === void 0 ? void 0 : _a.call(refetchFunctions));
|
|
1403
1409
|
}
|
|
1404
1410
|
else {
|
|
1405
1411
|
await createTenantConfiguration({
|
|
@@ -1416,7 +1422,7 @@ function getSubmitHandler({ configuration, configurationId, connectorId, }) {
|
|
|
1416
1422
|
});
|
|
1417
1423
|
}
|
|
1418
1424
|
sendEvent("REFRESH_CONFIGURATION_FORM");
|
|
1419
|
-
sendEvent("
|
|
1425
|
+
sendEvent("REFETCH_CONFIGURATIONS");
|
|
1420
1426
|
}
|
|
1421
1427
|
catch (error) {
|
|
1422
1428
|
throw new Error(formatApolloErrors(error));
|
|
@@ -1542,6 +1548,11 @@ async function getConfigurationForm(input) {
|
|
|
1542
1548
|
}
|
|
1543
1549
|
}
|
|
1544
1550
|
|
|
1551
|
+
const registerRefetchFunction = (input) => {
|
|
1552
|
+
console.log("registering refetch function", input);
|
|
1553
|
+
const { refetchFunction, refetchKey } = input;
|
|
1554
|
+
};
|
|
1555
|
+
|
|
1545
1556
|
class Fastn {
|
|
1546
1557
|
constructor(config) {
|
|
1547
1558
|
setConfig(config);
|
|
@@ -1561,6 +1572,9 @@ class Fastn {
|
|
|
1561
1572
|
onEvent(event, callback) {
|
|
1562
1573
|
return onEvent(event, callback);
|
|
1563
1574
|
}
|
|
1575
|
+
offEvent(event, callback) {
|
|
1576
|
+
return offEvent(event, callback);
|
|
1577
|
+
}
|
|
1564
1578
|
}
|
|
1565
1579
|
|
|
1566
1580
|
const FastnContext = createContext(null);
|
|
@@ -1580,7 +1594,6 @@ const useFastn = () => {
|
|
|
1580
1594
|
|
|
1581
1595
|
const useConfigurations = (input) => {
|
|
1582
1596
|
const fastn = useFastn();
|
|
1583
|
-
const queryClient = useQueryClient();
|
|
1584
1597
|
const query = useQuery({
|
|
1585
1598
|
queryKey: ["configurations", input],
|
|
1586
1599
|
queryFn: () => fastn.getConfigurations(input),
|
|
@@ -1588,10 +1601,12 @@ const useConfigurations = (input) => {
|
|
|
1588
1601
|
});
|
|
1589
1602
|
useEffect(() => {
|
|
1590
1603
|
const invalidate = () => {
|
|
1591
|
-
queryClient.invalidateQueries({ queryKey: ["configurations"] });
|
|
1592
1604
|
query.refetch();
|
|
1593
1605
|
};
|
|
1594
1606
|
fastn.onEvent("REFETCH_CONFIGURATIONS", invalidate);
|
|
1607
|
+
return () => {
|
|
1608
|
+
fastn.offEvent("REFETCH_CONFIGURATIONS", invalidate);
|
|
1609
|
+
};
|
|
1595
1610
|
}, [query.data]);
|
|
1596
1611
|
return query;
|
|
1597
1612
|
};
|
|
@@ -1599,7 +1614,6 @@ const useConfigurations = (input) => {
|
|
|
1599
1614
|
const useConfigurationForm = (input) => {
|
|
1600
1615
|
var _a;
|
|
1601
1616
|
const fastn = useFastn();
|
|
1602
|
-
const queryClient = useQueryClient();
|
|
1603
1617
|
const configurations = useConfigurations({
|
|
1604
1618
|
configurationId: input.configurationId,
|
|
1605
1619
|
});
|
|
@@ -1613,22 +1627,18 @@ const useConfigurationForm = (input) => {
|
|
|
1613
1627
|
});
|
|
1614
1628
|
useEffect(() => {
|
|
1615
1629
|
const invalidate = () => {
|
|
1616
|
-
queryClient.invalidateQueries({
|
|
1617
|
-
queryKey: ["configuration-form", input],
|
|
1618
|
-
});
|
|
1619
|
-
queryClient.invalidateQueries({
|
|
1620
|
-
queryKey: ["configurations"],
|
|
1621
|
-
});
|
|
1622
1630
|
query.refetch();
|
|
1623
1631
|
};
|
|
1624
1632
|
fastn.onEvent("REFRESH_CONFIGURATION_FORM", invalidate);
|
|
1633
|
+
return () => {
|
|
1634
|
+
fastn.offEvent("REFRESH_CONFIGURATION_FORM", invalidate);
|
|
1635
|
+
};
|
|
1625
1636
|
}, [query.data]);
|
|
1626
1637
|
return query;
|
|
1627
1638
|
};
|
|
1628
1639
|
|
|
1629
1640
|
const useConnectors = () => {
|
|
1630
1641
|
const fastn = useFastn();
|
|
1631
|
-
const queryClient = useQueryClient();
|
|
1632
1642
|
const query = useQuery({
|
|
1633
1643
|
queryKey: ["connectors"],
|
|
1634
1644
|
queryFn: () => fastn.getConnectors(),
|
|
@@ -1636,10 +1646,12 @@ const useConnectors = () => {
|
|
|
1636
1646
|
});
|
|
1637
1647
|
useEffect(() => {
|
|
1638
1648
|
const invalidate = () => {
|
|
1639
|
-
queryClient.invalidateQueries({ queryKey: ["connectors"] });
|
|
1640
1649
|
query.refetch();
|
|
1641
1650
|
};
|
|
1642
1651
|
fastn.onEvent("REFETCH_CONNECTORS", invalidate);
|
|
1652
|
+
return () => {
|
|
1653
|
+
fastn.offEvent("REFETCH_CONNECTORS", invalidate);
|
|
1654
|
+
};
|
|
1643
1655
|
}, [query.data]);
|
|
1644
1656
|
return query;
|
|
1645
1657
|
};
|
package/dist/index.esm.js.map
CHANGED
|
@@ -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];\n }\n\n return buf;\n }\n\n return unsafeStringify(rnds);\n}\n\nexport default v4;"],"names":[],"mappings":"
|
|
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,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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.
|
|
3
|
+
"version": "1.0.14",
|
|
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.
|
|
62
|
+
"@dev-fastn-ai/core": "^1.0.10"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
65
|
"@tanstack/react-query": "^5.0.0",
|