@inixiative/json-rules 2.26.0 → 2.27.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 +64 -1
- package/dist/index.cjs +5 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +146 -77
- package/dist/index.d.ts +146 -77
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -147,6 +147,88 @@ declare const getOperatorsForKind: (kind: FieldKind, target?: RuleTarget) => {
|
|
|
147
147
|
date: DateOperator[];
|
|
148
148
|
};
|
|
149
149
|
declare const getArrayOperators: (target?: RuleTarget) => ArrayOperator[];
|
|
150
|
+
/** Operators that read no comparison value. */
|
|
151
|
+
declare const NO_VALUE_OPERATORS: readonly string[];
|
|
152
|
+
/** Field comparisons with an order: `<`, `<=`, `>`, `>=`. */
|
|
153
|
+
declare const ORDERED_OPERATORS: readonly string[];
|
|
154
|
+
/** A window expression (`within`), not a pair. */
|
|
155
|
+
declare const WINDOW_OPERATORS: readonly string[];
|
|
156
|
+
/** Operators that compare against two ends. */
|
|
157
|
+
declare const RANGE_OPERATORS: readonly string[];
|
|
158
|
+
/** Operators with a point to move: the comparisons and both ends of a pair. */
|
|
159
|
+
declare const OFFSET_OPERATORS: readonly string[];
|
|
160
|
+
/** The negations: each is the complement of its positive form and keeps NULL fields
|
|
161
|
+
* (the 2.19.0 ruling). */
|
|
162
|
+
declare const NEGATED_OPERATORS: readonly string[];
|
|
163
|
+
/** Negations of a two-ended range. */
|
|
164
|
+
declare const NEGATED_RANGE_OPERATORS: string[];
|
|
165
|
+
/** Negated comparisons an offset can move; with nothing to compare against they still keep a
|
|
166
|
+
* null field. */
|
|
167
|
+
declare const NEGATED_COMPARISON_OPERATORS: string[];
|
|
168
|
+
/** Negations of one literal (`notEquals`, `notContains`). */
|
|
169
|
+
declare const NEGATED_SINGLE_VALUE_OPERATORS: string[];
|
|
170
|
+
/** Comparisons that bound a field from above / below — what a window's extremal rewrite reads. */
|
|
171
|
+
declare const UPPER_BOUND_OPERATORS: readonly string[];
|
|
172
|
+
declare const LOWER_BOUND_OPERATORS: readonly string[];
|
|
173
|
+
/** Kinds a calendar unit amount can read: whole numbers. */
|
|
174
|
+
declare const INTEGER_KINDS: readonly FieldKind[];
|
|
175
|
+
/** Kinds check() coerces a literal to (see coerceScalar in src/field.ts). */
|
|
176
|
+
declare const COERCIBLE_KINDS: readonly FieldKind[];
|
|
177
|
+
/** Kinds whose literal the compilers coerce exactly as check() does — Prisma rejects a string on
|
|
178
|
+
* Int/Float/Boolean; BigInt compares as Int. Decimal keeps its literal: Prisma and Postgres take
|
|
179
|
+
* the numeric string losslessly, and a JS number would not. */
|
|
180
|
+
declare const COMPILE_COERCED_KINDS: readonly FieldKind[];
|
|
181
|
+
/** Value shapes that take one literal. */
|
|
182
|
+
declare const SINGLE_VALUE_SHAPES: readonly ValueShape[];
|
|
183
|
+
/** Each relative unit: the Postgres interval field it adds to, its size there, and whether it is
|
|
184
|
+
* a calendar unit (whole steps). Applied months, then days, then time, as Postgres does. */
|
|
185
|
+
declare const RELATIVE_UNITS: {
|
|
186
|
+
readonly years: {
|
|
187
|
+
readonly interval: "months";
|
|
188
|
+
readonly factor: 12;
|
|
189
|
+
readonly calendar: true;
|
|
190
|
+
};
|
|
191
|
+
readonly quarters: {
|
|
192
|
+
readonly interval: "months";
|
|
193
|
+
readonly factor: 3;
|
|
194
|
+
readonly calendar: true;
|
|
195
|
+
};
|
|
196
|
+
readonly months: {
|
|
197
|
+
readonly interval: "months";
|
|
198
|
+
readonly factor: 1;
|
|
199
|
+
readonly calendar: true;
|
|
200
|
+
};
|
|
201
|
+
readonly weeks: {
|
|
202
|
+
readonly interval: "days";
|
|
203
|
+
readonly factor: 7;
|
|
204
|
+
readonly calendar: true;
|
|
205
|
+
};
|
|
206
|
+
readonly days: {
|
|
207
|
+
readonly interval: "days";
|
|
208
|
+
readonly factor: 1;
|
|
209
|
+
readonly calendar: true;
|
|
210
|
+
};
|
|
211
|
+
readonly hours: {
|
|
212
|
+
readonly interval: "secs";
|
|
213
|
+
readonly factor: 3600;
|
|
214
|
+
readonly calendar: false;
|
|
215
|
+
};
|
|
216
|
+
readonly minutes: {
|
|
217
|
+
readonly interval: "secs";
|
|
218
|
+
readonly factor: 60;
|
|
219
|
+
readonly calendar: false;
|
|
220
|
+
};
|
|
221
|
+
readonly seconds: {
|
|
222
|
+
readonly interval: "secs";
|
|
223
|
+
readonly factor: 1;
|
|
224
|
+
readonly calendar: false;
|
|
225
|
+
};
|
|
226
|
+
};
|
|
227
|
+
type RelativeUnit = keyof typeof RELATIVE_UNITS;
|
|
228
|
+
declare const INTERVAL_FIELDS: readonly ["months", "days", "secs"];
|
|
229
|
+
declare const isRelativeUnit: (unit: string) => unit is RelativeUnit;
|
|
230
|
+
declare const isCalendarUnit: (unit: string) => boolean;
|
|
231
|
+
declare const PERIOD_UNITS: readonly string[];
|
|
150
232
|
|
|
151
233
|
type OperatorValues = typeof Operator;
|
|
152
234
|
type ArrayOperatorValues = typeof ArrayOperator;
|
|
@@ -158,21 +240,33 @@ type RuleValue = RuleScalar | Date | RegExp | RuleValue[] | {
|
|
|
158
240
|
};
|
|
159
241
|
type OrderedRuleValue = string | number | Date;
|
|
160
242
|
type DateInputValue = string | number | Date;
|
|
161
|
-
type
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
243
|
+
type SourceSlots<TValue> = {
|
|
244
|
+
value: TValue;
|
|
245
|
+
path: string;
|
|
246
|
+
bind: string;
|
|
247
|
+
bindOptional: boolean;
|
|
248
|
+
};
|
|
249
|
+
type Never<K extends PropertyKey> = {
|
|
250
|
+
[P in K]?: never;
|
|
251
|
+
};
|
|
252
|
+
type ValueSourceOf<TValue> = (Pick<SourceSlots<TValue>, 'value'> & Never<'path' | 'bind' | 'bindOptional'>) | (Pick<SourceSlots<TValue>, 'path'> & Never<'value' | 'bind' | 'bindOptional'>) | (Pick<SourceSlots<TValue>, 'bind'> & Partial<Pick<SourceSlots<TValue>, 'bindOptional'>> & Never<'value' | 'path'>);
|
|
253
|
+
type ValueSourceFields<TValue> = Partial<SourceSlots<TValue>>;
|
|
254
|
+
type Magnitude = number | ValueSourceOf<number>;
|
|
255
|
+
type RelativeUnits<TAmount = Magnitude> = {
|
|
256
|
+
years?: TAmount;
|
|
257
|
+
quarters?: TAmount;
|
|
258
|
+
months?: TAmount;
|
|
259
|
+
weeks?: TAmount;
|
|
260
|
+
days?: TAmount;
|
|
261
|
+
hours?: TAmount;
|
|
262
|
+
minutes?: TAmount;
|
|
263
|
+
seconds?: TAmount;
|
|
170
264
|
};
|
|
171
265
|
type PeriodUnit = 'year' | 'quarter' | 'month' | 'week' | 'isoWeek' | 'day' | 'hour' | 'minute' | 'second';
|
|
172
|
-
type RollingExpr = {
|
|
173
|
-
ago: RelativeUnits
|
|
266
|
+
type RollingExpr<TAmount = Magnitude> = {
|
|
267
|
+
ago: RelativeUnits<TAmount>;
|
|
174
268
|
} | {
|
|
175
|
-
ahead: RelativeUnits
|
|
269
|
+
ahead: RelativeUnits<TAmount>;
|
|
176
270
|
};
|
|
177
271
|
type PeriodExpr = {
|
|
178
272
|
this: PeriodUnit;
|
|
@@ -186,38 +280,22 @@ type EdgeExpr = {
|
|
|
186
280
|
} | {
|
|
187
281
|
end: PeriodExpr;
|
|
188
282
|
};
|
|
189
|
-
type DateExpr = RollingExpr | PeriodExpr | EdgeExpr;
|
|
283
|
+
type DateExpr<TAmount = Magnitude> = RollingExpr<TAmount> | PeriodExpr | EdgeExpr;
|
|
190
284
|
type DateInputOrExpr = DateInputValue | DateExpr;
|
|
191
285
|
type DateRuleValue = DateInputValue | DateExpr | [DateInputOrExpr, DateInputOrExpr] | string[];
|
|
192
286
|
type WeekStart = 'monday' | 'sunday';
|
|
193
|
-
type TimeZoneConfig = string |
|
|
194
|
-
bind: string;
|
|
195
|
-
};
|
|
287
|
+
type TimeZoneConfig = string | ValueSourceOf<string>;
|
|
196
288
|
type DateConfig = {
|
|
197
289
|
now?: DateInputValue;
|
|
198
290
|
timeZone?: TimeZoneConfig;
|
|
199
291
|
weekStart?: WeekStart;
|
|
200
292
|
};
|
|
201
|
-
type ValueSource<TValue> = {
|
|
202
|
-
|
|
203
|
-
path?: never;
|
|
204
|
-
bind?: never;
|
|
205
|
-
bindOptional?: never;
|
|
206
|
-
} | {
|
|
207
|
-
path: string;
|
|
208
|
-
value?: never;
|
|
209
|
-
bind?: never;
|
|
210
|
-
bindOptional?: never;
|
|
211
|
-
} | {
|
|
212
|
-
bind: string;
|
|
213
|
-
bindOptional?: boolean;
|
|
214
|
-
value?: never;
|
|
215
|
-
path?: never;
|
|
216
|
-
};
|
|
217
|
-
type NoValueSource = {
|
|
218
|
-
value?: never;
|
|
219
|
-
path?: never;
|
|
293
|
+
type ValueSource<TValue, TOffset = never> = ValueSourceOf<TValue> & {
|
|
294
|
+
offset?: TOffset;
|
|
220
295
|
};
|
|
296
|
+
type NumberOffset = ValueSourceOf<number>;
|
|
297
|
+
type DateOffset = ValueSourceOf<RollingExpr>;
|
|
298
|
+
type NoValueSource = Never<keyof SourceSlots<unknown> | 'offset'>;
|
|
221
299
|
type RuleBase<TOperator extends Operator> = {
|
|
222
300
|
field: string;
|
|
223
301
|
operator: TOperator;
|
|
@@ -230,13 +308,13 @@ type DateRuleBase<TOperator extends DateOperator> = {
|
|
|
230
308
|
dateOperator: TOperator;
|
|
231
309
|
error?: string;
|
|
232
310
|
};
|
|
233
|
-
type StrictEqualityRule<TValue = RuleValue> = (RuleBase<OperatorValues['equals']> & ValueSource<TValue>) | (RuleBase<OperatorValues['notEquals']> & ValueSource<TValue>);
|
|
234
|
-
type StrictOrderedComparisonRule = (RuleBase<OperatorValues['lessThan']> & ValueSource<OrderedRuleValue>) | (RuleBase<OperatorValues['lessThanEquals']> & ValueSource<OrderedRuleValue>) | (RuleBase<OperatorValues['greaterThan']> & ValueSource<OrderedRuleValue>) | (RuleBase<OperatorValues['greaterThanEquals']> & ValueSource<OrderedRuleValue>);
|
|
311
|
+
type StrictEqualityRule<TValue = RuleValue> = (RuleBase<OperatorValues['equals']> & ValueSource<TValue, NumberOffset>) | (RuleBase<OperatorValues['notEquals']> & ValueSource<TValue, NumberOffset>);
|
|
312
|
+
type StrictOrderedComparisonRule = (RuleBase<OperatorValues['lessThan']> & ValueSource<OrderedRuleValue, NumberOffset>) | (RuleBase<OperatorValues['lessThanEquals']> & ValueSource<OrderedRuleValue, NumberOffset>) | (RuleBase<OperatorValues['greaterThan']> & ValueSource<OrderedRuleValue, NumberOffset>) | (RuleBase<OperatorValues['greaterThanEquals']> & ValueSource<OrderedRuleValue, NumberOffset>);
|
|
235
313
|
type StrictMembershipRule<TValue = RuleValue> = (RuleBase<OperatorValues['in']> & ValueSource<TValue[]>) | (RuleBase<OperatorValues['notIn']> & ValueSource<TValue[]>);
|
|
236
314
|
type StrictContainsRule<TValue = RuleValue> = (RuleBase<OperatorValues['contains']> & ValueSource<TValue>) | (RuleBase<OperatorValues['notContains']> & ValueSource<TValue>);
|
|
237
315
|
type StrictPatternRule = (RuleBase<OperatorValues['matches']> & ValueSource<RegExp | string>) | (RuleBase<OperatorValues['notMatches']> & ValueSource<RegExp | string>);
|
|
238
316
|
type StrictStringBoundaryRule = (RuleBase<OperatorValues['startsWith']> & ValueSource<string>) | (RuleBase<OperatorValues['endsWith']> & ValueSource<string>);
|
|
239
|
-
type StrictRangeRule = (RuleBase<OperatorValues['between']> & ValueSource<[OrderedRuleValue, OrderedRuleValue]>) | (RuleBase<OperatorValues['notBetween']> & ValueSource<[OrderedRuleValue, OrderedRuleValue]>);
|
|
317
|
+
type StrictRangeRule = (RuleBase<OperatorValues['between']> & ValueSource<[OrderedRuleValue, OrderedRuleValue], NumberOffset>) | (RuleBase<OperatorValues['notBetween']> & ValueSource<[OrderedRuleValue, OrderedRuleValue], NumberOffset>);
|
|
240
318
|
type StrictPresenceRule = (RuleBase<OperatorValues['isEmpty']> & NoValueSource) | (RuleBase<OperatorValues['notEmpty']> & NoValueSource) | (RuleBase<OperatorValues['exists']> & NoValueSource) | (RuleBase<OperatorValues['notExists']> & NoValueSource);
|
|
241
319
|
type StrictRule<TValue = RuleValue> = StrictEqualityRule<TValue> | StrictOrderedComparisonRule | StrictMembershipRule<TValue> | StrictContainsRule<TValue> | StrictPatternRule | StrictStringBoundaryRule | StrictRangeRule | StrictPresenceRule;
|
|
242
320
|
type ArrayRuleBase<TOperator extends ArrayOperator> = {
|
|
@@ -272,15 +350,9 @@ type StrictArrayPresenceRule = (ArrayRuleBase<ArrayOperatorValues['empty']> & {
|
|
|
272
350
|
count?: never;
|
|
273
351
|
});
|
|
274
352
|
type StrictArrayRule<TRuleValue = RuleValue, TDateValue = DateRuleValue> = StrictArrayPredicateRule<TRuleValue, TDateValue> | StrictArrayCountRule<TRuleValue, TDateValue> | StrictArrayPresenceRule;
|
|
275
|
-
type StrictDateComparisonRule = (DateRuleBase<DateOperatorValues['before']> & ValueSource<DateInputValue>) | (DateRuleBase<DateOperatorValues['after']> & ValueSource<DateInputValue>) | (DateRuleBase<DateOperatorValues['onOrBefore']> & ValueSource<DateInputValue>) | (DateRuleBase<DateOperatorValues['onOrAfter']> & ValueSource<DateInputValue>) | (DateRuleBase<DateOperatorValues['notBefore']> & ValueSource<DateInputValue>) | (DateRuleBase<DateOperatorValues['notAfter']> & ValueSource<DateInputValue>);
|
|
276
|
-
type StrictDateRangeRule = (DateRuleBase<DateOperatorValues['between']> & ValueSource<[DateInputValue, DateInputValue]>) | (DateRuleBase<DateOperatorValues['notBetween']> & ValueSource<[DateInputValue, DateInputValue]>);
|
|
277
|
-
type StrictDateDayRule = (DateRuleBase<DateOperatorValues['dayIn']> &
|
|
278
|
-
value: string[];
|
|
279
|
-
path?: never;
|
|
280
|
-
}) | (DateRuleBase<DateOperatorValues['dayNotIn']> & {
|
|
281
|
-
value: string[];
|
|
282
|
-
path?: never;
|
|
283
|
-
});
|
|
353
|
+
type StrictDateComparisonRule = (DateRuleBase<DateOperatorValues['before']> & ValueSource<DateInputValue, DateOffset>) | (DateRuleBase<DateOperatorValues['after']> & ValueSource<DateInputValue, DateOffset>) | (DateRuleBase<DateOperatorValues['onOrBefore']> & ValueSource<DateInputValue, DateOffset>) | (DateRuleBase<DateOperatorValues['onOrAfter']> & ValueSource<DateInputValue, DateOffset>) | (DateRuleBase<DateOperatorValues['notBefore']> & ValueSource<DateInputValue, DateOffset>) | (DateRuleBase<DateOperatorValues['notAfter']> & ValueSource<DateInputValue, DateOffset>);
|
|
354
|
+
type StrictDateRangeRule = (DateRuleBase<DateOperatorValues['between']> & ValueSource<[DateInputValue, DateInputValue], DateOffset>) | (DateRuleBase<DateOperatorValues['notBetween']> & ValueSource<[DateInputValue, DateInputValue], DateOffset>);
|
|
355
|
+
type StrictDateDayRule = (DateRuleBase<DateOperatorValues['dayIn']> & ValueSource<string[]>) | (DateRuleBase<DateOperatorValues['dayNotIn']> & ValueSource<string[]>);
|
|
284
356
|
type StrictDateRule = StrictDateComparisonRule | StrictDateRangeRule | StrictDateDayRule;
|
|
285
357
|
type AggregateRuleBase<TRuleValue = RuleValue, TDateValue = DateRuleValue> = {
|
|
286
358
|
field: string;
|
|
@@ -317,19 +389,12 @@ type AggregateRule<TRuleValue = RuleValue, TDateValue = DateRuleValue> = WindowF
|
|
|
317
389
|
};
|
|
318
390
|
condition?: Condition<TRuleValue, TDateValue>;
|
|
319
391
|
operator: Operator;
|
|
320
|
-
value?: number | [number, number];
|
|
321
|
-
path?: string;
|
|
322
|
-
bind?: string;
|
|
323
|
-
bindOptional?: boolean;
|
|
324
392
|
error?: string;
|
|
325
|
-
}
|
|
326
|
-
type Rule<TValue = RuleValue> = {
|
|
393
|
+
} & ValueSourceFields<number | [number, number]>;
|
|
394
|
+
type Rule<TValue = RuleValue> = ValueSourceFields<TValue> & {
|
|
327
395
|
field: string;
|
|
328
396
|
operator: Operator;
|
|
329
|
-
|
|
330
|
-
path?: string;
|
|
331
|
-
bind?: string;
|
|
332
|
-
bindOptional?: boolean;
|
|
397
|
+
offset?: NumberOffset;
|
|
333
398
|
error?: string;
|
|
334
399
|
caseInsensitive?: boolean;
|
|
335
400
|
fuzzy?: boolean | FuzzyConfig;
|
|
@@ -342,13 +407,10 @@ type ArrayRule<TRuleValue = RuleValue, TDateValue = DateRuleValue> = WindowField
|
|
|
342
407
|
count?: number;
|
|
343
408
|
error?: string;
|
|
344
409
|
};
|
|
345
|
-
type DateRule<TValue = DateRuleValue> = {
|
|
410
|
+
type DateRule<TValue = DateRuleValue> = ValueSourceFields<TValue> & {
|
|
346
411
|
field: string;
|
|
347
412
|
dateOperator: DateOperator;
|
|
348
|
-
|
|
349
|
-
path?: string;
|
|
350
|
-
bind?: string;
|
|
351
|
-
bindOptional?: boolean;
|
|
413
|
+
offset?: DateOffset;
|
|
352
414
|
error?: string;
|
|
353
415
|
};
|
|
354
416
|
type All<TRuleValue = RuleValue, TDateValue = DateRuleValue> = {
|
|
@@ -382,6 +444,27 @@ type StrictIfThenElse<TRuleValue = RuleValue, TDateValue = DateRuleValue> = {
|
|
|
382
444
|
};
|
|
383
445
|
type StrictCondition<TRuleValue = RuleValue, TDateValue = DateRuleValue> = StrictRule<TRuleValue> | StrictAggregateRule<TRuleValue, TDateValue> | StrictArrayRule<TRuleValue, TDateValue> | StrictDateRule | StrictAll<TRuleValue, TDateValue> | StrictAny<TRuleValue, TDateValue> | StrictIfThenElse<TRuleValue, TDateValue> | boolean;
|
|
384
446
|
|
|
447
|
+
type ScopeRef = {
|
|
448
|
+
depth: number;
|
|
449
|
+
path: string;
|
|
450
|
+
};
|
|
451
|
+
declare const parseScopeRef: (ref: string) => ScopeRef | null;
|
|
452
|
+
type ScopedRef<S> = {
|
|
453
|
+
scope: S;
|
|
454
|
+
path: string;
|
|
455
|
+
};
|
|
456
|
+
type ScopeOutOfBounds = {
|
|
457
|
+
outOfBounds: string;
|
|
458
|
+
};
|
|
459
|
+
declare const resolveScopeRef: <S>(ref: string, scopes: readonly S[]) => ScopedRef<S> | ScopeOutOfBounds;
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* The value of one `{ bind }` at evaluation. Key presence is the contract: an unsupplied
|
|
463
|
+
* binding is a caller bug (a forgotten scope must never silently run) unless the source marks
|
|
464
|
+
* it `bindOptional`, which reads as null. A supplied-but-undefined binding is null.
|
|
465
|
+
*/
|
|
466
|
+
declare const readBinding: (name: string, optional: boolean | undefined, bindings: Record<string, RuleValue> | undefined) => RuleValue;
|
|
467
|
+
|
|
385
468
|
/** Names of every `{ bind }` token in the tree, optional or not — what a lens declares. */
|
|
386
469
|
declare const bindingNames: (condition: Condition) => Set<string>;
|
|
387
470
|
/**
|
|
@@ -890,20 +973,6 @@ declare const sourceValuesFromRows: (lensOrNarrowing: Lens | LensNarrowing, rows
|
|
|
890
973
|
|
|
891
974
|
declare const stampCoercions: (condition: Condition, lensOrNarrowing: Lens | LensNarrowing) => Condition;
|
|
892
975
|
|
|
893
|
-
type ScopeRef = {
|
|
894
|
-
depth: number;
|
|
895
|
-
path: string;
|
|
896
|
-
};
|
|
897
|
-
declare const parseScopeRef: (ref: string) => ScopeRef | null;
|
|
898
|
-
type ScopedRef<S> = {
|
|
899
|
-
scope: S;
|
|
900
|
-
path: string;
|
|
901
|
-
};
|
|
902
|
-
type ScopeOutOfBounds = {
|
|
903
|
-
outOfBounds: string;
|
|
904
|
-
};
|
|
905
|
-
declare const resolveScopeRef: <S>(ref: string, scopes: readonly S[]) => ScopedRef<S> | ScopeOutOfBounds;
|
|
906
|
-
|
|
907
976
|
/**
|
|
908
977
|
* Execute a Prisma query plan produced by toPrisma().
|
|
909
978
|
*
|
|
@@ -989,4 +1058,4 @@ declare const assertValidRule: (condition: unknown, options?: {
|
|
|
989
1058
|
target?: RuleTarget;
|
|
990
1059
|
}) => asserts condition is Condition;
|
|
991
1060
|
|
|
992
|
-
export { AGGREGATE_OPERATORS, ALL_KINDS, ARRAY_OPERATOR_CATALOG, type AggregateMode, type AggregateRule, type All, type Any, type ArrayCatalogEntry, ArrayOperator, type ArrayRule, type Bridge, type BridgeCardinality, type BridgeDictionary, type BridgeEndpoint, type BuildOptions, type CatalogEntry, type CheckOptions, type Condition, type CreateLensInput, DATE_OPERATOR_CATALOG, type DateConfig, type DateExpr, type DateInputOrExpr, type DateInputValue, DateOperator, type DateRule, type DateRuleValue, EQUATABLE_KINDS, type EdgeExpr, type EngineGlobalsState, type EnumNarrowing, FIELD_OPERATOR_CATALOG, FieldKind, type FieldMap, type FieldMapEntry, type FieldMapSet, type FuzzyConfig, type GroupByStep, type IfThenElse, type Lens, type LensNarrowing, type LensPathHop, type LensPathResolution, type ModelDefaultNarrowing, type ModelNarrowing, NULLABLE_KINDS, NUMERIC_KINDS, type NarrowingDefaults, ORDERABLE_KINDS, Operator, type OrderBy, type OrderedRuleValue, type PathProjection, type PeriodExpr, type PeriodUnit, type PrismaProvider, type PrismaStep, type PrismaWhere, type ProjectOptions, type ProjectedVisit, type RelativeUnits, type RollingExpr, type Rule, type RuleDescription, type RuleLensCheck, type RuleLensViolation, type RuleScalar, type RuleSourceValues, RuleTarget, type RuleValue, STRINGY_KINDS, type ScopeOutOfBounds, type ScopeRef, type ScopedRef, type SortDir, type SourceOption, type SourcePrismaQuery, type SourceQuery, type SourceRowShape, type SourceSpec, type SourceSqlQuery, type SourceValue, type SourceValues, type SqlResult, type StepRef, type StrictAggregateRule, type StrictAll, type StrictAny, type StrictArrayCountRule, type StrictArrayPredicateRule, type StrictArrayPresenceRule, type StrictArrayRule, type StrictCondition, type StrictContainsRule, type StrictDateComparisonRule, type StrictDateDayRule, type StrictDateRangeRule, type StrictDateRule, type StrictEqualityRule, type StrictIfThenElse, type StrictMembershipRule, type StrictOrderedComparisonRule, type StrictPatternRule, type StrictPresenceRule, type StrictRangeRule, type StrictRule, type StrictStringBoundaryRule, type TimeZoneConfig, type ToPrismaResult, type ValidationIssue, type ValidationResult, ValueShape, WINDOW_SELECTOR, type WeekStart, type WhereStep, type WindowFields, type WindowRuleType, WindowSupport, applyLens, assertValidRule, bindingNames, buildBridgeDictionary, check, checkRuleAgainstLens, createLens, describeRule, engineGlobals, executePrismaQueryPlan, exposedSurface, fuzzyContains, getAggregateOperators, getArrayOperators, getOperatorsForKind, getValueShape, getWindowSupport, isAggregateRangeOperator, isAggregateSingleOperator, isOperatorSupportedForTarget, lensRequiredBindings, maxFuzzyDistance, parseScopeRef, projectByPath, requiredBindings, resolveBindings, resolveCaseInsensitive, resolveFuzzy, resolveLensBindings, resolveLensPath, resolveScopeRef, ruleSourceValues, sourceQueries, sourceValuesFromQueryRows, sourceValuesFromRows, stampCoercions, stitchFieldMaps, supportsQueryMode, toPrisma, toSql, validateBindNames, validateFieldMap, validateFieldMapSet, validateNarrowing, validateRule };
|
|
1061
|
+
export { AGGREGATE_OPERATORS, ALL_KINDS, ARRAY_OPERATOR_CATALOG, type AggregateMode, type AggregateRule, type All, type Any, type ArrayCatalogEntry, ArrayOperator, type ArrayRule, type Bridge, type BridgeCardinality, type BridgeDictionary, type BridgeEndpoint, type BuildOptions, COERCIBLE_KINDS, COMPILE_COERCED_KINDS, type CatalogEntry, type CheckOptions, type Condition, type CreateLensInput, DATE_OPERATOR_CATALOG, type DateConfig, type DateExpr, type DateInputOrExpr, type DateInputValue, type DateOffset, DateOperator, type DateRule, type DateRuleValue, EQUATABLE_KINDS, type EdgeExpr, type EngineGlobalsState, type EnumNarrowing, FIELD_OPERATOR_CATALOG, FieldKind, type FieldMap, type FieldMapEntry, type FieldMapSet, type FuzzyConfig, type GroupByStep, INTEGER_KINDS, INTERVAL_FIELDS, type IfThenElse, LOWER_BOUND_OPERATORS, type Lens, type LensNarrowing, type LensPathHop, type LensPathResolution, type Magnitude, type ModelDefaultNarrowing, type ModelNarrowing, NEGATED_COMPARISON_OPERATORS, NEGATED_OPERATORS, NEGATED_RANGE_OPERATORS, NEGATED_SINGLE_VALUE_OPERATORS, NO_VALUE_OPERATORS, NULLABLE_KINDS, NUMERIC_KINDS, type NarrowingDefaults, type NumberOffset, OFFSET_OPERATORS, ORDERABLE_KINDS, ORDERED_OPERATORS, Operator, type OrderBy, type OrderedRuleValue, PERIOD_UNITS, type PathProjection, type PeriodExpr, type PeriodUnit, type PrismaProvider, type PrismaStep, type PrismaWhere, type ProjectOptions, type ProjectedVisit, RANGE_OPERATORS, RELATIVE_UNITS, type RelativeUnit, type RelativeUnits, type RollingExpr, type Rule, type RuleDescription, type RuleLensCheck, type RuleLensViolation, type RuleScalar, type RuleSourceValues, RuleTarget, type RuleValue, SINGLE_VALUE_SHAPES, STRINGY_KINDS, type ScopeOutOfBounds, type ScopeRef, type ScopedRef, type SortDir, type SourceOption, type SourcePrismaQuery, type SourceQuery, type SourceRowShape, type SourceSpec, type SourceSqlQuery, type SourceValue, type SourceValues, type SqlResult, type StepRef, type StrictAggregateRule, type StrictAll, type StrictAny, type StrictArrayCountRule, type StrictArrayPredicateRule, type StrictArrayPresenceRule, type StrictArrayRule, type StrictCondition, type StrictContainsRule, type StrictDateComparisonRule, type StrictDateDayRule, type StrictDateRangeRule, type StrictDateRule, type StrictEqualityRule, type StrictIfThenElse, type StrictMembershipRule, type StrictOrderedComparisonRule, type StrictPatternRule, type StrictPresenceRule, type StrictRangeRule, type StrictRule, type StrictStringBoundaryRule, type TimeZoneConfig, type ToPrismaResult, UPPER_BOUND_OPERATORS, type ValidationIssue, type ValidationResult, ValueShape, type ValueSourceFields, type ValueSourceOf, WINDOW_OPERATORS, WINDOW_SELECTOR, type WeekStart, type WhereStep, type WindowFields, type WindowRuleType, WindowSupport, applyLens, assertValidRule, bindingNames, buildBridgeDictionary, check, checkRuleAgainstLens, createLens, describeRule, engineGlobals, executePrismaQueryPlan, exposedSurface, fuzzyContains, getAggregateOperators, getArrayOperators, getOperatorsForKind, getValueShape, getWindowSupport, isAggregateRangeOperator, isAggregateSingleOperator, isCalendarUnit, isOperatorSupportedForTarget, isRelativeUnit, lensRequiredBindings, maxFuzzyDistance, parseScopeRef, projectByPath, readBinding, requiredBindings, resolveBindings, resolveCaseInsensitive, resolveFuzzy, resolveLensBindings, resolveLensPath, resolveScopeRef, ruleSourceValues, sourceQueries, sourceValuesFromQueryRows, sourceValuesFromRows, stampCoercions, stitchFieldMaps, supportsQueryMode, toPrisma, toSql, validateBindNames, validateFieldMap, validateFieldMapSet, validateNarrowing, validateRule };
|
package/dist/index.d.ts
CHANGED
|
@@ -147,6 +147,88 @@ declare const getOperatorsForKind: (kind: FieldKind, target?: RuleTarget) => {
|
|
|
147
147
|
date: DateOperator[];
|
|
148
148
|
};
|
|
149
149
|
declare const getArrayOperators: (target?: RuleTarget) => ArrayOperator[];
|
|
150
|
+
/** Operators that read no comparison value. */
|
|
151
|
+
declare const NO_VALUE_OPERATORS: readonly string[];
|
|
152
|
+
/** Field comparisons with an order: `<`, `<=`, `>`, `>=`. */
|
|
153
|
+
declare const ORDERED_OPERATORS: readonly string[];
|
|
154
|
+
/** A window expression (`within`), not a pair. */
|
|
155
|
+
declare const WINDOW_OPERATORS: readonly string[];
|
|
156
|
+
/** Operators that compare against two ends. */
|
|
157
|
+
declare const RANGE_OPERATORS: readonly string[];
|
|
158
|
+
/** Operators with a point to move: the comparisons and both ends of a pair. */
|
|
159
|
+
declare const OFFSET_OPERATORS: readonly string[];
|
|
160
|
+
/** The negations: each is the complement of its positive form and keeps NULL fields
|
|
161
|
+
* (the 2.19.0 ruling). */
|
|
162
|
+
declare const NEGATED_OPERATORS: readonly string[];
|
|
163
|
+
/** Negations of a two-ended range. */
|
|
164
|
+
declare const NEGATED_RANGE_OPERATORS: string[];
|
|
165
|
+
/** Negated comparisons an offset can move; with nothing to compare against they still keep a
|
|
166
|
+
* null field. */
|
|
167
|
+
declare const NEGATED_COMPARISON_OPERATORS: string[];
|
|
168
|
+
/** Negations of one literal (`notEquals`, `notContains`). */
|
|
169
|
+
declare const NEGATED_SINGLE_VALUE_OPERATORS: string[];
|
|
170
|
+
/** Comparisons that bound a field from above / below — what a window's extremal rewrite reads. */
|
|
171
|
+
declare const UPPER_BOUND_OPERATORS: readonly string[];
|
|
172
|
+
declare const LOWER_BOUND_OPERATORS: readonly string[];
|
|
173
|
+
/** Kinds a calendar unit amount can read: whole numbers. */
|
|
174
|
+
declare const INTEGER_KINDS: readonly FieldKind[];
|
|
175
|
+
/** Kinds check() coerces a literal to (see coerceScalar in src/field.ts). */
|
|
176
|
+
declare const COERCIBLE_KINDS: readonly FieldKind[];
|
|
177
|
+
/** Kinds whose literal the compilers coerce exactly as check() does — Prisma rejects a string on
|
|
178
|
+
* Int/Float/Boolean; BigInt compares as Int. Decimal keeps its literal: Prisma and Postgres take
|
|
179
|
+
* the numeric string losslessly, and a JS number would not. */
|
|
180
|
+
declare const COMPILE_COERCED_KINDS: readonly FieldKind[];
|
|
181
|
+
/** Value shapes that take one literal. */
|
|
182
|
+
declare const SINGLE_VALUE_SHAPES: readonly ValueShape[];
|
|
183
|
+
/** Each relative unit: the Postgres interval field it adds to, its size there, and whether it is
|
|
184
|
+
* a calendar unit (whole steps). Applied months, then days, then time, as Postgres does. */
|
|
185
|
+
declare const RELATIVE_UNITS: {
|
|
186
|
+
readonly years: {
|
|
187
|
+
readonly interval: "months";
|
|
188
|
+
readonly factor: 12;
|
|
189
|
+
readonly calendar: true;
|
|
190
|
+
};
|
|
191
|
+
readonly quarters: {
|
|
192
|
+
readonly interval: "months";
|
|
193
|
+
readonly factor: 3;
|
|
194
|
+
readonly calendar: true;
|
|
195
|
+
};
|
|
196
|
+
readonly months: {
|
|
197
|
+
readonly interval: "months";
|
|
198
|
+
readonly factor: 1;
|
|
199
|
+
readonly calendar: true;
|
|
200
|
+
};
|
|
201
|
+
readonly weeks: {
|
|
202
|
+
readonly interval: "days";
|
|
203
|
+
readonly factor: 7;
|
|
204
|
+
readonly calendar: true;
|
|
205
|
+
};
|
|
206
|
+
readonly days: {
|
|
207
|
+
readonly interval: "days";
|
|
208
|
+
readonly factor: 1;
|
|
209
|
+
readonly calendar: true;
|
|
210
|
+
};
|
|
211
|
+
readonly hours: {
|
|
212
|
+
readonly interval: "secs";
|
|
213
|
+
readonly factor: 3600;
|
|
214
|
+
readonly calendar: false;
|
|
215
|
+
};
|
|
216
|
+
readonly minutes: {
|
|
217
|
+
readonly interval: "secs";
|
|
218
|
+
readonly factor: 60;
|
|
219
|
+
readonly calendar: false;
|
|
220
|
+
};
|
|
221
|
+
readonly seconds: {
|
|
222
|
+
readonly interval: "secs";
|
|
223
|
+
readonly factor: 1;
|
|
224
|
+
readonly calendar: false;
|
|
225
|
+
};
|
|
226
|
+
};
|
|
227
|
+
type RelativeUnit = keyof typeof RELATIVE_UNITS;
|
|
228
|
+
declare const INTERVAL_FIELDS: readonly ["months", "days", "secs"];
|
|
229
|
+
declare const isRelativeUnit: (unit: string) => unit is RelativeUnit;
|
|
230
|
+
declare const isCalendarUnit: (unit: string) => boolean;
|
|
231
|
+
declare const PERIOD_UNITS: readonly string[];
|
|
150
232
|
|
|
151
233
|
type OperatorValues = typeof Operator;
|
|
152
234
|
type ArrayOperatorValues = typeof ArrayOperator;
|
|
@@ -158,21 +240,33 @@ type RuleValue = RuleScalar | Date | RegExp | RuleValue[] | {
|
|
|
158
240
|
};
|
|
159
241
|
type OrderedRuleValue = string | number | Date;
|
|
160
242
|
type DateInputValue = string | number | Date;
|
|
161
|
-
type
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
243
|
+
type SourceSlots<TValue> = {
|
|
244
|
+
value: TValue;
|
|
245
|
+
path: string;
|
|
246
|
+
bind: string;
|
|
247
|
+
bindOptional: boolean;
|
|
248
|
+
};
|
|
249
|
+
type Never<K extends PropertyKey> = {
|
|
250
|
+
[P in K]?: never;
|
|
251
|
+
};
|
|
252
|
+
type ValueSourceOf<TValue> = (Pick<SourceSlots<TValue>, 'value'> & Never<'path' | 'bind' | 'bindOptional'>) | (Pick<SourceSlots<TValue>, 'path'> & Never<'value' | 'bind' | 'bindOptional'>) | (Pick<SourceSlots<TValue>, 'bind'> & Partial<Pick<SourceSlots<TValue>, 'bindOptional'>> & Never<'value' | 'path'>);
|
|
253
|
+
type ValueSourceFields<TValue> = Partial<SourceSlots<TValue>>;
|
|
254
|
+
type Magnitude = number | ValueSourceOf<number>;
|
|
255
|
+
type RelativeUnits<TAmount = Magnitude> = {
|
|
256
|
+
years?: TAmount;
|
|
257
|
+
quarters?: TAmount;
|
|
258
|
+
months?: TAmount;
|
|
259
|
+
weeks?: TAmount;
|
|
260
|
+
days?: TAmount;
|
|
261
|
+
hours?: TAmount;
|
|
262
|
+
minutes?: TAmount;
|
|
263
|
+
seconds?: TAmount;
|
|
170
264
|
};
|
|
171
265
|
type PeriodUnit = 'year' | 'quarter' | 'month' | 'week' | 'isoWeek' | 'day' | 'hour' | 'minute' | 'second';
|
|
172
|
-
type RollingExpr = {
|
|
173
|
-
ago: RelativeUnits
|
|
266
|
+
type RollingExpr<TAmount = Magnitude> = {
|
|
267
|
+
ago: RelativeUnits<TAmount>;
|
|
174
268
|
} | {
|
|
175
|
-
ahead: RelativeUnits
|
|
269
|
+
ahead: RelativeUnits<TAmount>;
|
|
176
270
|
};
|
|
177
271
|
type PeriodExpr = {
|
|
178
272
|
this: PeriodUnit;
|
|
@@ -186,38 +280,22 @@ type EdgeExpr = {
|
|
|
186
280
|
} | {
|
|
187
281
|
end: PeriodExpr;
|
|
188
282
|
};
|
|
189
|
-
type DateExpr = RollingExpr | PeriodExpr | EdgeExpr;
|
|
283
|
+
type DateExpr<TAmount = Magnitude> = RollingExpr<TAmount> | PeriodExpr | EdgeExpr;
|
|
190
284
|
type DateInputOrExpr = DateInputValue | DateExpr;
|
|
191
285
|
type DateRuleValue = DateInputValue | DateExpr | [DateInputOrExpr, DateInputOrExpr] | string[];
|
|
192
286
|
type WeekStart = 'monday' | 'sunday';
|
|
193
|
-
type TimeZoneConfig = string |
|
|
194
|
-
bind: string;
|
|
195
|
-
};
|
|
287
|
+
type TimeZoneConfig = string | ValueSourceOf<string>;
|
|
196
288
|
type DateConfig = {
|
|
197
289
|
now?: DateInputValue;
|
|
198
290
|
timeZone?: TimeZoneConfig;
|
|
199
291
|
weekStart?: WeekStart;
|
|
200
292
|
};
|
|
201
|
-
type ValueSource<TValue> = {
|
|
202
|
-
|
|
203
|
-
path?: never;
|
|
204
|
-
bind?: never;
|
|
205
|
-
bindOptional?: never;
|
|
206
|
-
} | {
|
|
207
|
-
path: string;
|
|
208
|
-
value?: never;
|
|
209
|
-
bind?: never;
|
|
210
|
-
bindOptional?: never;
|
|
211
|
-
} | {
|
|
212
|
-
bind: string;
|
|
213
|
-
bindOptional?: boolean;
|
|
214
|
-
value?: never;
|
|
215
|
-
path?: never;
|
|
216
|
-
};
|
|
217
|
-
type NoValueSource = {
|
|
218
|
-
value?: never;
|
|
219
|
-
path?: never;
|
|
293
|
+
type ValueSource<TValue, TOffset = never> = ValueSourceOf<TValue> & {
|
|
294
|
+
offset?: TOffset;
|
|
220
295
|
};
|
|
296
|
+
type NumberOffset = ValueSourceOf<number>;
|
|
297
|
+
type DateOffset = ValueSourceOf<RollingExpr>;
|
|
298
|
+
type NoValueSource = Never<keyof SourceSlots<unknown> | 'offset'>;
|
|
221
299
|
type RuleBase<TOperator extends Operator> = {
|
|
222
300
|
field: string;
|
|
223
301
|
operator: TOperator;
|
|
@@ -230,13 +308,13 @@ type DateRuleBase<TOperator extends DateOperator> = {
|
|
|
230
308
|
dateOperator: TOperator;
|
|
231
309
|
error?: string;
|
|
232
310
|
};
|
|
233
|
-
type StrictEqualityRule<TValue = RuleValue> = (RuleBase<OperatorValues['equals']> & ValueSource<TValue>) | (RuleBase<OperatorValues['notEquals']> & ValueSource<TValue>);
|
|
234
|
-
type StrictOrderedComparisonRule = (RuleBase<OperatorValues['lessThan']> & ValueSource<OrderedRuleValue>) | (RuleBase<OperatorValues['lessThanEquals']> & ValueSource<OrderedRuleValue>) | (RuleBase<OperatorValues['greaterThan']> & ValueSource<OrderedRuleValue>) | (RuleBase<OperatorValues['greaterThanEquals']> & ValueSource<OrderedRuleValue>);
|
|
311
|
+
type StrictEqualityRule<TValue = RuleValue> = (RuleBase<OperatorValues['equals']> & ValueSource<TValue, NumberOffset>) | (RuleBase<OperatorValues['notEquals']> & ValueSource<TValue, NumberOffset>);
|
|
312
|
+
type StrictOrderedComparisonRule = (RuleBase<OperatorValues['lessThan']> & ValueSource<OrderedRuleValue, NumberOffset>) | (RuleBase<OperatorValues['lessThanEquals']> & ValueSource<OrderedRuleValue, NumberOffset>) | (RuleBase<OperatorValues['greaterThan']> & ValueSource<OrderedRuleValue, NumberOffset>) | (RuleBase<OperatorValues['greaterThanEquals']> & ValueSource<OrderedRuleValue, NumberOffset>);
|
|
235
313
|
type StrictMembershipRule<TValue = RuleValue> = (RuleBase<OperatorValues['in']> & ValueSource<TValue[]>) | (RuleBase<OperatorValues['notIn']> & ValueSource<TValue[]>);
|
|
236
314
|
type StrictContainsRule<TValue = RuleValue> = (RuleBase<OperatorValues['contains']> & ValueSource<TValue>) | (RuleBase<OperatorValues['notContains']> & ValueSource<TValue>);
|
|
237
315
|
type StrictPatternRule = (RuleBase<OperatorValues['matches']> & ValueSource<RegExp | string>) | (RuleBase<OperatorValues['notMatches']> & ValueSource<RegExp | string>);
|
|
238
316
|
type StrictStringBoundaryRule = (RuleBase<OperatorValues['startsWith']> & ValueSource<string>) | (RuleBase<OperatorValues['endsWith']> & ValueSource<string>);
|
|
239
|
-
type StrictRangeRule = (RuleBase<OperatorValues['between']> & ValueSource<[OrderedRuleValue, OrderedRuleValue]>) | (RuleBase<OperatorValues['notBetween']> & ValueSource<[OrderedRuleValue, OrderedRuleValue]>);
|
|
317
|
+
type StrictRangeRule = (RuleBase<OperatorValues['between']> & ValueSource<[OrderedRuleValue, OrderedRuleValue], NumberOffset>) | (RuleBase<OperatorValues['notBetween']> & ValueSource<[OrderedRuleValue, OrderedRuleValue], NumberOffset>);
|
|
240
318
|
type StrictPresenceRule = (RuleBase<OperatorValues['isEmpty']> & NoValueSource) | (RuleBase<OperatorValues['notEmpty']> & NoValueSource) | (RuleBase<OperatorValues['exists']> & NoValueSource) | (RuleBase<OperatorValues['notExists']> & NoValueSource);
|
|
241
319
|
type StrictRule<TValue = RuleValue> = StrictEqualityRule<TValue> | StrictOrderedComparisonRule | StrictMembershipRule<TValue> | StrictContainsRule<TValue> | StrictPatternRule | StrictStringBoundaryRule | StrictRangeRule | StrictPresenceRule;
|
|
242
320
|
type ArrayRuleBase<TOperator extends ArrayOperator> = {
|
|
@@ -272,15 +350,9 @@ type StrictArrayPresenceRule = (ArrayRuleBase<ArrayOperatorValues['empty']> & {
|
|
|
272
350
|
count?: never;
|
|
273
351
|
});
|
|
274
352
|
type StrictArrayRule<TRuleValue = RuleValue, TDateValue = DateRuleValue> = StrictArrayPredicateRule<TRuleValue, TDateValue> | StrictArrayCountRule<TRuleValue, TDateValue> | StrictArrayPresenceRule;
|
|
275
|
-
type StrictDateComparisonRule = (DateRuleBase<DateOperatorValues['before']> & ValueSource<DateInputValue>) | (DateRuleBase<DateOperatorValues['after']> & ValueSource<DateInputValue>) | (DateRuleBase<DateOperatorValues['onOrBefore']> & ValueSource<DateInputValue>) | (DateRuleBase<DateOperatorValues['onOrAfter']> & ValueSource<DateInputValue>) | (DateRuleBase<DateOperatorValues['notBefore']> & ValueSource<DateInputValue>) | (DateRuleBase<DateOperatorValues['notAfter']> & ValueSource<DateInputValue>);
|
|
276
|
-
type StrictDateRangeRule = (DateRuleBase<DateOperatorValues['between']> & ValueSource<[DateInputValue, DateInputValue]>) | (DateRuleBase<DateOperatorValues['notBetween']> & ValueSource<[DateInputValue, DateInputValue]>);
|
|
277
|
-
type StrictDateDayRule = (DateRuleBase<DateOperatorValues['dayIn']> &
|
|
278
|
-
value: string[];
|
|
279
|
-
path?: never;
|
|
280
|
-
}) | (DateRuleBase<DateOperatorValues['dayNotIn']> & {
|
|
281
|
-
value: string[];
|
|
282
|
-
path?: never;
|
|
283
|
-
});
|
|
353
|
+
type StrictDateComparisonRule = (DateRuleBase<DateOperatorValues['before']> & ValueSource<DateInputValue, DateOffset>) | (DateRuleBase<DateOperatorValues['after']> & ValueSource<DateInputValue, DateOffset>) | (DateRuleBase<DateOperatorValues['onOrBefore']> & ValueSource<DateInputValue, DateOffset>) | (DateRuleBase<DateOperatorValues['onOrAfter']> & ValueSource<DateInputValue, DateOffset>) | (DateRuleBase<DateOperatorValues['notBefore']> & ValueSource<DateInputValue, DateOffset>) | (DateRuleBase<DateOperatorValues['notAfter']> & ValueSource<DateInputValue, DateOffset>);
|
|
354
|
+
type StrictDateRangeRule = (DateRuleBase<DateOperatorValues['between']> & ValueSource<[DateInputValue, DateInputValue], DateOffset>) | (DateRuleBase<DateOperatorValues['notBetween']> & ValueSource<[DateInputValue, DateInputValue], DateOffset>);
|
|
355
|
+
type StrictDateDayRule = (DateRuleBase<DateOperatorValues['dayIn']> & ValueSource<string[]>) | (DateRuleBase<DateOperatorValues['dayNotIn']> & ValueSource<string[]>);
|
|
284
356
|
type StrictDateRule = StrictDateComparisonRule | StrictDateRangeRule | StrictDateDayRule;
|
|
285
357
|
type AggregateRuleBase<TRuleValue = RuleValue, TDateValue = DateRuleValue> = {
|
|
286
358
|
field: string;
|
|
@@ -317,19 +389,12 @@ type AggregateRule<TRuleValue = RuleValue, TDateValue = DateRuleValue> = WindowF
|
|
|
317
389
|
};
|
|
318
390
|
condition?: Condition<TRuleValue, TDateValue>;
|
|
319
391
|
operator: Operator;
|
|
320
|
-
value?: number | [number, number];
|
|
321
|
-
path?: string;
|
|
322
|
-
bind?: string;
|
|
323
|
-
bindOptional?: boolean;
|
|
324
392
|
error?: string;
|
|
325
|
-
}
|
|
326
|
-
type Rule<TValue = RuleValue> = {
|
|
393
|
+
} & ValueSourceFields<number | [number, number]>;
|
|
394
|
+
type Rule<TValue = RuleValue> = ValueSourceFields<TValue> & {
|
|
327
395
|
field: string;
|
|
328
396
|
operator: Operator;
|
|
329
|
-
|
|
330
|
-
path?: string;
|
|
331
|
-
bind?: string;
|
|
332
|
-
bindOptional?: boolean;
|
|
397
|
+
offset?: NumberOffset;
|
|
333
398
|
error?: string;
|
|
334
399
|
caseInsensitive?: boolean;
|
|
335
400
|
fuzzy?: boolean | FuzzyConfig;
|
|
@@ -342,13 +407,10 @@ type ArrayRule<TRuleValue = RuleValue, TDateValue = DateRuleValue> = WindowField
|
|
|
342
407
|
count?: number;
|
|
343
408
|
error?: string;
|
|
344
409
|
};
|
|
345
|
-
type DateRule<TValue = DateRuleValue> = {
|
|
410
|
+
type DateRule<TValue = DateRuleValue> = ValueSourceFields<TValue> & {
|
|
346
411
|
field: string;
|
|
347
412
|
dateOperator: DateOperator;
|
|
348
|
-
|
|
349
|
-
path?: string;
|
|
350
|
-
bind?: string;
|
|
351
|
-
bindOptional?: boolean;
|
|
413
|
+
offset?: DateOffset;
|
|
352
414
|
error?: string;
|
|
353
415
|
};
|
|
354
416
|
type All<TRuleValue = RuleValue, TDateValue = DateRuleValue> = {
|
|
@@ -382,6 +444,27 @@ type StrictIfThenElse<TRuleValue = RuleValue, TDateValue = DateRuleValue> = {
|
|
|
382
444
|
};
|
|
383
445
|
type StrictCondition<TRuleValue = RuleValue, TDateValue = DateRuleValue> = StrictRule<TRuleValue> | StrictAggregateRule<TRuleValue, TDateValue> | StrictArrayRule<TRuleValue, TDateValue> | StrictDateRule | StrictAll<TRuleValue, TDateValue> | StrictAny<TRuleValue, TDateValue> | StrictIfThenElse<TRuleValue, TDateValue> | boolean;
|
|
384
446
|
|
|
447
|
+
type ScopeRef = {
|
|
448
|
+
depth: number;
|
|
449
|
+
path: string;
|
|
450
|
+
};
|
|
451
|
+
declare const parseScopeRef: (ref: string) => ScopeRef | null;
|
|
452
|
+
type ScopedRef<S> = {
|
|
453
|
+
scope: S;
|
|
454
|
+
path: string;
|
|
455
|
+
};
|
|
456
|
+
type ScopeOutOfBounds = {
|
|
457
|
+
outOfBounds: string;
|
|
458
|
+
};
|
|
459
|
+
declare const resolveScopeRef: <S>(ref: string, scopes: readonly S[]) => ScopedRef<S> | ScopeOutOfBounds;
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* The value of one `{ bind }` at evaluation. Key presence is the contract: an unsupplied
|
|
463
|
+
* binding is a caller bug (a forgotten scope must never silently run) unless the source marks
|
|
464
|
+
* it `bindOptional`, which reads as null. A supplied-but-undefined binding is null.
|
|
465
|
+
*/
|
|
466
|
+
declare const readBinding: (name: string, optional: boolean | undefined, bindings: Record<string, RuleValue> | undefined) => RuleValue;
|
|
467
|
+
|
|
385
468
|
/** Names of every `{ bind }` token in the tree, optional or not — what a lens declares. */
|
|
386
469
|
declare const bindingNames: (condition: Condition) => Set<string>;
|
|
387
470
|
/**
|
|
@@ -890,20 +973,6 @@ declare const sourceValuesFromRows: (lensOrNarrowing: Lens | LensNarrowing, rows
|
|
|
890
973
|
|
|
891
974
|
declare const stampCoercions: (condition: Condition, lensOrNarrowing: Lens | LensNarrowing) => Condition;
|
|
892
975
|
|
|
893
|
-
type ScopeRef = {
|
|
894
|
-
depth: number;
|
|
895
|
-
path: string;
|
|
896
|
-
};
|
|
897
|
-
declare const parseScopeRef: (ref: string) => ScopeRef | null;
|
|
898
|
-
type ScopedRef<S> = {
|
|
899
|
-
scope: S;
|
|
900
|
-
path: string;
|
|
901
|
-
};
|
|
902
|
-
type ScopeOutOfBounds = {
|
|
903
|
-
outOfBounds: string;
|
|
904
|
-
};
|
|
905
|
-
declare const resolveScopeRef: <S>(ref: string, scopes: readonly S[]) => ScopedRef<S> | ScopeOutOfBounds;
|
|
906
|
-
|
|
907
976
|
/**
|
|
908
977
|
* Execute a Prisma query plan produced by toPrisma().
|
|
909
978
|
*
|
|
@@ -989,4 +1058,4 @@ declare const assertValidRule: (condition: unknown, options?: {
|
|
|
989
1058
|
target?: RuleTarget;
|
|
990
1059
|
}) => asserts condition is Condition;
|
|
991
1060
|
|
|
992
|
-
export { AGGREGATE_OPERATORS, ALL_KINDS, ARRAY_OPERATOR_CATALOG, type AggregateMode, type AggregateRule, type All, type Any, type ArrayCatalogEntry, ArrayOperator, type ArrayRule, type Bridge, type BridgeCardinality, type BridgeDictionary, type BridgeEndpoint, type BuildOptions, type CatalogEntry, type CheckOptions, type Condition, type CreateLensInput, DATE_OPERATOR_CATALOG, type DateConfig, type DateExpr, type DateInputOrExpr, type DateInputValue, DateOperator, type DateRule, type DateRuleValue, EQUATABLE_KINDS, type EdgeExpr, type EngineGlobalsState, type EnumNarrowing, FIELD_OPERATOR_CATALOG, FieldKind, type FieldMap, type FieldMapEntry, type FieldMapSet, type FuzzyConfig, type GroupByStep, type IfThenElse, type Lens, type LensNarrowing, type LensPathHop, type LensPathResolution, type ModelDefaultNarrowing, type ModelNarrowing, NULLABLE_KINDS, NUMERIC_KINDS, type NarrowingDefaults, ORDERABLE_KINDS, Operator, type OrderBy, type OrderedRuleValue, type PathProjection, type PeriodExpr, type PeriodUnit, type PrismaProvider, type PrismaStep, type PrismaWhere, type ProjectOptions, type ProjectedVisit, type RelativeUnits, type RollingExpr, type Rule, type RuleDescription, type RuleLensCheck, type RuleLensViolation, type RuleScalar, type RuleSourceValues, RuleTarget, type RuleValue, STRINGY_KINDS, type ScopeOutOfBounds, type ScopeRef, type ScopedRef, type SortDir, type SourceOption, type SourcePrismaQuery, type SourceQuery, type SourceRowShape, type SourceSpec, type SourceSqlQuery, type SourceValue, type SourceValues, type SqlResult, type StepRef, type StrictAggregateRule, type StrictAll, type StrictAny, type StrictArrayCountRule, type StrictArrayPredicateRule, type StrictArrayPresenceRule, type StrictArrayRule, type StrictCondition, type StrictContainsRule, type StrictDateComparisonRule, type StrictDateDayRule, type StrictDateRangeRule, type StrictDateRule, type StrictEqualityRule, type StrictIfThenElse, type StrictMembershipRule, type StrictOrderedComparisonRule, type StrictPatternRule, type StrictPresenceRule, type StrictRangeRule, type StrictRule, type StrictStringBoundaryRule, type TimeZoneConfig, type ToPrismaResult, type ValidationIssue, type ValidationResult, ValueShape, WINDOW_SELECTOR, type WeekStart, type WhereStep, type WindowFields, type WindowRuleType, WindowSupport, applyLens, assertValidRule, bindingNames, buildBridgeDictionary, check, checkRuleAgainstLens, createLens, describeRule, engineGlobals, executePrismaQueryPlan, exposedSurface, fuzzyContains, getAggregateOperators, getArrayOperators, getOperatorsForKind, getValueShape, getWindowSupport, isAggregateRangeOperator, isAggregateSingleOperator, isOperatorSupportedForTarget, lensRequiredBindings, maxFuzzyDistance, parseScopeRef, projectByPath, requiredBindings, resolveBindings, resolveCaseInsensitive, resolveFuzzy, resolveLensBindings, resolveLensPath, resolveScopeRef, ruleSourceValues, sourceQueries, sourceValuesFromQueryRows, sourceValuesFromRows, stampCoercions, stitchFieldMaps, supportsQueryMode, toPrisma, toSql, validateBindNames, validateFieldMap, validateFieldMapSet, validateNarrowing, validateRule };
|
|
1061
|
+
export { AGGREGATE_OPERATORS, ALL_KINDS, ARRAY_OPERATOR_CATALOG, type AggregateMode, type AggregateRule, type All, type Any, type ArrayCatalogEntry, ArrayOperator, type ArrayRule, type Bridge, type BridgeCardinality, type BridgeDictionary, type BridgeEndpoint, type BuildOptions, COERCIBLE_KINDS, COMPILE_COERCED_KINDS, type CatalogEntry, type CheckOptions, type Condition, type CreateLensInput, DATE_OPERATOR_CATALOG, type DateConfig, type DateExpr, type DateInputOrExpr, type DateInputValue, type DateOffset, DateOperator, type DateRule, type DateRuleValue, EQUATABLE_KINDS, type EdgeExpr, type EngineGlobalsState, type EnumNarrowing, FIELD_OPERATOR_CATALOG, FieldKind, type FieldMap, type FieldMapEntry, type FieldMapSet, type FuzzyConfig, type GroupByStep, INTEGER_KINDS, INTERVAL_FIELDS, type IfThenElse, LOWER_BOUND_OPERATORS, type Lens, type LensNarrowing, type LensPathHop, type LensPathResolution, type Magnitude, type ModelDefaultNarrowing, type ModelNarrowing, NEGATED_COMPARISON_OPERATORS, NEGATED_OPERATORS, NEGATED_RANGE_OPERATORS, NEGATED_SINGLE_VALUE_OPERATORS, NO_VALUE_OPERATORS, NULLABLE_KINDS, NUMERIC_KINDS, type NarrowingDefaults, type NumberOffset, OFFSET_OPERATORS, ORDERABLE_KINDS, ORDERED_OPERATORS, Operator, type OrderBy, type OrderedRuleValue, PERIOD_UNITS, type PathProjection, type PeriodExpr, type PeriodUnit, type PrismaProvider, type PrismaStep, type PrismaWhere, type ProjectOptions, type ProjectedVisit, RANGE_OPERATORS, RELATIVE_UNITS, type RelativeUnit, type RelativeUnits, type RollingExpr, type Rule, type RuleDescription, type RuleLensCheck, type RuleLensViolation, type RuleScalar, type RuleSourceValues, RuleTarget, type RuleValue, SINGLE_VALUE_SHAPES, STRINGY_KINDS, type ScopeOutOfBounds, type ScopeRef, type ScopedRef, type SortDir, type SourceOption, type SourcePrismaQuery, type SourceQuery, type SourceRowShape, type SourceSpec, type SourceSqlQuery, type SourceValue, type SourceValues, type SqlResult, type StepRef, type StrictAggregateRule, type StrictAll, type StrictAny, type StrictArrayCountRule, type StrictArrayPredicateRule, type StrictArrayPresenceRule, type StrictArrayRule, type StrictCondition, type StrictContainsRule, type StrictDateComparisonRule, type StrictDateDayRule, type StrictDateRangeRule, type StrictDateRule, type StrictEqualityRule, type StrictIfThenElse, type StrictMembershipRule, type StrictOrderedComparisonRule, type StrictPatternRule, type StrictPresenceRule, type StrictRangeRule, type StrictRule, type StrictStringBoundaryRule, type TimeZoneConfig, type ToPrismaResult, UPPER_BOUND_OPERATORS, type ValidationIssue, type ValidationResult, ValueShape, type ValueSourceFields, type ValueSourceOf, WINDOW_OPERATORS, WINDOW_SELECTOR, type WeekStart, type WhereStep, type WindowFields, type WindowRuleType, WindowSupport, applyLens, assertValidRule, bindingNames, buildBridgeDictionary, check, checkRuleAgainstLens, createLens, describeRule, engineGlobals, executePrismaQueryPlan, exposedSurface, fuzzyContains, getAggregateOperators, getArrayOperators, getOperatorsForKind, getValueShape, getWindowSupport, isAggregateRangeOperator, isAggregateSingleOperator, isCalendarUnit, isOperatorSupportedForTarget, isRelativeUnit, lensRequiredBindings, maxFuzzyDistance, parseScopeRef, projectByPath, readBinding, requiredBindings, resolveBindings, resolveCaseInsensitive, resolveFuzzy, resolveLensBindings, resolveLensPath, resolveScopeRef, ruleSourceValues, sourceQueries, sourceValuesFromQueryRows, sourceValuesFromRows, stampCoercions, stitchFieldMaps, supportsQueryMode, toPrisma, toSql, validateBindNames, validateFieldMap, validateFieldMapSet, validateNarrowing, validateRule };
|