import type { DataSourceChartDefinition } from './decorators/chart/types'; import type { TCollectionName, TSchema } from './templates'; import type { DataSourceOptions, Plugin } from './types'; import type { Collection, DataSource, DataSourceFactory, DataSourceSchema, Logger } from '@forestadmin/datasource-toolkit'; import CollectionCustomizer from './collection-customizer'; import CompositeDatasource from './decorators/composite-datasource'; import DecoratorsStack from './decorators/decorators-stack'; export type Options = { ignoreMissingSchemaElementErrors?: boolean; strategy?: 'Normal' | 'NoCode'; }; /** * Allow to create a new Forest Admin agent from scratch. * Builds the application by composing and configuring all the collection decorators. * * Minimal code to add a datasource * @example * new AgentBuilder(options) * .addDataSource(new SomeDataSource()) * .start(); */ export default class DataSourceCustomizer { protected compositeDataSource: CompositeDatasource; protected readonly stack: DecoratorsStack; /** * Retrieve schema of the agent */ get schema(): DataSourceSchema; /** * Get list of customizable collections */ get collections(): CollectionCustomizer[]; constructor(options?: Options); /** * Add a datasource * @param factory the datasource to add * @param options the options */ addDataSource(factory: DataSourceFactory, options?: DataSourceOptions, restartAgentFunction?: () => Promise): this; /** * Create a new API chart * @param name name of the chart * @param definition definition of the chart * @example * .addChart('numCustomers', { * type: 'Value', * render: (context, resultBuilder) => { * return resultBuilder.value(123); * } * }) */ addChart(name: string, definition: DataSourceChartDefinition): this; /** * Allow to interact with a decorated collection * @param name the name of the collection to manipulate * @param handle a function that provide a * collection builder on the given collection name * @example * .customizeCollection('books', books => books.renameField('xx', 'yy')) */ customizeCollection>(name: N, handle: (collection: CollectionCustomizer) => unknown): this; /** * Get given collection by name * @param name name of the collection */ getCollection>(name: N): CollectionCustomizer; /** * Find a collection by name. Returns undefined if the collection is missing * @param name name of the collection */ findCollection(name: string): CollectionCustomizer | undefined; /** * Remove collections from the exported schema (they will still be usable within the agent). * @param names the collections to remove * @example * .removeCollection('aCollectionToRemove', 'anotherCollectionToRemove'); */ removeCollection(...names: TCollectionName[]): this; /** * Load a plugin across all collections * @param plugin instance of the plugin * @param options options which need to be passed to the plugin * @example * import { advancedExport } from '@forestadmin/plugin-advanced-export'; * * dataSourceCustomizer.use(advancedExportPlugin, { format: 'xlsx' }); */ use(plugin: Plugin, options?: TOptions): this; getDataSource(logger: Logger): Promise; getFactory(): DataSourceFactory; updateTypesOnFileSystem(typingsPath: string, typingsMaxDepth: number, logger?: Logger): Promise; } //# sourceMappingURL=datasource-customizer.d.ts.map