@inixiative/json-rules 2.15.1 → 2.17.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
@@ -45,6 +45,13 @@ declare const DateOperator: {
45
45
  };
46
46
  type DateOperator = (typeof DateOperator)[keyof typeof DateOperator];
47
47
 
48
+ type FuzzyConfig = {
49
+ maxDistance?: number;
50
+ maxRatio?: number;
51
+ };
52
+ declare const maxFuzzyDistance: (length: number) => number;
53
+ declare const fuzzyContains: (haystack: string, query: string, config?: FuzzyConfig) => boolean;
54
+
48
55
  declare const FieldKind: {
49
56
  readonly String: "String";
50
57
  readonly Boolean: "Boolean";
@@ -206,6 +213,7 @@ type RuleBase<TOperator extends Operator> = {
206
213
  operator: TOperator;
207
214
  error?: string;
208
215
  caseInsensitive?: boolean;
216
+ fuzzy?: boolean | FuzzyConfig;
209
217
  };
210
218
  type DateRuleBase<TOperator extends DateOperator> = {
211
219
  field: string;
@@ -312,6 +320,7 @@ type Rule<TValue = RuleValue> = {
312
320
  bind?: string;
313
321
  error?: string;
314
322
  caseInsensitive?: boolean;
323
+ fuzzy?: boolean | FuzzyConfig;
315
324
  coerceType?: FieldKind;
316
325
  };
317
326
  type ArrayRule<TRuleValue = RuleValue, TDateValue = DateRuleValue> = WindowFields & {
@@ -373,8 +382,8 @@ declare const requiredBindings: (condition: Condition) => Set<string>;
373
382
  */
374
383
  declare const resolveBindings: (condition: Condition, bindings: Record<string, RuleValue>) => Condition;
375
384
 
376
- type Row$2 = Record<string, unknown>;
377
- type CheckData = Row$2 | unknown[];
385
+ type Row$3 = Record<string, unknown>;
386
+ type CheckData = Row$3 | unknown[];
378
387
  type CheckOptions = {
379
388
  context?: CheckData;
380
389
  bindings?: Record<string, RuleValue>;
@@ -385,6 +394,7 @@ type PrismaProvider = 'postgresql' | 'mysql' | 'sqlite' | 'sqlserver' | 'cockroa
385
394
  type EngineGlobalsState = {
386
395
  string: {
387
396
  caseInsensitive: boolean;
397
+ fuzzy: boolean | FuzzyConfig;
388
398
  };
389
399
  prismaOptions: {
390
400
  datasource: {
@@ -392,19 +402,26 @@ type EngineGlobalsState = {
392
402
  };
393
403
  };
394
404
  };
405
+ type DeepPartial<T> = {
406
+ [K in keyof T]?: T[K] extends object ? DeepPartial<T[K]> : T[K];
407
+ };
395
408
  declare const engineGlobals: {
396
409
  set: (path: string, value: unknown) => void;
397
410
  get: (path: string) => unknown;
398
411
  reset: () => void;
412
+ with: <T>(partial: DeepPartial<EngineGlobalsState>, fn: () => T) => T;
399
413
  };
400
414
  declare const supportsQueryMode: (provider: PrismaProvider) => boolean;
401
415
  declare const resolveCaseInsensitive: (ruleFlag?: boolean) => boolean;
416
+ declare const resolveFuzzy: (ruleFlag?: boolean | FuzzyConfig) => FuzzyConfig | false;
402
417
 
403
418
  type PrismaWhere = Record<string, unknown>;
404
- /** A selectable option — the standard `<select>` shape: a value with an optional display label. */
419
+ /** A selectable option — the standard `<select>` shape: a value with an optional display
420
+ * label, plus the partition key when the source declares a `groupBy`. */
405
421
  type SourceOption = {
406
422
  value: string;
407
423
  label?: string;
424
+ group?: string;
408
425
  };
409
426
  type FieldMapEntry = {
410
427
  kind: 'scalar' | 'object' | 'enum' | 'bridge';
@@ -502,11 +519,11 @@ type FieldMapSet = {
502
519
  bridges?: Bridge[];
503
520
  };
504
521
 
505
- type Row$1 = Record<string, unknown>;
522
+ type Row$2 = Record<string, unknown>;
506
523
  type BridgeDictionary = Record<string, // map name
507
524
  Record<string, // model name
508
- Record<string, Record<string, Row$1 | Row$1[]>>>>;
509
- declare const buildBridgeDictionary: (set: FieldMapSet, rawData: Record<string, Row$1[]>) => BridgeDictionary;
525
+ Record<string, Record<string, Row$2 | Row$2[]>>>>;
526
+ declare const buildBridgeDictionary: (set: FieldMapSet, rawData: Record<string, Row$2[]>) => BridgeDictionary;
510
527
 
511
528
  declare const stitchFieldMaps: (set: FieldMapSet) => FieldMapSet;
512
529
 
@@ -552,15 +569,24 @@ type ModelDefaultNarrowing = {
552
569
  sources?: Record<string, SourceValue>;
553
570
  };
554
571
  /**
555
- * A sourced field's eligibility `where` plus an optional sibling display-label column.
556
- * At least one key is required `{}` is not a Condition; the unconstrained spelling is `true`.
572
+ * A sourced field's eligibility `where` plus an optional sibling display-label column
573
+ * and an optional `groupBy`a dotted path (to-one hops only, ending on a scalar)
574
+ * whose value partitions the option set. Grouped options carry `group`; the classic
575
+ * flat set is the ungrouped case. At least one key is required — `{}` is not a
576
+ * Condition; the unconstrained spelling is `true`.
557
577
  */
558
578
  type SourceSpec = {
559
579
  where: Condition;
560
580
  label?: string;
581
+ groupBy?: string;
561
582
  } | {
562
583
  where?: Condition;
563
584
  label: string;
585
+ groupBy?: string;
586
+ } | {
587
+ where?: Condition;
588
+ label?: string;
589
+ groupBy: string;
564
590
  };
565
591
  /** A `sources` entry: a bare eligibility `Condition`, or a richer `SourceSpec`. */
566
592
  type SourceValue = Condition | SourceSpec;
@@ -654,6 +680,8 @@ type ProjectedVisit = {
654
680
  sources: Record<string, Condition[]>;
655
681
  /** Per-field display-label column for a sourced field (from a SourceSpec's `label`). */
656
682
  sourceLabels: Record<string, string>;
683
+ /** Per-field option-partition path for a sourced field (from a SourceSpec's `groupBy`). */
684
+ sourceGroupBys: Record<string, string>;
657
685
  };
658
686
  type PathProjection = Map<string, ProjectedVisit>;
659
687
  /**
@@ -678,10 +706,18 @@ declare const exposedSurface: (lensOrNarrowing: Lens | LensNarrowing, opts?: Pro
678
706
 
679
707
  declare const validateNarrowing: (narrowing: LensNarrowing) => void;
680
708
 
709
+ /** Prisma `select` shape — nested for a grouped source's relation path. */
710
+ type SourceSelect = {
711
+ [field: string]: true | {
712
+ select: SourceSelect;
713
+ };
714
+ };
681
715
  type SourcePrismaQuery = {
682
716
  model: string;
683
- distinct: string[];
684
- select: Record<string, true>;
717
+ /** Absent for grouped sources — DISTINCT on the value column alone would collapse
718
+ * same-value rows across groups; dedup happens in `sourceValuesFromQueryRows`. */
719
+ distinct?: string[];
720
+ select: SourceSelect;
685
721
  where: PrismaWhere;
686
722
  /** Present only if the composed where used count operators (run via executePrismaQueryPlan). */
687
723
  steps?: PrismaStep[];
@@ -701,6 +737,9 @@ type SourceQuery = {
701
737
  field: string;
702
738
  /** Sibling column co-selected as each value's display label (from a SourceSpec's `label`). */
703
739
  label?: string;
740
+ /** Option-partition path (from a SourceSpec's `groupBy`); its column is selected
741
+ * nested in prisma and aliased `__group` in sql. */
742
+ groupBy?: string;
704
743
  composedWhere: Condition;
705
744
  prisma: SourcePrismaQuery;
706
745
  sql: SourceSqlQuery;
@@ -709,10 +748,25 @@ type SourceQuery = {
709
748
  * Compile a DISTINCT(value) query — Prisma and SQL — per sourced field across
710
749
  * the projected lens. The WHERE is the field's composed eligibility: the model's
711
750
  * own narrowing at that path AND its source where(s). The app runs these (with
712
- * its own client) to materialize each field's option set.
751
+ * its own client) to materialize each field's option set — feed the fetched rows
752
+ * to `sourceValuesFromQueryRows`.
713
753
  */
714
754
  declare const sourceQueries: (lensOrNarrowing: Lens | LensNarrowing) => SourceQuery[];
715
755
 
756
+ type Row$1 = Record<string, unknown>;
757
+ /** Which executor produced the rows — the caller always knows; never guessed. */
758
+ type SourceRowShape = 'prisma' | 'sql';
759
+ /**
760
+ * Materialize one compiled `SourceQuery`'s fetched rows into its `SourceValues` —
761
+ * the executor-side counterpart of `sourceQueries`, so apps never hand-map rows.
762
+ * `rowShape` names the wire format: prisma rows (default) nest the `groupBy` path
763
+ * as related objects; sql rows carry it flat under the statement's `__group` alias.
764
+ * Grouped queries fetch without DISTINCT, so dedup per (group, value) happens here.
765
+ */
766
+ declare const sourceValuesFromQueryRows: (query: SourceQuery, rows: readonly Row$1[], opts?: {
767
+ rowShape?: SourceRowShape;
768
+ }) => SourceValues;
769
+
716
770
  type Row = Record<string, unknown>;
717
771
  /**
718
772
  * Materialize each sourced field's option set from an already-fetched collection —
@@ -814,4 +868,4 @@ declare const assertValidRule: (condition: unknown, options?: {
814
868
  target?: RuleTarget;
815
869
  }) => asserts condition is Condition;
816
870
 
817
- 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 EngineGlobalsState, 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 PrismaProvider, 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, engineGlobals, executePrismaQueryPlan, exposedSurface, getArrayOperators, getOperatorsForKind, getValueShape, getWindowSupport, isAggregateRangeOperator, isAggregateSingleOperator, isOperatorSupportedForTarget, lensRequiredBindings, projectByPath, requiredBindings, resolveBindings, resolveCaseInsensitive, resolveLensBindings, sourceQueries, sourceValuesFromRows, stampCoercions, stitchFieldMaps, supportsQueryMode, toPrisma, toSql, validateBindNames, validateFieldMap, validateFieldMapSet, validateNarrowing, validateRule };
871
+ 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 EngineGlobalsState, type EnumNarrowing, FIELD_OPERATOR_CATALOG, FieldKind, type FieldMap, type FieldMapEntry, type FieldMapSet, type FuzzyConfig, 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 PrismaProvider, 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 SourceRowShape, 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, engineGlobals, executePrismaQueryPlan, exposedSurface, fuzzyContains, getArrayOperators, getOperatorsForKind, getValueShape, getWindowSupport, isAggregateRangeOperator, isAggregateSingleOperator, isOperatorSupportedForTarget, lensRequiredBindings, maxFuzzyDistance, projectByPath, requiredBindings, resolveBindings, resolveCaseInsensitive, resolveFuzzy, resolveLensBindings, sourceQueries, sourceValuesFromQueryRows, sourceValuesFromRows, stampCoercions, stitchFieldMaps, supportsQueryMode, toPrisma, toSql, validateBindNames, validateFieldMap, validateFieldMapSet, validateNarrowing, validateRule };
package/dist/index.d.ts CHANGED
@@ -45,6 +45,13 @@ declare const DateOperator: {
45
45
  };
46
46
  type DateOperator = (typeof DateOperator)[keyof typeof DateOperator];
47
47
 
48
+ type FuzzyConfig = {
49
+ maxDistance?: number;
50
+ maxRatio?: number;
51
+ };
52
+ declare const maxFuzzyDistance: (length: number) => number;
53
+ declare const fuzzyContains: (haystack: string, query: string, config?: FuzzyConfig) => boolean;
54
+
48
55
  declare const FieldKind: {
49
56
  readonly String: "String";
50
57
  readonly Boolean: "Boolean";
@@ -206,6 +213,7 @@ type RuleBase<TOperator extends Operator> = {
206
213
  operator: TOperator;
207
214
  error?: string;
208
215
  caseInsensitive?: boolean;
216
+ fuzzy?: boolean | FuzzyConfig;
209
217
  };
210
218
  type DateRuleBase<TOperator extends DateOperator> = {
211
219
  field: string;
@@ -312,6 +320,7 @@ type Rule<TValue = RuleValue> = {
312
320
  bind?: string;
313
321
  error?: string;
314
322
  caseInsensitive?: boolean;
323
+ fuzzy?: boolean | FuzzyConfig;
315
324
  coerceType?: FieldKind;
316
325
  };
317
326
  type ArrayRule<TRuleValue = RuleValue, TDateValue = DateRuleValue> = WindowFields & {
@@ -373,8 +382,8 @@ declare const requiredBindings: (condition: Condition) => Set<string>;
373
382
  */
374
383
  declare const resolveBindings: (condition: Condition, bindings: Record<string, RuleValue>) => Condition;
375
384
 
376
- type Row$2 = Record<string, unknown>;
377
- type CheckData = Row$2 | unknown[];
385
+ type Row$3 = Record<string, unknown>;
386
+ type CheckData = Row$3 | unknown[];
378
387
  type CheckOptions = {
379
388
  context?: CheckData;
380
389
  bindings?: Record<string, RuleValue>;
@@ -385,6 +394,7 @@ type PrismaProvider = 'postgresql' | 'mysql' | 'sqlite' | 'sqlserver' | 'cockroa
385
394
  type EngineGlobalsState = {
386
395
  string: {
387
396
  caseInsensitive: boolean;
397
+ fuzzy: boolean | FuzzyConfig;
388
398
  };
389
399
  prismaOptions: {
390
400
  datasource: {
@@ -392,19 +402,26 @@ type EngineGlobalsState = {
392
402
  };
393
403
  };
394
404
  };
405
+ type DeepPartial<T> = {
406
+ [K in keyof T]?: T[K] extends object ? DeepPartial<T[K]> : T[K];
407
+ };
395
408
  declare const engineGlobals: {
396
409
  set: (path: string, value: unknown) => void;
397
410
  get: (path: string) => unknown;
398
411
  reset: () => void;
412
+ with: <T>(partial: DeepPartial<EngineGlobalsState>, fn: () => T) => T;
399
413
  };
400
414
  declare const supportsQueryMode: (provider: PrismaProvider) => boolean;
401
415
  declare const resolveCaseInsensitive: (ruleFlag?: boolean) => boolean;
416
+ declare const resolveFuzzy: (ruleFlag?: boolean | FuzzyConfig) => FuzzyConfig | false;
402
417
 
403
418
  type PrismaWhere = Record<string, unknown>;
404
- /** A selectable option — the standard `<select>` shape: a value with an optional display label. */
419
+ /** A selectable option — the standard `<select>` shape: a value with an optional display
420
+ * label, plus the partition key when the source declares a `groupBy`. */
405
421
  type SourceOption = {
406
422
  value: string;
407
423
  label?: string;
424
+ group?: string;
408
425
  };
409
426
  type FieldMapEntry = {
410
427
  kind: 'scalar' | 'object' | 'enum' | 'bridge';
@@ -502,11 +519,11 @@ type FieldMapSet = {
502
519
  bridges?: Bridge[];
503
520
  };
504
521
 
505
- type Row$1 = Record<string, unknown>;
522
+ type Row$2 = Record<string, unknown>;
506
523
  type BridgeDictionary = Record<string, // map name
507
524
  Record<string, // model name
508
- Record<string, Record<string, Row$1 | Row$1[]>>>>;
509
- declare const buildBridgeDictionary: (set: FieldMapSet, rawData: Record<string, Row$1[]>) => BridgeDictionary;
525
+ Record<string, Record<string, Row$2 | Row$2[]>>>>;
526
+ declare const buildBridgeDictionary: (set: FieldMapSet, rawData: Record<string, Row$2[]>) => BridgeDictionary;
510
527
 
511
528
  declare const stitchFieldMaps: (set: FieldMapSet) => FieldMapSet;
512
529
 
@@ -552,15 +569,24 @@ type ModelDefaultNarrowing = {
552
569
  sources?: Record<string, SourceValue>;
553
570
  };
554
571
  /**
555
- * A sourced field's eligibility `where` plus an optional sibling display-label column.
556
- * At least one key is required `{}` is not a Condition; the unconstrained spelling is `true`.
572
+ * A sourced field's eligibility `where` plus an optional sibling display-label column
573
+ * and an optional `groupBy`a dotted path (to-one hops only, ending on a scalar)
574
+ * whose value partitions the option set. Grouped options carry `group`; the classic
575
+ * flat set is the ungrouped case. At least one key is required — `{}` is not a
576
+ * Condition; the unconstrained spelling is `true`.
557
577
  */
558
578
  type SourceSpec = {
559
579
  where: Condition;
560
580
  label?: string;
581
+ groupBy?: string;
561
582
  } | {
562
583
  where?: Condition;
563
584
  label: string;
585
+ groupBy?: string;
586
+ } | {
587
+ where?: Condition;
588
+ label?: string;
589
+ groupBy: string;
564
590
  };
565
591
  /** A `sources` entry: a bare eligibility `Condition`, or a richer `SourceSpec`. */
566
592
  type SourceValue = Condition | SourceSpec;
@@ -654,6 +680,8 @@ type ProjectedVisit = {
654
680
  sources: Record<string, Condition[]>;
655
681
  /** Per-field display-label column for a sourced field (from a SourceSpec's `label`). */
656
682
  sourceLabels: Record<string, string>;
683
+ /** Per-field option-partition path for a sourced field (from a SourceSpec's `groupBy`). */
684
+ sourceGroupBys: Record<string, string>;
657
685
  };
658
686
  type PathProjection = Map<string, ProjectedVisit>;
659
687
  /**
@@ -678,10 +706,18 @@ declare const exposedSurface: (lensOrNarrowing: Lens | LensNarrowing, opts?: Pro
678
706
 
679
707
  declare const validateNarrowing: (narrowing: LensNarrowing) => void;
680
708
 
709
+ /** Prisma `select` shape — nested for a grouped source's relation path. */
710
+ type SourceSelect = {
711
+ [field: string]: true | {
712
+ select: SourceSelect;
713
+ };
714
+ };
681
715
  type SourcePrismaQuery = {
682
716
  model: string;
683
- distinct: string[];
684
- select: Record<string, true>;
717
+ /** Absent for grouped sources — DISTINCT on the value column alone would collapse
718
+ * same-value rows across groups; dedup happens in `sourceValuesFromQueryRows`. */
719
+ distinct?: string[];
720
+ select: SourceSelect;
685
721
  where: PrismaWhere;
686
722
  /** Present only if the composed where used count operators (run via executePrismaQueryPlan). */
687
723
  steps?: PrismaStep[];
@@ -701,6 +737,9 @@ type SourceQuery = {
701
737
  field: string;
702
738
  /** Sibling column co-selected as each value's display label (from a SourceSpec's `label`). */
703
739
  label?: string;
740
+ /** Option-partition path (from a SourceSpec's `groupBy`); its column is selected
741
+ * nested in prisma and aliased `__group` in sql. */
742
+ groupBy?: string;
704
743
  composedWhere: Condition;
705
744
  prisma: SourcePrismaQuery;
706
745
  sql: SourceSqlQuery;
@@ -709,10 +748,25 @@ type SourceQuery = {
709
748
  * Compile a DISTINCT(value) query — Prisma and SQL — per sourced field across
710
749
  * the projected lens. The WHERE is the field's composed eligibility: the model's
711
750
  * own narrowing at that path AND its source where(s). The app runs these (with
712
- * its own client) to materialize each field's option set.
751
+ * its own client) to materialize each field's option set — feed the fetched rows
752
+ * to `sourceValuesFromQueryRows`.
713
753
  */
714
754
  declare const sourceQueries: (lensOrNarrowing: Lens | LensNarrowing) => SourceQuery[];
715
755
 
756
+ type Row$1 = Record<string, unknown>;
757
+ /** Which executor produced the rows — the caller always knows; never guessed. */
758
+ type SourceRowShape = 'prisma' | 'sql';
759
+ /**
760
+ * Materialize one compiled `SourceQuery`'s fetched rows into its `SourceValues` —
761
+ * the executor-side counterpart of `sourceQueries`, so apps never hand-map rows.
762
+ * `rowShape` names the wire format: prisma rows (default) nest the `groupBy` path
763
+ * as related objects; sql rows carry it flat under the statement's `__group` alias.
764
+ * Grouped queries fetch without DISTINCT, so dedup per (group, value) happens here.
765
+ */
766
+ declare const sourceValuesFromQueryRows: (query: SourceQuery, rows: readonly Row$1[], opts?: {
767
+ rowShape?: SourceRowShape;
768
+ }) => SourceValues;
769
+
716
770
  type Row = Record<string, unknown>;
717
771
  /**
718
772
  * Materialize each sourced field's option set from an already-fetched collection —
@@ -814,4 +868,4 @@ declare const assertValidRule: (condition: unknown, options?: {
814
868
  target?: RuleTarget;
815
869
  }) => asserts condition is Condition;
816
870
 
817
- 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 EngineGlobalsState, 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 PrismaProvider, 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, engineGlobals, executePrismaQueryPlan, exposedSurface, getArrayOperators, getOperatorsForKind, getValueShape, getWindowSupport, isAggregateRangeOperator, isAggregateSingleOperator, isOperatorSupportedForTarget, lensRequiredBindings, projectByPath, requiredBindings, resolveBindings, resolveCaseInsensitive, resolveLensBindings, sourceQueries, sourceValuesFromRows, stampCoercions, stitchFieldMaps, supportsQueryMode, toPrisma, toSql, validateBindNames, validateFieldMap, validateFieldMapSet, validateNarrowing, validateRule };
871
+ 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 EngineGlobalsState, type EnumNarrowing, FIELD_OPERATOR_CATALOG, FieldKind, type FieldMap, type FieldMapEntry, type FieldMapSet, type FuzzyConfig, 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 PrismaProvider, 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 SourceRowShape, 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, engineGlobals, executePrismaQueryPlan, exposedSurface, fuzzyContains, getArrayOperators, getOperatorsForKind, getValueShape, getWindowSupport, isAggregateRangeOperator, isAggregateSingleOperator, isOperatorSupportedForTarget, lensRequiredBindings, maxFuzzyDistance, projectByPath, requiredBindings, resolveBindings, resolveCaseInsensitive, resolveFuzzy, resolveLensBindings, sourceQueries, sourceValuesFromQueryRows, sourceValuesFromRows, stampCoercions, stitchFieldMaps, supportsQueryMode, toPrisma, toSql, validateBindNames, validateFieldMap, validateFieldMapSet, validateNarrowing, validateRule };