UNPKG

@cloudquery/plugin-ui-sdk

Version:

SDK for CloudQuery Plugin UI configuration

238 lines 8.74 kB
import { default as React } from 'react'; import { PluginTable, Service } from './components'; import { ControlBooleanFieldProps } from './components/form/controls/controlBooleanField'; import { ControlCodeFieldProps } from './components/form/controls/controlCodeField'; import { ControlDateFieldProps } from './components/form/controls/controlDateField'; import { ControlDateTimeFieldProps } from './components/form/controls/controlDateTimeField'; import { ControlExclusiveToggleFieldProps } from './components/form/controls/controlExclusiveToggleField'; import { ControlMultiSelectFieldProps } from './components/form/controls/controlMultiSelectField'; import { ControlNumberFieldProps } from './components/form/controls/controlNumberField'; import { ControlSecretFieldProps } from './components/form/controls/controlSecretField'; import { ControlSelectFieldProps } from './components/form/controls/controlSelectField'; import { ControlServiceSelectorFieldProps } from './components/form/controls/controlServiceSelectorField'; import { ControlTableSelectorFieldProps } from './components/form/controls/controlTableSelectorField'; import { ControlTextFieldProps } from './components/form/controls/controlTextField'; import { CollapsibleSectionProps } from './components/form/sections/collapsibleSection'; import { CollapsibleSubSectionProps } from './components/form/sections/collapsibleSubSection'; import { SectionProps } from './components/form/sections/section'; import { SubSectionProps } from './components/form/sections/subSection'; import * as yup from 'yup'; export interface CloudQueryTable { columns: unknown[]; description: string; is_incremental?: boolean; is_paid?: boolean; name: string; relations: CloudQueryTable[]; title: string; } type ShouldRenderAbstract = { shouldRender?: (values: any) => boolean; }; export interface ComponentAbstract extends ShouldRenderAbstract { name: string; schema: yup.AnySchema; } interface SectionAbstract extends ShouldRenderAbstract { children: (RenderSection | LayoutComponent | ReservedLayoutComponent | ReactField | LayoutWrapper | React.FC<any>)[]; } export type IterableStepComponent = RenderSection | LayoutComponent | ReservedLayoutComponent | ReactField | LayoutWrapper; export type RenderSection = ShouldRenderAbstract & (LayoutSection | LayoutCollapsibleSection | LayoutCollapsibleSubSection | LayoutSubSection); export type LayoutComponent = LayoutTextField | LayoutSecretInput | LayoutNumberField | LayoutDateTimeField | LayoutDateField | LayoutBooleanField | LayoutSelectField | LayoutMultiSelectField | LayoutExclusiveToggle | LayoutCodeField; export type ReservedLayoutComponent = LayoutTableSelector | LayoutServicesSelector; export interface ReactField extends ComponentAbstract { component: React.FC<any>; children?: (RenderSection | LayoutComponent | ReservedLayoutComponent | React.FC<any>)[]; } export interface LayoutTextField extends ComponentAbstract, ControlTextFieldProps { component: 'control-text-field'; } export interface LayoutSecretInput extends ComponentAbstract, Omit<ControlSecretFieldProps, 'editMode'> { component: 'control-secret-field'; } export interface LayoutNumberField extends ComponentAbstract, ControlNumberFieldProps { component: 'control-number-field'; } export interface LayoutSelectField extends ComponentAbstract, ControlSelectFieldProps { component: 'control-select-field'; } export interface LayoutBooleanField extends ComponentAbstract, ControlBooleanFieldProps { component: 'control-boolean-field'; } export interface LayoutDateTimeField extends ComponentAbstract, ControlDateTimeFieldProps { component: 'control-date-time-field'; } export interface LayoutDateField extends ComponentAbstract, ControlDateFieldProps { component: 'control-date-field'; } export interface LayoutMultiSelectField extends ComponentAbstract, ControlMultiSelectFieldProps { component: 'control-multi-select'; } export interface LayoutExclusiveToggle extends ComponentAbstract, ControlExclusiveToggleFieldProps { component: 'control-exclusive-toggle'; } export interface LayoutCodeField extends ComponentAbstract, ControlCodeFieldProps { component: 'control-code-field'; } export interface LayoutServicesSelector extends Omit<ControlServiceSelectorFieldProps, 'tables' | 'fallbackLogoSrc'> { component: 'control-service-selector'; } export interface LayoutTableSelector extends Omit<ControlTableSelectorFieldProps, 'tables'> { component: 'control-table-selector'; } export interface LayoutWrapper extends ShouldRenderAbstract { component: React.FC<any>; children?: (RenderSection | LayoutComponent | ReservedLayoutComponent | ReactField | React.FC<any>)[]; } export interface LayoutSection extends SectionAbstract, Omit<SectionProps, 'children'> { component: 'section'; } export interface LayoutCollapsibleSection extends SectionAbstract, Omit<CollapsibleSectionProps, 'children'> { component: 'collapsible-section'; } export interface LayoutSubSection extends SectionAbstract, Omit<SubSectionProps, 'children'> { component: 'sub-section'; } export interface LayoutCollapsibleSubSection extends SectionAbstract, Omit<CollapsibleSubSectionProps, 'children'> { component: 'collapsible-sub-section'; } export type WriteMode = 'append' | 'overwrite' | 'overwrite-delete-stale'; export type MigrateMode = 'forced' | 'safe'; export interface FormValues { name: string; displayName?: string; migrateMode?: MigrateMode; writeMode?: WriteMode; tables?: string[]; skipTables?: string[]; envs: Array<{ name: string; value: string; }>; spec: Record<string, any>; connectorId?: string; onboardingId?: string; } export interface InitialValues { name: string; displayName?: string; migrateMode?: MigrateMode; writeMode?: WriteMode; tables?: string[]; skipTables?: string[]; envs: Array<{ name: string; value: string; }>; spec: Record<string, any> | undefined; connectorId?: string; onboardingId?: string; } /** * @public */ export type GuideSectionBodyTab = { title: string; content: Omit<GuideSectionBody, 'tabs'>[]; }; /** * @public */ export type GuideSectionBodyTabs = GuideSectionBodyTab[]; /** * @public */ export type GuideSectionBody = { code?: string; codeLanguage?: string; image?: string; text?: any; tabs?: GuideSectionBodyTabs; shouldRender?: (values: any) => boolean; }; /** * @public */ export type GuideSection = { header?: string; bodies: GuideSectionBody[]; shouldRender?: (values: any) => boolean; }; /** * @public */ export interface GuideConfig { title: string | ((values: any) => string); sections: GuideSection[]; } /** * @public */ export type PluginConfigFormStep = { children: (IterableStepComponent | React.FC<any>)[]; title: string; submitGuard?: (formValues: Record<string, any>, teamName: string, setValue: (field: string, value: any) => void) => Promise<boolean | { errorMessage: string; }>; submitEnabledState?: (formValues: Record<string, any>) => { enabled: true; } | { enabled: false; errorMessage: string; }; guide?: React.FC | GuideConfig; }; /** * @public */ export interface PluginConfig { docsLink: string; steps: PluginConfigFormStep[]; stateSchema?: Record<string, yup.AnySchema>; errorCodes?: Record<string, string>; debug?: boolean; scriptUrl: string; } export interface Plugin { kind: string; name: string; team: string; version: string; } export interface PluginVersion { created_at: string; published_at?: string; name: string; message: string; draft: boolean; retracted: boolean; supported_targets: string[]; checksums: string[]; package_type: 'native' | 'docker'; spec_json_schema?: string; connector_required?: boolean; connector_types?: string[]; example_config: string; ui_base_url?: string; } export type UseConfigHook = (params: { initialValues?: InitialValues; plugin: Plugin; pluginVersion: PluginVersion; }) => PluginConfig; export type PrepareSubmitValues = (params: { config: PluginConfig; values: Record<string, any>; tables?: PluginTable[]; initialValues?: InitialValues; }) => FormValues; export type PluginUiWrapper = React.ComponentType<{ children: React.ReactNode; }>; export type ConvertTablesToServices = (params: { tables: CloudQueryTable[]; serviceLabelMap: Record<string, string>; serviceNameResolutions: Record<string, string>; }) => Service[]; export {}; //# sourceMappingURL=types.d.ts.map