@orkestrel/contract 0.0.9 → 0.0.11
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 +7 -3
- package/dist/src/core/index.cjs +7953 -2804
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +2512 -334
- package/dist/src/core/index.d.ts +2512 -334
- package/dist/src/core/index.js +7904 -2804
- package/dist/src/core/index.js.map +1 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
# @orkestrel/contract
|
|
2
2
|
|
|
3
3
|
The zero-dependency contract toolkit — runtime type guards, guard combinators, coerce-and-extract
|
|
4
|
-
parsers, and a shape DSL that compiles once into a guard, parser,
|
|
5
|
-
generator
|
|
4
|
+
parsers, and a shape DSL that compiles once into a JSON Schema, a guard, a parser, a strict audit, a
|
|
5
|
+
parse report, and a generator, every one of them derived from a single owned snapshot of the
|
|
6
|
+
declaration. The foundation package of the `@orkestrel` line.
|
|
6
7
|
|
|
7
8
|
## Install
|
|
8
9
|
|
|
@@ -36,6 +37,7 @@ const user = createContract(
|
|
|
36
37
|
user.is({ name: 'Ada', age: 36 }) // true
|
|
37
38
|
user.parse({ name: 'Ada', age: '36' }) // { name: 'Ada', age: 36 } — coerces, or undefined
|
|
38
39
|
user.explain({ name: '', age: 36 }) // [{ reason: 'constraint', path: ['name'], constraint: 'min', limit: 1, … }]
|
|
40
|
+
user.audit({ name: 'Ada', age: 36, extra: true }) // [{ reason: 'extra', path: ['extra'] }] — parse drops it, audit names it
|
|
39
41
|
user.schema // the owned, deeply frozen compiled JSON Schema
|
|
40
42
|
user.generate(seededRandom(42)) // reproducible seed data; omit the arg for a wall-clock-seeded source
|
|
41
43
|
```
|
|
@@ -43,7 +45,9 @@ user.generate(seededRandom(42)) // reproducible seed data; omit the arg for a wa
|
|
|
43
45
|
## Guide
|
|
44
46
|
|
|
45
47
|
For the full surface — guards, combinators, parsers, the JSON boundary, and the shape DSL — see
|
|
46
|
-
[`guides/src/contract.md`](guides/src/contract.md).
|
|
48
|
+
[`guides/src/contract.md`](https://github.com/orkestrel/contract/blob/main/guides/src/contract.md).
|
|
49
|
+
The guide is not published in the npm tarball (`files` ships `dist/src` and this README), so the
|
|
50
|
+
link is absolute on purpose: a relative one resolves in the repository and is dead in the package.
|
|
47
51
|
|
|
48
52
|
## Package
|
|
49
53
|
|