@dev-fastn-ai/react-core 1.0.11 → 1.0.13
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 +2 -1
- package/dist/core/src/types/index.d.ts +1 -0
- package/dist/core/src/utils/event-bus.d.ts +6 -0
- package/dist/index.cjs.js +125 -35
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +127 -37
- package/dist/index.esm.js.map +1 -1
- package/package.json +2 -2
package/dist/core/src/index.d.ts
CHANGED
|
@@ -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 { Event } from "../types";
|
|
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
|
@@ -1017,14 +1017,36 @@ const activateConnectorCore = async ({ dependencyConnector, authMethod, formData
|
|
|
1017
1017
|
}
|
|
1018
1018
|
};
|
|
1019
1019
|
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
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
|
|
1031
|
+
const sendEvent = (event) => {
|
|
1032
|
+
window.postMessage({ __eventBus: true, event }, '*');
|
|
1025
1033
|
};
|
|
1034
|
+
// Register a callback for a specific event
|
|
1035
|
+
const onEvent = (event, callback) => {
|
|
1036
|
+
var _a;
|
|
1037
|
+
(_a = listeners[event]) === null || _a === void 0 ? void 0 : _a.add(callback);
|
|
1038
|
+
};
|
|
1039
|
+
// Internal postMessage listener
|
|
1040
|
+
const handleMessage = (e) => {
|
|
1041
|
+
const data = e.data;
|
|
1042
|
+
if (!data || !data.__eventBus || !data.event)
|
|
1043
|
+
return;
|
|
1044
|
+
const callbacks = listeners[data.event];
|
|
1045
|
+
callbacks === null || callbacks === void 0 ? void 0 : callbacks.forEach((cb) => cb());
|
|
1046
|
+
};
|
|
1047
|
+
// Register listener once
|
|
1048
|
+
window.addEventListener('message', handleMessage);
|
|
1026
1049
|
|
|
1027
|
-
const REFETCH_KEY$2 = "connectors";
|
|
1028
1050
|
/**
|
|
1029
1051
|
* Fetches connectors and maps their actions for use in the application.
|
|
1030
1052
|
* Updates the global state store.
|
|
@@ -1063,7 +1085,7 @@ async function getConnectors({ disabled = false, status = "ALL", refetch } = {})
|
|
|
1063
1085
|
.map((action) => {
|
|
1064
1086
|
var _a, _b, _c, _d;
|
|
1065
1087
|
const handler = async (formData = {}) => {
|
|
1066
|
-
var _a, _b, _c, _d
|
|
1088
|
+
var _a, _b, _c, _d;
|
|
1067
1089
|
try {
|
|
1068
1090
|
let response = null;
|
|
1069
1091
|
if ((action === null || action === void 0 ? void 0 : action.actionType) === "ACTIVATION") {
|
|
@@ -1085,7 +1107,10 @@ async function getConnectors({ disabled = false, status = "ALL", refetch } = {})
|
|
|
1085
1107
|
else {
|
|
1086
1108
|
response = await executeActionHandler(action === null || action === void 0 ? void 0 : action.handler);
|
|
1087
1109
|
}
|
|
1088
|
-
|
|
1110
|
+
sendEvent("INVALIDATE_CONNECTORS");
|
|
1111
|
+
sendEvent("REFETCH_CONNECTORS");
|
|
1112
|
+
sendEvent("INVALIDATE_CONFIGURATIONS");
|
|
1113
|
+
sendEvent("REFETCH_CONFIGURATIONS");
|
|
1089
1114
|
return response;
|
|
1090
1115
|
}
|
|
1091
1116
|
catch (e) {
|
|
@@ -1127,9 +1152,7 @@ async function getConnectors({ disabled = false, status = "ALL", refetch } = {})
|
|
|
1127
1152
|
}
|
|
1128
1153
|
}
|
|
1129
1154
|
|
|
1130
|
-
const REFETCH_KEY$1 = "configurations";
|
|
1131
1155
|
const handleDisableConfiguration = async ({ id, connectorId, }) => {
|
|
1132
|
-
var _a;
|
|
1133
1156
|
try {
|
|
1134
1157
|
const config = getConfig();
|
|
1135
1158
|
await disableTenantConfig({
|
|
@@ -1141,14 +1164,14 @@ const handleDisableConfiguration = async ({ id, connectorId, }) => {
|
|
|
1141
1164
|
widgetConnectorId: connectorId,
|
|
1142
1165
|
},
|
|
1143
1166
|
});
|
|
1144
|
-
|
|
1167
|
+
sendEvent("REFETCH_CONFIGURATIONS");
|
|
1168
|
+
sendEvent("INVALIDATE_CONFIGURATIONS");
|
|
1145
1169
|
}
|
|
1146
1170
|
catch (error) {
|
|
1147
1171
|
throw new Error(formatApolloErrors(error));
|
|
1148
1172
|
}
|
|
1149
1173
|
};
|
|
1150
1174
|
const handleDeleteConfiguration = async ({ id, connectorId, }) => {
|
|
1151
|
-
var _a;
|
|
1152
1175
|
try {
|
|
1153
1176
|
const config = getConfig();
|
|
1154
1177
|
await deleteTenantConfiguration({
|
|
@@ -1162,7 +1185,8 @@ const handleDeleteConfiguration = async ({ id, connectorId, }) => {
|
|
|
1162
1185
|
},
|
|
1163
1186
|
},
|
|
1164
1187
|
});
|
|
1165
|
-
|
|
1188
|
+
sendEvent("REFETCH_CONFIGURATIONS");
|
|
1189
|
+
sendEvent("INVALIDATE_CONFIGURATIONS");
|
|
1166
1190
|
}
|
|
1167
1191
|
catch (error) {
|
|
1168
1192
|
throw new Error(formatApolloErrors(error));
|
|
@@ -1191,9 +1215,9 @@ async function getConfigurations({ configurationId, status = "ALL", }) {
|
|
|
1191
1215
|
name: "Disable",
|
|
1192
1216
|
actionType: ConnectorActionType.DISABLE,
|
|
1193
1217
|
onClick: async () => {
|
|
1194
|
-
var _a;
|
|
1195
1218
|
await handleDisableConfiguration({ connectorId: configSubscription.connector.id, id: configurationId });
|
|
1196
|
-
|
|
1219
|
+
sendEvent("INVALIDATE_CONFIGURATIONS");
|
|
1220
|
+
sendEvent("REFETCH_CONFIGURATIONS");
|
|
1197
1221
|
return { data: null, status: "SUCCESS" };
|
|
1198
1222
|
},
|
|
1199
1223
|
});
|
|
@@ -1201,9 +1225,9 @@ async function getConfigurations({ configurationId, status = "ALL", }) {
|
|
|
1201
1225
|
name: "Delete",
|
|
1202
1226
|
actionType: ConnectorActionType.DELETE,
|
|
1203
1227
|
onClick: async () => {
|
|
1204
|
-
var _a;
|
|
1205
1228
|
await handleDeleteConfiguration({ connectorId: configSubscription.connector.id, id: configurationId });
|
|
1206
|
-
|
|
1229
|
+
sendEvent("INVALIDATE_CONFIGURATIONS");
|
|
1230
|
+
sendEvent("REFETCH_CONFIGURATIONS");
|
|
1207
1231
|
return { data: null, status: "SUCCESS" };
|
|
1208
1232
|
},
|
|
1209
1233
|
});
|
|
@@ -1221,6 +1245,10 @@ async function getConfigurations({ configurationId, status = "ALL", }) {
|
|
|
1221
1245
|
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
1246
|
input: formData,
|
|
1223
1247
|
});
|
|
1248
|
+
sendEvent("INVALIDATE_CONFIGURATIONS");
|
|
1249
|
+
sendEvent("REFETCH_CONFIGURATIONS");
|
|
1250
|
+
sendEvent("INVALIDATE_CONNECTORS");
|
|
1251
|
+
sendEvent("REFETCH_CONNECTORS");
|
|
1224
1252
|
return { data: result, status: "SUCCESS" };
|
|
1225
1253
|
};
|
|
1226
1254
|
actions.push({
|
|
@@ -1252,6 +1280,13 @@ async function getConfigurations({ configurationId, status = "ALL", }) {
|
|
|
1252
1280
|
}
|
|
1253
1281
|
}
|
|
1254
1282
|
|
|
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
|
+
|
|
1255
1290
|
function loadGapiClient() {
|
|
1256
1291
|
return new Promise((resolve, reject) => {
|
|
1257
1292
|
const script = document.createElement('script');
|
|
@@ -1320,21 +1355,38 @@ async function createGooglePicker(developerKey, accessToken) {
|
|
|
1320
1355
|
const REFETCH_KEY = "configuration-form";
|
|
1321
1356
|
function openGoogleFilesPicker(parentArgs) {
|
|
1322
1357
|
return async (args) => {
|
|
1323
|
-
var _a, _b
|
|
1358
|
+
var _a, _b;
|
|
1324
1359
|
try {
|
|
1325
1360
|
const config = getConfig();
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
if (!accessToken)
|
|
1336
|
-
|
|
1337
|
-
|
|
1361
|
+
let accessToken = null;
|
|
1362
|
+
let apiKey = null;
|
|
1363
|
+
const cachedToken = localStorage.getItem(config.spaceId + parentArgs.connectorId + config.tenantId + "access_token");
|
|
1364
|
+
if (cachedToken) {
|
|
1365
|
+
const token = safeParse(cachedToken);
|
|
1366
|
+
if ((token === null || token === void 0 ? void 0 : token.expires_at) && token.expires_at > Date.now()) {
|
|
1367
|
+
accessToken = token.access_token;
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
if (!accessToken) {
|
|
1371
|
+
const { data } = await generateAccessToken({
|
|
1372
|
+
input: {
|
|
1373
|
+
orgId: config.spaceId,
|
|
1374
|
+
tenantId: config.tenantId,
|
|
1375
|
+
connectorId: parentArgs.connectorId,
|
|
1376
|
+
refresh: true,
|
|
1377
|
+
},
|
|
1378
|
+
});
|
|
1379
|
+
const token = data === null || data === void 0 ? void 0 : data.connectorConnection;
|
|
1380
|
+
// cache token in local storage
|
|
1381
|
+
localStorage.setItem(config.spaceId + parentArgs.connectorId + config.tenantId + "access_token", safeStringify({
|
|
1382
|
+
access_token: token.access_token,
|
|
1383
|
+
api_key: (_a = token.metadata) === null || _a === void 0 ? void 0 : _a.google_picker_api_key,
|
|
1384
|
+
expires_at: token.expires_at || Date.now() + token.expires_in * 1000,
|
|
1385
|
+
}));
|
|
1386
|
+
accessToken = token.access_token;
|
|
1387
|
+
apiKey = (_b = token.metadata) === null || _b === void 0 ? void 0 : _b.google_picker_api_key;
|
|
1388
|
+
}
|
|
1389
|
+
const docs = await createGooglePicker(args.apiKey || apiKey, accessToken);
|
|
1338
1390
|
const files = (docs || []).map((doc) => ({
|
|
1339
1391
|
label: doc === null || doc === void 0 ? void 0 : doc.name,
|
|
1340
1392
|
value: doc === null || doc === void 0 ? void 0 : doc.id,
|
|
@@ -1353,7 +1405,7 @@ function openGoogleFilesPicker(parentArgs) {
|
|
|
1353
1405
|
*/
|
|
1354
1406
|
function getSubmitHandler({ configuration, configurationId, connectorId, }) {
|
|
1355
1407
|
return async ({ formData }) => {
|
|
1356
|
-
var _a
|
|
1408
|
+
var _a;
|
|
1357
1409
|
const config = getConfig();
|
|
1358
1410
|
const uiCode = populateFormDataInUiCode(configuration.uiCode, formData);
|
|
1359
1411
|
try {
|
|
@@ -1385,8 +1437,9 @@ function getSubmitHandler({ configuration, configurationId, connectorId, }) {
|
|
|
1385
1437
|
configurations: formData,
|
|
1386
1438
|
}),
|
|
1387
1439
|
});
|
|
1388
|
-
await ((_b = refetchFunctions[REFETCH_KEY]) === null || _b === void 0 ? void 0 : _b.call(refetchFunctions));
|
|
1389
1440
|
}
|
|
1441
|
+
sendEvent("REFRESH_CONFIGURATION_FORM");
|
|
1442
|
+
sendEvent("REFETCH_CONNECTORS");
|
|
1390
1443
|
}
|
|
1391
1444
|
catch (error) {
|
|
1392
1445
|
throw new Error(formatApolloErrors(error));
|
|
@@ -1528,6 +1581,9 @@ class Fastn {
|
|
|
1528
1581
|
registerRefetchFunction(input) {
|
|
1529
1582
|
return registerRefetchFunction(input);
|
|
1530
1583
|
}
|
|
1584
|
+
onEvent(event, callback) {
|
|
1585
|
+
return onEvent(event, callback);
|
|
1586
|
+
}
|
|
1531
1587
|
}
|
|
1532
1588
|
|
|
1533
1589
|
const FastnContext = react.createContext(null);
|
|
@@ -1547,33 +1603,67 @@ const useFastn = () => {
|
|
|
1547
1603
|
|
|
1548
1604
|
const useConfigurations = (input) => {
|
|
1549
1605
|
const fastn = useFastn();
|
|
1606
|
+
const queryClient = reactQuery.useQueryClient();
|
|
1550
1607
|
const query = reactQuery.useQuery({
|
|
1551
1608
|
queryKey: ["configurations", input],
|
|
1552
1609
|
queryFn: () => fastn.getConfigurations(input),
|
|
1553
1610
|
staleTime: 1000 * 60 * 5, // 5 minutes
|
|
1554
1611
|
});
|
|
1612
|
+
react.useEffect(() => {
|
|
1613
|
+
const invalidate = () => {
|
|
1614
|
+
queryClient.invalidateQueries({ queryKey: ["configurations"] });
|
|
1615
|
+
query.refetch();
|
|
1616
|
+
};
|
|
1617
|
+
fastn.onEvent("REFETCH_CONFIGURATIONS", invalidate);
|
|
1618
|
+
}, [query.data]);
|
|
1555
1619
|
return query;
|
|
1556
1620
|
};
|
|
1557
1621
|
|
|
1558
1622
|
const useConfigurationForm = (input) => {
|
|
1559
1623
|
var _a;
|
|
1560
1624
|
const fastn = useFastn();
|
|
1561
|
-
const
|
|
1625
|
+
const queryClient = reactQuery.useQueryClient();
|
|
1626
|
+
const configurations = useConfigurations({
|
|
1627
|
+
configurationId: input.configurationId,
|
|
1628
|
+
});
|
|
1562
1629
|
const query = reactQuery.useQuery({
|
|
1563
1630
|
queryKey: ["configuration-form", input],
|
|
1564
|
-
queryFn: () => {
|
|
1565
|
-
|
|
1631
|
+
queryFn: () => {
|
|
1632
|
+
var _a;
|
|
1633
|
+
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) }));
|
|
1634
|
+
},
|
|
1635
|
+
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
1636
|
});
|
|
1637
|
+
react.useEffect(() => {
|
|
1638
|
+
const invalidate = () => {
|
|
1639
|
+
queryClient.invalidateQueries({
|
|
1640
|
+
queryKey: ["configuration-form", input],
|
|
1641
|
+
});
|
|
1642
|
+
queryClient.invalidateQueries({
|
|
1643
|
+
queryKey: ["configurations"],
|
|
1644
|
+
});
|
|
1645
|
+
query.refetch();
|
|
1646
|
+
};
|
|
1647
|
+
fastn.onEvent("REFRESH_CONFIGURATION_FORM", invalidate);
|
|
1648
|
+
}, [query.data]);
|
|
1567
1649
|
return query;
|
|
1568
1650
|
};
|
|
1569
1651
|
|
|
1570
1652
|
const useConnectors = () => {
|
|
1571
1653
|
const fastn = useFastn();
|
|
1654
|
+
const queryClient = reactQuery.useQueryClient();
|
|
1572
1655
|
const query = reactQuery.useQuery({
|
|
1573
1656
|
queryKey: ["connectors"],
|
|
1574
1657
|
queryFn: () => fastn.getConnectors(),
|
|
1575
1658
|
staleTime: 1000 * 60 * 5, // 5 minutes,
|
|
1576
1659
|
});
|
|
1660
|
+
react.useEffect(() => {
|
|
1661
|
+
const invalidate = () => {
|
|
1662
|
+
queryClient.invalidateQueries({ queryKey: ["connectors"] });
|
|
1663
|
+
query.refetch();
|
|
1664
|
+
};
|
|
1665
|
+
fastn.onEvent("REFETCH_CONNECTORS", invalidate);
|
|
1666
|
+
}, [query.data]);
|
|
1577
1667
|
return query;
|
|
1578
1668
|
};
|
|
1579
1669
|
|
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,CAAC,CAAC,CAAC,CAAC;AACnD;;AAE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e;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;\n\n for (let i = 0; i < 16; ++i) {\n buf[offset + i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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","x_google_ignoreList":[0,1,2,3]}
|
package/dist/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { createContext, useMemo, useContext, useState, useCallback } from 'react';
|
|
3
|
-
import { QueryClientProvider, QueryClient,
|
|
2
|
+
import { createContext, useMemo, useContext, useEffect, useState, useCallback } from 'react';
|
|
3
|
+
import { QueryClientProvider, QueryClient, useQueryClient, useQuery, 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';
|
|
@@ -1015,14 +1015,36 @@ const activateConnectorCore = async ({ dependencyConnector, authMethod, formData
|
|
|
1015
1015
|
}
|
|
1016
1016
|
};
|
|
1017
1017
|
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
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
|
|
1029
|
+
const sendEvent = (event) => {
|
|
1030
|
+
window.postMessage({ __eventBus: true, event }, '*');
|
|
1023
1031
|
};
|
|
1032
|
+
// Register a callback for a specific event
|
|
1033
|
+
const onEvent = (event, callback) => {
|
|
1034
|
+
var _a;
|
|
1035
|
+
(_a = listeners[event]) === null || _a === void 0 ? void 0 : _a.add(callback);
|
|
1036
|
+
};
|
|
1037
|
+
// Internal postMessage listener
|
|
1038
|
+
const handleMessage = (e) => {
|
|
1039
|
+
const data = e.data;
|
|
1040
|
+
if (!data || !data.__eventBus || !data.event)
|
|
1041
|
+
return;
|
|
1042
|
+
const callbacks = listeners[data.event];
|
|
1043
|
+
callbacks === null || callbacks === void 0 ? void 0 : callbacks.forEach((cb) => cb());
|
|
1044
|
+
};
|
|
1045
|
+
// Register listener once
|
|
1046
|
+
window.addEventListener('message', handleMessage);
|
|
1024
1047
|
|
|
1025
|
-
const REFETCH_KEY$2 = "connectors";
|
|
1026
1048
|
/**
|
|
1027
1049
|
* Fetches connectors and maps their actions for use in the application.
|
|
1028
1050
|
* Updates the global state store.
|
|
@@ -1061,7 +1083,7 @@ async function getConnectors({ disabled = false, status = "ALL", refetch } = {})
|
|
|
1061
1083
|
.map((action) => {
|
|
1062
1084
|
var _a, _b, _c, _d;
|
|
1063
1085
|
const handler = async (formData = {}) => {
|
|
1064
|
-
var _a, _b, _c, _d
|
|
1086
|
+
var _a, _b, _c, _d;
|
|
1065
1087
|
try {
|
|
1066
1088
|
let response = null;
|
|
1067
1089
|
if ((action === null || action === void 0 ? void 0 : action.actionType) === "ACTIVATION") {
|
|
@@ -1083,7 +1105,10 @@ async function getConnectors({ disabled = false, status = "ALL", refetch } = {})
|
|
|
1083
1105
|
else {
|
|
1084
1106
|
response = await executeActionHandler(action === null || action === void 0 ? void 0 : action.handler);
|
|
1085
1107
|
}
|
|
1086
|
-
|
|
1108
|
+
sendEvent("INVALIDATE_CONNECTORS");
|
|
1109
|
+
sendEvent("REFETCH_CONNECTORS");
|
|
1110
|
+
sendEvent("INVALIDATE_CONFIGURATIONS");
|
|
1111
|
+
sendEvent("REFETCH_CONFIGURATIONS");
|
|
1087
1112
|
return response;
|
|
1088
1113
|
}
|
|
1089
1114
|
catch (e) {
|
|
@@ -1125,9 +1150,7 @@ async function getConnectors({ disabled = false, status = "ALL", refetch } = {})
|
|
|
1125
1150
|
}
|
|
1126
1151
|
}
|
|
1127
1152
|
|
|
1128
|
-
const REFETCH_KEY$1 = "configurations";
|
|
1129
1153
|
const handleDisableConfiguration = async ({ id, connectorId, }) => {
|
|
1130
|
-
var _a;
|
|
1131
1154
|
try {
|
|
1132
1155
|
const config = getConfig();
|
|
1133
1156
|
await disableTenantConfig({
|
|
@@ -1139,14 +1162,14 @@ const handleDisableConfiguration = async ({ id, connectorId, }) => {
|
|
|
1139
1162
|
widgetConnectorId: connectorId,
|
|
1140
1163
|
},
|
|
1141
1164
|
});
|
|
1142
|
-
|
|
1165
|
+
sendEvent("REFETCH_CONFIGURATIONS");
|
|
1166
|
+
sendEvent("INVALIDATE_CONFIGURATIONS");
|
|
1143
1167
|
}
|
|
1144
1168
|
catch (error) {
|
|
1145
1169
|
throw new Error(formatApolloErrors(error));
|
|
1146
1170
|
}
|
|
1147
1171
|
};
|
|
1148
1172
|
const handleDeleteConfiguration = async ({ id, connectorId, }) => {
|
|
1149
|
-
var _a;
|
|
1150
1173
|
try {
|
|
1151
1174
|
const config = getConfig();
|
|
1152
1175
|
await deleteTenantConfiguration({
|
|
@@ -1160,7 +1183,8 @@ const handleDeleteConfiguration = async ({ id, connectorId, }) => {
|
|
|
1160
1183
|
},
|
|
1161
1184
|
},
|
|
1162
1185
|
});
|
|
1163
|
-
|
|
1186
|
+
sendEvent("REFETCH_CONFIGURATIONS");
|
|
1187
|
+
sendEvent("INVALIDATE_CONFIGURATIONS");
|
|
1164
1188
|
}
|
|
1165
1189
|
catch (error) {
|
|
1166
1190
|
throw new Error(formatApolloErrors(error));
|
|
@@ -1189,9 +1213,9 @@ async function getConfigurations({ configurationId, status = "ALL", }) {
|
|
|
1189
1213
|
name: "Disable",
|
|
1190
1214
|
actionType: ConnectorActionType.DISABLE,
|
|
1191
1215
|
onClick: async () => {
|
|
1192
|
-
var _a;
|
|
1193
1216
|
await handleDisableConfiguration({ connectorId: configSubscription.connector.id, id: configurationId });
|
|
1194
|
-
|
|
1217
|
+
sendEvent("INVALIDATE_CONFIGURATIONS");
|
|
1218
|
+
sendEvent("REFETCH_CONFIGURATIONS");
|
|
1195
1219
|
return { data: null, status: "SUCCESS" };
|
|
1196
1220
|
},
|
|
1197
1221
|
});
|
|
@@ -1199,9 +1223,9 @@ async function getConfigurations({ configurationId, status = "ALL", }) {
|
|
|
1199
1223
|
name: "Delete",
|
|
1200
1224
|
actionType: ConnectorActionType.DELETE,
|
|
1201
1225
|
onClick: async () => {
|
|
1202
|
-
var _a;
|
|
1203
1226
|
await handleDeleteConfiguration({ connectorId: configSubscription.connector.id, id: configurationId });
|
|
1204
|
-
|
|
1227
|
+
sendEvent("INVALIDATE_CONFIGURATIONS");
|
|
1228
|
+
sendEvent("REFETCH_CONFIGURATIONS");
|
|
1205
1229
|
return { data: null, status: "SUCCESS" };
|
|
1206
1230
|
},
|
|
1207
1231
|
});
|
|
@@ -1219,6 +1243,10 @@ async function getConfigurations({ configurationId, status = "ALL", }) {
|
|
|
1219
1243
|
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
1244
|
input: formData,
|
|
1221
1245
|
});
|
|
1246
|
+
sendEvent("INVALIDATE_CONFIGURATIONS");
|
|
1247
|
+
sendEvent("REFETCH_CONFIGURATIONS");
|
|
1248
|
+
sendEvent("INVALIDATE_CONNECTORS");
|
|
1249
|
+
sendEvent("REFETCH_CONNECTORS");
|
|
1222
1250
|
return { data: result, status: "SUCCESS" };
|
|
1223
1251
|
};
|
|
1224
1252
|
actions.push({
|
|
@@ -1250,6 +1278,13 @@ async function getConfigurations({ configurationId, status = "ALL", }) {
|
|
|
1250
1278
|
}
|
|
1251
1279
|
}
|
|
1252
1280
|
|
|
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
|
+
|
|
1253
1288
|
function loadGapiClient() {
|
|
1254
1289
|
return new Promise((resolve, reject) => {
|
|
1255
1290
|
const script = document.createElement('script');
|
|
@@ -1318,21 +1353,38 @@ async function createGooglePicker(developerKey, accessToken) {
|
|
|
1318
1353
|
const REFETCH_KEY = "configuration-form";
|
|
1319
1354
|
function openGoogleFilesPicker(parentArgs) {
|
|
1320
1355
|
return async (args) => {
|
|
1321
|
-
var _a, _b
|
|
1356
|
+
var _a, _b;
|
|
1322
1357
|
try {
|
|
1323
1358
|
const config = getConfig();
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
if (!accessToken)
|
|
1334
|
-
|
|
1335
|
-
|
|
1359
|
+
let accessToken = null;
|
|
1360
|
+
let apiKey = null;
|
|
1361
|
+
const cachedToken = localStorage.getItem(config.spaceId + parentArgs.connectorId + config.tenantId + "access_token");
|
|
1362
|
+
if (cachedToken) {
|
|
1363
|
+
const token = safeParse(cachedToken);
|
|
1364
|
+
if ((token === null || token === void 0 ? void 0 : token.expires_at) && token.expires_at > Date.now()) {
|
|
1365
|
+
accessToken = token.access_token;
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1368
|
+
if (!accessToken) {
|
|
1369
|
+
const { data } = await generateAccessToken({
|
|
1370
|
+
input: {
|
|
1371
|
+
orgId: config.spaceId,
|
|
1372
|
+
tenantId: config.tenantId,
|
|
1373
|
+
connectorId: parentArgs.connectorId,
|
|
1374
|
+
refresh: true,
|
|
1375
|
+
},
|
|
1376
|
+
});
|
|
1377
|
+
const token = data === null || data === void 0 ? void 0 : data.connectorConnection;
|
|
1378
|
+
// cache token in local storage
|
|
1379
|
+
localStorage.setItem(config.spaceId + parentArgs.connectorId + config.tenantId + "access_token", safeStringify({
|
|
1380
|
+
access_token: token.access_token,
|
|
1381
|
+
api_key: (_a = token.metadata) === null || _a === void 0 ? void 0 : _a.google_picker_api_key,
|
|
1382
|
+
expires_at: token.expires_at || Date.now() + token.expires_in * 1000,
|
|
1383
|
+
}));
|
|
1384
|
+
accessToken = token.access_token;
|
|
1385
|
+
apiKey = (_b = token.metadata) === null || _b === void 0 ? void 0 : _b.google_picker_api_key;
|
|
1386
|
+
}
|
|
1387
|
+
const docs = await createGooglePicker(args.apiKey || apiKey, accessToken);
|
|
1336
1388
|
const files = (docs || []).map((doc) => ({
|
|
1337
1389
|
label: doc === null || doc === void 0 ? void 0 : doc.name,
|
|
1338
1390
|
value: doc === null || doc === void 0 ? void 0 : doc.id,
|
|
@@ -1351,7 +1403,7 @@ function openGoogleFilesPicker(parentArgs) {
|
|
|
1351
1403
|
*/
|
|
1352
1404
|
function getSubmitHandler({ configuration, configurationId, connectorId, }) {
|
|
1353
1405
|
return async ({ formData }) => {
|
|
1354
|
-
var _a
|
|
1406
|
+
var _a;
|
|
1355
1407
|
const config = getConfig();
|
|
1356
1408
|
const uiCode = populateFormDataInUiCode(configuration.uiCode, formData);
|
|
1357
1409
|
try {
|
|
@@ -1383,8 +1435,9 @@ function getSubmitHandler({ configuration, configurationId, connectorId, }) {
|
|
|
1383
1435
|
configurations: formData,
|
|
1384
1436
|
}),
|
|
1385
1437
|
});
|
|
1386
|
-
await ((_b = refetchFunctions[REFETCH_KEY]) === null || _b === void 0 ? void 0 : _b.call(refetchFunctions));
|
|
1387
1438
|
}
|
|
1439
|
+
sendEvent("REFRESH_CONFIGURATION_FORM");
|
|
1440
|
+
sendEvent("REFETCH_CONNECTORS");
|
|
1388
1441
|
}
|
|
1389
1442
|
catch (error) {
|
|
1390
1443
|
throw new Error(formatApolloErrors(error));
|
|
@@ -1526,6 +1579,9 @@ class Fastn {
|
|
|
1526
1579
|
registerRefetchFunction(input) {
|
|
1527
1580
|
return registerRefetchFunction(input);
|
|
1528
1581
|
}
|
|
1582
|
+
onEvent(event, callback) {
|
|
1583
|
+
return onEvent(event, callback);
|
|
1584
|
+
}
|
|
1529
1585
|
}
|
|
1530
1586
|
|
|
1531
1587
|
const FastnContext = createContext(null);
|
|
@@ -1545,33 +1601,67 @@ const useFastn = () => {
|
|
|
1545
1601
|
|
|
1546
1602
|
const useConfigurations = (input) => {
|
|
1547
1603
|
const fastn = useFastn();
|
|
1604
|
+
const queryClient = useQueryClient();
|
|
1548
1605
|
const query = useQuery({
|
|
1549
1606
|
queryKey: ["configurations", input],
|
|
1550
1607
|
queryFn: () => fastn.getConfigurations(input),
|
|
1551
1608
|
staleTime: 1000 * 60 * 5, // 5 minutes
|
|
1552
1609
|
});
|
|
1610
|
+
useEffect(() => {
|
|
1611
|
+
const invalidate = () => {
|
|
1612
|
+
queryClient.invalidateQueries({ queryKey: ["configurations"] });
|
|
1613
|
+
query.refetch();
|
|
1614
|
+
};
|
|
1615
|
+
fastn.onEvent("REFETCH_CONFIGURATIONS", invalidate);
|
|
1616
|
+
}, [query.data]);
|
|
1553
1617
|
return query;
|
|
1554
1618
|
};
|
|
1555
1619
|
|
|
1556
1620
|
const useConfigurationForm = (input) => {
|
|
1557
1621
|
var _a;
|
|
1558
1622
|
const fastn = useFastn();
|
|
1559
|
-
const
|
|
1623
|
+
const queryClient = useQueryClient();
|
|
1624
|
+
const configurations = useConfigurations({
|
|
1625
|
+
configurationId: input.configurationId,
|
|
1626
|
+
});
|
|
1560
1627
|
const query = useQuery({
|
|
1561
1628
|
queryKey: ["configuration-form", input],
|
|
1562
|
-
queryFn: () => {
|
|
1563
|
-
|
|
1629
|
+
queryFn: () => {
|
|
1630
|
+
var _a;
|
|
1631
|
+
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) }));
|
|
1632
|
+
},
|
|
1633
|
+
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
1634
|
});
|
|
1635
|
+
useEffect(() => {
|
|
1636
|
+
const invalidate = () => {
|
|
1637
|
+
queryClient.invalidateQueries({
|
|
1638
|
+
queryKey: ["configuration-form", input],
|
|
1639
|
+
});
|
|
1640
|
+
queryClient.invalidateQueries({
|
|
1641
|
+
queryKey: ["configurations"],
|
|
1642
|
+
});
|
|
1643
|
+
query.refetch();
|
|
1644
|
+
};
|
|
1645
|
+
fastn.onEvent("REFRESH_CONFIGURATION_FORM", invalidate);
|
|
1646
|
+
}, [query.data]);
|
|
1565
1647
|
return query;
|
|
1566
1648
|
};
|
|
1567
1649
|
|
|
1568
1650
|
const useConnectors = () => {
|
|
1569
1651
|
const fastn = useFastn();
|
|
1652
|
+
const queryClient = useQueryClient();
|
|
1570
1653
|
const query = useQuery({
|
|
1571
1654
|
queryKey: ["connectors"],
|
|
1572
1655
|
queryFn: () => fastn.getConnectors(),
|
|
1573
1656
|
staleTime: 1000 * 60 * 5, // 5 minutes,
|
|
1574
1657
|
});
|
|
1658
|
+
useEffect(() => {
|
|
1659
|
+
const invalidate = () => {
|
|
1660
|
+
queryClient.invalidateQueries({ queryKey: ["connectors"] });
|
|
1661
|
+
query.refetch();
|
|
1662
|
+
};
|
|
1663
|
+
fastn.onEvent("REFETCH_CONNECTORS", invalidate);
|
|
1664
|
+
}, [query.data]);
|
|
1575
1665
|
return query;
|
|
1576
1666
|
};
|
|
1577
1667
|
|
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,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,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.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;A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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.13",
|
|
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.9"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
65
|
"@tanstack/react-query": "^5.0.0",
|