Skip to content

createStore()

Creates a Store from a pre-validated RecordMap.

type createStore = (validatedMap: RecordMap) => Store;

Return value

Returns a Store that can be used to retrieve decision and resolve decision values.

Params

validatedMap: RecordMap

Holds all decision input data and provides an API to retrieve validated records and validation errors.

 

Usage

The following is taken from the buildStaticStore() implementation.

14 collapsed lines
import { DEMO_DATA, createStore } from '@noodlestan/designer-decisions';
import {
type BuilderOptions,
createBuilderContext,
createDecisionValidator,
createRecordMap
loadDecisionsFromSources,
loadSchemasFromSources,
} from '@noodlestan/designer-functions';
const options: BuilderOptions = {
decisions: [DEMO_DATA, './data'],
};
const context = createBuilderContext(options);
const schemaMap = await loadSchemasFromSources(context);
const validator = createDecisionValidator(schemaMap);
const loadedRecords = await loadDecisionsFromSources(context);
const recordMap = createRecordMap(loadedRecords, validator);
const store = createStore(context, recordMap);

See also