@inixiative/json-rules 3.13.0 → 3.15.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 +4 -4
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +76 -12
- package/dist/index.d.ts +76 -12
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -460,7 +460,7 @@ format grows a node type, and it goes blind silently.
|
|
|
460
460
|
| `listBindings(rule, { required: true })` | Names a bindings map must cover — every `{ bind }` token not marked `bindOptional`, sorted. A name optional at one leaf and required at another is required. |
|
|
461
461
|
| `listBindings(rule)` | Every `{ bind }` name in the tree, optional or not, sorted — what a lens declares. |
|
|
462
462
|
| `bindRule(rule, bindings)` | Substitutes covered binds with their values, leaving uncovered tokens in place (partial resolution). |
|
|
463
|
-
| `clockUnit(rule)` | The finest clock unit the rule's answer can change by while its data stays the same: the smallest unit any relative date in the tree names (`{ ago: { hours: 2 } }` → `hour`, `{ this: 'week' }` → `week`, `isoWeek` → `week`), one of `CLOCK_UNITS` (`second` … `year`)
|
|
463
|
+
| `clockUnit(rule)` | The finest clock unit the rule's answer can change by while its data stays the same: the smallest unit any relative date in the tree names (`{ ago: { hours: 2 } }` → `hour`, `{ this: 'week' }` → `week`, `isoWeek` → `week`), one of `CLOCK_UNITS` (`second` … `year`); throws on a unit finer than the engine's `clock.finestUnit`, as evaluating the rule does. `null` when it reads no clock: absolute dates, column compares and their offsets, weekday lists. A caller re-evaluates a stored rule on that tick instead of guessing from its JSON. |
|
|
464
464
|
|
|
465
465
|
A leaf may mark its bind optional: `{ field, operator, bind: 'region', bindOptional: true }`. An
|
|
466
466
|
unsupplied required bind is a caller bug — `check()` throws, and both compilers refuse a
|
|
@@ -646,7 +646,7 @@ null`.
|
|
|
646
646
|
|
|
647
647
|
## Engine Globals
|
|
648
648
|
|
|
649
|
-
`engineGlobals` holds process-wide defaults. Keys are dotted paths into one state object.
|
|
649
|
+
`engineGlobals` holds process-wide defaults. Keys are dotted paths into one state object, and `set` / `get` are typed per path (`EngineGlobalPath`, `EngineGlobalValues`): each path takes only its own values.
|
|
650
650
|
|
|
651
651
|
| Key | Default | Governs |
|
|
652
652
|
| --- | --- | --- |
|
|
@@ -654,7 +654,7 @@ null`.
|
|
|
654
654
|
| `string.fuzzy` | `false` | Default for a rule's `fuzzy` (`true` or a `FuzzyConfig` `{ maxDistance?, maxRatio? }`): typo-tolerant `contains` / `notContains` on strings. A rule's own flag wins. The compilers have no fuzzy form: they refuse `contains` / `notContains` whenever fuzzy is on, by the rule or by this default. |
|
|
655
655
|
| `prismaOptions.datasource.provider` | `'postgresql'` | The Prisma connector. `toPrisma()` emits `mode: 'insensitive'` only for `postgresql`, `cockroachdb` and `mongodb`; the others are case-insensitive by collation and reject it. `toPrisma(rule, { datasource: { provider } })` overrides it per call. |
|
|
656
656
|
| `prismaOptions.anyNull` | your `@prisma/client`'s | Prisma's `AnyNull` for Json null checks (see above); set it only to use another client's. |
|
|
657
|
-
| `clock.finestUnit` | `'second'` | The finest unit
|
|
657
|
+
| `clock.finestUnit` | `'second'` | The finest clock unit a rule may read: one of `CLOCK_UNITS`, or its plural (`'hours'` reads as `'hour'`); anything else throws when a rule reads the clock. A comparison that reads the clock (its value, or an end of its range, is a relative date) fails when any unit it names is finer, the offset moving it included: `check`, `toPrisma` and `toSql` throw and `validateRule` reports `clock_unit_below_floor`. The rule decides as written, so an amount read from the row or a binding (`{ minutes: { path } }`, a null one too) fails the same, and a bound whole expression is held to it once bound. Under `'hour'`, `{ ago: { minutes: 30 } }`, `{ this: 'minute' }` and `{ ago: { days: 1 } }` offset by `{ ago: { minutes: 5 } }` fail. A comparison that reads no clock (an absolute date, a column compare) is never refused, offset or not. A caller whose finest tick is an hour sets it once at boot. |
|
|
658
658
|
|
|
659
659
|
```ts
|
|
660
660
|
import { engineGlobals } from '@inixiative/json-rules';
|
|
@@ -663,7 +663,7 @@ engineGlobals.set('string.caseInsensitive', true);
|
|
|
663
663
|
engineGlobals.get('string.caseInsensitive'); // true
|
|
664
664
|
engineGlobals.set('prismaOptions.datasource.provider', 'mysql');
|
|
665
665
|
engineGlobals.set('sql.dialect', SqlDialect.mysql); // what toWhereSql / toLensWhereSql write
|
|
666
|
-
engineGlobals.set('clock.finestUnit', 'hour'); //
|
|
666
|
+
engineGlobals.set('clock.finestUnit', 'hour'); // a rule reading minutes or seconds fails to evaluate
|
|
667
667
|
engineGlobals.reset(); // back to the defaults
|
|
668
668
|
|
|
669
669
|
// A scoped override: merged over the current state for the duration of a synchronous callback.
|