createStaticStore()
Creates a Store from a pre-validated StaticValidatedMap.
type createStaticStore = (context: StoreContext, validatedMap: StaticValidatedMap) => Store;
Return value
Returns a Store that can be used to retrieve decision and resolve decision values.
Params
༶ context
: StoreContext
A context object that exposes the StoreOptions and collects eventual errors produced building the store.
༶ validatedMap
: StaticValidatedMap
Holds all decision input data and provides an API to retrieve validated records and validation errors.
Usage
The following is taken from the staticStoreBuilder() implementation.
14 collapsed lines
import { DEMO_DATA } from '@noodlestan/designer-decisions';import { type StoreOptions, createStoreContext, createDecisionValidator, createStaticValidatedMap loadDecisionsFromSources, loadSchemasFromSources, createStaticStore,} from '@noodlestan/designer-functions';
const options: StoreOptions = { decisions: [DEMO_DATA, './data'],};
const context = createStoreContext(options);const schemaMap = await loadSchemasFromSources(context);const validator = createDecisionValidator(context, schemaMap);
const loadedRecords = await loadDecisionsFromSources(context);const validatedMap = createStaticValidatedMap(context, loadedRecords, validator);