@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.
Files changed (108) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +47 -2
  3. package/dist/Argument-D81dqizB.mjs +57 -0
  4. package/dist/Array-B4kuTQeW.mjs +2323 -0
  5. package/dist/Boolean-kILIvmhE.mjs +26 -0
  6. package/dist/ChildProcess-BCIwxPGc.mjs +577 -0
  7. package/dist/CliError-Cf5xqkkj.mjs +633 -0
  8. package/dist/Command-Dzq9KM-h.mjs +5135 -0
  9. package/dist/Config-B6OND9WR.mjs +854 -0
  10. package/dist/Console-BKHUkH6a.mjs +141 -0
  11. package/dist/Data-CeCULr0-.mjs +251 -0
  12. package/dist/Digest-CBd3uv5B.mjs +348 -0
  13. package/dist/Duration-EH9Vy4U6.mjs +791 -0
  14. package/dist/Effect-CKFpqbmw.mjs +12911 -0
  15. package/dist/FileSystem-4pPcEb_i.mjs +1366 -0
  16. package/dist/HttpClientError-BUeMWx70.mjs +303 -0
  17. package/dist/HttpClientResponse-D5ZKICVV.mjs +855 -0
  18. package/dist/Match-CGPLZYrV.mjs +434 -0
  19. package/dist/MutableHashMap-f8nW8AJR.mjs +376 -0
  20. package/dist/MutableHashSet-_HI572Ya.mjs +155 -0
  21. package/dist/MutableRef-D4Qv592C.mjs +107 -0
  22. package/dist/Number-BvkRkfc-.mjs +137 -0
  23. package/dist/Option-DkxSnBhp.mjs +3967 -0
  24. package/dist/Order-C1JC991I.mjs +481 -0
  25. package/dist/Path-Djdv_eF5.mjs +130 -0
  26. package/dist/Queue-CO5UQ6os.mjs +1394 -0
  27. package/dist/Redacted-RkJrG5Me.mjs +160 -0
  28. package/dist/Ref-BIPOxJNH.mjs +267 -0
  29. package/dist/Runtime-BInIAwK3.mjs +297 -0
  30. package/dist/Schema-MiKt5K1v.mjs +10999 -0
  31. package/dist/SecureRandom-B_U4ysO3.mjs +279 -0
  32. package/dist/Semaphore-DOVJ4ZGS.mjs +177 -0
  33. package/dist/Stdio-KylmOBX_.mjs +74 -0
  34. package/dist/Stream-bK9QIETN.mjs +4012 -0
  35. package/dist/String-q5dcsVe4.mjs +351 -0
  36. package/dist/TerminalCapabilities-w_44MAca.mjs +1769 -0
  37. package/dist/WebCrypto-ZI_GNVlw.mjs +33 -0
  38. package/dist/actor-call.service-CGM_vD9u.mjs +1269 -0
  39. package/dist/actor-client.adapter-Coem7gF1.mjs +3691 -0
  40. package/dist/akter-program.config-C4cXx4Fr.mjs +7034 -0
  41. package/dist/akter.cli.mjs +5 -0
  42. package/dist/app-cli.config.mjs +49 -0
  43. package/dist/app-entry.pure.mjs +31 -0
  44. package/dist/archive/akter-archive.schema.mjs +65 -0
  45. package/dist/archive/akter-archive.service.mjs +309 -0
  46. package/dist/archive/archive-cli.config.mjs +45 -0
  47. package/dist/archive/archive-invalid.errors.mjs +5 -0
  48. package/dist/archive/archived-lineage.pure.mjs +13 -0
  49. package/dist/archive/tar.pure.mjs +291 -0
  50. package/dist/archive/zstd.adapter.mjs +46 -0
  51. package/dist/bench/bench-report.pure.mjs +120 -0
  52. package/dist/bench/bench-runner.pure.mjs +89 -0
  53. package/dist/bench/bench.service.mjs +301 -0
  54. package/dist/cli-runtime.layer-BqK2mmVL.mjs +1191 -0
  55. package/dist/cli-runtime.layer.mjs +1 -0
  56. package/dist/cloud-client.adapter-Cy1BjDbG.mjs +3186 -0
  57. package/dist/cloud-client.adapter-DOVMoYAj.mjs +304 -0
  58. package/dist/command/akter-commands.config.mjs +32 -0
  59. package/dist/command/akter-program.config.mjs +1 -0
  60. package/dist/credentials/credentials.service.mjs +226 -0
  61. package/dist/credentials/keychain.adapter.mjs +92 -0
  62. package/dist/credentials/login.config.mjs +251 -0
  63. package/dist/deploy/auth/api-attempt.service.mjs +30 -0
  64. package/dist/deploy/auth/token-refresh.errors.mjs +4 -0
  65. package/dist/deploy/build-bundle.adapter.mjs +133 -0
  66. package/dist/deploy/build-manifest.pure.mjs +44 -0
  67. package/dist/deploy/cloud-client.adapter.mjs +1 -0
  68. package/dist/deploy/cloud-url.pure.mjs +17 -0
  69. package/dist/deploy/deploy-failed.errors.mjs +17 -0
  70. package/dist/deploy/deploy.service.mjs +156 -0
  71. package/dist/deploy/request-failure.pure.mjs +87 -0
  72. package/dist/dev-runner.pure.mjs +30 -0
  73. package/dist/docs/doc-topics.pure.mjs +21 -0
  74. package/dist/docs/docs.config.mjs +1 -0
  75. package/dist/docs.config-_21Xi6HU.mjs +190 -0
  76. package/dist/export/actor-export.service.mjs +267 -0
  77. package/dist/export/export-failed.errors.mjs +4 -0
  78. package/dist/export/export-failure.pure.mjs +18 -0
  79. package/dist/export/ordered-lines.pure.mjs +43 -0
  80. package/dist/export/ranged-download.pure.mjs +66 -0
  81. package/dist/export/snapshot-download.pure.mjs +86 -0
  82. package/dist/history-runner.pure.mjs +186 -0
  83. package/dist/history-since.pure.mjs +17 -0
  84. package/dist/hosted-runtime.layer-Cx3IPsEd.mjs +16358 -0
  85. package/dist/local/environment-cli.config.mjs +90 -0
  86. package/dist/local/environment-runner.pure.mjs +75 -0
  87. package/dist/local/local-cli.config.mjs +159 -0
  88. package/dist/logs/log-follow.config.mjs +21 -0
  89. package/dist/logs/log-follow.service.mjs +87 -0
  90. package/dist/logs/log-lines.pure.mjs +44 -0
  91. package/dist/migrate-runner.pure.mjs +28 -0
  92. package/dist/operation-input.pure-CS9iUhqK.mjs +1383 -0
  93. package/dist/operation-registry.pure-DVC8EDgj.mjs +283 -0
  94. package/dist/registry/actor-call.service.mjs +1 -0
  95. package/dist/registry/actor-commands.config.mjs +127 -0
  96. package/dist/registry/actor-refusal.pure.mjs +34 -0
  97. package/dist/registry/approval.service.mjs +80 -0
  98. package/dist/registry/cloud-commands.config.mjs +151 -0
  99. package/dist/registry/cloud-served.pure.mjs +31 -0
  100. package/dist/registry/operation-call.service.mjs +262 -0
  101. package/dist/registry/operation-input.pure.mjs +1 -0
  102. package/dist/registry/operation-output.pure.mjs +91 -0
  103. package/dist/registry/served-command.config.mjs +57 -0
  104. package/dist/runner-exited.errors.mjs +10 -0
  105. package/dist/terminal/cli-exit.errors.mjs +38 -0
  106. package/dist/terminal/cli-failure.pure.mjs +31 -0
  107. package/dist/terminal/confirm.adapter.mjs +27 -0
  108. package/package.json +61 -3
@@ -0,0 +1,854 @@
1
+ import { $ as fromResult, M as fail, N as failCause, Qr as isFailReason, V as flatMapEager, W as fnUntraced, Wr as fromReasons, Xr as isDieReason, Xt as succeed, _ as catchEager, dt as map$1, ia as Reference, m as catchCause, mt as mapEager, ni as makeDieReason, ri as makeFailReason, si as reasonAnnotations, va as Prototype } from "./Effect-CKFpqbmw.mjs";
2
+ import { $ as isFailure, S as isCanonicalArrayIndex, Y as fail$1, at as succeed$1, nt as map$2 } from "./Array-B4kuTQeW.mjs";
3
+ import { Cn as memoize, F as PipeInspectableProto, S as none, bn as dual, gt as assignProperty, un as isTagged, w as some } from "./Option-DkxSnBhp.mjs";
4
+ import { Cn as Transformation, F as String$2, N as Redacted$1, On as transformEffect, P as SchemaError, Sn as unknown, Tn as passthrough, gn as decodeTo, hn as applyToSelfOrLastLinkEncoding, ht as isBetween, jn as Pointer, ln as toCodecStringTree, mn as decodeUnknownEffect, o as BooleanLiterals, tn as make$2, v as Int, vn as getIndexSignatureKeys, xn as toEncoded } from "./Schema-MiKt5K1v.mjs";
5
+ // ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/ConfigProvider.js
6
+ /**
7
+ * Data sources used by `Config` to load raw configuration values. A
8
+ * `ConfigProvider` reads paths from places such as environment variables,
9
+ * JavaScript objects, `.env` contents, or directories, and returns a uniform
10
+ * `Node` shape that config schemas can decode. The module also includes helpers
11
+ * for composing providers, changing paths, and installing providers through
12
+ * layers.
13
+ *
14
+ * @stability stable
15
+ * @since 4.0.0
16
+ */
17
+ /**
18
+ * Creates a `Value` node representing a terminal string leaf.
19
+ *
20
+ * **When to use**
21
+ *
22
+ * Use when building nodes inside a custom `ConfigProvider`'s `get`
23
+ * callback.
24
+ *
25
+ * **Details**
26
+ *
27
+ * The function returns a new plain object.
28
+ *
29
+ * **Example** (Creating a value node)
30
+ *
31
+ * ```ts import.meta.vitest
32
+ * import { ConfigProvider } from "effect"
33
+ *
34
+ * ConfigProvider.makeValue("3000") // => { _tag: "Value", value: "3000" }
35
+ * ```
36
+ *
37
+ * @see {@link makeRecord} – for object-like containers
38
+ * @see {@link makeArray} – for array-like containers
39
+ *
40
+ * @stability stable
41
+ * @category constructors
42
+ * @since 4.0.0
43
+ */
44
+ function makeValue(value) {
45
+ return {
46
+ _tag: "Value",
47
+ value
48
+ };
49
+ }
50
+ /**
51
+ * Creates a `Record` node representing an object-like container with known
52
+ * child keys.
53
+ *
54
+ * **When to use**
55
+ *
56
+ * Use when you need to describe a directory or JSON object inside a custom
57
+ * provider.
58
+ *
59
+ * **Details**
60
+ *
61
+ * The optional `value` allows a node to be both a container and a leaf at the
62
+ * same time (for example, an env var `A=x` that also has children `A_FOO` and
63
+ * `A_BAR`).
64
+ *
65
+ * **Example** (Creating a record node)
66
+ *
67
+ * ```ts import.meta.vitest
68
+ * import { ConfigProvider } from "effect"
69
+ *
70
+ * const node = ConfigProvider.makeRecord(new Set(["host", "port"]))
71
+ * node._tag // => "Record"
72
+ * if (node._tag === "Record") {
73
+ * node.keys // => new Set(["host", "port"])
74
+ * node.value // => undefined
75
+ * }
76
+ * ```
77
+ *
78
+ * @see {@link makeValue} – for terminal leaves
79
+ * @see {@link makeArray} – for array-like containers
80
+ *
81
+ * @stability stable
82
+ * @category constructors
83
+ * @since 4.0.0
84
+ */
85
+ function makeRecord(keys, value) {
86
+ return {
87
+ _tag: "Record",
88
+ keys,
89
+ value
90
+ };
91
+ }
92
+ /**
93
+ * Creates an `Array` node representing an indexed container with a known
94
+ * length.
95
+ *
96
+ * **When to use**
97
+ *
98
+ * Use when you need to describe a JSON array or numerically indexed env vars
99
+ * inside a custom provider.
100
+ *
101
+ * **Details**
102
+ *
103
+ * The optional `value` allows a node to be both a container and a leaf at the
104
+ * same time.
105
+ *
106
+ * **Example** (Creating an array node)
107
+ *
108
+ * ```ts import.meta.vitest
109
+ * import { ConfigProvider } from "effect"
110
+ *
111
+ * ConfigProvider.makeArray(3) // => { _tag: "Array", length: 3, value: undefined }
112
+ * ```
113
+ *
114
+ * @see {@link makeValue} – for terminal leaves
115
+ * @see {@link makeRecord} – for object-like containers
116
+ *
117
+ * @stability stable
118
+ * @category constructors
119
+ * @since 4.0.0
120
+ */
121
+ function makeArray(length, value) {
122
+ return {
123
+ _tag: "Array",
124
+ length,
125
+ value
126
+ };
127
+ }
128
+ /**
129
+ * Context reference for the active raw configuration provider, registered in the context with a
130
+ * default value of `fromEnv()`. Because it is a `Context.Reference`, it is
131
+ * available without explicit provision; `Config` schemas automatically resolve
132
+ * it.
133
+ *
134
+ * **When to use**
135
+ *
136
+ * Use to override the active raw configuration provider for an entire program,
137
+ * or retrieve the current provider inside an Effect.
138
+ *
139
+ * **Example** (Providing a custom provider)
140
+ *
141
+ * ```ts import.meta.vitest
142
+ * import { ConfigProvider, Effect } from "effect"
143
+ *
144
+ * const provider = ConfigProvider.fromUnknown({ port: 8080 })
145
+ *
146
+ * const program = Effect.gen(function*() {
147
+ * const current = yield* ConfigProvider.ConfigProvider
148
+ * return current
149
+ * }).pipe(
150
+ * Effect.provideService(ConfigProvider.ConfigProvider, provider)
151
+ * )
152
+ *
153
+ * Effect.runSync(program) === provider // => true
154
+ * ```
155
+ *
156
+ * @see {@link layer} – install a provider as a Layer
157
+ * @see {@link layerAdd} – add a fallback provider as a Layer
158
+ *
159
+ * @stability stable
160
+ * @category services
161
+ * @since 4.0.0
162
+ */
163
+ const ConfigProvider = /*#__PURE__*/ Reference("effect/ConfigProvider", { defaultValue: () => fromEnv() });
164
+ const Proto$1 = {
165
+ ...PipeInspectableProto,
166
+ toJSON() {
167
+ return { _id: "ConfigProvider" };
168
+ }
169
+ };
170
+ const identityPath = (path) => path;
171
+ function makeProvider(load, mapInput) {
172
+ const self = Object.create(Proto$1);
173
+ self.load = load;
174
+ self.mapInput = mapInput;
175
+ return self;
176
+ }
177
+ function makeSource(get, transform) {
178
+ return makeProvider((path) => get(transform(path)), (f) => makeSource(get, (path) => f(transform(path))));
179
+ }
180
+ /**
181
+ * Creates a `ConfigProvider` from a raw lookup function.
182
+ *
183
+ * **When to use**
184
+ *
185
+ * Use when implementing a provider backed by a custom store, such as a
186
+ * database, remote API, or in-memory map.
187
+ *
188
+ * **Details**
189
+ *
190
+ * The `get` callback receives a `Path` and must return
191
+ * `Effect<Node | undefined, SourceError>`. Return `undefined` when the path does
192
+ * not exist, a `Node` when it does, and fail with `SourceError` only when the
193
+ * source cannot be read.
194
+ *
195
+ * Providers created by `make` also implement the path-transformation
196
+ * capability used by {@link mapInput}, {@link constantCase}, and
197
+ * {@link nested}.
198
+ *
199
+ * **Example** (Creating a simple in-memory provider)
200
+ *
201
+ * ```ts import.meta.vitest
202
+ * import { ConfigProvider, Effect } from "effect"
203
+ *
204
+ * const data: Record<string, string> = {
205
+ * host: "localhost",
206
+ * port: "5432"
207
+ * }
208
+ *
209
+ * const provider = ConfigProvider.make((path) => {
210
+ * const key = path.join(".")
211
+ * const value = data[key]
212
+ * return Effect.succeed(
213
+ * value !== undefined ? ConfigProvider.makeValue(value) : undefined
214
+ * )
215
+ * })
216
+ *
217
+ * Effect.runSync(provider.load(["host"])) // => ConfigProvider.makeValue("localhost")
218
+ * ```
219
+ *
220
+ * @see {@link fromEnv} – pre-built provider for environment variables
221
+ * @see {@link fromUnknown} – pre-built provider for JSON objects
222
+ *
223
+ * @stability stable
224
+ * @category constructors
225
+ * @since 4.0.0
226
+ */
227
+ function make$1(get) {
228
+ return makeSource(get, identityPath);
229
+ }
230
+ function emptyStringAsMissing(value, preserveEmptyStrings) {
231
+ return value === "" && !preserveEmptyStrings ? void 0 : value;
232
+ }
233
+ /**
234
+ * Creates a `ConfigProvider` backed by an explicit environment record.
235
+ *
236
+ * **When to use**
237
+ *
238
+ * Use when a restricted runtime cannot evaluate the automatic environment
239
+ * detection performed by {@link fromEnv}, or whenever the environment record
240
+ * must be supplied explicitly.
241
+ *
242
+ * **Details**
243
+ *
244
+ * `undefined` values are ignored. Path lookup and child discovery otherwise
245
+ * use the same environment-variable semantics as {@link fromEnv}.
246
+ *
247
+ * Environment variable names are captured at construction time to establish
248
+ * record keys and array lengths. The supplied record remains live for value
249
+ * lookups, so updates to known paths are observed by later loads. Keys added
250
+ * after construction can be loaded directly, but do not appear in captured
251
+ * parent record keys or array lengths.
252
+ *
253
+ * Literal empty strings are treated as missing values by default. Pass
254
+ * `{ preserveEmptyStrings: true }` to keep empty strings as explicit values.
255
+ *
256
+ * @see {@link fromEnv} – automatically reads the runtime environment
257
+ *
258
+ * @stability stable
259
+ * @category constructors
260
+ * @since 4.0.0
261
+ */
262
+ function fromEnvRecord(env, options) {
263
+ const preserveEmptyStrings = options?.preserveEmptyStrings === true;
264
+ const trie = buildEnvTrie(env);
265
+ return make$1((path) => succeed(nodeAtEnv(trie, env, path, preserveEmptyStrings)));
266
+ }
267
+ /**
268
+ * Creates a `ConfigProvider` backed by environment variables.
269
+ *
270
+ * **When to use**
271
+ *
272
+ * Use to read configuration from `process.env`, which is the default when no
273
+ * provider is explicitly set, or pass a custom env record for testing.
274
+ *
275
+ * **Details**
276
+ *
277
+ * Path segments are joined with `_` for direct lookup, and env var names are
278
+ * also split on `_` to build a trie for child key discovery. This means
279
+ * `DATABASE_HOST=localhost` is accessible at both path `["DATABASE_HOST"]`
280
+ * and `["DATABASE", "HOST"]`. If all immediate children of a trie node have
281
+ * purely numeric names, the node is reported as an `Array`; otherwise as a
282
+ * `Record`.
283
+ *
284
+ * The default environment merges `process.env` and `import.meta.env` (when
285
+ * available). Override by passing `{ env: { ... } }`.
286
+ *
287
+ * Literal empty strings are treated as missing values when loaded as values by
288
+ * default. Pass `{ preserveEmptyStrings: true }` to keep empty strings as
289
+ * explicit values. Child discovery still reflects the environment variable
290
+ * names present in the source.
291
+ *
292
+ * Never fails with `SourceError` — all lookups are synchronous.
293
+ *
294
+ * **Example** (Reading from a custom env record)
295
+ *
296
+ * ```ts import.meta.vitest
297
+ * import { Config, ConfigProvider, Effect } from "effect"
298
+ *
299
+ * const provider = ConfigProvider.fromEnv({
300
+ * env: {
301
+ * DATABASE_HOST: "localhost",
302
+ * DATABASE_PORT: "5432"
303
+ * }
304
+ * })
305
+ *
306
+ * const host = Config.String("HOST").parse(
307
+ * provider.pipe(ConfigProvider.nested("DATABASE"))
308
+ * )
309
+ *
310
+ * Effect.runSync(host) // => "localhost"
311
+ * ```
312
+ *
313
+ * @see {@link fromUnknown} – for JSON objects
314
+ * @see {@link fromEnvRecord} – for explicit records in restricted runtimes
315
+ * @see {@link constantCase} – bridge camelCase keys to SCREAMING_SNAKE_CASE
316
+ *
317
+ * @stability stable
318
+ * @category constructors
319
+ * @since 2.0.0
320
+ */
321
+ function fromEnv(options) {
322
+ return fromEnvRecord(options?.env ?? {
323
+ ...globalThis.process?.env,
324
+ ...import.meta.env
325
+ }, { preserveEmptyStrings: options?.preserveEmptyStrings });
326
+ }
327
+ function buildEnvTrie(env) {
328
+ const trie = {};
329
+ for (const [name, value] of Object.entries(env)) {
330
+ if (value === void 0) continue;
331
+ const segments = name.split("_");
332
+ let node = trie;
333
+ for (const seg of segments) {
334
+ const children = node.children ??= Object.create(null);
335
+ node = children[seg] ??= {};
336
+ }
337
+ }
338
+ return trie;
339
+ }
340
+ function nodeAtEnv(trie, env, path, preserveEmptyStrings) {
341
+ const key = path.map(String).join("_");
342
+ const leafValue = emptyStringAsMissing(Object.hasOwn(env, key) ? env[key] : void 0, preserveEmptyStrings);
343
+ const trieNode = trieNodeAt(trie, path);
344
+ const children = trieNode?.children ? Object.keys(trieNode.children) : [];
345
+ if (children.length === 0) return leafValue === void 0 ? void 0 : makeValue(leafValue);
346
+ if (children.every(isCanonicalArrayIndex)) return makeArray(Math.max(...children.map((k) => parseInt(k, 10))) + 1, leafValue);
347
+ return makeRecord(new Set(children), leafValue);
348
+ }
349
+ function trieNodeAt(root, path) {
350
+ if (path.length === 0) return root;
351
+ let node = root;
352
+ for (const seg of path) {
353
+ node = node?.children?.[String(seg)];
354
+ if (!node) return void 0;
355
+ }
356
+ return node;
357
+ }
358
+ // ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/Config.js
359
+ /**
360
+ * Descriptions of configuration values that can be read from a
361
+ * `ConfigProvider`. A `Config<T>` explains which keys to read, how to decode
362
+ * and validate them, and how to combine defaults, fallbacks, nested paths, and
363
+ * multiple settings. Configs are also Effects, so they can be yielded in
364
+ * `Effect.gen` after a provider has been supplied.
365
+ *
366
+ * @stability stable
367
+ * @since 4.0.0
368
+ */
369
+ const TypeId = "~effect/Config";
370
+ /**
371
+ * Represents the error type produced when config loading or validation fails.
372
+ *
373
+ * **When to use**
374
+ *
375
+ * Use when you need to inspect config loading or validation failures.
376
+ *
377
+ * **Details**
378
+ *
379
+ * Wraps either:
380
+ * - A `SourceError` — the provider could not read data (I/O failure).
381
+ * - A `SchemaError` — the data was found but did not match the schema
382
+ * (wrong type, out of range, missing key, etc.).
383
+ *
384
+ * @see {@link orElse} – recover from a ConfigError
385
+ * @see {@link withDefault} – provide a fallback when relevant input is absent
386
+ *
387
+ * @stability stable
388
+ * @category errors
389
+ * @since 4.0.0
390
+ */
391
+ var ConfigError = class {
392
+ _tag = "ConfigError";
393
+ name = "ConfigError";
394
+ cause;
395
+ constructor(cause) {
396
+ this.cause = cause;
397
+ }
398
+ get message() {
399
+ return this.cause.toString();
400
+ }
401
+ toString() {
402
+ return `ConfigError(${this.message})`;
403
+ }
404
+ };
405
+ const Proto = {
406
+ .../*#__PURE__*/ Prototype({
407
+ label: "Config",
408
+ evaluate(fiber) {
409
+ return this.parse(fiber.getRef(ConfigProvider));
410
+ }
411
+ }),
412
+ [TypeId]: TypeId,
413
+ toJSON() {
414
+ return { _id: "Config" };
415
+ }
416
+ };
417
+ function make(evaluator) {
418
+ const self = Object.create(Proto);
419
+ self.evaluator = evaluator;
420
+ self.parse = (provider) => flatMapEager(evaluator(provider, []), fromResult);
421
+ return self;
422
+ }
423
+ const evaluateAt = (self, provider, pathPrefix) => self.evaluator(provider, pathPrefix);
424
+ /**
425
+ * Transforms the parsed value of a config with a pure function.
426
+ *
427
+ * **When to use**
428
+ *
429
+ * Use when you need to transform a parsed config value with a function that
430
+ * cannot fail.
431
+ *
432
+ * **Example** (Uppercasing a string config)
433
+ *
434
+ * ```ts import.meta.vitest
435
+ * import { Config, ConfigProvider, Effect } from "effect"
436
+ *
437
+ * const upper = Config.String("name").pipe(
438
+ * Config.map((s) => s.toUpperCase())
439
+ * )
440
+ *
441
+ * const provider = ConfigProvider.fromUnknown({ name: "alice" })
442
+ * Effect.runSync(upper.parse(provider)) // => "ALICE"
443
+ * ```
444
+ *
445
+ * @see {@link mapEffect} – when the transformation can fail
446
+ *
447
+ * @stability stable
448
+ * @category mapping
449
+ * @since 2.0.0
450
+ */
451
+ const map = /*#__PURE__*/ dual(2, (self, f) => {
452
+ return make((provider, pathPrefix) => map$1(evaluateAt(self, provider, pathPrefix), map$2(f)));
453
+ });
454
+ /**
455
+ * Provides a fallback value when the config is absent.
456
+ *
457
+ * **When to use**
458
+ *
459
+ * Use when you need to make a config key optional with a sensible default.
460
+ *
461
+ * **Gotchas**
462
+ *
463
+ * Validation and source errors still propagate. For an {@link all} group, any
464
+ * absent child causes the default to replace the entire group unless another
465
+ * child fails. Apply defaults to individual children to preserve other values.
466
+ *
467
+ * A schema that successfully decodes absent input keeps its decoded value
468
+ * instead of using the default. Schema configs first represent a missing or
469
+ * incompatible provider shape as `undefined`; the default is used only when
470
+ * the schema rejects that value and no relevant input was found.
471
+ *
472
+ * **Example** (Defaulting a missing port)
473
+ *
474
+ * ```ts import.meta.vitest
475
+ * import { Config, ConfigProvider, Effect } from "effect"
476
+ *
477
+ * const port = Config.Number("port").pipe(Config.withDefault(3000))
478
+ *
479
+ * const provider = ConfigProvider.fromUnknown({})
480
+ * Effect.runSync(port.parse(provider)) // => 3000
481
+ * ```
482
+ *
483
+ * @see {@link option} – returns `Option` instead of a default value
484
+ * @see {@link orElse} – catches all errors, not just absent input
485
+ *
486
+ * @stability stable
487
+ * @category combinators
488
+ * @since 2.0.0
489
+ */
490
+ const withDefault = /*#__PURE__*/ dual(2, (self, defaultValue) => {
491
+ return make((provider, pathPrefix) => mapEager(evaluateAt(self, provider, pathPrefix), (resolution) => isFailure(resolution) ? succeed$1(defaultValue) : resolution));
492
+ });
493
+ /**
494
+ * Makes a config optional: returns `Some(value)` on success and `None` when the
495
+ * config is absent.
496
+ *
497
+ * **When to use**
498
+ *
499
+ * Use when you need to handle a config key that may or may not be present.
500
+ *
501
+ * **Gotchas**
502
+ *
503
+ * Validation and source errors still propagate. For an {@link all} group, any
504
+ * absent child produces `None` unless another child fails. Successful values
505
+ * are always wrapped in `Some`, including `undefined` when the schema
506
+ * explicitly accepts it. Schema configs first represent a missing or
507
+ * incompatible provider shape as `undefined`; `None` is returned only when the
508
+ * schema rejects that value and no relevant input was found.
509
+ *
510
+ * **Example** (Reading optional config)
511
+ *
512
+ * ```ts import.meta.vitest
513
+ * import { Config, ConfigProvider, Effect, Option } from "effect"
514
+ *
515
+ * const maybePort = Config.option(Config.Number("port"))
516
+ *
517
+ * const provider = ConfigProvider.fromUnknown({})
518
+ * Effect.runSync(maybePort.parse(provider)) // => Option.none()
519
+ * ```
520
+ *
521
+ * @see {@link withDefault} – provide a concrete fallback value instead
522
+ *
523
+ * @stability stable
524
+ * @category combinators
525
+ * @since 2.0.0
526
+ */
527
+ const option = (self) => self.pipe(map(some), withDefault(none()));
528
+ const isSourceError = (u) => isTagged(u, "SourceError");
529
+ const cursorToString = () => "<configuration>";
530
+ const mapReasons = (f) => (self) => catchCause(self, (cause) => failCause(fromReasons(cause.reasons.map(f))));
531
+ const loadCursor = (provider, path) => provider.load(path).pipe(mapReasons((reason) => isFailReason(reason) ? makeDieReason(reason.error).annotate(reasonAnnotations(reason)) : reason), mapEager((node) => ({
532
+ provider,
533
+ path,
534
+ node,
535
+ toString: cursorToString
536
+ })));
537
+ const loadChildCursor = (cursor, segment) => loadCursor(cursor.provider, [...cursor.path, segment]);
538
+ const decodeFromCursor = (ast, decode) => decodeTo(unknown, ast, new Transformation(transformEffect((input) => decode(input)), passthrough()));
539
+ const isScalarInput = (ast) => {
540
+ switch (ast._tag) {
541
+ case "Union": return ast.types.every(isScalarInput);
542
+ case "Objects":
543
+ case "Arrays":
544
+ case "Suspend": return false;
545
+ default: return true;
546
+ }
547
+ };
548
+ const hasProviderInput = (ast, node) => {
549
+ switch (ast._tag) {
550
+ case "Objects": return node?._tag === "Record";
551
+ case "Arrays": return node?._tag === "Array";
552
+ case "Union": return ast.types.some((ast) => hasProviderInput(ast, node));
553
+ case "Suspend": return hasProviderInput(ast.thunk(), node);
554
+ default: return node?.value !== void 0;
555
+ }
556
+ };
557
+ const toConfigCursorAST = /*#__PURE__*/ memoize((root) => {
558
+ const seen = /* @__PURE__ */ new WeakSet();
559
+ const recur = applyToSelfOrLastLinkEncoding((ast) => {
560
+ seen.add(ast);
561
+ switch (ast._tag) {
562
+ case "Objects": {
563
+ const materialize = fnUntraced(function* (cursor) {
564
+ if (cursor.node?._tag !== "Record") return;
565
+ const node = cursor.node;
566
+ const keys = /* @__PURE__ */ new Set();
567
+ for (const property of ast.propertySignatures) if (typeof property.name === "string") keys.add(property.name);
568
+ if (ast.indexSignatures.length > 0) {
569
+ const input = {};
570
+ for (const key of node.keys) assignProperty(input, key, void 0);
571
+ for (const is of ast.indexSignatures) for (const key of getIndexSignatureKeys(input, is.parameter)) if (typeof key === "string") keys.add(key);
572
+ }
573
+ const out = {};
574
+ for (const key of keys) {
575
+ const child = yield* loadChildCursor(cursor, key);
576
+ if (child.node !== void 0) assignProperty(out, key, child);
577
+ }
578
+ return out;
579
+ });
580
+ return decodeFromCursor(ast.recur(recur, (ast) => ast), materialize);
581
+ }
582
+ case "Arrays": {
583
+ const materialize = fnUntraced(function* (cursor) {
584
+ if (cursor.node?._tag !== "Array") return;
585
+ const out = [];
586
+ for (let i = 0; i < cursor.node.length; i++) out.push(yield* loadChildCursor(cursor, i));
587
+ return out;
588
+ });
589
+ return decodeFromCursor(ast.recur(recur), materialize);
590
+ }
591
+ case "Union":
592
+ for (const member of ast.types) recur(member);
593
+ if (!isScalarInput(ast)) return ast.recur(recur);
594
+ break;
595
+ case "Suspend": {
596
+ const target = ast.thunk();
597
+ if (!seen.has(target)) recur(target);
598
+ return ast.recur(recur);
599
+ }
600
+ case "Declaration":
601
+ case "Any": throw new globalThis.Error("Config.schema does not support opaque StringTree encodings", { cause: ast });
602
+ }
603
+ return decodeFromCursor(ast, (cursor) => succeed(cursor.node?.value));
604
+ });
605
+ return recur(root);
606
+ });
607
+ /**
608
+ * Creates a `Config<T>` from a `Schema.Codec`.
609
+ *
610
+ * **When to use**
611
+ *
612
+ * Use when you need to read structured or schema-validated configuration.
613
+ *
614
+ * **Details**
615
+ *
616
+ * The optional `path` sets the local path segment(s) for the config lookup.
617
+ * It is appended to the logical path prefix accumulated from outer
618
+ * {@link nested} calls. Pass a single string for a flat key or an array for
619
+ * nested paths.
620
+ *
621
+ * Convenience constructors such as `String`, `Number`, and `Boolean` delegate
622
+ * to this API.
623
+ *
624
+ * The codec is converted to its canonical `StringTree` form. Its encoded shape
625
+ * determines how provider data is loaded: scalar schemas read a co-located
626
+ * scalar value, object schemas read declared properties and matching record
627
+ * keys, and array schemas read indexed children. A mixed-shape union loads each
628
+ * member according to that member's shape before applying the union's mode and
629
+ * checks.
630
+ *
631
+ * At the config's lookup path, a missing node or a node that cannot provide the
632
+ * representation required by the schema is decoded as `undefined`. Missing
633
+ * object properties remain omitted so the schema's property semantics still
634
+ * apply. Decoding success always wins, even when no provider input was found.
635
+ * For example,
636
+ * `Schema.UndefinedOr(Schema.String)` decodes to `undefined` and is not replaced
637
+ * by {@link withDefault}. If decoding fails and no relevant representation was
638
+ * found, the config is absent. Invalid data in a relevant representation is a
639
+ * validation failure. Provider `SourceError`s are always failures.
640
+ *
641
+ * **Gotchas**
642
+ *
643
+ * Plain `Schema.Array` and `Schema.Record` schemas use structural provider
644
+ * input. Use {@link Array} or {@link Record} when a flat separated string must
645
+ * also be accepted.
646
+ *
647
+ * `Schema.Struct` and {@link all} describe different lookup models. An
648
+ * existing object, even an empty one, is validated as a whole by a struct;
649
+ * missing required fields cause a validation failure. An `all` group combines
650
+ * independent lookups and is absent if any child is absent and none fail.
651
+ *
652
+ * The canonical `StringTree` encoding must expose a concrete scalar, object,
653
+ * array, or union shape. Opaque encodings such as `Schema.Any`,
654
+ * `Schema.Unknown`, `Schema.ObjectKeyword`, `Schema.Json`, and
655
+ * `Schema.MutableJson` are rejected synchronously when this config is
656
+ * constructed, including when they are nested in another schema. Suspended
657
+ * recursive schemas remain supported when their eventual shape is concrete.
658
+ * Declarations such as `Schema.URL` also remain supported when their canonical
659
+ * encoding has a concrete shape. To read arbitrary JSON from one scalar value,
660
+ * use `Schema.fromJsonString(Schema.Json)`.
661
+ *
662
+ * **Example** (Reading a structured config)
663
+ *
664
+ * ```ts import.meta.vitest
665
+ * import { Config, ConfigProvider, Effect, Schema } from "effect"
666
+ *
667
+ * const DbConfig = Config.schema(
668
+ * Schema.Struct({
669
+ * host: Schema.String,
670
+ * port: Schema.Int
671
+ * }),
672
+ * "db"
673
+ * )
674
+ *
675
+ * const provider = ConfigProvider.fromUnknown({
676
+ * db: { host: "localhost", port: 5432 }
677
+ * })
678
+ *
679
+ * Effect.runSync(DbConfig.parse(provider)) // => { host: "localhost", port: 5432 }
680
+ * ```
681
+ *
682
+ * @see {@link String} / {@link Number} / {@link Boolean} – shortcuts for
683
+ * single-value configs
684
+ *
685
+ * @stability stable
686
+ * @category schemas
687
+ * @since 4.0.0
688
+ */
689
+ function schema(codec, path) {
690
+ const codecStringTree = toCodecStringTree(codec);
691
+ const encodedAst = toEncoded(codecStringTree.ast);
692
+ const decodeCursor = decodeUnknownEffect(make$2(toConfigCursorAST(codecStringTree.ast)));
693
+ const localPath = typeof path === "string" ? [path] : path ?? [];
694
+ return make((provider, pathPrefix) => {
695
+ const fullPath = [...pathPrefix, ...localPath];
696
+ return loadCursor(provider, fullPath).pipe(flatMapEager((cursor) => decodeCursor(cursor).pipe(mapEager(succeed$1), catchEager((issue) => {
697
+ const error = new ConfigError(new SchemaError(fullPath.length > 0 ? new Pointer(fullPath, issue) : issue));
698
+ return hasProviderInput(encodedAst, cursor.node) ? fail(error) : succeed(fail$1(error));
699
+ }))), mapReasons((reason) => isDieReason(reason) && isSourceError(reason.defect) ? makeFailReason(new ConfigError(reason.defect)).annotate(reasonAnnotations(reason)) : reason));
700
+ });
701
+ }
702
+ const PortSchema = /*#__PURE__*/ Int.check(/*#__PURE__*/ isBetween({
703
+ minimum: 1,
704
+ maximum: 65535
705
+ }));
706
+ /**
707
+ * Creates a config for a single string value.
708
+ *
709
+ * **When to use**
710
+ *
711
+ * Use when reading a single string env var or config key.
712
+ *
713
+ * **Details**
714
+ *
715
+ * Shortcut for `Config.schema(Schema.String, name)`.
716
+ *
717
+ * **Example** (Reading a string config)
718
+ *
719
+ * ```ts import.meta.vitest
720
+ * import { Config, ConfigProvider, Effect } from "effect"
721
+ *
722
+ * const host = Config.String("HOST")
723
+ *
724
+ * const provider = ConfigProvider.fromUnknown({ HOST: "localhost" })
725
+ * Effect.runSync(host.parse(provider)) // => "localhost"
726
+ * ```
727
+ *
728
+ * @see {@link NonEmptyString} – rejects empty strings
729
+ * @see {@link schema} – for more complex types
730
+ *
731
+ * @stability stable
732
+ * @category constructors
733
+ * @since 2.0.0
734
+ */
735
+ function String$1(name) {
736
+ return schema(String$2, name);
737
+ }
738
+ /**
739
+ * Creates a config for a boolean value parsed from common string
740
+ * representations.
741
+ *
742
+ * **When to use**
743
+ *
744
+ * Use to read boolean flags from string-like config sources.
745
+ *
746
+ * **Details**
747
+ *
748
+ * Accepted values: `true`, `false`, `yes`, `no`, `on`, `off`, `1`, `0`,
749
+ * `y`, `n`.
750
+ *
751
+ * **Example** (Reading a boolean flag)
752
+ *
753
+ * ```ts import.meta.vitest
754
+ * import { Config, ConfigProvider, Effect } from "effect"
755
+ *
756
+ * const program = Config.Boolean("FEATURE_FLAG")
757
+ *
758
+ * const provider = ConfigProvider.fromEnv({
759
+ * env: {
760
+ * FEATURE_FLAG: "yes"
761
+ * }
762
+ * })
763
+ *
764
+ * Effect.runSync(
765
+ * program.pipe(Effect.provideService(ConfigProvider.ConfigProvider, provider))
766
+ * ) // => true
767
+ * ```
768
+ *
769
+ * @stability stable
770
+ * @category constructors
771
+ * @since 2.0.0
772
+ */
773
+ function Boolean(name) {
774
+ return schema(BooleanLiterals, name);
775
+ }
776
+ /**
777
+ * Creates a config for a port number (integer in 1–65535).
778
+ *
779
+ * **When to use**
780
+ *
781
+ * Use to read network port settings that must be valid port numbers.
782
+ *
783
+ * **Details**
784
+ *
785
+ * Accepts integers from `1` through `65535`.
786
+ *
787
+ * **Example** (Reading a port)
788
+ *
789
+ * ```ts import.meta.vitest
790
+ * import { Config, ConfigProvider, Effect } from "effect"
791
+ *
792
+ * const program = Config.Port("PORT")
793
+ *
794
+ * const provider = ConfigProvider.fromEnv({
795
+ * env: {
796
+ * PORT: "8080"
797
+ * }
798
+ * })
799
+ *
800
+ * Effect.runSync(
801
+ * program.pipe(Effect.provideService(ConfigProvider.ConfigProvider, provider))
802
+ * ) // => 8080
803
+ * ```
804
+ *
805
+ * @see {@link Int} for integer config values outside the port range
806
+ *
807
+ * @stability stable
808
+ * @category constructors
809
+ * @since 3.16.0
810
+ */
811
+ function Port(name) {
812
+ return schema(PortSchema, name);
813
+ }
814
+ /**
815
+ * Creates a config for a redacted string value. The parsed result is wrapped
816
+ * in a `Redacted` container that hides the value from logs and `toString`.
817
+ *
818
+ * **When to use**
819
+ *
820
+ * Use to read secret string settings that should not be exposed in logs or
821
+ * string output.
822
+ *
823
+ * **Details**
824
+ *
825
+ * Shortcut for `Config.schema(Schema.Redacted(Schema.String), name)`.
826
+ *
827
+ * **Example** (Reading a secret)
828
+ *
829
+ * ```ts import.meta.vitest
830
+ * import { Config, ConfigProvider, Effect } from "effect"
831
+ *
832
+ * const program = Config.Redacted("API_KEY").pipe(Effect.map(String))
833
+ *
834
+ * const provider = ConfigProvider.fromEnv({
835
+ * env: {
836
+ * API_KEY: "sk-1234567890abcdef"
837
+ * }
838
+ * })
839
+ *
840
+ * Effect.runSync(
841
+ * program.pipe(Effect.provideService(ConfigProvider.ConfigProvider, provider))
842
+ * ) // => "<redacted>"
843
+ * ```
844
+ *
845
+ * @see {@link String} for non-secret string settings
846
+ *
847
+ * @stability stable
848
+ * @category constructors
849
+ * @since 2.0.0
850
+ */
851
+ function Redacted(name) {
852
+ return schema(Redacted$1(String$2), name);
853
+ }
854
+ export { option as a, String$1 as i, Port as n, withDefault as o, Redacted as r, ConfigProvider as s, Boolean as t };