@workos-inc/widgets 1.14.1 → 1.15.0-next.1782258061855

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/CHANGELOG.md CHANGED
@@ -1,6 +1,19 @@
1
1
  # Changelog
2
2
 
3
- ## 1.14.1
3
+ ## 1.15.0-next.1782258061855
4
+
5
+ ### Minor Changes
6
+
7
+ - [#291](https://github.com/workos/widgets/pull/291) [`6356ad9`](https://github.com/workos/widgets/commit/6356ad99d21fe1f7bc218ead24155cb1ac2c1fdb) Thanks [@dandorman](https://github.com/dandorman)! - Add API-key install form for data integrations
8
+
9
+ Integrations whose `authMethods` includes `api_key` now render an API-key entry
10
+ dialog (via `useUpsertDataIntegrationApiKey`). Features:
11
+ - Single-method `api_key` integrations show a direct "Connect" button opening the key dialog.
12
+ - Dual-method (`oauth` + `api_key`) integrations show a dropdown letting the user choose.
13
+ - Connected API-key integrations show a "Rotate API key" option in the actions menu with
14
+ the current key masked as `••••{last4}`.
15
+ - 422 / validation errors are surfaced in a `Callout` without discarding the entered value.
16
+ - OAuth-only integrations are unchanged.
4
17
 
5
18
  ### Patch Changes
6
19
 
@@ -190,6 +190,9 @@ __export(endpoint_exports, {
190
190
  useUpdatePassword: () => useUpdatePassword,
191
191
  useUpdatePasswordHook: () => useUpdatePasswordHook,
192
192
  useUpdatePasswordMutationOptions: () => useUpdatePasswordMutationOptions,
193
+ useUpsertDataIntegrationApiKey: () => useUpsertDataIntegrationApiKey,
194
+ useUpsertDataIntegrationApiKeyHook: () => useUpsertDataIntegrationApiKeyHook,
195
+ useUpsertDataIntegrationApiKeyMutationOptions: () => useUpsertDataIntegrationApiKeyMutationOptions,
193
196
  useUpsertDataIntegrationConfiguration: () => useUpsertDataIntegrationConfiguration,
194
197
  useUpsertDataIntegrationConfigurationHook: () => useUpsertDataIntegrationConfigurationHook,
195
198
  useUpsertDataIntegrationConfigurationMutationOptions: () => useUpsertDataIntegrationConfigurationMutationOptions,
@@ -596,6 +599,37 @@ function useGetDataInstallationAuthorizationStatus(dataIntegrationId, state, opt
596
599
  const query = (0, import_react_query.useQuery)(queryOptions, queryClient);
597
600
  return { ...query, queryKey: queryOptions.queryKey };
598
601
  }
602
+ const useUpsertDataIntegrationApiKeyHook = () => {
603
+ const upsertDataIntegrationApiKey = (0, import_widgets_api_client.useWidgetsApiClient)();
604
+ return (0, import_react.useCallback)(
605
+ (slug, upsertApiKeyBody, signal) => {
606
+ return upsertDataIntegrationApiKey({
607
+ url: `/_widgets/DataIntegrations/${slug}/api-key`,
608
+ method: "PUT",
609
+ headers: { "Content-Type": "application/json" },
610
+ data: upsertApiKeyBody,
611
+ signal
612
+ });
613
+ },
614
+ [upsertDataIntegrationApiKey]
615
+ );
616
+ };
617
+ const useUpsertDataIntegrationApiKeyMutationOptions = (options) => {
618
+ const mutationKey = ["upsertDataIntegrationApiKey"];
619
+ const { mutation: mutationOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : { ...options, mutation: { ...options.mutation, mutationKey } } : { mutation: { mutationKey } };
620
+ const upsertDataIntegrationApiKey = useUpsertDataIntegrationApiKeyHook();
621
+ const mutationFn = (props) => {
622
+ const { slug, data } = props ?? {};
623
+ return upsertDataIntegrationApiKey(slug, data);
624
+ };
625
+ return { mutationFn, ...mutationOptions };
626
+ };
627
+ const useUpsertDataIntegrationApiKey = (options, queryClient) => {
628
+ return (0, import_react_query.useMutation)(
629
+ useUpsertDataIntegrationApiKeyMutationOptions(options),
630
+ queryClient
631
+ );
632
+ };
599
633
  const useGetDataIntegrationAuthorizeUrlHook = () => {
600
634
  const getDataIntegrationAuthorizeUrl = (0, import_widgets_api_client.useWidgetsApiClient)();
601
635
  return (0, import_react.useCallback)(
@@ -2052,6 +2086,9 @@ function useSettings(options, queryClient) {
2052
2086
  useUpdatePassword,
2053
2087
  useUpdatePasswordHook,
2054
2088
  useUpdatePasswordMutationOptions,
2089
+ useUpsertDataIntegrationApiKey,
2090
+ useUpsertDataIntegrationApiKeyHook,
2091
+ useUpsertDataIntegrationApiKeyMutationOptions,
2055
2092
  useUpsertDataIntegrationConfiguration,
2056
2093
  useUpsertDataIntegrationConfigurationHook,
2057
2094
  useUpsertDataIntegrationConfigurationMutationOptions,