@inixiative/json-rules 4.3.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/README.md +50 -9
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +110 -25
- package/dist/index.d.ts +110 -25
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
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
|
|
146
|
-
* endpoint
|
|
147
|
-
* not found by a key, such as who is acting.
|
|
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
|
-
/**
|
|
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
|
|
340
|
-
|
|
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
|
-
|
|
406
|
-
|
|
407
|
-
|
|
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:
|
|
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<
|
|
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
|
|
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`. */
|
|
@@ -844,14 +883,31 @@ declare const engineGlobals: {
|
|
|
844
883
|
with: <T>(overrides: Overrides, fn: () => T) => T;
|
|
845
884
|
};
|
|
846
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
|
+
|
|
847
892
|
/** A caller's input missing or malformed — the clock, the time zone, a bind's value — not the
|
|
848
893
|
* rule's or the lens's shape. */
|
|
849
894
|
declare class UsageError extends Error {
|
|
850
895
|
name: string;
|
|
851
896
|
}
|
|
852
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;
|
|
853
901
|
/** Whether a bridge joins on a field of each side, or its far row is supplied on the record. */
|
|
854
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;
|
|
855
911
|
|
|
856
912
|
type BridgeDictionary = Record<string, // map name
|
|
857
913
|
Record<string, // model name
|
|
@@ -861,6 +917,19 @@ Record<string, Record<string, Row | Row[]>>>>;
|
|
|
861
917
|
* Throws on a duplicate value where a side must be unique. */
|
|
862
918
|
declare const indexBridges: (set: FieldMapSet, rawData: Record<string, Row[]>) => BridgeDictionary;
|
|
863
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
|
+
|
|
864
933
|
/** A copy of the set where each bridge's endpoint models gain a `kind: 'bridge'` field named
|
|
865
934
|
* after the other endpoint (`<fieldMap>:<Model>`). Throws on a missing endpoint, a joined bridge's
|
|
866
935
|
* missing `on` field, an `on` on one side only, a supplied bridge that is not one-to-one, a
|
|
@@ -1117,13 +1186,30 @@ type ProjectLensOptions = {
|
|
|
1117
1186
|
*/
|
|
1118
1187
|
declare const lensVisit: (lensOrNarrowing: Lens | LensNarrowing, relationPath: string, opts?: ProjectLensOptions) => ProjectedVisit | null;
|
|
1119
1188
|
|
|
1120
|
-
/** 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`. */
|
|
1121
1191
|
type LensSelect = {
|
|
1122
1192
|
[field: string]: true | LensRelationSelect;
|
|
1123
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
|
+
};
|
|
1124
1200
|
type LensRelationSelect = {
|
|
1125
1201
|
select?: LensSelect;
|
|
1126
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;
|
|
1127
1213
|
};
|
|
1128
1214
|
/** What a clamp's compile reads: the clock, never a schema (the lens is it). */
|
|
1129
1215
|
type LensSelectOptions = Omit<ToPrismaOptions, 'map' | 'mapName' | 'model' | 'lens'>;
|
|
@@ -1142,9 +1228,7 @@ type ProjectRowsOptions = CheckOptions & {
|
|
|
1142
1228
|
* that needs a counting step, or has a window toPrisma can't compile, is refused before anything
|
|
1143
1229
|
* compiles.
|
|
1144
1230
|
*/
|
|
1145
|
-
declare const toLensSelect: (lensOrNarrowing: Lens | LensNarrowing, options?: LensSelectOptions) =>
|
|
1146
|
-
select: LensSelect;
|
|
1147
|
-
};
|
|
1231
|
+
declare const toLensSelect: (lensOrNarrowing: Lens | LensNarrowing, options?: LensSelectOptions) => LensQuery;
|
|
1148
1232
|
/**
|
|
1149
1233
|
* Rows cut to what a lens shows, recursively from its base model: hidden columns, and relations
|
|
1150
1234
|
* 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 +1627,11 @@ declare const valueExpressionShape: (expr: unknown) => ValueExpressionShape | nu
|
|
|
1543
1627
|
|
|
1544
1628
|
/**
|
|
1545
1629
|
* 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
|
|
1547
|
-
*
|
|
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
|
|
1548
1632
|
* reads them at run time.
|
|
1549
1633
|
*/
|
|
1550
|
-
type UncheckedPath = `$.${string}` | `$$.${string}` | `${string}:${string}` |
|
|
1634
|
+
type UncheckedPath = `$.${string}` | `$$.${string}` | `${string}:${string}` | `${string}[${string}`;
|
|
1551
1635
|
type FieldOn<M extends FieldMap, Model extends string> = ScalarPath<M, Model> | UncheckedPath;
|
|
1552
1636
|
type Window<M extends FieldMap, Target extends string, Root extends string, TR, TD> = {
|
|
1553
1637
|
filter?: ConditionOn<M, Target, Root, TR, TD>;
|
|
@@ -1710,8 +1794,9 @@ declare const valueClockUnit: (expression: ValueExpression) => ClockUnit | null;
|
|
|
1710
1794
|
/**
|
|
1711
1795
|
* Records sorted by an `OrderBy`, the way every rail orders a window: each key in turn, read as an
|
|
1712
1796
|
* 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.
|
|
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).
|
|
1714
1799
|
*/
|
|
1715
|
-
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[];
|
|
1716
1801
|
|
|
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 };
|
|
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
|
@@ -142,9 +142,9 @@ type JoinedBridge = {
|
|
|
142
142
|
cardinality: BridgeCardinality;
|
|
143
143
|
};
|
|
144
144
|
/**
|
|
145
|
-
* A cross-source edge with no join
|
|
146
|
-
* endpoint
|
|
147
|
-
* not found by a key, such as who is acting.
|
|
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
|
-
/**
|
|
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
|
|
340
|
-
|
|
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
|
-
|
|
406
|
-
|
|
407
|
-
|
|
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:
|
|
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<
|
|
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
|
|
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`. */
|
|
@@ -844,14 +883,31 @@ declare const engineGlobals: {
|
|
|
844
883
|
with: <T>(overrides: Overrides, fn: () => T) => T;
|
|
845
884
|
};
|
|
846
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
|
+
|
|
847
892
|
/** A caller's input missing or malformed — the clock, the time zone, a bind's value — not the
|
|
848
893
|
* rule's or the lens's shape. */
|
|
849
894
|
declare class UsageError extends Error {
|
|
850
895
|
name: string;
|
|
851
896
|
}
|
|
852
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;
|
|
853
901
|
/** Whether a bridge joins on a field of each side, or its far row is supplied on the record. */
|
|
854
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;
|
|
855
911
|
|
|
856
912
|
type BridgeDictionary = Record<string, // map name
|
|
857
913
|
Record<string, // model name
|
|
@@ -861,6 +917,19 @@ Record<string, Record<string, Row | Row[]>>>>;
|
|
|
861
917
|
* Throws on a duplicate value where a side must be unique. */
|
|
862
918
|
declare const indexBridges: (set: FieldMapSet, rawData: Record<string, Row[]>) => BridgeDictionary;
|
|
863
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
|
+
|
|
864
933
|
/** A copy of the set where each bridge's endpoint models gain a `kind: 'bridge'` field named
|
|
865
934
|
* after the other endpoint (`<fieldMap>:<Model>`). Throws on a missing endpoint, a joined bridge's
|
|
866
935
|
* missing `on` field, an `on` on one side only, a supplied bridge that is not one-to-one, a
|
|
@@ -1117,13 +1186,30 @@ type ProjectLensOptions = {
|
|
|
1117
1186
|
*/
|
|
1118
1187
|
declare const lensVisit: (lensOrNarrowing: Lens | LensNarrowing, relationPath: string, opts?: ProjectLensOptions) => ProjectedVisit | null;
|
|
1119
1188
|
|
|
1120
|
-
/** 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`. */
|
|
1121
1191
|
type LensSelect = {
|
|
1122
1192
|
[field: string]: true | LensRelationSelect;
|
|
1123
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
|
+
};
|
|
1124
1200
|
type LensRelationSelect = {
|
|
1125
1201
|
select?: LensSelect;
|
|
1126
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;
|
|
1127
1213
|
};
|
|
1128
1214
|
/** What a clamp's compile reads: the clock, never a schema (the lens is it). */
|
|
1129
1215
|
type LensSelectOptions = Omit<ToPrismaOptions, 'map' | 'mapName' | 'model' | 'lens'>;
|
|
@@ -1142,9 +1228,7 @@ type ProjectRowsOptions = CheckOptions & {
|
|
|
1142
1228
|
* that needs a counting step, or has a window toPrisma can't compile, is refused before anything
|
|
1143
1229
|
* compiles.
|
|
1144
1230
|
*/
|
|
1145
|
-
declare const toLensSelect: (lensOrNarrowing: Lens | LensNarrowing, options?: LensSelectOptions) =>
|
|
1146
|
-
select: LensSelect;
|
|
1147
|
-
};
|
|
1231
|
+
declare const toLensSelect: (lensOrNarrowing: Lens | LensNarrowing, options?: LensSelectOptions) => LensQuery;
|
|
1148
1232
|
/**
|
|
1149
1233
|
* Rows cut to what a lens shows, recursively from its base model: hidden columns, and relations
|
|
1150
1234
|
* 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 +1627,11 @@ declare const valueExpressionShape: (expr: unknown) => ValueExpressionShape | nu
|
|
|
1543
1627
|
|
|
1544
1628
|
/**
|
|
1545
1629
|
* 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
|
|
1547
|
-
*
|
|
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
|
|
1548
1632
|
* reads them at run time.
|
|
1549
1633
|
*/
|
|
1550
|
-
type UncheckedPath = `$.${string}` | `$$.${string}` | `${string}:${string}` |
|
|
1634
|
+
type UncheckedPath = `$.${string}` | `$$.${string}` | `${string}:${string}` | `${string}[${string}`;
|
|
1551
1635
|
type FieldOn<M extends FieldMap, Model extends string> = ScalarPath<M, Model> | UncheckedPath;
|
|
1552
1636
|
type Window<M extends FieldMap, Target extends string, Root extends string, TR, TD> = {
|
|
1553
1637
|
filter?: ConditionOn<M, Target, Root, TR, TD>;
|
|
@@ -1710,8 +1794,9 @@ declare const valueClockUnit: (expression: ValueExpression) => ClockUnit | null;
|
|
|
1710
1794
|
/**
|
|
1711
1795
|
* Records sorted by an `OrderBy`, the way every rail orders a window: each key in turn, read as an
|
|
1712
1796
|
* 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.
|
|
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).
|
|
1714
1799
|
*/
|
|
1715
|
-
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[];
|
|
1716
1801
|
|
|
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 };
|
|
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 };
|