effect 4.0.0-beta.83 → 4.0.0-beta.84

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 (195) hide show
  1. package/dist/Array.d.ts +64 -64
  2. package/dist/Array.js +26 -26
  3. package/dist/Cache.d.ts +1 -1
  4. package/dist/Cache.js +1 -1
  5. package/dist/Cause.d.ts +68 -68
  6. package/dist/Cause.js +47 -47
  7. package/dist/Channel.d.ts +5 -5
  8. package/dist/Channel.js +3 -3
  9. package/dist/Clock.d.ts +1 -1
  10. package/dist/Clock.js +1 -1
  11. package/dist/Combiner.d.ts +9 -9
  12. package/dist/Combiner.js +8 -8
  13. package/dist/Config.d.ts +15 -94
  14. package/dist/Config.d.ts.map +1 -1
  15. package/dist/Config.js +22 -70
  16. package/dist/Config.js.map +1 -1
  17. package/dist/ConfigProvider.d.ts +58 -74
  18. package/dist/ConfigProvider.d.ts.map +1 -1
  19. package/dist/ConfigProvider.js +66 -41
  20. package/dist/ConfigProvider.js.map +1 -1
  21. package/dist/Console.d.ts +1 -1
  22. package/dist/Console.js +1 -1
  23. package/dist/Data.d.ts +15 -15
  24. package/dist/Data.js +3 -3
  25. package/dist/DateTime.d.ts +6 -6
  26. package/dist/DateTime.js +2 -2
  27. package/dist/Duration.d.ts +3 -3
  28. package/dist/Duration.js +3 -3
  29. package/dist/Effect.d.ts +84 -45
  30. package/dist/Effect.d.ts.map +1 -1
  31. package/dist/Effect.js +72 -33
  32. package/dist/Effect.js.map +1 -1
  33. package/dist/Equal.d.ts +7 -7
  34. package/dist/Equal.js +5 -5
  35. package/dist/Equivalence.d.ts +17 -17
  36. package/dist/Equivalence.js +13 -13
  37. package/dist/Exit.d.ts +3 -3
  38. package/dist/Exit.js +3 -3
  39. package/dist/Formatter.d.ts +5 -5
  40. package/dist/Formatter.js +4 -4
  41. package/dist/Function.d.ts +10 -10
  42. package/dist/Function.js +3 -3
  43. package/dist/HashMap.d.ts +3 -3
  44. package/dist/HashMap.js +1 -1
  45. package/dist/Iterable.d.ts +6 -6
  46. package/dist/Iterable.js +2 -2
  47. package/dist/JsonPatch.d.ts +2 -2
  48. package/dist/Layer.d.ts +1 -1
  49. package/dist/Layer.js +1 -1
  50. package/dist/Logger.d.ts +1 -1
  51. package/dist/Logger.js +1 -1
  52. package/dist/Match.d.ts +8 -8
  53. package/dist/Match.js +8 -8
  54. package/dist/Metric.d.ts +3 -3
  55. package/dist/Metric.js +3 -3
  56. package/dist/Optic.d.ts +30 -30
  57. package/dist/Optic.js +12 -12
  58. package/dist/Option.d.ts +7 -7
  59. package/dist/Option.js +7 -7
  60. package/dist/Order.d.ts +23 -23
  61. package/dist/Order.js +20 -20
  62. package/dist/Pool.d.ts +1 -1
  63. package/dist/Pool.js +1 -1
  64. package/dist/Predicate.d.ts +88 -88
  65. package/dist/Predicate.js +47 -47
  66. package/dist/PubSub.d.ts +3 -3
  67. package/dist/PubSub.js +3 -3
  68. package/dist/Reducer.d.ts +1 -1
  69. package/dist/Reducer.js +1 -1
  70. package/dist/Result.d.ts +18 -18
  71. package/dist/Result.js +8 -8
  72. package/dist/Runtime.d.ts +1 -1
  73. package/dist/Runtime.js +1 -1
  74. package/dist/Schema.d.ts +265 -120
  75. package/dist/Schema.d.ts.map +1 -1
  76. package/dist/Schema.js +285 -116
  77. package/dist/Schema.js.map +1 -1
  78. package/dist/SchemaAST.d.ts +1 -1
  79. package/dist/SchemaAST.d.ts.map +1 -1
  80. package/dist/SchemaAST.js +13 -9
  81. package/dist/SchemaAST.js.map +1 -1
  82. package/dist/SchemaGetter.d.ts +48 -48
  83. package/dist/SchemaGetter.js +44 -44
  84. package/dist/SchemaIssue.d.ts +3 -3
  85. package/dist/SchemaIssue.js +3 -3
  86. package/dist/SchemaParser.d.ts +122 -22
  87. package/dist/SchemaParser.d.ts.map +1 -1
  88. package/dist/SchemaParser.js +186 -50
  89. package/dist/SchemaParser.js.map +1 -1
  90. package/dist/SchemaRepresentation.d.ts +1 -1
  91. package/dist/SchemaRepresentation.d.ts.map +1 -1
  92. package/dist/SchemaRepresentation.js +96 -2
  93. package/dist/SchemaRepresentation.js.map +1 -1
  94. package/dist/SchemaTransformation.d.ts +20 -20
  95. package/dist/SchemaTransformation.js +18 -18
  96. package/dist/Stream.d.ts +3 -3
  97. package/dist/Stream.js +2 -2
  98. package/dist/Stream.js.map +1 -1
  99. package/dist/String.d.ts +1 -1
  100. package/dist/String.js +1 -1
  101. package/dist/Struct.d.ts +1 -1
  102. package/dist/Struct.js +1 -1
  103. package/dist/Types.d.ts +13 -13
  104. package/dist/internal/effect.js +23 -10
  105. package/dist/internal/effect.js.map +1 -1
  106. package/dist/internal/schema/cause.d.ts +2 -0
  107. package/dist/internal/schema/cause.d.ts.map +1 -0
  108. package/dist/internal/schema/cause.js +24 -0
  109. package/dist/internal/schema/cause.js.map +1 -0
  110. package/dist/internal/schema/schema.d.ts +8 -4
  111. package/dist/internal/schema/schema.d.ts.map +1 -1
  112. package/dist/internal/schema/schema.js +21 -8
  113. package/dist/internal/schema/schema.js.map +1 -1
  114. package/dist/testing/TestSchema.d.ts +3 -3
  115. package/dist/testing/TestSchema.js +1 -1
  116. package/dist/unstable/ai/AiError.d.ts +1 -1
  117. package/dist/unstable/ai/AiError.js +1 -1
  118. package/dist/unstable/ai/Chat.d.ts +1 -1
  119. package/dist/unstable/ai/Chat.js +1 -1
  120. package/dist/unstable/cli/Prompt.js +2 -2
  121. package/dist/unstable/cli/Prompt.js.map +1 -1
  122. package/dist/unstable/httpapi/HttpApiScalar.d.ts +2 -2
  123. package/dist/unstable/rpc/Rpc.d.ts +1 -1
  124. package/dist/unstable/rpc/Rpc.js +1 -1
  125. package/dist/unstable/rpc/RpcGroup.d.ts.map +1 -1
  126. package/dist/unstable/rpc/RpcGroup.js +3 -4
  127. package/dist/unstable/rpc/RpcGroup.js.map +1 -1
  128. package/dist/unstable/sql/SqlResolver.d.ts.map +1 -1
  129. package/dist/unstable/sql/SqlResolver.js +15 -2
  130. package/dist/unstable/sql/SqlResolver.js.map +1 -1
  131. package/dist/unstable/workflow/Activity.d.ts +1 -0
  132. package/dist/unstable/workflow/Activity.d.ts.map +1 -1
  133. package/dist/unstable/workflow/Activity.js +1 -0
  134. package/dist/unstable/workflow/Activity.js.map +1 -1
  135. package/dist/unstable/workflow/WorkflowEngine.js +1 -1
  136. package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
  137. package/package.json +1 -1
  138. package/src/Array.ts +65 -65
  139. package/src/Cache.ts +1 -1
  140. package/src/Cause.ts +68 -68
  141. package/src/Channel.ts +5 -5
  142. package/src/Clock.ts +1 -1
  143. package/src/Combiner.ts +9 -9
  144. package/src/Config.ts +40 -108
  145. package/src/ConfigProvider.ts +139 -100
  146. package/src/Console.ts +1 -1
  147. package/src/Data.ts +15 -15
  148. package/src/DateTime.ts +6 -6
  149. package/src/Duration.ts +3 -3
  150. package/src/Effect.ts +89 -45
  151. package/src/Equal.ts +7 -7
  152. package/src/Equivalence.ts +17 -17
  153. package/src/Exit.ts +3 -3
  154. package/src/Formatter.ts +5 -5
  155. package/src/Function.ts +10 -10
  156. package/src/HashMap.ts +3 -3
  157. package/src/Iterable.ts +6 -6
  158. package/src/JsonPatch.ts +2 -2
  159. package/src/Layer.ts +1 -1
  160. package/src/Logger.ts +1 -1
  161. package/src/Match.ts +8 -8
  162. package/src/Metric.ts +3 -3
  163. package/src/Optic.ts +30 -30
  164. package/src/Option.ts +7 -7
  165. package/src/Order.ts +23 -23
  166. package/src/Pool.ts +1 -1
  167. package/src/Predicate.ts +88 -88
  168. package/src/PubSub.ts +3 -3
  169. package/src/Reducer.ts +1 -1
  170. package/src/Result.ts +20 -20
  171. package/src/Runtime.ts +1 -1
  172. package/src/Schema.ts +314 -131
  173. package/src/SchemaAST.ts +20 -11
  174. package/src/SchemaGetter.ts +48 -48
  175. package/src/SchemaIssue.ts +3 -3
  176. package/src/SchemaParser.ts +197 -58
  177. package/src/SchemaRepresentation.ts +73 -3
  178. package/src/SchemaTransformation.ts +20 -20
  179. package/src/Stream.ts +4 -4
  180. package/src/String.ts +1 -1
  181. package/src/Struct.ts +1 -1
  182. package/src/Types.ts +13 -13
  183. package/src/internal/effect.ts +29 -10
  184. package/src/internal/schema/cause.ts +26 -0
  185. package/src/internal/schema/schema.ts +36 -10
  186. package/src/testing/TestSchema.ts +3 -3
  187. package/src/unstable/ai/AiError.ts +1 -1
  188. package/src/unstable/ai/Chat.ts +1 -1
  189. package/src/unstable/cli/Prompt.ts +1 -1
  190. package/src/unstable/httpapi/HttpApiScalar.ts +2 -2
  191. package/src/unstable/rpc/Rpc.ts +1 -1
  192. package/src/unstable/rpc/RpcGroup.ts +3 -4
  193. package/src/unstable/sql/SqlResolver.ts +15 -2
  194. package/src/unstable/workflow/Activity.ts +2 -0
  195. package/src/unstable/workflow/WorkflowEngine.ts +1 -1
@@ -176,7 +176,7 @@ export function makeArray(length: number, value?: string): Node {
176
176
  * **Gotchas**
177
177
  *
178
178
  * Do not use `SourceError` for "key not found". That case is represented by
179
- * returning `undefined` from `load` or `get`.
179
+ * returning `undefined` from `load`.
180
180
  *
181
181
  * **Example** (Failing with a SourceError)
182
182
  *
@@ -190,8 +190,8 @@ export function makeArray(length: number, value?: string): Node {
190
190
  * )
191
191
  * ```
192
192
  *
193
- * @see {@link ConfigProvider} – the interface whose `load`/`get` may fail
194
- * with this error
193
+ * @see {@link ConfigProvider} – the interface whose `load` may fail with this
194
+ * error
195
195
  *
196
196
  * @category models
197
197
  * @since 4.0.0
@@ -234,13 +234,10 @@ export type Path = ReadonlyArray<string | number>
234
234
  *
235
235
  * **Details**
236
236
  *
237
- * `load(path)` resolves `mapInput` and `prefix` transformations, then
238
- * delegates to `get`. This is what the `Config` module calls. `get(path)` is
239
- * raw access to the underlying store without path transformations.
240
- * `mapInput` and `prefix` are optional path transformations set by
241
- * {@link mapInput} and {@link nested}. All methods return
242
- * `Effect<Node | undefined, SourceError>`: `undefined` means "not found" and
243
- * `SourceError` means the source itself failed.
237
+ * `load(path)` is the semantic lookup operation used by the `Config` module.
238
+ * It applies provider transformations and composition before consulting the
239
+ * underlying source. `undefined` means "not found" and `SourceError` means the
240
+ * source itself failed.
244
241
  *
245
242
  * @see {@link make} – construct a provider from a lookup function
246
243
  * @see {@link orElse} – compose providers with fallback
@@ -260,33 +257,8 @@ export interface ConfigProvider extends Pipeable {
260
257
  */
261
258
  readonly load: (path: Path) => Effect.Effect<Node | undefined, SourceError>
262
259
 
263
- /**
264
- * Raw access to the underlying source.
265
- *
266
- * **When to use**
267
- *
268
- * Use to read from the backing source without applying this provider's path
269
- * transformations.
270
- */
271
- readonly get: (path: Path) => Effect.Effect<Node | undefined, SourceError>
272
-
273
- /**
274
- * Function to map the input path.
275
- *
276
- * **When to use**
277
- *
278
- * Use to store the path transformation applied before raw provider lookup.
279
- */
280
- readonly mapInput: ((path: Path) => Path) | undefined
281
-
282
- /**
283
- * Prefix to add to the input path.
284
- *
285
- * **When to use**
286
- *
287
- * Use to store the path prefix applied before raw provider lookup.
288
- */
289
- readonly prefix: Path | undefined
260
+ /** @internal */
261
+ readonly state: ProviderState
290
262
  }
291
263
 
292
264
  /**
@@ -335,6 +307,57 @@ const Proto = {
335
307
  }
336
308
  }
337
309
 
310
+ type SourceState = {
311
+ readonly _tag: "Source"
312
+ readonly get: (path: Path) => Effect.Effect<Node | undefined, SourceError>
313
+ readonly transform: (path: Path) => Path
314
+ }
315
+
316
+ type OrElseState = {
317
+ readonly _tag: "OrElse"
318
+ readonly first: ConfigProvider
319
+ readonly second: ConfigProvider
320
+ }
321
+
322
+ type ProviderState = SourceState | OrElseState
323
+
324
+ const identityPath = (path: Path): Path => path
325
+
326
+ function makeProvider(
327
+ state: ProviderState,
328
+ load: (path: Path) => Effect.Effect<Node | undefined, SourceError>
329
+ ): ConfigProvider {
330
+ const self = Object.create(Proto)
331
+ self.state = state
332
+ self.load = load
333
+ return self
334
+ }
335
+
336
+ function makeSource(
337
+ get: (path: Path) => Effect.Effect<Node | undefined, SourceError>,
338
+ transform: (path: Path) => Path
339
+ ): ConfigProvider {
340
+ const state: SourceState = {
341
+ _tag: "Source",
342
+ get,
343
+ transform
344
+ }
345
+ return makeProvider(state, (path) => state.get(state.transform(path)))
346
+ }
347
+
348
+ function makeOrElse(first: ConfigProvider, second: ConfigProvider): ConfigProvider {
349
+ const state: OrElseState = {
350
+ _tag: "OrElse",
351
+ first,
352
+ second
353
+ }
354
+ return makeProvider(state, (path) =>
355
+ Effect.flatMap(
356
+ state.first.load(path),
357
+ (node) => node ? Effect.succeed(node) : state.second.load(path)
358
+ ))
359
+ }
360
+
338
361
  /**
339
362
  * Creates a `ConfigProvider` from a raw lookup function.
340
363
  *
@@ -349,11 +372,7 @@ const Proto = {
349
372
  * `Effect<Node | undefined, SourceError>`. Return `undefined` when the path
350
373
  * does not exist; fail with `SourceError` only for actual I/O errors.
351
374
  *
352
- * The optional `mapInput` and `prefix` parameters are wired into the
353
- * resulting `load` method so that combinators like {@link mapInput} and
354
- * {@link nested} can compose without wrapping `get`.
355
- *
356
- * **Example** (A simple in-memory provider)
375
+ * **Example** (Creating a simple in-memory provider)
357
376
  *
358
377
  * ```ts
359
378
  * import { ConfigProvider, Effect } from "effect"
@@ -378,21 +397,8 @@ const Proto = {
378
397
  * @category constructors
379
398
  * @since 2.0.0
380
399
  */
381
- export function make(
382
- get: (path: Path) => Effect.Effect<Node | undefined, SourceError>,
383
- mapInput?: (path: Path) => Path,
384
- prefix?: Path
385
- ): ConfigProvider {
386
- const self = Object.create(Proto)
387
- self.get = get
388
- self.mapInput = mapInput
389
- self.prefix = prefix
390
- self.load = (path: Path) => {
391
- if (mapInput) path = mapInput(path)
392
- if (prefix) path = [...prefix, ...path]
393
- return get(path)
394
- }
395
- return self
400
+ export function make(get: (path: Path) => Effect.Effect<Node | undefined, SourceError>): ConfigProvider {
401
+ return makeSource(get, identityPath)
396
402
  }
397
403
 
398
404
  /**
@@ -406,7 +412,9 @@ export function make(
406
412
  *
407
413
  * **Details**
408
414
  *
409
- * Supports both data-last and data-first calling conventions.
415
+ * Each provider keeps its own path transformations. If the combined provider
416
+ * is later transformed with {@link mapInput} or {@link nested}, the
417
+ * transformation is applied to both sides.
410
418
  *
411
419
  * **Gotchas**
412
420
  *
@@ -443,7 +451,9 @@ export const orElse: {
443
451
  *
444
452
  * **Details**
445
453
  *
446
- * Supports both data-last and data-first calling conventions.
454
+ * Each provider keeps its own path transformations. If the combined provider
455
+ * is later transformed with {@link mapInput} or {@link nested}, the
456
+ * transformation is applied to both sides.
447
457
  *
448
458
  * **Gotchas**
449
459
  *
@@ -480,7 +490,9 @@ export const orElse: {
480
490
  *
481
491
  * **Details**
482
492
  *
483
- * Supports both data-last and data-first calling conventions.
493
+ * Each provider keeps its own path transformations. If the combined provider
494
+ * is later transformed with {@link mapInput} or {@link nested}, the
495
+ * transformation is applied to both sides.
484
496
  *
485
497
  * **Gotchas**
486
498
  *
@@ -508,8 +520,7 @@ export const orElse: {
508
520
  (self: ConfigProvider, that: ConfigProvider): ConfigProvider
509
521
  } = dual(
510
522
  2,
511
- (self: ConfigProvider, that: ConfigProvider): ConfigProvider =>
512
- make((path) => Effect.flatMap(self.get(path), (node) => node ? Effect.succeed(node) : that.get(path)))
523
+ (self: ConfigProvider, that: ConfigProvider): ConfigProvider => makeOrElse(self, that)
513
524
  )
514
525
 
515
526
  /**
@@ -522,10 +533,11 @@ export const orElse: {
522
533
  *
523
534
  * **Details**
524
535
  *
525
- * The function `f` receives the full path and must return a new path. If the
526
- * provider already has a `mapInput`, the functions compose: the existing
527
- * mapping runs first, then `f`. Supports both data-last and data-first calling
528
- * conventions.
536
+ * The function `f` receives the whole path produced by earlier provider
537
+ * transformations and must return a new path. Lookup path transformations
538
+ * compose in application order: the existing transformation runs first, then
539
+ * `f` runs. For providers composed with {@link orElse}, the transformation is
540
+ * applied to each operand.
529
541
  *
530
542
  * **Example** (Uppercasing path segments)
531
543
  *
@@ -560,10 +572,11 @@ export const mapInput: {
560
572
  *
561
573
  * **Details**
562
574
  *
563
- * The function `f` receives the full path and must return a new path. If the
564
- * provider already has a `mapInput`, the functions compose: the existing
565
- * mapping runs first, then `f`. Supports both data-last and data-first calling
566
- * conventions.
575
+ * The function `f` receives the whole path produced by earlier provider
576
+ * transformations and must return a new path. Lookup path transformations
577
+ * compose in application order: the existing transformation runs first, then
578
+ * `f` runs. For providers composed with {@link orElse}, the transformation is
579
+ * applied to each operand.
567
580
  *
568
581
  * **Example** (Uppercasing path segments)
569
582
  *
@@ -598,10 +611,11 @@ export const mapInput: {
598
611
  *
599
612
  * **Details**
600
613
  *
601
- * The function `f` receives the full path and must return a new path. If the
602
- * provider already has a `mapInput`, the functions compose: the existing
603
- * mapping runs first, then `f`. Supports both data-last and data-first calling
604
- * conventions.
614
+ * The function `f` receives the whole path produced by earlier provider
615
+ * transformations and must return a new path. Lookup path transformations
616
+ * compose in application order: the existing transformation runs first, then
617
+ * `f` runs. For providers composed with {@link orElse}, the transformation is
618
+ * applied to each operand.
605
619
  *
606
620
  * **Example** (Uppercasing path segments)
607
621
  *
@@ -629,7 +643,13 @@ export const mapInput: {
629
643
  } = dual(
630
644
  2,
631
645
  (self: ConfigProvider, f: (path: Path) => Path): ConfigProvider => {
632
- return make(self.get, self.mapInput ? flow(self.mapInput, f) : f, self.prefix ? f(self.prefix) : undefined)
646
+ const state = self.state
647
+ switch (state._tag) {
648
+ case "Source":
649
+ return makeSource(state.get, flow(state.transform, f))
650
+ case "OrElse":
651
+ return makeOrElse(mapInput(state.first, f), mapInput(state.second, f))
652
+ }
633
653
  }
634
654
  )
635
655
 
@@ -678,14 +698,16 @@ export const constantCase: (self: ConfigProvider) => ConfigProvider = mapInput((
678
698
  *
679
699
  * **Details**
680
700
  *
681
- * Accepts a single string or a full `Path` array. Supports both data-last and
682
- * data-first calling conventions.
701
+ * Accepts a single string or a full `Path` array. For providers composed with
702
+ * {@link orElse}, the prefix is applied to each operand. Supports both
703
+ * data-last and data-first calling conventions.
683
704
  *
684
705
  * **Gotchas**
685
706
  *
686
- * The prefix is prepended after any `mapInput` transformation runs, so
687
- * ordering matters when composing with {@link mapInput} or
688
- * {@link constantCase}.
707
+ * Ordering matters when composing with {@link mapInput} or
708
+ * {@link constantCase}. Later provider transformations run after earlier ones:
709
+ * a later `nested` becomes the outer prefix, and a later `mapInput` sees the
710
+ * whole path produced by previous transformations.
689
711
  *
690
712
  * **Example** (Nesting under a prefix)
691
713
  *
@@ -717,14 +739,16 @@ export const nested: {
717
739
  *
718
740
  * **Details**
719
741
  *
720
- * Accepts a single string or a full `Path` array. Supports both data-last and
721
- * data-first calling conventions.
742
+ * Accepts a single string or a full `Path` array. For providers composed with
743
+ * {@link orElse}, the prefix is applied to each operand. Supports both
744
+ * data-last and data-first calling conventions.
722
745
  *
723
746
  * **Gotchas**
724
747
  *
725
- * The prefix is prepended after any `mapInput` transformation runs, so
726
- * ordering matters when composing with {@link mapInput} or
727
- * {@link constantCase}.
748
+ * Ordering matters when composing with {@link mapInput} or
749
+ * {@link constantCase}. Later provider transformations run after earlier ones:
750
+ * a later `nested` becomes the outer prefix, and a later `mapInput` sees the
751
+ * whole path produced by previous transformations.
728
752
  *
729
753
  * **Example** (Nesting under a prefix)
730
754
  *
@@ -756,14 +780,16 @@ export const nested: {
756
780
  *
757
781
  * **Details**
758
782
  *
759
- * Accepts a single string or a full `Path` array. Supports both data-last and
760
- * data-first calling conventions.
783
+ * Accepts a single string or a full `Path` array. For providers composed with
784
+ * {@link orElse}, the prefix is applied to each operand. Supports both
785
+ * data-last and data-first calling conventions.
761
786
  *
762
787
  * **Gotchas**
763
788
  *
764
- * The prefix is prepended after any `mapInput` transformation runs, so
765
- * ordering matters when composing with {@link mapInput} or
766
- * {@link constantCase}.
789
+ * Ordering matters when composing with {@link mapInput} or
790
+ * {@link constantCase}. Later provider transformations run after earlier ones:
791
+ * a later `nested` becomes the outer prefix, and a later `mapInput` sees the
792
+ * whole path produced by previous transformations.
767
793
  *
768
794
  * **Example** (Nesting under a prefix)
769
795
  *
@@ -788,7 +814,13 @@ export const nested: {
788
814
  2,
789
815
  (self: ConfigProvider, prefix: string | Path): ConfigProvider => {
790
816
  const path = typeof prefix === "string" ? [prefix] : prefix
791
- return make(self.get, self.mapInput, self.prefix ? [...self.prefix, ...path] : path)
817
+ const state = self.state
818
+ switch (state._tag) {
819
+ case "Source":
820
+ return makeSource(state.get, flow(state.transform, (input) => [...path, ...input]))
821
+ case "OrElse":
822
+ return makeOrElse(nested(state.first, path), nested(state.second, path))
823
+ }
792
824
  }
793
825
  )
794
826
 
@@ -805,7 +837,7 @@ export const nested: {
805
837
  * Accepts either a plain `ConfigProvider` or an `Effect` that produces one.
806
838
  * When given an Effect, it is evaluated once when the layer is built.
807
839
  *
808
- * **Example** (Using a JSON object as the config source)
840
+ * **Example** (Reading config from a JSON object)
809
841
  *
810
842
  * ```ts
811
843
  * import { Config, ConfigProvider, Effect, Layer } from "effect"
@@ -1286,8 +1318,9 @@ export const fromDotEnv: (options?: {
1286
1318
  *
1287
1319
  * Resolution tries a regular file first and returns a `Value` node with
1288
1320
  * trimmed file contents. If the file read fails, it tries a directory and
1289
- * returns a `Record` node with immediate child names as keys. If both fail, it
1290
- * returns `SourceError`.
1321
+ * returns a `Record` node with immediate child names as keys. If both fail with
1322
+ * `NotFound`, it returns `undefined`. Other platform failures return
1323
+ * `SourceError`.
1291
1324
  *
1292
1325
  * Requires `Path` and `FileSystem` in the Effect context. Defaults to root
1293
1326
  * path `/`; override with `{ rootPath: "/etc/config" }`.
@@ -1332,15 +1365,19 @@ export const fromDir: (options?: {
1332
1365
 
1333
1366
  // If not a file, try reading as a *directory*
1334
1367
  const asDirectory = fs.readDirectory(fullPath).pipe(
1335
- Effect.map((entries: ReadonlyArray<any>) => {
1336
- // Support both string paths and DirEntry-like objects
1337
- const keys = entries.map((e) => typeof e === "string" ? platformPath.basename(e) : format(e?.name ?? ""))
1338
- return makeRecord(new Set(keys))
1339
- })
1368
+ Effect.map((entries) => makeRecord(new Set(entries.map((entry) => platformPath.basename(entry)))))
1340
1369
  )
1341
1370
 
1342
1371
  return asFile.pipe(
1343
- Effect.catch(() => asDirectory),
1372
+ Effect.catch((fileCause) =>
1373
+ asDirectory.pipe(
1374
+ Effect.catch((dirCause) =>
1375
+ isNotFound(fileCause) && isNotFound(dirCause)
1376
+ ? Effect.succeed(undefined)
1377
+ : Effect.fail(isNotFound(fileCause) ? dirCause : fileCause)
1378
+ )
1379
+ )
1380
+ ),
1344
1381
  Effect.mapError((cause: PlatformError) =>
1345
1382
  new SourceError({
1346
1383
  message: `Failed to read file at ${platformPath.join(rootPath, ...path.map(String))}`,
@@ -1350,3 +1387,5 @@ export const fromDir: (options?: {
1350
1387
  )
1351
1388
  })
1352
1389
  })
1390
+
1391
+ const isNotFound = (cause: PlatformError) => cause.reason._tag === "NotFound"
package/src/Console.ts CHANGED
@@ -78,7 +78,7 @@ export const Console: Context.Reference<Console> = effect.ConsoleRef
78
78
  /**
79
79
  * Creates an Effect that provides access to the current console service and lets you perform operations with it within an Effect context.
80
80
  *
81
- * **Example** (Using the current console service)
81
+ * **Example** (Accessing the current console service)
82
82
  *
83
83
  * ```ts
84
84
  * import { Console, Effect } from "effect"
package/src/Data.ts CHANGED
@@ -195,7 +195,7 @@ export declare namespace TaggedEnum {
195
195
  * `this["A"]`, `this["B"]`, etc. as placeholders for the generics. The
196
196
  * `Count` parameter declares how many generics are used (up to 4).
197
197
  *
198
- * **Example** (Generic tagged enum)
198
+ * **Example** (Defining a generic tagged enum)
199
199
  *
200
200
  * ```ts
201
201
  * import { Data } from "effect"
@@ -325,7 +325,7 @@ export declare namespace TaggedEnum {
325
325
  *
326
326
  * Use to select one full tagged-union variant by its `_tag` value.
327
327
  *
328
- * **Example** (extracting a variant type)
328
+ * **Example** (Extracting a variant type)
329
329
  *
330
330
  * ```ts
331
331
  * import type { Data } from "effect"
@@ -537,7 +537,7 @@ export declare namespace TaggedEnum {
537
537
  * on the tag being globally unique and the value being produced by your
538
538
  * constructors. For untrusted input, validate with the `Schema` module first.
539
539
  *
540
- * **Example** (Basic usage)
540
+ * **Example** (Creating and matching tagged enum values)
541
541
  *
542
542
  * ```ts
543
543
  * import { Data } from "effect"
@@ -562,7 +562,7 @@ export declare namespace TaggedEnum {
562
562
  * console.log(msg) // "/missing not found"
563
563
  * ```
564
564
  *
565
- * **Example** (Generic tagged enum)
565
+ * **Example** (Defining a generic tagged enum)
566
566
  *
567
567
  * ```ts
568
568
  * import { Data } from "effect"
@@ -610,7 +610,7 @@ export const taggedEnum: {
610
610
  * on the tag being globally unique and the value being produced by your
611
611
  * constructors. For untrusted input, validate with the `Schema` module first.
612
612
  *
613
- * **Example** (Basic usage)
613
+ * **Example** (Creating and matching tagged enum values)
614
614
  *
615
615
  * ```ts
616
616
  * import { Data } from "effect"
@@ -635,7 +635,7 @@ export const taggedEnum: {
635
635
  * console.log(msg) // "/missing not found"
636
636
  * ```
637
637
  *
638
- * **Example** (Generic tagged enum)
638
+ * **Example** (Defining a generic tagged enum)
639
639
  *
640
640
  * ```ts
641
641
  * import { Data } from "effect"
@@ -694,7 +694,7 @@ export const taggedEnum: {
694
694
  * on the tag being globally unique and the value being produced by your
695
695
  * constructors. For untrusted input, validate with the `Schema` module first.
696
696
  *
697
- * **Example** (Basic usage)
697
+ * **Example** (Creating and matching tagged enum values)
698
698
  *
699
699
  * ```ts
700
700
  * import { Data } from "effect"
@@ -719,7 +719,7 @@ export const taggedEnum: {
719
719
  * console.log(msg) // "/missing not found"
720
720
  * ```
721
721
  *
722
- * **Example** (Generic tagged enum)
722
+ * **Example** (Defining a generic tagged enum)
723
723
  *
724
724
  * ```ts
725
725
  * import { Data } from "effect"
@@ -778,7 +778,7 @@ export const taggedEnum: {
778
778
  * on the tag being globally unique and the value being produced by your
779
779
  * constructors. For untrusted input, validate with the `Schema` module first.
780
780
  *
781
- * **Example** (Basic usage)
781
+ * **Example** (Creating and matching tagged enum values)
782
782
  *
783
783
  * ```ts
784
784
  * import { Data } from "effect"
@@ -803,7 +803,7 @@ export const taggedEnum: {
803
803
  * console.log(msg) // "/missing not found"
804
804
  * ```
805
805
  *
806
- * **Example** (Generic tagged enum)
806
+ * **Example** (Defining a generic tagged enum)
807
807
  *
808
808
  * ```ts
809
809
  * import { Data } from "effect"
@@ -862,7 +862,7 @@ export const taggedEnum: {
862
862
  * on the tag being globally unique and the value being produced by your
863
863
  * constructors. For untrusted input, validate with the `Schema` module first.
864
864
  *
865
- * **Example** (Basic usage)
865
+ * **Example** (Creating and matching tagged enum values)
866
866
  *
867
867
  * ```ts
868
868
  * import { Data } from "effect"
@@ -887,7 +887,7 @@ export const taggedEnum: {
887
887
  * console.log(msg) // "/missing not found"
888
888
  * ```
889
889
  *
890
- * **Example** (Generic tagged enum)
890
+ * **Example** (Defining a generic tagged enum)
891
891
  *
892
892
  * ```ts
893
893
  * import { Data } from "effect"
@@ -946,7 +946,7 @@ export const taggedEnum: {
946
946
  * on the tag being globally unique and the value being produced by your
947
947
  * constructors. For untrusted input, validate with the `Schema` module first.
948
948
  *
949
- * **Example** (Basic usage)
949
+ * **Example** (Creating and matching tagged enum values)
950
950
  *
951
951
  * ```ts
952
952
  * import { Data } from "effect"
@@ -971,7 +971,7 @@ export const taggedEnum: {
971
971
  * console.log(msg) // "/missing not found"
972
972
  * ```
973
973
  *
974
- * **Example** (Generic tagged enum)
974
+ * **Example** (Defining a generic tagged enum)
975
975
  *
976
976
  * ```ts
977
977
  * import { Data } from "effect"
@@ -1098,7 +1098,7 @@ export const Error: new<A extends Record<string, any> = {}>(
1098
1098
  * The `_tag` is excluded from the constructor argument. Yielding an instance
1099
1099
  * inside `Effect.gen` fails the effect with this error.
1100
1100
  *
1101
- * **Example** (Tag-based error recovery)
1101
+ * **Example** (Recovering by tag)
1102
1102
  *
1103
1103
  * ```ts
1104
1104
  * import { Data, Effect } from "effect"
package/src/DateTime.ts CHANGED
@@ -3177,7 +3177,7 @@ export const mapEpochMillis: {
3177
3177
  * `DateTime.Zoned` values. Use `DateTime.withDateUtc` when the callback should
3178
3178
  * receive the UTC instant.
3179
3179
  *
3180
- * **Example** (Using time zone adjusted Dates)
3180
+ * **Example** (Applying time zone adjusted Dates)
3181
3181
  *
3182
3182
  * ```ts
3183
3183
  * import { DateTime } from "effect"
@@ -3202,7 +3202,7 @@ export const withDate: {
3202
3202
  * `DateTime.Zoned` values. Use `DateTime.withDateUtc` when the callback should
3203
3203
  * receive the UTC instant.
3204
3204
  *
3205
- * **Example** (Using time zone adjusted Dates)
3205
+ * **Example** (Applying time zone adjusted Dates)
3206
3206
  *
3207
3207
  * ```ts
3208
3208
  * import { DateTime } from "effect"
@@ -3227,7 +3227,7 @@ export const withDate: {
3227
3227
  * `DateTime.Zoned` values. Use `DateTime.withDateUtc` when the callback should
3228
3228
  * receive the UTC instant.
3229
3229
  *
3230
- * **Example** (Using time zone adjusted Dates)
3230
+ * **Example** (Applying time zone adjusted Dates)
3231
3231
  *
3232
3232
  * ```ts
3233
3233
  * import { DateTime } from "effect"
@@ -3253,7 +3253,7 @@ export const withDate: {
3253
3253
  * This ignores any associated time zone. Use `DateTime.withDate` when the
3254
3254
  * callback should receive the time-zone-adjusted wall-clock date.
3255
3255
  *
3256
- * **Example** (Using UTC Dates)
3256
+ * **Example** (Applying UTC Dates)
3257
3257
  *
3258
3258
  * ```ts
3259
3259
  * import { DateTime } from "effect"
@@ -3277,7 +3277,7 @@ export const withDateUtc: {
3277
3277
  * This ignores any associated time zone. Use `DateTime.withDate` when the
3278
3278
  * callback should receive the time-zone-adjusted wall-clock date.
3279
3279
  *
3280
- * **Example** (Using UTC Dates)
3280
+ * **Example** (Applying UTC Dates)
3281
3281
  *
3282
3282
  * ```ts
3283
3283
  * import { DateTime } from "effect"
@@ -3301,7 +3301,7 @@ export const withDateUtc: {
3301
3301
  * This ignores any associated time zone. Use `DateTime.withDate` when the
3302
3302
  * callback should receive the time-zone-adjusted wall-clock date.
3303
3303
  *
3304
- * **Example** (Using UTC Dates)
3304
+ * **Example** (Applying UTC Dates)
3305
3305
  *
3306
3306
  * ```ts
3307
3307
  * import { DateTime } from "effect"
package/src/Duration.ts CHANGED
@@ -573,7 +573,7 @@ export const negate = (self: Duration): Duration => {
573
573
  /**
574
574
  * A Duration representing zero time.
575
575
  *
576
- * **Example** (Using the zero duration)
576
+ * **Example** (Referencing the zero duration)
577
577
  *
578
578
  * ```ts
579
579
  * import { Duration } from "effect"
@@ -589,7 +589,7 @@ export const zero: Duration = make(0)
589
589
  /**
590
590
  * A Duration representing infinite time.
591
591
  *
592
- * **Example** (Using infinite duration)
592
+ * **Example** (Referencing infinite duration)
593
593
  *
594
594
  * ```ts
595
595
  * import { Duration } from "effect"
@@ -605,7 +605,7 @@ export const infinity: Duration = make(Infinity)
605
605
  /**
606
606
  * A Duration representing negative infinite time.
607
607
  *
608
- * **Example** (Using negative infinite duration)
608
+ * **Example** (Referencing negative infinite duration)
609
609
  *
610
610
  * ```ts
611
611
  * import { Duration } from "effect"