@demlik/tea 0.20.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -2
- package/dist/agent/index.d.ts +36 -23
- package/dist/agent/index.js +12 -10
- package/dist/{chunk-UHAQ4PI6.js → chunk-2A5XTKQQ.js} +205 -59
- package/dist/chunk-2A5XTKQQ.js.map +1 -0
- package/dist/{chunk-JAKM53JF.js → chunk-7K7SEYCH.js} +16 -15
- package/dist/chunk-7K7SEYCH.js.map +1 -0
- package/dist/{chunk-RKVUVALV.js → chunk-A3QPMX5M.js} +31 -9
- package/dist/chunk-A3QPMX5M.js.map +1 -0
- package/dist/{chunk-DVNXEB7V.js → chunk-BVFS3ICC.js} +3 -3
- package/dist/chunk-BVFS3ICC.js.map +1 -0
- package/dist/{chunk-FTCYY2DO.js → chunk-CPE5ZQXQ.js} +3 -3
- package/dist/{chunk-FTCYY2DO.js.map → chunk-CPE5ZQXQ.js.map} +1 -1
- package/dist/chunk-DEAPNMKO.js +11 -0
- package/dist/chunk-DEAPNMKO.js.map +1 -0
- package/dist/{chunk-XWIE5V7R.js → chunk-ETRNSJCR.js} +4 -4
- package/dist/{chunk-XWIE5V7R.js.map → chunk-ETRNSJCR.js.map} +1 -1
- package/dist/chunk-FXWDDNGD.js +98 -0
- package/dist/chunk-FXWDDNGD.js.map +1 -0
- package/dist/chunk-GFGOQIEC.js +10 -0
- package/dist/chunk-GFGOQIEC.js.map +1 -0
- package/dist/{chunk-2R62Q5UK.js → chunk-IAHEYPYJ.js} +3 -3
- package/dist/{chunk-2R62Q5UK.js.map → chunk-IAHEYPYJ.js.map} +1 -1
- package/dist/{chunk-NGYFBD5G.js → chunk-J5JNLXO7.js} +3 -3
- package/dist/{chunk-NGYFBD5G.js.map → chunk-J5JNLXO7.js.map} +1 -1
- package/dist/{chunk-72CN3VPY.js → chunk-NFOGYDRS.js} +5 -5
- package/dist/{chunk-72CN3VPY.js.map → chunk-NFOGYDRS.js.map} +1 -1
- package/dist/{chunk-A73IJ27X.js → chunk-R2YNDRGL.js} +3 -3
- package/dist/{chunk-A73IJ27X.js.map → chunk-R2YNDRGL.js.map} +1 -1
- package/dist/{chunk-5HVKDHY6.js → chunk-R5NXOPL2.js} +3 -3
- package/dist/{chunk-5HVKDHY6.js.map → chunk-R5NXOPL2.js.map} +1 -1
- package/dist/chunk-RMBZ7YH7.js +52 -0
- package/dist/chunk-RMBZ7YH7.js.map +1 -0
- package/dist/{chunk-AIXC33SE.js → chunk-SHXUSTHM.js} +62 -15
- package/dist/chunk-SHXUSTHM.js.map +1 -0
- package/dist/{chunk-TAKPC6SD.js → chunk-UGTC33VH.js} +4 -4
- package/dist/{chunk-TAKPC6SD.js.map → chunk-UGTC33VH.js.map} +1 -1
- package/dist/{chunk-EA47MI5Q.js → chunk-VH5MYJ2K.js} +4 -4
- package/dist/{chunk-EA47MI5Q.js.map → chunk-VH5MYJ2K.js.map} +1 -1
- package/dist/{chunk-2774I242.js → chunk-WZEDIUWR.js} +21 -20
- package/dist/chunk-WZEDIUWR.js.map +1 -0
- package/dist/{chunk-TGJLXZAU.js → chunk-ZRRET3RP.js} +11 -11
- package/dist/chunk-ZRRET3RP.js.map +1 -0
- package/dist/{core-CtvAyPpH.d.ts → core-DNDAEhO2.d.ts} +9 -12
- package/dist/devtools/index.d.ts +4 -4
- package/dist/do/index.d.ts +103 -38
- package/dist/do/index.js +40 -21
- package/dist/do/index.js.map +1 -1
- package/dist/{drive-loop-Dw1sGSsW.d.ts → drive-loop-DlOEv49c.d.ts} +2 -2
- package/dist/{durable-effects-Ump5lSdO.d.ts → durable-effects-wLWEdy9H.d.ts} +1 -1
- package/dist/effect/index.d.ts +121 -28
- package/dist/effect/index.js +45 -31
- package/dist/effect/index.js.map +1 -1
- package/dist/extension/index.d.ts +3 -3
- package/dist/extension/index.js +2 -2
- package/dist/extension/index.js.map +1 -1
- package/dist/flow/index.d.ts +17 -13
- package/dist/flow/index.js +15 -12
- package/dist/flow/index.js.map +1 -1
- package/dist/idempotency/index.d.ts +3 -3
- package/dist/idempotency/index.js +3 -3
- package/dist/{index-CrcoVfd_.d.ts → index-9P1PaXIV.d.ts} +2 -2
- package/dist/{index-D3NY3VCN.d.ts → index-BBLI2WWN.d.ts} +1 -1
- package/dist/{index-Dl71V7kt.d.ts → index-C1WhBZ6a.d.ts} +4 -5
- package/dist/{index-CKtEKGyp.d.ts → index-C92SgNWz.d.ts} +3 -3
- package/dist/{index-CZZ3HI-Z.d.ts → index-CAsUE_d1.d.ts} +4 -4
- package/dist/{index-EIgfl83J.d.ts → index-CO34esWT.d.ts} +2 -2
- package/dist/{index-Bk2hBUdK.d.ts → index-COeX9Bmz.d.ts} +11 -9
- package/dist/{index-CVU7SK3a.d.ts → index-Cg0QXnzf.d.ts} +2 -2
- package/dist/index.d.ts +9 -9
- package/dist/index.js +2 -2
- package/dist/jev/index.d.ts +15 -15
- package/dist/jev/index.js +5 -5
- package/dist/jev/index.js.map +1 -1
- package/dist/laws-DTtCDDlU.d.ts +135 -0
- package/dist/loop-DReKGV1X.d.ts +70 -0
- package/dist/{machine-Dtre2TmN.d.ts → machine-C0WhOAyB.d.ts} +7 -7
- package/dist/machine-viz/index.d.ts +1 -1
- package/dist/machine-viz/index.js +2 -2
- package/dist/mem/index.d.ts +4 -3
- package/dist/mem/index.js +2 -2
- package/dist/mem/index.js.map +1 -1
- package/dist/node/index.d.ts +57 -9
- package/dist/node/index.js +175 -68
- package/dist/node/index.js.map +1 -1
- package/dist/otel/index.d.ts +28 -12
- package/dist/otel/index.js +25 -21
- package/dist/otel/index.js.map +1 -1
- package/dist/paginate/index.d.ts +4 -4
- package/dist/paginate/index.js +5 -5
- package/dist/parity/index.d.ts +11 -15
- package/dist/parity/index.js +4 -9
- package/dist/parity/index.js.map +1 -1
- package/dist/pbt/index.d.ts +279 -67
- package/dist/pbt/index.js +299 -58
- package/dist/pbt/index.js.map +1 -1
- package/dist/persistence/index.d.ts +10 -12
- package/dist/persistence/index.js +4 -4
- package/dist/promise/index.d.ts +118 -21
- package/dist/promise/index.js +6 -4
- package/dist/react/index.d.ts +34 -21
- package/dist/react/index.js +271 -42
- package/dist/react/index.js.map +1 -1
- package/dist/resilience/index.d.ts +6 -6
- package/dist/resilience/index.js +5 -5
- package/dist/{run-fiBe7pOG.d.ts → run-Cnw4qXj2.d.ts} +105 -23
- package/dist/{runtime-types-DEluQgGO.d.ts → runtime-types-CP-ykwgf.d.ts} +157 -29
- package/dist/testing/effect/index.d.ts +162 -9
- package/dist/testing/effect/index.js +110 -10
- package/dist/testing/effect/index.js.map +1 -1
- package/dist/testing/index.d.ts +6 -8
- package/dist/testing/index.js +4 -24
- package/dist/testing/index.js.map +1 -1
- package/dist/testing/promise/index.d.ts +4 -4
- package/dist/testing/promise/index.js +5 -5
- package/dist/timing/index.d.ts +4 -4
- package/dist/timing/index.js +4 -4
- package/dist/{types-CXNzlbAg.d.ts → types-S53WDy_h.d.ts} +1 -1
- package/dist/work-queue/index.d.ts +4 -4
- package/dist/work-queue/index.js +2 -2
- package/package.json +19 -17
- package/dist/chunk-2774I242.js.map +0 -1
- package/dist/chunk-AIXC33SE.js.map +0 -1
- package/dist/chunk-DVNXEB7V.js.map +0 -1
- package/dist/chunk-HX3C6LDK.js +0 -34
- package/dist/chunk-HX3C6LDK.js.map +0 -1
- package/dist/chunk-JAKM53JF.js.map +0 -1
- package/dist/chunk-RKVUVALV.js.map +0 -1
- package/dist/chunk-TGJLXZAU.js.map +0 -1
- package/dist/chunk-UHAQ4PI6.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as CtxArg } from './runtime-types-
|
|
1
|
+
import { C as CtxArg } from './runtime-types-CP-ykwgf.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* The default round bound when `opts.maxRounds` is omitted: **100**.
|
|
@@ -124,4 +124,4 @@ declare class DriveNoHandlerError<M, C> extends Error {
|
|
|
124
124
|
*/
|
|
125
125
|
declare function driveTraceOf<M, C>(err: unknown): readonly DriveTraceEntry<M, C>[] | undefined;
|
|
126
126
|
|
|
127
|
-
export {
|
|
127
|
+
export { type DriveOptions as D, type DriveResult as a, DEFAULT_MAX_ROUNDS as b, type DriveCtxArg as c, DriveNoHandlerError as d, DriveRoundsExceededError as e, type DriveTraceEntry as f, driveTraceOf as g };
|
package/dist/effect/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { T as TellAnswer } from '../loop-DReKGV1X.js';
|
|
2
|
+
import { Scope, Effect, Schema } from 'effect';
|
|
3
|
+
import { C as Cmd$1, c as Sub, M as Machine, k as CmdInput, b as CmdDef, f as TaggedError } from '../core-DNDAEhO2.js';
|
|
4
|
+
import { E as EffectRun } from '../run-Cnw4qXj2.js';
|
|
5
|
+
export { C as CellErrors, a as EffectBootingRun, b as EffectBootingRuntime, c as EffectInterpret, d as EffectInterpretCell, e as EffectRunOptions, f as EffectRunner, g as EffectRuntime, h as EffectSubscribe, I as InterpretServices, S as Stopped, i as StoreFailed, j as SubFailed, k as SubscribeServices, r as run } from '../run-Cnw4qXj2.js';
|
|
5
6
|
import '@standard-schema/spec';
|
|
6
|
-
import '../runtime-types-
|
|
7
|
+
import '../runtime-types-CP-ykwgf.js';
|
|
7
8
|
import 'effect/Cause';
|
|
8
9
|
import 'effect/Types';
|
|
9
10
|
|
|
@@ -14,30 +15,49 @@ import 'effect/Types';
|
|
|
14
15
|
* tea still runs one machine per `run` and keeps no table of runs (#312). A
|
|
15
16
|
* host that builds a tree of runs keeps its own table, ids and Msg names, and
|
|
16
17
|
* hands the steps that race to these functions: `spawn` starts a child and
|
|
17
|
-
* enrols it as one step, `stop` stops one child, and `tell`
|
|
18
|
-
*
|
|
18
|
+
* enrols it as one step, `stop` stops one child, and `tell` puts a Msg on a
|
|
19
|
+
* run's line without waiting for it.
|
|
19
20
|
*/
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
|
-
*
|
|
23
|
-
* the run
|
|
23
|
+
* Put `msg` on a run's line and answer at once. The answer means queued, not
|
|
24
|
+
* handled: the receiver's step has not run yet, and any result comes back later
|
|
25
|
+
* as its own Msg. So two machines can tell each other from their Cmd handlers
|
|
26
|
+
* and neither stops. `machine` is the machine `runtime` runs.
|
|
24
27
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
28
|
+
* The answer is `"queued"`, `"stopped"` for a run that is stopping or has
|
|
29
|
+
* stopped, or `"no_cell"` when its current State has no cell for the Msg. Msgs
|
|
30
|
+
* already in line have not folded yet, so a Msg that only a queued one makes
|
|
31
|
+
* acceptable answers `"no_cell"`.
|
|
32
|
+
*
|
|
33
|
+
* `runtime` is what `ready` succeeded with, or a spread of it. Those carry the
|
|
34
|
+
* run's line, and the type asks for it, so an `EffectRuntime` built by hand is a
|
|
35
|
+
* compile error. So is the handle `run` yielded, with a store or without one: wait
|
|
36
|
+
* for `ready`.
|
|
37
|
+
*
|
|
38
|
+
* `tell` carries no failure in its type. A hand-built object cast past the type
|
|
39
|
+
* has no line to put a Msg on, and `tell` dies with a defect there.
|
|
40
|
+
*
|
|
41
|
+
* What happens after `"queued"` is the receiver's. Two `tell`s from one sender
|
|
42
|
+
* fold in the order they were sent. A failed save or a cell's failure goes to
|
|
43
|
+
* the receiver's `onError`, never back to the sender. A Msg whose cell is gone
|
|
44
|
+
* by its turn is dropped without a word, and a `stop()` that gives up drops
|
|
45
|
+
* what is still in line and counts it, per Msg type, in its
|
|
46
|
+
* `DrainTimeoutNotice`.
|
|
47
|
+
*
|
|
48
|
+
* Two hand-written waiting `runtime.dispatch(...)` calls into each other, one
|
|
49
|
+
* from each machine's Cmd handler, still stop both machines: `dispatch` waits,
|
|
50
|
+
* and tea has no lock-up detector. Use `tell` there.
|
|
31
51
|
*
|
|
32
52
|
* ```ts
|
|
33
|
-
* yield* tell(parent, parentRun, { type: "child_stopped", id });
|
|
53
|
+
* const answer = yield* tell(parent, parentRun, { type: "child_stopped", id });
|
|
34
54
|
* ```
|
|
35
55
|
*/
|
|
36
56
|
declare const tell: <S, M extends {
|
|
37
57
|
type: string;
|
|
38
|
-
}, C extends Cmd, U extends Sub, Ctx, E extends {
|
|
58
|
+
}, C extends Cmd$1, U extends Sub, Ctx, E extends {
|
|
39
59
|
type: string;
|
|
40
|
-
} = never, Err = never>(machine: Machine<S, M, C, U, Ctx>, runtime:
|
|
60
|
+
} = never, Err = never>(machine: Machine<S, M, C, U, Ctx>, runtime: EffectRun<S, M, E, Err>, msg: NoInfer<M>) => Effect.Effect<TellAnswer>;
|
|
41
61
|
/**
|
|
42
62
|
* The host's own steps of a {@link spawn}. The host owns the table of
|
|
43
63
|
* children, their ids and the parent's Msg names; `spawn` owns the order the
|
|
@@ -63,11 +83,14 @@ interface SpawnSteps<A, E = never, R = never> {
|
|
|
63
83
|
/**
|
|
64
84
|
* Say the child stopped, usually a {@link tell} to the parent. It runs
|
|
65
85
|
* after `remove`, on a fiber of its own that the closing scope never waits
|
|
66
|
-
* for, so
|
|
86
|
+
* for, so even a step that does wait cannot hold the close.
|
|
67
87
|
*
|
|
68
88
|
* It cannot fail: nothing reads that fiber, so the step itself handles what
|
|
69
|
-
* its notice can fail with
|
|
70
|
-
*
|
|
89
|
+
* its notice can fail with. A `tell` has nothing to handle. Its argument is the
|
|
90
|
+
* handle the parent's `ready` gave: a parent handle built by hand, or one straight
|
|
91
|
+
* from `run`, does not compile. A defect in this step, such as a `tell` on a
|
|
92
|
+
* hand-built object cast past that type, is not observed by `spawn` and ends the
|
|
93
|
+
* fiber unseen.
|
|
71
94
|
*/
|
|
72
95
|
readonly notify: Effect.Effect<unknown>;
|
|
73
96
|
}
|
|
@@ -87,9 +110,14 @@ interface SpawnSteps<A, E = never, R = never> {
|
|
|
87
110
|
* - `remove` runs after the child's run has stopped.
|
|
88
111
|
*
|
|
89
112
|
* Nothing reads the fiber `notify` runs on, so `spawn` reports no failure of
|
|
90
|
-
* it and `notify` is typed to have none.
|
|
91
|
-
*
|
|
92
|
-
*
|
|
113
|
+
* it and `notify` is typed to have none. A `tell` carries no failure, and a
|
|
114
|
+
* failed save of the parent reaches the parent's own `onError`. A defect in
|
|
115
|
+
* `notify`, such as a `tell` on a handle cast past its type, ends that fiber
|
|
116
|
+
* unseen.
|
|
117
|
+
*
|
|
118
|
+
* A child whose run fails stops the same way, with no host call: a Sub failure
|
|
119
|
+
* the Sub did not map to a Msg, or a reducer throw under the default `stop`
|
|
120
|
+
* strategy, closes the child's scope, so `remove` and `notify` run.
|
|
93
121
|
*
|
|
94
122
|
* `child.run.stop()` is not one of the two ways to stop a child. It stops the
|
|
95
123
|
* run and leaves the scope open, so the entry stays in the table and the
|
|
@@ -101,9 +129,7 @@ interface SpawnSteps<A, E = never, R = never> {
|
|
|
101
129
|
* Effect.map(run(worker, {}), (run) => ({ run, scope })),
|
|
102
130
|
* enrol: (child) => Effect.sync(() => children.set(id, child)),
|
|
103
131
|
* remove: Effect.sync(() => children.delete(id)),
|
|
104
|
-
* notify: tell(parent, parentRun, { type: "child_stopped", id })
|
|
105
|
-
* Effect.catch((failure) => Effect.logError("notice failed", failure)),
|
|
106
|
-
* ),
|
|
132
|
+
* notify: tell(parent, parentRun, { type: "child_stopped", id }),
|
|
107
133
|
* });
|
|
108
134
|
* ```
|
|
109
135
|
*/
|
|
@@ -123,4 +149,71 @@ declare const spawn: <A, E = never, R = never>(parentScope: Scope.Scope, steps:
|
|
|
123
149
|
*/
|
|
124
150
|
declare const stop: (scope: Scope.Closeable) => Effect.Effect<void>;
|
|
125
151
|
|
|
126
|
-
|
|
152
|
+
/**
|
|
153
|
+
* The Effect entry's `Cmd`: the core `Cmd` with a `define` that takes plain
|
|
154
|
+
* Effect schemas (#631). It is a function over the core `Cmd.define`, so the
|
|
155
|
+
* def it returns is the same `CmdDef` a hand-wrapped call builds.
|
|
156
|
+
*/
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* An Effect schema that checks a value and hands the same type on. Both sides
|
|
160
|
+
* are one type, and decoding needs no service.
|
|
161
|
+
*
|
|
162
|
+
* tea types a handler's answer by the type the `ok` schema hands on, and checks
|
|
163
|
+
* that answer by parsing it. A schema whose two sides differ — a
|
|
164
|
+
* transformation like `Schema.FiniteFromString`, a brand — would refuse the
|
|
165
|
+
* very value the handler's type asks for, so it does not compile here. Pass
|
|
166
|
+
* `Schema.toType(schema)` to keep the checks and drop the translation.
|
|
167
|
+
*/
|
|
168
|
+
type CheckingSchema<T> = Schema.Codec<T, NoInfer<T>>;
|
|
169
|
+
declare function define<const Name extends string, Input extends CmdInput, Ok, const Tags extends readonly string[]>(name: Name, spec: {
|
|
170
|
+
readonly input: CheckingSchema<Input>;
|
|
171
|
+
readonly ok: CheckingSchema<Ok>;
|
|
172
|
+
readonly err: Tags;
|
|
173
|
+
}): CmdDef<Name, Input, Ok, TaggedError<Tags[number]>>;
|
|
174
|
+
/**
|
|
175
|
+
* A Cmd value, as the core types it. Exported beside the `Cmd` helpers so an
|
|
176
|
+
* Effect user reads both from this entry.
|
|
177
|
+
*/
|
|
178
|
+
type Cmd<T extends string = string, Ok = unknown, E = unknown> = Cmd$1<T, Ok, E>;
|
|
179
|
+
/**
|
|
180
|
+
* The helpers for building Cmds on the Effect engine. `Cmd.none`, `Cmd.batch`,
|
|
181
|
+
* `Cmd.when` and `Cmd.whenDefined` are the core's; `Cmd.define` is this
|
|
182
|
+
* entry's own.
|
|
183
|
+
*/
|
|
184
|
+
declare const Cmd: {
|
|
185
|
+
/**
|
|
186
|
+
* Declare a typed Cmd constructor from plain Effect schemas. It returns what
|
|
187
|
+
* the core `Cmd.define` returns, with each schema passed through
|
|
188
|
+
* `Schema.toStandardSchemaV1` for you:
|
|
189
|
+
*
|
|
190
|
+
* const fetchUser = Cmd.define("fetch_user", {
|
|
191
|
+
* input: Schema.Struct({ id: Schema.String }),
|
|
192
|
+
* ok: Schema.Struct({ name: Schema.String }),
|
|
193
|
+
* err: ["not_found"],
|
|
194
|
+
* });
|
|
195
|
+
*
|
|
196
|
+
* `input` and `ok` take a schema that checks and never translates: both of
|
|
197
|
+
* its sides are one type and decoding needs no service. A transformation, a
|
|
198
|
+
* brand or a schema that needs a service is a compile error.
|
|
199
|
+
*
|
|
200
|
+
* To keep the checks of a transformation or a brand, pass
|
|
201
|
+
* `Schema.toType(schema)`. That is no way through for a schema that needs a
|
|
202
|
+
* service: its check lives in the decode step, and `Schema.toType` drops that
|
|
203
|
+
* step, so the Cmd would compile and never run the check. Run such a check in
|
|
204
|
+
* the handler.
|
|
205
|
+
*
|
|
206
|
+
* A schema whose validation needs a Promise compiles, and is refused with
|
|
207
|
+
* `AsyncSchemaError` when the Cmd settles, as the core's is.
|
|
208
|
+
*
|
|
209
|
+
* It takes Effect schemas only. A zod schema, or any other Standard Schema,
|
|
210
|
+
* goes to `Cmd.define` from `@demlik/tea`.
|
|
211
|
+
*/
|
|
212
|
+
readonly define: typeof define;
|
|
213
|
+
readonly none: readonly never[];
|
|
214
|
+
readonly batch: <const C extends Cmd$1>(...arrs: readonly (readonly C[])[]) => readonly C[];
|
|
215
|
+
readonly when: <const C extends Cmd$1>(cond: boolean, cmd: C) => readonly C[];
|
|
216
|
+
readonly whenDefined: <T, const C extends Cmd$1>(value: T | undefined, build: (value: T) => C) => readonly C[];
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
export { type CheckingSchema, Cmd, EffectRun, type SpawnSteps, TellAnswer, spawn, stop, tell };
|
package/dist/effect/index.js
CHANGED
|
@@ -1,35 +1,49 @@
|
|
|
1
|
-
export { Stopped, StoreFailed, run } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
1
|
+
export { Stopped, StoreFailed, SubFailed, run, spawn, stop, tell } from '../chunk-SHXUSTHM.js';
|
|
2
|
+
import '../chunk-2A5XTKQQ.js';
|
|
3
|
+
import '../chunk-R2YNDRGL.js';
|
|
4
|
+
import '../chunk-DEAPNMKO.js';
|
|
5
|
+
import { Cmd } from '../chunk-A3QPMX5M.js';
|
|
6
|
+
import { Schema } from 'effect';
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
8
|
+
function define(name, spec) {
|
|
9
|
+
return Cmd.define(name, {
|
|
10
|
+
input: Schema.toStandardSchemaV1(spec.input),
|
|
11
|
+
ok: Schema.toStandardSchemaV1(spec.ok),
|
|
12
|
+
err: spec.err
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
var Cmd2 = {
|
|
16
|
+
...Cmd,
|
|
17
|
+
/**
|
|
18
|
+
* Declare a typed Cmd constructor from plain Effect schemas. It returns what
|
|
19
|
+
* the core `Cmd.define` returns, with each schema passed through
|
|
20
|
+
* `Schema.toStandardSchemaV1` for you:
|
|
21
|
+
*
|
|
22
|
+
* const fetchUser = Cmd.define("fetch_user", {
|
|
23
|
+
* input: Schema.Struct({ id: Schema.String }),
|
|
24
|
+
* ok: Schema.Struct({ name: Schema.String }),
|
|
25
|
+
* err: ["not_found"],
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* `input` and `ok` take a schema that checks and never translates: both of
|
|
29
|
+
* its sides are one type and decoding needs no service. A transformation, a
|
|
30
|
+
* brand or a schema that needs a service is a compile error.
|
|
31
|
+
*
|
|
32
|
+
* To keep the checks of a transformation or a brand, pass
|
|
33
|
+
* `Schema.toType(schema)`. That is no way through for a schema that needs a
|
|
34
|
+
* service: its check lives in the decode step, and `Schema.toType` drops that
|
|
35
|
+
* step, so the Cmd would compile and never run the check. Run such a check in
|
|
36
|
+
* the handler.
|
|
37
|
+
*
|
|
38
|
+
* A schema whose validation needs a Promise compiles, and is refused with
|
|
39
|
+
* `AsyncSchemaError` when the Cmd settles, as the core's is.
|
|
40
|
+
*
|
|
41
|
+
* It takes Effect schemas only. A zod schema, or any other Standard Schema,
|
|
42
|
+
* goes to `Cmd.define` from `@demlik/tea`.
|
|
43
|
+
*/
|
|
44
|
+
define
|
|
45
|
+
};
|
|
32
46
|
|
|
33
|
-
export {
|
|
47
|
+
export { Cmd2 as Cmd };
|
|
34
48
|
//# sourceMappingURL=index.js.map
|
|
35
49
|
//# sourceMappingURL=index.js.map
|
package/dist/effect/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/effect/
|
|
1
|
+
{"version":3,"sources":["../../src/effect/cmd.ts"],"names":["Cmd"],"mappings":";;;;;;;AA0BA,SAAS,MAAA,CAMP,MACA,IAAA,EAKoD;AACpD,EAAA,OAAO,GAAA,CAAQ,OAAO,IAAA,EAAM;AAAA,IAC1B,KAAA,EAAO,MAAA,CAAO,kBAAA,CAAmB,IAAA,CAAK,KAAK,CAAA;AAAA,IAC3C,EAAA,EAAI,MAAA,CAAO,kBAAA,CAAmB,IAAA,CAAK,EAAE,CAAA;AAAA,IACrC,KAAK,IAAA,CAAK;AAAA,GACX,CAAA;AACH;AAiBO,IAAMA,IAAAA,GAAM;AAAA,EACjB,GAAG,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA4BH;AACF","file":"index.js","sourcesContent":["/**\n * The Effect entry's `Cmd`: the core `Cmd` with a `define` that takes plain\n * Effect schemas (#631). It is a function over the core `Cmd.define`, so the\n * def it returns is the same `CmdDef` a hand-wrapped call builds.\n */\n\nimport { Schema } from \"effect\";\nimport {\n type CmdDef,\n type CmdInput,\n Cmd as CoreCmd,\n type TaggedError,\n} from \"../pure/core\";\n\n/**\n * An Effect schema that checks a value and hands the same type on. Both sides\n * are one type, and decoding needs no service.\n *\n * tea types a handler's answer by the type the `ok` schema hands on, and checks\n * that answer by parsing it. A schema whose two sides differ — a\n * transformation like `Schema.FiniteFromString`, a brand — would refuse the\n * very value the handler's type asks for, so it does not compile here. Pass\n * `Schema.toType(schema)` to keep the checks and drop the translation.\n */\nexport type CheckingSchema<T> = Schema.Codec<T, NoInfer<T>>;\n\nfunction define<\n const Name extends string,\n Input extends CmdInput,\n Ok,\n const Tags extends readonly string[],\n>(\n name: Name,\n spec: {\n readonly input: CheckingSchema<Input>;\n readonly ok: CheckingSchema<Ok>;\n readonly err: Tags;\n },\n): CmdDef<Name, Input, Ok, TaggedError<Tags[number]>> {\n return CoreCmd.define(name, {\n input: Schema.toStandardSchemaV1(spec.input),\n ok: Schema.toStandardSchemaV1(spec.ok),\n err: spec.err,\n });\n}\n\n/**\n * A Cmd value, as the core types it. Exported beside the `Cmd` helpers so an\n * Effect user reads both from this entry.\n */\nexport type Cmd<T extends string = string, Ok = unknown, E = unknown> = CoreCmd<\n T,\n Ok,\n E\n>;\n\n/**\n * The helpers for building Cmds on the Effect engine. `Cmd.none`, `Cmd.batch`,\n * `Cmd.when` and `Cmd.whenDefined` are the core's; `Cmd.define` is this\n * entry's own.\n */\nexport const Cmd = {\n ...CoreCmd,\n /**\n * Declare a typed Cmd constructor from plain Effect schemas. It returns what\n * the core `Cmd.define` returns, with each schema passed through\n * `Schema.toStandardSchemaV1` for you:\n *\n * const fetchUser = Cmd.define(\"fetch_user\", {\n * input: Schema.Struct({ id: Schema.String }),\n * ok: Schema.Struct({ name: Schema.String }),\n * err: [\"not_found\"],\n * });\n *\n * `input` and `ok` take a schema that checks and never translates: both of\n * its sides are one type and decoding needs no service. A transformation, a\n * brand or a schema that needs a service is a compile error.\n *\n * To keep the checks of a transformation or a brand, pass\n * `Schema.toType(schema)`. That is no way through for a schema that needs a\n * service: its check lives in the decode step, and `Schema.toType` drops that\n * step, so the Cmd would compile and never run the check. Run such a check in\n * the handler.\n *\n * A schema whose validation needs a Promise compiles, and is refused with\n * `AsyncSchemaError` when the Cmd settles, as the core's is.\n *\n * It takes Effect schemas only. A zod schema, or any other Standard Schema,\n * goes to `Cmd.define` from `@demlik/tea`.\n */\n define,\n} as const;\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { R as Runtime, M as Migrated,
|
|
1
|
+
import { R as Runtime, M as Migrated, b as Store } from '../runtime-types-CP-ykwgf.js';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
import { S as SubscribeHandler } from '../types-
|
|
3
|
+
import { c as Sub } from '../core-DNDAEhO2.js';
|
|
4
|
+
import { S as SubscribeHandler } from '../types-S53WDy_h.js';
|
|
5
5
|
import '@standard-schema/spec';
|
|
6
6
|
|
|
7
7
|
/**
|
package/dist/extension/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { historyTracker, dispatchIfPresent } from '../chunk-
|
|
2
|
-
import { describeError } from '../chunk-
|
|
1
|
+
import { historyTracker, dispatchIfPresent } from '../chunk-BVFS3ICC.js';
|
|
2
|
+
import { describeError } from '../chunk-A3QPMX5M.js';
|
|
3
3
|
import { useRef, useSyncExternalStore, useEffect, useCallback, createContext, useMemo, useContext } from 'react';
|
|
4
4
|
import { jsx } from 'react/jsx-runtime';
|
|
5
5
|
|