@inixiative/json-rules 4.2.0 → 4.5.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
@@ -112,14 +112,18 @@ type LensFieldMap = {
112
112
  readonly [enumName: string]: readonly string[];
113
113
  };
114
114
  };
115
+ /** One end of a bridge: a model of a map, named `map:Model` (`endpointKey`). */
115
116
  type BridgeEndpoint = {
116
117
  fieldMap: string;
117
118
  model: string;
119
+ };
120
+ /** One end of a joined bridge: the endpoint and the field its rows join on. */
121
+ type JoinedBridgeEndpoint = BridgeEndpoint & {
118
122
  on: string;
119
123
  };
120
124
  type BridgeCardinality = 'oneToOne' | 'oneToMany';
121
125
  /**
122
- * A cross-source edge between two endpoints.
126
+ * A cross-source edge joined on a field of each side.
123
127
  *
124
128
  * Endpoint ordering convention for `oneToMany`:
125
129
  * - `endpoints[0]` is the "one" side — its `on` field must be unique per row
@@ -133,10 +137,20 @@ type BridgeCardinality = 'oneToOne' | 'oneToMany';
133
137
  *
134
138
  * For `oneToOne`, both `on` fields must be unique; endpoint order is symmetric.
135
139
  */
136
- type Bridge = {
137
- endpoints: [BridgeEndpoint, BridgeEndpoint];
140
+ type JoinedBridge = {
141
+ endpoints: [JoinedBridgeEndpoint, JoinedBridgeEndpoint];
138
142
  cardinality: BridgeCardinality;
139
143
  };
144
+ /**
145
+ * A cross-source edge with no join, from its first endpoint to its second: the data gives the second
146
+ * endpoint's one row (keyed `map:Model`, as a joined bridge's rows are), and `recordWithBridgeData`
147
+ * puts it on each record of the first. For data that is not found by a key, such as who is acting.
148
+ */
149
+ type SuppliedBridge = {
150
+ endpoints: [BridgeEndpoint, BridgeEndpoint];
151
+ cardinality: 'oneToOne';
152
+ };
153
+ type Bridge = JoinedBridge | SuppliedBridge;
140
154
  type FieldMapSet = {
141
155
  maps: Record<string, LensFieldMap>;
142
156
  bridges?: Bridge[];
@@ -194,6 +208,17 @@ type ModelDefaultNarrowing = {
194
208
  * relation; a later layer's only what its parent shows.
195
209
  */
196
210
  relations?: Record<string, ModelNarrowing>;
211
+ /**
212
+ * The order a node's rows come back in — the root's rows, or a to-many relation's — wherever
213
+ * rows are read through the lens: `toLensSelect` (Prisma's `orderBy`) and `projectRows` (in
214
+ * memory). The window's own order: each
215
+ * key in turn, by a column of this model or of one it reaches through to-one relations
216
+ * (`org.seats`), a NULL or a row with no related one last in either direction, ties as fetched.
217
+ * Ordering narrows nothing: a later layer's (or, in one layer, the path's over the model
218
+ * default's) replaces it, and it may only name a column its parent shows. A to-one hop is one
219
+ * row, with nothing to order: `validateNarrowing` reports an `orderBy` written there.
220
+ */
221
+ orderBy?: OrderBy;
197
222
  };
198
223
  /**
199
224
  * A sourced field's eligibility `where` plus an optional display-label column — a
@@ -314,16 +339,24 @@ declare const ORDERED_VALUE_KINDS: readonly FieldKind[];
314
339
  * stored, so `1` and `Decimal('1')` stay two values unless `coerceType` reads them as one. */
315
340
  declare const DISTINCT_VALUE_KINDS: readonly FieldKind[];
316
341
  /** The aggregate modes that read values of `kind`; `{ comparable: true }` keeps the ones an
317
- * aggregate rule compares. */
342
+ * aggregate rule compares, `{ compiled: true }` the ones an aggregate rule compiles to SQL and
343
+ * Prisma. */
318
344
  declare const aggregateModesForKind: (kind: FieldKind, options?: {
319
345
  comparable?: boolean;
346
+ compiled?: boolean;
320
347
  }) => ValueAggregateMode[];
321
- /** The modes an aggregate rule compares (`sum`, `avg`). */
348
+ /** Whether an aggregate rule in `mode` compiles on `toSql` / `toPrisma` (`sum`, `avg`). */
349
+ declare const isCompiledAggregateMode: (mode: unknown) => boolean;
350
+ /** The modes an aggregate rule compares (`sum`, `avg`, `pick`). */
322
351
  declare const AGGREGATE_MODES: readonly AggregateMode[];
323
352
  /** Every mode a value expression's aggregate takes. */
324
353
  declare const VALUE_AGGREGATE_MODES: readonly ValueAggregateMode[];
325
- /** The comparisons an aggregate rule takes; every target compiles all of them. */
326
- declare const getAggregateOperators: () => readonly Operator[];
354
+ /** The comparisons an aggregate rule takes — in `mode` when given (`pick` takes more; a list
355
+ * pick, any `take` but 1, only whether the picked values hold a member: `{ list: true }`).
356
+ * `sum` / `avg` compile all of them on every target. */
357
+ declare const getAggregateOperators: (mode?: AggregateMode, options?: {
358
+ list?: boolean;
359
+ }) => readonly Operator[];
327
360
  /** The steps a clock-relative date moves by, finest first. */
328
361
  declare const CLOCK_UNITS: readonly ["second", "minute", "hour", "day", "week", "month", "quarter", "year"];
329
362
  type ClockUnit = (typeof CLOCK_UNITS)[number];
@@ -388,9 +421,11 @@ type OperatorValues = typeof Operator;
388
421
  type ArrayOperatorValues = typeof ArrayOperator;
389
422
  type DateOperatorValues = typeof DateOperator;
390
423
  type RuleScalar = string | number | boolean | null | undefined;
391
- type AggregateMode = 'sum' | 'avg';
392
- /** What a value expression's aggregate computes: an aggregate rule's modes, plus `count` and the
393
- * least / greatest item value. */
424
+ /** What an aggregate rule compares: a sum, an average, or the picked values (`pick`: the window's
425
+ * `aggregate.field` values, one for `take: 1`, a list otherwise; check() only). */
426
+ type AggregateMode = 'sum' | 'avg' | 'pick';
427
+ /** What a value expression's aggregate computes: an aggregate rule's modes, plus `count`, the
428
+ * least / greatest item value and the distinct values. */
394
429
  type ValueAggregateMode = AggregateMode | 'count' | 'min' | 'max' | 'distinct';
395
430
  type RuleValue = RuleScalar | Date | RegExp | RuleValue[] | {
396
431
  [key: string]: RuleValue;
@@ -514,10 +549,10 @@ type StrictDateComparisonRule = (DateRuleBase<DateOperatorValues['before']> & Va
514
549
  type StrictDateRangeRule = (DateRuleBase<DateOperatorValues['between']> & ValueSource<[DateInputValue, DateInputValue], DateOffset>) | (DateRuleBase<DateOperatorValues['notBetween']> & ValueSource<[DateInputValue, DateInputValue], DateOffset>);
515
550
  type StrictDateDayRule = (DateRuleBase<DateOperatorValues['dayIn']> & ValueSource<string[]>) | (DateRuleBase<DateOperatorValues['dayNotIn']> & ValueSource<string[]>);
516
551
  type StrictDateRule = StrictDateComparisonRule | StrictDateRangeRule | StrictDateDayRule;
517
- type AggregateRuleBase<TRuleValue = RuleValue, TDateValue = DateRuleValue> = {
552
+ type AggregateRuleBase<TRuleValue = RuleValue, TDateValue = DateRuleValue, TMode extends AggregateMode = Exclude<AggregateMode, 'pick'>> = {
518
553
  field: string;
519
554
  aggregate: {
520
- mode: AggregateMode;
555
+ mode: TMode;
521
556
  field?: string;
522
557
  };
523
558
  condition?: StrictCondition<TRuleValue, TDateValue>;
@@ -532,6 +567,24 @@ type StrictAggregateRule<TRuleValue = RuleValue, TDateValue = DateRuleValue> = (
532
567
  operator: AggregateRangeOperator;
533
568
  } & ValueSource<[number, number]>) | (AggregateRuleBase<TRuleValue, TDateValue> & {
534
569
  operator: AggregatePresenceOperator;
570
+ }) | StrictPickRule<TRuleValue, TDateValue>;
571
+ type PickMembershipOperator = OperatorValues['in'] | OperatorValues['notIn'];
572
+ type PickContainsOperator = OperatorValues['contains'] | OperatorValues['notContains'];
573
+ /** A `pick` aggregate rule: the picked value compared as a field holding it is — one value for
574
+ * `take: 1`, a list otherwise (which `contains` / `notContains` test for a member). */
575
+ type StrictPickRule<TRuleValue = RuleValue, TDateValue = DateRuleValue> = WindowFields & AggregateRuleBase<TRuleValue, TDateValue, 'pick'> & {
576
+ coerceType?: FieldKind;
577
+ caseInsensitive?: boolean;
578
+ } & (({
579
+ operator: AggregateSingleOperator;
580
+ } & ValueSource<OrderedRuleValue | boolean | null>) | ({
581
+ operator: AggregateRangeOperator;
582
+ } & ValueSource<[OrderedRuleValue, OrderedRuleValue]>) | ({
583
+ operator: PickMembershipOperator;
584
+ } & ValueSource<TRuleValue[]>) | ({
585
+ operator: PickContainsOperator;
586
+ } & ValueSource<TRuleValue>) | {
587
+ operator: AggregatePresenceOperator;
535
588
  });
536
589
  type SortDir = 'asc' | 'desc';
537
590
  type OrderBy = {
@@ -554,7 +607,7 @@ type AggregateRule<TRuleValue = RuleValue, TDateValue = DateRuleValue> = WindowF
554
607
  operator: Operator;
555
608
  error?: string;
556
609
  coerceType?: FieldKind;
557
- } & ValueSourceFields<number | [number, number]>;
610
+ } & ValueSourceFields<RuleValue>;
558
611
  type Rule<TValue = RuleValue> = ValueSourceFields<TValue> & {
559
612
  field: string;
560
613
  operator: Operator;
@@ -629,8 +682,8 @@ type AggregateValue<TRuleValue = RuleValue, TDateValue = DateRuleValue> = Window
629
682
  field?: string;
630
683
  };
631
684
  condition?: Condition<TRuleValue, TDateValue>;
632
- /** `distinct` / `min` / `max`: read each value as this kind first (`'10'` as 10, an ISO string
633
- * as a date, `Decimal('1')` as 1). Without it values compare as stored, kind by kind. */
685
+ /** `distinct` / `min` / `max` / `pick`: read each value as this kind first (`'10'` as 10, an ISO
686
+ * string as a date, `Decimal('1')` as 1). Without it values compare as stored, kind by kind. */
634
687
  coerceType?: FieldKind;
635
688
  /** `distinct` over strings: `'Acme'` and `'acme'` are one value (the first seen is kept).
636
689
  * Defaults to the engine's `string.caseInsensitive`. */
@@ -830,12 +883,32 @@ declare const engineGlobals: {
830
883
  with: <T>(overrides: Overrides, fn: () => T) => T;
831
884
  };
832
885
 
886
+ /** The model a relation entry leads to, in this map or across a bridge; null for a column. */
887
+ declare const relationTargetOf: (entry: FieldMapEntry, currentMap: string) => {
888
+ mapName: string;
889
+ modelName: string;
890
+ } | null;
891
+
833
892
  /** A caller's input missing or malformed — the clock, the time zone, a bind's value — not the
834
893
  * rule's or the lens's shape. */
835
894
  declare class UsageError extends Error {
836
895
  name: string;
837
896
  }
838
897
 
898
+ /** The name a bridge endpoint goes by — `map:Model`: the stitched bridge field's name and the
899
+ * raw-data key. */
900
+ declare const endpointKey: ({ fieldMap, model }: BridgeEndpoint) => string;
901
+ /** Whether a bridge joins on a field of each side, or its far row is supplied on the record. */
902
+ declare const isJoinedBridge: (bridge: Bridge) => bridge is JoinedBridge;
903
+ /** The map and model an endpoint key names; a bare model is in `currentMap`. */
904
+ declare const parseEndpointKey: (key: string, currentMap: string) => {
905
+ mapName: string;
906
+ modelName: string;
907
+ };
908
+
909
+ /** An enum field's declared values: the entry's own, else the registry's for its type. */
910
+ declare const declaredEnumValues: (entry: FieldMapEntry, enums: Record<string, readonly string[]> | undefined) => readonly string[] | undefined;
911
+
839
912
  type BridgeDictionary = Record<string, // map name
840
913
  Record<string, // model name
841
914
  Record<string, Record<string, Row | Row[]>>>>;
@@ -844,8 +917,22 @@ Record<string, Record<string, Row | Row[]>>>>;
844
917
  * Throws on a duplicate value where a side must be unique. */
845
918
  declare const indexBridges: (set: FieldMapSet, rawData: Record<string, Row[]>) => BridgeDictionary;
846
919
 
920
+ /**
921
+ * `record`, a row of the endpoint `at` (`app:Doc`) of a stitched set, with every bridge filled from `data` (rows keyed
922
+ * by endpoint, `<fieldMap>:<Model>`, as `indexBridges` takes them), and the far rows' bridges in
923
+ * turn, so a rule can read across a chain of sources (`crm:Contact.sec:Device.risk`); a related row
924
+ * (`org`) is filled as a row of its own model. Every key a row carries that names a model of the
925
+ * set's maps is dropped before its bridges are filled, so no row anywhere brings its own. A joined bridge gives the row its `on` value finds, a supplied
926
+ * bridge (from its first endpoint to its second) the one row `data` holds for its second. A chain
927
+ * never re-enters an endpoint it came through, and a far end with no row is left out, so a rule
928
+ * reading it reads a missing value. A caller filling many records from one `data` passes the
929
+ * `indexBridges` dictionary it built once.
930
+ */
931
+ declare const recordWithBridgeData: (set: FieldMapSet, at: string, record: Row, data?: Record<string, Row[]>, dictionary?: BridgeDictionary) => Row;
932
+
847
933
  /** A copy of the set where each bridge's endpoint models gain a `kind: 'bridge'` field named
848
- * after the other endpoint (`<fieldMap>:<Model>`). Throws on a missing endpoint or `on` field, a
934
+ * after the other endpoint (`<fieldMap>:<Model>`). Throws on a missing endpoint, a joined bridge's
935
+ * missing `on` field, an `on` on one side only, a supplied bridge that is not one-to-one, a
849
936
  * self-bridge, or a bridge stitched twice. */
850
937
  declare const stitchFieldMaps: (set: FieldMapSet) => FieldMapSet;
851
938
 
@@ -1099,13 +1186,30 @@ type ProjectLensOptions = {
1099
1186
  */
1100
1187
  declare const lensVisit: (lensOrNarrowing: Lens | LensNarrowing, relationPath: string, opts?: ProjectLensOptions) => ProjectedVisit | null;
1101
1188
 
1102
- /** A Prisma `select` tree: a column, or a relation with its own `select` and, to-many, `where`. */
1189
+ /** A Prisma `select` tree: a column, or a relation with its own `select` and, to-many, `where` and
1190
+ * `orderBy`. */
1103
1191
  type LensSelect = {
1104
1192
  [field: string]: true | LensRelationSelect;
1105
1193
  };
1194
+ /** What `toLensSelect` hands a `findMany`: the select, and the root rows' order when the lens
1195
+ * gives one. */
1196
+ type LensQuery = {
1197
+ select: LensSelect;
1198
+ orderBy?: LensOrderBy;
1199
+ };
1106
1200
  type LensRelationSelect = {
1107
1201
  select?: LensSelect;
1108
1202
  where?: PrismaWhere;
1203
+ orderBy?: LensOrderBy;
1204
+ };
1205
+ /** Prisma's `orderBy` for a node's rows: each key a column, nested under the to-one relations its
1206
+ * path crosses; a nullable column sorts its NULLs last, as check() orders a window. */
1207
+ type LensOrderBy = Record<string, LensOrderKey>[];
1208
+ type LensOrderKey = SortDir | {
1209
+ sort: SortDir;
1210
+ nulls: 'last';
1211
+ } | {
1212
+ [relation: string]: LensOrderKey;
1109
1213
  };
1110
1214
  /** What a clamp's compile reads: the clock, never a schema (the lens is it). */
1111
1215
  type LensSelectOptions = Omit<ToPrismaOptions, 'map' | 'mapName' | 'model' | 'lens'>;
@@ -1124,9 +1228,7 @@ type ProjectRowsOptions = CheckOptions & {
1124
1228
  * that needs a counting step, or has a window toPrisma can't compile, is refused before anything
1125
1229
  * compiles.
1126
1230
  */
1127
- declare const toLensSelect: (lensOrNarrowing: Lens | LensNarrowing, options?: LensSelectOptions) => {
1128
- select: LensSelect;
1129
- };
1231
+ declare const toLensSelect: (lensOrNarrowing: Lens | LensNarrowing, options?: LensSelectOptions) => LensQuery;
1130
1232
  /**
1131
1233
  * Rows cut to what a lens shows, recursively from its base model: hidden columns, and relations
1132
1234
  * hidden or off, removed, and every row a visit's `where` hides gone — a root or list row dropped, a to-one row
@@ -1525,11 +1627,11 @@ declare const valueExpressionShape: (expr: unknown) => ValueExpressionShape | nu
1525
1627
 
1526
1628
  /**
1527
1629
  * The path spellings `ConditionOn` passes through as `string`, unchecked: a scope ref into an
1528
- * enclosing row (`$.x`, `$$.x`), a bridge into another map (`map:Model.field`), the actor
1529
- * (`__actor.x`), and a bracket spelling (`a[0].b`). The lens gate (`validateRuleInLens`) still
1630
+ * enclosing row (`$.x`, `$$.x`), a bridge into another map (`map:Model.field`, the actor's
1631
+ * `actor:User.id` among them), and a bracket spelling (`a[0].b`). The lens gate (`validateRuleInLens`) still
1530
1632
  * reads them at run time.
1531
1633
  */
1532
- type UncheckedPath = `$.${string}` | `$$.${string}` | `${string}:${string}` | `__actor.${string}` | `${string}[${string}`;
1634
+ type UncheckedPath = `$.${string}` | `$$.${string}` | `${string}:${string}` | `${string}[${string}`;
1533
1635
  type FieldOn<M extends FieldMap, Model extends string> = ScalarPath<M, Model> | UncheckedPath;
1534
1636
  type Window<M extends FieldMap, Target extends string, Root extends string, TR, TD> = {
1535
1637
  filter?: ConditionOn<M, Target, Root, TR, TD>;
@@ -1692,8 +1794,9 @@ declare const valueClockUnit: (expression: ValueExpression) => ClockUnit | null;
1692
1794
  /**
1693
1795
  * Records sorted by an `OrderBy`, the way every rail orders a window: each key in turn, read as an
1694
1796
  * own-property path, `dir` order, a NULL (or absent) value last in either direction; ties keep their
1695
- * input order. A new array; the input is not mutated.
1797
+ * input order. A new array; the input is not mutated. `read` reads a key off a record (a lens
1798
+ * reads a Decimal column as its number).
1696
1799
  */
1697
- declare const orderRecords: <T>(items: readonly T[], orderBy: OrderBy) => T[];
1800
+ declare const orderRecords: <T>(items: readonly T[], orderBy: OrderBy, read?: (item: T, field: string) => unknown) => T[];
1698
1801
 
1699
- export { AGGREGATE_MODES, ALL_KINDS, type Absent, type AggregateMode, type AggregateRule, type AggregateValue, type All, type Any, ArrayOperator, type ArrayRule, type BareLiteral, type Bridge, type BridgeCardinality, type BridgeDictionary, type BridgeEndpoint, type BridgeEntry, CATEGORIZATION_MATCHES, CLOCK_UNITS, type Categorization, type CategorizationDescription, type CategorizationMatch, type Category, type CheckData, type CheckOptions, type ClockUnit, type CoercedLiteral, type CompileOptions, type Condition, type ConditionOn, ConditionShape, type ConditionShapeKeys, DISTINCT_VALUE_KINDS, 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 FieldMapEntry, type FieldMapSet, type FuzzyConfig, type GroupByStep, type IfThenElse, type IfThenElseValue, type Lens, type LensClamps, type LensFieldMap, type LensModelEntry, type LensNarrowing, type LensNarrowingOn, type LensPathHop, type LensPathResolution, LensRefusal, type LensRelationSelect, type LensSelect, type LensSelectOptions, type LensValue, type LensWhereSql, type LensWhereSqlOptions, type ListBindingsOptions, type ListValue, type Magnitude, type MaterializeSourceQueryOptions, type ModelDefaultNarrowing, type ModelNarrowing, type ModelNarrowingOn, NUMERIC_KINDS, type NarrowingDefaults, type NumberOffset, ORDERED_VALUE_KINDS, 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, type UncheckedPath, UsageError, VALUE_AGGREGATE_MODES, type ValidateRuleOptions, type ValidationIssue, type ValidationResult, type ValueAggregateMode, type ValueDescription, type ValueExpression, ValueExpressionShape, ValueShape, type ValueSourceFields, type ValueSourceOf, type ValueType, type WeekStart, type WhereSqlOptions, type WhereStep, type WindowFields, aggregateModesForKind, andWhere, assertValidCategorization, assertValidFieldMaps, assertValidNarrowing, assertValidRule, assertValidValue, bindLens, bindRule, categorize, check, clampLens, clockUnit, coerceRule, coerceValue, composeLens, createLens, describeCategorization, describeRule, describeRuleSources, describeValue, engineGlobals, evaluateValue, executePrismaPlan, getAggregateOperators, getArrayOperators, getConditionShapeKeys, getLensRoot, getOperatorsForKind, getValueShape, indexBridges, inferValueType, lensVisit, listBindings, listFields, listItems, listLensBindings, matchAll, matchNothing, materializeSourceQuery, materializeSources, narrowRule, orWhere, orderRecords, parseScopeRef, pathSegments, prefixConditionFields, projectLens, projectRows, readLensValue, readScopeRef, registerEngineGlobals, stitchFieldMaps, storeLens, toLensSelect, toLensWhereSql, toPrisma, toSourceQueries, toSql, toWhereSql, validateCategorization, validateFieldMaps, validateNarrowing, validateRule, validateRuleInLens, validateValue, valueClockUnit, valueExpressionShape, walkLensPath };
1802
+ export { AGGREGATE_MODES, ALL_KINDS, type Absent, type AggregateMode, type AggregateRule, type AggregateValue, type All, type Any, ArrayOperator, type ArrayRule, type BareLiteral, type Bridge, type BridgeCardinality, type BridgeDictionary, type BridgeEndpoint, type BridgeEntry, CATEGORIZATION_MATCHES, CLOCK_UNITS, type Categorization, type CategorizationDescription, type CategorizationMatch, type Category, type CheckData, type CheckOptions, type ClockUnit, type CoercedLiteral, type CompileOptions, type Condition, type ConditionOn, ConditionShape, type ConditionShapeKeys, DISTINCT_VALUE_KINDS, 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 FieldMapEntry, type FieldMapSet, type FuzzyConfig, type GroupByStep, type IfThenElse, type IfThenElseValue, type JoinedBridge, type JoinedBridgeEndpoint, type Lens, type LensClamps, type LensFieldMap, type LensModelEntry, type LensNarrowing, type LensNarrowingOn, type LensOrderBy, type LensOrderKey, type LensPathHop, type LensPathResolution, type LensQuery, LensRefusal, type LensRelationSelect, type LensSelect, type LensSelectOptions, type LensValue, type LensWhereSql, type LensWhereSqlOptions, type ListBindingsOptions, type ListValue, type Magnitude, type MaterializeSourceQueryOptions, type ModelDefaultNarrowing, type ModelNarrowing, type ModelNarrowingOn, NUMERIC_KINDS, type NarrowingDefaults, type NumberOffset, ORDERED_VALUE_KINDS, 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 StrictPickRule, type StrictPresenceRule, type StrictRangeRule, type StrictRule, type StrictStringBoundaryRule, type SuppliedBridge, type TimeZoneConfig, type ToPrismaOptions, type ToPrismaResult, type ToSqlOptions, type ToSqlResult, type UncheckedPath, UsageError, VALUE_AGGREGATE_MODES, type ValidateRuleOptions, type ValidationIssue, type ValidationResult, type ValueAggregateMode, type ValueDescription, type ValueExpression, ValueExpressionShape, ValueShape, type ValueSourceFields, type ValueSourceOf, type ValueType, type WeekStart, type WhereSqlOptions, type WhereStep, type WindowFields, aggregateModesForKind, andWhere, assertValidCategorization, assertValidFieldMaps, assertValidNarrowing, assertValidRule, assertValidValue, bindLens, bindRule, categorize, check, clampLens, clockUnit, coerceRule, coerceValue, composeLens, createLens, declaredEnumValues, describeCategorization, describeRule, describeRuleSources, describeValue, endpointKey, engineGlobals, evaluateValue, executePrismaPlan, getAggregateOperators, getArrayOperators, getConditionShapeKeys, getLensRoot, getOperatorsForKind, getValueShape, indexBridges, inferValueType, isCompiledAggregateMode, isJoinedBridge, lensVisit, listBindings, listFields, listItems, listLensBindings, matchAll, matchNothing, materializeSourceQuery, materializeSources, narrowRule, orWhere, orderRecords, parseEndpointKey, parseScopeRef, pathSegments, prefixConditionFields, projectLens, projectRows, readLensValue, readScopeRef, recordWithBridgeData, registerEngineGlobals, relationTargetOf, stitchFieldMaps, storeLens, toLensSelect, toLensWhereSql, toPrisma, toSourceQueries, toSql, toWhereSql, validateCategorization, validateFieldMaps, validateNarrowing, validateRule, validateRuleInLens, validateValue, valueClockUnit, valueExpressionShape, walkLensPath };
package/dist/index.d.ts CHANGED
@@ -112,14 +112,18 @@ type LensFieldMap = {
112
112
  readonly [enumName: string]: readonly string[];
113
113
  };
114
114
  };
115
+ /** One end of a bridge: a model of a map, named `map:Model` (`endpointKey`). */
115
116
  type BridgeEndpoint = {
116
117
  fieldMap: string;
117
118
  model: string;
119
+ };
120
+ /** One end of a joined bridge: the endpoint and the field its rows join on. */
121
+ type JoinedBridgeEndpoint = BridgeEndpoint & {
118
122
  on: string;
119
123
  };
120
124
  type BridgeCardinality = 'oneToOne' | 'oneToMany';
121
125
  /**
122
- * A cross-source edge between two endpoints.
126
+ * A cross-source edge joined on a field of each side.
123
127
  *
124
128
  * Endpoint ordering convention for `oneToMany`:
125
129
  * - `endpoints[0]` is the "one" side — its `on` field must be unique per row
@@ -133,10 +137,20 @@ type BridgeCardinality = 'oneToOne' | 'oneToMany';
133
137
  *
134
138
  * For `oneToOne`, both `on` fields must be unique; endpoint order is symmetric.
135
139
  */
136
- type Bridge = {
137
- endpoints: [BridgeEndpoint, BridgeEndpoint];
140
+ type JoinedBridge = {
141
+ endpoints: [JoinedBridgeEndpoint, JoinedBridgeEndpoint];
138
142
  cardinality: BridgeCardinality;
139
143
  };
144
+ /**
145
+ * A cross-source edge with no join, from its first endpoint to its second: the data gives the second
146
+ * endpoint's one row (keyed `map:Model`, as a joined bridge's rows are), and `recordWithBridgeData`
147
+ * puts it on each record of the first. For data that is not found by a key, such as who is acting.
148
+ */
149
+ type SuppliedBridge = {
150
+ endpoints: [BridgeEndpoint, BridgeEndpoint];
151
+ cardinality: 'oneToOne';
152
+ };
153
+ type Bridge = JoinedBridge | SuppliedBridge;
140
154
  type FieldMapSet = {
141
155
  maps: Record<string, LensFieldMap>;
142
156
  bridges?: Bridge[];
@@ -194,6 +208,17 @@ type ModelDefaultNarrowing = {
194
208
  * relation; a later layer's only what its parent shows.
195
209
  */
196
210
  relations?: Record<string, ModelNarrowing>;
211
+ /**
212
+ * The order a node's rows come back in — the root's rows, or a to-many relation's — wherever
213
+ * rows are read through the lens: `toLensSelect` (Prisma's `orderBy`) and `projectRows` (in
214
+ * memory). The window's own order: each
215
+ * key in turn, by a column of this model or of one it reaches through to-one relations
216
+ * (`org.seats`), a NULL or a row with no related one last in either direction, ties as fetched.
217
+ * Ordering narrows nothing: a later layer's (or, in one layer, the path's over the model
218
+ * default's) replaces it, and it may only name a column its parent shows. A to-one hop is one
219
+ * row, with nothing to order: `validateNarrowing` reports an `orderBy` written there.
220
+ */
221
+ orderBy?: OrderBy;
197
222
  };
198
223
  /**
199
224
  * A sourced field's eligibility `where` plus an optional display-label column — a
@@ -314,16 +339,24 @@ declare const ORDERED_VALUE_KINDS: readonly FieldKind[];
314
339
  * stored, so `1` and `Decimal('1')` stay two values unless `coerceType` reads them as one. */
315
340
  declare const DISTINCT_VALUE_KINDS: readonly FieldKind[];
316
341
  /** The aggregate modes that read values of `kind`; `{ comparable: true }` keeps the ones an
317
- * aggregate rule compares. */
342
+ * aggregate rule compares, `{ compiled: true }` the ones an aggregate rule compiles to SQL and
343
+ * Prisma. */
318
344
  declare const aggregateModesForKind: (kind: FieldKind, options?: {
319
345
  comparable?: boolean;
346
+ compiled?: boolean;
320
347
  }) => ValueAggregateMode[];
321
- /** The modes an aggregate rule compares (`sum`, `avg`). */
348
+ /** Whether an aggregate rule in `mode` compiles on `toSql` / `toPrisma` (`sum`, `avg`). */
349
+ declare const isCompiledAggregateMode: (mode: unknown) => boolean;
350
+ /** The modes an aggregate rule compares (`sum`, `avg`, `pick`). */
322
351
  declare const AGGREGATE_MODES: readonly AggregateMode[];
323
352
  /** Every mode a value expression's aggregate takes. */
324
353
  declare const VALUE_AGGREGATE_MODES: readonly ValueAggregateMode[];
325
- /** The comparisons an aggregate rule takes; every target compiles all of them. */
326
- declare const getAggregateOperators: () => readonly Operator[];
354
+ /** The comparisons an aggregate rule takes — in `mode` when given (`pick` takes more; a list
355
+ * pick, any `take` but 1, only whether the picked values hold a member: `{ list: true }`).
356
+ * `sum` / `avg` compile all of them on every target. */
357
+ declare const getAggregateOperators: (mode?: AggregateMode, options?: {
358
+ list?: boolean;
359
+ }) => readonly Operator[];
327
360
  /** The steps a clock-relative date moves by, finest first. */
328
361
  declare const CLOCK_UNITS: readonly ["second", "minute", "hour", "day", "week", "month", "quarter", "year"];
329
362
  type ClockUnit = (typeof CLOCK_UNITS)[number];
@@ -388,9 +421,11 @@ type OperatorValues = typeof Operator;
388
421
  type ArrayOperatorValues = typeof ArrayOperator;
389
422
  type DateOperatorValues = typeof DateOperator;
390
423
  type RuleScalar = string | number | boolean | null | undefined;
391
- type AggregateMode = 'sum' | 'avg';
392
- /** What a value expression's aggregate computes: an aggregate rule's modes, plus `count` and the
393
- * least / greatest item value. */
424
+ /** What an aggregate rule compares: a sum, an average, or the picked values (`pick`: the window's
425
+ * `aggregate.field` values, one for `take: 1`, a list otherwise; check() only). */
426
+ type AggregateMode = 'sum' | 'avg' | 'pick';
427
+ /** What a value expression's aggregate computes: an aggregate rule's modes, plus `count`, the
428
+ * least / greatest item value and the distinct values. */
394
429
  type ValueAggregateMode = AggregateMode | 'count' | 'min' | 'max' | 'distinct';
395
430
  type RuleValue = RuleScalar | Date | RegExp | RuleValue[] | {
396
431
  [key: string]: RuleValue;
@@ -514,10 +549,10 @@ type StrictDateComparisonRule = (DateRuleBase<DateOperatorValues['before']> & Va
514
549
  type StrictDateRangeRule = (DateRuleBase<DateOperatorValues['between']> & ValueSource<[DateInputValue, DateInputValue], DateOffset>) | (DateRuleBase<DateOperatorValues['notBetween']> & ValueSource<[DateInputValue, DateInputValue], DateOffset>);
515
550
  type StrictDateDayRule = (DateRuleBase<DateOperatorValues['dayIn']> & ValueSource<string[]>) | (DateRuleBase<DateOperatorValues['dayNotIn']> & ValueSource<string[]>);
516
551
  type StrictDateRule = StrictDateComparisonRule | StrictDateRangeRule | StrictDateDayRule;
517
- type AggregateRuleBase<TRuleValue = RuleValue, TDateValue = DateRuleValue> = {
552
+ type AggregateRuleBase<TRuleValue = RuleValue, TDateValue = DateRuleValue, TMode extends AggregateMode = Exclude<AggregateMode, 'pick'>> = {
518
553
  field: string;
519
554
  aggregate: {
520
- mode: AggregateMode;
555
+ mode: TMode;
521
556
  field?: string;
522
557
  };
523
558
  condition?: StrictCondition<TRuleValue, TDateValue>;
@@ -532,6 +567,24 @@ type StrictAggregateRule<TRuleValue = RuleValue, TDateValue = DateRuleValue> = (
532
567
  operator: AggregateRangeOperator;
533
568
  } & ValueSource<[number, number]>) | (AggregateRuleBase<TRuleValue, TDateValue> & {
534
569
  operator: AggregatePresenceOperator;
570
+ }) | StrictPickRule<TRuleValue, TDateValue>;
571
+ type PickMembershipOperator = OperatorValues['in'] | OperatorValues['notIn'];
572
+ type PickContainsOperator = OperatorValues['contains'] | OperatorValues['notContains'];
573
+ /** A `pick` aggregate rule: the picked value compared as a field holding it is — one value for
574
+ * `take: 1`, a list otherwise (which `contains` / `notContains` test for a member). */
575
+ type StrictPickRule<TRuleValue = RuleValue, TDateValue = DateRuleValue> = WindowFields & AggregateRuleBase<TRuleValue, TDateValue, 'pick'> & {
576
+ coerceType?: FieldKind;
577
+ caseInsensitive?: boolean;
578
+ } & (({
579
+ operator: AggregateSingleOperator;
580
+ } & ValueSource<OrderedRuleValue | boolean | null>) | ({
581
+ operator: AggregateRangeOperator;
582
+ } & ValueSource<[OrderedRuleValue, OrderedRuleValue]>) | ({
583
+ operator: PickMembershipOperator;
584
+ } & ValueSource<TRuleValue[]>) | ({
585
+ operator: PickContainsOperator;
586
+ } & ValueSource<TRuleValue>) | {
587
+ operator: AggregatePresenceOperator;
535
588
  });
536
589
  type SortDir = 'asc' | 'desc';
537
590
  type OrderBy = {
@@ -554,7 +607,7 @@ type AggregateRule<TRuleValue = RuleValue, TDateValue = DateRuleValue> = WindowF
554
607
  operator: Operator;
555
608
  error?: string;
556
609
  coerceType?: FieldKind;
557
- } & ValueSourceFields<number | [number, number]>;
610
+ } & ValueSourceFields<RuleValue>;
558
611
  type Rule<TValue = RuleValue> = ValueSourceFields<TValue> & {
559
612
  field: string;
560
613
  operator: Operator;
@@ -629,8 +682,8 @@ type AggregateValue<TRuleValue = RuleValue, TDateValue = DateRuleValue> = Window
629
682
  field?: string;
630
683
  };
631
684
  condition?: Condition<TRuleValue, TDateValue>;
632
- /** `distinct` / `min` / `max`: read each value as this kind first (`'10'` as 10, an ISO string
633
- * as a date, `Decimal('1')` as 1). Without it values compare as stored, kind by kind. */
685
+ /** `distinct` / `min` / `max` / `pick`: read each value as this kind first (`'10'` as 10, an ISO
686
+ * string as a date, `Decimal('1')` as 1). Without it values compare as stored, kind by kind. */
634
687
  coerceType?: FieldKind;
635
688
  /** `distinct` over strings: `'Acme'` and `'acme'` are one value (the first seen is kept).
636
689
  * Defaults to the engine's `string.caseInsensitive`. */
@@ -830,12 +883,32 @@ declare const engineGlobals: {
830
883
  with: <T>(overrides: Overrides, fn: () => T) => T;
831
884
  };
832
885
 
886
+ /** The model a relation entry leads to, in this map or across a bridge; null for a column. */
887
+ declare const relationTargetOf: (entry: FieldMapEntry, currentMap: string) => {
888
+ mapName: string;
889
+ modelName: string;
890
+ } | null;
891
+
833
892
  /** A caller's input missing or malformed — the clock, the time zone, a bind's value — not the
834
893
  * rule's or the lens's shape. */
835
894
  declare class UsageError extends Error {
836
895
  name: string;
837
896
  }
838
897
 
898
+ /** The name a bridge endpoint goes by — `map:Model`: the stitched bridge field's name and the
899
+ * raw-data key. */
900
+ declare const endpointKey: ({ fieldMap, model }: BridgeEndpoint) => string;
901
+ /** Whether a bridge joins on a field of each side, or its far row is supplied on the record. */
902
+ declare const isJoinedBridge: (bridge: Bridge) => bridge is JoinedBridge;
903
+ /** The map and model an endpoint key names; a bare model is in `currentMap`. */
904
+ declare const parseEndpointKey: (key: string, currentMap: string) => {
905
+ mapName: string;
906
+ modelName: string;
907
+ };
908
+
909
+ /** An enum field's declared values: the entry's own, else the registry's for its type. */
910
+ declare const declaredEnumValues: (entry: FieldMapEntry, enums: Record<string, readonly string[]> | undefined) => readonly string[] | undefined;
911
+
839
912
  type BridgeDictionary = Record<string, // map name
840
913
  Record<string, // model name
841
914
  Record<string, Record<string, Row | Row[]>>>>;
@@ -844,8 +917,22 @@ Record<string, Record<string, Row | Row[]>>>>;
844
917
  * Throws on a duplicate value where a side must be unique. */
845
918
  declare const indexBridges: (set: FieldMapSet, rawData: Record<string, Row[]>) => BridgeDictionary;
846
919
 
920
+ /**
921
+ * `record`, a row of the endpoint `at` (`app:Doc`) of a stitched set, with every bridge filled from `data` (rows keyed
922
+ * by endpoint, `<fieldMap>:<Model>`, as `indexBridges` takes them), and the far rows' bridges in
923
+ * turn, so a rule can read across a chain of sources (`crm:Contact.sec:Device.risk`); a related row
924
+ * (`org`) is filled as a row of its own model. Every key a row carries that names a model of the
925
+ * set's maps is dropped before its bridges are filled, so no row anywhere brings its own. A joined bridge gives the row its `on` value finds, a supplied
926
+ * bridge (from its first endpoint to its second) the one row `data` holds for its second. A chain
927
+ * never re-enters an endpoint it came through, and a far end with no row is left out, so a rule
928
+ * reading it reads a missing value. A caller filling many records from one `data` passes the
929
+ * `indexBridges` dictionary it built once.
930
+ */
931
+ declare const recordWithBridgeData: (set: FieldMapSet, at: string, record: Row, data?: Record<string, Row[]>, dictionary?: BridgeDictionary) => Row;
932
+
847
933
  /** A copy of the set where each bridge's endpoint models gain a `kind: 'bridge'` field named
848
- * after the other endpoint (`<fieldMap>:<Model>`). Throws on a missing endpoint or `on` field, a
934
+ * after the other endpoint (`<fieldMap>:<Model>`). Throws on a missing endpoint, a joined bridge's
935
+ * missing `on` field, an `on` on one side only, a supplied bridge that is not one-to-one, a
849
936
  * self-bridge, or a bridge stitched twice. */
850
937
  declare const stitchFieldMaps: (set: FieldMapSet) => FieldMapSet;
851
938
 
@@ -1099,13 +1186,30 @@ type ProjectLensOptions = {
1099
1186
  */
1100
1187
  declare const lensVisit: (lensOrNarrowing: Lens | LensNarrowing, relationPath: string, opts?: ProjectLensOptions) => ProjectedVisit | null;
1101
1188
 
1102
- /** A Prisma `select` tree: a column, or a relation with its own `select` and, to-many, `where`. */
1189
+ /** A Prisma `select` tree: a column, or a relation with its own `select` and, to-many, `where` and
1190
+ * `orderBy`. */
1103
1191
  type LensSelect = {
1104
1192
  [field: string]: true | LensRelationSelect;
1105
1193
  };
1194
+ /** What `toLensSelect` hands a `findMany`: the select, and the root rows' order when the lens
1195
+ * gives one. */
1196
+ type LensQuery = {
1197
+ select: LensSelect;
1198
+ orderBy?: LensOrderBy;
1199
+ };
1106
1200
  type LensRelationSelect = {
1107
1201
  select?: LensSelect;
1108
1202
  where?: PrismaWhere;
1203
+ orderBy?: LensOrderBy;
1204
+ };
1205
+ /** Prisma's `orderBy` for a node's rows: each key a column, nested under the to-one relations its
1206
+ * path crosses; a nullable column sorts its NULLs last, as check() orders a window. */
1207
+ type LensOrderBy = Record<string, LensOrderKey>[];
1208
+ type LensOrderKey = SortDir | {
1209
+ sort: SortDir;
1210
+ nulls: 'last';
1211
+ } | {
1212
+ [relation: string]: LensOrderKey;
1109
1213
  };
1110
1214
  /** What a clamp's compile reads: the clock, never a schema (the lens is it). */
1111
1215
  type LensSelectOptions = Omit<ToPrismaOptions, 'map' | 'mapName' | 'model' | 'lens'>;
@@ -1124,9 +1228,7 @@ type ProjectRowsOptions = CheckOptions & {
1124
1228
  * that needs a counting step, or has a window toPrisma can't compile, is refused before anything
1125
1229
  * compiles.
1126
1230
  */
1127
- declare const toLensSelect: (lensOrNarrowing: Lens | LensNarrowing, options?: LensSelectOptions) => {
1128
- select: LensSelect;
1129
- };
1231
+ declare const toLensSelect: (lensOrNarrowing: Lens | LensNarrowing, options?: LensSelectOptions) => LensQuery;
1130
1232
  /**
1131
1233
  * Rows cut to what a lens shows, recursively from its base model: hidden columns, and relations
1132
1234
  * hidden or off, removed, and every row a visit's `where` hides gone — a root or list row dropped, a to-one row
@@ -1525,11 +1627,11 @@ declare const valueExpressionShape: (expr: unknown) => ValueExpressionShape | nu
1525
1627
 
1526
1628
  /**
1527
1629
  * The path spellings `ConditionOn` passes through as `string`, unchecked: a scope ref into an
1528
- * enclosing row (`$.x`, `$$.x`), a bridge into another map (`map:Model.field`), the actor
1529
- * (`__actor.x`), and a bracket spelling (`a[0].b`). The lens gate (`validateRuleInLens`) still
1630
+ * enclosing row (`$.x`, `$$.x`), a bridge into another map (`map:Model.field`, the actor's
1631
+ * `actor:User.id` among them), and a bracket spelling (`a[0].b`). The lens gate (`validateRuleInLens`) still
1530
1632
  * reads them at run time.
1531
1633
  */
1532
- type UncheckedPath = `$.${string}` | `$$.${string}` | `${string}:${string}` | `__actor.${string}` | `${string}[${string}`;
1634
+ type UncheckedPath = `$.${string}` | `$$.${string}` | `${string}:${string}` | `${string}[${string}`;
1533
1635
  type FieldOn<M extends FieldMap, Model extends string> = ScalarPath<M, Model> | UncheckedPath;
1534
1636
  type Window<M extends FieldMap, Target extends string, Root extends string, TR, TD> = {
1535
1637
  filter?: ConditionOn<M, Target, Root, TR, TD>;
@@ -1692,8 +1794,9 @@ declare const valueClockUnit: (expression: ValueExpression) => ClockUnit | null;
1692
1794
  /**
1693
1795
  * Records sorted by an `OrderBy`, the way every rail orders a window: each key in turn, read as an
1694
1796
  * own-property path, `dir` order, a NULL (or absent) value last in either direction; ties keep their
1695
- * input order. A new array; the input is not mutated.
1797
+ * input order. A new array; the input is not mutated. `read` reads a key off a record (a lens
1798
+ * reads a Decimal column as its number).
1696
1799
  */
1697
- declare const orderRecords: <T>(items: readonly T[], orderBy: OrderBy) => T[];
1800
+ declare const orderRecords: <T>(items: readonly T[], orderBy: OrderBy, read?: (item: T, field: string) => unknown) => T[];
1698
1801
 
1699
- export { AGGREGATE_MODES, ALL_KINDS, type Absent, type AggregateMode, type AggregateRule, type AggregateValue, type All, type Any, ArrayOperator, type ArrayRule, type BareLiteral, type Bridge, type BridgeCardinality, type BridgeDictionary, type BridgeEndpoint, type BridgeEntry, CATEGORIZATION_MATCHES, CLOCK_UNITS, type Categorization, type CategorizationDescription, type CategorizationMatch, type Category, type CheckData, type CheckOptions, type ClockUnit, type CoercedLiteral, type CompileOptions, type Condition, type ConditionOn, ConditionShape, type ConditionShapeKeys, DISTINCT_VALUE_KINDS, 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 FieldMapEntry, type FieldMapSet, type FuzzyConfig, type GroupByStep, type IfThenElse, type IfThenElseValue, type Lens, type LensClamps, type LensFieldMap, type LensModelEntry, type LensNarrowing, type LensNarrowingOn, type LensPathHop, type LensPathResolution, LensRefusal, type LensRelationSelect, type LensSelect, type LensSelectOptions, type LensValue, type LensWhereSql, type LensWhereSqlOptions, type ListBindingsOptions, type ListValue, type Magnitude, type MaterializeSourceQueryOptions, type ModelDefaultNarrowing, type ModelNarrowing, type ModelNarrowingOn, NUMERIC_KINDS, type NarrowingDefaults, type NumberOffset, ORDERED_VALUE_KINDS, 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, type UncheckedPath, UsageError, VALUE_AGGREGATE_MODES, type ValidateRuleOptions, type ValidationIssue, type ValidationResult, type ValueAggregateMode, type ValueDescription, type ValueExpression, ValueExpressionShape, ValueShape, type ValueSourceFields, type ValueSourceOf, type ValueType, type WeekStart, type WhereSqlOptions, type WhereStep, type WindowFields, aggregateModesForKind, andWhere, assertValidCategorization, assertValidFieldMaps, assertValidNarrowing, assertValidRule, assertValidValue, bindLens, bindRule, categorize, check, clampLens, clockUnit, coerceRule, coerceValue, composeLens, createLens, describeCategorization, describeRule, describeRuleSources, describeValue, engineGlobals, evaluateValue, executePrismaPlan, getAggregateOperators, getArrayOperators, getConditionShapeKeys, getLensRoot, getOperatorsForKind, getValueShape, indexBridges, inferValueType, lensVisit, listBindings, listFields, listItems, listLensBindings, matchAll, matchNothing, materializeSourceQuery, materializeSources, narrowRule, orWhere, orderRecords, parseScopeRef, pathSegments, prefixConditionFields, projectLens, projectRows, readLensValue, readScopeRef, registerEngineGlobals, stitchFieldMaps, storeLens, toLensSelect, toLensWhereSql, toPrisma, toSourceQueries, toSql, toWhereSql, validateCategorization, validateFieldMaps, validateNarrowing, validateRule, validateRuleInLens, validateValue, valueClockUnit, valueExpressionShape, walkLensPath };
1802
+ export { AGGREGATE_MODES, ALL_KINDS, type Absent, type AggregateMode, type AggregateRule, type AggregateValue, type All, type Any, ArrayOperator, type ArrayRule, type BareLiteral, type Bridge, type BridgeCardinality, type BridgeDictionary, type BridgeEndpoint, type BridgeEntry, CATEGORIZATION_MATCHES, CLOCK_UNITS, type Categorization, type CategorizationDescription, type CategorizationMatch, type Category, type CheckData, type CheckOptions, type ClockUnit, type CoercedLiteral, type CompileOptions, type Condition, type ConditionOn, ConditionShape, type ConditionShapeKeys, DISTINCT_VALUE_KINDS, 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 FieldMapEntry, type FieldMapSet, type FuzzyConfig, type GroupByStep, type IfThenElse, type IfThenElseValue, type JoinedBridge, type JoinedBridgeEndpoint, type Lens, type LensClamps, type LensFieldMap, type LensModelEntry, type LensNarrowing, type LensNarrowingOn, type LensOrderBy, type LensOrderKey, type LensPathHop, type LensPathResolution, type LensQuery, LensRefusal, type LensRelationSelect, type LensSelect, type LensSelectOptions, type LensValue, type LensWhereSql, type LensWhereSqlOptions, type ListBindingsOptions, type ListValue, type Magnitude, type MaterializeSourceQueryOptions, type ModelDefaultNarrowing, type ModelNarrowing, type ModelNarrowingOn, NUMERIC_KINDS, type NarrowingDefaults, type NumberOffset, ORDERED_VALUE_KINDS, 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 StrictPickRule, type StrictPresenceRule, type StrictRangeRule, type StrictRule, type StrictStringBoundaryRule, type SuppliedBridge, type TimeZoneConfig, type ToPrismaOptions, type ToPrismaResult, type ToSqlOptions, type ToSqlResult, type UncheckedPath, UsageError, VALUE_AGGREGATE_MODES, type ValidateRuleOptions, type ValidationIssue, type ValidationResult, type ValueAggregateMode, type ValueDescription, type ValueExpression, ValueExpressionShape, ValueShape, type ValueSourceFields, type ValueSourceOf, type ValueType, type WeekStart, type WhereSqlOptions, type WhereStep, type WindowFields, aggregateModesForKind, andWhere, assertValidCategorization, assertValidFieldMaps, assertValidNarrowing, assertValidRule, assertValidValue, bindLens, bindRule, categorize, check, clampLens, clockUnit, coerceRule, coerceValue, composeLens, createLens, declaredEnumValues, describeCategorization, describeRule, describeRuleSources, describeValue, endpointKey, engineGlobals, evaluateValue, executePrismaPlan, getAggregateOperators, getArrayOperators, getConditionShapeKeys, getLensRoot, getOperatorsForKind, getValueShape, indexBridges, inferValueType, isCompiledAggregateMode, isJoinedBridge, lensVisit, listBindings, listFields, listItems, listLensBindings, matchAll, matchNothing, materializeSourceQuery, materializeSources, narrowRule, orWhere, orderRecords, parseEndpointKey, parseScopeRef, pathSegments, prefixConditionFields, projectLens, projectRows, readLensValue, readScopeRef, recordWithBridgeData, registerEngineGlobals, relationTargetOf, stitchFieldMaps, storeLens, toLensSelect, toLensWhereSql, toPrisma, toSourceQueries, toSql, toWhereSql, validateCategorization, validateFieldMaps, validateNarrowing, validateRule, validateRuleInLens, validateValue, valueClockUnit, valueExpressionShape, walkLensPath };