@inixiative/json-rules 4.3.0 → 4.5.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
@@ -142,9 +142,9 @@ type JoinedBridge = {
142
142
  cardinality: BridgeCardinality;
143
143
  };
144
144
  /**
145
- * A cross-source edge with no join: the caller supplies the far row on the record under its
146
- * endpoint key (`map:Model`), as it would after `indexBridges` for a joined one. For data that is
147
- * not found by a key, such as who is acting. One row each way.
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
148
  */
149
149
  type SuppliedBridge = {
150
150
  endpoints: [BridgeEndpoint, BridgeEndpoint];
@@ -208,6 +208,17 @@ type ModelDefaultNarrowing = {
208
208
  * relation; a later layer's only what its parent shows.
209
209
  */
210
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;
211
222
  };
212
223
  /**
213
224
  * A sourced field's eligibility `where` plus an optional display-label column — a
@@ -328,16 +339,24 @@ declare const ORDERED_VALUE_KINDS: readonly FieldKind[];
328
339
  * stored, so `1` and `Decimal('1')` stay two values unless `coerceType` reads them as one. */
329
340
  declare const DISTINCT_VALUE_KINDS: readonly FieldKind[];
330
341
  /** The aggregate modes that read values of `kind`; `{ comparable: true }` keeps the ones an
331
- * aggregate rule compares. */
342
+ * aggregate rule compares, `{ compiled: true }` the ones an aggregate rule compiles to SQL and
343
+ * Prisma. */
332
344
  declare const aggregateModesForKind: (kind: FieldKind, options?: {
333
345
  comparable?: boolean;
346
+ compiled?: boolean;
334
347
  }) => ValueAggregateMode[];
335
- /** 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`). */
336
351
  declare const AGGREGATE_MODES: readonly AggregateMode[];
337
352
  /** Every mode a value expression's aggregate takes. */
338
353
  declare const VALUE_AGGREGATE_MODES: readonly ValueAggregateMode[];
339
- /** The comparisons an aggregate rule takes; every target compiles all of them. */
340
- 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[];
341
360
  /** The steps a clock-relative date moves by, finest first. */
342
361
  declare const CLOCK_UNITS: readonly ["second", "minute", "hour", "day", "week", "month", "quarter", "year"];
343
362
  type ClockUnit = (typeof CLOCK_UNITS)[number];
@@ -402,9 +421,11 @@ type OperatorValues = typeof Operator;
402
421
  type ArrayOperatorValues = typeof ArrayOperator;
403
422
  type DateOperatorValues = typeof DateOperator;
404
423
  type RuleScalar = string | number | boolean | null | undefined;
405
- type AggregateMode = 'sum' | 'avg';
406
- /** What a value expression's aggregate computes: an aggregate rule's modes, plus `count` and the
407
- * 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. */
408
429
  type ValueAggregateMode = AggregateMode | 'count' | 'min' | 'max' | 'distinct';
409
430
  type RuleValue = RuleScalar | Date | RegExp | RuleValue[] | {
410
431
  [key: string]: RuleValue;
@@ -528,10 +549,10 @@ type StrictDateComparisonRule = (DateRuleBase<DateOperatorValues['before']> & Va
528
549
  type StrictDateRangeRule = (DateRuleBase<DateOperatorValues['between']> & ValueSource<[DateInputValue, DateInputValue], DateOffset>) | (DateRuleBase<DateOperatorValues['notBetween']> & ValueSource<[DateInputValue, DateInputValue], DateOffset>);
529
550
  type StrictDateDayRule = (DateRuleBase<DateOperatorValues['dayIn']> & ValueSource<string[]>) | (DateRuleBase<DateOperatorValues['dayNotIn']> & ValueSource<string[]>);
530
551
  type StrictDateRule = StrictDateComparisonRule | StrictDateRangeRule | StrictDateDayRule;
531
- type AggregateRuleBase<TRuleValue = RuleValue, TDateValue = DateRuleValue> = {
552
+ type AggregateRuleBase<TRuleValue = RuleValue, TDateValue = DateRuleValue, TMode extends AggregateMode = Exclude<AggregateMode, 'pick'>> = {
532
553
  field: string;
533
554
  aggregate: {
534
- mode: AggregateMode;
555
+ mode: TMode;
535
556
  field?: string;
536
557
  };
537
558
  condition?: StrictCondition<TRuleValue, TDateValue>;
@@ -546,6 +567,24 @@ type StrictAggregateRule<TRuleValue = RuleValue, TDateValue = DateRuleValue> = (
546
567
  operator: AggregateRangeOperator;
547
568
  } & ValueSource<[number, number]>) | (AggregateRuleBase<TRuleValue, TDateValue> & {
548
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;
549
588
  });
550
589
  type SortDir = 'asc' | 'desc';
551
590
  type OrderBy = {
@@ -568,7 +607,7 @@ type AggregateRule<TRuleValue = RuleValue, TDateValue = DateRuleValue> = WindowF
568
607
  operator: Operator;
569
608
  error?: string;
570
609
  coerceType?: FieldKind;
571
- } & ValueSourceFields<number | [number, number]>;
610
+ } & ValueSourceFields<RuleValue>;
572
611
  type Rule<TValue = RuleValue> = ValueSourceFields<TValue> & {
573
612
  field: string;
574
613
  operator: Operator;
@@ -643,8 +682,8 @@ type AggregateValue<TRuleValue = RuleValue, TDateValue = DateRuleValue> = Window
643
682
  field?: string;
644
683
  };
645
684
  condition?: Condition<TRuleValue, TDateValue>;
646
- /** `distinct` / `min` / `max`: read each value as this kind first (`'10'` as 10, an ISO string
647
- * 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. */
648
687
  coerceType?: FieldKind;
649
688
  /** `distinct` over strings: `'Acme'` and `'acme'` are one value (the first seen is kept).
650
689
  * Defaults to the engine's `string.caseInsensitive`. */
@@ -749,6 +788,8 @@ declare const readScopeRef: <S>(ref: string, scopes: readonly S[]) => ScopedRef<
749
788
  /** The keys a path reads, in order, as `check()` reads them: dotted names, bracket indices and
750
789
  * quoted keys (`ids[1]` → `['ids', '1']`, `meta["a.b"]` → `['meta', 'a.b']`). `''` is `['']`. */
751
790
  declare const pathSegments: (path: string) => string[];
791
+ /** A path read of own properties only, bracket indices included: nothing inherited resolves. */
792
+ declare const readOwnPath: (root: unknown, path: string) => unknown;
752
793
 
753
794
  /** `bindings`: the caller's values, read by `{ bind }`. The rest is the clock and zone. */
754
795
  type CheckOptions = {
@@ -844,14 +885,31 @@ declare const engineGlobals: {
844
885
  with: <T>(overrides: Overrides, fn: () => T) => T;
845
886
  };
846
887
 
888
+ /** The model a relation entry leads to, in this map or across a bridge; null for a column. */
889
+ declare const relationTargetOf: (entry: FieldMapEntry, currentMap: string) => {
890
+ mapName: string;
891
+ modelName: string;
892
+ } | null;
893
+
847
894
  /** A caller's input missing or malformed — the clock, the time zone, a bind's value — not the
848
895
  * rule's or the lens's shape. */
849
896
  declare class UsageError extends Error {
850
897
  name: string;
851
898
  }
852
899
 
900
+ /** The name a bridge endpoint goes by — `map:Model`: the stitched bridge field's name and the
901
+ * raw-data key. */
902
+ declare const endpointKey: ({ fieldMap, model }: BridgeEndpoint) => string;
853
903
  /** Whether a bridge joins on a field of each side, or its far row is supplied on the record. */
854
904
  declare const isJoinedBridge: (bridge: Bridge) => bridge is JoinedBridge;
905
+ /** The map and model an endpoint key names; a bare model is in `currentMap`. */
906
+ declare const parseEndpointKey: (key: string, currentMap: string) => {
907
+ mapName: string;
908
+ modelName: string;
909
+ };
910
+
911
+ /** An enum field's declared values: the entry's own, else the registry's for its type. */
912
+ declare const declaredEnumValues: (entry: FieldMapEntry, enums: Record<string, readonly string[]> | undefined) => readonly string[] | undefined;
855
913
 
856
914
  type BridgeDictionary = Record<string, // map name
857
915
  Record<string, // model name
@@ -861,8 +919,22 @@ Record<string, Record<string, Row | Row[]>>>>;
861
919
  * Throws on a duplicate value where a side must be unique. */
862
920
  declare const indexBridges: (set: FieldMapSet, rawData: Record<string, Row[]>) => BridgeDictionary;
863
921
 
922
+ /**
923
+ * `record`, a row of the endpoint `at` (`app:Doc`) of a stitched set, with every bridge filled from `data` (rows keyed
924
+ * by endpoint, `<fieldMap>:<Model>`, as `indexBridges` takes them), and the far rows' bridges in
925
+ * turn, so a rule can read across a chain of sources (`crm:Contact.sec:Device.risk`); a related row
926
+ * (`org`) is filled as a row of its own model. Every key a row carries that names a model of the
927
+ * 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
928
+ * bridge (from its first endpoint to its second) the one row `data` holds for its second. A chain
929
+ * never re-enters an endpoint it came through, and a far end with no row is left out, so a rule
930
+ * reading it reads a missing value. A caller filling many records from one `data` passes the
931
+ * `indexBridges` dictionary it built once.
932
+ */
933
+ declare const recordWithBridgeData: (set: FieldMapSet, at: string, record: Row, data?: Record<string, Row[]>, dictionary?: BridgeDictionary) => Row;
934
+
864
935
  /** A copy of the set where each bridge's endpoint models gain a `kind: 'bridge'` field named
865
- * after the other endpoint (`<fieldMap>:<Model>`). Throws on a missing endpoint, a joined bridge's
936
+ * after the other endpoint (`<fieldMap>:<Model>`); a supplied bridge runs one way, so only its
937
+ * first endpoint gains one. Throws on a missing endpoint, a joined bridge's
866
938
  * missing `on` field, an `on` on one side only, a supplied bridge that is not one-to-one, a
867
939
  * self-bridge, or a bridge stitched twice. */
868
940
  declare const stitchFieldMaps: (set: FieldMapSet) => FieldMapSet;
@@ -1117,13 +1189,30 @@ type ProjectLensOptions = {
1117
1189
  */
1118
1190
  declare const lensVisit: (lensOrNarrowing: Lens | LensNarrowing, relationPath: string, opts?: ProjectLensOptions) => ProjectedVisit | null;
1119
1191
 
1120
- /** A Prisma `select` tree: a column, or a relation with its own `select` and, to-many, `where`. */
1192
+ /** A Prisma `select` tree: a column, or a relation with its own `select` and, to-many, `where` and
1193
+ * `orderBy`. */
1121
1194
  type LensSelect = {
1122
1195
  [field: string]: true | LensRelationSelect;
1123
1196
  };
1197
+ /** What `toLensSelect` hands a `findMany`: the select, and the root rows' order when the lens
1198
+ * gives one. */
1199
+ type LensQuery = {
1200
+ select: LensSelect;
1201
+ orderBy?: LensOrderBy;
1202
+ };
1124
1203
  type LensRelationSelect = {
1125
1204
  select?: LensSelect;
1126
1205
  where?: PrismaWhere;
1206
+ orderBy?: LensOrderBy;
1207
+ };
1208
+ /** Prisma's `orderBy` for a node's rows: each key a column, nested under the to-one relations its
1209
+ * path crosses; a nullable column sorts its NULLs last, as check() orders a window. */
1210
+ type LensOrderBy = Record<string, LensOrderKey>[];
1211
+ type LensOrderKey = SortDir | {
1212
+ sort: SortDir;
1213
+ nulls: 'last';
1214
+ } | {
1215
+ [relation: string]: LensOrderKey;
1127
1216
  };
1128
1217
  /** What a clamp's compile reads: the clock, never a schema (the lens is it). */
1129
1218
  type LensSelectOptions = Omit<ToPrismaOptions, 'map' | 'mapName' | 'model' | 'lens'>;
@@ -1142,9 +1231,7 @@ type ProjectRowsOptions = CheckOptions & {
1142
1231
  * that needs a counting step, or has a window toPrisma can't compile, is refused before anything
1143
1232
  * compiles.
1144
1233
  */
1145
- declare const toLensSelect: (lensOrNarrowing: Lens | LensNarrowing, options?: LensSelectOptions) => {
1146
- select: LensSelect;
1147
- };
1234
+ declare const toLensSelect: (lensOrNarrowing: Lens | LensNarrowing, options?: LensSelectOptions) => LensQuery;
1148
1235
  /**
1149
1236
  * Rows cut to what a lens shows, recursively from its base model: hidden columns, and relations
1150
1237
  * hidden or off, removed, and every row a visit's `where` hides gone — a root or list row dropped, a to-one row
@@ -1543,11 +1630,11 @@ declare const valueExpressionShape: (expr: unknown) => ValueExpressionShape | nu
1543
1630
 
1544
1631
  /**
1545
1632
  * The path spellings `ConditionOn` passes through as `string`, unchecked: a scope ref into an
1546
- * enclosing row (`$.x`, `$$.x`), a bridge into another map (`map:Model.field`), the actor
1547
- * (`__actor.x`), and a bracket spelling (`a[0].b`). The lens gate (`validateRuleInLens`) still
1633
+ * enclosing row (`$.x`, `$$.x`), a bridge into another map (`map:Model.field`, the actor's
1634
+ * `actor:User.id` among them), and a bracket spelling (`a[0].b`). The lens gate (`validateRuleInLens`) still
1548
1635
  * reads them at run time.
1549
1636
  */
1550
- type UncheckedPath = `$.${string}` | `$$.${string}` | `${string}:${string}` | `__actor.${string}` | `${string}[${string}`;
1637
+ type UncheckedPath = `$.${string}` | `$$.${string}` | `${string}:${string}` | `${string}[${string}`;
1551
1638
  type FieldOn<M extends FieldMap, Model extends string> = ScalarPath<M, Model> | UncheckedPath;
1552
1639
  type Window<M extends FieldMap, Target extends string, Root extends string, TR, TD> = {
1553
1640
  filter?: ConditionOn<M, Target, Root, TR, TD>;
@@ -1710,8 +1797,9 @@ declare const valueClockUnit: (expression: ValueExpression) => ClockUnit | null;
1710
1797
  /**
1711
1798
  * Records sorted by an `OrderBy`, the way every rail orders a window: each key in turn, read as an
1712
1799
  * own-property path, `dir` order, a NULL (or absent) value last in either direction; ties keep their
1713
- * input order. A new array; the input is not mutated.
1800
+ * input order. A new array; the input is not mutated. `read` reads a key off a record (a lens
1801
+ * reads a Decimal column as its number).
1714
1802
  */
1715
- declare const orderRecords: <T>(items: readonly T[], orderBy: OrderBy) => T[];
1803
+ declare const orderRecords: <T>(items: readonly T[], orderBy: OrderBy, read?: (item: T, field: string) => unknown) => T[];
1716
1804
 
1717
- 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 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 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, describeCategorization, describeRule, describeRuleSources, describeValue, engineGlobals, evaluateValue, executePrismaPlan, getAggregateOperators, getArrayOperators, getConditionShapeKeys, getLensRoot, getOperatorsForKind, getValueShape, indexBridges, inferValueType, isJoinedBridge, 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 };
1805
+ 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, readOwnPath, 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
@@ -142,9 +142,9 @@ type JoinedBridge = {
142
142
  cardinality: BridgeCardinality;
143
143
  };
144
144
  /**
145
- * A cross-source edge with no join: the caller supplies the far row on the record under its
146
- * endpoint key (`map:Model`), as it would after `indexBridges` for a joined one. For data that is
147
- * not found by a key, such as who is acting. One row each way.
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
148
  */
149
149
  type SuppliedBridge = {
150
150
  endpoints: [BridgeEndpoint, BridgeEndpoint];
@@ -208,6 +208,17 @@ type ModelDefaultNarrowing = {
208
208
  * relation; a later layer's only what its parent shows.
209
209
  */
210
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;
211
222
  };
212
223
  /**
213
224
  * A sourced field's eligibility `where` plus an optional display-label column — a
@@ -328,16 +339,24 @@ declare const ORDERED_VALUE_KINDS: readonly FieldKind[];
328
339
  * stored, so `1` and `Decimal('1')` stay two values unless `coerceType` reads them as one. */
329
340
  declare const DISTINCT_VALUE_KINDS: readonly FieldKind[];
330
341
  /** The aggregate modes that read values of `kind`; `{ comparable: true }` keeps the ones an
331
- * aggregate rule compares. */
342
+ * aggregate rule compares, `{ compiled: true }` the ones an aggregate rule compiles to SQL and
343
+ * Prisma. */
332
344
  declare const aggregateModesForKind: (kind: FieldKind, options?: {
333
345
  comparable?: boolean;
346
+ compiled?: boolean;
334
347
  }) => ValueAggregateMode[];
335
- /** 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`). */
336
351
  declare const AGGREGATE_MODES: readonly AggregateMode[];
337
352
  /** Every mode a value expression's aggregate takes. */
338
353
  declare const VALUE_AGGREGATE_MODES: readonly ValueAggregateMode[];
339
- /** The comparisons an aggregate rule takes; every target compiles all of them. */
340
- 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[];
341
360
  /** The steps a clock-relative date moves by, finest first. */
342
361
  declare const CLOCK_UNITS: readonly ["second", "minute", "hour", "day", "week", "month", "quarter", "year"];
343
362
  type ClockUnit = (typeof CLOCK_UNITS)[number];
@@ -402,9 +421,11 @@ type OperatorValues = typeof Operator;
402
421
  type ArrayOperatorValues = typeof ArrayOperator;
403
422
  type DateOperatorValues = typeof DateOperator;
404
423
  type RuleScalar = string | number | boolean | null | undefined;
405
- type AggregateMode = 'sum' | 'avg';
406
- /** What a value expression's aggregate computes: an aggregate rule's modes, plus `count` and the
407
- * 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. */
408
429
  type ValueAggregateMode = AggregateMode | 'count' | 'min' | 'max' | 'distinct';
409
430
  type RuleValue = RuleScalar | Date | RegExp | RuleValue[] | {
410
431
  [key: string]: RuleValue;
@@ -528,10 +549,10 @@ type StrictDateComparisonRule = (DateRuleBase<DateOperatorValues['before']> & Va
528
549
  type StrictDateRangeRule = (DateRuleBase<DateOperatorValues['between']> & ValueSource<[DateInputValue, DateInputValue], DateOffset>) | (DateRuleBase<DateOperatorValues['notBetween']> & ValueSource<[DateInputValue, DateInputValue], DateOffset>);
529
550
  type StrictDateDayRule = (DateRuleBase<DateOperatorValues['dayIn']> & ValueSource<string[]>) | (DateRuleBase<DateOperatorValues['dayNotIn']> & ValueSource<string[]>);
530
551
  type StrictDateRule = StrictDateComparisonRule | StrictDateRangeRule | StrictDateDayRule;
531
- type AggregateRuleBase<TRuleValue = RuleValue, TDateValue = DateRuleValue> = {
552
+ type AggregateRuleBase<TRuleValue = RuleValue, TDateValue = DateRuleValue, TMode extends AggregateMode = Exclude<AggregateMode, 'pick'>> = {
532
553
  field: string;
533
554
  aggregate: {
534
- mode: AggregateMode;
555
+ mode: TMode;
535
556
  field?: string;
536
557
  };
537
558
  condition?: StrictCondition<TRuleValue, TDateValue>;
@@ -546,6 +567,24 @@ type StrictAggregateRule<TRuleValue = RuleValue, TDateValue = DateRuleValue> = (
546
567
  operator: AggregateRangeOperator;
547
568
  } & ValueSource<[number, number]>) | (AggregateRuleBase<TRuleValue, TDateValue> & {
548
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;
549
588
  });
550
589
  type SortDir = 'asc' | 'desc';
551
590
  type OrderBy = {
@@ -568,7 +607,7 @@ type AggregateRule<TRuleValue = RuleValue, TDateValue = DateRuleValue> = WindowF
568
607
  operator: Operator;
569
608
  error?: string;
570
609
  coerceType?: FieldKind;
571
- } & ValueSourceFields<number | [number, number]>;
610
+ } & ValueSourceFields<RuleValue>;
572
611
  type Rule<TValue = RuleValue> = ValueSourceFields<TValue> & {
573
612
  field: string;
574
613
  operator: Operator;
@@ -643,8 +682,8 @@ type AggregateValue<TRuleValue = RuleValue, TDateValue = DateRuleValue> = Window
643
682
  field?: string;
644
683
  };
645
684
  condition?: Condition<TRuleValue, TDateValue>;
646
- /** `distinct` / `min` / `max`: read each value as this kind first (`'10'` as 10, an ISO string
647
- * 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. */
648
687
  coerceType?: FieldKind;
649
688
  /** `distinct` over strings: `'Acme'` and `'acme'` are one value (the first seen is kept).
650
689
  * Defaults to the engine's `string.caseInsensitive`. */
@@ -749,6 +788,8 @@ declare const readScopeRef: <S>(ref: string, scopes: readonly S[]) => ScopedRef<
749
788
  /** The keys a path reads, in order, as `check()` reads them: dotted names, bracket indices and
750
789
  * quoted keys (`ids[1]` → `['ids', '1']`, `meta["a.b"]` → `['meta', 'a.b']`). `''` is `['']`. */
751
790
  declare const pathSegments: (path: string) => string[];
791
+ /** A path read of own properties only, bracket indices included: nothing inherited resolves. */
792
+ declare const readOwnPath: (root: unknown, path: string) => unknown;
752
793
 
753
794
  /** `bindings`: the caller's values, read by `{ bind }`. The rest is the clock and zone. */
754
795
  type CheckOptions = {
@@ -844,14 +885,31 @@ declare const engineGlobals: {
844
885
  with: <T>(overrides: Overrides, fn: () => T) => T;
845
886
  };
846
887
 
888
+ /** The model a relation entry leads to, in this map or across a bridge; null for a column. */
889
+ declare const relationTargetOf: (entry: FieldMapEntry, currentMap: string) => {
890
+ mapName: string;
891
+ modelName: string;
892
+ } | null;
893
+
847
894
  /** A caller's input missing or malformed — the clock, the time zone, a bind's value — not the
848
895
  * rule's or the lens's shape. */
849
896
  declare class UsageError extends Error {
850
897
  name: string;
851
898
  }
852
899
 
900
+ /** The name a bridge endpoint goes by — `map:Model`: the stitched bridge field's name and the
901
+ * raw-data key. */
902
+ declare const endpointKey: ({ fieldMap, model }: BridgeEndpoint) => string;
853
903
  /** Whether a bridge joins on a field of each side, or its far row is supplied on the record. */
854
904
  declare const isJoinedBridge: (bridge: Bridge) => bridge is JoinedBridge;
905
+ /** The map and model an endpoint key names; a bare model is in `currentMap`. */
906
+ declare const parseEndpointKey: (key: string, currentMap: string) => {
907
+ mapName: string;
908
+ modelName: string;
909
+ };
910
+
911
+ /** An enum field's declared values: the entry's own, else the registry's for its type. */
912
+ declare const declaredEnumValues: (entry: FieldMapEntry, enums: Record<string, readonly string[]> | undefined) => readonly string[] | undefined;
855
913
 
856
914
  type BridgeDictionary = Record<string, // map name
857
915
  Record<string, // model name
@@ -861,8 +919,22 @@ Record<string, Record<string, Row | Row[]>>>>;
861
919
  * Throws on a duplicate value where a side must be unique. */
862
920
  declare const indexBridges: (set: FieldMapSet, rawData: Record<string, Row[]>) => BridgeDictionary;
863
921
 
922
+ /**
923
+ * `record`, a row of the endpoint `at` (`app:Doc`) of a stitched set, with every bridge filled from `data` (rows keyed
924
+ * by endpoint, `<fieldMap>:<Model>`, as `indexBridges` takes them), and the far rows' bridges in
925
+ * turn, so a rule can read across a chain of sources (`crm:Contact.sec:Device.risk`); a related row
926
+ * (`org`) is filled as a row of its own model. Every key a row carries that names a model of the
927
+ * 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
928
+ * bridge (from its first endpoint to its second) the one row `data` holds for its second. A chain
929
+ * never re-enters an endpoint it came through, and a far end with no row is left out, so a rule
930
+ * reading it reads a missing value. A caller filling many records from one `data` passes the
931
+ * `indexBridges` dictionary it built once.
932
+ */
933
+ declare const recordWithBridgeData: (set: FieldMapSet, at: string, record: Row, data?: Record<string, Row[]>, dictionary?: BridgeDictionary) => Row;
934
+
864
935
  /** A copy of the set where each bridge's endpoint models gain a `kind: 'bridge'` field named
865
- * after the other endpoint (`<fieldMap>:<Model>`). Throws on a missing endpoint, a joined bridge's
936
+ * after the other endpoint (`<fieldMap>:<Model>`); a supplied bridge runs one way, so only its
937
+ * first endpoint gains one. Throws on a missing endpoint, a joined bridge's
866
938
  * missing `on` field, an `on` on one side only, a supplied bridge that is not one-to-one, a
867
939
  * self-bridge, or a bridge stitched twice. */
868
940
  declare const stitchFieldMaps: (set: FieldMapSet) => FieldMapSet;
@@ -1117,13 +1189,30 @@ type ProjectLensOptions = {
1117
1189
  */
1118
1190
  declare const lensVisit: (lensOrNarrowing: Lens | LensNarrowing, relationPath: string, opts?: ProjectLensOptions) => ProjectedVisit | null;
1119
1191
 
1120
- /** A Prisma `select` tree: a column, or a relation with its own `select` and, to-many, `where`. */
1192
+ /** A Prisma `select` tree: a column, or a relation with its own `select` and, to-many, `where` and
1193
+ * `orderBy`. */
1121
1194
  type LensSelect = {
1122
1195
  [field: string]: true | LensRelationSelect;
1123
1196
  };
1197
+ /** What `toLensSelect` hands a `findMany`: the select, and the root rows' order when the lens
1198
+ * gives one. */
1199
+ type LensQuery = {
1200
+ select: LensSelect;
1201
+ orderBy?: LensOrderBy;
1202
+ };
1124
1203
  type LensRelationSelect = {
1125
1204
  select?: LensSelect;
1126
1205
  where?: PrismaWhere;
1206
+ orderBy?: LensOrderBy;
1207
+ };
1208
+ /** Prisma's `orderBy` for a node's rows: each key a column, nested under the to-one relations its
1209
+ * path crosses; a nullable column sorts its NULLs last, as check() orders a window. */
1210
+ type LensOrderBy = Record<string, LensOrderKey>[];
1211
+ type LensOrderKey = SortDir | {
1212
+ sort: SortDir;
1213
+ nulls: 'last';
1214
+ } | {
1215
+ [relation: string]: LensOrderKey;
1127
1216
  };
1128
1217
  /** What a clamp's compile reads: the clock, never a schema (the lens is it). */
1129
1218
  type LensSelectOptions = Omit<ToPrismaOptions, 'map' | 'mapName' | 'model' | 'lens'>;
@@ -1142,9 +1231,7 @@ type ProjectRowsOptions = CheckOptions & {
1142
1231
  * that needs a counting step, or has a window toPrisma can't compile, is refused before anything
1143
1232
  * compiles.
1144
1233
  */
1145
- declare const toLensSelect: (lensOrNarrowing: Lens | LensNarrowing, options?: LensSelectOptions) => {
1146
- select: LensSelect;
1147
- };
1234
+ declare const toLensSelect: (lensOrNarrowing: Lens | LensNarrowing, options?: LensSelectOptions) => LensQuery;
1148
1235
  /**
1149
1236
  * Rows cut to what a lens shows, recursively from its base model: hidden columns, and relations
1150
1237
  * hidden or off, removed, and every row a visit's `where` hides gone — a root or list row dropped, a to-one row
@@ -1543,11 +1630,11 @@ declare const valueExpressionShape: (expr: unknown) => ValueExpressionShape | nu
1543
1630
 
1544
1631
  /**
1545
1632
  * The path spellings `ConditionOn` passes through as `string`, unchecked: a scope ref into an
1546
- * enclosing row (`$.x`, `$$.x`), a bridge into another map (`map:Model.field`), the actor
1547
- * (`__actor.x`), and a bracket spelling (`a[0].b`). The lens gate (`validateRuleInLens`) still
1633
+ * enclosing row (`$.x`, `$$.x`), a bridge into another map (`map:Model.field`, the actor's
1634
+ * `actor:User.id` among them), and a bracket spelling (`a[0].b`). The lens gate (`validateRuleInLens`) still
1548
1635
  * reads them at run time.
1549
1636
  */
1550
- type UncheckedPath = `$.${string}` | `$$.${string}` | `${string}:${string}` | `__actor.${string}` | `${string}[${string}`;
1637
+ type UncheckedPath = `$.${string}` | `$$.${string}` | `${string}:${string}` | `${string}[${string}`;
1551
1638
  type FieldOn<M extends FieldMap, Model extends string> = ScalarPath<M, Model> | UncheckedPath;
1552
1639
  type Window<M extends FieldMap, Target extends string, Root extends string, TR, TD> = {
1553
1640
  filter?: ConditionOn<M, Target, Root, TR, TD>;
@@ -1710,8 +1797,9 @@ declare const valueClockUnit: (expression: ValueExpression) => ClockUnit | null;
1710
1797
  /**
1711
1798
  * Records sorted by an `OrderBy`, the way every rail orders a window: each key in turn, read as an
1712
1799
  * own-property path, `dir` order, a NULL (or absent) value last in either direction; ties keep their
1713
- * input order. A new array; the input is not mutated.
1800
+ * input order. A new array; the input is not mutated. `read` reads a key off a record (a lens
1801
+ * reads a Decimal column as its number).
1714
1802
  */
1715
- declare const orderRecords: <T>(items: readonly T[], orderBy: OrderBy) => T[];
1803
+ declare const orderRecords: <T>(items: readonly T[], orderBy: OrderBy, read?: (item: T, field: string) => unknown) => T[];
1716
1804
 
1717
- 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 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 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, describeCategorization, describeRule, describeRuleSources, describeValue, engineGlobals, evaluateValue, executePrismaPlan, getAggregateOperators, getArrayOperators, getConditionShapeKeys, getLensRoot, getOperatorsForKind, getValueShape, indexBridges, inferValueType, isJoinedBridge, 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 };
1805
+ 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, readOwnPath, readScopeRef, recordWithBridgeData, registerEngineGlobals, relationTargetOf, stitchFieldMaps, storeLens, toLensSelect, toLensWhereSql, toPrisma, toSourceQueries, toSql, toWhereSql, validateCategorization, validateFieldMaps, validateNarrowing, validateRule, validateRuleInLens, validateValue, valueClockUnit, valueExpressionShape, walkLensPath };