@inixiative/json-rules 3.7.0 → 3.9.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 +54 -9
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -5
- package/dist/index.d.ts +14 -5
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.cts
CHANGED
|
@@ -1089,6 +1089,9 @@ type LensWhereSqlOptions = {
|
|
|
1089
1089
|
* `'name'` at the root and `'<relation path>.<field>'` below it; a model default reads
|
|
1090
1090
|
* `'<Model>.<field>'`. */
|
|
1091
1091
|
columns: Record<string, string>;
|
|
1092
|
+
/** To-many relation path → the caller's SQL for its table, as `toWhereSql` reads it: by its path
|
|
1093
|
+
* from the lens model in a path `where`, `'<Model>.<relation>'` in a model default. */
|
|
1094
|
+
tables?: Record<string, string>;
|
|
1092
1095
|
};
|
|
1093
1096
|
/** A lens's `where`s as SQL, each where the lens wrote it. */
|
|
1094
1097
|
type LensWhereSql = {
|
|
@@ -1102,7 +1105,7 @@ type LensWhereSql = {
|
|
|
1102
1105
|
models: Record<string, string>;
|
|
1103
1106
|
}>;
|
|
1104
1107
|
};
|
|
1105
|
-
declare const toLensWhereSql: (lens: Lens | LensNarrowing, { columns }: LensWhereSqlOptions) => LensWhereSql;
|
|
1108
|
+
declare const toLensWhereSql: (lens: Lens | LensNarrowing, { columns, tables }: LensWhereSqlOptions) => LensWhereSql;
|
|
1106
1109
|
|
|
1107
1110
|
/** Gate a rule against a lens: every field and value-side ref resolves through it, and every
|
|
1108
1111
|
* operator, value and amount fits the field it reaches. */
|
|
@@ -1223,8 +1226,13 @@ type ToSqlOptions = CompileOptions & {
|
|
|
1223
1226
|
|
|
1224
1227
|
type WhereSqlOptions = {
|
|
1225
1228
|
/** Field path → the caller's SQL for that column, used as written. A to-one relation's
|
|
1226
|
-
* existence reads `'<relation>.<key>'
|
|
1229
|
+
* existence reads `'<relation>.<key>'`; a to-many relation's rows read
|
|
1230
|
+
* `'<relation>.<field>'`. */
|
|
1227
1231
|
columns: Record<string, string>;
|
|
1232
|
+
/** To-many relation path → the caller's SQL for its table, written after `FROM` as given, with
|
|
1233
|
+
* the alias its `columns` read (`{ affiliations: 'FanUserAffiliation AS a' }`). An array rule
|
|
1234
|
+
* on that relation reads it. */
|
|
1235
|
+
tables?: Record<string, string>;
|
|
1228
1236
|
/** The schema the condition reads: it types each literal by its column, finds a relation's key,
|
|
1229
1237
|
* and refuses what has no form here (a date, Json or list value, a bridge, a to-many hop). */
|
|
1230
1238
|
map: FieldMap | FieldMapSet;
|
|
@@ -1234,9 +1242,10 @@ type WhereSqlOptions = {
|
|
|
1234
1242
|
/**
|
|
1235
1243
|
* A condition as a SQL predicate in the engine's `sql.dialect`, with every value written inline
|
|
1236
1244
|
* and every field read from `columns` — no parameters to fill, no joins. Negations keep NULL rows,
|
|
1237
|
-
* as on every rail.
|
|
1238
|
-
*
|
|
1239
|
-
*
|
|
1245
|
+
* as on every rail. An array rule (any / all / none / empty / notEmpty) on a to-many relation of
|
|
1246
|
+
* the model is an `EXISTS` subquery on its table from `tables`. Throws for any other operator or
|
|
1247
|
+
* node, for binds, bridges, column-to-column `path`s, a Json value or existence, and a date or
|
|
1248
|
+
* list value (their existence is fine: `IS NULL` compares no value).
|
|
1240
1249
|
*/
|
|
1241
1250
|
declare const toWhereSql: (condition: Condition, options: WhereSqlOptions) => string;
|
|
1242
1251
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1089,6 +1089,9 @@ type LensWhereSqlOptions = {
|
|
|
1089
1089
|
* `'name'` at the root and `'<relation path>.<field>'` below it; a model default reads
|
|
1090
1090
|
* `'<Model>.<field>'`. */
|
|
1091
1091
|
columns: Record<string, string>;
|
|
1092
|
+
/** To-many relation path → the caller's SQL for its table, as `toWhereSql` reads it: by its path
|
|
1093
|
+
* from the lens model in a path `where`, `'<Model>.<relation>'` in a model default. */
|
|
1094
|
+
tables?: Record<string, string>;
|
|
1092
1095
|
};
|
|
1093
1096
|
/** A lens's `where`s as SQL, each where the lens wrote it. */
|
|
1094
1097
|
type LensWhereSql = {
|
|
@@ -1102,7 +1105,7 @@ type LensWhereSql = {
|
|
|
1102
1105
|
models: Record<string, string>;
|
|
1103
1106
|
}>;
|
|
1104
1107
|
};
|
|
1105
|
-
declare const toLensWhereSql: (lens: Lens | LensNarrowing, { columns }: LensWhereSqlOptions) => LensWhereSql;
|
|
1108
|
+
declare const toLensWhereSql: (lens: Lens | LensNarrowing, { columns, tables }: LensWhereSqlOptions) => LensWhereSql;
|
|
1106
1109
|
|
|
1107
1110
|
/** Gate a rule against a lens: every field and value-side ref resolves through it, and every
|
|
1108
1111
|
* operator, value and amount fits the field it reaches. */
|
|
@@ -1223,8 +1226,13 @@ type ToSqlOptions = CompileOptions & {
|
|
|
1223
1226
|
|
|
1224
1227
|
type WhereSqlOptions = {
|
|
1225
1228
|
/** Field path → the caller's SQL for that column, used as written. A to-one relation's
|
|
1226
|
-
* existence reads `'<relation>.<key>'
|
|
1229
|
+
* existence reads `'<relation>.<key>'`; a to-many relation's rows read
|
|
1230
|
+
* `'<relation>.<field>'`. */
|
|
1227
1231
|
columns: Record<string, string>;
|
|
1232
|
+
/** To-many relation path → the caller's SQL for its table, written after `FROM` as given, with
|
|
1233
|
+
* the alias its `columns` read (`{ affiliations: 'FanUserAffiliation AS a' }`). An array rule
|
|
1234
|
+
* on that relation reads it. */
|
|
1235
|
+
tables?: Record<string, string>;
|
|
1228
1236
|
/** The schema the condition reads: it types each literal by its column, finds a relation's key,
|
|
1229
1237
|
* and refuses what has no form here (a date, Json or list value, a bridge, a to-many hop). */
|
|
1230
1238
|
map: FieldMap | FieldMapSet;
|
|
@@ -1234,9 +1242,10 @@ type WhereSqlOptions = {
|
|
|
1234
1242
|
/**
|
|
1235
1243
|
* A condition as a SQL predicate in the engine's `sql.dialect`, with every value written inline
|
|
1236
1244
|
* and every field read from `columns` — no parameters to fill, no joins. Negations keep NULL rows,
|
|
1237
|
-
* as on every rail.
|
|
1238
|
-
*
|
|
1239
|
-
*
|
|
1245
|
+
* as on every rail. An array rule (any / all / none / empty / notEmpty) on a to-many relation of
|
|
1246
|
+
* the model is an `EXISTS` subquery on its table from `tables`. Throws for any other operator or
|
|
1247
|
+
* node, for binds, bridges, column-to-column `path`s, a Json value or existence, and a date or
|
|
1248
|
+
* list value (their existence is fine: `IS NULL` compares no value).
|
|
1240
1249
|
*/
|
|
1241
1250
|
declare const toWhereSql: (condition: Condition, options: WhereSqlOptions) => string;
|
|
1242
1251
|
|