Create a new Agent Builder. If any options are missing, the default will be applied:
forestServerUrl: 'https://api.forestadmin.com',
logger: (level, data) => console.error(level, data),
prefix: 'api/v1',
schemaPath: '.forestadmin-schema.json',
permissionsCacheDurationInSeconds: 15 * 60,
new AgentBuilder(options)
.addDataSource(new DataSource())
.start();
options
Protected
customizationProtected
customizerProtected
nocodeProtected
optionsCreate a new API chart
.addChart('numCustomers', (context, resultBuilder) => {
return resultBuilder.distribution({
tomatoes: 10,
potatoes: 20,
carrots: 30,
});
})
name of the chart
definition of the chart
the datasource to add
Optional
options: DataSourceOptionsthe options
Allow to interact with a decorated collection
.customizeCollection('books', books => books.renameField('xx', 'yy'))
the name of the collection to manipulate
a function that provide a collection builder on the given collection name
Protected
getProtected
mountExpose the agent on a given port and host
Optional
port: numberport that should be used, defaults to 3351 or to the PORT
environment variable.
O will be set a random available port and the port will be available in the standaloneServerPort
property.
Optional
host: stringhost that should be used, default to the unspecified IPv6 address (::) when IPv6 is available, or the unspecified IPv4 address (0.0.0.0) otherwise.
Protected
remountRemove collections from the exported schema (they will still be usable within the agent).
.removeField('aCollectionToRemove', 'anotherCollectionToRemove');
Rest
...names: Extract<keyof S, string>[]the collections to remove
Protected
sendSend the apimap to forest admin server
Load a plugin across all collections
import advancedExportPlugin from '@forestadmin/plugin-advanced-export';
agent.use(advancedExportPlugin, { format: 'xlsx' });
instance of the plugin
Optional
options: Optionsoptions which need to be passed to the plugin
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