@flatfile/safe-api
Version:
Flatfile Safe API client with streaming capabilities
114 lines (113 loc) • 3.9 kB
TypeScript
import { Collection } from '@flatfile/records';
import { GetRequest } from '../utils/requests/get.request';
import { PostRequest } from '../utils/requests/post.request';
import { FlatfileRecord, SimpleRecord, Primitive } from '@flatfile/records';
import { Flatfile } from '@flatfile/api';
import { RetryOptions } from "../utils/requests/safe.request";
export interface StreamRecordsQuery {
sheetId?: string;
workbookId?: string;
stream?: boolean;
includeMetadata?: boolean;
includeMessages?: boolean;
includeConfig?: boolean;
includeSheet?: boolean;
includeSheetSlug?: boolean;
noContext?: boolean;
}
export interface StreamRecordsPatchQuery {
sheetId?: string;
workbookId?: string;
stream?: boolean;
truncate?: boolean;
snapshot?: boolean;
silent?: boolean;
}
export declare class CreateRecordsRequest extends PostRequest<{
commitId?: string;
success: boolean;
}, SimpleRecord[]> {
retry: boolean;
path: string;
constructor(sheetId: string, records: SimpleRecord[], options?: RetryOptions);
}
export declare class GetRecordCountsRequest extends GetRequest<Flatfile.RecordCounts> {
path: string;
constructor(sheetId: string, opts?: Flatfile.GetRecordCountsRequest, options?: RetryOptions);
protected parseBody(body?: Record<string, any>): Promise<Flatfile.RecordCounts>;
}
/**
* Request class for getting full record data with metadata and configuration
*/
export declare class StreamRecordsRequest extends GetRequest<FlatfileRecord<any>[]> {
path: string;
isRaw: boolean;
_headers: {
Accept: string;
};
constructor(opts?: StreamRecordsQuery, options?: RetryOptions);
protected parseBody(body: any): Promise<FlatfileRecord<any>[]>;
}
/**
* Request class for getting simplified record data without internal metadata
*/
export declare class SimpleStreamRecordsRequest extends GetRequest<Array<SimpleRecord>> {
path: string;
isRaw: boolean;
_headers: {
Accept: string;
};
constructor(opts?: StreamRecordsQuery, options?: RetryOptions);
protected parseBody(body: any): Promise<Array<SimpleRecord>>;
}
/**
* Request class for getting raw JSONL record data
*/
export declare class RawRecordsRequest extends GetRequest<Record<string, any>[]> {
path: string;
isRaw: boolean;
_headers: {
Accept: string;
};
constructor(opts?: StreamRecordsQuery, options?: RetryOptions);
protected parseBody(body?: Record<string, any>): Promise<any[]>;
}
/**
* Request class for updating records using JSONL format
*/
export declare class StreamRecordsUpdate extends PostRequest<{
success: true;
}, Collection<FlatfileRecord<any>>> {
protected opts: StreamRecordsPatchQuery;
path: string;
isRaw: boolean;
_headers: {
"Content-Type": string;
};
constructor(opts: StreamRecordsPatchQuery, payload: Collection<FlatfileRecord<any>>, options?: RetryOptions);
afterSuccess(): void;
protected parseBody(_body: any): Promise<{
success: true;
}>;
protected serializeBody(records: Collection<FlatfileRecord<any>>): string;
}
export declare class RawRecordsUpsert extends PostRequest<{
success: true;
}, Array<Record<string, Primitive>>> {
protected opts: StreamRecordsPatchQuery;
path: string;
isRaw: boolean;
_headers: {
"Content-Type": string;
"Content-Encoding": string;
};
constructor(opts: StreamRecordsPatchQuery, payload: Array<Record<string, Primitive>>, options?: RetryOptions);
protected parseBody(_body: any): Promise<{
success: true;
}>;
protected serializeBody(records: Array<Record<string, Primitive>>): string;
}
export declare class GetRecordsRequest extends GetRequest<Flatfile.RecordsResponse> {
path: string;
constructor(sheetId: string, query?: Record<string, any>, options?: RetryOptions);
}