UNPKG

@tableau/taco-toolkit

Version:
61 lines (60 loc) 2.27 kB
import { TacoFileParserName } from '../enums/taco-file-parser'; /** * Represents an input type for handlers, allowing flexibility between basic and file-based inputs. * * @typedef {Object} HandlerInput * @template Data - The type of data that the handler input can carry. * @property {BasicHandlerInput<Data> | FileBasedHandlerInput<Data>} input - The actual handler input, which can be either basic or file-based. * * @example * ```ts * // Usage with basic handler input * const basicHandlerInputObj: HandlerInput = { * fetcher: 'my-fetcher', * parser: 'my-parser', * data: [], * } * * // Usage with file-based handler input * const fileBasedHandlerInputObj: HandlerInput = { * fetcher: 'my-fetcher', * parser: <TacoFileParserName> // "taco:excel-file-parser" | "taco:csv-file-parser" | "taco:parquet-file-parser" | "taco:data-file-parser", * data: [], * name: 'table-name', * } * ``` */ export type HandlerInput<Data = any> = BasicHandlerInput<Data> | FileBasedHandlerInput<Data> | IngestorHandlerInput<Data>; /** * The object type sent by the connector app to handlers. * * The object is used to perform data extraction. * */ export interface BasicHandlerInput<Data> { /** File name of connector authenticator */ auth?: string; /** File name of connector fetcher */ fetcher: string; /** File name of connector parser */ parser: string; /** Arbitrary data sent to the connector fetcher */ data: Data; } export declare function isBasicHandlerInput<D>(input: unknown): input is BasicHandlerInput<D>; /** * The object type sent by the connector app to handlers for data source with large data. */ export interface FileBasedHandlerInput<Data> extends BasicHandlerInput<Data> { /** Built-in parser name */ parser: TacoFileParserName; /** Identifier of source object, will be used as table name */ name: string; } export declare function isFileBasedHandlerInput<D>(input: unknown): input is FileBasedHandlerInput<D>; export interface IngestorHandlerInput<Data> { ingestor: string; data: Data; } export declare function isIngestorHandlerInput<D>(input: unknown): input is IngestorHandlerInput<D>; export declare function isValidHandlerInput(input: unknown): input is HandlerInput;