@akterjs/cli 0.0.0-stage → 0.1.1
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/LICENSE +201 -0
- package/README.md +47 -2
- package/dist/Argument-D81dqizB.mjs +57 -0
- package/dist/Array-B4kuTQeW.mjs +2323 -0
- package/dist/Boolean-kILIvmhE.mjs +26 -0
- package/dist/ChildProcess-BCIwxPGc.mjs +577 -0
- package/dist/CliError-Cf5xqkkj.mjs +633 -0
- package/dist/Command-Dzq9KM-h.mjs +5135 -0
- package/dist/Config-B6OND9WR.mjs +854 -0
- package/dist/Console-BKHUkH6a.mjs +141 -0
- package/dist/Data-CeCULr0-.mjs +251 -0
- package/dist/Digest-CBd3uv5B.mjs +348 -0
- package/dist/Duration-EH9Vy4U6.mjs +791 -0
- package/dist/Effect-CKFpqbmw.mjs +12911 -0
- package/dist/FileSystem-4pPcEb_i.mjs +1366 -0
- package/dist/HttpClientError-BUeMWx70.mjs +303 -0
- package/dist/HttpClientResponse-D5ZKICVV.mjs +855 -0
- package/dist/Match-CGPLZYrV.mjs +434 -0
- package/dist/MutableHashMap-f8nW8AJR.mjs +376 -0
- package/dist/MutableHashSet-_HI572Ya.mjs +155 -0
- package/dist/MutableRef-D4Qv592C.mjs +107 -0
- package/dist/Number-BvkRkfc-.mjs +137 -0
- package/dist/Option-DkxSnBhp.mjs +3967 -0
- package/dist/Order-C1JC991I.mjs +481 -0
- package/dist/Path-Djdv_eF5.mjs +130 -0
- package/dist/Queue-CO5UQ6os.mjs +1394 -0
- package/dist/Redacted-RkJrG5Me.mjs +160 -0
- package/dist/Ref-BIPOxJNH.mjs +267 -0
- package/dist/Runtime-BInIAwK3.mjs +297 -0
- package/dist/Schema-MiKt5K1v.mjs +10999 -0
- package/dist/SecureRandom-B_U4ysO3.mjs +279 -0
- package/dist/Semaphore-DOVJ4ZGS.mjs +177 -0
- package/dist/Stdio-KylmOBX_.mjs +74 -0
- package/dist/Stream-bK9QIETN.mjs +4012 -0
- package/dist/String-q5dcsVe4.mjs +351 -0
- package/dist/TerminalCapabilities-w_44MAca.mjs +1769 -0
- package/dist/WebCrypto-ZI_GNVlw.mjs +33 -0
- package/dist/actor-call.service-CGM_vD9u.mjs +1269 -0
- package/dist/actor-client.adapter-Coem7gF1.mjs +3691 -0
- package/dist/akter-program.config-D8yb9xQP.mjs +7034 -0
- package/dist/akter.cli.mjs +5 -0
- package/dist/app-cli.config.mjs +49 -0
- package/dist/app-entry.pure.mjs +31 -0
- package/dist/archive/akter-archive.schema.mjs +65 -0
- package/dist/archive/akter-archive.service.mjs +309 -0
- package/dist/archive/archive-cli.config.mjs +45 -0
- package/dist/archive/archive-invalid.errors.mjs +5 -0
- package/dist/archive/archived-lineage.pure.mjs +13 -0
- package/dist/archive/tar.pure.mjs +291 -0
- package/dist/archive/zstd.adapter.mjs +46 -0
- package/dist/bench/bench-report.pure.mjs +120 -0
- package/dist/bench/bench-runner.pure.mjs +89 -0
- package/dist/bench/bench.service.mjs +301 -0
- package/dist/cli-runtime.layer-BqK2mmVL.mjs +1191 -0
- package/dist/cli-runtime.layer.mjs +1 -0
- package/dist/cloud-client.adapter-Cy1BjDbG.mjs +3186 -0
- package/dist/cloud-client.adapter-DOVMoYAj.mjs +304 -0
- package/dist/command/akter-commands.config.mjs +32 -0
- package/dist/command/akter-program.config.mjs +1 -0
- package/dist/credentials/credentials.service.mjs +226 -0
- package/dist/credentials/keychain.adapter.mjs +92 -0
- package/dist/credentials/login.config.mjs +251 -0
- package/dist/deploy/auth/api-attempt.service.mjs +30 -0
- package/dist/deploy/auth/token-refresh.errors.mjs +4 -0
- package/dist/deploy/build-bundle.adapter.mjs +133 -0
- package/dist/deploy/build-manifest.pure.mjs +44 -0
- package/dist/deploy/cloud-client.adapter.mjs +1 -0
- package/dist/deploy/cloud-url.pure.mjs +17 -0
- package/dist/deploy/deploy-failed.errors.mjs +17 -0
- package/dist/deploy/deploy.service.mjs +156 -0
- package/dist/deploy/request-failure.pure.mjs +87 -0
- package/dist/dev-runner.pure.mjs +30 -0
- package/dist/docs/doc-topics.pure.mjs +21 -0
- package/dist/docs/docs.config.mjs +1 -0
- package/dist/docs.config-D2amjsje.mjs +190 -0
- package/dist/docs.config-D3zzLzLR.mjs +190 -0
- package/dist/export/actor-export.service.mjs +267 -0
- package/dist/export/export-failed.errors.mjs +4 -0
- package/dist/export/export-failure.pure.mjs +18 -0
- package/dist/export/ordered-lines.pure.mjs +43 -0
- package/dist/export/ranged-download.pure.mjs +66 -0
- package/dist/export/snapshot-download.pure.mjs +86 -0
- package/dist/history-runner.pure.mjs +186 -0
- package/dist/history-since.pure.mjs +17 -0
- package/dist/hosted-runtime.layer-Cx3IPsEd.mjs +16358 -0
- package/dist/local/environment-cli.config.mjs +90 -0
- package/dist/local/environment-runner.pure.mjs +75 -0
- package/dist/local/local-cli.config.mjs +159 -0
- package/dist/logs/log-follow.config.mjs +21 -0
- package/dist/logs/log-follow.service.mjs +87 -0
- package/dist/logs/log-lines.pure.mjs +44 -0
- package/dist/migrate-runner.pure.mjs +28 -0
- package/dist/operation-input.pure-CS9iUhqK.mjs +1383 -0
- package/dist/operation-registry.pure-DVC8EDgj.mjs +283 -0
- package/dist/registry/actor-call.service.mjs +1 -0
- package/dist/registry/actor-commands.config.mjs +127 -0
- package/dist/registry/actor-refusal.pure.mjs +34 -0
- package/dist/registry/approval.service.mjs +80 -0
- package/dist/registry/cloud-commands.config.mjs +151 -0
- package/dist/registry/cloud-served.pure.mjs +31 -0
- package/dist/registry/operation-call.service.mjs +262 -0
- package/dist/registry/operation-input.pure.mjs +1 -0
- package/dist/registry/operation-output.pure.mjs +91 -0
- package/dist/registry/served-command.config.mjs +57 -0
- package/dist/runner-exited.errors.mjs +10 -0
- package/dist/terminal/cli-exit.errors.mjs +38 -0
- package/dist/terminal/cli-failure.pure.mjs +31 -0
- package/dist/terminal/confirm.adapter.mjs +27 -0
- package/package.json +61 -3
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { mt as withFiber } from "./Option-DkxSnBhp.mjs";
|
|
2
|
+
import { Gi as sync, ui as ConsoleRef } from "./Effect-CKFpqbmw.mjs";
|
|
3
|
+
// ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/Console.js
|
|
4
|
+
/**
|
|
5
|
+
* Context reference for the current console service in the Effect system, allowing access to the active console implementation from within the Effect context.
|
|
6
|
+
*
|
|
7
|
+
* **When to use**
|
|
8
|
+
*
|
|
9
|
+
* Use when you need an effect to run against a provided console implementation,
|
|
10
|
+
* such as tests or alternate runtimes, rather than the default console.
|
|
11
|
+
*
|
|
12
|
+
* **Details**
|
|
13
|
+
*
|
|
14
|
+
* When no override is provided, the reference resolves to `globalThis.console`.
|
|
15
|
+
*
|
|
16
|
+
* **Example** (Accessing the current console)
|
|
17
|
+
*
|
|
18
|
+
* ```ts import.meta.vitest
|
|
19
|
+
* import { Console, Effect } from "effect"
|
|
20
|
+
*
|
|
21
|
+
* const messages: Array<unknown> = []
|
|
22
|
+
* const testConsole: Console.Console = Object.assign(Object.create(console), {
|
|
23
|
+
* log: (...args: ReadonlyArray<unknown>) => messages.push(...args)
|
|
24
|
+
* })
|
|
25
|
+
* const program = Console.consoleWith((console) =>
|
|
26
|
+
* Effect.sync(() => {
|
|
27
|
+
* console.log("Hello from current console!")
|
|
28
|
+
* })
|
|
29
|
+
* )
|
|
30
|
+
*
|
|
31
|
+
* Effect.runSync(Effect.provideService(program, Console.Console, testConsole))
|
|
32
|
+
* messages // => ["Hello from current console!"]
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @see {@link consoleWith} for using the current console service inside an effect
|
|
36
|
+
*
|
|
37
|
+
* @stability stable
|
|
38
|
+
* @category services
|
|
39
|
+
* @since 2.0.0
|
|
40
|
+
*/
|
|
41
|
+
const Console = ConsoleRef;
|
|
42
|
+
/**
|
|
43
|
+
* Creates an Effect that provides access to the current console service and lets you perform operations with it within an Effect context.
|
|
44
|
+
*
|
|
45
|
+
* **Example** (Accessing the current console service)
|
|
46
|
+
*
|
|
47
|
+
* ```ts import.meta.vitest
|
|
48
|
+
* import { Console, Effect } from "effect"
|
|
49
|
+
*
|
|
50
|
+
* const messages: Array<unknown> = []
|
|
51
|
+
* const testConsole: Console.Console = Object.assign(Object.create(console), {
|
|
52
|
+
* log: (...args: ReadonlyArray<unknown>) => messages.push(...args),
|
|
53
|
+
* error: (...args: ReadonlyArray<unknown>) => messages.push(...args)
|
|
54
|
+
* })
|
|
55
|
+
* const program = Console.consoleWith((console) =>
|
|
56
|
+
* Effect.sync(() => {
|
|
57
|
+
* console.log("Hello, world!")
|
|
58
|
+
* console.error("This is an error message")
|
|
59
|
+
* })
|
|
60
|
+
* )
|
|
61
|
+
*
|
|
62
|
+
* Effect.runSync(Effect.provideService(program, Console.Console, testConsole))
|
|
63
|
+
* messages // => ["Hello, world!", "This is an error message"]
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
66
|
+
* @stability stable
|
|
67
|
+
* @category constructors
|
|
68
|
+
* @since 2.0.0
|
|
69
|
+
*/
|
|
70
|
+
const consoleWith = (f) => withFiber((fiber) => f(fiber.getRef(Console)));
|
|
71
|
+
/**
|
|
72
|
+
* Writes an error-level message to the console, typically displayed with error
|
|
73
|
+
* styling by the active console implementation.
|
|
74
|
+
*
|
|
75
|
+
* **Example** (Writing error messages)
|
|
76
|
+
*
|
|
77
|
+
* ```ts import.meta.vitest
|
|
78
|
+
* import { Console, Effect } from "effect"
|
|
79
|
+
*
|
|
80
|
+
* const messages: Array<ReadonlyArray<unknown>> = []
|
|
81
|
+
* const testConsole: Console.Console = Object.assign(Object.create(console), {
|
|
82
|
+
* error: (...args: ReadonlyArray<unknown>) => messages.push(args)
|
|
83
|
+
* })
|
|
84
|
+
* const program = Effect.gen(function*() {
|
|
85
|
+
* yield* Console.error("Something went wrong!")
|
|
86
|
+
* yield* Console.error("Error details:", {
|
|
87
|
+
* code: 500,
|
|
88
|
+
* message: "Internal Server Error"
|
|
89
|
+
* })
|
|
90
|
+
* })
|
|
91
|
+
*
|
|
92
|
+
* Effect.runSync(Effect.provideService(program, Console.Console, testConsole))
|
|
93
|
+
* const expected = [
|
|
94
|
+
* ["Something went wrong!"],
|
|
95
|
+
* ["Error details:", { code: 500, message: "Internal Server Error" }]
|
|
96
|
+
* ]
|
|
97
|
+
* messages // => expected
|
|
98
|
+
* ```
|
|
99
|
+
*
|
|
100
|
+
* @stability stable
|
|
101
|
+
* @category accessors
|
|
102
|
+
* @since 2.0.0
|
|
103
|
+
*/
|
|
104
|
+
const error = (...args) => consoleWith((console) => sync(() => {
|
|
105
|
+
console.error(...args);
|
|
106
|
+
}));
|
|
107
|
+
/**
|
|
108
|
+
* Logs a general-purpose message to the console.
|
|
109
|
+
*
|
|
110
|
+
* **Example** (Writing log messages)
|
|
111
|
+
*
|
|
112
|
+
* ```ts import.meta.vitest
|
|
113
|
+
* import { Console, Effect } from "effect"
|
|
114
|
+
*
|
|
115
|
+
* const messages: Array<ReadonlyArray<unknown>> = []
|
|
116
|
+
* const testConsole: Console.Console = Object.assign(Object.create(console), {
|
|
117
|
+
* log: (...args: ReadonlyArray<unknown>) => messages.push(args)
|
|
118
|
+
* })
|
|
119
|
+
* const program = Effect.gen(function*() {
|
|
120
|
+
* yield* Console.log("Hello, world!")
|
|
121
|
+
* yield* Console.log("User data:", { name: "John", age: 30 })
|
|
122
|
+
* yield* Console.log("Processing", 42, "items")
|
|
123
|
+
* })
|
|
124
|
+
*
|
|
125
|
+
* Effect.runSync(Effect.provideService(program, Console.Console, testConsole))
|
|
126
|
+
* const expected = [
|
|
127
|
+
* ["Hello, world!"],
|
|
128
|
+
* ["User data:", { name: "John", age: 30 }],
|
|
129
|
+
* ["Processing", 42, "items"]
|
|
130
|
+
* ]
|
|
131
|
+
* messages // => expected
|
|
132
|
+
* ```
|
|
133
|
+
*
|
|
134
|
+
* @stability stable
|
|
135
|
+
* @category accessors
|
|
136
|
+
* @since 2.0.0
|
|
137
|
+
*/
|
|
138
|
+
const log = (...args) => consoleWith((console) => sync(() => {
|
|
139
|
+
console.log(...args);
|
|
140
|
+
}));
|
|
141
|
+
export { log as n, error as t };
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import { A as Error$1, En as Class$1, R as TaggedError$1, ht as assignProperties, un as isTagged } from "./Option-DkxSnBhp.mjs";
|
|
2
|
+
// ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/Data.js
|
|
3
|
+
/**
|
|
4
|
+
* Provides a base class for immutable data types.
|
|
5
|
+
*
|
|
6
|
+
* **When to use**
|
|
7
|
+
*
|
|
8
|
+
* Use when you need a lightweight immutable value type with `.pipe()` support.
|
|
9
|
+
*
|
|
10
|
+
* **Details**
|
|
11
|
+
*
|
|
12
|
+
* Extend `Class` with a type parameter to declare fields. The constructor
|
|
13
|
+
* accepts those fields as a single object argument. When there are no fields
|
|
14
|
+
* the argument is optional. Instances are `Readonly` and `Pipeable`.
|
|
15
|
+
*
|
|
16
|
+
* **Example** (Defining a value class)
|
|
17
|
+
*
|
|
18
|
+
* ```ts import.meta.vitest
|
|
19
|
+
* import { Data, Equal } from "effect"
|
|
20
|
+
*
|
|
21
|
+
* class Person extends Data.Class<{ readonly name: string }> {}
|
|
22
|
+
*
|
|
23
|
+
* Equal.equals(new Person({ name: "Mike" }), new Person({ name: "Mike" })) // => true
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @see {@link TaggedClass} — adds a `_tag` field
|
|
27
|
+
* @see {@link Error} — yieldable error variant
|
|
28
|
+
*
|
|
29
|
+
* @stability stable
|
|
30
|
+
* @category constructors
|
|
31
|
+
* @since 2.0.0
|
|
32
|
+
*/
|
|
33
|
+
const Class = class extends Class$1 {
|
|
34
|
+
constructor(props) {
|
|
35
|
+
super();
|
|
36
|
+
if (props) assignProperties(this, props);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Provides a base class for immutable data types with a `_tag` discriminator.
|
|
41
|
+
*
|
|
42
|
+
* **When to use**
|
|
43
|
+
*
|
|
44
|
+
* Use when you need a single-variant tagged type or an ad-hoc discriminator.
|
|
45
|
+
*
|
|
46
|
+
* **Details**
|
|
47
|
+
*
|
|
48
|
+
* Like {@link Class}, but the resulting instances also carry a
|
|
49
|
+
* `readonly _tag: Tag` property. The `_tag` is excluded from the constructor
|
|
50
|
+
* argument.
|
|
51
|
+
*
|
|
52
|
+
* **Example** (Defining a tagged class)
|
|
53
|
+
*
|
|
54
|
+
* ```ts import.meta.vitest
|
|
55
|
+
* import { Data } from "effect"
|
|
56
|
+
*
|
|
57
|
+
* class Person extends Data.TaggedClass("Person")<{
|
|
58
|
+
* readonly name: string
|
|
59
|
+
* }> {}
|
|
60
|
+
*
|
|
61
|
+
* new Person({ name: "Mike" })._tag // => "Person"
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* @see {@link Class} — without a `_tag`
|
|
65
|
+
* @see {@link TaggedError} — tagged error variant
|
|
66
|
+
* @see {@link TaggedEnum} — multi-variant unions
|
|
67
|
+
*
|
|
68
|
+
* @stability stable
|
|
69
|
+
* @category constructors
|
|
70
|
+
* @since 2.0.0
|
|
71
|
+
*/
|
|
72
|
+
const TaggedClass = (tag) => class extends Class {
|
|
73
|
+
_tag = tag;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Creates constructors and matchers for a `TaggedEnum` type.
|
|
77
|
+
*
|
|
78
|
+
* **When to use**
|
|
79
|
+
*
|
|
80
|
+
* Use when you model a closed union with plain data objects and want
|
|
81
|
+
* construction, tag checks, and exhaustive matching from the same definition.
|
|
82
|
+
*
|
|
83
|
+
* **Details**
|
|
84
|
+
*
|
|
85
|
+
* Returns an object with:
|
|
86
|
+
* - One constructor per variant (keyed by tag name)
|
|
87
|
+
* - `$is(tag)` — returns a type-guard function that checks only the `_tag` field
|
|
88
|
+
* - `$match` — exhaustive pattern matching (data-first or data-last)
|
|
89
|
+
*
|
|
90
|
+
* **Gotchas**
|
|
91
|
+
*
|
|
92
|
+
* - Constructors produce **plain objects**, not class instances.
|
|
93
|
+
* - `$is(tag)` only checks the `_tag` field, not the full structure. It relies
|
|
94
|
+
* on the tag being globally unique and the value being produced by your
|
|
95
|
+
* constructors. For untrusted input, validate with the `Schema` module first.
|
|
96
|
+
*
|
|
97
|
+
* **Example** (Creating and matching tagged enum values)
|
|
98
|
+
*
|
|
99
|
+
* ```ts import.meta.vitest
|
|
100
|
+
* import { Data } from "effect"
|
|
101
|
+
*
|
|
102
|
+
* type HttpError = Data.TaggedEnum<{
|
|
103
|
+
* BadRequest: { readonly message: string }
|
|
104
|
+
* NotFound: { readonly url: string }
|
|
105
|
+
* }>
|
|
106
|
+
*
|
|
107
|
+
* const { BadRequest, NotFound, $is, $match } = Data.taggedEnum<HttpError>()
|
|
108
|
+
*
|
|
109
|
+
* const err = NotFound({ url: "/missing" })
|
|
110
|
+
*
|
|
111
|
+
* $is("NotFound")(err) // => true
|
|
112
|
+
*
|
|
113
|
+
* $match(err, {
|
|
114
|
+
* BadRequest: (e) => e.message,
|
|
115
|
+
* NotFound: (e) => `${e.url} not found`
|
|
116
|
+
* }) // => "/missing not found"
|
|
117
|
+
* ```
|
|
118
|
+
*
|
|
119
|
+
* **Example** (Defining a generic tagged enum)
|
|
120
|
+
*
|
|
121
|
+
* ```ts import.meta.vitest
|
|
122
|
+
* import { Data } from "effect"
|
|
123
|
+
*
|
|
124
|
+
* type MyResult<E, A> = Data.TaggedEnum<{
|
|
125
|
+
* Failure: { readonly error: E }
|
|
126
|
+
* Success: { readonly value: A }
|
|
127
|
+
* }>
|
|
128
|
+
* interface MyResultDef extends Data.TaggedEnum.WithGenerics<2> {
|
|
129
|
+
* readonly taggedEnum: MyResult<this["A"], this["B"]>
|
|
130
|
+
* }
|
|
131
|
+
* const { Failure, Success } = Data.taggedEnum<MyResultDef>()
|
|
132
|
+
*
|
|
133
|
+
* const ok = Success({ value: 42 })
|
|
134
|
+
* // ok: { readonly _tag: "Success"; readonly value: number }
|
|
135
|
+
* ok // => { value: 42, _tag: "Success" }
|
|
136
|
+
* ```
|
|
137
|
+
*
|
|
138
|
+
* @see {@link TaggedEnum} — the type-level companion
|
|
139
|
+
* @see {@link TaggedEnum.Constructor} — the returned object type
|
|
140
|
+
* @see {@link TaggedEnum.WithGenerics} — generic enum support
|
|
141
|
+
*
|
|
142
|
+
* @stability stable
|
|
143
|
+
* @category constructors
|
|
144
|
+
* @since 2.0.0
|
|
145
|
+
*/
|
|
146
|
+
const taggedEnum = () => new Proxy({}, { get(_target, tag, _receiver) {
|
|
147
|
+
if (tag === "$is") return isTagged;
|
|
148
|
+
else if (tag === "$match") return taggedMatch;
|
|
149
|
+
return (props) => ({
|
|
150
|
+
...props,
|
|
151
|
+
_tag: tag
|
|
152
|
+
});
|
|
153
|
+
} });
|
|
154
|
+
function taggedMatch() {
|
|
155
|
+
if (arguments.length === 1) {
|
|
156
|
+
const cases = arguments[0];
|
|
157
|
+
return function(value) {
|
|
158
|
+
return cases[value._tag](value);
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
const value = arguments[0];
|
|
162
|
+
return arguments[1][value._tag](value);
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Provides a base class for yieldable errors.
|
|
166
|
+
*
|
|
167
|
+
* **When to use**
|
|
168
|
+
*
|
|
169
|
+
* Use when you need yieldable errors that do **not** need tag-based
|
|
170
|
+
* discrimination.
|
|
171
|
+
*
|
|
172
|
+
* **Details**
|
|
173
|
+
*
|
|
174
|
+
* Extends `Cause.YieldableError`, so instances can be yielded inside
|
|
175
|
+
* `Effect.gen` to fail the enclosing effect. Fields are passed as a single
|
|
176
|
+
* object; when there are no fields the argument is optional. If a `message`
|
|
177
|
+
* field is provided, it becomes the error's `.message`.
|
|
178
|
+
*
|
|
179
|
+
* **Example** (Defining a yieldable error)
|
|
180
|
+
*
|
|
181
|
+
* ```ts import.meta.vitest
|
|
182
|
+
* import { Data, Effect, Exit } from "effect"
|
|
183
|
+
*
|
|
184
|
+
* class NetworkError extends Data.Error<{
|
|
185
|
+
* readonly code: number
|
|
186
|
+
* readonly message: string
|
|
187
|
+
* }> {}
|
|
188
|
+
*
|
|
189
|
+
* const program = Effect.gen(function*() {
|
|
190
|
+
* return yield* new NetworkError({ code: 500, message: "timeout" })
|
|
191
|
+
* })
|
|
192
|
+
*
|
|
193
|
+
* Effect.runSync(Effect.exit(program)) // => Exit.fail(new NetworkError({ code: 500, message: "timeout" }))
|
|
194
|
+
* ```
|
|
195
|
+
*
|
|
196
|
+
* @see {@link TaggedError} — adds a `_tag` for `Effect.catchTag`
|
|
197
|
+
* @see {@link Class} — non-error data class
|
|
198
|
+
*
|
|
199
|
+
* @stability stable
|
|
200
|
+
* @category constructors
|
|
201
|
+
* @since 2.0.0
|
|
202
|
+
*/
|
|
203
|
+
const Error = Error$1;
|
|
204
|
+
/**
|
|
205
|
+
* Creates a tagged error class with a `_tag` discriminator.
|
|
206
|
+
*
|
|
207
|
+
* **When to use**
|
|
208
|
+
*
|
|
209
|
+
* Use when you need domain errors with discriminated-union handling.
|
|
210
|
+
*
|
|
211
|
+
* **Details**
|
|
212
|
+
*
|
|
213
|
+
* Like {@link Error}, but instances also carry a `readonly _tag` property,
|
|
214
|
+
* enabling `Effect.catchTag` and `Effect.catchTags` for tag-based recovery.
|
|
215
|
+
* The `_tag` is excluded from the constructor argument. Yielding an instance
|
|
216
|
+
* inside `Effect.gen` fails the effect with this error.
|
|
217
|
+
*
|
|
218
|
+
* **Example** (Recovering by tag)
|
|
219
|
+
*
|
|
220
|
+
* ```ts import.meta.vitest
|
|
221
|
+
* import { Data, Effect } from "effect"
|
|
222
|
+
*
|
|
223
|
+
* class NotFound extends Data.TaggedError("NotFound")<{
|
|
224
|
+
* readonly resource: string
|
|
225
|
+
* }> {}
|
|
226
|
+
*
|
|
227
|
+
* class Forbidden extends Data.TaggedError("Forbidden")<{
|
|
228
|
+
* readonly reason: string
|
|
229
|
+
* }> {}
|
|
230
|
+
*
|
|
231
|
+
* const program = Effect.gen(function*() {
|
|
232
|
+
* return yield* new NotFound({ resource: "/users/42" })
|
|
233
|
+
* })
|
|
234
|
+
*
|
|
235
|
+
* const recovered = program.pipe(
|
|
236
|
+
* Effect.catchTag("NotFound", (e) =>
|
|
237
|
+
* Effect.succeed(`missing: ${e.resource}`))
|
|
238
|
+
* )
|
|
239
|
+
*
|
|
240
|
+
* await Effect.runPromise(recovered) // => "missing: /users/42"
|
|
241
|
+
* ```
|
|
242
|
+
*
|
|
243
|
+
* @see {@link Error} — without a `_tag`
|
|
244
|
+
* @see {@link TaggedClass} — tagged class that is not an error
|
|
245
|
+
*
|
|
246
|
+
* @stability stable
|
|
247
|
+
* @category constructors
|
|
248
|
+
* @since 2.0.0
|
|
249
|
+
*/
|
|
250
|
+
const TaggedError = TaggedError$1;
|
|
251
|
+
export { taggedEnum as a, TaggedError as i, Error as n, TaggedClass as r, Class as t };
|