@inixiative/json-rules 3.15.1 → 3.16.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 +51 -1
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -2
- package/dist/index.d.ts +13 -2
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1182,8 +1182,19 @@ type LensWhereSqlOptions = {
|
|
|
1182
1182
|
* `'<Model>.<field>'`. */
|
|
1183
1183
|
columns: Record<string, string>;
|
|
1184
1184
|
/** To-many relation path → the caller's SQL for its table, as `toWhereSql` reads it: by its path
|
|
1185
|
-
* from the lens model in a path `where`, `'<Model>.<relation>'` in a model default.
|
|
1185
|
+
* from the lens model in a path `where`, `'<Model>.<relation>'` in a model default. Not read with
|
|
1186
|
+
* `toMany: 'join'`. */
|
|
1186
1187
|
tables?: Record<string, string>;
|
|
1188
|
+
/** What an array rule on a to-many relation reads. `'subquery'` (the default): an `EXISTS` on its
|
|
1189
|
+
* table from `tables`, carrying its clamps. `'join'`: the row the caller's LEFT JOIN brings — the
|
|
1190
|
+
* caller joins each to-many relation the root's `where` reads (a relation the lens declares), ON
|
|
1191
|
+
* its keys AND `relations[path]` AND the related model's `mapDefaults` entry; a join the `where`
|
|
1192
|
+
* does not read only fans the rows out (count distinct), and a read of one the caller did not
|
|
1193
|
+
* join fails loudly (a missing column). Only the root's `where` reads one, with `notEmpty`
|
|
1194
|
+
* (`<key> IS NOT NULL`) or one `any` (`(<key> IS NOT NULL AND cond)`), and only when every clamp
|
|
1195
|
+
* in that ON sits in a layer above the `where`'s, and the related model's default (if any) is
|
|
1196
|
+
* needed on that join alone — not on the root, not on another joined relation. */
|
|
1197
|
+
toMany?: 'subquery' | 'join';
|
|
1187
1198
|
};
|
|
1188
1199
|
/** A lens's `where`s as SQL, each where the lens wrote it. */
|
|
1189
1200
|
type LensWhereSql = {
|
|
@@ -1197,7 +1208,7 @@ type LensWhereSql = {
|
|
|
1197
1208
|
models: Record<string, string>;
|
|
1198
1209
|
}>;
|
|
1199
1210
|
};
|
|
1200
|
-
declare const toLensWhereSql: (lens: Lens | LensNarrowing, { columns, tables }: LensWhereSqlOptions) => LensWhereSql;
|
|
1211
|
+
declare const toLensWhereSql: (lens: Lens | LensNarrowing, { columns, tables, toMany }: LensWhereSqlOptions) => LensWhereSql;
|
|
1201
1212
|
|
|
1202
1213
|
/** Gate a rule against a lens: every field and value-side ref resolves through it, and every
|
|
1203
1214
|
* operator, value and amount fits the field it reaches. */
|
package/dist/index.d.ts
CHANGED
|
@@ -1182,8 +1182,19 @@ type LensWhereSqlOptions = {
|
|
|
1182
1182
|
* `'<Model>.<field>'`. */
|
|
1183
1183
|
columns: Record<string, string>;
|
|
1184
1184
|
/** To-many relation path → the caller's SQL for its table, as `toWhereSql` reads it: by its path
|
|
1185
|
-
* from the lens model in a path `where`, `'<Model>.<relation>'` in a model default.
|
|
1185
|
+
* from the lens model in a path `where`, `'<Model>.<relation>'` in a model default. Not read with
|
|
1186
|
+
* `toMany: 'join'`. */
|
|
1186
1187
|
tables?: Record<string, string>;
|
|
1188
|
+
/** What an array rule on a to-many relation reads. `'subquery'` (the default): an `EXISTS` on its
|
|
1189
|
+
* table from `tables`, carrying its clamps. `'join'`: the row the caller's LEFT JOIN brings — the
|
|
1190
|
+
* caller joins each to-many relation the root's `where` reads (a relation the lens declares), ON
|
|
1191
|
+
* its keys AND `relations[path]` AND the related model's `mapDefaults` entry; a join the `where`
|
|
1192
|
+
* does not read only fans the rows out (count distinct), and a read of one the caller did not
|
|
1193
|
+
* join fails loudly (a missing column). Only the root's `where` reads one, with `notEmpty`
|
|
1194
|
+
* (`<key> IS NOT NULL`) or one `any` (`(<key> IS NOT NULL AND cond)`), and only when every clamp
|
|
1195
|
+
* in that ON sits in a layer above the `where`'s, and the related model's default (if any) is
|
|
1196
|
+
* needed on that join alone — not on the root, not on another joined relation. */
|
|
1197
|
+
toMany?: 'subquery' | 'join';
|
|
1187
1198
|
};
|
|
1188
1199
|
/** A lens's `where`s as SQL, each where the lens wrote it. */
|
|
1189
1200
|
type LensWhereSql = {
|
|
@@ -1197,7 +1208,7 @@ type LensWhereSql = {
|
|
|
1197
1208
|
models: Record<string, string>;
|
|
1198
1209
|
}>;
|
|
1199
1210
|
};
|
|
1200
|
-
declare const toLensWhereSql: (lens: Lens | LensNarrowing, { columns, tables }: LensWhereSqlOptions) => LensWhereSql;
|
|
1211
|
+
declare const toLensWhereSql: (lens: Lens | LensNarrowing, { columns, tables, toMany }: LensWhereSqlOptions) => LensWhereSql;
|
|
1201
1212
|
|
|
1202
1213
|
/** Gate a rule against a lens: every field and value-side ref resolves through it, and every
|
|
1203
1214
|
* operator, value and amount fits the field it reaches. */
|