@akterjs/cli 0.0.0-stage → 0.1.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/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-C4cXx4Fr.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-_21Xi6HU.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,434 @@
|
|
|
1
|
+
import { On as pipeArguments, Sn as identity } from "./Option-DkxSnBhp.mjs";
|
|
2
|
+
import { Y as fail, at as succeed, et as isResult, tt as isSuccess } from "./Array-B4kuTQeW.mjs";
|
|
3
|
+
// ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/internal/matcher.js
|
|
4
|
+
/** @internal */
|
|
5
|
+
const TypeId = "~effect/Match/Matcher";
|
|
6
|
+
const TypeMatcherProto = {
|
|
7
|
+
[TypeId]: {
|
|
8
|
+
_input: identity,
|
|
9
|
+
_filters: identity,
|
|
10
|
+
_remaining: identity,
|
|
11
|
+
_result: identity,
|
|
12
|
+
_return: identity,
|
|
13
|
+
_args: identity
|
|
14
|
+
},
|
|
15
|
+
_tag: "TypeMatcher",
|
|
16
|
+
add(_case) {
|
|
17
|
+
return makeTypeMatcher(this.select, [...this.cases, _case]);
|
|
18
|
+
},
|
|
19
|
+
pipe() {
|
|
20
|
+
return pipeArguments(this, arguments);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
function makeTypeMatcher(select, cases) {
|
|
24
|
+
const matcher = Object.create(TypeMatcherProto);
|
|
25
|
+
matcher.select = select;
|
|
26
|
+
matcher.cases = cases;
|
|
27
|
+
return matcher;
|
|
28
|
+
}
|
|
29
|
+
const ValueMatcherProto = {
|
|
30
|
+
[TypeId]: {
|
|
31
|
+
_input: identity,
|
|
32
|
+
_filters: identity,
|
|
33
|
+
_result: identity,
|
|
34
|
+
_return: identity,
|
|
35
|
+
_flavor: identity
|
|
36
|
+
},
|
|
37
|
+
_tag: "ValueMatcher",
|
|
38
|
+
add(_case) {
|
|
39
|
+
if (isSuccess(this.value)) return this;
|
|
40
|
+
if (_case._tag === "When" && _case.guard(this.provided) === true) return makeValueMatcher(this.provided, succeed(_case.evaluate(this.provided)));
|
|
41
|
+
else if (_case._tag === "Not" && _case.guard(this.provided) === false) return makeValueMatcher(this.provided, succeed(_case.evaluate(this.provided)));
|
|
42
|
+
return this;
|
|
43
|
+
},
|
|
44
|
+
pipe() {
|
|
45
|
+
return pipeArguments(this, arguments);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
function makeValueMatcher(provided, value) {
|
|
49
|
+
const matcher = Object.create(ValueMatcherProto);
|
|
50
|
+
matcher.provided = provided;
|
|
51
|
+
matcher.value = value;
|
|
52
|
+
return matcher;
|
|
53
|
+
}
|
|
54
|
+
const makeWhen = (guard, evaluate) => ({
|
|
55
|
+
_tag: "When",
|
|
56
|
+
guard,
|
|
57
|
+
evaluate
|
|
58
|
+
});
|
|
59
|
+
/** @internal */
|
|
60
|
+
const type$1 = () => makeTypeMatcher(identity, []);
|
|
61
|
+
/** @internal */
|
|
62
|
+
const value$1 = (i) => makeValueMatcher(i, fail(i));
|
|
63
|
+
/** @internal */
|
|
64
|
+
const discriminator = (field) => (...pattern) => {
|
|
65
|
+
const f = pattern[pattern.length - 1];
|
|
66
|
+
const values = pattern.slice(0, -1);
|
|
67
|
+
const pred = values.length === 1 ? (_) => _ != null && _[field] === values[0] : (_) => _ != null && values.includes(_[field]);
|
|
68
|
+
return (self) => self.add(makeWhen(pred, f));
|
|
69
|
+
};
|
|
70
|
+
/** @internal */
|
|
71
|
+
const discriminators = (field) => (fields) => {
|
|
72
|
+
const predicate = makeWhen((arg) => arg != null && Object.hasOwn(fields, arg[field]), (data) => fields[data[field]](data));
|
|
73
|
+
return (self) => self.add(predicate);
|
|
74
|
+
};
|
|
75
|
+
/** @internal */
|
|
76
|
+
const discriminatorsExhaustive$1 = (field) => (fields) => {
|
|
77
|
+
const addCases = discriminators(field)(fields);
|
|
78
|
+
return (matcher) => exhaustive$1(addCases(matcher));
|
|
79
|
+
};
|
|
80
|
+
/** @internal */
|
|
81
|
+
const tag$1 = /*#__PURE__*/ discriminator("_tag");
|
|
82
|
+
/** @internal */
|
|
83
|
+
const tags$1 = /*#__PURE__*/ discriminators("_tag");
|
|
84
|
+
/** @internal */
|
|
85
|
+
const orElse$1 = (f) => (self) => {
|
|
86
|
+
const toResult = result(self);
|
|
87
|
+
if (isResult(toResult)) return toResult._tag === "Success" ? toResult.success : f(toResult.failure);
|
|
88
|
+
return (...args) => {
|
|
89
|
+
const a = toResult(...args);
|
|
90
|
+
return isSuccess(a) ? a.success : f(a.failure, ...args);
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
/** @internal */
|
|
94
|
+
const result = (self) => {
|
|
95
|
+
if (self._tag === "ValueMatcher") return self.value;
|
|
96
|
+
const len = self.cases.length;
|
|
97
|
+
if (len === 1) {
|
|
98
|
+
const _case = self.cases[0];
|
|
99
|
+
return (...args) => {
|
|
100
|
+
const input = self.select(...args);
|
|
101
|
+
if (_case._tag === "When" && _case.guard(input) === true) return succeed(_case.evaluate(input, ...args));
|
|
102
|
+
else if (_case._tag === "Not" && _case.guard(input) === false) return succeed(_case.evaluate(input, ...args));
|
|
103
|
+
return fail(input);
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
return (...args) => {
|
|
107
|
+
const input = self.select(...args);
|
|
108
|
+
for (let i = 0; i < len; i++) {
|
|
109
|
+
const _case = self.cases[i];
|
|
110
|
+
if (_case._tag === "When" && _case.guard(input) === true) return succeed(_case.evaluate(input, ...args));
|
|
111
|
+
else if (_case._tag === "Not" && _case.guard(input) === false) return succeed(_case.evaluate(input, ...args));
|
|
112
|
+
}
|
|
113
|
+
return fail(input);
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
const getExhaustiveAbsurdErrorMessage = "effect/match/Match/exhaustive: absurd";
|
|
117
|
+
/** @internal */
|
|
118
|
+
const exhaustive$1 = (self) => {
|
|
119
|
+
const toResult = result(self);
|
|
120
|
+
if (isResult(toResult)) {
|
|
121
|
+
if (isSuccess(toResult)) return toResult.success;
|
|
122
|
+
throw new Error(getExhaustiveAbsurdErrorMessage);
|
|
123
|
+
}
|
|
124
|
+
return (...args) => {
|
|
125
|
+
const result = toResult(...args);
|
|
126
|
+
if (isSuccess(result)) return result.success;
|
|
127
|
+
throw new Error(getExhaustiveAbsurdErrorMessage);
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
// ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/Match.js
|
|
131
|
+
/**
|
|
132
|
+
* Builds pattern matchers for TypeScript values.
|
|
133
|
+
*
|
|
134
|
+
* `Match` lets you add ordered cases and then finish them with a result,
|
|
135
|
+
* fallback, `Option`, or exhaustive check. Use `Match.type` to define a
|
|
136
|
+
* reusable matcher for a type, or `Match.value` to match one value immediately.
|
|
137
|
+
* Cases can match literal values, predicates, object shapes, tags, negated
|
|
138
|
+
* patterns, and common checks such as strings, numbers, records, and class
|
|
139
|
+
* instances.
|
|
140
|
+
*
|
|
141
|
+
* @stability stable
|
|
142
|
+
* @since 4.0.0
|
|
143
|
+
*/
|
|
144
|
+
/**
|
|
145
|
+
* Creates a matcher for a specific type.
|
|
146
|
+
*
|
|
147
|
+
* **When to use**
|
|
148
|
+
*
|
|
149
|
+
* Use to build a reusable matcher function for values of a known input type.
|
|
150
|
+
*
|
|
151
|
+
* **Details**
|
|
152
|
+
*
|
|
153
|
+
* This function defines a `Matcher` that operates on a given type, allowing you
|
|
154
|
+
* to specify conditions for handling different cases. Once the matcher is
|
|
155
|
+
* created, you can use pattern-matching functions like {@link when} to define
|
|
156
|
+
* how different values should be processed.
|
|
157
|
+
*
|
|
158
|
+
* **Example** (Matching Numbers and Strings)
|
|
159
|
+
*
|
|
160
|
+
* ```ts import.meta.vitest
|
|
161
|
+
* import { Match } from "effect"
|
|
162
|
+
*
|
|
163
|
+
* // Create a matcher for values that are either strings or numbers
|
|
164
|
+
* //
|
|
165
|
+
* // ┌─── (u: string | number) => string
|
|
166
|
+
* // ▼
|
|
167
|
+
* const match = Match.type<string | number>().pipe(
|
|
168
|
+
* // Match when the value is a number
|
|
169
|
+
* Match.when(Match.number, (n) => `number: ${n}`),
|
|
170
|
+
* // Match when the value is a string
|
|
171
|
+
* Match.when(Match.string, (s) => `string: ${s}`),
|
|
172
|
+
* // Ensure all possible cases are handled
|
|
173
|
+
* Match.exhaustive
|
|
174
|
+
* )
|
|
175
|
+
*
|
|
176
|
+
* match(0) // => "number: 0"
|
|
177
|
+
*
|
|
178
|
+
* match("hello") // => "string: hello"
|
|
179
|
+
* ```
|
|
180
|
+
*
|
|
181
|
+
* @see {@link value} for creating a matcher from a specific value.
|
|
182
|
+
*
|
|
183
|
+
* @stability stable
|
|
184
|
+
* @category constructors
|
|
185
|
+
* @since 4.0.0
|
|
186
|
+
*/
|
|
187
|
+
const type = type$1;
|
|
188
|
+
/**
|
|
189
|
+
* Creates a matcher from a specific value.
|
|
190
|
+
*
|
|
191
|
+
* **When to use**
|
|
192
|
+
*
|
|
193
|
+
* Use to match one concrete input immediately.
|
|
194
|
+
*
|
|
195
|
+
* **Details**
|
|
196
|
+
*
|
|
197
|
+
* This function allows you to define a `Matcher` directly from a given value,
|
|
198
|
+
* rather than from a type. This is useful when working with known values,
|
|
199
|
+
* enabling structured pattern matching on objects, primitives, or any data
|
|
200
|
+
* structure.
|
|
201
|
+
*
|
|
202
|
+
* Once the matcher is created, you can use pattern-matching functions like
|
|
203
|
+
* {@link when} to define how different cases should be handled.
|
|
204
|
+
*
|
|
205
|
+
* **Example** (Matching an Object by Property)
|
|
206
|
+
*
|
|
207
|
+
* ```ts import.meta.vitest
|
|
208
|
+
* import { Match } from "effect"
|
|
209
|
+
*
|
|
210
|
+
* const input = { name: "John", age: 30 }
|
|
211
|
+
*
|
|
212
|
+
* // Create a matcher for the specific object
|
|
213
|
+
* const result = Match.value(input).pipe(
|
|
214
|
+
* // Match when the 'name' property is "John"
|
|
215
|
+
* Match.when(
|
|
216
|
+
* { name: "John" },
|
|
217
|
+
* (user) => `${user.name} is ${user.age} years old`
|
|
218
|
+
* ),
|
|
219
|
+
* // Provide a fallback if no match is found
|
|
220
|
+
* Match.orElse(() => "Oh, not John")
|
|
221
|
+
* )
|
|
222
|
+
*
|
|
223
|
+
* result // => "John is 30 years old"
|
|
224
|
+
* ```
|
|
225
|
+
*
|
|
226
|
+
* @see {@link type} for creating a matcher from a specific type.
|
|
227
|
+
*
|
|
228
|
+
* @stability stable
|
|
229
|
+
* @category constructors
|
|
230
|
+
* @since 4.0.0
|
|
231
|
+
*/
|
|
232
|
+
const value = value$1;
|
|
233
|
+
/**
|
|
234
|
+
* Matches values by a discriminator field and requires every possible case to
|
|
235
|
+
* be handled.
|
|
236
|
+
*
|
|
237
|
+
* **When to use**
|
|
238
|
+
*
|
|
239
|
+
* Use to define an exhaustive discriminator handler map that finalizes the
|
|
240
|
+
* matcher.
|
|
241
|
+
*
|
|
242
|
+
* **Details**
|
|
243
|
+
*
|
|
244
|
+
* This is the exhaustive variant of {@link discriminators}. Each possible
|
|
245
|
+
* discriminator value must have a corresponding handler, so the matcher is
|
|
246
|
+
* finalized directly and does not require `Match.exhaustive` at the end of the
|
|
247
|
+
* pipeline.
|
|
248
|
+
*
|
|
249
|
+
* **Example** (Handling all discriminator cases)
|
|
250
|
+
*
|
|
251
|
+
* ```ts import.meta.vitest
|
|
252
|
+
* import { Match, pipe } from "effect"
|
|
253
|
+
*
|
|
254
|
+
* const match = pipe(
|
|
255
|
+
* Match.type<
|
|
256
|
+
* { type: "A"; a: string } | { type: "B"; b: number } | {
|
|
257
|
+
* type: "C"
|
|
258
|
+
* c: boolean
|
|
259
|
+
* }
|
|
260
|
+
* >(),
|
|
261
|
+
* Match.discriminatorsExhaustive("type")({
|
|
262
|
+
* A: (a) => a.a,
|
|
263
|
+
* B: (b) => b.b,
|
|
264
|
+
* C: (c) => c.c
|
|
265
|
+
* })
|
|
266
|
+
* )
|
|
267
|
+
* match({ type: "C", c: true }) // => true
|
|
268
|
+
* ```
|
|
269
|
+
*
|
|
270
|
+
* @see {@link discriminators} for defining discriminator handlers without finalizing the matcher
|
|
271
|
+
*
|
|
272
|
+
* @stability stable
|
|
273
|
+
* @category defining patterns
|
|
274
|
+
* @since 4.0.0
|
|
275
|
+
*/
|
|
276
|
+
const discriminatorsExhaustive = discriminatorsExhaustive$1;
|
|
277
|
+
/**
|
|
278
|
+
* Matches discriminated union members by their `_tag` field.
|
|
279
|
+
*
|
|
280
|
+
* **When to use**
|
|
281
|
+
*
|
|
282
|
+
* Use to handle one or more `_tag` cases with the same matcher branch.
|
|
283
|
+
*
|
|
284
|
+
* **Details**
|
|
285
|
+
*
|
|
286
|
+
* This helper follows the Effect convention that discriminated unions use
|
|
287
|
+
* `"_tag"` as their discriminator field. Use {@link discriminator} for a
|
|
288
|
+
* different discriminator field.
|
|
289
|
+
*
|
|
290
|
+
* **Example** (Matching a discriminated union by tag)
|
|
291
|
+
*
|
|
292
|
+
* ```ts import.meta.vitest
|
|
293
|
+
* import { Match } from "effect"
|
|
294
|
+
*
|
|
295
|
+
* type Event =
|
|
296
|
+
* | { readonly _tag: "fetch" }
|
|
297
|
+
* | { readonly _tag: "success"; readonly data: string }
|
|
298
|
+
* | { readonly _tag: "error"; readonly error: Error }
|
|
299
|
+
* | { readonly _tag: "cancel" }
|
|
300
|
+
*
|
|
301
|
+
* const match = Match.type<Event>().pipe(
|
|
302
|
+
* // Match either "fetch" or "success"
|
|
303
|
+
* Match.tag("fetch", "success", () => `Ok!`),
|
|
304
|
+
* // Match "error" and extract the error message
|
|
305
|
+
* Match.tag("error", (event) => `Error: ${event.error.message}`),
|
|
306
|
+
* // Match "cancel"
|
|
307
|
+
* Match.tag("cancel", () => "Cancelled"),
|
|
308
|
+
* Match.exhaustive
|
|
309
|
+
* )
|
|
310
|
+
*
|
|
311
|
+
* match({ _tag: "success", data: "Hello" }) // => "Ok!"
|
|
312
|
+
*
|
|
313
|
+
* match({ _tag: "error", error: new Error("Oops!") }) // => "Error: Oops!"
|
|
314
|
+
* ```
|
|
315
|
+
*
|
|
316
|
+
* @stability stable
|
|
317
|
+
* @category defining patterns
|
|
318
|
+
* @since 4.0.0
|
|
319
|
+
*/
|
|
320
|
+
const tag = tag$1;
|
|
321
|
+
/**
|
|
322
|
+
* Matches values based on their `_tag` field, mapping each tag to a
|
|
323
|
+
* corresponding handler.
|
|
324
|
+
*
|
|
325
|
+
* **Details**
|
|
326
|
+
*
|
|
327
|
+
* This function provides a way to handle discriminated unions by mapping `_tag`
|
|
328
|
+
* values to specific functions. Each handler receives the matched value and
|
|
329
|
+
* returns a transformed result. If all possible tags are handled, you can
|
|
330
|
+
* enforce exhaustiveness using `Match.exhaustive` to ensure no case is missed.
|
|
331
|
+
*
|
|
332
|
+
* **Example** (Mapping tag handlers)
|
|
333
|
+
*
|
|
334
|
+
* ```ts import.meta.vitest
|
|
335
|
+
* import { Match, pipe } from "effect"
|
|
336
|
+
*
|
|
337
|
+
* const match = pipe(
|
|
338
|
+
* Match.type<
|
|
339
|
+
* { _tag: "A"; a: string } | { _tag: "B"; b: number } | {
|
|
340
|
+
* _tag: "C"
|
|
341
|
+
* c: boolean
|
|
342
|
+
* }
|
|
343
|
+
* >(),
|
|
344
|
+
* Match.tags({
|
|
345
|
+
* A: (a) => a.a,
|
|
346
|
+
* B: (b) => b.b,
|
|
347
|
+
* C: (c) => c.c
|
|
348
|
+
* }),
|
|
349
|
+
* Match.exhaustive
|
|
350
|
+
* )
|
|
351
|
+
* match({ _tag: "A", a: "ok" }) // => "ok"
|
|
352
|
+
* ```
|
|
353
|
+
*
|
|
354
|
+
* @stability stable
|
|
355
|
+
* @category defining patterns
|
|
356
|
+
* @since 4.0.0
|
|
357
|
+
*/
|
|
358
|
+
const tags = tags$1;
|
|
359
|
+
/**
|
|
360
|
+
* Provides a fallback value when no patterns match.
|
|
361
|
+
*
|
|
362
|
+
* **When to use**
|
|
363
|
+
*
|
|
364
|
+
* Use to finalize a matcher with a fallback for unmatched input.
|
|
365
|
+
*
|
|
366
|
+
* **Details**
|
|
367
|
+
*
|
|
368
|
+
* This function ensures that a matcher always returns a valid result, even if
|
|
369
|
+
* no defined patterns match. It acts as a default case, similar to the
|
|
370
|
+
* `default` clause in a `switch` statement or the final `else` in an `if-else`
|
|
371
|
+
* chain.
|
|
372
|
+
*
|
|
373
|
+
* **Example** (Providing a default value when no patterns match)
|
|
374
|
+
*
|
|
375
|
+
* ```ts import.meta.vitest
|
|
376
|
+
* import { Match } from "effect"
|
|
377
|
+
*
|
|
378
|
+
* // Create a matcher for string or number values
|
|
379
|
+
* const match = Match.type<string | number>().pipe(
|
|
380
|
+
* // Match when the value is "a"
|
|
381
|
+
* Match.when("a", () => "ok"),
|
|
382
|
+
* // Fallback when no patterns match
|
|
383
|
+
* Match.orElse(() => "fallback")
|
|
384
|
+
* )
|
|
385
|
+
*
|
|
386
|
+
* match("a") // => "ok"
|
|
387
|
+
*
|
|
388
|
+
* match("b") // => "fallback"
|
|
389
|
+
* ```
|
|
390
|
+
*
|
|
391
|
+
* @see {@link option} for finalizing unmatched input as `Option.none`
|
|
392
|
+
* @see {@link result} for returning unmatched input as a `Result` failure
|
|
393
|
+
* @see {@link orElseAbsurd} for finalizing when unmatched input should be impossible
|
|
394
|
+
*
|
|
395
|
+
* @stability stable
|
|
396
|
+
* @category completion
|
|
397
|
+
* @since 4.0.0
|
|
398
|
+
*/
|
|
399
|
+
const orElse = orElse$1;
|
|
400
|
+
/**
|
|
401
|
+
* Completes a matcher that handles every remaining input case.
|
|
402
|
+
*
|
|
403
|
+
* **When to use**
|
|
404
|
+
*
|
|
405
|
+
* Use to require TypeScript to reject incomplete matcher definitions before the
|
|
406
|
+
* matcher is turned into a function.
|
|
407
|
+
*
|
|
408
|
+
* **Details**
|
|
409
|
+
*
|
|
410
|
+
* If any case is still unmatched, the matcher does not type-check as
|
|
411
|
+
* exhaustive.
|
|
412
|
+
*
|
|
413
|
+
* **Example** (Ensuring all cases are covered)
|
|
414
|
+
*
|
|
415
|
+
* ```ts import.meta.vitest
|
|
416
|
+
* import { Match } from "effect"
|
|
417
|
+
*
|
|
418
|
+
* // Create a matcher for string or number values
|
|
419
|
+
* const match = Match.type<string | number>().pipe(
|
|
420
|
+
* // Match when the value is a number
|
|
421
|
+
* Match.when(Match.number, (n) => `number: ${n}`),
|
|
422
|
+
* // Mark the match as exhaustive, ensuring all cases are handled
|
|
423
|
+
* // TypeScript will throw an error if any case is missing
|
|
424
|
+
* // @ts-expect-error Type 'string' is not assignable to type 'never'
|
|
425
|
+
* Match.exhaustive
|
|
426
|
+
* )
|
|
427
|
+
* ```
|
|
428
|
+
*
|
|
429
|
+
* @stability stable
|
|
430
|
+
* @category completion
|
|
431
|
+
* @since 4.0.0
|
|
432
|
+
*/
|
|
433
|
+
const exhaustive = exhaustive$1;
|
|
434
|
+
export { tags as a, tag as i, exhaustive as n, type as o, orElse as r, value as s, discriminatorsExhaustive as t };
|