@niscorp/tide 0.1.4 → 0.1.5
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/CHANGELOG.md +35 -0
- package/DESIGN.md +1 -1
- package/DOCS.md +1 -1
- package/README.md +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# @niscorp/tide
|
|
2
2
|
|
|
3
|
+
## 0.1.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f834f3f: `evaluate` checks a config object once and only evaluates it after that; `prismTransform` is gone. **Breaking.**
|
|
8
|
+
|
|
9
|
+
BREAKING — approved by moccadroid, 2026-10-09: replace `prismTransform` with `evaluate` (`transform: evaluate`), and pass limits as `{ limits: … }`.
|
|
10
|
+
|
|
11
|
+
Prism had three ways to run a config, and the one a host was told to hand to its seam (`prismTransform`) was the one that reported worst, while the hosts on a hot path each wrapped `evaluate`, which checked the config on every call. There are two now, with one job each.
|
|
12
|
+
|
|
13
|
+
**`evaluate(config, source, options?)`** — for a config a program holds.
|
|
14
|
+
- The first time it is handed a config object it checks it and keeps its tree; the second time it prepares the tree as `compile` would; from then on a call only evaluates. Four fields picked and renamed, the same config object again: 3.5 µs before, 0.4 µs now. A nested choice on two fields: 18 µs before, 0.7 µs now. A config that is a new object on every call costs what it did.
|
|
15
|
+
- It is kept **by the object**: a config changed in place after its first call is not read again. Hand over a new object.
|
|
16
|
+
- Both arguments are `unknown`, so it is what a host's transform seam takes: `createTide({ transform: evaluate })`, `createUpgrader(grammars, { transform: evaluate })`.
|
|
17
|
+
- The third argument is `{ limits?, check? }`. Limits were the third argument themselves: `evaluate(config, source, { maxSteps: 100 })` is now `evaluate(config, source, { limits: { maxSteps: 100 } })`.
|
|
18
|
+
- `check: 'always'` is for writing a config, for tests and for tools: nothing is kept, the config is checked on every call, and the source must be plain JSON (a source holding `undefined`, a function, a `Date` or a non-finite number is refused with `E_TYPE`).
|
|
19
|
+
- An invalid config is a `PrismError` (`E_SCHEMA`) naming the part that is wrong, however deep the config. `prismTransform` threw zod's own error, and a `RangeError` for a config nested far past the limit.
|
|
20
|
+
|
|
21
|
+
`evaluateSafe` takes the same arguments.
|
|
22
|
+
|
|
23
|
+
**`compile` and `execute`** — for a config that is stored. Unchanged.
|
|
24
|
+
|
|
25
|
+
**`prismTransform` is removed**, from `@niscorp/prism` and from `@niscorp/prism/migrations`. What it added over `evaluate` was a check that the source is plain JSON; that check is now `check: 'always'`, and a seam's source is taken as it is.
|
|
26
|
+
|
|
27
|
+
**moss, nova, vex, loom, nisc, create-nisc and the cli move with it.** Each has Prism as a peer or a dependency, or has one of those that do, and a Prism at 0.3 is outside the range their last versions accept: an app takes them together. Nothing in vex, loom or the cli changed beyond that range.
|
|
28
|
+
|
|
29
|
+
moss's shell and nova's `$prism` binding called `evaluate` on every use and so paid the check each time: an endpoint's request and response under moss, and a `$prism` value on each draw and for each row of a list, are 8 to 45 times faster for the configs measured. tide's and strata's documentation name `evaluate` where they named `prismTransform`.
|
|
30
|
+
|
|
31
|
+
**What to change**
|
|
32
|
+
- `import { prismTransform } from '@niscorp/prism'` or `'@niscorp/prism/migrations'` → `import { evaluate } from '@niscorp/prism'`, and `transform: prismTransform` → `transform: evaluate`. Every app made by `create-nisc` has this in `src/dev/strata.ts`; the app's typecheck and `npm run strata` both stop on that line until it is changed.
|
|
33
|
+
- A third argument of limits becomes `{ limits: … }`.
|
|
34
|
+
- A wrapper that parsed the config before calling `evaluate` (`evaluate(ConfigSchema.parse(config), …)`) makes a new object on every call and so is checked on every call: hand `evaluate` the config itself.
|
|
35
|
+
- Code that changes a config object in place and evaluates it again must hand over a new object, or pass `{ check: 'always' }`.
|
|
36
|
+
- A host that relied on `prismTransform` refusing a source that is not plain JSON checks it itself, or passes `{ check: 'always' }`.
|
|
37
|
+
|
|
3
38
|
## 0.1.4
|
|
4
39
|
|
|
5
40
|
### Patch Changes
|
package/DESIGN.md
CHANGED
|
@@ -841,7 +841,7 @@ destructuring it produced a transaction that failed inside the library.
|
|
|
841
841
|
```ts
|
|
842
842
|
const tide = createTide({
|
|
843
843
|
store: createMemoryStore(), // or your own, held to STORE_CONTRACT
|
|
844
|
-
transform:
|
|
844
|
+
transform: evaluate, // prism, or your own
|
|
845
845
|
select: async function* (q) { yield* (await pg.query(q.sql, q.params)).rows; },
|
|
846
846
|
effects: {
|
|
847
847
|
'mail.send': { run: (input) => mailer.send(input) },
|
package/DOCS.md
CHANGED
|
@@ -251,7 +251,7 @@ the reflex selects what changed. Mechanisms that already exist, and no table.
|
|
|
251
251
|
A template is a transform-config slot inside a reflex — `effect.input`, `when`
|
|
252
252
|
and `select.query`. Tide stores, diffs and hashes them but never interprets
|
|
253
253
|
them: they go to the `transform` seam verbatim (under moss, Prism —
|
|
254
|
-
`
|
|
254
|
+
`evaluate` from `@niscorp/prism` fits the seam as it is).
|
|
255
255
|
|
|
256
256
|
What tide puts in `$` itself is plain JSON: a fact carries no key for a value
|
|
257
257
|
it was never given, in the memory store as in a database. What the host handed
|
package/README.md
CHANGED
|
@@ -18,11 +18,11 @@ pnpm add @niscorp/prism @niscorp/strata
|
|
|
18
18
|
|
|
19
19
|
```typescript
|
|
20
20
|
import { createTide, createMemoryStore } from '@niscorp/tide';
|
|
21
|
-
import {
|
|
21
|
+
import { evaluate } from '@niscorp/prism';
|
|
22
22
|
|
|
23
23
|
const tide = createTide({
|
|
24
24
|
store: createMemoryStore(),
|
|
25
|
-
transform:
|
|
25
|
+
transform: evaluate,
|
|
26
26
|
select: async (query) => db.rows(query),
|
|
27
27
|
effects: {
|
|
28
28
|
'mail.send': {
|
package/package.json
CHANGED