@bsm-form/core 0.39.0 → 0.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _bsm_form_schema from '@bsm-form/schema';
2
- import { ToastVariant, ToastPosition, Condition, DisplayEventType, FieldEventType, TableInteraction, DialogEventType, DrawerEventType, RepeatOperation, Node, ActionNode, DisplayNode, FieldNode, LayoutNode, ValidationRule, FormSchema, TableTagValueMapping } from '@bsm-form/schema';
2
+ import { FormEnvValues, ToastVariant, ToastPosition, Condition, FormEnvConfig, DisplayEventType, FieldEventType, TableInteraction, DialogEventType, DrawerEventType, RepeatOperation, Node, ActionNode, DisplayNode, FieldNode, LayoutNode, ValidationRule, FormSchema, TableTagValueMapping, FormEnvDefinitions } from '@bsm-form/schema';
3
3
 
4
4
  type FormEngineNotification = {
5
5
  message: string;
@@ -9,6 +9,7 @@ type FormEngineNotification = {
9
9
  duration?: number;
10
10
  };
11
11
  type InvokeContext = {
12
+ env?: FormEnvValues;
12
13
  values: Record<string, unknown>;
13
14
  resources: Record<string, unknown>;
14
15
  row?: Record<string, unknown>;
@@ -25,6 +26,7 @@ type ValidatorHandler = (ctx: InvokeContext) => true | string;
25
26
  /** Sync computed value producer. Must not return a Promise. */
26
27
  type ComputerHandler = (ctx: InvokeContext) => unknown;
27
28
  type FormEngineEnvironment = {
29
+ env?: FormEnvValues;
28
30
  request: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
29
31
  log: (message: string) => void;
30
32
  navigate: (to: string) => void;
@@ -85,6 +87,9 @@ declare class FormEngine {
85
87
  private graph;
86
88
  private stepRunner;
87
89
  private environment;
90
+ private envConfig;
91
+ getEnvDefinitions(): _bsm_form_schema.FormEnvDefinitions;
92
+ getEnv(): FormEnvValues;
88
93
  private fieldNodes;
89
94
  private actionNodes;
90
95
  private displayNodes;
@@ -110,7 +115,7 @@ declare class FormEngine {
110
115
  private hasPendingStateUpdate;
111
116
  private initializationPromise?;
112
117
  private skipLoadStepsOnInitialize;
113
- constructor(runtimeTree: RuntimeNode, environment?: Partial<FormEngineEnvironment>);
118
+ constructor(runtimeTree: RuntimeNode, environment?: Partial<FormEngineEnvironment>, envConfig?: FormEnvConfig);
114
119
  runLoadSteps(): Promise<void>;
115
120
  initialize(options?: {
116
121
  skipLoadSteps?: boolean;
@@ -335,6 +340,7 @@ type FormSnapshot = {
335
340
  nodes: Map<string, RuntimeNode>;
336
341
  };
337
342
  type PipelineContext = {
343
+ env?: Readonly<Record<string, string | number | boolean>>;
338
344
  tree: RuntimeNode;
339
345
  values: FormValues;
340
346
  changedField: string;
@@ -509,6 +515,7 @@ declare const validationRegistry: ValidationRegistry;
509
515
 
510
516
  type ValidateFieldOptions = {
511
517
  environment?: FormEngineEnvironment;
518
+ env?: Readonly<Record<string, string | number | boolean>>;
512
519
  values?: Record<string, unknown>;
513
520
  resources?: Record<string, unknown>;
514
521
  row?: Record<string, unknown>;
@@ -588,4 +595,19 @@ declare function resolveTagValueMapping(value: unknown, map: Record<string, Tabl
588
595
  declare function tagMapKey(value: unknown): string | undefined;
589
596
  declare function formatTagSourceValue(value: unknown): string;
590
597
 
591
- export { type AccordionChangeReason, type AccordionChangeResult, type AccordionState, type ActionAdapterInput, type ActionContext, type ActionHandler, type ComputerHandler, DependencyGraph, type DependencyMap, type DialogState, type DialogTransitionReason, type DialogTransitionResult, type DisplayAdapterInput, type DrawerState, type DrawerTransitionReason, type DrawerTransitionResult, EventBus, type FieldAdapterInput, FormEngine, type FormEngineConfig, type FormEngineEnvironment, type FormEngineNotification, type FormEngineState, type FormErrors, type FormEvent, type FormSnapshot, type FormState, type FormValues, type InitializationStatus, type InvokeContext, type InvokeHandler, type LayoutAdapterInput, type Listener, type OptionsConfig, type PaginationChangeReason, type PaginationChangeResult, type PaginationState, type PipelineContext, type PredicateHandler, type RepeatMutationReason, type RepeatMutationResult, type RuntimeNode, type RuntimeNodeState, type RuntimeTree, type StepRunOptions, type StepperNavigationReason, type StepperNavigationResult, type StepperState, type TabsChangeReason, type TabsChangeResult, type TabsState, type ValidateFieldOptions, type ValidationResult, type Validator, type ValidatorHandler, adaptAction, adaptDisplay, adaptField, adaptLayout, compileSchema, conditions, createFormEngineEnvironment, createRuntimeNode, formatTagSourceValue, isThenable, resolveLoadingProp, resolveTagValueMapping, runConditionEngine, tagMapKey, traverseNode, validateField, validateSchema, validation, validationRegistry };
598
+ /** Validates syntax without reading values or running author code. */
599
+ declare function validateApiUrlTemplate(url: string): void;
600
+
601
+ type FormEnvReference = {
602
+ name: string;
603
+ path: string;
604
+ };
605
+ declare function collectFormEnvReferences(schema: unknown): FormEnvReference[];
606
+ declare function validateFormEnvReferences(schema: unknown, definitions?: FormEnvDefinitions): void;
607
+ declare function remapFormEnvReferences<T>(schema: T, previous: string, next: string): T;
608
+
609
+ declare function validateEnvBaseUrl(value: string): void;
610
+ declare function validateEnvDefinitions(value: unknown): asserts value is FormEnvDefinitions;
611
+ declare function resolveFormEnv(config?: FormEnvConfig, requireValues?: boolean): FormEnvValues;
612
+
613
+ export { type AccordionChangeReason, type AccordionChangeResult, type AccordionState, type ActionAdapterInput, type ActionContext, type ActionHandler, type ComputerHandler, DependencyGraph, type DependencyMap, type DialogState, type DialogTransitionReason, type DialogTransitionResult, type DisplayAdapterInput, type DrawerState, type DrawerTransitionReason, type DrawerTransitionResult, EventBus, type FieldAdapterInput, FormEngine, type FormEngineConfig, type FormEngineEnvironment, type FormEngineNotification, type FormEngineState, type FormErrors, type FormEvent, type FormSnapshot, type FormState, type FormValues, type InitializationStatus, type InvokeContext, type InvokeHandler, type LayoutAdapterInput, type Listener, type OptionsConfig, type PaginationChangeReason, type PaginationChangeResult, type PaginationState, type PipelineContext, type PredicateHandler, type RepeatMutationReason, type RepeatMutationResult, type RuntimeNode, type RuntimeNodeState, type RuntimeTree, type StepRunOptions, type StepperNavigationReason, type StepperNavigationResult, type StepperState, type TabsChangeReason, type TabsChangeResult, type TabsState, type ValidateFieldOptions, type ValidationResult, type Validator, type ValidatorHandler, adaptAction, adaptDisplay, adaptField, adaptLayout, collectFormEnvReferences, compileSchema, conditions, createFormEngineEnvironment, createRuntimeNode, formatTagSourceValue, isThenable, remapFormEnvReferences, resolveFormEnv, resolveLoadingProp, resolveTagValueMapping, runConditionEngine, tagMapKey, traverseNode, validateApiUrlTemplate, validateEnvBaseUrl, validateEnvDefinitions, validateField, validateFormEnvReferences, validateSchema, validation, validationRegistry };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _bsm_form_schema from '@bsm-form/schema';
2
- import { ToastVariant, ToastPosition, Condition, DisplayEventType, FieldEventType, TableInteraction, DialogEventType, DrawerEventType, RepeatOperation, Node, ActionNode, DisplayNode, FieldNode, LayoutNode, ValidationRule, FormSchema, TableTagValueMapping } from '@bsm-form/schema';
2
+ import { FormEnvValues, ToastVariant, ToastPosition, Condition, FormEnvConfig, DisplayEventType, FieldEventType, TableInteraction, DialogEventType, DrawerEventType, RepeatOperation, Node, ActionNode, DisplayNode, FieldNode, LayoutNode, ValidationRule, FormSchema, TableTagValueMapping, FormEnvDefinitions } from '@bsm-form/schema';
3
3
 
4
4
  type FormEngineNotification = {
5
5
  message: string;
@@ -9,6 +9,7 @@ type FormEngineNotification = {
9
9
  duration?: number;
10
10
  };
11
11
  type InvokeContext = {
12
+ env?: FormEnvValues;
12
13
  values: Record<string, unknown>;
13
14
  resources: Record<string, unknown>;
14
15
  row?: Record<string, unknown>;
@@ -25,6 +26,7 @@ type ValidatorHandler = (ctx: InvokeContext) => true | string;
25
26
  /** Sync computed value producer. Must not return a Promise. */
26
27
  type ComputerHandler = (ctx: InvokeContext) => unknown;
27
28
  type FormEngineEnvironment = {
29
+ env?: FormEnvValues;
28
30
  request: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
29
31
  log: (message: string) => void;
30
32
  navigate: (to: string) => void;
@@ -85,6 +87,9 @@ declare class FormEngine {
85
87
  private graph;
86
88
  private stepRunner;
87
89
  private environment;
90
+ private envConfig;
91
+ getEnvDefinitions(): _bsm_form_schema.FormEnvDefinitions;
92
+ getEnv(): FormEnvValues;
88
93
  private fieldNodes;
89
94
  private actionNodes;
90
95
  private displayNodes;
@@ -110,7 +115,7 @@ declare class FormEngine {
110
115
  private hasPendingStateUpdate;
111
116
  private initializationPromise?;
112
117
  private skipLoadStepsOnInitialize;
113
- constructor(runtimeTree: RuntimeNode, environment?: Partial<FormEngineEnvironment>);
118
+ constructor(runtimeTree: RuntimeNode, environment?: Partial<FormEngineEnvironment>, envConfig?: FormEnvConfig);
114
119
  runLoadSteps(): Promise<void>;
115
120
  initialize(options?: {
116
121
  skipLoadSteps?: boolean;
@@ -335,6 +340,7 @@ type FormSnapshot = {
335
340
  nodes: Map<string, RuntimeNode>;
336
341
  };
337
342
  type PipelineContext = {
343
+ env?: Readonly<Record<string, string | number | boolean>>;
338
344
  tree: RuntimeNode;
339
345
  values: FormValues;
340
346
  changedField: string;
@@ -509,6 +515,7 @@ declare const validationRegistry: ValidationRegistry;
509
515
 
510
516
  type ValidateFieldOptions = {
511
517
  environment?: FormEngineEnvironment;
518
+ env?: Readonly<Record<string, string | number | boolean>>;
512
519
  values?: Record<string, unknown>;
513
520
  resources?: Record<string, unknown>;
514
521
  row?: Record<string, unknown>;
@@ -588,4 +595,19 @@ declare function resolveTagValueMapping(value: unknown, map: Record<string, Tabl
588
595
  declare function tagMapKey(value: unknown): string | undefined;
589
596
  declare function formatTagSourceValue(value: unknown): string;
590
597
 
591
- export { type AccordionChangeReason, type AccordionChangeResult, type AccordionState, type ActionAdapterInput, type ActionContext, type ActionHandler, type ComputerHandler, DependencyGraph, type DependencyMap, type DialogState, type DialogTransitionReason, type DialogTransitionResult, type DisplayAdapterInput, type DrawerState, type DrawerTransitionReason, type DrawerTransitionResult, EventBus, type FieldAdapterInput, FormEngine, type FormEngineConfig, type FormEngineEnvironment, type FormEngineNotification, type FormEngineState, type FormErrors, type FormEvent, type FormSnapshot, type FormState, type FormValues, type InitializationStatus, type InvokeContext, type InvokeHandler, type LayoutAdapterInput, type Listener, type OptionsConfig, type PaginationChangeReason, type PaginationChangeResult, type PaginationState, type PipelineContext, type PredicateHandler, type RepeatMutationReason, type RepeatMutationResult, type RuntimeNode, type RuntimeNodeState, type RuntimeTree, type StepRunOptions, type StepperNavigationReason, type StepperNavigationResult, type StepperState, type TabsChangeReason, type TabsChangeResult, type TabsState, type ValidateFieldOptions, type ValidationResult, type Validator, type ValidatorHandler, adaptAction, adaptDisplay, adaptField, adaptLayout, compileSchema, conditions, createFormEngineEnvironment, createRuntimeNode, formatTagSourceValue, isThenable, resolveLoadingProp, resolveTagValueMapping, runConditionEngine, tagMapKey, traverseNode, validateField, validateSchema, validation, validationRegistry };
598
+ /** Validates syntax without reading values or running author code. */
599
+ declare function validateApiUrlTemplate(url: string): void;
600
+
601
+ type FormEnvReference = {
602
+ name: string;
603
+ path: string;
604
+ };
605
+ declare function collectFormEnvReferences(schema: unknown): FormEnvReference[];
606
+ declare function validateFormEnvReferences(schema: unknown, definitions?: FormEnvDefinitions): void;
607
+ declare function remapFormEnvReferences<T>(schema: T, previous: string, next: string): T;
608
+
609
+ declare function validateEnvBaseUrl(value: string): void;
610
+ declare function validateEnvDefinitions(value: unknown): asserts value is FormEnvDefinitions;
611
+ declare function resolveFormEnv(config?: FormEnvConfig, requireValues?: boolean): FormEnvValues;
612
+
613
+ export { type AccordionChangeReason, type AccordionChangeResult, type AccordionState, type ActionAdapterInput, type ActionContext, type ActionHandler, type ComputerHandler, DependencyGraph, type DependencyMap, type DialogState, type DialogTransitionReason, type DialogTransitionResult, type DisplayAdapterInput, type DrawerState, type DrawerTransitionReason, type DrawerTransitionResult, EventBus, type FieldAdapterInput, FormEngine, type FormEngineConfig, type FormEngineEnvironment, type FormEngineNotification, type FormEngineState, type FormErrors, type FormEvent, type FormSnapshot, type FormState, type FormValues, type InitializationStatus, type InvokeContext, type InvokeHandler, type LayoutAdapterInput, type Listener, type OptionsConfig, type PaginationChangeReason, type PaginationChangeResult, type PaginationState, type PipelineContext, type PredicateHandler, type RepeatMutationReason, type RepeatMutationResult, type RuntimeNode, type RuntimeNodeState, type RuntimeTree, type StepRunOptions, type StepperNavigationReason, type StepperNavigationResult, type StepperState, type TabsChangeReason, type TabsChangeResult, type TabsState, type ValidateFieldOptions, type ValidationResult, type Validator, type ValidatorHandler, adaptAction, adaptDisplay, adaptField, adaptLayout, collectFormEnvReferences, compileSchema, conditions, createFormEngineEnvironment, createRuntimeNode, formatTagSourceValue, isThenable, remapFormEnvReferences, resolveFormEnv, resolveLoadingProp, resolveTagValueMapping, runConditionEngine, tagMapKey, traverseNode, validateApiUrlTemplate, validateEnvBaseUrl, validateEnvDefinitions, validateField, validateFormEnvReferences, validateSchema, validation, validationRegistry };