@inixiative/json-rules 3.4.0 → 3.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -899,17 +899,27 @@ type SourceQuery = {
899
899
  field: string;
900
900
  /** Co-selected as each value's display label (from a SourceSpec's `label`): a sibling
901
901
  * column, or a dotted to-one path like a groupBy axis — then selected nested in prisma
902
- * and aliased `__label` in sql. */
902
+ * and aliased `__label` in sql. Across a bridge it is not selected: it is read from the far side
903
+ * the caller loads onto each candidate row. */
903
904
  label?: string;
904
905
  /** Option-partition axes (from a SourceSpec's `groupBy`, normalized); each axis
905
- * column is selected nested in prisma and aliased `__group_i` in sql. */
906
+ * column is selected nested in prisma and aliased `__group_i` in sql — save one across a
907
+ * bridge, read from the far side as a label across one is. */
906
908
  groupBy?: string[];
907
909
  composedWhere: Condition;
908
- /** Null, with `sql.sql` null and `sql.error` saying why, when the composed where crosses a
909
- * bridge: a database holds one side of it only, so no query offers the right set — materialize
910
- * it with `materializeSources` over rows that hold both sides. */
911
- prisma: SourcePrismaQuery | null;
910
+ prisma: SourcePrismaQuery;
912
911
  sql: SourceSqlQuery;
912
+ /** Present when the source reads across a bridge (its where, a grant carried across one, its
913
+ * label or an axis); absent otherwise. **If `recheck` is present, the query's rows are
914
+ * candidates, not options:** a database holds one side of a bridge, so the query folds what
915
+ * reads across it to TRUE and over-fetches — it never misses an option, but may return more.
916
+ * `recheck` is the condition the database couldn't decide (the conjuncts of `composedWhere` that
917
+ * read across a bridge; `true` when only the label or an axis does). The query selects the local
918
+ * columns `recheck` reads and each bridge's local `on` key; load the far side onto each candidate
919
+ * row under its bridge field (the `indexBridges` shape) and pass the rows to
920
+ * `materializeSourceQuery(query, rows, { lens })`, which re-checks them and reads the label and
921
+ * axes across the bridge from the far side. */
922
+ recheck?: Condition;
913
923
  };
914
924
  /** What a source query's compile reads besides the lens: the clock, as the compilers take it. */
915
925
  type SourceQueryOptions = DateConfig;
@@ -922,15 +932,19 @@ type SourceQueryOptions = DateConfig;
922
932
  * its layer on. The app runs these (with its own client) to materialize each field's
923
933
  * option set — feed the fetched rows to `materializeSourceQuery`. `options` is the clock a
924
934
  * relative date in the where compiles with (`now` required for one, as for any compile). A
925
- * where across a bridge has no query (`prisma` null; see `SourceQuery`).
935
+ * source that reads across a bridge gets an over-fetching query and a `recheck` (see
936
+ * `SourceQuery`): its rows are candidates, not options.
926
937
  */
927
938
  declare const toSourceQueries: (lensOrNarrowing: Lens | LensNarrowing, options?: SourceQueryOptions) => SourceQuery[];
928
939
 
929
940
  /** Which executor produced the rows — the caller always knows; never guessed. */
930
941
  type SourceRowShape = 'prisma' | 'sql';
931
- /** `rowShape`: how the rows came back — nested Prisma rows (the default) or flat SQL rows. */
932
- type MaterializeSourceQueryOptions = {
942
+ /** `rowShape`: how the rows came back — nested Prisma rows (the default) or flat SQL rows.
943
+ * `lens`: the lens the query was compiled from, required for a query with a `recheck` — it says
944
+ * what each far side must hold. The rest is the clock and bindings the re-check runs with. */
945
+ type MaterializeSourceQueryOptions = CheckOptions & {
933
946
  rowShape?: SourceRowShape;
947
+ lens?: Lens | LensNarrowing;
934
948
  };
935
949
  /**
936
950
  * Materialize one compiled `SourceQuery`'s fetched rows into its `SourceValues` —
@@ -939,6 +953,12 @@ type MaterializeSourceQueryOptions = {
939
953
  * (and a dotted `label`) as related objects; sql rows carry them flat under the
940
954
  * statement's `__group_i` / `__label` aliases. Grouped queries fetch without
941
955
  * DISTINCT, so dedup per (groups, value) happens here.
956
+ *
957
+ * A query with a `recheck` (a source across a bridge) returned candidates: each row must hold the
958
+ * far side inline under its bridge field — one row or a list as the bridge names it, with every
959
+ * key the re-check, the label and the axes read across it — or this throws a `UsageError` rather
960
+ * than offer a wrong set. A candidate offers its value only if `check(recheck, row, options)`
961
+ * holds; a label or axis across the bridge is read from the far side, in either row shape.
942
962
  */
943
963
  declare const materializeSourceQuery: (query: SourceQuery, rows: readonly Row[], opts?: MaterializeSourceQueryOptions) => SourceValues;
944
964
 
@@ -955,10 +975,9 @@ declare const materializeSourceQuery: (query: SourceQuery, rows: readonly Row[],
955
975
  * `bindings`), so it offers what the database does. Scalar-list fields contribute one option per
956
976
  * element, a value takes its least label (a sibling column, or a dotted to-one path read through
957
977
  * the nested rows), and sorting is numeric-aware in a fixed locale. Feed the result to
958
- * `projectLens` as `{ sourceValues }`. A source across a bridge is materialized here alone, from
959
- * rows that hold the far side inline under its bridge field (the fetch selects no bridge); a
960
- * `from: 'mapDefaults'` source throws unless it crosses one: a fetched collection can't hold
961
- * unlinked rows.
978
+ * `projectLens` as `{ sourceValues }`. A source across a bridge is materialized from rows that
979
+ * hold the far side inline under its bridge field (the fetch selects no bridge); a
980
+ * `from: 'mapDefaults'` source throws: a fetched collection can't hold unlinked rows — query it.
962
981
  */
963
982
  declare const materializeSources: (lensOrNarrowing: Lens | LensNarrowing, rows: readonly Row[], options?: CheckOptions) => SourceValues[];
964
983
 
package/dist/index.d.ts CHANGED
@@ -899,17 +899,27 @@ type SourceQuery = {
899
899
  field: string;
900
900
  /** Co-selected as each value's display label (from a SourceSpec's `label`): a sibling
901
901
  * column, or a dotted to-one path like a groupBy axis — then selected nested in prisma
902
- * and aliased `__label` in sql. */
902
+ * and aliased `__label` in sql. Across a bridge it is not selected: it is read from the far side
903
+ * the caller loads onto each candidate row. */
903
904
  label?: string;
904
905
  /** Option-partition axes (from a SourceSpec's `groupBy`, normalized); each axis
905
- * column is selected nested in prisma and aliased `__group_i` in sql. */
906
+ * column is selected nested in prisma and aliased `__group_i` in sql — save one across a
907
+ * bridge, read from the far side as a label across one is. */
906
908
  groupBy?: string[];
907
909
  composedWhere: Condition;
908
- /** Null, with `sql.sql` null and `sql.error` saying why, when the composed where crosses a
909
- * bridge: a database holds one side of it only, so no query offers the right set — materialize
910
- * it with `materializeSources` over rows that hold both sides. */
911
- prisma: SourcePrismaQuery | null;
910
+ prisma: SourcePrismaQuery;
912
911
  sql: SourceSqlQuery;
912
+ /** Present when the source reads across a bridge (its where, a grant carried across one, its
913
+ * label or an axis); absent otherwise. **If `recheck` is present, the query's rows are
914
+ * candidates, not options:** a database holds one side of a bridge, so the query folds what
915
+ * reads across it to TRUE and over-fetches — it never misses an option, but may return more.
916
+ * `recheck` is the condition the database couldn't decide (the conjuncts of `composedWhere` that
917
+ * read across a bridge; `true` when only the label or an axis does). The query selects the local
918
+ * columns `recheck` reads and each bridge's local `on` key; load the far side onto each candidate
919
+ * row under its bridge field (the `indexBridges` shape) and pass the rows to
920
+ * `materializeSourceQuery(query, rows, { lens })`, which re-checks them and reads the label and
921
+ * axes across the bridge from the far side. */
922
+ recheck?: Condition;
913
923
  };
914
924
  /** What a source query's compile reads besides the lens: the clock, as the compilers take it. */
915
925
  type SourceQueryOptions = DateConfig;
@@ -922,15 +932,19 @@ type SourceQueryOptions = DateConfig;
922
932
  * its layer on. The app runs these (with its own client) to materialize each field's
923
933
  * option set — feed the fetched rows to `materializeSourceQuery`. `options` is the clock a
924
934
  * relative date in the where compiles with (`now` required for one, as for any compile). A
925
- * where across a bridge has no query (`prisma` null; see `SourceQuery`).
935
+ * source that reads across a bridge gets an over-fetching query and a `recheck` (see
936
+ * `SourceQuery`): its rows are candidates, not options.
926
937
  */
927
938
  declare const toSourceQueries: (lensOrNarrowing: Lens | LensNarrowing, options?: SourceQueryOptions) => SourceQuery[];
928
939
 
929
940
  /** Which executor produced the rows — the caller always knows; never guessed. */
930
941
  type SourceRowShape = 'prisma' | 'sql';
931
- /** `rowShape`: how the rows came back — nested Prisma rows (the default) or flat SQL rows. */
932
- type MaterializeSourceQueryOptions = {
942
+ /** `rowShape`: how the rows came back — nested Prisma rows (the default) or flat SQL rows.
943
+ * `lens`: the lens the query was compiled from, required for a query with a `recheck` — it says
944
+ * what each far side must hold. The rest is the clock and bindings the re-check runs with. */
945
+ type MaterializeSourceQueryOptions = CheckOptions & {
933
946
  rowShape?: SourceRowShape;
947
+ lens?: Lens | LensNarrowing;
934
948
  };
935
949
  /**
936
950
  * Materialize one compiled `SourceQuery`'s fetched rows into its `SourceValues` —
@@ -939,6 +953,12 @@ type MaterializeSourceQueryOptions = {
939
953
  * (and a dotted `label`) as related objects; sql rows carry them flat under the
940
954
  * statement's `__group_i` / `__label` aliases. Grouped queries fetch without
941
955
  * DISTINCT, so dedup per (groups, value) happens here.
956
+ *
957
+ * A query with a `recheck` (a source across a bridge) returned candidates: each row must hold the
958
+ * far side inline under its bridge field — one row or a list as the bridge names it, with every
959
+ * key the re-check, the label and the axes read across it — or this throws a `UsageError` rather
960
+ * than offer a wrong set. A candidate offers its value only if `check(recheck, row, options)`
961
+ * holds; a label or axis across the bridge is read from the far side, in either row shape.
942
962
  */
943
963
  declare const materializeSourceQuery: (query: SourceQuery, rows: readonly Row[], opts?: MaterializeSourceQueryOptions) => SourceValues;
944
964
 
@@ -955,10 +975,9 @@ declare const materializeSourceQuery: (query: SourceQuery, rows: readonly Row[],
955
975
  * `bindings`), so it offers what the database does. Scalar-list fields contribute one option per
956
976
  * element, a value takes its least label (a sibling column, or a dotted to-one path read through
957
977
  * the nested rows), and sorting is numeric-aware in a fixed locale. Feed the result to
958
- * `projectLens` as `{ sourceValues }`. A source across a bridge is materialized here alone, from
959
- * rows that hold the far side inline under its bridge field (the fetch selects no bridge); a
960
- * `from: 'mapDefaults'` source throws unless it crosses one: a fetched collection can't hold
961
- * unlinked rows.
978
+ * `projectLens` as `{ sourceValues }`. A source across a bridge is materialized from rows that
979
+ * hold the far side inline under its bridge field (the fetch selects no bridge); a
980
+ * `from: 'mapDefaults'` source throws: a fetched collection can't hold unlinked rows — query it.
962
981
  */
963
982
  declare const materializeSources: (lensOrNarrowing: Lens | LensNarrowing, rows: readonly Row[], options?: CheckOptions) => SourceValues[];
964
983