@inixiative/json-rules 2.13.1 → 2.14.1

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
@@ -371,8 +371,8 @@ declare const requiredBindings: (condition: Condition) => Set<string>;
371
371
  */
372
372
  declare const resolveBindings: (condition: Condition, bindings: Record<string, RuleValue>) => Condition;
373
373
 
374
- type Row$1 = Record<string, unknown>;
375
- type CheckData = Row$1 | unknown[];
374
+ type Row$2 = Record<string, unknown>;
375
+ type CheckData = Row$2 | unknown[];
376
376
  type CheckOptions = {
377
377
  context?: CheckData;
378
378
  bindings?: Record<string, RuleValue>;
@@ -478,11 +478,11 @@ type FieldMapSet = {
478
478
  bridges?: Bridge[];
479
479
  };
480
480
 
481
- type Row = Record<string, unknown>;
481
+ type Row$1 = Record<string, unknown>;
482
482
  type BridgeDictionary = Record<string, // map name
483
483
  Record<string, // model name
484
- Record<string, Record<string, Row | Row[]>>>>;
485
- declare const buildBridgeDictionary: (set: FieldMapSet, rawData: Record<string, Row[]>) => BridgeDictionary;
484
+ Record<string, Record<string, Row$1 | Row$1[]>>>>;
485
+ declare const buildBridgeDictionary: (set: FieldMapSet, rawData: Record<string, Row$1[]>) => BridgeDictionary;
486
486
 
487
487
  declare const stitchFieldMaps: (set: FieldMapSet) => FieldMapSet;
488
488
 
@@ -527,10 +527,16 @@ type ModelDefaultNarrowing = {
527
527
  */
528
528
  sources?: Record<string, SourceValue>;
529
529
  };
530
- /** A sourced field's eligibility `where` plus an optional sibling display-label column. */
530
+ /**
531
+ * A sourced field's eligibility `where` plus an optional sibling display-label column.
532
+ * At least one key is required — `{}` is not a Condition; the unconstrained spelling is `true`.
533
+ */
531
534
  type SourceSpec = {
532
- where?: Condition;
535
+ where: Condition;
533
536
  label?: string;
537
+ } | {
538
+ where?: Condition;
539
+ label: string;
534
540
  };
535
541
  /** A `sources` entry: a bare eligibility `Condition`, or a richer `SourceSpec`. */
536
542
  type SourceValue = Condition | SourceSpec;
@@ -683,6 +689,20 @@ type SourceQuery = {
683
689
  */
684
690
  declare const sourceQueries: (lensOrNarrowing: Lens | LensNarrowing) => SourceQuery[];
685
691
 
692
+ type Row = Record<string, unknown>;
693
+ /**
694
+ * Materialize each sourced field's option set from an already-fetched collection —
695
+ * the in-memory executor of `sources` declarations, alongside `sourceQueries`
696
+ * (which compiles the same declarations to DISTINCT queries for a DB). Rows are
697
+ * the collection fetched UNDER the lens (relations inline), so they are already
698
+ * lens-scoped: eligibility here is the field's source `where` only, evaluated via
699
+ * `check()` (`options` feeds `{bind}` clauses). Scalar-list fields contribute one
700
+ * option per element, labels take the first non-null sibling, and sorting is
701
+ * numeric-aware in a fixed locale. Feed the result to `exposedSurface` /
702
+ * `projectByPath` as `{ sourceValues }`.
703
+ */
704
+ declare const sourceValuesFromRows: (lensOrNarrowing: Lens | LensNarrowing, rows: readonly Row[], options?: CheckOptions) => SourceValues[];
705
+
686
706
  declare const stampCoercions: (condition: Condition, lensOrNarrowing: Lens | LensNarrowing) => Condition;
687
707
 
688
708
  /**
@@ -770,4 +790,4 @@ declare const assertValidRule: (condition: unknown, options?: {
770
790
  target?: RuleTarget;
771
791
  }) => asserts condition is Condition;
772
792
 
773
- export { AGGREGATE_OPERATORS, ALL_KINDS, ARRAY_OPERATOR_CATALOG, type AggregateMode, type AggregateRule, type All, type Any, type ArrayCatalogEntry, ArrayOperator, type ArrayRule, type Bridge, type BridgeCardinality, type BridgeDictionary, type BridgeEndpoint, type BuildOptions, type CatalogEntry, type CheckOptions, type Condition, type CreateLensInput, DATE_OPERATOR_CATALOG, type DateConfig, type DateExpr, type DateInputOrExpr, type DateInputValue, DateOperator, type DateRule, type DateRuleValue, EQUATABLE_KINDS, type EdgeExpr, type EnumNarrowing, FIELD_OPERATOR_CATALOG, FieldKind, type FieldMap, type FieldMapEntry, type FieldMapSet, type GroupByStep, type IfThenElse, type Lens, type LensNarrowing, type ModelDefaultNarrowing, type ModelNarrowing, NULLABLE_KINDS, NUMERIC_KINDS, type NarrowingDefaults, ORDERABLE_KINDS, Operator, type OrderBy, type OrderedRuleValue, type PathProjection, type PeriodExpr, type PeriodUnit, type PrismaStep, type PrismaWhere, type ProjectOptions, type ProjectedVisit, type RelativeUnits, type RollingExpr, type Rule, type RuleDescription, type RuleLensCheck, type RuleLensViolation, type RuleScalar, RuleTarget, type RuleValue, STRINGY_KINDS, type SortDir, type SourceOption, type SourcePrismaQuery, type SourceQuery, type SourceSpec, type SourceSqlQuery, type SourceValue, type SourceValues, type SqlResult, type StepRef, 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 ToPrismaResult, type ValidationIssue, type ValidationResult, ValueShape, WINDOW_SELECTOR, type WeekStart, type WhereStep, type WindowFields, type WindowRuleType, WindowSupport, applyLens, assertValidRule, buildBridgeDictionary, check, checkRuleAgainstLens, createLens, describeRule, executePrismaQueryPlan, exposedSurface, getArrayOperators, getOperatorsForKind, getValueShape, getWindowSupport, isAggregateRangeOperator, isAggregateSingleOperator, isOperatorSupportedForTarget, lensRequiredBindings, projectByPath, requiredBindings, resolveBindings, resolveLensBindings, sourceQueries, stampCoercions, stitchFieldMaps, toPrisma, toSql, validateBindNames, validateFieldMap, validateFieldMapSet, validateNarrowing, validateRule };
793
+ export { AGGREGATE_OPERATORS, ALL_KINDS, ARRAY_OPERATOR_CATALOG, type AggregateMode, type AggregateRule, type All, type Any, type ArrayCatalogEntry, ArrayOperator, type ArrayRule, type Bridge, type BridgeCardinality, type BridgeDictionary, type BridgeEndpoint, type BuildOptions, type CatalogEntry, type CheckOptions, type Condition, type CreateLensInput, DATE_OPERATOR_CATALOG, type DateConfig, type DateExpr, type DateInputOrExpr, type DateInputValue, DateOperator, type DateRule, type DateRuleValue, EQUATABLE_KINDS, type EdgeExpr, type EnumNarrowing, FIELD_OPERATOR_CATALOG, FieldKind, type FieldMap, type FieldMapEntry, type FieldMapSet, type GroupByStep, type IfThenElse, type Lens, type LensNarrowing, type ModelDefaultNarrowing, type ModelNarrowing, NULLABLE_KINDS, NUMERIC_KINDS, type NarrowingDefaults, ORDERABLE_KINDS, Operator, type OrderBy, type OrderedRuleValue, type PathProjection, type PeriodExpr, type PeriodUnit, type PrismaStep, type PrismaWhere, type ProjectOptions, type ProjectedVisit, type RelativeUnits, type RollingExpr, type Rule, type RuleDescription, type RuleLensCheck, type RuleLensViolation, type RuleScalar, RuleTarget, type RuleValue, STRINGY_KINDS, type SortDir, type SourceOption, type SourcePrismaQuery, type SourceQuery, type SourceSpec, type SourceSqlQuery, type SourceValue, type SourceValues, type SqlResult, type StepRef, 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 ToPrismaResult, type ValidationIssue, type ValidationResult, ValueShape, WINDOW_SELECTOR, type WeekStart, type WhereStep, type WindowFields, type WindowRuleType, WindowSupport, applyLens, assertValidRule, buildBridgeDictionary, check, checkRuleAgainstLens, createLens, describeRule, executePrismaQueryPlan, exposedSurface, getArrayOperators, getOperatorsForKind, getValueShape, getWindowSupport, isAggregateRangeOperator, isAggregateSingleOperator, isOperatorSupportedForTarget, lensRequiredBindings, projectByPath, requiredBindings, resolveBindings, resolveLensBindings, sourceQueries, sourceValuesFromRows, stampCoercions, stitchFieldMaps, toPrisma, toSql, validateBindNames, validateFieldMap, validateFieldMapSet, validateNarrowing, validateRule };
package/dist/index.d.ts CHANGED
@@ -371,8 +371,8 @@ declare const requiredBindings: (condition: Condition) => Set<string>;
371
371
  */
372
372
  declare const resolveBindings: (condition: Condition, bindings: Record<string, RuleValue>) => Condition;
373
373
 
374
- type Row$1 = Record<string, unknown>;
375
- type CheckData = Row$1 | unknown[];
374
+ type Row$2 = Record<string, unknown>;
375
+ type CheckData = Row$2 | unknown[];
376
376
  type CheckOptions = {
377
377
  context?: CheckData;
378
378
  bindings?: Record<string, RuleValue>;
@@ -478,11 +478,11 @@ type FieldMapSet = {
478
478
  bridges?: Bridge[];
479
479
  };
480
480
 
481
- type Row = Record<string, unknown>;
481
+ type Row$1 = Record<string, unknown>;
482
482
  type BridgeDictionary = Record<string, // map name
483
483
  Record<string, // model name
484
- Record<string, Record<string, Row | Row[]>>>>;
485
- declare const buildBridgeDictionary: (set: FieldMapSet, rawData: Record<string, Row[]>) => BridgeDictionary;
484
+ Record<string, Record<string, Row$1 | Row$1[]>>>>;
485
+ declare const buildBridgeDictionary: (set: FieldMapSet, rawData: Record<string, Row$1[]>) => BridgeDictionary;
486
486
 
487
487
  declare const stitchFieldMaps: (set: FieldMapSet) => FieldMapSet;
488
488
 
@@ -527,10 +527,16 @@ type ModelDefaultNarrowing = {
527
527
  */
528
528
  sources?: Record<string, SourceValue>;
529
529
  };
530
- /** A sourced field's eligibility `where` plus an optional sibling display-label column. */
530
+ /**
531
+ * A sourced field's eligibility `where` plus an optional sibling display-label column.
532
+ * At least one key is required — `{}` is not a Condition; the unconstrained spelling is `true`.
533
+ */
531
534
  type SourceSpec = {
532
- where?: Condition;
535
+ where: Condition;
533
536
  label?: string;
537
+ } | {
538
+ where?: Condition;
539
+ label: string;
534
540
  };
535
541
  /** A `sources` entry: a bare eligibility `Condition`, or a richer `SourceSpec`. */
536
542
  type SourceValue = Condition | SourceSpec;
@@ -683,6 +689,20 @@ type SourceQuery = {
683
689
  */
684
690
  declare const sourceQueries: (lensOrNarrowing: Lens | LensNarrowing) => SourceQuery[];
685
691
 
692
+ type Row = Record<string, unknown>;
693
+ /**
694
+ * Materialize each sourced field's option set from an already-fetched collection —
695
+ * the in-memory executor of `sources` declarations, alongside `sourceQueries`
696
+ * (which compiles the same declarations to DISTINCT queries for a DB). Rows are
697
+ * the collection fetched UNDER the lens (relations inline), so they are already
698
+ * lens-scoped: eligibility here is the field's source `where` only, evaluated via
699
+ * `check()` (`options` feeds `{bind}` clauses). Scalar-list fields contribute one
700
+ * option per element, labels take the first non-null sibling, and sorting is
701
+ * numeric-aware in a fixed locale. Feed the result to `exposedSurface` /
702
+ * `projectByPath` as `{ sourceValues }`.
703
+ */
704
+ declare const sourceValuesFromRows: (lensOrNarrowing: Lens | LensNarrowing, rows: readonly Row[], options?: CheckOptions) => SourceValues[];
705
+
686
706
  declare const stampCoercions: (condition: Condition, lensOrNarrowing: Lens | LensNarrowing) => Condition;
687
707
 
688
708
  /**
@@ -770,4 +790,4 @@ declare const assertValidRule: (condition: unknown, options?: {
770
790
  target?: RuleTarget;
771
791
  }) => asserts condition is Condition;
772
792
 
773
- export { AGGREGATE_OPERATORS, ALL_KINDS, ARRAY_OPERATOR_CATALOG, type AggregateMode, type AggregateRule, type All, type Any, type ArrayCatalogEntry, ArrayOperator, type ArrayRule, type Bridge, type BridgeCardinality, type BridgeDictionary, type BridgeEndpoint, type BuildOptions, type CatalogEntry, type CheckOptions, type Condition, type CreateLensInput, DATE_OPERATOR_CATALOG, type DateConfig, type DateExpr, type DateInputOrExpr, type DateInputValue, DateOperator, type DateRule, type DateRuleValue, EQUATABLE_KINDS, type EdgeExpr, type EnumNarrowing, FIELD_OPERATOR_CATALOG, FieldKind, type FieldMap, type FieldMapEntry, type FieldMapSet, type GroupByStep, type IfThenElse, type Lens, type LensNarrowing, type ModelDefaultNarrowing, type ModelNarrowing, NULLABLE_KINDS, NUMERIC_KINDS, type NarrowingDefaults, ORDERABLE_KINDS, Operator, type OrderBy, type OrderedRuleValue, type PathProjection, type PeriodExpr, type PeriodUnit, type PrismaStep, type PrismaWhere, type ProjectOptions, type ProjectedVisit, type RelativeUnits, type RollingExpr, type Rule, type RuleDescription, type RuleLensCheck, type RuleLensViolation, type RuleScalar, RuleTarget, type RuleValue, STRINGY_KINDS, type SortDir, type SourceOption, type SourcePrismaQuery, type SourceQuery, type SourceSpec, type SourceSqlQuery, type SourceValue, type SourceValues, type SqlResult, type StepRef, 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 ToPrismaResult, type ValidationIssue, type ValidationResult, ValueShape, WINDOW_SELECTOR, type WeekStart, type WhereStep, type WindowFields, type WindowRuleType, WindowSupport, applyLens, assertValidRule, buildBridgeDictionary, check, checkRuleAgainstLens, createLens, describeRule, executePrismaQueryPlan, exposedSurface, getArrayOperators, getOperatorsForKind, getValueShape, getWindowSupport, isAggregateRangeOperator, isAggregateSingleOperator, isOperatorSupportedForTarget, lensRequiredBindings, projectByPath, requiredBindings, resolveBindings, resolveLensBindings, sourceQueries, stampCoercions, stitchFieldMaps, toPrisma, toSql, validateBindNames, validateFieldMap, validateFieldMapSet, validateNarrowing, validateRule };
793
+ export { AGGREGATE_OPERATORS, ALL_KINDS, ARRAY_OPERATOR_CATALOG, type AggregateMode, type AggregateRule, type All, type Any, type ArrayCatalogEntry, ArrayOperator, type ArrayRule, type Bridge, type BridgeCardinality, type BridgeDictionary, type BridgeEndpoint, type BuildOptions, type CatalogEntry, type CheckOptions, type Condition, type CreateLensInput, DATE_OPERATOR_CATALOG, type DateConfig, type DateExpr, type DateInputOrExpr, type DateInputValue, DateOperator, type DateRule, type DateRuleValue, EQUATABLE_KINDS, type EdgeExpr, type EnumNarrowing, FIELD_OPERATOR_CATALOG, FieldKind, type FieldMap, type FieldMapEntry, type FieldMapSet, type GroupByStep, type IfThenElse, type Lens, type LensNarrowing, type ModelDefaultNarrowing, type ModelNarrowing, NULLABLE_KINDS, NUMERIC_KINDS, type NarrowingDefaults, ORDERABLE_KINDS, Operator, type OrderBy, type OrderedRuleValue, type PathProjection, type PeriodExpr, type PeriodUnit, type PrismaStep, type PrismaWhere, type ProjectOptions, type ProjectedVisit, type RelativeUnits, type RollingExpr, type Rule, type RuleDescription, type RuleLensCheck, type RuleLensViolation, type RuleScalar, RuleTarget, type RuleValue, STRINGY_KINDS, type SortDir, type SourceOption, type SourcePrismaQuery, type SourceQuery, type SourceSpec, type SourceSqlQuery, type SourceValue, type SourceValues, type SqlResult, type StepRef, 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 ToPrismaResult, type ValidationIssue, type ValidationResult, ValueShape, WINDOW_SELECTOR, type WeekStart, type WhereStep, type WindowFields, type WindowRuleType, WindowSupport, applyLens, assertValidRule, buildBridgeDictionary, check, checkRuleAgainstLens, createLens, describeRule, executePrismaQueryPlan, exposedSurface, getArrayOperators, getOperatorsForKind, getValueShape, getWindowSupport, isAggregateRangeOperator, isAggregateSingleOperator, isOperatorSupportedForTarget, lensRequiredBindings, projectByPath, requiredBindings, resolveBindings, resolveLensBindings, sourceQueries, sourceValuesFromRows, stampCoercions, stitchFieldMaps, toPrisma, toSql, validateBindNames, validateFieldMap, validateFieldMapSet, validateNarrowing, validateRule };