@directus/api
Version:
Directus is a real-time API and App dashboard for managing SQL database content
45 lines (44 loc) • 1.99 kB
TypeScript
import type { AbstractServiceOptions, Accountability, DirectusError, ExportFormat, File, Query, SchemaOverview } from '@directus/types';
import type { Knex } from 'knex';
import type { Readable } from 'node:stream';
import type { FieldNode, FunctionFieldNode, NestedCollectionNode } from '../types/index.js';
export declare function createErrorTracker(): {
addCapturedError: (err: any, rowNumber: number) => void;
buildFinalErrors: () => DirectusError<any>[];
getCount: () => number;
hasErrors: () => boolean;
shouldStop: () => boolean;
hasGenericError: () => boolean;
};
export declare class ImportService {
knex: Knex;
accountability: Accountability | null;
schema: SchemaOverview;
constructor(options: AbstractServiceOptions);
import(collection: string, mimetype: string, stream: Readable): Promise<void>;
importJSON(collection: string, stream: Readable): Promise<void>;
importCSV(collection: string, stream: Readable): Promise<void>;
}
export declare class ExportService {
knex: Knex;
accountability: Accountability | null;
schema: SchemaOverview;
constructor(options: AbstractServiceOptions);
/**
* Export the query results as a named file. Will query in batches, and keep appending a tmp file
* until all the data is retrieved. Uploads the result as a new file using the regular
* FilesService upload method.
*/
exportToFile(collection: string, query: Partial<Query>, format: ExportFormat, options?: {
file?: Partial<File>;
}): Promise<void>;
/**
* Transform a given input object / array to the given type
*/
transform(input: Record<string, any>[], format: ExportFormat, options?: {
includeHeader?: boolean;
includeFooter?: boolean;
fields?: string[] | null;
}): string;
}
export declare function getHeadingsForCsvExport(nodes: (NestedCollectionNode | FieldNode | FunctionFieldNode)[] | undefined, prefix?: string): string[];