Skip to content
This repository was archived by the owner on Jan 12, 2026. It is now read-only.

Commit bb52211

Browse files
Test connection logs with same domain refactor (#79)
Since we assume that iframe domain is the same as main app domain, I've applied several refactors and improvements * Removed `useApiCall` hook and replaced it with normal fetch. * Added test connection logs * Removed handling of opening links in the new tab via postMessage * Removed handling of opening lighboxes via postMessage * Removed handling of showing toast messages via postMessage
1 parent 393769a commit bb52211

37 files changed

+1086
-2105
lines changed

README.md

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,6 @@ The Config UI Framework provides a way for anyone to build a plugin UI with simp
2424

2525
### Hooks
2626

27-
#### useApiCall
28-
29-
This hook is used to make API calls that require Authentication header from CloudQuery Cloud App.
30-
31-
```tsx
32-
const { callApi } = useApiCall(pluginUiMessageHandler);
33-
34-
callApi('https://api.cloudquery.io', 'POST', { name: 'my-source' });
35-
```
36-
3727
#### useFormActions
3828

3929
This hook is used export data and functions that can be used in the footer for plugin UI.
@@ -64,15 +54,6 @@ useFormCurrentValues({
6454
});
6555
```
6656

67-
#### useFormHeightChange
68-
69-
This hook is used to automatically detect the changes of the height of the form container and notify CloudQuery Cloud App about those.
70-
The hooks returns the React Ref object that should reference the HTML element that represents the form container.
71-
72-
```tsx
73-
useFormHeightChange(pluginUiMessageHandler);
74-
```
75-
7657
#### useFormInit
7758

7859
This hook is used get the initial values for the form from the CloudQuery Cloud App.

etc/plugin-config-ui-lib.api.md

Lines changed: 38 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import { ListProps } from '@mui/material/List';
2020
import { PluginUiMessageHandler } from '@cloudquery/plugin-config-ui-connector';
2121
import { PluginUiMessagePayload } from '@cloudquery/plugin-config-ui-connector';
2222
import { default as React_2 } from 'react';
23-
import { ReactElement } from 'react';
2423
import { ReactNode } from 'react';
2524
import { Ref } from 'react';
2625
import { RefAttributes } from 'react';
@@ -274,15 +273,14 @@ export function convertStringToSlug(value: string): string;
274273
export function corePrepareSubmitValues(config: PluginConfig, values: any, tablesList?: PluginTable[]): PluginUiMessagePayload['validation_passed']['values'];
275274

276275
// @public
277-
export function createAndAuthenticateConnector<T>({ connectorId: existingConnectorId, teamName, pluginTeamName, authPluginType, pluginName, pluginKind, callApi, authenticatePayload, }: {
276+
export function createAndAuthenticateConnector<T>({ connectorId: existingConnectorId, teamName, pluginTeamName, authPluginType, pluginName, pluginKind, authenticatePayload, }: {
278277
connectorId?: string;
279278
teamName: string;
280279
pluginTeamName: string;
281280
authPluginType: AuthPluginType;
282281
pluginName: string;
283282
pluginKind: 'source' | 'destination';
284283
finishImmediately?: boolean;
285-
callApi: ReturnType<typeof useApiCall>['callApi'];
286284
authenticatePayload?: Partial<{
287285
plugin_version: string;
288286
spec: Record<string, any>;
@@ -321,11 +319,10 @@ export interface ExclusiveToggleProps {
321319
}
322320

323321
// @public
324-
export function finishAuthConnectorAuthentication({ authPluginType, connectorId, teamName, callApi, method, payload, path, }: {
322+
export function finishAuthConnectorAuthentication({ authPluginType, connectorId, teamName, method, payload, path, }: {
325323
connectorId: string;
326324
teamName: string;
327325
authPluginType: AuthPluginType;
328-
callApi: ReturnType<typeof useApiCall>['callApi'];
329326
method: 'POST' | 'PATCH';
330327
payload: Record<string, any>;
331328
path?: string;
@@ -381,7 +378,7 @@ export interface FormFieldResetProps {
381378
}
382379

383380
// @public
384-
export function FormFooter({ isUpdating, isSubmitting, isTestingConnection, testConnectionError, pluginKind, submitPayload, onCancel, onCancelTestConnection, onDelete, onGoToPreviousStep, onTestConnectionSuccess, submitLabel, submitDisabled, showPreviousStepButton, }: FormFooterProps): JSX_2.Element;
381+
export function FormFooter({ isUpdating, isSubmitting, isTestingConnection, testConnectionError, pluginKind, submitPayload, onCancel, onCancelTestConnection, onDelete, onGoToPreviousStep, onTestConnectionSuccess, submitLabel, submitDisabled, showPreviousStepButton, pluginName, teamName, testConnectionId, }: FormFooterProps): JSX_2.Element;
385382

386383
// @public (undocumented)
387384
export interface FormFooterProps {
@@ -394,16 +391,19 @@ export interface FormFooterProps {
394391
onGoToPreviousStep: () => void;
395392
onTestConnectionSuccess: () => void;
396393
pluginKind: 'source' | 'destination';
394+
pluginName: string;
397395
showPreviousStepButton: boolean;
398396
submitDisabled?: boolean;
399397
submitLabel?: string;
400398
// Warning: (ae-forgotten-export) The symbol "FormValues" needs to be exported by the entry point index.d.ts
401399
submitPayload: (FormValues & {
402400
connectionId: string;
403401
}) | undefined;
402+
teamName: string;
404403
testConnectionError: (Error & {
405404
code?: string;
406405
}) | undefined;
406+
testConnectionId?: string;
407407
}
408408

409409
export { FormProvider }
@@ -423,12 +423,11 @@ export type FormWrapperProps = {
423423
};
424424

425425
// @public
426-
export function GCPConnect({ variant, pluginUiMessageHandler }: GCPConnectProps): JSX_2.Element;
426+
export function GCPConnect({ variant }: GCPConnectProps): JSX_2.Element;
427427

428428
// @public (undocumented)
429429
export type GCPConnectProps = {
430430
variant?: 'link' | 'button';
431-
pluginUiMessageHandler: PluginUiMessageHandler;
432431
};
433432

434433
// @public
@@ -456,19 +455,13 @@ export function getAppRootElements({ rootSelector, shadowRootWindowKey, }?: {
456455
};
457456

458457
// @public
459-
export function getAuthenticateConnector({ connectorId, teamName, callApi, authPluginType, }: {
458+
export function getAuthenticateConnector({ connectorId, teamName, authPluginType, }: {
460459
connectorId: string;
461460
teamName: string;
462-
callApi: ReturnType<typeof useApiCall>['callApi'];
463461
authPluginType: AuthPluginType;
464462
}): Promise<{
465-
body: {
466-
role_arn: string;
467-
external_id: string;
468-
};
469-
endpoint: string;
470-
headers: Record<string, string>;
471-
status: number;
463+
role_arn: string;
464+
external_id: string;
472465
}>;
473466

474467
// @public
@@ -478,10 +471,10 @@ export const getEnabledTablesObject: ({ tablesList, tables, }: {
478471
}) => Record<string, boolean>;
479472

480473
// @public
481-
export function getFieldHelperText(errorMessage: string | undefined, helperText: string | ReactNode): string | number | boolean | JSX_2.Element | Iterable<ReactNode> | null | undefined;
474+
export function getFieldHelperText(errorMessage: string | undefined, helperText: string | ReactNode): string | number | boolean | Iterable<ReactNode> | JSX_2.Element | null | undefined;
482475

483476
// @public
484-
export const getGCPAuthFormula: ({ initialValues, pluginUiMessageHandler, }: GetGCPAuthFormulaProps) => ({
477+
export const getGCPAuthFormula: ({ initialValues }: GetGCPAuthFormulaProps) => ({
485478
component: string;
486479
name: string;
487480
options: {
@@ -494,7 +487,7 @@ export const getGCPAuthFormula: ({ initialValues, pluginUiMessageHandler, }: Get
494487
} | {
495488
component: string;
496489
shouldRender: (values: any) => boolean;
497-
children: (() => JSX_2.Element)[];
490+
children: (typeof GCPConnect)[];
498491
name?: undefined;
499492
options?: undefined;
500493
schema?: undefined;
@@ -530,9 +523,7 @@ export function getYupValidationResolver<FieldValues extends yup.AnyObject, Sche
530523
}>;
531524

532525
// @public
533-
export function GuideComponent({ pluginUiMessageHandler, }: {
534-
pluginUiMessageHandler: any;
535-
}): ReactElement | null;
526+
export function GuideComponent(): JSX_2.Element | null;
536527

537528
// @public (undocumented)
538529
export interface GuideConfig {
@@ -561,21 +552,15 @@ export type GuideSectionBody = {
561552
export function isApiAbortError(error: Error): boolean;
562553

563554
// @public
564-
export function LightboxImage({ pluginUiMessageHandler, ...props }: LightboxImageProps): JSX_2.Element;
565-
566-
// @public (undocumented)
567-
export type LightboxImageProps = ImgHTMLAttributes<HTMLImageElement> & {
568-
pluginUiMessageHandler: PluginUiMessageHandler;
569-
};
555+
export function LightboxImage({ sizes, ...props }: ImgHTMLAttributes<HTMLImageElement>): JSX_2.Element;
570556

571557
// @public
572-
export function Link({ children, href, pluginUiMessageHandler, ...linkProps }: LinkProps): JSX_2.Element;
558+
export const Link: React_2.ForwardRefExoticComponent<Omit<LinkProps, "ref"> & React_2.RefAttributes<HTMLAnchorElement>>;
573559

574560
// @public (undocumented)
575561
export type LinkProps = Omit<LinkProps_2, 'onClick' | 'children' | 'href'> & {
576562
children: ReactNode;
577563
href: string;
578-
pluginUiMessageHandler: PluginUiMessageHandler;
579564
};
580565

581566
// @public
@@ -650,7 +635,7 @@ export interface PluginConfig {
650635
export type PluginConfigFormStep = {
651636
children: (IterableStepComponent | React_2.FC<any>)[];
652637
title: string;
653-
submitGuard?: (formValues: any, teamName: string, callApi: ReturnType<typeof useApiCall>['callApi'], setValue: (field: string, value: any) => void) => Promise<boolean | {
638+
submitGuard?: (formValues: any, teamName: string, setValue: (field: string, value: any) => void) => Promise<boolean | {
654639
errorMessage: string;
655640
}>;
656641
};
@@ -711,12 +696,11 @@ export function readSecretsFromInitialValues<T extends object>(defaultEnv: T, ap
711696
}[]): T;
712697

713698
// @public
714-
export function RenderGuide({ sections, pluginUiMessageHandler }: RenderGuideProps): JSX_2.Element;
699+
export function RenderGuide({ sections }: RenderGuideProps): JSX_2.Element;
715700

716701
// @public (undocumented)
717702
export type RenderGuideProps = {
718703
sections: GuideSection[];
719-
pluginUiMessageHandler: PluginUiMessageHandler;
720704
};
721705

722706
// @public
@@ -793,7 +777,7 @@ export interface ServiceListProps {
793777
export type ServiceTypes = Record<string, ServiceType>;
794778

795779
// @public
796-
export function SetupGuide({ docsLink, title, children, maxHeight, pluginUiMessageHandler, }: SetupGuideProps): JSX_2.Element;
780+
export function SetupGuide({ docsLink, title, children, maxHeight }: SetupGuideProps): JSX_2.Element;
797781

798782
// @public (undocumented)
799783
export interface SetupGuideProps {
@@ -804,14 +788,9 @@ export interface SetupGuideProps {
804788
// (undocumented)
805789
maxHeight?: number;
806790
// (undocumented)
807-
pluginUiMessageHandler: PluginUiMessageHandler;
808-
// (undocumented)
809791
title: string;
810792
}
811793

812-
// @public
813-
export function showToast(pluginUiMessageHandler: PluginUiMessageHandler, type: 'error' | 'success' | 'blank', message: string): void;
814-
815794
// @public (undocumented)
816795
export interface SourceConfig extends PluginConfig {
817796
// (undocumented)
@@ -823,6 +802,20 @@ export type SyncFormStepIconProps = StepIconProps & {
823802
label: string;
824803
};
825804

805+
// Warning: (ae-internal-missing-underscore) The name "SyncLogLevel" should be prefixed with an underscore because the declaration is marked as @internal
806+
//
807+
// @internal (undocumented)
808+
export enum SyncLogLevel {
809+
// (undocumented)
810+
DEBUG = "debug",
811+
// (undocumented)
812+
ERROR = "error",
813+
// (undocumented)
814+
INFO = "info",
815+
// (undocumented)
816+
WARNING = "warning"
817+
}
818+
826819
// @public
827820
export function TableSelector({ subscribeToTablesValueChange, errorMessage, value, onChange, tableList, disabled, }: TableSelectorProps): JSX_2.Element;
828821

@@ -879,23 +872,6 @@ export type UploadJSONProps = {
879872
helperText?: string;
880873
};
881874

882-
// @public
883-
export function useApiCall(pluginUiMessageHandler: PluginUiMessageHandler): {
884-
callApi: <ResponseData>(endpoint: string, method: "GET" | "POST" | "PATCH" | "PUT" | "DELETE", body?: any, options?: {
885-
headers?: Record<string, string>;
886-
mode?: "cors" | "navigate" | "no-cors" | "same-origin";
887-
}) => {
888-
requestPromise: Promise<{
889-
body: ResponseData;
890-
endpoint: string;
891-
headers: Record<string, string>;
892-
status: number;
893-
}>;
894-
abortRequest: () => void;
895-
requestId: string;
896-
};
897-
};
898-
899875
// @public (undocumented)
900876
export const useConfigUIForm: () => UseFormReturn<any, any, undefined>;
901877

@@ -974,16 +950,14 @@ export function useFormActions<PluginKind extends 'source' | 'destination'>({ ge
974950
} & {
975951
connectionId: string;
976952
}) | undefined;
953+
testConnectionId: string | undefined;
977954
};
978955

979956
export { useFormContext }
980957

981958
// @public
982959
export function useFormCurrentValues(pluginUiMessageHandler: PluginUiMessageHandler, getCurrentValues: () => PluginUiMessagePayload['current_values']['values']): void;
983960

984-
// @public
985-
export function useFormHeightChange(pluginUiMessageHandler: PluginUiMessageHandler): void;
986-
987961
// @public
988962
export function useFormInit(pluginUiMessageHandler: PluginUiMessageHandler, implementsCustomFooter: boolean): {
989963
initialized: boolean;
@@ -1028,7 +1002,7 @@ export function useOauthConnector({ pluginUiMessageHandler, teamName, pluginKind
10281002
export const usePluginContext: () => PluginContextProps;
10291003

10301004
// @public
1031-
export function useTestConnection(pluginUiMessageHandler: PluginUiMessageHandler): {
1005+
export function useTestConnection(): {
10321006
cancelTestConnection: () => void;
10331007
testConnection: (values: {
10341008
name: string;
@@ -1041,6 +1015,7 @@ export function useTestConnection(pluginUiMessageHandler: PluginUiMessageHandler
10411015
}>;
10421016
connector_id?: string;
10431017
}, teamName: string, pluginKind: "source" | "destination", isUpdating: boolean) => Promise<string>;
1018+
testConnectionId: string | undefined;
10441019
};
10451020

10461021
export { useWatch }
@@ -1056,8 +1031,8 @@ export function writeSecretsToPrepareValues(env?: Record<string, string>): {
10561031

10571032
// Warnings were encountered during analysis:
10581033
//
1059-
// src/types.ts:48:3 - (ae-forgotten-export) The symbol "IterableStepComponent" needs to be exported by the entry point index.d.ts
1060-
// src/utils/authConnectorAuthentication.ts:51:3 - (ae-forgotten-export) The symbol "AuthPluginType" needs to be exported by the entry point index.d.ts
1034+
// src/types.ts:47:3 - (ae-forgotten-export) The symbol "IterableStepComponent" needs to be exported by the entry point index.d.ts
1035+
// src/utils/authConnectorAuthentication.ts:47:3 - (ae-forgotten-export) The symbol "AuthPluginType" needs to be exported by the entry point index.d.ts
10611036

10621037
// (No @packageDocumentation comment for this package)
10631038

package-lock.json

Lines changed: 18 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)