UNPKG

@impler/client

Version:

API client to be used in end user environments

186 lines 5.66 kB
import { WIDGET_TEXTS } from './config'; import { ButtonConfig } from './config/appearance.config'; export declare const ColumnTypes: { readonly STRING: "String"; readonly NUMBER: "Number"; readonly DATE: "Date"; readonly EMAIL: "Email"; readonly REGEX: "Regex"; readonly SELECT: "Select"; readonly ANY: "Any"; readonly DOUBLE: "Double"; readonly IMAGE: "Image"; }; export declare const ValidationTypes: { readonly RANGE: "range"; readonly LENGTH: "length"; readonly UNIQUE_WITH: "unique_with"; }; export declare const EventTypes: { readonly INIT_IFRAME: "INIT_IFRAME"; readonly WIDGET_READY: "WIDGET_READY"; readonly CLOSE_WIDGET: "CLOSE_WIDGET"; readonly AUTHENTICATION_VALID: "AUTHENTICATION_VALID"; readonly AUTHENTICATION_ERROR: "AUTHENTICATION_ERROR"; readonly UPLOAD_STARTED: "UPLOAD_STARTED"; readonly UPLOAD_TERMINATED: "UPLOAD_TERMINATED"; readonly UPLOAD_COMPLETED: "UPLOAD_COMPLETED"; readonly DATA_IMPORTED: "DATA_IMPORTED"; readonly IMPORT_JOB_CREATED: "IMPORT_JOB_CREATED"; }; export interface IUpload { _id: string; _templateId: string; _uploadedFileId: string; _allDataFileId: string; _validDataFileId: string; _invalidDataFileId: string; invalidCSVDataFileUrl: string; originalFileName: string; originalFileType: string; headings: string[]; uploadedDate: Date; totalRecords: number; validRecords: number; invalidRecords: number; authHeaderValue: string; status: string; extra: string; __v: number; processInvalidRecords: boolean; customRecordFormat: string; customChunkFormat: string; } export interface IUserJob { _id: string; url: string; _templateId: string; headings: string[]; cron: string; } export declare enum ValidationTypesEnum { RANGE = "range", LENGTH = "length", UNIQUE_WITH = "unique_with" } export declare type RangeValidationType = { validate: 'range' | ValidationTypesEnum.RANGE; min?: number; max?: number; errorMessage?: string; }; export declare type LengthValidationType = { validate: 'length' | ValidationTypesEnum.LENGTH; min?: number; max?: number; errorMessage?: string; }; export declare type UniqueWithValidationType = { validate: 'unique_with' | ValidationTypesEnum.UNIQUE_WITH; uniqueKey: string; errorMessage?: string; }; export declare type ValidationType = RangeValidationType | LengthValidationType | UniqueWithValidationType; export interface ISchemaItem { key: string; name: string; description?: string; alternateKeys?: string[]; isRequired?: boolean; isUnique?: boolean; isFrozen?: boolean; defaultValue?: string | '<<null>>' | '<<undefined>>' | '<<>>' | '<<[]>>' | '<<true>>' | '<<false>>'; selectValues?: string[]; dateFormats?: string[]; type?: ValueOf<typeof ColumnTypes>; regex?: string; allowMultiSelect?: boolean; validations?: ValidationType[]; } export declare type UploadTemplateData = { uploadId: string; templateId: string; }; export declare type UploadData = { uploadId: string; }; export declare type EventCalls = { type: typeof EventTypes.UPLOAD_STARTED; value: UploadTemplateData; } | { type: typeof EventTypes.UPLOAD_TERMINATED; value: UploadData; } | { type: typeof EventTypes.UPLOAD_COMPLETED; value: IUpload; } | { type: typeof EventTypes.DATA_IMPORTED; value: Record<string, any>[]; } | { type: typeof EventTypes.IMPORT_JOB_CREATED; value: IUserJob; } | { type: typeof EventTypes.CLOSE_WIDGET; } | { type: typeof EventTypes.WIDGET_READY; }; export interface IShowWidgetProps { colorScheme?: 'light' | 'dark'; schema?: ISchemaItem[]; data?: Record<string, string | any>[]; output?: Record<string, string | any>; projectId: string; templateId: string; accessToken: string; sampleFile?: File | Blob; texts?: CustomTexts; config?: WidgetConfig; appearance?: AppearanceConfig; maxRecords?: number; title?: string; primaryColor?: string; extra?: string | Record<string, any>; authHeaderValue?: string | (() => string) | (() => Promise<string>); } export declare type DeepPartial<T> = T extends object ? { [P in keyof T]?: DeepPartial<T[P]>; } : T; export declare type ValueOf<T> = T[keyof T]; export declare type WidgetConfig = { hideFindAndReplaceButton?: boolean; hideDeleteButton?: boolean; hideCheckBox?: boolean; hideSrNo?: boolean; hideDownloadSampleButton?: boolean; }; export declare type AppearanceConfig = { widget?: { backgroundColor?: string; }; primaryColor?: string; fontFamily?: string; borderRadius?: string; primaryButtonConfig?: ButtonConfig; secondaryButtonConfig?: ButtonConfig; }; export declare type CustomTexts = DeepPartial<typeof WIDGET_TEXTS>; export interface IUseImplerProps { title?: string; texts?: CustomTexts; projectId?: string; templateId?: string; accessToken?: string; primaryColor?: string; extra?: string | Record<string, any>; config?: WidgetConfig; appearance?: AppearanceConfig; maxRecords?: number; authHeaderValue?: string | (() => string) | (() => Promise<string>); onUploadStart?: (value: UploadTemplateData) => void; onUploadTerminate?: (value: UploadData) => void; onUploadComplete?: (value: IUpload) => void; onDataImported?: (importedData: Record<string, any>[]) => void; onWidgetClose?: () => void; onImportJobCreated?: (jobInfo: IUserJob) => void; } //# sourceMappingURL=types.d.ts.map