UNPKG

@cloudquery/plugin-sdk-javascript

Version:

This is the high-level package to use for developing CloudQuery plugins in JavaScript

68 lines (67 loc) 2.25 kB
import type { Logger } from 'winston'; import type { SyncStream, ReadStream, WriteStream } from '../grpc/plugin.js'; import type { Table } from '../schema/table.js'; export type BackendOptions = { tableName: string; connection: string; }; export type TableOptions = { tables: string[]; skipTables: string[]; skipDependentTables: boolean; }; export type SyncOptions = { tables: string[]; skipTables: string[]; skipDependentTables: boolean; deterministicCQId: boolean; backendOptions: BackendOptions; stream: SyncStream; }; export type NewClientOptions = { noConnection: boolean; }; export type NewClientFunction = (logger: Logger, spec: string, options: NewClientOptions) => Promise<Client>; export type PluginKind = 'source' | 'destination'; export type BuildTarget = { os: 'linux' | 'darwin' | 'windows'; arch: 'amd64' | 'arm64'; }; export type PluginOptions = { team: string; kind: PluginKind; dockerFile?: string; buildTargets?: BuildTarget[]; jsonSchema?: string; }; export interface SourceClient { tables: (options: TableOptions) => Promise<Table[]>; sync: (options: SyncOptions) => void; } export interface DestinationClient { read: (stream: ReadStream) => void; write: (stream: WriteStream) => Promise<void>; } export interface Client extends SourceClient, DestinationClient { close: () => Promise<void>; } export interface Plugin extends Client { getLogger: () => Logger; setLogger: (logger: Logger) => void; name: () => string; version: () => string; team: () => string | undefined; kind: () => PluginKind | undefined; jsonSchema: () => string | undefined; dockerFile: () => string; buildTargets: () => BuildTarget[]; init: (spec: string, options: NewClientOptions) => Promise<void>; testConnection?: (spec: string) => Promise<{ success?: boolean; failureCode?: string; failureDescription?: string; }>; } export declare const newUnimplementedSource: () => SourceClient; export declare const newUnimplementedDestination: () => DestinationClient; export declare const newPlugin: (name: string, version: string, newClient: NewClientFunction, options?: PluginOptions) => Plugin;