@inixiative/json-rules 3.16.0 → 3.18.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
@@ -599,6 +599,13 @@ type ListBindingsOptions = {
599
599
  * another is required.
600
600
  */
601
601
  declare const listBindings: (condition: Condition, { required }?: ListBindingsOptions) => string[];
602
+ /**
603
+ * The paths a rule reads from the row it is checked on, sorted: each leaf's `field` and each
604
+ * `{ path }` on its value side. A relation node (`arrayOperator`, `aggregate`) contributes its own
605
+ * field; what its `condition` / `filter` read is relative to the related rows, so it is not listed.
606
+ * For a caller that must load what a rule reads before checking it (a hydrator).
607
+ */
608
+ declare const listFields: (condition: Condition) => string[];
602
609
  /**
603
610
  * Substitute covered binds with their values; uncovered tokens stay in place (partial
604
611
  * resolution). A supplied-but-undefined binding becomes null to stay serializable.
@@ -657,25 +664,47 @@ type EngineGlobalsState = {
657
664
  finestUnit: ClockUnit | RelativeUnit;
658
665
  };
659
666
  };
660
- /** Each path `engineGlobals` reads and writes, and the values it takes. */
661
- type EngineGlobalValues = {
667
+ /**
668
+ * Each path `engineGlobals` reads and writes, and the values it takes. An interface, so a library
669
+ * built on the engine adds its own namespace's paths by module augmentation:
670
+ *
671
+ * ```ts
672
+ * declare module '@inixiative/json-rules' {
673
+ * interface EngineGlobalValues { 'permissions.idField': string }
674
+ * }
675
+ * ```
676
+ */
677
+ interface EngineGlobalValues {
662
678
  'string.caseInsensitive': EngineGlobalsState['string']['caseInsensitive'];
663
679
  'string.fuzzy': EngineGlobalsState['string']['fuzzy'];
664
680
  'prismaOptions.datasource.provider': EngineGlobalsState['prismaOptions']['datasource']['provider'];
665
681
  'prismaOptions.anyNull': EngineGlobalsState['prismaOptions']['anyNull'];
666
682
  'sql.dialect': EngineGlobalsState['sql']['dialect'];
667
683
  'clock.finestUnit': EngineGlobalsState['clock']['finestUnit'];
668
- };
684
+ }
669
685
  type EngineGlobalPath = keyof EngineGlobalValues;
686
+ /** The defaults a namespace registers: its paths, relative to the namespace. */
687
+ type EngineGlobalDefaults<N extends string> = {
688
+ [P in EngineGlobalPath as P extends `${N}.${infer K}` ? K : never]: EngineGlobalValues[P];
689
+ };
670
690
  type DeepPartial<T> = {
671
691
  [K in keyof T]?: T[K] extends object ? DeepPartial<T[K]> : T[K];
672
692
  };
693
+ type Overrides = Partial<EngineGlobalValues> | DeepPartial<EngineGlobalsState>;
694
+ /**
695
+ * Register a library's namespace of engine globals and its defaults. A library built on the
696
+ * engine calls this at the top of the module that reads the setting, for its own namespace only.
697
+ * Defaults go in under any value already set (an app may configure a library before importing
698
+ * it). Registering the same defaults again is a no-op (a second installed copy of the library);
699
+ * different defaults, a dotted namespace or one of the engine's own roots throw.
700
+ */
701
+ declare const registerEngineGlobals: <N extends string>(namespace: N, defaults: EngineGlobalDefaults<N>) => void;
673
702
  /** Process-wide defaults, read and written by dotted path (`EngineGlobalPath`). */
674
703
  declare const engineGlobals: {
675
704
  set: <P extends EngineGlobalPath>(path: P, value: EngineGlobalValues[P]) => void;
676
705
  get: <P extends EngineGlobalPath>(path: P) => EngineGlobalValues[P];
677
706
  reset: () => void;
678
- with: <T>(partial: DeepPartial<EngineGlobalsState>, fn: () => T) => T;
707
+ with: <T>(overrides: Overrides, fn: () => T) => T;
679
708
  };
680
709
 
681
710
  /** A caller's input missing or malformed — the clock, the time zone, a bind's value — not the
@@ -1380,4 +1409,4 @@ declare const getConditionShapeKeys: (shape: ConditionShape) => ConditionShapeKe
1380
1409
  */
1381
1410
  declare const orderRecords: <T>(items: readonly T[], orderBy: OrderBy) => T[];
1382
1411
 
1383
- export { ALL_KINDS, type Absent, type AggregateMode, type AggregateRule, type All, type Any, ArrayOperator, type ArrayRule, type Bridge, type BridgeCardinality, type BridgeDictionary, type BridgeEndpoint, CLOCK_UNITS, type CheckData, type CheckOptions, type ClockUnit, type CompileOptions, type Condition, ConditionShape, type ConditionShapeKeys, type DateConfig, type DateExpr, type DateInputOrExpr, type DateInputValue, type DateOffset, DateOperator, type DateRule, type DateRuleValue, type EdgeExpr, type EngineGlobalPath, type EngineGlobalValues, type EngineGlobalsState, type EnumNarrowing, FieldKind, type FieldMap, type FieldMapEntry, type FieldMapSet, type FuzzyConfig, type GroupByStep, type IfThenElse, type Lens, type LensClamps, type LensNarrowing, type LensPathHop, type LensPathResolution, LensRefusal, type LensRelationSelect, type LensSelect, type LensSelectOptions, type LensValue, type LensWhereSql, type LensWhereSqlOptions, type ListBindingsOptions, type Magnitude, type MaterializeSourceQueryOptions, type ModelDefaultNarrowing, type ModelEntry, type ModelNarrowing, NUMERIC_KINDS, type NarrowingDefaults, type NumberOffset, Operator, type OperatorFamily, type OrderBy, type OrderedRuleValue, type PathProjection, type PeriodExpr, type PeriodUnit, type PrismaProvider, type PrismaStep, type PrismaWhere, type ProjectLensOptions, type ProjectRowsOptions, type ProjectedVisit, type RelativeUnit, type RelativeUnits, type RollingExpr, type Row, type Rule, type RuleDescription, type RuleScalar, type RuleSourceDescription, RuleTarget, type RuleValue, type ScopeOutOfBounds, type ScopeRef, type ScopedRef, type SortDir, type SourceEntry, type SourceOption, SourceOptionOrder, type SourcePrismaQuery, type SourceQuery, type SourceRowShape, type SourceSelect, type SourceSpec, type SourceSqlQuery, type SourceValues, SqlDialect, type StepRef, type StoredLens, type StrictAggregateRule, type StrictAll, type StrictAny, type StrictArrayCountRule, type StrictArrayPredicateRule, type StrictArrayPresenceRule, type StrictArrayRule, type StrictCondition, type StrictContainsRule, type StrictDateComparisonRule, type StrictDateDayRule, type StrictDateRangeRule, type StrictDateRule, type StrictEqualityRule, type StrictIfThenElse, type StrictMembershipRule, type StrictOrderedComparisonRule, type StrictPatternRule, type StrictPresenceRule, type StrictRangeRule, type StrictRule, type StrictStringBoundaryRule, type TimeZoneConfig, type ToPrismaOptions, type ToPrismaResult, type ToSqlOptions, type ToSqlResult, UsageError, type ValidateRuleOptions, type ValidationIssue, type ValidationResult, ValueShape, type ValueSourceFields, type ValueSourceOf, type WeekStart, type WhereSqlOptions, type WhereStep, type WindowFields, andWhere, assertValidFieldMaps, assertValidNarrowing, assertValidRule, bindLens, bindRule, check, clampLens, clockUnit, coerceRule, composeLens, createLens, describeRule, describeRuleSources, engineGlobals, executePrismaPlan, getAggregateOperators, getArrayOperators, getConditionShapeKeys, getLensRoot, getOperatorsForKind, getValueShape, indexBridges, lensVisit, listBindings, listLensBindings, matchAll, matchNothing, materializeSourceQuery, materializeSources, narrowRule, orWhere, orderRecords, parseScopeRef, prefixConditionFields, projectLens, projectRows, readLensValue, readScopeRef, stitchFieldMaps, storeLens, toLensSelect, toLensWhereSql, toPrisma, toSourceQueries, toSql, toWhereSql, validateFieldMaps, validateNarrowing, validateRule, validateRuleInLens, walkLensPath };
1412
+ export { ALL_KINDS, type Absent, type AggregateMode, type AggregateRule, type All, type Any, ArrayOperator, type ArrayRule, type Bridge, type BridgeCardinality, type BridgeDictionary, type BridgeEndpoint, CLOCK_UNITS, type CheckData, type CheckOptions, type ClockUnit, type CompileOptions, type Condition, ConditionShape, type ConditionShapeKeys, type DateConfig, type DateExpr, type DateInputOrExpr, type DateInputValue, type DateOffset, DateOperator, type DateRule, type DateRuleValue, type EdgeExpr, type EngineGlobalDefaults, type EngineGlobalPath, type EngineGlobalValues, type EngineGlobalsState, type EnumNarrowing, FieldKind, type FieldMap, type FieldMapEntry, type FieldMapSet, type FuzzyConfig, type GroupByStep, type IfThenElse, type Lens, type LensClamps, type LensNarrowing, type LensPathHop, type LensPathResolution, LensRefusal, type LensRelationSelect, type LensSelect, type LensSelectOptions, type LensValue, type LensWhereSql, type LensWhereSqlOptions, type ListBindingsOptions, type Magnitude, type MaterializeSourceQueryOptions, type ModelDefaultNarrowing, type ModelEntry, type ModelNarrowing, NUMERIC_KINDS, type NarrowingDefaults, type NumberOffset, Operator, type OperatorFamily, type OrderBy, type OrderedRuleValue, type PathProjection, type PeriodExpr, type PeriodUnit, type PrismaProvider, type PrismaStep, type PrismaWhere, type ProjectLensOptions, type ProjectRowsOptions, type ProjectedVisit, type RelativeUnit, type RelativeUnits, type RollingExpr, type Row, type Rule, type RuleDescription, type RuleScalar, type RuleSourceDescription, RuleTarget, type RuleValue, type ScopeOutOfBounds, type ScopeRef, type ScopedRef, type SortDir, type SourceEntry, type SourceOption, SourceOptionOrder, type SourcePrismaQuery, type SourceQuery, type SourceRowShape, type SourceSelect, type SourceSpec, type SourceSqlQuery, type SourceValues, SqlDialect, type StepRef, type StoredLens, type StrictAggregateRule, type StrictAll, type StrictAny, type StrictArrayCountRule, type StrictArrayPredicateRule, type StrictArrayPresenceRule, type StrictArrayRule, type StrictCondition, type StrictContainsRule, type StrictDateComparisonRule, type StrictDateDayRule, type StrictDateRangeRule, type StrictDateRule, type StrictEqualityRule, type StrictIfThenElse, type StrictMembershipRule, type StrictOrderedComparisonRule, type StrictPatternRule, type StrictPresenceRule, type StrictRangeRule, type StrictRule, type StrictStringBoundaryRule, type TimeZoneConfig, type ToPrismaOptions, type ToPrismaResult, type ToSqlOptions, type ToSqlResult, UsageError, type ValidateRuleOptions, type ValidationIssue, type ValidationResult, ValueShape, type ValueSourceFields, type ValueSourceOf, type WeekStart, type WhereSqlOptions, type WhereStep, type WindowFields, andWhere, assertValidFieldMaps, assertValidNarrowing, assertValidRule, bindLens, bindRule, check, clampLens, clockUnit, coerceRule, composeLens, createLens, describeRule, describeRuleSources, engineGlobals, executePrismaPlan, getAggregateOperators, getArrayOperators, getConditionShapeKeys, getLensRoot, getOperatorsForKind, getValueShape, indexBridges, lensVisit, listBindings, listFields, listLensBindings, matchAll, matchNothing, materializeSourceQuery, materializeSources, narrowRule, orWhere, orderRecords, parseScopeRef, prefixConditionFields, projectLens, projectRows, readLensValue, readScopeRef, registerEngineGlobals, stitchFieldMaps, storeLens, toLensSelect, toLensWhereSql, toPrisma, toSourceQueries, toSql, toWhereSql, validateFieldMaps, validateNarrowing, validateRule, validateRuleInLens, walkLensPath };
package/dist/index.d.ts CHANGED
@@ -599,6 +599,13 @@ type ListBindingsOptions = {
599
599
  * another is required.
600
600
  */
601
601
  declare const listBindings: (condition: Condition, { required }?: ListBindingsOptions) => string[];
602
+ /**
603
+ * The paths a rule reads from the row it is checked on, sorted: each leaf's `field` and each
604
+ * `{ path }` on its value side. A relation node (`arrayOperator`, `aggregate`) contributes its own
605
+ * field; what its `condition` / `filter` read is relative to the related rows, so it is not listed.
606
+ * For a caller that must load what a rule reads before checking it (a hydrator).
607
+ */
608
+ declare const listFields: (condition: Condition) => string[];
602
609
  /**
603
610
  * Substitute covered binds with their values; uncovered tokens stay in place (partial
604
611
  * resolution). A supplied-but-undefined binding becomes null to stay serializable.
@@ -657,25 +664,47 @@ type EngineGlobalsState = {
657
664
  finestUnit: ClockUnit | RelativeUnit;
658
665
  };
659
666
  };
660
- /** Each path `engineGlobals` reads and writes, and the values it takes. */
661
- type EngineGlobalValues = {
667
+ /**
668
+ * Each path `engineGlobals` reads and writes, and the values it takes. An interface, so a library
669
+ * built on the engine adds its own namespace's paths by module augmentation:
670
+ *
671
+ * ```ts
672
+ * declare module '@inixiative/json-rules' {
673
+ * interface EngineGlobalValues { 'permissions.idField': string }
674
+ * }
675
+ * ```
676
+ */
677
+ interface EngineGlobalValues {
662
678
  'string.caseInsensitive': EngineGlobalsState['string']['caseInsensitive'];
663
679
  'string.fuzzy': EngineGlobalsState['string']['fuzzy'];
664
680
  'prismaOptions.datasource.provider': EngineGlobalsState['prismaOptions']['datasource']['provider'];
665
681
  'prismaOptions.anyNull': EngineGlobalsState['prismaOptions']['anyNull'];
666
682
  'sql.dialect': EngineGlobalsState['sql']['dialect'];
667
683
  'clock.finestUnit': EngineGlobalsState['clock']['finestUnit'];
668
- };
684
+ }
669
685
  type EngineGlobalPath = keyof EngineGlobalValues;
686
+ /** The defaults a namespace registers: its paths, relative to the namespace. */
687
+ type EngineGlobalDefaults<N extends string> = {
688
+ [P in EngineGlobalPath as P extends `${N}.${infer K}` ? K : never]: EngineGlobalValues[P];
689
+ };
670
690
  type DeepPartial<T> = {
671
691
  [K in keyof T]?: T[K] extends object ? DeepPartial<T[K]> : T[K];
672
692
  };
693
+ type Overrides = Partial<EngineGlobalValues> | DeepPartial<EngineGlobalsState>;
694
+ /**
695
+ * Register a library's namespace of engine globals and its defaults. A library built on the
696
+ * engine calls this at the top of the module that reads the setting, for its own namespace only.
697
+ * Defaults go in under any value already set (an app may configure a library before importing
698
+ * it). Registering the same defaults again is a no-op (a second installed copy of the library);
699
+ * different defaults, a dotted namespace or one of the engine's own roots throw.
700
+ */
701
+ declare const registerEngineGlobals: <N extends string>(namespace: N, defaults: EngineGlobalDefaults<N>) => void;
673
702
  /** Process-wide defaults, read and written by dotted path (`EngineGlobalPath`). */
674
703
  declare const engineGlobals: {
675
704
  set: <P extends EngineGlobalPath>(path: P, value: EngineGlobalValues[P]) => void;
676
705
  get: <P extends EngineGlobalPath>(path: P) => EngineGlobalValues[P];
677
706
  reset: () => void;
678
- with: <T>(partial: DeepPartial<EngineGlobalsState>, fn: () => T) => T;
707
+ with: <T>(overrides: Overrides, fn: () => T) => T;
679
708
  };
680
709
 
681
710
  /** A caller's input missing or malformed — the clock, the time zone, a bind's value — not the
@@ -1380,4 +1409,4 @@ declare const getConditionShapeKeys: (shape: ConditionShape) => ConditionShapeKe
1380
1409
  */
1381
1410
  declare const orderRecords: <T>(items: readonly T[], orderBy: OrderBy) => T[];
1382
1411
 
1383
- export { ALL_KINDS, type Absent, type AggregateMode, type AggregateRule, type All, type Any, ArrayOperator, type ArrayRule, type Bridge, type BridgeCardinality, type BridgeDictionary, type BridgeEndpoint, CLOCK_UNITS, type CheckData, type CheckOptions, type ClockUnit, type CompileOptions, type Condition, ConditionShape, type ConditionShapeKeys, type DateConfig, type DateExpr, type DateInputOrExpr, type DateInputValue, type DateOffset, DateOperator, type DateRule, type DateRuleValue, type EdgeExpr, type EngineGlobalPath, type EngineGlobalValues, type EngineGlobalsState, type EnumNarrowing, FieldKind, type FieldMap, type FieldMapEntry, type FieldMapSet, type FuzzyConfig, type GroupByStep, type IfThenElse, type Lens, type LensClamps, type LensNarrowing, type LensPathHop, type LensPathResolution, LensRefusal, type LensRelationSelect, type LensSelect, type LensSelectOptions, type LensValue, type LensWhereSql, type LensWhereSqlOptions, type ListBindingsOptions, type Magnitude, type MaterializeSourceQueryOptions, type ModelDefaultNarrowing, type ModelEntry, type ModelNarrowing, NUMERIC_KINDS, type NarrowingDefaults, type NumberOffset, Operator, type OperatorFamily, type OrderBy, type OrderedRuleValue, type PathProjection, type PeriodExpr, type PeriodUnit, type PrismaProvider, type PrismaStep, type PrismaWhere, type ProjectLensOptions, type ProjectRowsOptions, type ProjectedVisit, type RelativeUnit, type RelativeUnits, type RollingExpr, type Row, type Rule, type RuleDescription, type RuleScalar, type RuleSourceDescription, RuleTarget, type RuleValue, type ScopeOutOfBounds, type ScopeRef, type ScopedRef, type SortDir, type SourceEntry, type SourceOption, SourceOptionOrder, type SourcePrismaQuery, type SourceQuery, type SourceRowShape, type SourceSelect, type SourceSpec, type SourceSqlQuery, type SourceValues, SqlDialect, type StepRef, type StoredLens, type StrictAggregateRule, type StrictAll, type StrictAny, type StrictArrayCountRule, type StrictArrayPredicateRule, type StrictArrayPresenceRule, type StrictArrayRule, type StrictCondition, type StrictContainsRule, type StrictDateComparisonRule, type StrictDateDayRule, type StrictDateRangeRule, type StrictDateRule, type StrictEqualityRule, type StrictIfThenElse, type StrictMembershipRule, type StrictOrderedComparisonRule, type StrictPatternRule, type StrictPresenceRule, type StrictRangeRule, type StrictRule, type StrictStringBoundaryRule, type TimeZoneConfig, type ToPrismaOptions, type ToPrismaResult, type ToSqlOptions, type ToSqlResult, UsageError, type ValidateRuleOptions, type ValidationIssue, type ValidationResult, ValueShape, type ValueSourceFields, type ValueSourceOf, type WeekStart, type WhereSqlOptions, type WhereStep, type WindowFields, andWhere, assertValidFieldMaps, assertValidNarrowing, assertValidRule, bindLens, bindRule, check, clampLens, clockUnit, coerceRule, composeLens, createLens, describeRule, describeRuleSources, engineGlobals, executePrismaPlan, getAggregateOperators, getArrayOperators, getConditionShapeKeys, getLensRoot, getOperatorsForKind, getValueShape, indexBridges, lensVisit, listBindings, listLensBindings, matchAll, matchNothing, materializeSourceQuery, materializeSources, narrowRule, orWhere, orderRecords, parseScopeRef, prefixConditionFields, projectLens, projectRows, readLensValue, readScopeRef, stitchFieldMaps, storeLens, toLensSelect, toLensWhereSql, toPrisma, toSourceQueries, toSql, toWhereSql, validateFieldMaps, validateNarrowing, validateRule, validateRuleInLens, walkLensPath };
1412
+ export { ALL_KINDS, type Absent, type AggregateMode, type AggregateRule, type All, type Any, ArrayOperator, type ArrayRule, type Bridge, type BridgeCardinality, type BridgeDictionary, type BridgeEndpoint, CLOCK_UNITS, type CheckData, type CheckOptions, type ClockUnit, type CompileOptions, type Condition, ConditionShape, type ConditionShapeKeys, type DateConfig, type DateExpr, type DateInputOrExpr, type DateInputValue, type DateOffset, DateOperator, type DateRule, type DateRuleValue, type EdgeExpr, type EngineGlobalDefaults, type EngineGlobalPath, type EngineGlobalValues, type EngineGlobalsState, type EnumNarrowing, FieldKind, type FieldMap, type FieldMapEntry, type FieldMapSet, type FuzzyConfig, type GroupByStep, type IfThenElse, type Lens, type LensClamps, type LensNarrowing, type LensPathHop, type LensPathResolution, LensRefusal, type LensRelationSelect, type LensSelect, type LensSelectOptions, type LensValue, type LensWhereSql, type LensWhereSqlOptions, type ListBindingsOptions, type Magnitude, type MaterializeSourceQueryOptions, type ModelDefaultNarrowing, type ModelEntry, type ModelNarrowing, NUMERIC_KINDS, type NarrowingDefaults, type NumberOffset, Operator, type OperatorFamily, type OrderBy, type OrderedRuleValue, type PathProjection, type PeriodExpr, type PeriodUnit, type PrismaProvider, type PrismaStep, type PrismaWhere, type ProjectLensOptions, type ProjectRowsOptions, type ProjectedVisit, type RelativeUnit, type RelativeUnits, type RollingExpr, type Row, type Rule, type RuleDescription, type RuleScalar, type RuleSourceDescription, RuleTarget, type RuleValue, type ScopeOutOfBounds, type ScopeRef, type ScopedRef, type SortDir, type SourceEntry, type SourceOption, SourceOptionOrder, type SourcePrismaQuery, type SourceQuery, type SourceRowShape, type SourceSelect, type SourceSpec, type SourceSqlQuery, type SourceValues, SqlDialect, type StepRef, type StoredLens, type StrictAggregateRule, type StrictAll, type StrictAny, type StrictArrayCountRule, type StrictArrayPredicateRule, type StrictArrayPresenceRule, type StrictArrayRule, type StrictCondition, type StrictContainsRule, type StrictDateComparisonRule, type StrictDateDayRule, type StrictDateRangeRule, type StrictDateRule, type StrictEqualityRule, type StrictIfThenElse, type StrictMembershipRule, type StrictOrderedComparisonRule, type StrictPatternRule, type StrictPresenceRule, type StrictRangeRule, type StrictRule, type StrictStringBoundaryRule, type TimeZoneConfig, type ToPrismaOptions, type ToPrismaResult, type ToSqlOptions, type ToSqlResult, UsageError, type ValidateRuleOptions, type ValidationIssue, type ValidationResult, ValueShape, type ValueSourceFields, type ValueSourceOf, type WeekStart, type WhereSqlOptions, type WhereStep, type WindowFields, andWhere, assertValidFieldMaps, assertValidNarrowing, assertValidRule, bindLens, bindRule, check, clampLens, clockUnit, coerceRule, composeLens, createLens, describeRule, describeRuleSources, engineGlobals, executePrismaPlan, getAggregateOperators, getArrayOperators, getConditionShapeKeys, getLensRoot, getOperatorsForKind, getValueShape, indexBridges, lensVisit, listBindings, listFields, listLensBindings, matchAll, matchNothing, materializeSourceQuery, materializeSources, narrowRule, orWhere, orderRecords, parseScopeRef, prefixConditionFields, projectLens, projectRows, readLensValue, readScopeRef, registerEngineGlobals, stitchFieldMaps, storeLens, toLensSelect, toLensWhereSql, toPrisma, toSourceQueries, toSql, toWhereSql, validateFieldMaps, validateNarrowing, validateRule, validateRuleInLens, walkLensPath };