@dev-fastn-ai/react-core 1.0.13 → 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/index.cjs.js +24 -33
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +25 -34
- 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';
|
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));
|
|
@@ -1186,7 +1188,6 @@ const handleDeleteConfiguration = async ({ id, connectorId, }) => {
|
|
|
1186
1188
|
},
|
|
1187
1189
|
});
|
|
1188
1190
|
sendEvent("REFETCH_CONFIGURATIONS");
|
|
1189
|
-
sendEvent("INVALIDATE_CONFIGURATIONS");
|
|
1190
1191
|
}
|
|
1191
1192
|
catch (error) {
|
|
1192
1193
|
throw new Error(formatApolloErrors(error));
|
|
@@ -1216,8 +1217,6 @@ async function getConfigurations({ configurationId, status = "ALL", }) {
|
|
|
1216
1217
|
actionType: ConnectorActionType.DISABLE,
|
|
1217
1218
|
onClick: async () => {
|
|
1218
1219
|
await handleDisableConfiguration({ connectorId: configSubscription.connector.id, id: configurationId });
|
|
1219
|
-
sendEvent("INVALIDATE_CONFIGURATIONS");
|
|
1220
|
-
sendEvent("REFETCH_CONFIGURATIONS");
|
|
1221
1220
|
return { data: null, status: "SUCCESS" };
|
|
1222
1221
|
},
|
|
1223
1222
|
});
|
|
@@ -1226,8 +1225,6 @@ async function getConfigurations({ configurationId, status = "ALL", }) {
|
|
|
1226
1225
|
actionType: ConnectorActionType.DELETE,
|
|
1227
1226
|
onClick: async () => {
|
|
1228
1227
|
await handleDeleteConfiguration({ connectorId: configSubscription.connector.id, id: configurationId });
|
|
1229
|
-
sendEvent("INVALIDATE_CONFIGURATIONS");
|
|
1230
|
-
sendEvent("REFETCH_CONFIGURATIONS");
|
|
1231
1228
|
return { data: null, status: "SUCCESS" };
|
|
1232
1229
|
},
|
|
1233
1230
|
});
|
|
@@ -1245,9 +1242,7 @@ async function getConfigurations({ configurationId, status = "ALL", }) {
|
|
|
1245
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],
|
|
1246
1243
|
input: formData,
|
|
1247
1244
|
});
|
|
1248
|
-
sendEvent("INVALIDATE_CONFIGURATIONS");
|
|
1249
1245
|
sendEvent("REFETCH_CONFIGURATIONS");
|
|
1250
|
-
sendEvent("INVALIDATE_CONNECTORS");
|
|
1251
1246
|
sendEvent("REFETCH_CONNECTORS");
|
|
1252
1247
|
return { data: result, status: "SUCCESS" };
|
|
1253
1248
|
};
|
|
@@ -1280,13 +1275,6 @@ async function getConfigurations({ configurationId, status = "ALL", }) {
|
|
|
1280
1275
|
}
|
|
1281
1276
|
}
|
|
1282
1277
|
|
|
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
1278
|
function loadGapiClient() {
|
|
1291
1279
|
return new Promise((resolve, reject) => {
|
|
1292
1280
|
const script = document.createElement('script');
|
|
@@ -1352,7 +1340,6 @@ async function createGooglePicker(developerKey, accessToken) {
|
|
|
1352
1340
|
});
|
|
1353
1341
|
}
|
|
1354
1342
|
|
|
1355
|
-
const REFETCH_KEY = "configuration-form";
|
|
1356
1343
|
function openGoogleFilesPicker(parentArgs) {
|
|
1357
1344
|
return async (args) => {
|
|
1358
1345
|
var _a, _b;
|
|
@@ -1405,7 +1392,6 @@ function openGoogleFilesPicker(parentArgs) {
|
|
|
1405
1392
|
*/
|
|
1406
1393
|
function getSubmitHandler({ configuration, configurationId, connectorId, }) {
|
|
1407
1394
|
return async ({ formData }) => {
|
|
1408
|
-
var _a;
|
|
1409
1395
|
const config = getConfig();
|
|
1410
1396
|
const uiCode = populateFormDataInUiCode(configuration.uiCode, formData);
|
|
1411
1397
|
try {
|
|
@@ -1422,7 +1408,6 @@ function getSubmitHandler({ configuration, configurationId, connectorId, }) {
|
|
|
1422
1408
|
configurations: formData,
|
|
1423
1409
|
}),
|
|
1424
1410
|
});
|
|
1425
|
-
await ((_a = refetchFunctions[REFETCH_KEY]) === null || _a === void 0 ? void 0 : _a.call(refetchFunctions));
|
|
1426
1411
|
}
|
|
1427
1412
|
else {
|
|
1428
1413
|
await createTenantConfiguration({
|
|
@@ -1439,7 +1424,7 @@ function getSubmitHandler({ configuration, configurationId, connectorId, }) {
|
|
|
1439
1424
|
});
|
|
1440
1425
|
}
|
|
1441
1426
|
sendEvent("REFRESH_CONFIGURATION_FORM");
|
|
1442
|
-
sendEvent("
|
|
1427
|
+
sendEvent("REFETCH_CONFIGURATIONS");
|
|
1443
1428
|
}
|
|
1444
1429
|
catch (error) {
|
|
1445
1430
|
throw new Error(formatApolloErrors(error));
|
|
@@ -1565,6 +1550,11 @@ async function getConfigurationForm(input) {
|
|
|
1565
1550
|
}
|
|
1566
1551
|
}
|
|
1567
1552
|
|
|
1553
|
+
const registerRefetchFunction = (input) => {
|
|
1554
|
+
console.log("registering refetch function", input);
|
|
1555
|
+
const { refetchFunction, refetchKey } = input;
|
|
1556
|
+
};
|
|
1557
|
+
|
|
1568
1558
|
class Fastn {
|
|
1569
1559
|
constructor(config) {
|
|
1570
1560
|
setConfig(config);
|
|
@@ -1584,6 +1574,9 @@ class Fastn {
|
|
|
1584
1574
|
onEvent(event, callback) {
|
|
1585
1575
|
return onEvent(event, callback);
|
|
1586
1576
|
}
|
|
1577
|
+
offEvent(event, callback) {
|
|
1578
|
+
return offEvent(event, callback);
|
|
1579
|
+
}
|
|
1587
1580
|
}
|
|
1588
1581
|
|
|
1589
1582
|
const FastnContext = react.createContext(null);
|
|
@@ -1603,7 +1596,6 @@ const useFastn = () => {
|
|
|
1603
1596
|
|
|
1604
1597
|
const useConfigurations = (input) => {
|
|
1605
1598
|
const fastn = useFastn();
|
|
1606
|
-
const queryClient = reactQuery.useQueryClient();
|
|
1607
1599
|
const query = reactQuery.useQuery({
|
|
1608
1600
|
queryKey: ["configurations", input],
|
|
1609
1601
|
queryFn: () => fastn.getConfigurations(input),
|
|
@@ -1611,10 +1603,12 @@ const useConfigurations = (input) => {
|
|
|
1611
1603
|
});
|
|
1612
1604
|
react.useEffect(() => {
|
|
1613
1605
|
const invalidate = () => {
|
|
1614
|
-
queryClient.invalidateQueries({ queryKey: ["configurations"] });
|
|
1615
1606
|
query.refetch();
|
|
1616
1607
|
};
|
|
1617
1608
|
fastn.onEvent("REFETCH_CONFIGURATIONS", invalidate);
|
|
1609
|
+
return () => {
|
|
1610
|
+
fastn.offEvent("REFETCH_CONFIGURATIONS", invalidate);
|
|
1611
|
+
};
|
|
1618
1612
|
}, [query.data]);
|
|
1619
1613
|
return query;
|
|
1620
1614
|
};
|
|
@@ -1622,7 +1616,6 @@ const useConfigurations = (input) => {
|
|
|
1622
1616
|
const useConfigurationForm = (input) => {
|
|
1623
1617
|
var _a;
|
|
1624
1618
|
const fastn = useFastn();
|
|
1625
|
-
const queryClient = reactQuery.useQueryClient();
|
|
1626
1619
|
const configurations = useConfigurations({
|
|
1627
1620
|
configurationId: input.configurationId,
|
|
1628
1621
|
});
|
|
@@ -1636,22 +1629,18 @@ const useConfigurationForm = (input) => {
|
|
|
1636
1629
|
});
|
|
1637
1630
|
react.useEffect(() => {
|
|
1638
1631
|
const invalidate = () => {
|
|
1639
|
-
queryClient.invalidateQueries({
|
|
1640
|
-
queryKey: ["configuration-form", input],
|
|
1641
|
-
});
|
|
1642
|
-
queryClient.invalidateQueries({
|
|
1643
|
-
queryKey: ["configurations"],
|
|
1644
|
-
});
|
|
1645
1632
|
query.refetch();
|
|
1646
1633
|
};
|
|
1647
1634
|
fastn.onEvent("REFRESH_CONFIGURATION_FORM", invalidate);
|
|
1635
|
+
return () => {
|
|
1636
|
+
fastn.offEvent("REFRESH_CONFIGURATION_FORM", invalidate);
|
|
1637
|
+
};
|
|
1648
1638
|
}, [query.data]);
|
|
1649
1639
|
return query;
|
|
1650
1640
|
};
|
|
1651
1641
|
|
|
1652
1642
|
const useConnectors = () => {
|
|
1653
1643
|
const fastn = useFastn();
|
|
1654
|
-
const queryClient = reactQuery.useQueryClient();
|
|
1655
1644
|
const query = reactQuery.useQuery({
|
|
1656
1645
|
queryKey: ["connectors"],
|
|
1657
1646
|
queryFn: () => fastn.getConnectors(),
|
|
@@ -1659,10 +1648,12 @@ const useConnectors = () => {
|
|
|
1659
1648
|
});
|
|
1660
1649
|
react.useEffect(() => {
|
|
1661
1650
|
const invalidate = () => {
|
|
1662
|
-
queryClient.invalidateQueries({ queryKey: ["connectors"] });
|
|
1663
1651
|
query.refetch();
|
|
1664
1652
|
};
|
|
1665
1653
|
fastn.onEvent("REFETCH_CONNECTORS", invalidate);
|
|
1654
|
+
return () => {
|
|
1655
|
+
fastn.offEvent("REFETCH_CONNECTORS", invalidate);
|
|
1656
|
+
};
|
|
1666
1657
|
}, [query.data]);
|
|
1667
1658
|
return query;
|
|
1668
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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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C,IAAI,CAAC,MAAM,CAAC;AACvG,aAAe;AACf,EAAE;AACF,CAAC;;ACCD,SAAS,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE;AAClC,EAAE,IAAI,MAAM,CAAC,UAAU,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE;AAC7C,IAAI,OAAO,MAAM,CAAC,UAAU,EAAE;AAC9B,EAAE;;AAEF,EAAE,OAAO,GAAG,OAAO,IAAI,EAAE;AACzB,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,GAAG,GAAG,CAAC;;AAExD,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,IAAI;AACjC,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;;AAYlC,EAAE,OAAO,eAAe,CAAC,IAAI,CAAC;AAC9B
|
|
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;\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Memo, useContext, useEffect, useState, useCallback } from 'react';
|
|
3
|
-
import { QueryClientProvider, QueryClient,
|
|
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));
|
|
@@ -1184,7 +1186,6 @@ const handleDeleteConfiguration = async ({ id, connectorId, }) => {
|
|
|
1184
1186
|
},
|
|
1185
1187
|
});
|
|
1186
1188
|
sendEvent("REFETCH_CONFIGURATIONS");
|
|
1187
|
-
sendEvent("INVALIDATE_CONFIGURATIONS");
|
|
1188
1189
|
}
|
|
1189
1190
|
catch (error) {
|
|
1190
1191
|
throw new Error(formatApolloErrors(error));
|
|
@@ -1214,8 +1215,6 @@ async function getConfigurations({ configurationId, status = "ALL", }) {
|
|
|
1214
1215
|
actionType: ConnectorActionType.DISABLE,
|
|
1215
1216
|
onClick: async () => {
|
|
1216
1217
|
await handleDisableConfiguration({ connectorId: configSubscription.connector.id, id: configurationId });
|
|
1217
|
-
sendEvent("INVALIDATE_CONFIGURATIONS");
|
|
1218
|
-
sendEvent("REFETCH_CONFIGURATIONS");
|
|
1219
1218
|
return { data: null, status: "SUCCESS" };
|
|
1220
1219
|
},
|
|
1221
1220
|
});
|
|
@@ -1224,8 +1223,6 @@ async function getConfigurations({ configurationId, status = "ALL", }) {
|
|
|
1224
1223
|
actionType: ConnectorActionType.DELETE,
|
|
1225
1224
|
onClick: async () => {
|
|
1226
1225
|
await handleDeleteConfiguration({ connectorId: configSubscription.connector.id, id: configurationId });
|
|
1227
|
-
sendEvent("INVALIDATE_CONFIGURATIONS");
|
|
1228
|
-
sendEvent("REFETCH_CONFIGURATIONS");
|
|
1229
1226
|
return { data: null, status: "SUCCESS" };
|
|
1230
1227
|
},
|
|
1231
1228
|
});
|
|
@@ -1243,9 +1240,7 @@ async function getConfigurations({ configurationId, status = "ALL", }) {
|
|
|
1243
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],
|
|
1244
1241
|
input: formData,
|
|
1245
1242
|
});
|
|
1246
|
-
sendEvent("INVALIDATE_CONFIGURATIONS");
|
|
1247
1243
|
sendEvent("REFETCH_CONFIGURATIONS");
|
|
1248
|
-
sendEvent("INVALIDATE_CONNECTORS");
|
|
1249
1244
|
sendEvent("REFETCH_CONNECTORS");
|
|
1250
1245
|
return { data: result, status: "SUCCESS" };
|
|
1251
1246
|
};
|
|
@@ -1278,13 +1273,6 @@ async function getConfigurations({ configurationId, status = "ALL", }) {
|
|
|
1278
1273
|
}
|
|
1279
1274
|
}
|
|
1280
1275
|
|
|
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
1276
|
function loadGapiClient() {
|
|
1289
1277
|
return new Promise((resolve, reject) => {
|
|
1290
1278
|
const script = document.createElement('script');
|
|
@@ -1350,7 +1338,6 @@ async function createGooglePicker(developerKey, accessToken) {
|
|
|
1350
1338
|
});
|
|
1351
1339
|
}
|
|
1352
1340
|
|
|
1353
|
-
const REFETCH_KEY = "configuration-form";
|
|
1354
1341
|
function openGoogleFilesPicker(parentArgs) {
|
|
1355
1342
|
return async (args) => {
|
|
1356
1343
|
var _a, _b;
|
|
@@ -1403,7 +1390,6 @@ function openGoogleFilesPicker(parentArgs) {
|
|
|
1403
1390
|
*/
|
|
1404
1391
|
function getSubmitHandler({ configuration, configurationId, connectorId, }) {
|
|
1405
1392
|
return async ({ formData }) => {
|
|
1406
|
-
var _a;
|
|
1407
1393
|
const config = getConfig();
|
|
1408
1394
|
const uiCode = populateFormDataInUiCode(configuration.uiCode, formData);
|
|
1409
1395
|
try {
|
|
@@ -1420,7 +1406,6 @@ function getSubmitHandler({ configuration, configurationId, connectorId, }) {
|
|
|
1420
1406
|
configurations: formData,
|
|
1421
1407
|
}),
|
|
1422
1408
|
});
|
|
1423
|
-
await ((_a = refetchFunctions[REFETCH_KEY]) === null || _a === void 0 ? void 0 : _a.call(refetchFunctions));
|
|
1424
1409
|
}
|
|
1425
1410
|
else {
|
|
1426
1411
|
await createTenantConfiguration({
|
|
@@ -1437,7 +1422,7 @@ function getSubmitHandler({ configuration, configurationId, connectorId, }) {
|
|
|
1437
1422
|
});
|
|
1438
1423
|
}
|
|
1439
1424
|
sendEvent("REFRESH_CONFIGURATION_FORM");
|
|
1440
|
-
sendEvent("
|
|
1425
|
+
sendEvent("REFETCH_CONFIGURATIONS");
|
|
1441
1426
|
}
|
|
1442
1427
|
catch (error) {
|
|
1443
1428
|
throw new Error(formatApolloErrors(error));
|
|
@@ -1563,6 +1548,11 @@ async function getConfigurationForm(input) {
|
|
|
1563
1548
|
}
|
|
1564
1549
|
}
|
|
1565
1550
|
|
|
1551
|
+
const registerRefetchFunction = (input) => {
|
|
1552
|
+
console.log("registering refetch function", input);
|
|
1553
|
+
const { refetchFunction, refetchKey } = input;
|
|
1554
|
+
};
|
|
1555
|
+
|
|
1566
1556
|
class Fastn {
|
|
1567
1557
|
constructor(config) {
|
|
1568
1558
|
setConfig(config);
|
|
@@ -1582,6 +1572,9 @@ class Fastn {
|
|
|
1582
1572
|
onEvent(event, callback) {
|
|
1583
1573
|
return onEvent(event, callback);
|
|
1584
1574
|
}
|
|
1575
|
+
offEvent(event, callback) {
|
|
1576
|
+
return offEvent(event, callback);
|
|
1577
|
+
}
|
|
1585
1578
|
}
|
|
1586
1579
|
|
|
1587
1580
|
const FastnContext = createContext(null);
|
|
@@ -1601,7 +1594,6 @@ const useFastn = () => {
|
|
|
1601
1594
|
|
|
1602
1595
|
const useConfigurations = (input) => {
|
|
1603
1596
|
const fastn = useFastn();
|
|
1604
|
-
const queryClient = useQueryClient();
|
|
1605
1597
|
const query = useQuery({
|
|
1606
1598
|
queryKey: ["configurations", input],
|
|
1607
1599
|
queryFn: () => fastn.getConfigurations(input),
|
|
@@ -1609,10 +1601,12 @@ const useConfigurations = (input) => {
|
|
|
1609
1601
|
});
|
|
1610
1602
|
useEffect(() => {
|
|
1611
1603
|
const invalidate = () => {
|
|
1612
|
-
queryClient.invalidateQueries({ queryKey: ["configurations"] });
|
|
1613
1604
|
query.refetch();
|
|
1614
1605
|
};
|
|
1615
1606
|
fastn.onEvent("REFETCH_CONFIGURATIONS", invalidate);
|
|
1607
|
+
return () => {
|
|
1608
|
+
fastn.offEvent("REFETCH_CONFIGURATIONS", invalidate);
|
|
1609
|
+
};
|
|
1616
1610
|
}, [query.data]);
|
|
1617
1611
|
return query;
|
|
1618
1612
|
};
|
|
@@ -1620,7 +1614,6 @@ const useConfigurations = (input) => {
|
|
|
1620
1614
|
const useConfigurationForm = (input) => {
|
|
1621
1615
|
var _a;
|
|
1622
1616
|
const fastn = useFastn();
|
|
1623
|
-
const queryClient = useQueryClient();
|
|
1624
1617
|
const configurations = useConfigurations({
|
|
1625
1618
|
configurationId: input.configurationId,
|
|
1626
1619
|
});
|
|
@@ -1634,22 +1627,18 @@ const useConfigurationForm = (input) => {
|
|
|
1634
1627
|
});
|
|
1635
1628
|
useEffect(() => {
|
|
1636
1629
|
const invalidate = () => {
|
|
1637
|
-
queryClient.invalidateQueries({
|
|
1638
|
-
queryKey: ["configuration-form", input],
|
|
1639
|
-
});
|
|
1640
|
-
queryClient.invalidateQueries({
|
|
1641
|
-
queryKey: ["configurations"],
|
|
1642
|
-
});
|
|
1643
1630
|
query.refetch();
|
|
1644
1631
|
};
|
|
1645
1632
|
fastn.onEvent("REFRESH_CONFIGURATION_FORM", invalidate);
|
|
1633
|
+
return () => {
|
|
1634
|
+
fastn.offEvent("REFRESH_CONFIGURATION_FORM", invalidate);
|
|
1635
|
+
};
|
|
1646
1636
|
}, [query.data]);
|
|
1647
1637
|
return query;
|
|
1648
1638
|
};
|
|
1649
1639
|
|
|
1650
1640
|
const useConnectors = () => {
|
|
1651
1641
|
const fastn = useFastn();
|
|
1652
|
-
const queryClient = useQueryClient();
|
|
1653
1642
|
const query = useQuery({
|
|
1654
1643
|
queryKey: ["connectors"],
|
|
1655
1644
|
queryFn: () => fastn.getConnectors(),
|
|
@@ -1657,10 +1646,12 @@ const useConnectors = () => {
|
|
|
1657
1646
|
});
|
|
1658
1647
|
useEffect(() => {
|
|
1659
1648
|
const invalidate = () => {
|
|
1660
|
-
queryClient.invalidateQueries({ queryKey: ["connectors"] });
|
|
1661
1649
|
query.refetch();
|
|
1662
1650
|
};
|
|
1663
1651
|
fastn.onEvent("REFETCH_CONNECTORS", invalidate);
|
|
1652
|
+
return () => {
|
|
1653
|
+
fastn.offEvent("REFETCH_CONNECTORS", invalidate);
|
|
1654
|
+
};
|
|
1664
1655
|
}, [query.data]);
|
|
1665
1656
|
return query;
|
|
1666
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\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,CAAC,CAAC,GAAG,IAAI,GAAG,IAAI;AACjC,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;;AAYlC,EAAE,OAAO,eAAe,CAAC,IAAI,CAAC;AAC9B
|
|
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,IA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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",
|