@kairos-es/codec 1.0.0-alpha.3 → 1.0.0-alpha.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/README.md +27 -2
- package/dist/cjs/MetadataSource.js +10 -0
- package/dist/cjs/MetadataSource.js.map +1 -0
- package/dist/cjs/Serializer.js +3 -3
- package/dist/cjs/Serializer.js.map +1 -1
- package/dist/cjs/Uuid.js +6 -3
- package/dist/cjs/Uuid.js.map +1 -1
- package/dist/cjs/decider.js +1 -1
- package/dist/cjs/decisionModel.js +1 -1
- package/dist/cjs/decisionModel.js.map +1 -1
- package/dist/cjs/decode.js +5 -5
- package/dist/cjs/decode.js.map +1 -1
- package/dist/cjs/deserialiseThenDecode.js +1 -1
- package/dist/cjs/deserialiseThenDecode.js.map +1 -1
- package/dist/cjs/errors.js +6 -4
- package/dist/cjs/errors.js.map +1 -1
- package/dist/cjs/event.js.map +1 -1
- package/dist/cjs/index.js +7 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/precondition.js +2 -2
- package/dist/cjs/precondition.js.map +1 -1
- package/dist/cjs/projection.js +9 -10
- package/dist/cjs/projection.js.map +1 -1
- package/dist/cjs/readLedger.js +20 -5
- package/dist/cjs/readLedger.js.map +1 -1
- package/dist/cjs/registry.js.map +1 -1
- package/dist/cjs/toEvent.js +58 -4
- package/dist/cjs/toEvent.js.map +1 -1
- package/dist/dts-cjs/MetadataSource.d.ts +8 -0
- package/dist/dts-cjs/MetadataSource.d.ts.map +1 -0
- package/dist/{dts → dts-cjs}/Serializer.d.ts +3 -3
- package/dist/{dts → dts-cjs}/Serializer.d.ts.map +1 -1
- package/dist/{dts → dts-cjs}/Uuid.d.ts +6 -3
- package/dist/{dts → dts-cjs}/Uuid.d.ts.map +1 -1
- package/dist/{dts → dts-cjs}/decider.d.ts +7 -7
- package/dist/{dts → dts-cjs}/decider.d.ts.map +1 -1
- package/dist/{dts → dts-cjs}/decision.d.ts +2 -2
- package/dist/{dts → dts-cjs}/decode.d.ts +3 -3
- package/dist/{dts → dts-cjs}/decode.d.ts.map +1 -1
- package/dist/{dts → dts-cjs}/deserialiseThenDecode.d.ts +3 -3
- package/dist/{dts → dts-cjs}/deserialiseThenDecode.d.ts.map +1 -1
- package/dist/{dts → dts-cjs}/errors.d.ts +4 -3
- package/dist/dts-cjs/errors.d.ts.map +1 -0
- package/dist/{dts → dts-cjs}/event.d.ts +18 -8
- package/dist/dts-cjs/event.d.ts.map +1 -0
- package/dist/{dts → dts-cjs}/index.d.ts +4 -2
- package/dist/dts-cjs/index.d.ts.map +1 -0
- package/dist/dts-cjs/package.json +3 -0
- package/dist/{dts → dts-cjs}/precondition.d.ts +2 -2
- package/dist/{dts → dts-cjs}/projection.d.ts +2 -2
- package/dist/dts-cjs/projection.d.ts.map +1 -0
- package/dist/{dts → dts-cjs}/readLedger.d.ts +4 -4
- package/dist/{dts → dts-cjs}/readLedger.d.ts.map +1 -1
- package/dist/{dts → dts-cjs}/toEvent.d.ts +15 -4
- package/dist/dts-cjs/toEvent.d.ts.map +1 -0
- package/dist/dts-esm/MetadataSource.d.ts +8 -0
- package/dist/dts-esm/MetadataSource.d.ts.map +1 -0
- package/dist/dts-esm/Serializer.d.ts +27 -0
- package/dist/dts-esm/Serializer.d.ts.map +1 -0
- package/dist/dts-esm/Uuid.d.ts +22 -0
- package/dist/dts-esm/Uuid.d.ts.map +1 -0
- package/dist/dts-esm/decider.d.ts +206 -0
- package/dist/dts-esm/decider.d.ts.map +1 -0
- package/dist/dts-esm/decision.d.ts +161 -0
- package/dist/dts-esm/decision.d.ts.map +1 -0
- package/dist/dts-esm/decisionModel.d.ts +149 -0
- package/dist/dts-esm/decisionModel.d.ts.map +1 -0
- package/dist/dts-esm/decode.d.ts +92 -0
- package/dist/dts-esm/decode.d.ts.map +1 -0
- package/dist/dts-esm/deserialiseThenDecode.d.ts +62 -0
- package/dist/dts-esm/deserialiseThenDecode.d.ts.map +1 -0
- package/dist/dts-esm/errors.d.ts +80 -0
- package/dist/dts-esm/errors.d.ts.map +1 -0
- package/dist/dts-esm/event.d.ts +81 -0
- package/dist/dts-esm/event.d.ts.map +1 -0
- package/dist/dts-esm/index.d.ts +134 -0
- package/dist/dts-esm/index.d.ts.map +1 -0
- package/dist/dts-esm/package.json +3 -0
- package/dist/dts-esm/precondition.d.ts +244 -0
- package/dist/dts-esm/precondition.d.ts.map +1 -0
- package/dist/dts-esm/projection.d.ts +56 -0
- package/dist/dts-esm/projection.d.ts.map +1 -0
- package/dist/dts-esm/readLedger.d.ts +263 -0
- package/dist/dts-esm/readLedger.d.ts.map +1 -0
- package/dist/dts-esm/registry.d.ts +46 -0
- package/dist/dts-esm/registry.d.ts.map +1 -0
- package/dist/dts-esm/toEvent.d.ts +45 -0
- package/dist/dts-esm/toEvent.d.ts.map +1 -0
- package/dist/esm/MetadataSource.js +3 -0
- package/dist/esm/MetadataSource.js.map +1 -0
- package/dist/esm/Serializer.js +3 -3
- package/dist/esm/Serializer.js.map +1 -1
- package/dist/esm/Uuid.js +6 -3
- package/dist/esm/Uuid.js.map +1 -1
- package/dist/esm/decider.js +1 -1
- package/dist/esm/decisionModel.js +1 -1
- package/dist/esm/decisionModel.js.map +1 -1
- package/dist/esm/decode.js +5 -5
- package/dist/esm/decode.js.map +1 -1
- package/dist/esm/deserialiseThenDecode.js +1 -1
- package/dist/esm/deserialiseThenDecode.js.map +1 -1
- package/dist/esm/errors.js +6 -4
- package/dist/esm/errors.js.map +1 -1
- package/dist/esm/event.js.map +1 -1
- package/dist/esm/index.js +4 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/precondition.js +2 -2
- package/dist/esm/precondition.js.map +1 -1
- package/dist/esm/projection.js +9 -10
- package/dist/esm/projection.js.map +1 -1
- package/dist/esm/readLedger.js +21 -6
- package/dist/esm/readLedger.js.map +1 -1
- package/dist/esm/registry.js.map +1 -1
- package/dist/esm/toEvent.js +58 -5
- package/dist/esm/toEvent.js.map +1 -1
- package/package.json +12 -7
- package/src/MetadataSource.ts +43 -0
- package/src/Serializer.ts +4 -4
- package/src/Uuid.ts +7 -4
- package/src/decider.ts +9 -9
- package/src/decision.ts +1 -1
- package/src/decisionModel.ts +1 -1
- package/src/decode.ts +12 -18
- package/src/deserialiseThenDecode.ts +5 -5
- package/src/errors.ts +6 -4
- package/src/event.ts +19 -9
- package/src/index.ts +4 -2
- package/src/precondition.ts +3 -3
- package/src/projection.ts +15 -20
- package/src/readLedger.ts +28 -12
- package/src/registry.ts +1 -1
- package/src/toEvent.ts +54 -7
- package/dist/dts/errors.d.ts.map +0 -1
- package/dist/dts/event.d.ts.map +0 -1
- package/dist/dts/index.d.ts.map +0 -1
- package/dist/dts/projection.d.ts.map +0 -1
- package/dist/dts/toEvent.d.ts.map +0 -1
- /package/dist/{dts → dts-cjs}/decision.d.ts.map +0 -0
- /package/dist/{dts → dts-cjs}/decisionModel.d.ts +0 -0
- /package/dist/{dts → dts-cjs}/decisionModel.d.ts.map +0 -0
- /package/dist/{dts → dts-cjs}/precondition.d.ts.map +0 -0
- /package/dist/{dts → dts-cjs}/registry.d.ts +0 -0
- /package/dist/{dts → dts-cjs}/registry.d.ts.map +0 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The typed slice path (primary): a schema-backed projection and the fluent
|
|
3
|
+
* builder that produces it.
|
|
4
|
+
*
|
|
5
|
+
* A `SliceProjection<S, R>` is a core `AnyProjection<S>` (directly composable —
|
|
6
|
+
* its `evolve` folds a `DecodedEvent`) enriched with the `type -> Schema` map
|
|
7
|
+
* `decodeSlices` merges and decodes through. That map's value type carries `R`
|
|
8
|
+
* covariantly (`Schema.Decoder<unknown, R>`), so the union of the defs'
|
|
9
|
+
* requirements flows to the decision model with no cast (and no phantom marker).
|
|
10
|
+
* Because `evolve` is already erased, a built slice drops straight into
|
|
11
|
+
* `composeProjections` — no `AnyProjection.of` ceremony.
|
|
12
|
+
*
|
|
13
|
+
* `projection(initialState).on(def, fold)...build()` infers the state `S` and
|
|
14
|
+
* the union `R` of the `.on`-ed defs' requirements, derives the read `Query`'s
|
|
15
|
+
* event-types from the defs' branded type literals (no `as EventType`), and
|
|
16
|
+
* hands each `fold` its decoded, typed payload. A handler for an un-imported
|
|
17
|
+
* event is therefore a compile error, and a mistyped type cannot silently match
|
|
18
|
+
* nothing.
|
|
19
|
+
*/
|
|
20
|
+
import { type AnyProjection, type Tag } from '@kairos-es/core';
|
|
21
|
+
import type { Schema } from 'effect';
|
|
22
|
+
import type { EventDef } from './event.js';
|
|
23
|
+
/**
|
|
24
|
+
* A schema-backed, directly-composable projection: an `AnyProjection<S>` plus
|
|
25
|
+
* the `type -> Schema` map for decode. The map's value type carries the union
|
|
26
|
+
* `R` of its defs' requirements covariantly, so `RequirementOf` recovers `R`
|
|
27
|
+
* (and the `out R` annotation keeps union-widening sound) with no phantom marker.
|
|
28
|
+
*/
|
|
29
|
+
export interface SliceProjection<out S = unknown, out R = unknown> extends AnyProjection<S> {
|
|
30
|
+
readonly schemas: ReadonlyMap<string, Schema.Decoder<unknown, R>>;
|
|
31
|
+
}
|
|
32
|
+
/** The fluent builder: accumulate `.on(def, fold)` steps, then `.build()`. */
|
|
33
|
+
export interface ProjectionBuilder<S, R = never> {
|
|
34
|
+
/**
|
|
35
|
+
* Fold events of `def`'s type: `fold` receives the decoded, typed `payload`.
|
|
36
|
+
* Adds `def`'s requirement `R2` to the accumulated `R`.
|
|
37
|
+
*
|
|
38
|
+
* Throws if this chain has already `.on`-ed that event type — see the guard in
|
|
39
|
+
* `projection` for why a repeat is always a mistake here, where across two
|
|
40
|
+
* slices it need not be.
|
|
41
|
+
*/
|
|
42
|
+
on<A, I, R2>(def: EventDef<A, I, R2>, fold: (state: S, payload: A) => S): ProjectionBuilder<S, R | R2>;
|
|
43
|
+
/**
|
|
44
|
+
* Materialise the slice. The query is a single item over the `.on`-ed defs'
|
|
45
|
+
* types (branded via `EventType.make`) and `options.tags` (default none).
|
|
46
|
+
*/
|
|
47
|
+
build(options?: {
|
|
48
|
+
readonly tags?: ReadonlyArray<Tag>;
|
|
49
|
+
}): SliceProjection<S, R>;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Start a slice for `initialState`. Returns a builder with no defs yet
|
|
53
|
+
* (`R = never`); each `.on(def, fold)` widens `R` by the def's requirement.
|
|
54
|
+
*/
|
|
55
|
+
export declare const projection: <S>(initialState: S) => ProjectionBuilder<S, never>;
|
|
56
|
+
//# sourceMappingURL=projection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projection.d.ts","sourceRoot":"","sources":["../../src/projection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EACL,KAAK,aAAa,EAIlB,KAAK,GAAG,EACT,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AACpC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEvC;;;;;GAKG;AACH,MAAM,WAAW,eAAe,CAAC,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,CAAC,CAAC,GAAG,OAAO,CAC/D,SAAQ,aAAa,CAAC,CAAC,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAA;CAClE;AAED,8EAA8E;AAC9E,MAAM,WAAW,iBAAiB,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK;IAC7C;;;;;;;OAOG;IACH,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EACT,GAAG,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,EACvB,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,KAAK,CAAC,GAChC,iBAAiB,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAA;IAC/B;;;OAGG;IACH,KAAK,CAAC,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,aAAa,CAAC,GAAG,CAAC,CAAA;KAAE,GAAG,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;CAC/E;AAED;;;GAGG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,EAAE,cAAc,CAAC,KAAG,iBAAiB,CAAC,CAAC,EAAE,KAAK,CA4FzE,CAAA"}
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ambient read ledger: the hops a bracket walked, and the single derivation
|
|
3
|
+
* that turns them into one `AppendCondition`.
|
|
4
|
+
*
|
|
5
|
+
* ## The gap this closes, and why the fix has to be ambient
|
|
6
|
+
*
|
|
7
|
+
* A decision model whose second query cannot be written until an earlier read has
|
|
8
|
+
* been folded — the identifier it needs is data that fold produced — guards its
|
|
9
|
+
* append on only the LAST read if it reaches for `buildDecisionModel` there. The
|
|
10
|
+
* append then succeeds on a premise that is no longer true, and nothing warns: it
|
|
11
|
+
* compiles, it runs, and it is silent. Two things must both change for the
|
|
12
|
+
* condition to be sound, and fixing either alone still lets the stale write
|
|
13
|
+
* through. Keeping the union of queries but taking the last head misses, because
|
|
14
|
+
* the invalidating event lands in the window between the two heads. Keeping the
|
|
15
|
+
* earliest head but taking the last query misses, because the invalidating event
|
|
16
|
+
* fails that query's TYPE arm before its tag arm is reached — which is why adding
|
|
17
|
+
* a tag to the last query cannot recover it.
|
|
18
|
+
*
|
|
19
|
+
* The ledger is an OPTIONAL AMBIENT SERVICE rather than a scope object a caller
|
|
20
|
+
* threads, and that is the whole design. A scope object's guarantee is "every read
|
|
21
|
+
* through this object", which is not "every read": `modelAtHead` stays exported
|
|
22
|
+
* and stays in scope inside the bracket, so a read that reached for the familiar
|
|
23
|
+
* name — or that happened inside a helper the body merely called — drops a hop
|
|
24
|
+
* silently. Here `modelAtHead` ITSELF records, so a read is recorded whatever
|
|
25
|
+
* symbol performed it and at whatever call depth. `Effect.serviceOption` is what
|
|
26
|
+
* makes that additive: it reads the service if present and adds NOTHING to the
|
|
27
|
+
* requirement channel, so `modelAtHead`'s published signature is untouched and no
|
|
28
|
+
* existing caller provides anything.
|
|
29
|
+
*
|
|
30
|
+
* ## Why the query is recorded eagerly and the head only on completion
|
|
31
|
+
*
|
|
32
|
+
* A `Hop` is `{ query, head? }` and the two halves are recorded at different
|
|
33
|
+
* moments: the query before a single event is streamed, the head once the fold has
|
|
34
|
+
* run to completion. So a read that opened and never finished widens the guard
|
|
35
|
+
* without contributing a floor, and both halves fail safe.
|
|
36
|
+
*
|
|
37
|
+
* The laziness is deliberate protection rather than an accident of where the line
|
|
38
|
+
* sits. Recording the head at read-return is available and MUST NOT be done: a
|
|
39
|
+
* read that failed part-way folded only a PREFIX, and a head recorded for it is a
|
|
40
|
+
* claim the hop did not earn — the floor would sit above events that read never
|
|
41
|
+
* folded, and nothing would refuse an append those events invalidate.
|
|
42
|
+
*
|
|
43
|
+
* ## An invalidated ledger must REFUSE to derive, never derive narrowly
|
|
44
|
+
*
|
|
45
|
+
* Nothing here evicts a hop, so there is no eviction policy to specify — but the
|
|
46
|
+
* rule is stated now because the moment a bound is added, and an unbounded walk on
|
|
47
|
+
* a large log will want one, the tempting implementation is to drop the oldest hop
|
|
48
|
+
* and carry on. A ledger that has lost hops must become a poison value and refuse
|
|
49
|
+
* to produce a condition at all. Deriving from a PARTIAL set is worse than
|
|
50
|
+
* refusing, because it looks like it worked: an emptied ledger produces a NARROWER
|
|
51
|
+
* condition and a silent success, which is the original hazard wearing a fix's
|
|
52
|
+
* name. The valve is coarsen, then poison. Never forget.
|
|
53
|
+
*
|
|
54
|
+
* ## What is deliberately NOT exported from the package
|
|
55
|
+
*
|
|
56
|
+
* `deriveLayeredCondition` is PACKAGE-internal and reaches no entry point. Two
|
|
57
|
+
* traps stay reachable for a caller who assembles a condition by hand, both
|
|
58
|
+
* demonstrated: concatenating query items drops a wildcard hop, an empty item list
|
|
59
|
+
* being absorbing under OR while an empty concatenation contributes nothing; and a
|
|
60
|
+
* MAXIMUM over heads reads as naturally as a minimum, two reducers of identical
|
|
61
|
+
* signature where "the position I read at" argues just as fluently for the later
|
|
62
|
+
* one. Offering the derivation as a public step would put both back within reach
|
|
63
|
+
* of the callers the bracket exists to protect.
|
|
64
|
+
*/
|
|
65
|
+
import type { AnyProjection, AppendCondition, Position, Query } from '@kairos-es/core';
|
|
66
|
+
import { Context, Effect, Layer, Option } from 'effect';
|
|
67
|
+
/**
|
|
68
|
+
* One recorded read: the query it rode, and the head it observed.
|
|
69
|
+
*
|
|
70
|
+
* `head` is a genuinely OPTIONAL key and not `Position | undefined`, because
|
|
71
|
+
* `exactOptionalPropertyTypes` is on and the absent case must be an absent key.
|
|
72
|
+
* Absent means the read did not complete, which the derivation below treats as
|
|
73
|
+
* the widest possible floor.
|
|
74
|
+
*/
|
|
75
|
+
export interface Hop {
|
|
76
|
+
readonly query: Query;
|
|
77
|
+
readonly head?: Position;
|
|
78
|
+
}
|
|
79
|
+
declare const ReadLedger_base: Context.ServiceClass<ReadLedger, "@kairos-es/codec/ReadLedger", {
|
|
80
|
+
/**
|
|
81
|
+
* File a query, and hand back the effect that will fill in its head.
|
|
82
|
+
*
|
|
83
|
+
* Two phases and not one `record(hop)`, which is what the eager/lazy split
|
|
84
|
+
* above needs: a one-shot recorder cannot express a hop whose head never
|
|
85
|
+
* arrives, and that is the case the whole fail-safe direction turns on.
|
|
86
|
+
*
|
|
87
|
+
* The second phase comes back as a CLOSURE rather than as a slot number the
|
|
88
|
+
* caller carries to a second method. The closure holds its own slot, so
|
|
89
|
+
* nothing threads an index through the reader, nothing looks the service up a
|
|
90
|
+
* second time to spend it, and there is no slot value for a caller to hold
|
|
91
|
+
* wrongly.
|
|
92
|
+
*/
|
|
93
|
+
readonly record: (query: Query) => Effect.Effect<CloseHop>;
|
|
94
|
+
readonly hops: Effect.Effect<ReadonlyArray<Hop>>;
|
|
95
|
+
}>;
|
|
96
|
+
/**
|
|
97
|
+
* The ambient ledger, present only inside a bracket.
|
|
98
|
+
*
|
|
99
|
+
* ⚠ A RECORDING path reads it with `Effect.serviceOption` and never
|
|
100
|
+
* `yield* ReadLedger`: its absence is the normal case there, and costing the
|
|
101
|
+
* requirement channel nothing is exactly what makes this change additive.
|
|
102
|
+
* `modelAtHead` is that path and is why the rule exists.
|
|
103
|
+
*
|
|
104
|
+
* A BRACKET-ONLY function is the opposite case and yields the service deliberately.
|
|
105
|
+
* `decideOnly` does, and naming the requirement is what turns *"call me inside a
|
|
106
|
+
* bracket"* from a runtime defect into a compile error — presence being the one
|
|
107
|
+
* direction the type system can decide here. So the test is what the function
|
|
108
|
+
* means outside a bracket: nothing (record ambiently), or nothing sensible
|
|
109
|
+
* (require it).
|
|
110
|
+
*
|
|
111
|
+
* Recording is two-phase, and `record`'s own doc below owns why and what shape the
|
|
112
|
+
* second phase takes.
|
|
113
|
+
*/
|
|
114
|
+
export declare class ReadLedger extends ReadLedger_base {
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Fill in a recorded hop's head. Never called if the read does not complete.
|
|
118
|
+
*
|
|
119
|
+
* On the package's public surface because it is already ON it: `record` returns
|
|
120
|
+
* one, `ReadLedger` is exported, so a consumer holding the service holds this
|
|
121
|
+
* type and could not name it. `Hop` was exported and this was not — the same interface, two
|
|
122
|
+
* treatments.
|
|
123
|
+
*/
|
|
124
|
+
export type CloseHop = (head: Position) => Effect.Effect<void>;
|
|
125
|
+
declare const NoReadsRecorded_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
126
|
+
readonly _tag: "NoReadsRecorded";
|
|
127
|
+
} & Readonly<A>;
|
|
128
|
+
/**
|
|
129
|
+
* Raised when a bracket closes having recorded no read at all.
|
|
130
|
+
*
|
|
131
|
+
* On the ERROR channel and deliberately split from the nested-append DEFECT,
|
|
132
|
+
* because the two are different mistakes. An empty bracket can arise from a
|
|
133
|
+
* data-dependent branch that produces events without reading — a genuinely
|
|
134
|
+
* unconditional creation, written inside a bracket by mistake — where a nested
|
|
135
|
+
* append is always a wiring fault. An error-channel value lets a caller decide
|
|
136
|
+
* which it is.
|
|
137
|
+
*
|
|
138
|
+
* Its job is narrower than it looks, and the narrowing is worth stating because
|
|
139
|
+
* the wider reading is the tempting one. Once a bracket's guard is itself a fold,
|
|
140
|
+
* a body that reads nothing still has a hop, so this cannot fire — it is the guard
|
|
141
|
+
* against an unguarded UNCONDITIONAL bracket, not against an unguarded bracket. A
|
|
142
|
+
* bracket that looks guarded and is not is NOT what this catches and never was,
|
|
143
|
+
* and nothing else catches it either — `precondition.ts` owns that gap and the
|
|
144
|
+
* rule a reader has to keep in its place. A refusal taken BEFORE reading is not
|
|
145
|
+
* this case either: it short-circuits and surfaces as the refusal.
|
|
146
|
+
*/
|
|
147
|
+
export declare class NoReadsRecorded extends NoReadsRecorded_base<Record<never, never>> {
|
|
148
|
+
/**
|
|
149
|
+
* The sentence, as the `Error` field that says why — so the fault renders
|
|
150
|
+
* ITSELF, exactly as this package's other two errors do (`errors.ts` owns the
|
|
151
|
+
* argument for the mechanism and it is not restated here).
|
|
152
|
+
*
|
|
153
|
+
* A getter over a constant rather than a constructor field, because there is no
|
|
154
|
+
* datum to vary: every raise of this error means one thing.
|
|
155
|
+
*/
|
|
156
|
+
get message(): string;
|
|
157
|
+
}
|
|
158
|
+
declare const TaglessSliceInLedger_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
159
|
+
readonly _tag: "TaglessSliceInLedger";
|
|
160
|
+
} & Readonly<A>;
|
|
161
|
+
/**
|
|
162
|
+
* Raised when recording a hop would leave the bracket's accumulated union
|
|
163
|
+
* unservable.
|
|
164
|
+
*
|
|
165
|
+
* The store refuses a multi-item query in which any item is tagless, and it
|
|
166
|
+
* refuses it by THROWING inside the append decorator, which becomes a defect:
|
|
167
|
+
* uncatchable, one call and one layer away from the `build()` that chose no tags.
|
|
168
|
+
* A slice built without tags defaults to none, so it is perfectly servable alone
|
|
169
|
+
* and kills the append the moment it is unioned. This moves that failure onto the
|
|
170
|
+
* error channel, to the read that caused it, naming the record entry to fix.
|
|
171
|
+
*
|
|
172
|
+
* It refuses an unservable UNION and not every tagless hop, which is the easy
|
|
173
|
+
* mistake to make in the other direction: one tagless slice read on its own is
|
|
174
|
+
* servable and must keep working. Two cases reach it — a tagless hop unioned with
|
|
175
|
+
* another, and a single hop whose own RECORD holds two tagless slices, which
|
|
176
|
+
* composes to a multi-item query with no second hop needed.
|
|
177
|
+
*/
|
|
178
|
+
export declare class TaglessSliceInLedger extends TaglessSliceInLedger_base<{
|
|
179
|
+
readonly sliceKey: string;
|
|
180
|
+
}> {
|
|
181
|
+
/** The offending slice and the remedy, in one sentence. */
|
|
182
|
+
get message(): string;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* The ONE derivation: the union of every query walked, at the earliest head
|
|
186
|
+
* observed. Package-internal, for the reason the module doc gives.
|
|
187
|
+
*
|
|
188
|
+
* The union goes through core's own `unionQueries` — the merge
|
|
189
|
+
* `composeProjections` folds a record through, reached without one — and never a
|
|
190
|
+
* spread of `items`, because a wildcard hop (`items: []`) is ABSORBING under OR
|
|
191
|
+
* while a spread of an empty list contributes nothing, so hand-rolling the union
|
|
192
|
+
* narrows a match-everything hop to its sibling, silently and in the unsafe
|
|
193
|
+
* direction. A
|
|
194
|
+
* repeated or overlapping hop is harmless because this derives ONCE from a merged
|
|
195
|
+
* set and matching is idempotent over an OR; that property belongs to deriving
|
|
196
|
+
* once and would be lost by a refactor to per-hop evaluation.
|
|
197
|
+
*
|
|
198
|
+
* ## When any hop is headless the floor is `ORIGIN`, and the alternative is unsound
|
|
199
|
+
*
|
|
200
|
+
* The earliest head that actually ARRIVED is refused, and is named here as refused
|
|
201
|
+
* rather than merely not chosen, because it is what a reader writes by accident
|
|
202
|
+
* when told to take the earliest head. With one headless hop among completed hops
|
|
203
|
+
* the union looks right and the floor betrays it, sitting already above the
|
|
204
|
+
* invalidating event.
|
|
205
|
+
*
|
|
206
|
+
* `ORIGIN`'s cost is measured rather than described: it refuses every append to
|
|
207
|
+
* any identity that already has history, so it is not a conservative default but a
|
|
208
|
+
* hard stop. It is affordable only because conflict retry wraps the bracket from
|
|
209
|
+
* OUTSIDE and re-reads, which is the rule the whole shape depends on.
|
|
210
|
+
*/
|
|
211
|
+
export declare const deriveLayeredCondition: (hops: ReadonlyArray<Hop>) => AppendCondition | undefined;
|
|
212
|
+
/**
|
|
213
|
+
* A fresh ledger and the `Layer` providing it: a `Ref` of hops behind the two-phase
|
|
214
|
+
* `record` the service declares.
|
|
215
|
+
*
|
|
216
|
+
* The hops effect is handed back beside the layer because the bracket reads them
|
|
217
|
+
* AFTER the body has run and the layer is out of scope, which is the same moment it
|
|
218
|
+
* stops being able to reach the service.
|
|
219
|
+
*/
|
|
220
|
+
export declare const makeReadLedger: Effect.Effect<{
|
|
221
|
+
readonly layer: Layer.Layer<ReadLedger>;
|
|
222
|
+
readonly hops: Effect.Effect<ReadonlyArray<Hop>>;
|
|
223
|
+
}>;
|
|
224
|
+
/**
|
|
225
|
+
* File a query into the ambient ledger if there is one, and hand back the effect
|
|
226
|
+
* that completes it. Outside a bracket the whole thing is a no-op, and the caller
|
|
227
|
+
* still writes one line rather than a conditional.
|
|
228
|
+
*/
|
|
229
|
+
export declare const recordQuery: (query: Query) => Effect.Effect<CloseHop>;
|
|
230
|
+
/**
|
|
231
|
+
* Refuse a read that would leave the bracket's accumulated union unservable,
|
|
232
|
+
* BEFORE the read is paid for.
|
|
233
|
+
*
|
|
234
|
+
* Servability is answerable from the queries alone, so the check runs when a hop is
|
|
235
|
+
* recorded rather than at append time — the eager half of the eager/lazy split doing
|
|
236
|
+
* one more job. Outside a bracket nothing is unioned and nothing is unservable, so
|
|
237
|
+
* the ordinary single-hop caller is untaxed.
|
|
238
|
+
*
|
|
239
|
+
* It judges the PROSPECTIVE UNION and asks core for the verdict, which is what makes
|
|
240
|
+
* both failing shapes one case rather than two. An earlier version tested each
|
|
241
|
+
* recorded query separately and treated a FIRST hop as unconditionally fine — but a
|
|
242
|
+
* hop is a RECORD, and a record of two tagless slices composes to a multi-item query
|
|
243
|
+
* that is unservable on its own. That read died at the store, uncatchably, on the
|
|
244
|
+
* exact path this error exists to keep off the defect channel. A grammar with two
|
|
245
|
+
* homes drifts at the shapes neither author had in mind, so there is one home and it
|
|
246
|
+
* is `servableQueryFault`'s.
|
|
247
|
+
*
|
|
248
|
+
* Where the OFFENDING slice is THIS record's the ledger can name its key; where it
|
|
249
|
+
* belongs to an earlier hop it can only say so, a recorded hop keeping its query
|
|
250
|
+
* rather than the key it was composed from. That asymmetry is diagnostic-only and is
|
|
251
|
+
* why the message is built from a key that may be a placeholder.
|
|
252
|
+
*/
|
|
253
|
+
export declare const assertServableAddition: (projections: Record<string, AnyProjection>) => Effect.Effect<void, TaglessSliceInLedger>;
|
|
254
|
+
/**
|
|
255
|
+
* The condition the ambient ledger derives right now, or `None` outside a bracket.
|
|
256
|
+
*
|
|
257
|
+
* This is what makes `buildDecisionModel` correct inside a bracket: the call whose
|
|
258
|
+
* current behaviour is the hazard derives from every hop the bracket walked rather
|
|
259
|
+
* than from its own single read.
|
|
260
|
+
*/
|
|
261
|
+
export declare const ambientLayeredCondition: Effect.Effect<Option.Option<AppendCondition>>;
|
|
262
|
+
export {};
|
|
263
|
+
//# sourceMappingURL=readLedger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readLedger.d.ts","sourceRoot":"","sources":["../../src/readLedger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;AACH,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,QAAQ,EACR,KAAK,EACN,MAAM,iBAAiB,CAAA;AAQxB,OAAO,EAAE,OAAO,EAAQ,MAAM,EAAE,KAAK,EAAE,MAAM,EAAO,MAAM,QAAQ,CAAA;AAElE;;;;;;;GAOG;AACH,MAAM,WAAW,GAAG;IAClB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;IACrB,QAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAA;CACzB;;IAuBG;;;;;;;;;;;;OAYG;qBACc,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;mBAC3C,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;;AAnCpD;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,UAAW,SAAQ,eAmBE;CAAG;AAErC;;;;;;;GAOG;AACH,MAAM,MAAM,QAAQ,GAAG,CAAC,IAAI,EAAE,QAAQ,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;;;;AAE9D;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,eAAgB,SAAQ,qBACnC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CACrB;IACC;;;;;;;OAOG;IACH,IAAa,OAAO,IAAI,MAAM,CAM7B;CACF;;;;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,oBAAqB,SAAQ,0BAExC;IAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;IAC9B,2DAA2D;IAC3D,IAAa,OAAO,IAAI,MAAM,CAO7B;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,sBAAsB,GACjC,MAAM,aAAa,CAAC,GAAG,CAAC,KACvB,eAAe,GAAG,SAiBpB,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,CAAC;IACzC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;IACvC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAA;CACjD,CAsBC,CAAA;AAsBF;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,OAAO,KAAK,KAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CACT,CAAA;AAoCxD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,sBAAsB,GACjC,aAAa,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,KACzC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,oBAAoB,CAaxC,CAAA;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,MAAM,CACjD,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,CAK/B,CAAA"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The general (registry) path (minimal): decode an arbitrary wire event by its
|
|
3
|
+
* runtime type string. This is the one place a type outside the known set
|
|
4
|
+
* surfaces as a typed `UnknownEventType` — the home of ADR-0005 decode-totality.
|
|
5
|
+
*
|
|
6
|
+
* `makeRegistry(defs)` builds a `type -> Schema` map with a construction-time
|
|
7
|
+
* uniqueness guard (a duplicate type throws at wiring, not at runtime). Its
|
|
8
|
+
* requirement `R` is the union of the defs' requirements. `decode` looks the
|
|
9
|
+
* type up, then runs `deserialiseThenDecode` over the bytes, yielding
|
|
10
|
+
* `{ type, payload: unknown }`. That `unknown` is the point of the path rather
|
|
11
|
+
* than a gap in it: the type is discovered at RUNTIME off the wire event, so the
|
|
12
|
+
* caller has named no def and the return is deliberately NOT a discriminated
|
|
13
|
+
* union over `Defs`. What this path owes its caller is decode TOTALITY — every
|
|
14
|
+
* known type decodes, an unknown one fails as `UnknownEventType` — and not typed
|
|
15
|
+
* access. A caller who wants a typed payload names the def it expects and takes
|
|
16
|
+
* the typed slice path (`projection(init).on(def, fold)`), where each fold
|
|
17
|
+
* receives its payload already decoded and narrowed.
|
|
18
|
+
*
|
|
19
|
+
* What is this path's OWN and what it merely shares. The lookup is its own: a
|
|
20
|
+
* miss here is `UnknownEventType`, where the same miss on the typed path is a
|
|
21
|
+
* `CodecError` about a schema the caller did not supply — the asymmetry ADR-0005
|
|
22
|
+
* exists for. Everything after the lookup is the two-step both paths perform, so
|
|
23
|
+
* it is `deserialiseThenDecode` that owns it and fixes the `deserialise` /
|
|
24
|
+
* `decode` `reason` strings; this module holding a second copy is exactly how one
|
|
25
|
+
* of them would come to be reworded on one path only.
|
|
26
|
+
*/
|
|
27
|
+
import type { DcbEvent } from '@kairos-es/core';
|
|
28
|
+
import { Effect } from 'effect';
|
|
29
|
+
import { type CodecError, UnknownEventType } from './errors.js';
|
|
30
|
+
import type { EventDef, EventDefAny } from './event.js';
|
|
31
|
+
import { Serializer } from './Serializer.js';
|
|
32
|
+
/** A registry decoding arbitrary wire events; `R` is the union of def requirements. */
|
|
33
|
+
export interface Registry<R> {
|
|
34
|
+
readonly decode: (event: DcbEvent) => Effect.Effect<{
|
|
35
|
+
readonly type: string;
|
|
36
|
+
readonly payload: unknown;
|
|
37
|
+
}, UnknownEventType | CodecError, Serializer | R>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Build a `Registry` from a def barrel. Throws at construction on a duplicate
|
|
41
|
+
* type; `R` is the union of the defs' requirements.
|
|
42
|
+
*/
|
|
43
|
+
type RequirementOfDefs<Defs extends ReadonlyArray<EventDefAny>> = Defs[number] extends EventDef<any, any, infer R> ? R : never;
|
|
44
|
+
export declare const makeRegistry: <Defs extends ReadonlyArray<EventDefAny>>(defs: Defs) => Registry<RequirementOfDefs<Defs>>;
|
|
45
|
+
export {};
|
|
46
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,MAAM,EAAe,MAAM,QAAQ,CAAA;AAE5C,OAAO,EAAE,KAAK,UAAU,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAC5D,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC,uFAAuF;AACvF,MAAM,WAAW,QAAQ,CAAC,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,CACf,KAAK,EAAE,QAAQ,KACZ,MAAM,CAAC,MAAM,CAChB;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;KAAE,EACpD,gBAAgB,GAAG,UAAU,EAC7B,UAAU,GAAG,CAAC,CACf,CAAA;CACF;AAED;;;GAGG;AACH,KAAK,iBAAiB,CAAC,IAAI,SAAS,aAAa,CAAC,WAAW,CAAC,IAE5D,IAAI,CAAC,MAAM,CAAC,SAAS,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;AAE9D,eAAO,MAAM,YAAY,GAAI,IAAI,SAAS,aAAa,CAAC,WAAW,CAAC,EAClE,MAAM,IAAI,KACT,QAAQ,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAgClC,CAAA"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event production (codec edge-helper): turn a typed payload into a wire
|
|
3
|
+
* `DcbEvent`. Encode is `Schema.encodeEffect(def.schema)` (a `SchemaError`
|
|
4
|
+
* becomes a `CodecError`; any encryption transform runs here, *before* serialisation)
|
|
5
|
+
* then `serialiser.serialise`. The wire `tags` are derived from the def's
|
|
6
|
+
* required `tagsFor` mapper (ADR-0006) — they are never hand-passed, so two
|
|
7
|
+
* command sites emitting the same event type cannot tag it differently. A mapper
|
|
8
|
+
* that throws (e.g. an ill-formed `key:value` rejected by `Tag.make`) is
|
|
9
|
+
* surfaced on the `CodecError` channel, not as a defect. `uuid`
|
|
10
|
+
* comes from `options.uuid` or the `Uuid` service; `occurredAt` from
|
|
11
|
+
* `options.occurredAt` or the Effect clock (`DateTime.now`), keeping `core`
|
|
12
|
+
* clock- and RNG-free while staying overridable for backdated imports.
|
|
13
|
+
* `metadata` comes from `options.metadata` or the OPTIONAL ambient
|
|
14
|
+
* `MetadataSource` service, and is `{}` when neither supplies it (ADR-0017). A
|
|
15
|
+
* bag core's `Metadata` schema refuses, such as one holding a value that is not a
|
|
16
|
+
* string, fails on the `CodecError` channel (`reason: 'metadata'`), whichever of
|
|
17
|
+
* the two supplied it. It never reaches `tagsFor`, the
|
|
18
|
+
* event's schema or the serialiser, so it can enter neither the tag junction
|
|
19
|
+
* table nor the encryption seam.
|
|
20
|
+
*/
|
|
21
|
+
import { type DcbEvent, Metadata } from '@kairos-es/core';
|
|
22
|
+
import { DateTime, Effect } from 'effect';
|
|
23
|
+
import { CodecError } from './errors.js';
|
|
24
|
+
import type { EventDef } from './event.js';
|
|
25
|
+
import { Serializer } from './Serializer.js';
|
|
26
|
+
import { Uuid } from './Uuid.js';
|
|
27
|
+
/**
|
|
28
|
+
* Encode `payload` under `def` and stamp it into a wire `DcbEvent`, deriving its
|
|
29
|
+
* `tags` from `def.tagsFor(payload)` (a throwing mapper surfaces as a
|
|
30
|
+
* `CodecError`, not a defect). The tags are stamped exactly as the mapper
|
|
31
|
+
* returns them — no dedup or reordering. `type` and `tags` are cleartext
|
|
32
|
+
* wire-envelope fields (the query surface), so a `tagsFor` mapper may only key
|
|
33
|
+
* off cleartext payload fields (ADR-0006). `uuid` / `occurredAt` are
|
|
34
|
+
* exact-optional overrides; absent, they come from the `Uuid` service and the
|
|
35
|
+
* Effect clock. `metadata` is an exact-optional override too; absent, it comes
|
|
36
|
+
* from the ambient `MetadataSource` if one is provided and is `{}` otherwise.
|
|
37
|
+
* The ambient read adds nothing to the requirement channel. A bag core's
|
|
38
|
+
* `Metadata` schema refuses fails as a `CodecError` with `reason: 'metadata'`.
|
|
39
|
+
*/
|
|
40
|
+
export declare const toEvent: <A, I, R>(def: EventDef<A, I, R>, payload: A, options?: {
|
|
41
|
+
readonly uuid?: string;
|
|
42
|
+
readonly occurredAt?: DateTime.Utc;
|
|
43
|
+
readonly metadata?: Metadata;
|
|
44
|
+
}) => Effect.Effect<DcbEvent, CodecError, Serializer | Uuid | R>;
|
|
45
|
+
//# sourceMappingURL=toEvent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toEvent.d.ts","sourceRoot":"","sources":["../../src/toEvent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,KAAK,QAAQ,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAkB,MAAM,QAAQ,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEvC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAE7B;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,OAAO,GAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAC7B,KAAK,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EACtB,SAAS,CAAC,EACV,UAAU;IACR,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAA;IAClC,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAA;CAC7B,KACA,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,UAAU,EAAE,UAAU,GAAG,IAAI,GAAG,CAAC,CA4DxD,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MetadataSource.js","names":["Context","MetadataSource","Service"],"sources":["../../src/MetadataSource.ts"],"sourcesContent":[null],"mappings":"AAsCA,SAASA,OAAO,QAAQ,QAAQ;AAEhC,OAAM,MAAOC,cAAe,sBAAQD,OAAO,CAACE,OAAO,EAA4B,CAC7E,iCAAiC,CAClC","ignoreList":[]}
|
package/dist/esm/Serializer.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The pluggable serialiser: the `Uint8Array` <-> value boundary applied
|
|
3
|
-
* *outside* `Schema`. Encode is `Schema.
|
|
4
|
-
* `deserialise` then `Schema.
|
|
3
|
+
* *outside* `Schema`. Encode is `Schema.encodeEffect` then `serialise`; decode is
|
|
4
|
+
* `deserialise` then `Schema.decodeUnknownEffect`. Both codec paths read the same
|
|
5
5
|
* `Serializer` from context, so encode and decode cannot mismatch; swapping
|
|
6
6
|
* JSON for msgpack is a different layer with no schema or call-site changes.
|
|
7
7
|
*
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* a trivial `Layer.succeed`.
|
|
12
12
|
*/
|
|
13
13
|
import { Context, Layer } from 'effect';
|
|
14
|
-
export class Serializer extends /*#__PURE__*/Context.
|
|
14
|
+
export class Serializer extends /*#__PURE__*/Context.Service()('@kairos-es/codec/Serializer') {}
|
|
15
15
|
const encoder = /*#__PURE__*/new TextEncoder();
|
|
16
16
|
const decoder = /*#__PURE__*/new TextDecoder();
|
|
17
17
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Serializer.js","names":["Context","Layer","Serializer","
|
|
1
|
+
{"version":3,"file":"Serializer.js","names":["Context","Layer","Serializer","Service","encoder","TextEncoder","decoder","TextDecoder","SerializerDefault","succeed","serialise","v","encode","JSON","stringify","deserialise","b","parse","decode"],"sources":["../../src/Serializer.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;AAYA,SAASA,OAAO,EAAEC,KAAK,QAAQ,QAAQ;AAEvC,OAAM,MAAOC,UAAW,sBAAQF,OAAO,CAACG,OAAO,EAM5C,CAAC,6BAA6B,CAAC;AAElC,MAAMC,OAAO,gBAAG,IAAIC,WAAW,EAAE;AACjC,MAAMC,OAAO,gBAAG,IAAIC,WAAW,EAAE;AAEjC;;;;;AAKA,OAAO,MAAMC,iBAAiB,gBAA4BP,KAAK,CAACQ,OAAO,CACrEP,UAAU,EACV;EACEQ,SAAS,EAAGC,CAAC,IAAKP,OAAO,CAACQ,MAAM,CAACC,IAAI,CAACC,SAAS,CAACH,CAAC,CAAC,CAAC;EACnDI,WAAW,EAAGC,CAAC,IAAKH,IAAI,CAACI,KAAK,CAACX,OAAO,CAACY,MAAM,CAACF,CAAC,CAAC;CACjD,CACF","ignoreList":[]}
|
package/dist/esm/Uuid.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { makeSequentialUuid } from '@kairos-es/core/testing';
|
|
13
13
|
import { Context, Effect, Layer } from 'effect';
|
|
14
|
-
export class Uuid extends /*#__PURE__*/Context.
|
|
14
|
+
export class Uuid extends /*#__PURE__*/Context.Service()('@kairos-es/codec/Uuid') {}
|
|
15
15
|
/** Live uuid generation via WebCrypto (no `node:crypto`). */
|
|
16
16
|
export const UuidLive = /*#__PURE__*/Layer.succeed(Uuid, {
|
|
17
17
|
generate: /*#__PURE__*/Effect.sync(() => globalThis.crypto.randomUUID())
|
|
@@ -19,9 +19,12 @@ export const UuidLive = /*#__PURE__*/Layer.succeed(Uuid, {
|
|
|
19
19
|
/**
|
|
20
20
|
* A deterministic uuid layer for suites, wrapping core's shared
|
|
21
21
|
* `makeSequentialUuid` (the single source of truth for the counter scheme).
|
|
22
|
-
* Each layer
|
|
22
|
+
* Each BUILD of the layer makes a fresh generator, so it owns its own counter and
|
|
23
23
|
* yields a stable v4-shaped sequence `00000000-0000-4000-8000-<12 hex>` starting
|
|
24
|
-
* at `...000000000000`.
|
|
24
|
+
* at `...000000000000`. A build is not one per `Effect.provide`: Effect memoises
|
|
25
|
+
* a layer across the provisions that share a memo map, so a nested second
|
|
26
|
+
* provision of this layer continues the counter rather than restarting it, and
|
|
27
|
+
* `Layer.fresh` is the way to ask for a restart. Generation is wrapped in `Effect.sync` because the
|
|
25
28
|
* generator advances its counter (a side effect on each call).
|
|
26
29
|
*/
|
|
27
30
|
export const UuidTest = /*#__PURE__*/Layer.sync(Uuid, () => {
|
package/dist/esm/Uuid.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Uuid.js","names":["makeSequentialUuid","Context","Effect","Layer","Uuid","
|
|
1
|
+
{"version":3,"file":"Uuid.js","names":["makeSequentialUuid","Context","Effect","Layer","Uuid","Service","UuidLive","succeed","generate","sync","globalThis","crypto","randomUUID","UuidTest","next"],"sources":["../../src/Uuid.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;AAWA,SAASA,kBAAkB,QAAQ,yBAAyB;AAC5D,SAASC,OAAO,EAAEC,MAAM,EAAEC,KAAK,QAAQ,QAAQ;AAE/C,OAAM,MAAOC,IAAK,sBAAQH,OAAO,CAACI,OAAO,EAGtC,CAAC,uBAAuB,CAAC;AAE5B;AACA,OAAO,MAAMC,QAAQ,gBAAsBH,KAAK,CAACI,OAAO,CAACH,IAAI,EAAE;EAC7DI,QAAQ,eAAEN,MAAM,CAACO,IAAI,CAAC,MAAMC,UAAU,CAACC,MAAM,CAACC,UAAU,EAAE;CAC3D,CAAC;AAEF;;;;;;;;;;;AAWA,OAAO,MAAMC,QAAQ,gBAAsBV,KAAK,CAACM,IAAI,CAACL,IAAI,EAAE,MAAK;EAC/D,MAAMU,IAAI,GAAGd,kBAAkB,EAAE;EACjC,OAAO;IAAEQ,QAAQ,EAAEN,MAAM,CAACO,IAAI,CAACK,IAAI;EAAC,CAAE;AACxC,CAAC,CAAC","ignoreList":[]}
|
package/dist/esm/decider.js
CHANGED
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
* append condition the read produced. That IS the optimistic-concurrency
|
|
40
40
|
* contract, in production and in a scenario alike — which is also why the
|
|
41
41
|
* Given/When/Then surface built on it exercises the real fold and the real store
|
|
42
|
-
* rather than a mock. It is a free function rather than a `Context.
|
|
42
|
+
* rather than a mock. It is a free function rather than a `Context.Service`,
|
|
43
43
|
* so it is still not the "production command-runner service method" a retrying
|
|
44
44
|
* `Layer` would need (ADR-0008): the correct retry remains
|
|
45
45
|
* `retryOnConflict(runDecider(...))`, wrapping the whole cycle so a fresh read
|
|
@@ -117,7 +117,7 @@ export const modelAtHead = projections => Effect.gen(function* () {
|
|
|
117
117
|
head
|
|
118
118
|
} = yield* store.read(composite.query);
|
|
119
119
|
const decoded = decode(events);
|
|
120
|
-
const state = yield* Stream.runFold(decoded, composite.initialState, (acc, event) => composite.evolve(acc, event));
|
|
120
|
+
const state = yield* Stream.runFold(decoded, () => composite.initialState, (acc, event) => composite.evolve(acc, event));
|
|
121
121
|
// LAZY: only once the fold has run to completion. A read that failed
|
|
122
122
|
// part-way folded a PREFIX, and a head recorded for it is a claim it did not
|
|
123
123
|
// earn — so the line below is unreachable on that path, deliberately.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decisionModel.js","names":["composeProjections","DcbEventStore","Effect","Option","Stream","decodeSlices","ambientLayeredCondition","assertServableAddition","recordQuery","modelAtHead","projections","gen","store","decode","composite","closeHop","query","events","head","read","decoded","state","runFold","initialState","acc","event","evolve","buildDecisionModel","ambient","isSome","appendCondition","value","failIfEventsMatch","after"],"sources":["../../src/decisionModel.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,SAIEA,kBAAkB,EAClBC,aAAa,QAER,iBAAiB;AACxB,SAASC,MAAM,EAAEC,MAAM,EAAEC,MAAM,QAAQ,QAAQ;AAC/C,SAASC,YAAY,QAAQ,aAAU;AAGvC,SACEC,uBAAuB,EACvBC,sBAAsB,EACtBC,WAAW,QAEN,iBAAc;AAOrB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyDA,OAAO,MAAMC,WAAW,GACtBC,WAAc,IAMdR,MAAM,CAACS,GAAG,CAAC,aAAS;EAClB,MAAMC,KAAK,GAAG,OAAOX,aAAa;EAElC;EACA;EACA;EACA,MAAMY,MAAM,GAAGR,YAAY,CAACK,WAAW,CAAC;EAExC;EACA,MAAMI,SAAS,GAAGd,kBAAkB,CAClCU,WAA4C,CAC7C;EAED;EACA;EACA;EACA;EACA;EACA;EACA;EACA,OAAOH,sBAAsB,CAACG,WAA4C,CAAC;EAE3E;EACA;EACA;EACA,MAAMK,QAAQ,GAAG,OAAOP,WAAW,CAACM,SAAS,CAACE,KAAK,CAAC;EAEpD,MAAM;IAAEC,MAAM;IAAEC;EAAI,CAAE,GAAG,OAAON,KAAK,CAACO,IAAI,CAACL,SAAS,CAACE,KAAK,CAAC;EAE3D,MAAMI,OAAO,GAAGP,MAAM,CAACI,MAAM,CAAC;EAE9B,MAAMI,KAAK,GAAI,OAAOjB,MAAM,CAACkB,OAAO,CAClCF,OAAO,
|
|
1
|
+
{"version":3,"file":"decisionModel.js","names":["composeProjections","DcbEventStore","Effect","Option","Stream","decodeSlices","ambientLayeredCondition","assertServableAddition","recordQuery","modelAtHead","projections","gen","store","decode","composite","closeHop","query","events","head","read","decoded","state","runFold","initialState","acc","event","evolve","buildDecisionModel","ambient","isSome","appendCondition","value","failIfEventsMatch","after"],"sources":["../../src/decisionModel.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,SAIEA,kBAAkB,EAClBC,aAAa,QAER,iBAAiB;AACxB,SAASC,MAAM,EAAEC,MAAM,EAAEC,MAAM,QAAQ,QAAQ;AAC/C,SAASC,YAAY,QAAQ,aAAU;AAGvC,SACEC,uBAAuB,EACvBC,sBAAsB,EACtBC,WAAW,QAEN,iBAAc;AAOrB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyDA,OAAO,MAAMC,WAAW,GACtBC,WAAc,IAMdR,MAAM,CAACS,GAAG,CAAC,aAAS;EAClB,MAAMC,KAAK,GAAG,OAAOX,aAAa;EAElC;EACA;EACA;EACA,MAAMY,MAAM,GAAGR,YAAY,CAACK,WAAW,CAAC;EAExC;EACA,MAAMI,SAAS,GAAGd,kBAAkB,CAClCU,WAA4C,CAC7C;EAED;EACA;EACA;EACA;EACA;EACA;EACA;EACA,OAAOH,sBAAsB,CAACG,WAA4C,CAAC;EAE3E;EACA;EACA;EACA,MAAMK,QAAQ,GAAG,OAAOP,WAAW,CAACM,SAAS,CAACE,KAAK,CAAC;EAEpD,MAAM;IAAEC,MAAM;IAAEC;EAAI,CAAE,GAAG,OAAON,KAAK,CAACO,IAAI,CAACL,SAAS,CAACE,KAAK,CAAC;EAE3D,MAAMI,OAAO,GAAGP,MAAM,CAACI,MAAM,CAAC;EAE9B,MAAMI,KAAK,GAAI,OAAOjB,MAAM,CAACkB,OAAO,CAClCF,OAAO,EACP,MAAMN,SAAS,CAACS,YAAY,EAC5B,CAACC,GAAG,EAAEC,KAAK,KAAKX,SAAS,CAACY,MAAM,CAACF,GAAG,EAAEC,KAAK,CAAC,CACvB;EAEvB;EACA;EACA;EACA,OAAOV,QAAQ,CAACG,IAAI,CAAC;EAErB,OAAO;IAAEG,KAAK;IAAEH;EAAI,CAAE;AACxB,CAAC,CAAC;AAEJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,OAAO,MAAMS,kBAAkB,GAC7BjB,WAAc,IASdR,MAAM,CAACS,GAAG,CAAC,aAAS;EAClB,MAAM;IAAEU,KAAK;IAAEH;EAAI,CAAE,GAAG,OAAOT,WAAW,CAACC,WAAW,CAAC;EAEvD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,MAAMkB,OAAO,GAAG,OAAOtB,uBAAuB;EAC9C,IAAIH,MAAM,CAAC0B,MAAM,CAACD,OAAO,CAAC,EAAE;IAC1B,OAAO;MAAEP,KAAK;MAAES,eAAe,EAAEF,OAAO,CAACG;IAAK,CAAE;EAClD;EAEA;EACA,OAAO;IACLV,KAAK;IACLS,eAAe,EAAE;MACfE,iBAAiB,EAAEhC,kBAAkB,CACnCU,WAA4C,CAC7C,CAACM,KAAK;MACPiB,KAAK,EAAEf;;GAEV;AACH,CAAC,CAAC","ignoreList":[]}
|
package/dist/esm/decode.js
CHANGED
|
@@ -29,9 +29,9 @@ import { Serializer } from "./Serializer.js";
|
|
|
29
29
|
* last, an ordering the record does not express and its author never chose.
|
|
30
30
|
* Every event of that type is then decoded against the wrong def for one of the
|
|
31
31
|
* slices, and where the two shapes overlap that failure is SILENT rather than a
|
|
32
|
-
* `CodecError`: `Schema.
|
|
33
|
-
* (`effect@
|
|
34
|
-
* `'error'`
|
|
32
|
+
* `CodecError`: `Schema.decodeUnknownEffect` defaults `onExcessProperty` to
|
|
33
|
+
* `'ignore'` (`effect@4`'s `SchemaAST.ts` runs its excess-key loop only under
|
|
34
|
+
* `'error'`), so a field the other def declared is dropped, not
|
|
35
35
|
* reported, and the fold downstream is handed a payload quietly missing it.
|
|
36
36
|
*
|
|
37
37
|
* **Why a throw, and why here rather than at the read side's wiring gate.**
|
|
@@ -45,8 +45,8 @@ import { Serializer } from "./Serializer.js";
|
|
|
45
45
|
* the write path merges before its first `store.read`, and the read side
|
|
46
46
|
* merges after that gate and before it forks the pipeline — and inside
|
|
47
47
|
* their `Effect.gen`s a throw becomes a DEFECT rather than an escaping exception
|
|
48
|
-
* (`effect@
|
|
49
|
-
* `
|
|
48
|
+
* (`effect@4`'s fibre run loop catches a thrown value and converts it with
|
|
49
|
+
* `exitDie`), which is the classification a mis-wiring already has on both
|
|
50
50
|
* sides of the library.
|
|
51
51
|
*
|
|
52
52
|
* The sentence names BOTH slices. The two halves of this mistake are in
|
package/dist/esm/decode.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decode.js","names":["Effect","Stream","deserialiseThenDecode","CodecError","Serializer","mergeSliceSchemas","projections","schemas","Map","contributedBy","key","Object","keys","slice","type","schema","owner","get","undefined","Error","set","decodeEvents","events","unwrap","map","serializer","pipe","mapEffect","sequenced","event","fail","reason","data","payload","decodeSlices","slices"],"sources":["../../src/decode.ts"],"sourcesContent":[null],"mappings":"AAiDA,SAASA,MAAM,EAAeC,MAAM,QAAQ,QAAQ;AAKpD,SAASC,qBAAqB,QAAQ,4BAAyB;AAC/D,SAASC,UAAU,QAAQ,aAAU;AAErC,SAASC,UAAU,QAAQ,iBAAc;AAEzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DA,MAAMC,iBAAiB,GACrBC,WAAc,
|
|
1
|
+
{"version":3,"file":"decode.js","names":["Effect","Stream","deserialiseThenDecode","CodecError","Serializer","mergeSliceSchemas","projections","schemas","Map","contributedBy","key","Object","keys","slice","type","schema","owner","get","undefined","Error","set","decodeEvents","events","unwrap","map","serializer","pipe","mapEffect","sequenced","event","fail","reason","data","payload","decodeSlices","slices"],"sources":["../../src/decode.ts"],"sourcesContent":[null],"mappings":"AAiDA,SAASA,MAAM,EAAeC,MAAM,QAAQ,QAAQ;AAKpD,SAASC,qBAAqB,QAAQ,4BAAyB;AAC/D,SAASC,UAAU,QAAQ,aAAU;AAErC,SAASC,UAAU,QAAQ,iBAAc;AAEzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DA,MAAMC,iBAAiB,GACrBC,WAAc,IACoD;EAClE,MAAMC,OAAO,GAAG,IAAIC,GAAG,EAAqD;EAC5E;EACA;EACA;EACA;EACA,MAAMC,aAAa,GAAG,IAAID,GAAG,EAAkB;EAC/C,KAAK,MAAME,GAAG,IAAIC,MAAM,CAACC,IAAI,CAACN,WAAW,CAAC,EAAE;IAC1C,MAAMO,KAAK,GAAGP,WAAW,CAACI,GAAG,CAAC;IAC9B,KAAK,MAAM,CAACI,IAAI,EAAEC,MAAM,CAAC,IAAIF,KAAK,CAACN,OAAO,EAAE;MAC1C,MAAMS,KAAK,GAAGP,aAAa,CAACQ,GAAG,CAACH,IAAI,CAAC;MACrC,IAAIE,KAAK,KAAKE,SAAS,IAAIX,OAAO,CAACU,GAAG,CAACH,IAAI,CAAC,KAAKC,MAAM,EAAE;QACvD,MAAM,IAAII,KAAK,CACb,yBAAyBL,IAAI,gBAAgBE,KAAK,UAAUN,GAAG,KAAK,GAClE,gEAAgE,GAChE,kEAAkE,GAClE,+BAA+B,CAClC;MACH;MACAH,OAAO,CAACa,GAAG,CAACN,IAAI,EAAEC,MAAmD,CAAC;MACtEN,aAAa,CAACW,GAAG,CAACN,IAAI,EAAEJ,GAAG,CAAC;IAC9B;EACF;EACA,OAAOH,OAAO;AAChB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,MAAMc,YAAY,GACXd,OAAyD,IAE5De,MAA2C,IAE3CrB,MAAM,CAACsB,MAAM,CACXvB,MAAM,CAACwB,GAAG,CAACpB,UAAU,EAAGqB,UAAU,IAChCH,MAAM,CAACI,IAAI,CACTzB,MAAM,CAAC0B,SAAS,CAAEC,SAAS,IAAI;EAC7B,MAAMb,MAAM,GAAGR,OAAO,CAACU,GAAG,CAACW,SAAS,CAACC,KAAK,CAACf,IAAI,CAAC;EAChD,IAAIC,MAAM,KAAKG,SAAS,EAAE;IACxB,OAAOlB,MAAM,CAAC8B,IAAI,CAChB,IAAI3B,UAAU,CAAC;MACb4B,MAAM,EAAE,6BAA6BH,SAAS,CAACC,KAAK,CAACf,IAAI;KAC1D,CAAC,CACH;EACH;EACA,OAAOZ,qBAAqB,CAC1BuB,UAAU,EACVV,MAAM,EACNa,SAAS,CAACC,KAAK,CAACG,IAAI,CACrB,CAACN,IAAI,CACJ1B,MAAM,CAACwB,GAAG,CAAES,OAAO,KAAoB;IAAEL,SAAS;IAAEK;EAAO,CAAE,CAAC,CAAC,CAChE;AACH,CAAC,CAAC,CACH,CACF,CACF;AAEL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,OAAO,MAAMC,YAAY,GACvBC,MAAS,IAOLd,YAAY,CAAChB,iBAAiB,CAAC8B,MAAM,CAAC,CAAC","ignoreList":[]}
|
|
@@ -6,7 +6,7 @@ export const deserialiseThenDecode = (serializer, schema, bytes) => Effect.try({
|
|
|
6
6
|
reason: 'deserialise',
|
|
7
7
|
cause
|
|
8
8
|
})
|
|
9
|
-
}).pipe(Effect.flatMap(raw => Schema.
|
|
9
|
+
}).pipe(Effect.flatMap(raw => Schema.decodeUnknownEffect(schema)(raw).pipe(Effect.mapError(cause => new CodecError({
|
|
10
10
|
reason: 'decode',
|
|
11
11
|
cause
|
|
12
12
|
})))));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deserialiseThenDecode.js","names":["Effect","Schema","CodecError","deserialiseThenDecode","serializer","schema","bytes","try","deserialise","catch","cause","reason","pipe","flatMap","raw","
|
|
1
|
+
{"version":3,"file":"deserialiseThenDecode.js","names":["Effect","Schema","CodecError","deserialiseThenDecode","serializer","schema","bytes","try","deserialise","catch","cause","reason","pipe","flatMap","raw","decodeUnknownEffect","mapError"],"sources":["../../src/deserialiseThenDecode.ts"],"sourcesContent":[null],"mappings":"AAyDA,SAASA,MAAM,EAAEC,MAAM,QAAQ,QAAQ;AACvC,SAASC,UAAU,QAAQ,aAAU;AAGrC,OAAO,MAAMC,qBAAqB,GAAGA,CACnCC,UAAoD,EACpDC,MAAkC,EAClCC,KAAiB,KAEjBN,MAAM,CAACO,GAAG,CAAC;EACTA,GAAG,EAAEA,CAAA,KAAMH,UAAU,CAACI,WAAW,CAACF,KAAK,CAAC;EACxCG,KAAK,EAAGC,KAAK,IAAK,IAAIR,UAAU,CAAC;IAAES,MAAM,EAAE,aAAa;IAAED;EAAK,CAAE;CAClE,CAAC,CAACE,IAAI,CACLZ,MAAM,CAACa,OAAO,CAAEC,GAAG,IACjBb,MAAM,CAACc,mBAAmB,CAACV,MAAM,CAAC,CAACS,GAAG,CAAC,CAACF,IAAI,CAC1CZ,MAAM,CAACgB,QAAQ,CAAEN,KAAK,IAAK,IAAIR,UAAU,CAAC;EAAES,MAAM,EAAE,QAAQ;EAAED;AAAK,CAAE,CAAC,CAAC,CACxE,CACF,CACF","ignoreList":[]}
|
package/dist/esm/errors.js
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* never defects.
|
|
4
4
|
*
|
|
5
5
|
* `CodecError` covers every serialisation/`Schema` failure on the codec path
|
|
6
|
-
* (deserialise threw, `Schema.
|
|
6
|
+
* (deserialise threw, `Schema.decodeUnknownEffect`/`encodeEffect` produced a
|
|
7
|
+
* `SchemaError`, a
|
|
7
8
|
* wrong/absent encryption key surfaced through a `Schema` transform, or a
|
|
8
9
|
* `tagsFor` mapper threw while deriving an event's tags). It carries a
|
|
9
10
|
* human-readable `reason` and the underlying `cause` (exact-optional).
|
|
@@ -38,9 +39,10 @@ export class CodecError extends /*#__PURE__*/Data.TaggedError('CodecError') {
|
|
|
38
39
|
*
|
|
39
40
|
* A GETTER rather than a second field, so `reason` stays the single declaration.
|
|
40
41
|
* It is visible because `Data.TaggedError`'s constructor is
|
|
41
|
-
* `super(args?.message, …)` followed by
|
|
42
|
-
* against `effect@
|
|
43
|
-
* nothing shadows this prototype accessor
|
|
42
|
+
* `super(args?.message, …)` followed by copying the args' own enumerable keys
|
|
43
|
+
* onto the instance (verified against `effect@4`'s `internal/core.ts`): the
|
|
44
|
+
* args above carry no `message`, so nothing shadows this prototype accessor
|
|
45
|
+
* with an own property.
|
|
44
46
|
*/
|
|
45
47
|
get message() {
|
|
46
48
|
return this.reason;
|
package/dist/esm/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","names":["Data","CodecError","TaggedError","message","reason","UnknownEventType","type"],"sources":["../../src/errors.ts"],"sourcesContent":[null],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"errors.js","names":["Data","CodecError","TaggedError","message","reason","UnknownEventType","type"],"sources":["../../src/errors.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;AAcA,SAASA,IAAI,QAAQ,QAAQ;AAE7B;AACA,OAAM,MAAOC,UAAW,sBAAQD,IAAI,CAACE,WAAW,CAAC,YAAY,CAG3D;EACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6BA,IAAaC,OAAOA,CAAA;IAClB,OAAO,IAAI,CAACC,MAAM;EACpB;;AAGF;AACA,OAAM,MAAOC,gBAAiB,sBAAQL,IAAI,CAACE,WAAW,CAAC,kBAAkB,CAEvE;EACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8BA,IAAaC,OAAOA,CAAA;IAClB,OAAO,eAAe,IAAI,CAACG,IAAI,0BAA0B;EAC3D","ignoreList":[]}
|