@inixiative/json-rules 3.5.1 → 3.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -958,12 +958,17 @@ declare const toSourceQueries: (lensOrNarrowing: Lens | LensNarrowing, options?:
958
958
 
959
959
  /** Which executor produced the rows — the caller always knows; never guessed. */
960
960
  type SourceRowShape = 'prisma' | 'sql';
961
+ /** How the options come back: sorted by value (the default), or in the order each first appears
962
+ * in the rows — so a query that ranks its rows (most-held first) keeps its ranking. */
963
+ type SourceOptionOrder = 'value' | 'rows';
961
964
  /** `rowShape`: how the rows came back — nested Prisma rows (the default) or flat SQL rows.
962
965
  * `lens`: the lens the query was compiled from, required for a query with a `recheck` — it says
963
- * what each far side must hold. The rest is the clock and bindings the re-check runs with. */
966
+ * what each far side must hold. `order`: see `SourceOptionOrder`. The rest is the clock and
967
+ * bindings the re-check runs with. */
964
968
  type MaterializeSourceQueryOptions = CheckOptions & {
965
969
  rowShape?: SourceRowShape;
966
970
  lens?: Lens | LensNarrowing;
971
+ order?: SourceOptionOrder;
967
972
  };
968
973
  /**
969
974
  * Materialize one compiled `SourceQuery`'s fetched rows into its `SourceValues` —
@@ -1116,6 +1121,38 @@ declare const readScopeRef: <S>(ref: string, scopes: readonly S[]) => ScopedRef<
1116
1121
  */
1117
1122
  declare const executePrismaPlan: (plan: ToPrismaResult, prismaDelegate: Record<string, object>) => Promise<Record<string, unknown>>;
1118
1123
 
1124
+ /**
1125
+ * The two boolean constants and how Prisma reads them.
1126
+ *
1127
+ * `{}` is match-all only where Prisma treats an empty filter as "no constraint": the top
1128
+ * level, an AND arm, a relation filter (`some: {}`). Inside an OR Prisma DROPS it — `OR: [x, {}]`
1129
+ * is just `x` — and `NOT: {}` is not the negation of true. `{ OR: [] }` is the documented
1130
+ * match-nothing, and it holds at the top level, as an OR arm, under NOT and inside a relation
1131
+ * filter — but NOT as an arm of an AND list: Prisma drops it there and `AND: [x, { OR: [] }]`
1132
+ * is just `x` (measured on Prisma 7 + Postgres and Prisma 6 + MySQL).
1133
+ *
1134
+ * So the logical builders never nest a constant under OR or NOT; they fold it instead:
1135
+ * a `true` arm absorbs an OR, a `false` arm absorbs an AND, either drops out of the other,
1136
+ * and NOT of a constant is the other constant. The fold runs on compiled output, so it also
1137
+ * covers constants that arrive indirectly — `all: []`, `any: []`, `atLeast 0`, and the bridge
1138
+ * over-fetch sentinel (a bridge under `any` now over-fetches the disjunction instead of being
1139
+ * dropped by Prisma and under-fetching).
1140
+ *
1141
+ * Every arm is compiled exactly once, in order, BEFORE folding. Count operators push a
1142
+ * groupBy step into `state` as they compile, so an arm that then folds away leaves its step
1143
+ * behind — harmless (an unreferenced step is executed and ignored) and necessary: step refs
1144
+ * are positional, so nothing may be rebuilt or renumbered.
1145
+ */
1146
+ /** A consumer composing a compiled where with its own filters (a scope, a floor, a clamp) goes
1147
+ * through andWhere / orWhere, never a hand-written `AND: [...]` — the same fold, so a compiled
1148
+ * `false` still matches nothing. */
1149
+ declare const matchAll: () => PrismaWhere;
1150
+ declare const matchNothing: () => PrismaWhere;
1151
+ /** AND of arms: match-nothing absorbs, match-all drops, one arm stands alone. */
1152
+ declare const andWhere: (arms: PrismaWhere[]) => PrismaWhere;
1153
+ /** OR of arms: match-all absorbs, match-nothing drops, one arm stands alone. */
1154
+ declare const orWhere: (arms: PrismaWhere[]) => PrismaWhere;
1155
+
1119
1156
  /**
1120
1157
  * Compile a condition to a Prisma query plan: `steps`, any groupBy steps (counts and relation
1121
1158
  * aggregates, which need `{ map, model }` or `{ lens }`) and then the final `where`. With `lens`,
@@ -1158,4 +1195,4 @@ declare const toSql: (rule: Condition, compileOptions?: ToSqlOptions) => ToSqlRe
1158
1195
  */
1159
1196
  declare const orderRecords: <T>(items: readonly T[], orderBy: OrderBy) => T[];
1160
1197
 
1161
- export { ALL_KINDS, type AggregateMode, type AggregateRule, type All, type Any, ArrayOperator, type ArrayRule, type Bridge, type BridgeCardinality, type BridgeDictionary, type BridgeEndpoint, type CheckData, type CheckOptions, type CompileOptions, type Condition, type DateConfig, type DateExpr, type DateInputOrExpr, type DateInputValue, type DateOffset, DateOperator, type DateRule, type DateRuleValue, type EdgeExpr, type EngineGlobalsState, type EnumNarrowing, FieldKind, type FieldMap, type FieldMapEntry, type FieldMapSet, type FuzzyConfig, type GroupByStep, type IfThenElse, type Lens, type LensClamps, type LensNarrowing, type LensPathHop, type LensPathResolution, LensRefusal, type LensRelationSelect, type LensSelect, type LensSelectOptions, type LensValue, type ListBindingsOptions, type Magnitude, type MaterializeSourceQueryOptions, type ModelDefaultNarrowing, type ModelEntry, type ModelNarrowing, NUMERIC_KINDS, type NarrowingDefaults, type NumberOffset, 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 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, type SourcePrismaQuery, type SourceQuery, type SourceRowShape, type SourceSelect, type SourceSpec, type SourceSqlQuery, type SourceValues, type StepRef, type StoredLens, type StrictAggregateRule, type StrictAll, type StrictAny, type StrictArrayCountRule, type StrictArrayPredicateRule, type StrictArrayPresenceRule, type StrictArrayRule, type StrictCondition, type StrictContainsRule, type StrictDateComparisonRule, type StrictDateDayRule, type StrictDateRangeRule, type StrictDateRule, type StrictEqualityRule, type StrictIfThenElse, type StrictMembershipRule, type StrictOrderedComparisonRule, type StrictPatternRule, type StrictPresenceRule, type StrictRangeRule, type StrictRule, type StrictStringBoundaryRule, type TimeZoneConfig, type ToPrismaOptions, type ToPrismaResult, type ToSqlOptions, type ToSqlResult, UsageError, type ValidateRuleOptions, type ValidationIssue, type ValidationResult, ValueShape, type ValueSourceFields, type ValueSourceOf, type WeekStart, type WhereStep, type WindowFields, assertValidFieldMaps, assertValidNarrowing, assertValidRule, bindLens, bindRule, check, clampLens, coerceRule, composeLens, createLens, describeRule, describeRuleSources, engineGlobals, executePrismaPlan, getAggregateOperators, getArrayOperators, getLensRoot, getOperatorsForKind, getValueShape, indexBridges, lensVisit, listBindings, listLensBindings, materializeSourceQuery, materializeSources, narrowRule, orderRecords, parseScopeRef, projectLens, projectRows, readLensValue, readScopeRef, stitchFieldMaps, storeLens, toLensSelect, toPrisma, toSourceQueries, toSql, validateFieldMaps, validateNarrowing, validateRule, validateRuleInLens, walkLensPath };
1198
+ export { ALL_KINDS, type AggregateMode, type AggregateRule, type All, type Any, ArrayOperator, type ArrayRule, type Bridge, type BridgeCardinality, type BridgeDictionary, type BridgeEndpoint, type CheckData, type CheckOptions, type CompileOptions, type Condition, type DateConfig, type DateExpr, type DateInputOrExpr, type DateInputValue, type DateOffset, DateOperator, type DateRule, type DateRuleValue, type EdgeExpr, type EngineGlobalsState, type EnumNarrowing, FieldKind, type FieldMap, type FieldMapEntry, type FieldMapSet, type FuzzyConfig, type GroupByStep, type IfThenElse, type Lens, type LensClamps, type LensNarrowing, type LensPathHop, type LensPathResolution, LensRefusal, type LensRelationSelect, type LensSelect, type LensSelectOptions, type LensValue, type ListBindingsOptions, type Magnitude, type MaterializeSourceQueryOptions, type ModelDefaultNarrowing, type ModelEntry, type ModelNarrowing, NUMERIC_KINDS, type NarrowingDefaults, type NumberOffset, 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 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, type SourceOptionOrder, type SourcePrismaQuery, type SourceQuery, type SourceRowShape, type SourceSelect, type SourceSpec, type SourceSqlQuery, type SourceValues, type StepRef, type StoredLens, type StrictAggregateRule, type StrictAll, type StrictAny, type StrictArrayCountRule, type StrictArrayPredicateRule, type StrictArrayPresenceRule, type StrictArrayRule, type StrictCondition, type StrictContainsRule, type StrictDateComparisonRule, type StrictDateDayRule, type StrictDateRangeRule, type StrictDateRule, type StrictEqualityRule, type StrictIfThenElse, type StrictMembershipRule, type StrictOrderedComparisonRule, type StrictPatternRule, type StrictPresenceRule, type StrictRangeRule, type StrictRule, type StrictStringBoundaryRule, type TimeZoneConfig, type ToPrismaOptions, type ToPrismaResult, type ToSqlOptions, type ToSqlResult, UsageError, type ValidateRuleOptions, type ValidationIssue, type ValidationResult, ValueShape, type ValueSourceFields, type ValueSourceOf, type WeekStart, type WhereStep, type WindowFields, andWhere, assertValidFieldMaps, assertValidNarrowing, assertValidRule, bindLens, bindRule, check, clampLens, coerceRule, composeLens, createLens, describeRule, describeRuleSources, engineGlobals, executePrismaPlan, getAggregateOperators, getArrayOperators, getLensRoot, getOperatorsForKind, getValueShape, indexBridges, lensVisit, listBindings, listLensBindings, matchAll, matchNothing, materializeSourceQuery, materializeSources, narrowRule, orWhere, orderRecords, parseScopeRef, projectLens, projectRows, readLensValue, readScopeRef, stitchFieldMaps, storeLens, toLensSelect, toPrisma, toSourceQueries, toSql, validateFieldMaps, validateNarrowing, validateRule, validateRuleInLens, walkLensPath };
package/dist/index.d.ts CHANGED
@@ -958,12 +958,17 @@ declare const toSourceQueries: (lensOrNarrowing: Lens | LensNarrowing, options?:
958
958
 
959
959
  /** Which executor produced the rows — the caller always knows; never guessed. */
960
960
  type SourceRowShape = 'prisma' | 'sql';
961
+ /** How the options come back: sorted by value (the default), or in the order each first appears
962
+ * in the rows — so a query that ranks its rows (most-held first) keeps its ranking. */
963
+ type SourceOptionOrder = 'value' | 'rows';
961
964
  /** `rowShape`: how the rows came back — nested Prisma rows (the default) or flat SQL rows.
962
965
  * `lens`: the lens the query was compiled from, required for a query with a `recheck` — it says
963
- * what each far side must hold. The rest is the clock and bindings the re-check runs with. */
966
+ * what each far side must hold. `order`: see `SourceOptionOrder`. The rest is the clock and
967
+ * bindings the re-check runs with. */
964
968
  type MaterializeSourceQueryOptions = CheckOptions & {
965
969
  rowShape?: SourceRowShape;
966
970
  lens?: Lens | LensNarrowing;
971
+ order?: SourceOptionOrder;
967
972
  };
968
973
  /**
969
974
  * Materialize one compiled `SourceQuery`'s fetched rows into its `SourceValues` —
@@ -1116,6 +1121,38 @@ declare const readScopeRef: <S>(ref: string, scopes: readonly S[]) => ScopedRef<
1116
1121
  */
1117
1122
  declare const executePrismaPlan: (plan: ToPrismaResult, prismaDelegate: Record<string, object>) => Promise<Record<string, unknown>>;
1118
1123
 
1124
+ /**
1125
+ * The two boolean constants and how Prisma reads them.
1126
+ *
1127
+ * `{}` is match-all only where Prisma treats an empty filter as "no constraint": the top
1128
+ * level, an AND arm, a relation filter (`some: {}`). Inside an OR Prisma DROPS it — `OR: [x, {}]`
1129
+ * is just `x` — and `NOT: {}` is not the negation of true. `{ OR: [] }` is the documented
1130
+ * match-nothing, and it holds at the top level, as an OR arm, under NOT and inside a relation
1131
+ * filter — but NOT as an arm of an AND list: Prisma drops it there and `AND: [x, { OR: [] }]`
1132
+ * is just `x` (measured on Prisma 7 + Postgres and Prisma 6 + MySQL).
1133
+ *
1134
+ * So the logical builders never nest a constant under OR or NOT; they fold it instead:
1135
+ * a `true` arm absorbs an OR, a `false` arm absorbs an AND, either drops out of the other,
1136
+ * and NOT of a constant is the other constant. The fold runs on compiled output, so it also
1137
+ * covers constants that arrive indirectly — `all: []`, `any: []`, `atLeast 0`, and the bridge
1138
+ * over-fetch sentinel (a bridge under `any` now over-fetches the disjunction instead of being
1139
+ * dropped by Prisma and under-fetching).
1140
+ *
1141
+ * Every arm is compiled exactly once, in order, BEFORE folding. Count operators push a
1142
+ * groupBy step into `state` as they compile, so an arm that then folds away leaves its step
1143
+ * behind — harmless (an unreferenced step is executed and ignored) and necessary: step refs
1144
+ * are positional, so nothing may be rebuilt or renumbered.
1145
+ */
1146
+ /** A consumer composing a compiled where with its own filters (a scope, a floor, a clamp) goes
1147
+ * through andWhere / orWhere, never a hand-written `AND: [...]` — the same fold, so a compiled
1148
+ * `false` still matches nothing. */
1149
+ declare const matchAll: () => PrismaWhere;
1150
+ declare const matchNothing: () => PrismaWhere;
1151
+ /** AND of arms: match-nothing absorbs, match-all drops, one arm stands alone. */
1152
+ declare const andWhere: (arms: PrismaWhere[]) => PrismaWhere;
1153
+ /** OR of arms: match-all absorbs, match-nothing drops, one arm stands alone. */
1154
+ declare const orWhere: (arms: PrismaWhere[]) => PrismaWhere;
1155
+
1119
1156
  /**
1120
1157
  * Compile a condition to a Prisma query plan: `steps`, any groupBy steps (counts and relation
1121
1158
  * aggregates, which need `{ map, model }` or `{ lens }`) and then the final `where`. With `lens`,
@@ -1158,4 +1195,4 @@ declare const toSql: (rule: Condition, compileOptions?: ToSqlOptions) => ToSqlRe
1158
1195
  */
1159
1196
  declare const orderRecords: <T>(items: readonly T[], orderBy: OrderBy) => T[];
1160
1197
 
1161
- export { ALL_KINDS, type AggregateMode, type AggregateRule, type All, type Any, ArrayOperator, type ArrayRule, type Bridge, type BridgeCardinality, type BridgeDictionary, type BridgeEndpoint, type CheckData, type CheckOptions, type CompileOptions, type Condition, type DateConfig, type DateExpr, type DateInputOrExpr, type DateInputValue, type DateOffset, DateOperator, type DateRule, type DateRuleValue, type EdgeExpr, type EngineGlobalsState, type EnumNarrowing, FieldKind, type FieldMap, type FieldMapEntry, type FieldMapSet, type FuzzyConfig, type GroupByStep, type IfThenElse, type Lens, type LensClamps, type LensNarrowing, type LensPathHop, type LensPathResolution, LensRefusal, type LensRelationSelect, type LensSelect, type LensSelectOptions, type LensValue, type ListBindingsOptions, type Magnitude, type MaterializeSourceQueryOptions, type ModelDefaultNarrowing, type ModelEntry, type ModelNarrowing, NUMERIC_KINDS, type NarrowingDefaults, type NumberOffset, 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 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, type SourcePrismaQuery, type SourceQuery, type SourceRowShape, type SourceSelect, type SourceSpec, type SourceSqlQuery, type SourceValues, type StepRef, type StoredLens, type StrictAggregateRule, type StrictAll, type StrictAny, type StrictArrayCountRule, type StrictArrayPredicateRule, type StrictArrayPresenceRule, type StrictArrayRule, type StrictCondition, type StrictContainsRule, type StrictDateComparisonRule, type StrictDateDayRule, type StrictDateRangeRule, type StrictDateRule, type StrictEqualityRule, type StrictIfThenElse, type StrictMembershipRule, type StrictOrderedComparisonRule, type StrictPatternRule, type StrictPresenceRule, type StrictRangeRule, type StrictRule, type StrictStringBoundaryRule, type TimeZoneConfig, type ToPrismaOptions, type ToPrismaResult, type ToSqlOptions, type ToSqlResult, UsageError, type ValidateRuleOptions, type ValidationIssue, type ValidationResult, ValueShape, type ValueSourceFields, type ValueSourceOf, type WeekStart, type WhereStep, type WindowFields, assertValidFieldMaps, assertValidNarrowing, assertValidRule, bindLens, bindRule, check, clampLens, coerceRule, composeLens, createLens, describeRule, describeRuleSources, engineGlobals, executePrismaPlan, getAggregateOperators, getArrayOperators, getLensRoot, getOperatorsForKind, getValueShape, indexBridges, lensVisit, listBindings, listLensBindings, materializeSourceQuery, materializeSources, narrowRule, orderRecords, parseScopeRef, projectLens, projectRows, readLensValue, readScopeRef, stitchFieldMaps, storeLens, toLensSelect, toPrisma, toSourceQueries, toSql, validateFieldMaps, validateNarrowing, validateRule, validateRuleInLens, walkLensPath };
1198
+ export { ALL_KINDS, type AggregateMode, type AggregateRule, type All, type Any, ArrayOperator, type ArrayRule, type Bridge, type BridgeCardinality, type BridgeDictionary, type BridgeEndpoint, type CheckData, type CheckOptions, type CompileOptions, type Condition, type DateConfig, type DateExpr, type DateInputOrExpr, type DateInputValue, type DateOffset, DateOperator, type DateRule, type DateRuleValue, type EdgeExpr, type EngineGlobalsState, type EnumNarrowing, FieldKind, type FieldMap, type FieldMapEntry, type FieldMapSet, type FuzzyConfig, type GroupByStep, type IfThenElse, type Lens, type LensClamps, type LensNarrowing, type LensPathHop, type LensPathResolution, LensRefusal, type LensRelationSelect, type LensSelect, type LensSelectOptions, type LensValue, type ListBindingsOptions, type Magnitude, type MaterializeSourceQueryOptions, type ModelDefaultNarrowing, type ModelEntry, type ModelNarrowing, NUMERIC_KINDS, type NarrowingDefaults, type NumberOffset, 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 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, type SourceOptionOrder, type SourcePrismaQuery, type SourceQuery, type SourceRowShape, type SourceSelect, type SourceSpec, type SourceSqlQuery, type SourceValues, type StepRef, type StoredLens, type StrictAggregateRule, type StrictAll, type StrictAny, type StrictArrayCountRule, type StrictArrayPredicateRule, type StrictArrayPresenceRule, type StrictArrayRule, type StrictCondition, type StrictContainsRule, type StrictDateComparisonRule, type StrictDateDayRule, type StrictDateRangeRule, type StrictDateRule, type StrictEqualityRule, type StrictIfThenElse, type StrictMembershipRule, type StrictOrderedComparisonRule, type StrictPatternRule, type StrictPresenceRule, type StrictRangeRule, type StrictRule, type StrictStringBoundaryRule, type TimeZoneConfig, type ToPrismaOptions, type ToPrismaResult, type ToSqlOptions, type ToSqlResult, UsageError, type ValidateRuleOptions, type ValidationIssue, type ValidationResult, ValueShape, type ValueSourceFields, type ValueSourceOf, type WeekStart, type WhereStep, type WindowFields, andWhere, assertValidFieldMaps, assertValidNarrowing, assertValidRule, bindLens, bindRule, check, clampLens, coerceRule, composeLens, createLens, describeRule, describeRuleSources, engineGlobals, executePrismaPlan, getAggregateOperators, getArrayOperators, getLensRoot, getOperatorsForKind, getValueShape, indexBridges, lensVisit, listBindings, listLensBindings, matchAll, matchNothing, materializeSourceQuery, materializeSources, narrowRule, orWhere, orderRecords, parseScopeRef, projectLens, projectRows, readLensValue, readScopeRef, stitchFieldMaps, storeLens, toLensSelect, toPrisma, toSourceQueries, toSql, validateFieldMaps, validateNarrowing, validateRule, validateRuleInLens, walkLensPath };