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();

Type Parameters

Hierarchy

  • DataSourceCustomizer

Constructors

Accessors

  • get collections(): CollectionCustomizer<S, Extract<keyof S, string>>[]
  • Get list of customizable collections

    Returns CollectionCustomizer<S, Extract<keyof S, string>>[]

  • get schema(): DataSourceSchema
  • Retrieve schema of the agent

    Returns DataSourceSchema

Methods

  • Create a new API chart

    Example

    .addChart('numCustomers', {
    type: 'Value',
    render: (context, resultBuilder) => {
    return resultBuilder.value(123);
    }
    })

    Parameters

    Returns DataSourceCustomizer<S>

  • Allow to interact with a decorated collection

    Example

    .customizeCollection('books', books => books.renameField('xx', 'yy'))
    

    Type Parameters

    • N extends string

    Parameters

    • name: N

      the name of the collection to manipulate

    • handle: ((collection: CollectionCustomizer<S, N>) => unknown)

      a function that provide a collection builder on the given collection name

    Returns DataSourceCustomizer<S>

  • Find a collection by name. Returns undefined if the collection is missing

    Parameters

    • name: string

      name of the collection

    Returns CollectionCustomizer<S, Extract<keyof S, string>>

  • Get given collection by name

    Type Parameters

    • N extends string

    Parameters

    • name: N

      name of the collection

    Returns CollectionCustomizer<S, N>

  • Remove collections from the exported schema (they will still be usable within the agent).

    Example

    .removeCollection('aCollectionToRemove', 'anotherCollectionToRemove');
    

    Parameters

    • Rest ...names: Extract<keyof S, string>[]

      the collections to remove

    Returns DataSourceCustomizer<S>

  • Parameters

    • typingsPath: string
    • typingsMaxDepth: number
    • Optional logger: Logger

    Returns Promise<void>

  • Load a plugin across all collections

    Example

    import { advancedExport } from '@forestadmin/plugin-advanced-export';

    dataSourceCustomizer.use(advancedExportPlugin, { format: 'xlsx' });

    Type Parameters

    • TOptions

    Parameters

    • plugin: Plugin<TOptions>

      instance of the plugin

    • Optional options: TOptions

      options which need to be passed to the plugin

    Returns DataSourceCustomizer<S>