// Type definitions for @hotglue/widget 1.4 // Project: https://github.com/baz/foo (Does not have to be to GitHub, but prefer linking to a source code repository rather than to a project website.) // Definitions by: Breno // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// export as namespace hotglue__widget; export type Config = { envId: string; apiKey: string; apiUrl?: string; }; interface HotglueConfig { config: Config; } interface InnerOptions { isTarget?: boolean; isConnector?: boolean; tenantMetadata?: unknown; } /** * Hotglue Hook that returns functions to handle the hotglue widget * @returns { * link: (tenant: string, flow: string, id: string, preloaded: boolean, options: LinkOptions) => {}; * setListener: (listener: Listener) => {}; * setSchema: (schemas: Array) => {}; * setMetadata: (metadata: Metadata) => {}; * reconnect: (tenant: string, flow: string, entityId: string, options: Options) => Promise; * disconnect: (tenant: string, flow: string, entityId: string, options: Options) => Promise; * createJob: (flow: string, tenant: string) => Promise; * runJob: (entityId: string, flow: string, tenant: string, startDate: string, jobType: 'read' | 'write') => Promise; * getLinkedSources: (flow: string, tenant: string) => Promise; * getLinkedConnectors: (flow: string, tenant: string) => Promise; * getLinkedTargets: (flow: string, tenant: string) => Promise; * getAvailableSources: () => Promise; * getAvailableConnectors: () => Promise; * getAvailableTargets: () => Promise; * getSupportedSources: (flow: string) => Promise; * getSupportedTargets: (flow: string) => Promise; * getSupportedConnectors: (flow: string) => Promise; * pollJob: (jobRoot, flow, tenant) => Promise, * getLinkedFlows: (tenant: string) => Promise; * openWidget: (tenant: string, options: Options) => {}; * setOptions: (options: Options) => void; * close: () => {}; * } * */ type LinkOptions = Options & InnerOptions; type HotglueHandlers = { /** * Directly open on the link screen of the widget with givin parameters values * @param tenant * @param flow * @param id * @param preloaded * @param options * @returns * @example * const { link } = useHotglue(); * link('tenant', 'flow', 'id', false, { filter: { flowFilter: (flow) => flow.id === 'flow' } }); * */ link: (tenant: string, flow: string, id: string, preloaded?: boolean, options?: LinkOptions) => {}; /** * a hook to set the options. * @param options set the options by passing a object of the schema Options * @returns */ setOptions: (options: Options) => {}; /** * Updates current listener configuration to specified listener object * @param listener * @returns * @example * const { setListener } = useHotglue(); * setListener({ * onWidgetOpen: () => { * console.log('Widget opened'); * }, */ setListener: (listener: Listener) => {}; /** * Set the schemas to be used for the mapping for this user. * Accepts an optional schemaOptions object to configure the schema mapping behavior. * e.g: * ``` * const { setSchema } = useHotglue(); * setSchema([{ * flowId: 'SgRPndCVr', * schema: [{ * table: 'users', * fields: [ * { id: 'id', name: "Id" }, * { id: 'email', name: 'Email' }, * { id: "phone_number", name: "Phone Number" } * ] * }] * }], { enforceOneToOneMapping: true }); * ``` * @param schemas * @param schemaOptions - e.g. `{ enforceOneToOneMapping: true }` */ setSchema: (schemas: Array, schemaOptions?: SchemaOptions) => {}; pollJob: (jobRoot: string, flow: string, tenant: string) => Promise; /** * Set the metadata of the current tenant * @param metadata * @returns * @example * const { setMetadata } = useHotglue(); * setMetadata({ name: 'Batman' }); */ setMetadata: (metadata: Metadata) => {}; /** * Reconnect the following entity to the given flow, tenant and entityId values * @param tenant * @param flow * @param entityId * @param options * @returns * @example * const { reconnect } = useHotglue(); * reconnect('test-tenant-id', 'nxhEl23', 'salesforce'}); */ reconnect: (tenant: string, flow: string, entityId: string, options?: Options & InnerOptions) => Promise; /** * Disconnect the following entity from the given flow, tenant and entityId values * @param tenant * @param flow * @param entityId * @param options * @returns * @example * const { disconnect } = useHotglue(); * disconnect('test-tenant-id', 'nxhEl23', 'salesforce'}); */ disconnect: (tenant: string, flow: string, entityId: string, options?: Options & InnerOptions) => Promise; /** * @deprecated you should use runJob instead * Directly create a job without need of open the widget. * @param flow * @param tenant * @param startDate * @returns * @example * const { createJob } = useHotglue(); * createJob('flow', 'tenant'); */ createJob: (flow: string, tenant: string, startDate: string) => Promise; /** * Directly create a job without need of open the widget. * @param entityId * @param flow * @param tenant * @param startDate * @param jobType * @returns * @example * const { createJob } = useHotglue(); * createJob('flow', 'tenant'); */ runJob: ( entityId: string, flow: string, tenant: string, startDate: string, jobType: 'read' | 'write', ) => Promise; /** * Get the linked sources of the given flow and tenant values * @param flow * @param tenant * @returns * @example * const { getLinkedSources } = useHotglue(); * getLinkedSources('flow', 'tenant'); */ getLinkedSources: (flow: string, tenant: string) => Promise; /** * Get the linked sources of the given flow and tenant values * @param flow * @param tenant * @returns * @example * const { getLinkedConnectors } = useHotglue(); * getLinkedConnectors('flow', 'tenant'); */ getLinkedConnectors: (flow: string, tenant: string) => Promise; /** * Get the linked sources of the given flow and tenant values * @param flow * @param tenant * @returns * @example * const { getLinkedTargets } = useHotglue(); * getLinkedTargets('flow', 'tenant'); */ getLinkedTargets: (flow: string, tenant: string) => Promise; getAvailableSources: () => Promise; getAvailableConnectors: () => Promise; getAvailableTargets: () => Promise; getSupportedSources: (flow: string) => Promise; getSupportedTargets: (flow: string) => Promise; getSupportedConnectors: (flow: string) => Promise; /** * Get the linked flows of the given tenant value * @param tenant * @returns * @example * const { getLinkedFlows } = useHotglue(); * getLinkedFlows('tenant'); */ getLinkedFlows: (tenant: string) => Promise; /** * Open the widget under the given tenant with the given options * @param tenant * @param options * @returns * @example * const { openWidget } = useHotglue(); * openWidget('tenant', { filter: { flowFilter: (flow) => flow.id === 'flow' } }); * */ openWidget: (tenant: string, options?: Options) => {}; /** * It will close the widget. */ close: () => {}; }; export function useHotglue(): HotglueHandlers; export type Listener = { onWidgetOpen?: () => {}; onWidgetClose?: () => {}; onReconnect?: (entityId: string, flow: string) => {}; onPopupClose?: (id: string, flowId: string) => {}; onTargetLinked?: (target: { [x: string]: any }, flowId: string) => {}; onSourceLinked?: (source: { [x: string]: any }, flowId: string, tenantId: string) => {}; onConnectorLinked?: (connector: { [x: string]: any }, flowId: string, tenantId: string) => {}; onSourceLinkCanceled?: (tapId: string, flowId: string) => {}; onConnectorLinkCanceled?: (connectorId: string, flowId: string) => {}; onSourceUnlinked?: (source: string, flowId: string) => {}; onConnectorUnlinked?: (connector: string, flowId: string) => {}; onSourceLinkFailed?: (source: string | Object, flowId: string, tenant: string, errorMessage: string) => {}; onConnectorLinkFailed?: (connector: string | Object, flowId: string, tenant: string, errorMessage: string) => {}; onTargetLinkFailed?: (target: string | Object, flowId: string, tenant: string, errorMessage: string) => {}; onStartJob?: (tap_id: string, flow_id: string, user_id: string) => {}; onFieldMapSave?: (entityId: string, flowId: string, tenantId: string) => {}; onCustomMappingSave?: (entityId: string, flowId: string, tenantId: string) => {}; onScheduleSave?: (oldSchedule: string, newSchedule: string, entityId: string, flowId: string, tenantId: string) => {}; }; type SchemaOptions = { enforceOneToOneMapping?: boolean; }; export interface Options { filter?: { flowFilter: (flow: any) => {}; }; listener?: Listener; localization?: Localization; demo?: Boolean; breadcrumbs?: Boolean; multipleSources?: Boolean; multipleConnectors?: Boolean; multipleTables?: Boolean; hideBackButtons?: Boolean; flow?: string; jwtToken?: string; nextStep?: string; helperText?: string; subTenantsEnabled?: Boolean; showSubTenantsId?: Boolean; hideJobStatusBadge?: Boolean; credentialsFormValidator?: ( oldConfig: TConfig, newConfig: TConfig, availableEntity: Record, flowId: string, tenantId: string ) => Promise<{ errorMessage?: string; success: boolean }>; } type Table = { table: string; fields: Array; }; type Fields = { id: string; name: string; }; export type Schemas = { flowId: string; schema: Array; }; export type Metadata = { [x: string]: any; }; export type ConnectionsProps = { tenant: string; helperText?: string; filterFlow?: (flow: string) => boolean; filterEntity?: (flowId: string, entityId: string, isTarget: Boolean) => Boolean; shouldDisable?: (flowId: string, entityId: string) => Boolean; localization?: Localization; hideFlows?: Boolean; connectionName?: string; multipleSources?: Boolean; multipleConnectors?: Boolean; hideBackButtons?: Boolean; operation?: 'link' | 'unlink'; nextStep?: string; }; export interface StartingScreen { header?: string; subtitle?: string; } export interface ConnectSourceScreen { instructionText?: string; connectDataButtonText?: string; saveConfigurationButtonText?: string; } export interface CopySourceScreen { header?: string; actionButton?: string; } export interface QuickActions { runJobsTitle?: string; runJobsSubtitle?: string; editFieldMapTitle?: string; editFieldMapSubtitle?: string; reconnectTitle?: string; reconnectSubtitle?: string; editScheduleTitle?: string; editScheduleSubtitle?: string; unlinkTitle?: string; unlinkSubtitle?: string; } export interface JobHistory { noJobsCaption?: string; } export interface SearchSource { searchSourceText?: string; noSourceCaption?: string; noSourceAvailableCaption?: string; } export interface SearchTarget { searchTargetText?: string; noTargetCaption?: string; noTargetAvailableCaption?: string; } export interface CustomMapping { loadingTitle?: string; loadingDescription?: string; } export interface FieldMap { loadingTitle?: string; loadingDescription?: string; } export interface MappingRowCard { header?: string; subtitle?: string; } export interface connectorTabsLocalization { quickActions?: string; credentials?: string; jobHistory?: string; mapping?: string; triggers?: string; uploadFiles?: string; } export interface Localization { startingScreen?: StartingScreen; connectSourceScreen?: ConnectSourceScreen; copySourceScreen?: CopySourceScreen; quickActions?: QuickActions; jobHistory?: JobHistory; searchSource?: SearchSource; searchTarget?: SearchTarget; customMapping?: CustomMapping; fieldMap?: FieldMap; mappingRowCard?: MappingRowCard; connectorManagementTabs?: connectorTabsLocalization; } /** * A component that will render a list of cards with all the connections that you have supported at Hotglue. */ export function Connections(props: React.PropsWithoutRef): JSX.Element | React.ReactElement; /** * An wrapper that loads mounts the Hotglue Widget. * @param props * @example * * * */ export default function HotglueConfig(props: React.PropsWithChildren): JSX.Element | React.ReactElement;