@inixiative/json-rules 3.12.2 → 3.13.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 +3 -0
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -2
- package/dist/index.d.ts +19 -2
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -460,6 +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`), never finer than the engine's `clock.finestUnit`. `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. |
|
|
463
464
|
|
|
464
465
|
A leaf may mark its bind optional: `{ field, operator, bind: 'region', bindOptional: true }`. An
|
|
465
466
|
unsupplied required bind is a caller bug — `check()` throws, and both compilers refuse a
|
|
@@ -653,6 +654,7 @@ null`.
|
|
|
653
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. |
|
|
654
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. |
|
|
655
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 `clockUnit()` reports (one of `CLOCK_UNITS`). A finer unit reads as this one, with no rounding: under `'hour'`, `{ ago: { minutes: 30 } }` reads `hour`. A caller whose finest tick is an hour sets it once at boot. |
|
|
656
658
|
|
|
657
659
|
```ts
|
|
658
660
|
import { engineGlobals } from '@inixiative/json-rules';
|
|
@@ -661,6 +663,7 @@ engineGlobals.set('string.caseInsensitive', true);
|
|
|
661
663
|
engineGlobals.get('string.caseInsensitive'); // true
|
|
662
664
|
engineGlobals.set('prismaOptions.datasource.provider', 'mysql');
|
|
663
665
|
engineGlobals.set('sql.dialect', SqlDialect.mysql); // what toWhereSql / toLensWhereSql write
|
|
666
|
+
engineGlobals.set('clock.finestUnit', 'hour'); // clockUnit reads minutes and seconds as hour
|
|
664
667
|
engineGlobals.reset(); // back to the defaults
|
|
665
668
|
|
|
666
669
|
// A scoped override: merged over the current state for the duration of a synchronous callback.
|