@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
|
@@ -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
|
-
declare const Serializer_base: Context.
|
|
14
|
+
declare const Serializer_base: Context.ServiceClass<Serializer, "@kairos-es/codec/Serializer", {
|
|
15
15
|
readonly serialise: (v: unknown) => Uint8Array;
|
|
16
16
|
readonly deserialise: (b: Uint8Array) => unknown;
|
|
17
17
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Serializer.d.ts","sourceRoot":"","sources":["../../src/Serializer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;;wBAKf,CAAC,CAAC,EAAE,OAAO,KAAK,UAAU;0BACxB,CAAC,CAAC,EAAE,UAAU,KAAK,OAAO;;AAJpD,qBAAa,UAAW,SAAQ,
|
|
1
|
+
{"version":3,"file":"Serializer.d.ts","sourceRoot":"","sources":["../../src/Serializer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;;wBAKf,CAAC,CAAC,EAAE,OAAO,KAAK,UAAU;0BACxB,CAAC,CAAC,EAAE,UAAU,KAAK,OAAO;;AAJpD,qBAAa,UAAW,SAAQ,eAME;CAAG;AAKrC;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,KAAK,CAAC,UAAU,CAMrD,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Context, Effect, Layer } from 'effect';
|
|
2
|
-
declare const Uuid_base: Context.
|
|
2
|
+
declare const Uuid_base: Context.ServiceClass<Uuid, "@kairos-es/codec/Uuid", {
|
|
3
3
|
readonly generate: Effect.Effect<string>;
|
|
4
4
|
}>;
|
|
5
5
|
export declare class Uuid extends Uuid_base {
|
|
@@ -9,9 +9,12 @@ export declare const UuidLive: Layer.Layer<Uuid>;
|
|
|
9
9
|
/**
|
|
10
10
|
* A deterministic uuid layer for suites, wrapping core's shared
|
|
11
11
|
* `makeSequentialUuid` (the single source of truth for the counter scheme).
|
|
12
|
-
* Each layer
|
|
12
|
+
* Each BUILD of the layer makes a fresh generator, so it owns its own counter and
|
|
13
13
|
* yields a stable v4-shaped sequence `00000000-0000-4000-8000-<12 hex>` starting
|
|
14
|
-
* at `...000000000000`.
|
|
14
|
+
* at `...000000000000`. A build is not one per `Effect.provide`: Effect memoises
|
|
15
|
+
* a layer across the provisions that share a memo map, so a nested second
|
|
16
|
+
* provision of this layer continues the counter rather than restarting it, and
|
|
17
|
+
* `Layer.fresh` is the way to ask for a restart. Generation is wrapped in `Effect.sync` because the
|
|
15
18
|
* generator advances its counter (a side effect on each call).
|
|
16
19
|
*/
|
|
17
20
|
export declare const UuidTest: Layer.Layer<Uuid>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Uuid.d.ts","sourceRoot":"","sources":["../../src/Uuid.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;;uBAIxB,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;;AAF5C,qBAAa,IAAK,SAAQ,
|
|
1
|
+
{"version":3,"file":"Uuid.d.ts","sourceRoot":"","sources":["../../src/Uuid.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;;uBAIxB,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;;AAF5C,qBAAa,IAAK,SAAQ,SAGE;CAAG;AAE/B,6DAA6D;AAC7D,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,KAAK,CAAC,IAAI,CAErC,CAAA;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,KAAK,CAAC,IAAI,CAGrC,CAAA"}
|
|
@@ -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
|
|
@@ -132,7 +132,7 @@ export interface Decider<P extends Record<string, SliceProjection>, Command, E =
|
|
|
132
132
|
* unioning them. Against the shaped target `E` therefore came out as whichever
|
|
133
133
|
* branch won, and every other branch was then rejected against it. Inference to
|
|
134
134
|
* a NAKED type variable takes the union whole, which is why `Eff` is the
|
|
135
|
-
* parameter and `Effect.
|
|
135
|
+
* parameter and `Effect.Error` / `Effect.Services` recover the two
|
|
136
136
|
* channels afterwards: those do distribute across a union of effects.
|
|
137
137
|
*
|
|
138
138
|
* The constraint on `Eff` is load-bearing twice over. It is what still refuses a
|
|
@@ -170,13 +170,13 @@ export interface Decider<P extends Record<string, SliceProjection>, Command, E =
|
|
|
170
170
|
* them in would state the same requirement twice and make an ordinary decider
|
|
171
171
|
* read as though it carried an extra one, though the set `runDecider` ends up
|
|
172
172
|
* asking for is identical either way. The exclusion cannot swallow a caller's
|
|
173
|
-
* own service by accident: a `Context.
|
|
174
|
-
* a literal `
|
|
175
|
-
* `@kairos-es/codec/Serializer` matches — and a
|
|
173
|
+
* own service by accident: a `Context.Service` class's requirement type carries
|
|
174
|
+
* its key as a literal `key` field, so only a service declared under `@kairos-es/codec/Uuid` or
|
|
175
|
+
* `@kairos-es/codec/Serializer` matches — and a service under that key IS that
|
|
176
176
|
* service, context being keyed by the same string at runtime.
|
|
177
177
|
*/
|
|
178
|
-
export declare function decider<P extends Record<string, SliceProjection>, Command, Eff extends Effect.Effect<Arr.NonEmptyReadonlyArray<DcbEvent>, unknown, unknown>>(projections: (command: Command) => P, decide: (state: CompositeState<P>, command: Command) => Eff): Decider<P, Command, Effect.
|
|
179
|
-
export declare function decider<P extends Record<string, SliceProjection>, Command, Eff extends Effect.Effect<DecisionOutput, unknown, unknown>>(projections: (command: Command) => P, decide: (state: CompositeState<P>, command: Command) => Eff): Decider<P, Command, Effect.
|
|
178
|
+
export declare function decider<P extends Record<string, SliceProjection>, Command, Eff extends Effect.Effect<Arr.NonEmptyReadonlyArray<DcbEvent>, unknown, unknown>>(projections: (command: Command) => P, decide: (state: CompositeState<P>, command: Command) => Eff): Decider<P, Command, Effect.Error<Eff>, Exclude<Effect.Services<Eff>, Serializer | Uuid>>;
|
|
179
|
+
export declare function decider<P extends Record<string, SliceProjection>, Command, Eff extends Effect.Effect<DecisionOutput, unknown, unknown>>(projections: (command: Command) => P, decide: (state: CompositeState<P>, command: Command) => Eff): Decider<P, Command, Effect.Error<Eff>, Exclude<Effect.Services<Eff>, Serializer | Uuid>, DecisionOutput>;
|
|
180
180
|
/**
|
|
181
181
|
* Run the full DCB command cycle for a decider against the ambient
|
|
182
182
|
* `DcbEventStore`: build the decision model (real read + decode + fold), decide,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decider.d.ts","sourceRoot":"","sources":["../../src/decider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiEG;AAEH,OAAO,KAAK,EACV,qBAAqB,EACrB,cAAc,EACd,QAAQ,EACT,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,KAAK,EAAE,KAAK,IAAI,GAAG,EAAE,MAAM,QAAQ,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,cAAc,EAEpB,MAAM,YAAY,CAAA;AACnB,OAAO,EAAsB,KAAK,aAAa,EAAE,MAAM,iBAA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E,UAAU,GAAG,IAAI,CAAC,EAChD,cAAc,CACf,CAAA;AAiBD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,UAAU,GACrB,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,EACzC,OAAO,EACP,CAAC,EACD,CAAC,EACD,CAAC,SAAS,cAAc,GAAG,GAAG,CAAC,qBAAqB,CAAC,QAAQ,CAAC,EAE9D,SAAS,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EACrC,SAAS,OAAO,KACf,MAAM,CAAC,MAAM,CACd,cAAc,CAAC,CAAC,CAAC,EACjB,CAAC,GAAG,UAAU,GAAG,qBAAqB,GAAG,oBAAoB,EAC7D,aAAa,GAAG,UAAU,GAAG,IAAI,GAAG,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAgBtD,CAAA"}
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
* channels; an overloaded step would lose both to `unknown`.
|
|
67
67
|
*
|
|
68
68
|
* `decider(…)` cannot be served by a conditional at all. Its `O` is derived from
|
|
69
|
-
* the SUCCESS of an effect type variable, and `Effect.
|
|
69
|
+
* the SUCCESS of an effect type variable, and `Effect.Success` of a type
|
|
70
70
|
* variable is itself deferred, so a wrapper that copies `decider`'s own generics
|
|
71
71
|
* would get a `Decider` whose `O` nothing can resolve, and a runner result that
|
|
72
72
|
* is not `Position`. So `decider` is declared TWICE, which asks the question by
|
|
@@ -100,7 +100,7 @@ export declare const UnchangedTypeId: unique symbol;
|
|
|
100
100
|
export type UnchangedTypeId = typeof UnchangedTypeId;
|
|
101
101
|
declare const Unchanged_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]; }>) => Readonly<A> & {
|
|
102
102
|
readonly _tag: "Unchanged";
|
|
103
|
-
};
|
|
103
|
+
} & import("effect/Pipeable").Pipeable;
|
|
104
104
|
/**
|
|
105
105
|
* "Nothing to do: this work is already done." A runner that receives it appends
|
|
106
106
|
* nothing and returns it in place of a `Position`.
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
* than memory.
|
|
21
21
|
*
|
|
22
22
|
* Be precise about what adding `concurrency` here would and would not cost,
|
|
23
|
-
* because the obvious reason is the wrong one. Effect
|
|
23
|
+
* because the obvious reason is the wrong one. Effect's `mapEffect` is
|
|
24
24
|
* order-PRESERVING even when concurrent — reordering needs the separate
|
|
25
|
-
* `unordered: true` option (verified against
|
|
26
|
-
*
|
|
25
|
+
* `unordered: true` option (verified against `effect@4`'s `Channel.mapEffect`,
|
|
26
|
+
* which takes the ordered path unless that option is set) — so a bare
|
|
27
27
|
* `concurrency` would NOT hand the fold its events out of position order. What
|
|
28
28
|
* it would actually cost is the back-pressure above, and it would run
|
|
29
29
|
* application-authored `Schema` transforms (an ADR-0004 decryption hook, say)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decode.d.ts","sourceRoot":"","sources":["../../src/decode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AACnE,OAAO,EAAuB,MAAM,EAAE,MAAM,QAAQ,CAAA;AAIpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAEpD,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"decode.d.ts","sourceRoot":"","sources":["../../src/decode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AACnE,OAAO,EAAuB,MAAM,EAAE,MAAM,QAAQ,CAAA;AAIpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAEpD,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAoJzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,EACpE,QAAQ,CAAC,KACR,CAAC,CAAC,CAAC,EAAE,CAAC,EACP,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC,EAAE,CAAC,CAAC,KACxC,MAAM,CAAC,MAAM,CAChB,YAAY,EACZ,CAAC,GAAG,UAAU,EACd,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,GAAG,UAAU,CAClC,CAA4C,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The two-step every decode in this package performs, in one implementation:
|
|
3
3
|
* deserialise the wire bytes through the `Serializer` its caller already holds,
|
|
4
|
-
* then `Schema.
|
|
4
|
+
* then `Schema.decodeUnknownEffect` the result, each half's failure wrapped as the
|
|
5
5
|
* `CodecError` whose `reason` says WHICH half failed.
|
|
6
6
|
*
|
|
7
7
|
* **What it is the single home of.** The two `reason` strings `'deserialise'`
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* as a function and not as a second test.
|
|
18
18
|
*
|
|
19
19
|
* **The order is contract, not accident.** Deserialise has to run first because
|
|
20
|
-
* `Schema.
|
|
20
|
+
* `Schema.decodeUnknownEffect` has nothing to read until it has, and the observable
|
|
21
21
|
* consequence is that the two reasons PARTITION the causes an operator acts on:
|
|
22
22
|
* rotten bytes are always `'deserialise'` and never `'decode'`, so a storage or
|
|
23
23
|
* producer problem never arrives dressed as schema drift. Swapping the labels
|
|
@@ -58,5 +58,5 @@ import type { Context } from 'effect';
|
|
|
58
58
|
import { Effect, Schema } from 'effect';
|
|
59
59
|
import { CodecError } from './errors.js';
|
|
60
60
|
import type { Serializer } from './Serializer.js';
|
|
61
|
-
export declare const deserialiseThenDecode: <R>(serializer: Context.
|
|
61
|
+
export declare const deserialiseThenDecode: <R>(serializer: Context.Service.Shape<typeof Serializer>, schema: Schema.Decoder<unknown, R>, bytes: Uint8Array) => Effect.Effect<unknown, CodecError, R>;
|
|
62
62
|
//# sourceMappingURL=deserialiseThenDecode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deserialiseThenDecode.d.ts","sourceRoot":"","sources":["../../src/deserialiseThenDecode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAE9C,eAAO,MAAM,qBAAqB,GAAI,CAAC,EACrC,YAAY,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"deserialiseThenDecode.d.ts","sourceRoot":"","sources":["../../src/deserialiseThenDecode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAE9C,eAAO,MAAM,qBAAqB,GAAI,CAAC,EACrC,YAAY,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,EACpD,QAAQ,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,EAClC,OAAO,UAAU,KAChB,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,UAAU,EAAE,CAAC,CAUpC,CAAA"}
|
|
@@ -30,9 +30,10 @@ export declare class CodecError extends CodecError_base<{
|
|
|
30
30
|
*
|
|
31
31
|
* A GETTER rather than a second field, so `reason` stays the single declaration.
|
|
32
32
|
* It is visible because `Data.TaggedError`'s constructor is
|
|
33
|
-
* `super(args?.message, …)` followed by
|
|
34
|
-
* against `effect@
|
|
35
|
-
* nothing shadows this prototype accessor
|
|
33
|
+
* `super(args?.message, …)` followed by copying the args' own enumerable keys
|
|
34
|
+
* onto the instance (verified against `effect@4`'s `internal/core.ts`): the
|
|
35
|
+
* args above carry no `message`, so nothing shadows this prototype accessor
|
|
36
|
+
* with an own property.
|
|
36
37
|
*/
|
|
37
38
|
get message(): string;
|
|
38
39
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":";;;AAgBA,2EAA2E;AAC3E,qBAAa,UAAW,SAAQ,gBAA+B;IAC7D,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CACzB,CAAC;IACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,IAAa,OAAO,IAAI,MAAM,CAE7B;CACF;;;;AAED,kFAAkF;AAClF,qBAAa,gBAAiB,SAAQ,sBAAqC;IACzE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACtB,CAAC;IACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACH,IAAa,OAAO,IAAI,MAAM,CAE7B;CACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Event definitions: a tagged `Schema` built through `event(type, fields,
|
|
3
|
-
* tagsFor)`. Each def is a `Schema<Payload, Wire, R>` plus its branded versioned
|
|
3
|
+
* tagsFor)`. Each def is a `Schema.Codec<Payload, Wire, R, R>` plus its branded versioned
|
|
4
4
|
* `type` (ADR-0005) captured *beside* the payload, and a required `tagsFor`
|
|
5
5
|
* mapper deriving the event's tags from its decoded payload (ADR-0006).
|
|
6
6
|
*
|
|
@@ -40,19 +40,29 @@ export type TagsFor<A> = (payload: A) => Arr.NonEmptyReadonlyArray<Tag>;
|
|
|
40
40
|
/**
|
|
41
41
|
* An event definition: its branded `type`, the `Schema` mapping its typed
|
|
42
42
|
* payload `A` to its wire encoding `I` (requiring `R`), and the `tagsFor` mapper
|
|
43
|
-
* that derives the event's tags from a decoded payload.
|
|
44
|
-
*
|
|
43
|
+
* that derives the event's tags from a decoded payload.
|
|
44
|
+
*
|
|
45
|
+
* `R` is ONE requirement for both directions, which is why the schema is a
|
|
46
|
+
* `Schema.Codec<A, I, R, R>` rather than leaving decoding and encoding services
|
|
47
|
+
* apart. A def is decoded on the read path and encoded by `toEvent`, so a
|
|
48
|
+
* consumer providing a def's services provides them for both; an application
|
|
49
|
+
* encryption transform needs its key either way. A struct whose two directions
|
|
50
|
+
* differ still fits, the codec being covariant in both, and `R` is then their
|
|
51
|
+
* union.
|
|
52
|
+
*
|
|
53
|
+
* `tagsFor` CONSUMES an `A`, so `EventDef` is invariant in `A` whatever the
|
|
54
|
+
* schema's own variance, and is therefore not declared `out A`.
|
|
45
55
|
*/
|
|
46
56
|
export interface EventDef<A = unknown, I = unknown, R = never> {
|
|
47
57
|
readonly type: EventType;
|
|
48
|
-
readonly schema: Schema.
|
|
58
|
+
readonly schema: Schema.Codec<A, I, R, R>;
|
|
49
59
|
readonly tagsFor: TagsFor<A>;
|
|
50
60
|
}
|
|
51
61
|
/**
|
|
52
|
-
* The heterogeneous bound
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
62
|
+
* The heterogeneous bound for arrays/records of mixed defs, where the precise
|
|
63
|
+
* `A`/`I` differ per element. `tagsFor` erases to `(a: any) => …`, which is
|
|
64
|
+
* harmless: only the write path (`toEvent`) calls it, and the registry/decode
|
|
65
|
+
* path never does (stored events already carry tags).
|
|
56
66
|
*/
|
|
57
67
|
export type EventDefAny = EventDef<any, any, unknown>;
|
|
58
68
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../src/event.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,KAAK,EAAE,KAAK,IAAI,GAAG,EAAE,MAAM,QAAQ,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B;;;;;GAKG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,KAAK,GAAG,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAA;AAEvE;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,QAAQ,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,KAAK;IAC3D,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;IACzC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAA;CAC7B;AAED;;;;;GAKG;AAEH,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,CAAA;AAErD;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,GAChB,KAAK,CAAC,IAAI,SAAS,MAAM,EACzB,MAAM,SAAS,MAAM,CAAC,MAAM,CAAC,MAAM,EAEnC,MAAM,IAAI,EACV,QAAQ,MAAM,EACd,SAAS,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAC3C;IACD,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS,CAAA;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IACtC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA;CAStD,CAAA"}
|
|
@@ -17,8 +17,9 @@
|
|
|
17
17
|
* on this path: the type is discovered at runtime, so no def was named to
|
|
18
18
|
* narrow it (see `registry.ts`).
|
|
19
19
|
*
|
|
20
|
-
* `toEvent(def, payload, { uuid?, occurredAt? })` produces a wire
|
|
21
|
-
* -> serialise, tags derived from `def.tagsFor`, clock + uuid from
|
|
20
|
+
* `toEvent(def, payload, { uuid?, occurredAt?, metadata? })` produces a wire
|
|
21
|
+
* event (encode -> serialise, tags derived from `def.tagsFor`, clock + uuid from
|
|
22
|
+
* services, metadata from the call or the optional ambient `MetadataSource`).
|
|
22
23
|
* Serialisation is a pluggable `Serializer` (JSON
|
|
23
24
|
* default). Encryption, when needed, is an *application*-authored `Schema`
|
|
24
25
|
* transform on a payload field; the codec only propagates its requirement and
|
|
@@ -122,6 +123,7 @@ export { buildDecisionModel, modelAtHead, type RequirementOf, } from './decision
|
|
|
122
123
|
export { decodeSlices } from './decode.js';
|
|
123
124
|
export { CodecError, UnknownEventType } from './errors.js';
|
|
124
125
|
export { type EventDef, type EventDefAny, event, type TagsFor } from './event.js';
|
|
126
|
+
export { MetadataSource } from './MetadataSource.js';
|
|
125
127
|
export { decideOnly, type Precondition, transact, unsafeAppend, } from './precondition.js';
|
|
126
128
|
export { type ProjectionBuilder, projection, type SliceProjection, } from './projection.js';
|
|
127
129
|
export { type CloseHop, type Hop, NoReadsRecorded, ReadLedger, TaglessSliceInLedger, } from './readLedger.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsHG;AAEH,OAAO,EAAE,KAAK,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAC7D,OAAO,EACL,QAAQ,EACR,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,WAAW,EACX,SAAS,EACT,eAAe,GAChB,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,KAAK,aAAa,GACnB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AACvC,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AACvD,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,WAAW,EAAE,KAAK,EAAE,KAAK,OAAO,EAAE,MAAM,SAAS,CAAA;AAC9E,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EACL,UAAU,EACV,KAAK,YAAY,EACjB,QAAQ,EACR,YAAY,GACb,MAAM,gBAAgB,CAAA;AACvB,OAAO,EACL,KAAK,iBAAiB,EACtB,UAAU,EACV,KAAK,eAAe,GACrB,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,GAAG,EACR,eAAe,EACf,UAAU,EACV,oBAAoB,GACrB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,YAAY,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAA;AACxD,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA"}
|
|
@@ -137,7 +137,7 @@ import type { Uuid } from './Uuid.js';
|
|
|
137
137
|
* path meant to deny the input cheaply. Wrap such work in `Effect.suspend`.
|
|
138
138
|
*/
|
|
139
139
|
export interface Precondition<Id, Service, E, R> {
|
|
140
|
-
readonly tag: Context.
|
|
140
|
+
readonly tag: Context.Key<Id, Service>;
|
|
141
141
|
readonly evaluate: Effect.Effect<Service, E, R>;
|
|
142
142
|
}
|
|
143
143
|
/**
|
|
@@ -211,7 +211,7 @@ export declare const decideOnly: <P extends Record<string, SliceProjection>, Com
|
|
|
211
211
|
* condition here. If that turns up in practice, a composing override is the
|
|
212
212
|
* additive answer and this hatch is not it.
|
|
213
213
|
*
|
|
214
|
-
* `Effect.
|
|
214
|
+
* `Effect.updateContext` over
|
|
215
215
|
* `Context.omit(AppendIsOwned)` is what lets it through the store's ownership
|
|
216
216
|
* refusal — the one route, and `AppendIsOwned.ts` owns why removing the marker is
|
|
217
217
|
* the shape rather than a second tag or a sanctioning flag.
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* A `SliceProjection<S, R>` is a core `AnyProjection<S>` (directly composable —
|
|
6
6
|
* its `evolve` folds a `DecodedEvent`) enriched with the `type -> Schema` map
|
|
7
7
|
* `decodeSlices` merges and decodes through. That map's value type carries `R`
|
|
8
|
-
* covariantly (`Schema<unknown,
|
|
8
|
+
* covariantly (`Schema.Decoder<unknown, R>`), so the union of the defs'
|
|
9
9
|
* requirements flows to the decision model with no cast (and no phantom marker).
|
|
10
10
|
* Because `evolve` is already erased, a built slice drops straight into
|
|
11
11
|
* `composeProjections` — no `AnyProjection.of` ceremony.
|
|
@@ -27,7 +27,7 @@ import type { EventDef } from './event.js';
|
|
|
27
27
|
* (and the `out R` annotation keeps union-widening sound) with no phantom marker.
|
|
28
28
|
*/
|
|
29
29
|
export interface SliceProjection<out S = unknown, out R = unknown> extends AnyProjection<S> {
|
|
30
|
-
readonly schemas: ReadonlyMap<string, Schema.
|
|
30
|
+
readonly schemas: ReadonlyMap<string, Schema.Decoder<unknown, R>>;
|
|
31
31
|
}
|
|
32
32
|
/** The fluent builder: accumulate `.on(def, fold)` steps, then `.build()`. */
|
|
33
33
|
export interface ProjectionBuilder<S, R = never> {
|
|
@@ -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"}
|
|
@@ -76,7 +76,7 @@ export interface Hop {
|
|
|
76
76
|
readonly query: Query;
|
|
77
77
|
readonly head?: Position;
|
|
78
78
|
}
|
|
79
|
-
declare const ReadLedger_base: Context.
|
|
79
|
+
declare const ReadLedger_base: Context.ServiceClass<ReadLedger, "@kairos-es/codec/ReadLedger", {
|
|
80
80
|
/**
|
|
81
81
|
* File a query, and hand back the effect that will fill in its head.
|
|
82
82
|
*
|
|
@@ -101,7 +101,7 @@ declare const ReadLedger_base: Context.TagClass<ReadLedger, "@kairos-es/codec/Re
|
|
|
101
101
|
* requirement channel nothing is exactly what makes this change additive.
|
|
102
102
|
* `modelAtHead` is that path and is why the rule exists.
|
|
103
103
|
*
|
|
104
|
-
* A BRACKET-ONLY function is the opposite case and yields the
|
|
104
|
+
* A BRACKET-ONLY function is the opposite case and yields the service deliberately.
|
|
105
105
|
* `decideOnly` does, and naming the requirement is what turns *"call me inside a
|
|
106
106
|
* bracket"* from a runtime defect into a compile error — presence being the one
|
|
107
107
|
* direction the type system can decide here. So the test is what the function
|
|
@@ -117,8 +117,8 @@ export declare class ReadLedger extends ReadLedger_base {
|
|
|
117
117
|
* Fill in a recorded hop's head. Never called if the read does not complete.
|
|
118
118
|
*
|
|
119
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
|
|
121
|
-
* could not name it. `Hop` was exported and this was not — the same interface, two
|
|
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
122
|
* treatments.
|
|
123
123
|
*/
|
|
124
124
|
export type CloseHop = (head: Position) => Effect.Effect<void>;
|
|
@@ -1 +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;
|
|
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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;GAMG;AACH,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,MAAM,CACjD,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,CAK/B,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Event production (codec edge-helper): turn a typed payload into a wire
|
|
3
|
-
* `DcbEvent`. Encode is `Schema.
|
|
4
|
-
* `CodecError`; any encryption transform runs here, *before* serialisation)
|
|
3
|
+
* `DcbEvent`. Encode is `Schema.encodeEffect(def.schema)` (a `SchemaError`
|
|
4
|
+
* becomes a `CodecError`; any encryption transform runs here, *before* serialisation)
|
|
5
5
|
* then `serialiser.serialise`. The wire `tags` are derived from the def's
|
|
6
6
|
* required `tagsFor` mapper (ADR-0006) — they are never hand-passed, so two
|
|
7
7
|
* command sites emitting the same event type cannot tag it differently. A mapper
|
|
@@ -10,8 +10,15 @@
|
|
|
10
10
|
* comes from `options.uuid` or the `Uuid` service; `occurredAt` from
|
|
11
11
|
* `options.occurredAt` or the Effect clock (`DateTime.now`), keeping `core`
|
|
12
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.
|
|
13
20
|
*/
|
|
14
|
-
import type
|
|
21
|
+
import { type DcbEvent, Metadata } from '@kairos-es/core';
|
|
15
22
|
import { DateTime, Effect } from 'effect';
|
|
16
23
|
import { CodecError } from './errors.js';
|
|
17
24
|
import type { EventDef } from './event.js';
|
|
@@ -25,10 +32,14 @@ import { Uuid } from './Uuid.js';
|
|
|
25
32
|
* wire-envelope fields (the query surface), so a `tagsFor` mapper may only key
|
|
26
33
|
* off cleartext payload fields (ADR-0006). `uuid` / `occurredAt` are
|
|
27
34
|
* exact-optional overrides; absent, they come from the `Uuid` service and the
|
|
28
|
-
* Effect clock.
|
|
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'`.
|
|
29
39
|
*/
|
|
30
40
|
export declare const toEvent: <A, I, R>(def: EventDef<A, I, R>, payload: A, options?: {
|
|
31
41
|
readonly uuid?: string;
|
|
32
42
|
readonly occurredAt?: DateTime.Utc;
|
|
43
|
+
readonly metadata?: Metadata;
|
|
33
44
|
}) => Effect.Effect<DcbEvent, CodecError, Serializer | Uuid | R>;
|
|
34
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,8 @@
|
|
|
1
|
+
import { Context } from 'effect';
|
|
2
|
+
declare const MetadataSource_base: Context.ServiceClass<MetadataSource, "@kairos-es/codec/MetadataSource", {
|
|
3
|
+
readonly [x: string]: string;
|
|
4
|
+
}>;
|
|
5
|
+
export declare class MetadataSource extends MetadataSource_base {
|
|
6
|
+
}
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=MetadataSource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MetadataSource.d.ts","sourceRoot":"","sources":["../../src/MetadataSource.ts"],"names":[],"mappings":"AAsCA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;;;;AAEhC,qBAAa,cAAe,SAAQ,mBAEnC;CAAG"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The pluggable serialiser: the `Uint8Array` <-> value boundary applied
|
|
3
|
+
* *outside* `Schema`. Encode is `Schema.encodeEffect` then `serialise`; decode is
|
|
4
|
+
* `deserialise` then `Schema.decodeUnknownEffect`. Both codec paths read the same
|
|
5
|
+
* `Serializer` from context, so encode and decode cannot mismatch; swapping
|
|
6
|
+
* JSON for msgpack is a different layer with no schema or call-site changes.
|
|
7
|
+
*
|
|
8
|
+
* `deserialise` may throw synchronously (corrupt bytes): wrapping it as a
|
|
9
|
+
* `CodecError` is the *caller's* concern — every decode site wraps it in
|
|
10
|
+
* `Effect.try`. Keeping the service interface plain (no Effect) lets a layer be
|
|
11
|
+
* a trivial `Layer.succeed`.
|
|
12
|
+
*/
|
|
13
|
+
import { Context, Layer } from 'effect';
|
|
14
|
+
declare const Serializer_base: Context.ServiceClass<Serializer, "@kairos-es/codec/Serializer", {
|
|
15
|
+
readonly serialise: (v: unknown) => Uint8Array;
|
|
16
|
+
readonly deserialise: (b: Uint8Array) => unknown;
|
|
17
|
+
}>;
|
|
18
|
+
export declare class Serializer extends Serializer_base {
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The shipped default: JSON over UTF-8. `serialise` = `JSON.stringify` then
|
|
22
|
+
* `TextEncoder`; `deserialise` = `TextDecoder` then `JSON.parse` (which throws
|
|
23
|
+
* synchronously on corrupt bytes, wrapped to `CodecError` at the call site).
|
|
24
|
+
*/
|
|
25
|
+
export declare const SerializerDefault: Layer.Layer<Serializer>;
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=Serializer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Serializer.d.ts","sourceRoot":"","sources":["../../src/Serializer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;;wBAKf,CAAC,CAAC,EAAE,OAAO,KAAK,UAAU;0BACxB,CAAC,CAAC,EAAE,UAAU,KAAK,OAAO;;AAJpD,qBAAa,UAAW,SAAQ,eAME;CAAG;AAKrC;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,KAAK,CAAC,UAAU,CAMrD,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Context, Effect, Layer } from 'effect';
|
|
2
|
+
declare const Uuid_base: Context.ServiceClass<Uuid, "@kairos-es/codec/Uuid", {
|
|
3
|
+
readonly generate: Effect.Effect<string>;
|
|
4
|
+
}>;
|
|
5
|
+
export declare class Uuid extends Uuid_base {
|
|
6
|
+
}
|
|
7
|
+
/** Live uuid generation via WebCrypto (no `node:crypto`). */
|
|
8
|
+
export declare const UuidLive: Layer.Layer<Uuid>;
|
|
9
|
+
/**
|
|
10
|
+
* A deterministic uuid layer for suites, wrapping core's shared
|
|
11
|
+
* `makeSequentialUuid` (the single source of truth for the counter scheme).
|
|
12
|
+
* Each BUILD of the layer makes a fresh generator, so it owns its own counter and
|
|
13
|
+
* yields a stable v4-shaped sequence `00000000-0000-4000-8000-<12 hex>` starting
|
|
14
|
+
* at `...000000000000`. A build is not one per `Effect.provide`: Effect memoises
|
|
15
|
+
* a layer across the provisions that share a memo map, so a nested second
|
|
16
|
+
* provision of this layer continues the counter rather than restarting it, and
|
|
17
|
+
* `Layer.fresh` is the way to ask for a restart. Generation is wrapped in `Effect.sync` because the
|
|
18
|
+
* generator advances its counter (a side effect on each call).
|
|
19
|
+
*/
|
|
20
|
+
export declare const UuidTest: Layer.Layer<Uuid>;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=Uuid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Uuid.d.ts","sourceRoot":"","sources":["../../src/Uuid.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;;uBAIxB,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;;AAF5C,qBAAa,IAAK,SAAQ,SAGE;CAAG;AAE/B,6DAA6D;AAC7D,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,KAAK,CAAC,IAAI,CAErC,CAAA;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,KAAK,CAAC,IAAI,CAGrC,CAAA"}
|