staticStoreBuilder()
type staticStoreBuilder = (options: StoreOptions) => () => Promise<Store>;
Return value
() => Promise<Store>
A builder function that resolves with a populated decision store.
Builder implementation
Given a list of paths and schemas configs:
- Loads schemas from paths and creates a schema map.
- Validates the schema map and creates a validator.
- Loads all decisions files and merges all data.
- Validates decision inputs.
- Populates and returns a decision Store.
Params
༶ context
: StoreContext
A context object that exposes the StoreOptions and collects eventual errors produced building the store.
It is recommended to declare the options object directly in a dd.config.mjs
file in the root of the project and then load it via loadConfig().
Usage
Recommended:
Using the dd.config.mjs
configuration file and loadConfig().
import { loadConfig, createStoreContext, staticStoreBuilder } from '@noodlestan/designer-functions';
const config = await loadConfig();const context = createStoreContext(config.store);const build = staticStoreBuilder(context);
const store = await build();
Building the options object manually:
7 collapsed lines
import { DEMO_DATA } from '@noodlestan/designer-decisions';import { type StoreOptions, createStoreContext, staticStoreBuilder,} from '@noodlestan/designer-functions';
const options: StoreOptions = { decisions: [DEMO_DATA, './data'],};const context = createStoreContext(options);const build = staticStoreBuilder(context);
const store = await build();