effect 4.0.0-beta.19 → 4.0.0-beta.20

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 (141) hide show
  1. package/dist/Channel.d.ts +6 -6
  2. package/dist/Channel.d.ts.map +1 -1
  3. package/dist/Channel.js.map +1 -1
  4. package/dist/Config.d.ts +5 -6
  5. package/dist/Config.d.ts.map +1 -1
  6. package/dist/Config.js +3 -3
  7. package/dist/Config.js.map +1 -1
  8. package/dist/Effect.d.ts +22 -22
  9. package/dist/Effect.d.ts.map +1 -1
  10. package/dist/Effect.js +3 -3
  11. package/dist/Effect.js.map +1 -1
  12. package/dist/ErrorReporter.js +2 -2
  13. package/dist/ErrorReporter.js.map +1 -1
  14. package/dist/Layer.d.ts +9 -9
  15. package/dist/Layer.d.ts.map +1 -1
  16. package/dist/Layer.js.map +1 -1
  17. package/dist/Schedule.d.ts +14 -6
  18. package/dist/Schedule.d.ts.map +1 -1
  19. package/dist/Schedule.js +25 -9
  20. package/dist/Schedule.js.map +1 -1
  21. package/dist/Schema.d.ts +21 -0
  22. package/dist/Schema.d.ts.map +1 -1
  23. package/dist/Schema.js.map +1 -1
  24. package/dist/ServiceMap.d.ts +39 -30
  25. package/dist/ServiceMap.d.ts.map +1 -1
  26. package/dist/ServiceMap.js +3 -3
  27. package/dist/ServiceMap.js.map +1 -1
  28. package/dist/Sink.d.ts +2 -2
  29. package/dist/Sink.d.ts.map +1 -1
  30. package/dist/Sink.js.map +1 -1
  31. package/dist/Stream.d.ts +6 -6
  32. package/dist/Stream.d.ts.map +1 -1
  33. package/dist/Stream.js.map +1 -1
  34. package/dist/index.d.ts +1 -1
  35. package/dist/index.js +1 -1
  36. package/dist/internal/effect.js +2 -2
  37. package/dist/internal/effect.js.map +1 -1
  38. package/dist/testing/TestSchema.d.ts +2 -2
  39. package/dist/testing/TestSchema.d.ts.map +1 -1
  40. package/dist/testing/TestSchema.js.map +1 -1
  41. package/dist/unstable/ai/AiError.d.ts +90 -10
  42. package/dist/unstable/ai/AiError.d.ts.map +1 -1
  43. package/dist/unstable/ai/AiError.js +11 -12
  44. package/dist/unstable/ai/AiError.js.map +1 -1
  45. package/dist/unstable/ai/Model.d.ts +25 -7
  46. package/dist/unstable/ai/Model.d.ts.map +1 -1
  47. package/dist/unstable/ai/Model.js +22 -6
  48. package/dist/unstable/ai/Model.js.map +1 -1
  49. package/dist/unstable/ai/Tool.d.ts +3 -3
  50. package/dist/unstable/ai/Tool.d.ts.map +1 -1
  51. package/dist/unstable/ai/Tool.js.map +1 -1
  52. package/dist/unstable/ai/index.d.ts +1 -1
  53. package/dist/unstable/ai/index.js +1 -1
  54. package/dist/unstable/cli/Command.d.ts +6 -6
  55. package/dist/unstable/cli/Command.d.ts.map +1 -1
  56. package/dist/unstable/cli/Command.js.map +1 -1
  57. package/dist/unstable/cli/internal/command.d.ts +2 -2
  58. package/dist/unstable/cli/internal/command.d.ts.map +1 -1
  59. package/dist/unstable/cluster/Entity.d.ts +2 -2
  60. package/dist/unstable/cluster/Entity.d.ts.map +1 -1
  61. package/dist/unstable/cluster/Entity.js.map +1 -1
  62. package/dist/unstable/cluster/ShardingConfig.js +20 -20
  63. package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
  64. package/dist/unstable/httpapi/HttpApi.d.ts +3 -3
  65. package/dist/unstable/httpapi/HttpApi.d.ts.map +1 -1
  66. package/dist/unstable/httpapi/HttpApi.js.map +1 -1
  67. package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
  68. package/dist/unstable/httpapi/HttpApiClient.d.ts +7 -2
  69. package/dist/unstable/httpapi/HttpApiClient.d.ts.map +1 -1
  70. package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
  71. package/dist/unstable/httpapi/HttpApiEndpoint.d.ts +3 -3
  72. package/dist/unstable/httpapi/HttpApiEndpoint.d.ts.map +1 -1
  73. package/dist/unstable/httpapi/HttpApiEndpoint.js.map +1 -1
  74. package/dist/unstable/httpapi/HttpApiGroup.d.ts +3 -3
  75. package/dist/unstable/httpapi/HttpApiGroup.d.ts.map +1 -1
  76. package/dist/unstable/httpapi/HttpApiGroup.js.map +1 -1
  77. package/dist/unstable/httpapi/HttpApiMiddleware.d.ts +4 -4
  78. package/dist/unstable/httpapi/HttpApiMiddleware.d.ts.map +1 -1
  79. package/dist/unstable/httpapi/HttpApiMiddleware.js.map +1 -1
  80. package/dist/unstable/httpapi/HttpApiSecurity.d.ts +2 -2
  81. package/dist/unstable/httpapi/HttpApiSecurity.d.ts.map +1 -1
  82. package/dist/unstable/httpapi/HttpApiSecurity.js.map +1 -1
  83. package/dist/unstable/httpapi/OpenApi.js.map +1 -1
  84. package/dist/unstable/process/ChildProcess.d.ts +3 -126
  85. package/dist/unstable/process/ChildProcess.d.ts.map +1 -1
  86. package/dist/unstable/process/ChildProcess.js +1 -65
  87. package/dist/unstable/process/ChildProcess.js.map +1 -1
  88. package/dist/unstable/process/ChildProcessSpawner.d.ts +39 -7
  89. package/dist/unstable/process/ChildProcessSpawner.d.ts.map +1 -1
  90. package/dist/unstable/process/ChildProcessSpawner.js +21 -1
  91. package/dist/unstable/process/ChildProcessSpawner.js.map +1 -1
  92. package/dist/unstable/rpc/Rpc.d.ts +1 -1
  93. package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
  94. package/dist/unstable/rpc/Rpc.js.map +1 -1
  95. package/dist/unstable/rpc/RpcGroup.d.ts +2 -2
  96. package/dist/unstable/rpc/RpcGroup.d.ts.map +1 -1
  97. package/dist/unstable/rpc/RpcGroup.js.map +1 -1
  98. package/dist/unstable/rpc/RpcMiddleware.d.ts +3 -3
  99. package/dist/unstable/rpc/RpcMiddleware.d.ts.map +1 -1
  100. package/dist/unstable/rpc/RpcMiddleware.js.map +1 -1
  101. package/dist/unstable/sql/SqlClient.d.ts +1 -1
  102. package/dist/unstable/sql/SqlClient.d.ts.map +1 -1
  103. package/dist/unstable/workflow/Workflow.d.ts +1 -1
  104. package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
  105. package/package.json +1 -1
  106. package/src/Channel.ts +9 -9
  107. package/src/Config.ts +9 -9
  108. package/src/Effect.ts +24 -32
  109. package/src/ErrorReporter.ts +2 -2
  110. package/src/Layer.ts +11 -15
  111. package/src/Schedule.ts +35 -19
  112. package/src/Schema.ts +21 -0
  113. package/src/ServiceMap.ts +47 -38
  114. package/src/Sink.ts +3 -3
  115. package/src/Stream.ts +9 -9
  116. package/src/index.ts +1 -1
  117. package/src/internal/effect.ts +24 -24
  118. package/src/testing/TestSchema.ts +2 -2
  119. package/src/unstable/ai/AiError.ts +95 -42
  120. package/src/unstable/ai/Model.ts +40 -9
  121. package/src/unstable/ai/Tool.ts +4 -4
  122. package/src/unstable/ai/index.ts +1 -1
  123. package/src/unstable/cli/Command.ts +9 -12
  124. package/src/unstable/cli/internal/command.ts +2 -2
  125. package/src/unstable/cluster/Entity.ts +4 -4
  126. package/src/unstable/cluster/ShardingConfig.ts +20 -20
  127. package/src/unstable/httpapi/HttpApi.ts +5 -5
  128. package/src/unstable/httpapi/HttpApiBuilder.ts +2 -2
  129. package/src/unstable/httpapi/HttpApiClient.ts +11 -3
  130. package/src/unstable/httpapi/HttpApiEndpoint.ts +7 -7
  131. package/src/unstable/httpapi/HttpApiGroup.ts +6 -6
  132. package/src/unstable/httpapi/HttpApiMiddleware.ts +4 -4
  133. package/src/unstable/httpapi/HttpApiSecurity.ts +3 -3
  134. package/src/unstable/httpapi/OpenApi.ts +2 -2
  135. package/src/unstable/process/ChildProcess.ts +4 -206
  136. package/src/unstable/process/ChildProcessSpawner.ts +69 -14
  137. package/src/unstable/rpc/Rpc.ts +2 -2
  138. package/src/unstable/rpc/RpcGroup.ts +4 -4
  139. package/src/unstable/rpc/RpcMiddleware.ts +3 -3
  140. package/src/unstable/sql/SqlClient.ts +1 -1
  141. package/src/unstable/workflow/Workflow.ts +1 -1
package/src/Channel.ts CHANGED
@@ -8624,7 +8624,7 @@ export const provideService: {
8624
8624
  * @since 4.0.0
8625
8625
  * @category Services
8626
8626
  */
8627
- <I, S>(key: ServiceMap.Service<I, S>, service: NoInfer<S>): <OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>(
8627
+ <I, S>(key: ServiceMap.Key<I, S>, service: NoInfer<S>): <OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>(
8628
8628
  self: Channel<OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>
8629
8629
  ) => Channel<OutElem, OutErr, OutDone, InElem, InErr, InDone, Exclude<Env, I>>
8630
8630
  /**
@@ -8633,12 +8633,12 @@ export const provideService: {
8633
8633
  */
8634
8634
  <OutElem, OutErr, OutDone, InElem, InErr, InDone, Env, I, S>(
8635
8635
  self: Channel<OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>,
8636
- key: ServiceMap.Service<I, S>,
8636
+ key: ServiceMap.Key<I, S>,
8637
8637
  service: NoInfer<S>
8638
8638
  ): Channel<OutElem, OutErr, OutDone, InElem, InErr, InDone, Exclude<Env, I>>
8639
8639
  } = dual(3, <OutElem, OutErr, OutDone, InElem, InErr, InDone, Env, I, S>(
8640
8640
  self: Channel<OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>,
8641
- key: ServiceMap.Service<I, S>,
8641
+ key: ServiceMap.Key<I, S>,
8642
8642
  service: NoInfer<S>
8643
8643
  ): Channel<OutElem, OutErr, OutDone, InElem, InErr, InDone, Exclude<Env, I>> =>
8644
8644
  fromTransform((upstream, scope) =>
@@ -8657,7 +8657,7 @@ export const provideServiceEffect: {
8657
8657
  * @since 4.0.0
8658
8658
  * @category Services
8659
8659
  */
8660
- <I, S, ES, RS>(key: ServiceMap.Service<I, S>, service: Effect.Effect<NoInfer<S>, ES, RS>): <OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>(
8660
+ <I, S, ES, RS>(key: ServiceMap.Key<I, S>, service: Effect.Effect<NoInfer<S>, ES, RS>): <OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>(
8661
8661
  self: Channel<OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>
8662
8662
  ) => Channel<OutElem, OutErr | ES, OutDone, InElem, InErr, InDone, Exclude<Env, I> | RS>
8663
8663
  /**
@@ -8666,12 +8666,12 @@ export const provideServiceEffect: {
8666
8666
  */
8667
8667
  <OutElem, OutErr, OutDone, InElem, InErr, InDone, Env, I, S, ES, RS>(
8668
8668
  self: Channel<OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>,
8669
- key: ServiceMap.Service<I, S>,
8669
+ key: ServiceMap.Key<I, S>,
8670
8670
  service: Effect.Effect<NoInfer<S>, ES, RS>
8671
8671
  ): Channel<OutElem, OutErr | ES, OutDone, InElem, InErr, InDone, Exclude<Env, I> | RS>
8672
8672
  } = dual(3, <OutElem, OutErr, OutDone, InElem, InErr, InDone, Env, I, S, ES, RS>(
8673
8673
  self: Channel<OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>,
8674
- key: ServiceMap.Service<I, S>,
8674
+ key: ServiceMap.Key<I, S>,
8675
8675
  service: Effect.Effect<NoInfer<S>, ES, RS>
8676
8676
  ): Channel<OutElem, OutErr | ES, OutDone, InElem, InErr, InDone, Exclude<Env, I> | RS> =>
8677
8677
  fromTransform((upstream, scope) =>
@@ -8769,7 +8769,7 @@ export const updateService: {
8769
8769
  * @since 2.0.0
8770
8770
  * @category Services
8771
8771
  */
8772
- <I, S>(key: ServiceMap.Service<I, S>, f: (service: NoInfer<S>) => S): <OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>(
8772
+ <I, S>(key: ServiceMap.Key<I, S>, f: (service: NoInfer<S>) => S): <OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>(
8773
8773
  self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
8774
8774
  ) => Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env | I>
8775
8775
  /**
@@ -8778,12 +8778,12 @@ export const updateService: {
8778
8778
  */
8779
8779
  <OutElem, OutErr, OutDone, InElem, InErr, InDone, Env, I, S>(
8780
8780
  self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
8781
- service: ServiceMap.Service<I, S>,
8781
+ service: ServiceMap.Key<I, S>,
8782
8782
  f: (service: NoInfer<S>) => S
8783
8783
  ): Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env | I>
8784
8784
  } = dual(3, <OutElem, OutErr, OutDone, InElem, InErr, InDone, Env, I, S>(
8785
8785
  self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
8786
- service: ServiceMap.Service<I, S>,
8786
+ service: ServiceMap.Key<I, S>,
8787
8787
  f: (service: NoInfer<S>) => S
8788
8788
  ): Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env | I> =>
8789
8789
  updateServices(self, (services) =>
package/src/Config.ts CHANGED
@@ -75,7 +75,7 @@ import type { Path, SourceError } from "./ConfigProvider.ts"
75
75
  import * as ConfigProvider from "./ConfigProvider.ts"
76
76
  import * as Duration_ from "./Duration.ts"
77
77
  import * as Effect from "./Effect.ts"
78
- import { dual, type LazyArg } from "./Function.ts"
78
+ import { dual } from "./Function.ts"
79
79
  import { PipeInspectableProto, YieldableProto } from "./internal/core.ts"
80
80
  import * as LogLevel_ from "./LogLevel.ts"
81
81
  import * as Option from "./Option.ts"
@@ -569,7 +569,7 @@ function isMissingDataOnly(issue: Issue.Issue): boolean {
569
569
  * ```ts
570
570
  * import { Config, ConfigProvider, Effect } from "effect"
571
571
  *
572
- * const port = Config.number("port").pipe(Config.withDefault(() => 3000))
572
+ * const port = Config.number("port").pipe(Config.withDefault(3000))
573
573
  *
574
574
  * const provider = ConfigProvider.fromUnknown({})
575
575
  * // Effect.runSync(port.parse(provider)) // 3000
@@ -598,7 +598,7 @@ export const withDefault: {
598
598
  * ```ts
599
599
  * import { Config, ConfigProvider, Effect } from "effect"
600
600
  *
601
- * const port = Config.number("port").pipe(Config.withDefault(() => 3000))
601
+ * const port = Config.number("port").pipe(Config.withDefault(3000))
602
602
  *
603
603
  * const provider = ConfigProvider.fromUnknown({})
604
604
  * // Effect.runSync(port.parse(provider)) // 3000
@@ -609,7 +609,7 @@ export const withDefault: {
609
609
  *
610
610
  * @since 4.0.0
611
611
  */
612
- <const A2>(defaultValue: LazyArg<A2>): <A>(self: Config<A>) => Config<A2 | A>
612
+ <const A2>(defaultValue: A2): <A>(self: Config<A>) => Config<A2 | A>
613
613
  /**
614
614
  * Provides a fallback value when the config fails due to missing data.
615
615
  *
@@ -627,7 +627,7 @@ export const withDefault: {
627
627
  * ```ts
628
628
  * import { Config, ConfigProvider, Effect } from "effect"
629
629
  *
630
- * const port = Config.number("port").pipe(Config.withDefault(() => 3000))
630
+ * const port = Config.number("port").pipe(Config.withDefault(3000))
631
631
  *
632
632
  * const provider = ConfigProvider.fromUnknown({})
633
633
  * // Effect.runSync(port.parse(provider)) // 3000
@@ -638,13 +638,13 @@ export const withDefault: {
638
638
  *
639
639
  * @since 4.0.0
640
640
  */
641
- <A, const A2>(self: Config<A>, defaultValue: LazyArg<A2>): Config<A | A2>
642
- } = dual(2, <A, const A2>(self: Config<A>, defaultValue: LazyArg<A2>): Config<A | A2> => {
641
+ <A, const A2>(self: Config<A>, defaultValue: A2): Config<A | A2>
642
+ } = dual(2, <A, const A2>(self: Config<A>, defaultValue: A2): Config<A | A2> => {
643
643
  return orElse(self, (err) => {
644
644
  if (Schema.isSchemaError(err.cause)) {
645
645
  const issue = err.cause.issue
646
646
  if (isMissingDataOnly(issue)) {
647
- return succeed(defaultValue())
647
+ return succeed(defaultValue)
648
648
  }
649
649
  }
650
650
  return fail(err.cause)
@@ -678,7 +678,7 @@ export const withDefault: {
678
678
  * @since 4.0.0
679
679
  */
680
680
  export const option = <A>(self: Config<A>): Config<Option.Option<A>> =>
681
- self.pipe(map(Option.some), withDefault(() => Option.none()))
681
+ self.pipe(map(Option.some), withDefault(Option.none()))
682
682
 
683
683
  /**
684
684
  * Utility type that recursively replaces primitives with `Config` in a nested
package/src/Effect.ts CHANGED
@@ -763,7 +763,7 @@ export const all: <
763
763
  ) => All.Return<Arg, O> = internal.all
764
764
 
765
765
  /**
766
- * Applies an effectful `Filter` to each element and partitions failures and
766
+ * Applies an effectful function to each element and partitions failures and
767
767
  * successes.
768
768
  *
769
769
  * The returned tuple is `[excluded, satisfying]`, where:
@@ -776,10 +776,10 @@ export const all: <
776
776
  *
777
777
  * @example
778
778
  * ```ts
779
- * import { Effect, Result } from "effect"
779
+ * import { Effect } from "effect"
780
780
  *
781
781
  * const program = Effect.partition([0, 1, 2, 3], (n) =>
782
- * Effect.succeed(n % 2 === 0 ? Result.fail(`${n} is even`) : Result.succeed(n))
782
+ * n % 2 === 0 ? Effect.fail(`${n} is even`) : Effect.succeed(n)
783
783
  * )
784
784
  *
785
785
  * Effect.runPromise(program).then(console.log)
@@ -791,7 +791,7 @@ export const all: <
791
791
  */
792
792
  export const partition: {
793
793
  /**
794
- * Applies an effectful `Filter` to each element and partitions failures and
794
+ * Applies an effectful function to each element and partitions failures and
795
795
  * successes.
796
796
  *
797
797
  * The returned tuple is `[excluded, satisfying]`, where:
@@ -804,10 +804,10 @@ export const partition: {
804
804
  *
805
805
  * @example
806
806
  * ```ts
807
- * import { Effect, Result } from "effect"
807
+ * import { Effect } from "effect"
808
808
  *
809
809
  * const program = Effect.partition([0, 1, 2, 3], (n) =>
810
- * Effect.succeed(n % 2 === 0 ? Result.fail(`${n} is even`) : Result.succeed(n))
810
+ * n % 2 === 0 ? Effect.fail(`${n} is even`) : Effect.succeed(n)
811
811
  * )
812
812
  *
813
813
  * Effect.runPromise(program).then(console.log)
@@ -817,12 +817,12 @@ export const partition: {
817
817
  * @since 3.0.0
818
818
  * @category Collecting
819
819
  */
820
- <A, Pass, Fail, E, R>(
821
- filter: Filter.FilterEffect<NoInfer<A>, Pass, Fail, E, R, [i: number]>,
820
+ <A, B, E, R>(
821
+ f: (a: A, i: number) => Effect<B, E, R>,
822
822
  options?: { readonly concurrency?: Concurrency | undefined }
823
- ): (elements: Iterable<A>) => Effect<[excluded: Array<Fail>, satisfying: Array<Pass>], E, R>
823
+ ): (elements: Iterable<A>) => Effect<[excluded: Array<E>, satisfying: Array<B>], never, R>
824
824
  /**
825
- * Applies an effectful `Filter` to each element and partitions failures and
825
+ * Applies an effectful function to each element and partitions failures and
826
826
  * successes.
827
827
  *
828
828
  * The returned tuple is `[excluded, satisfying]`, where:
@@ -835,10 +835,10 @@ export const partition: {
835
835
  *
836
836
  * @example
837
837
  * ```ts
838
- * import { Effect, Result } from "effect"
838
+ * import { Effect } from "effect"
839
839
  *
840
840
  * const program = Effect.partition([0, 1, 2, 3], (n) =>
841
- * Effect.succeed(n % 2 === 0 ? Result.fail(`${n} is even`) : Result.succeed(n))
841
+ * n % 2 === 0 ? Effect.fail(`${n} is even`) : Effect.succeed(n)
842
842
  * )
843
843
  *
844
844
  * Effect.runPromise(program).then(console.log)
@@ -848,11 +848,11 @@ export const partition: {
848
848
  * @since 3.0.0
849
849
  * @category Collecting
850
850
  */
851
- <A, Pass, Fail, E, R>(
851
+ <A, B, E, R>(
852
852
  elements: Iterable<A>,
853
- filter: Filter.FilterEffect<NoInfer<A>, Pass, Fail, E, R, [i: number]>,
853
+ f: (a: A, i: number) => Effect<B, E, R>,
854
854
  options?: { readonly concurrency?: Concurrency | undefined }
855
- ): Effect<[excluded: Array<Fail>, satisfying: Array<Pass>], E, R>
855
+ ): Effect<[excluded: Array<E>, satisfying: Array<B>], never, R>
856
856
  } = internal.partition
857
857
 
858
858
  /**
@@ -10787,7 +10787,7 @@ export const provideServices: {
10787
10787
  * @since 4.0.0
10788
10788
  * @category ServiceMap
10789
10789
  */
10790
- export const service: <I, S>(service: ServiceMap.Service<I, S>) => Effect<S, never, I> = internal.service
10790
+ export const service: <I, S>(service: ServiceMap.Key<I, S>) => Effect<S, never, I> = internal.service
10791
10791
 
10792
10792
  /**
10793
10793
  * Optionally accesses a service from the environment.
@@ -10823,7 +10823,7 @@ export const service: <I, S>(service: ServiceMap.Service<I, S>) => Effect<S, nev
10823
10823
  * @since 2.0.0
10824
10824
  * @category ServiceMap
10825
10825
  */
10826
- export const serviceOption: <I, S>(key: ServiceMap.Service<I, S>) => Effect<Option<S>> = internal.serviceOption
10826
+ export const serviceOption: <I, S>(key: ServiceMap.Key<I, S>) => Effect<Option<S>> = internal.serviceOption
10827
10827
 
10828
10828
  /**
10829
10829
  * Provides part of the required context while leaving the rest unchanged.
@@ -11012,7 +11012,7 @@ export const updateService: {
11012
11012
  * @since 2.0.0
11013
11013
  * @category ServiceMap
11014
11014
  */
11015
- <I, A>(service: ServiceMap.Service<I, A>, f: (value: A) => A): <XA, E, R>(self: Effect<XA, E, R>) => Effect<XA, E, R | I>
11015
+ <I, A>(service: ServiceMap.Key<I, A>, f: (value: A) => A): <XA, E, R>(self: Effect<XA, E, R>) => Effect<XA, E, R | I>
11016
11016
  /**
11017
11017
  * Updates the service with the required service entry.
11018
11018
  *
@@ -11041,11 +11041,7 @@ export const updateService: {
11041
11041
  * @since 2.0.0
11042
11042
  * @category ServiceMap
11043
11043
  */
11044
- <XA, E, R, I, A>(
11045
- self: Effect<XA, E, R>,
11046
- service: ServiceMap.Service<I, A>,
11047
- f: (value: A) => A
11048
- ): Effect<XA, E, R | I>
11044
+ <XA, E, R, I, A>(self: Effect<XA, E, R>, service: ServiceMap.Key<I, A>, f: (value: A) => A): Effect<XA, E, R | I>
11049
11045
  } = internal.updateService
11050
11046
 
11051
11047
  /**
@@ -11139,7 +11135,7 @@ export const provideService: {
11139
11135
  * @since 2.0.0
11140
11136
  * @category ServiceMap
11141
11137
  */
11142
- <I, S>(service: ServiceMap.Service<I, S>): {
11138
+ <I, S>(service: ServiceMap.Key<I, S>): {
11143
11139
  /**
11144
11140
  * The `provideService` function is used to provide an actual
11145
11141
  * implementation for a service in the context of an effect.
@@ -11278,7 +11274,7 @@ export const provideService: {
11278
11274
  * @since 2.0.0
11279
11275
  * @category ServiceMap
11280
11276
  */
11281
- <I, S>(service: ServiceMap.Service<I, S>, implementation: S): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, Exclude<R, I>>
11277
+ <I, S>(service: ServiceMap.Key<I, S>, implementation: S): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, Exclude<R, I>>
11282
11278
  /**
11283
11279
  * The `provideService` function is used to provide an actual
11284
11280
  * implementation for a service in the context of an effect.
@@ -11324,11 +11320,7 @@ export const provideService: {
11324
11320
  * @since 2.0.0
11325
11321
  * @category ServiceMap
11326
11322
  */
11327
- <A, E, R, I, S>(
11328
- self: Effect<A, E, R>,
11329
- service: ServiceMap.Service<I, S>,
11330
- implementation: S
11331
- ): Effect<A, E, Exclude<R, I>>
11323
+ <A, E, R, I, S>(self: Effect<A, E, R>, service: ServiceMap.Key<I, S>, implementation: S): Effect<A, E, Exclude<R, I>>
11332
11324
  } = internal.provideService
11333
11325
 
11334
11326
  /**
@@ -11436,7 +11428,7 @@ export const provideServiceEffect: {
11436
11428
  * @since 2.0.0
11437
11429
  * @category ServiceMap
11438
11430
  */
11439
- <I, S, E2, R2>(service: ServiceMap.Service<I, S>, acquire: Effect<S, E2, R2>): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E | E2, Exclude<R, I> | R2>
11431
+ <I, S, E2, R2>(service: ServiceMap.Key<I, S>, acquire: Effect<S, E2, R2>): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E | E2, Exclude<R, I> | R2>
11440
11432
  /**
11441
11433
  * Provides the effect with the single service it requires. If the effect
11442
11434
  * requires more than one service use `provide` instead.
@@ -11491,7 +11483,7 @@ export const provideServiceEffect: {
11491
11483
  */
11492
11484
  <A, E, R, I, S, E2, R2>(
11493
11485
  self: Effect<A, E, R>,
11494
- service: ServiceMap.Service<I, S>,
11486
+ service: ServiceMap.Key<I, S>,
11495
11487
  acquire: Effect<S, E2, R2>
11496
11488
  ): Effect<A, E | E2, Exclude<R, I> | R2>
11497
11489
  } = internal.provideServiceEffect
@@ -145,7 +145,7 @@ export const make = (
145
145
  report({
146
146
  ...options,
147
147
  error: pretty,
148
- severity: isObject ? getSeverity(original) : "Error",
148
+ severity: isObject ? getSeverity(original) : "Info",
149
149
  attributes: isObject ? getAttributes(original) : emptyAttributes
150
150
  })
151
151
  }
@@ -392,7 +392,7 @@ export const getSeverity = (error: object): Severity => {
392
392
  if (severity in error && LogLevel.values.includes(error[severity] as Severity)) {
393
393
  return error[severity] as Severity
394
394
  }
395
- return "Error"
395
+ return "Info"
396
396
  }
397
397
 
398
398
  /**
package/src/Layer.ts CHANGED
@@ -815,7 +815,7 @@ export const succeed: {
815
815
  * @since 2.0.0
816
816
  * @category constructors
817
817
  */
818
- <I, S>(service: ServiceMap.Service<I, S>): (resource: S) => Layer<I>
818
+ <I, S>(service: ServiceMap.Key<I, S>): (resource: S) => Layer<I>
819
819
  /**
820
820
  * Constructs a layer from the specified value.
821
821
  *
@@ -858,7 +858,7 @@ export const succeed: {
858
858
  * @since 2.0.0
859
859
  * @category constructors
860
860
  */
861
- <I, S>(service: ServiceMap.Service<I, S>, resource: Types.NoInfer<S>): Layer<I>
861
+ <I, S>(service: ServiceMap.Key<I, S>, resource: Types.NoInfer<S>): Layer<I>
862
862
  } = function() {
863
863
  if (arguments.length === 1) {
864
864
  return (resource: any) => succeedServices(ServiceMap.make(arguments[0], resource))
@@ -966,7 +966,7 @@ export const sync: {
966
966
  * @since 2.0.0
967
967
  * @category constructors
968
968
  */
969
- <I, S>(service: ServiceMap.Service<I, S>): (evaluate: LazyArg<S>) => Layer<I>
969
+ <I, S>(service: ServiceMap.Key<I, S>): (evaluate: LazyArg<S>) => Layer<I>
970
970
  /**
971
971
  * Lazily constructs a layer from the specified value.
972
972
  *
@@ -989,7 +989,7 @@ export const sync: {
989
989
  * @since 2.0.0
990
990
  * @category constructors
991
991
  */
992
- <I, S>(service: ServiceMap.Service<I, S>, evaluate: LazyArg<S>): Layer<I>
992
+ <I, S>(service: ServiceMap.Key<I, S>, evaluate: LazyArg<S>): Layer<I>
993
993
  } = function() {
994
994
  if (arguments.length === 1) {
995
995
  return (evaluate: LazyArg<any>) => syncServices(() => ServiceMap.make(arguments[0], evaluate()))
@@ -1088,7 +1088,7 @@ export const effect: {
1088
1088
  * @since 2.0.0
1089
1089
  * @category constructors
1090
1090
  */
1091
- <I, S>(service: ServiceMap.Service<I, S>): <E, R>(
1091
+ <I, S>(service: ServiceMap.Key<I, S>): <E, R>(
1092
1092
  effect: Effect<S, E, R>
1093
1093
  ) => Layer<I, E, Exclude<R, Scope.Scope>>
1094
1094
  /**
@@ -1122,7 +1122,7 @@ export const effect: {
1122
1122
  * @since 2.0.0
1123
1123
  * @category constructors
1124
1124
  */
1125
- <I, S, E, R>(service: ServiceMap.Service<I, S>, effect: Effect<S, E, R>): Layer<I, E, Exclude<R, Scope.Scope>>
1125
+ <I, S, E, R>(service: ServiceMap.Key<I, S>, effect: Effect<S, E, R>): Layer<I, E, Exclude<R, Scope.Scope>>
1126
1126
  } = function() {
1127
1127
  if (arguments.length === 1) {
1128
1128
  return (effect: any) => effectImpl(arguments[0], effect)
@@ -1131,7 +1131,7 @@ export const effect: {
1131
1131
  } as any
1132
1132
 
1133
1133
  const effectImpl = <I, S, E, R>(
1134
- service: ServiceMap.Service<I, S>,
1134
+ service: ServiceMap.Key<I, S>,
1135
1135
  effect: Effect<S, E, R>
1136
1136
  ): Layer<I, E, Exclude<R, Scope.Scope>> =>
1137
1137
  effectServices(internalEffect.map(effect, (value) => ServiceMap.make(service, value)))
@@ -2879,7 +2879,7 @@ export const updateService: {
2879
2879
  * @since 3.13.0
2880
2880
  * @category utils
2881
2881
  */
2882
- <I, A>(service: ServiceMap.Service<I, A>, f: (a: A) => A): <A1, E1, R1>(layer: Layer<A1, E1, R1>) => Layer<A1, E1, I | R1>
2882
+ <I, A>(service: ServiceMap.Key<I, A>, f: (a: A) => A): <A1, E1, R1>(layer: Layer<A1, E1, R1>) => Layer<A1, E1, I | R1>
2883
2883
  /**
2884
2884
  * Updates a service in the context with a new implementation.
2885
2885
  *
@@ -2898,16 +2898,12 @@ export const updateService: {
2898
2898
  * @since 3.13.0
2899
2899
  * @category utils
2900
2900
  */
2901
- <A1, E1, R1, I, A>(
2902
- layer: Layer<A1, E1, R1>,
2903
- service: ServiceMap.Service<I, A>,
2904
- f: (a: A) => A
2905
- ): Layer<A1, E1, I | R1>
2901
+ <A1, E1, R1, I, A>(layer: Layer<A1, E1, R1>, service: ServiceMap.Key<I, A>, f: (a: A) => A): Layer<A1, E1, I | R1>
2906
2902
  } = dual(
2907
2903
  3,
2908
2904
  <A1, E1, R1, I, A>(
2909
2905
  layer: Layer<A1, E1, R1>,
2910
- service: ServiceMap.Service<I, A>,
2906
+ service: ServiceMap.Key<I, A>,
2911
2907
  f: (a: A) => A
2912
2908
  ): Layer<A1, E1, I | R1> => provide(layer, effect(service)(internalEffect.map(service.asEffect(), f)))
2913
2909
  )
@@ -3096,7 +3092,7 @@ export type PartialEffectful<A extends object> = Types.Simplify<
3096
3092
  * @category Testing
3097
3093
  */
3098
3094
  export const mock =
3099
- <I, S extends object>(service: ServiceMap.Service<I, S>) => (implementation: PartialEffectful<S>): Layer<I> =>
3095
+ <I, S extends object>(service: ServiceMap.Key<I, S>) => (implementation: PartialEffectful<S>): Layer<I> =>
3100
3096
  succeed(service)(
3101
3097
  new Proxy({ ...implementation as object } as S, {
3102
3098
  get(target, prop, _receiver) {
package/src/Schedule.ts CHANGED
@@ -2410,7 +2410,7 @@ export const collectWhile: {
2410
2410
  <Input, Output, Error2 = never, Env2 = never>(
2411
2411
  predicate: (
2412
2412
  metadata: Metadata<Output, Input>
2413
- ) => Effect<boolean, Error2, Env2>
2413
+ ) => boolean | Effect<boolean, Error2, Env2>
2414
2414
  ): <Error, Env>(
2415
2415
  self: Schedule<Output, Input, Error, Env>
2416
2416
  ) => Schedule<Array<Output>, Input, Error | Error2, Env | Env2>
@@ -2522,19 +2522,18 @@ export const collectWhile: {
2522
2522
  self: Schedule<Output, Input, Error, Env>,
2523
2523
  predicate: (
2524
2524
  metadata: Metadata<Output, Input>
2525
- ) => Effect<boolean, Error2, Env2>
2525
+ ) => boolean | Effect<boolean, Error2, Env2>
2526
2526
  ): Schedule<Array<Output>, Input, Error | Error2, Env | Env2>
2527
2527
  } = dual(2, <Output, Input, Error, Env, Error2 = never, Env2 = never>(
2528
2528
  self: Schedule<Output, Input, Error, Env>,
2529
2529
  predicate: (
2530
2530
  metadata: Metadata<Output, Input>
2531
- ) => Effect<boolean, Error2, Env2>
2531
+ ) => boolean | Effect<boolean, Error2, Env2>
2532
2532
  ): Schedule<Array<Output>, Input, Error | Error2, Env | Env2> =>
2533
- reduce(while_(self, predicate), () => [] as Array<Output>, (outputs, output) =>
2534
- effect.succeed((() => {
2535
- outputs.push(output)
2536
- return outputs
2537
- })())))
2533
+ reduce(while_(self, predicate), () => [] as Array<Output>, (outputs, output) => {
2534
+ outputs.push(output)
2535
+ return outputs
2536
+ }))
2538
2537
 
2539
2538
  /**
2540
2539
  * Returns a new `Schedule` that recurs on the specified `Cron` schedule and
@@ -4698,7 +4697,7 @@ export const reduce: {
4698
4697
  */
4699
4698
  <State, Output, Error2 = never, Env2 = never>(
4700
4699
  initial: LazyArg<State>,
4701
- combine: (state: State, output: Output) => Effect<State, Error2, Env2>
4700
+ combine: (state: State, output: Output) => State | Effect<State, Error2, Env2>
4702
4701
  ): <Input, Error, Env>(
4703
4702
  self: Schedule<Output, Input, Error, Env>
4704
4703
  ) => Schedule<State, Input, Error | Error2, Env | Env2>
@@ -4816,24 +4815,30 @@ export const reduce: {
4816
4815
  <Output, Input, Error, Env, State, Error2 = never, Env2 = never>(
4817
4816
  self: Schedule<Output, Input, Error, Env>,
4818
4817
  initial: LazyArg<State>,
4819
- combine: (state: State, output: Output) => Effect<State, Error2, Env2>
4818
+ combine: (state: State, output: Output) => State | Effect<State, Error2, Env2>
4820
4819
  ): Schedule<State, Input, Error | Error2, Env | Env2>
4821
4820
  } = dual(3, <Output, Input, Error, Env, State, Error2 = never, Env2 = never>(
4822
4821
  self: Schedule<Output, Input, Error, Env>,
4823
4822
  initial: LazyArg<State>,
4824
- combine: (state: State, output: Output) => Effect<State, Error2, Env2>
4823
+ combine: (state: State, output: Output) => State | Effect<State, Error2, Env2>
4825
4824
  ): Schedule<State, Input, Error | Error2, Env | Env2> =>
4826
4825
  fromStep(effect.map(toStep(self), (step) => {
4827
4826
  let state = initial()
4828
4827
  return (now, input) =>
4829
4828
  Pull.matchEffect(step(now, input), {
4830
- onSuccess: ([output, delay]) =>
4831
- effect.map(combine(state, output), (nextState) => {
4829
+ onSuccess([output, delay]) {
4830
+ const next = combine(state, output)
4831
+ if (!isEffect(next)) return effect.succeed([next, delay] as [State, Duration.Duration])
4832
+ return effect.map(next, (nextState) => {
4832
4833
  state = nextState
4833
4834
  return [nextState, delay]
4834
- }),
4835
+ })
4836
+ },
4835
4837
  onFailure: effect.failCause,
4836
- onDone: (output) => effect.flatMap(combine(state, output), Cause.done)
4838
+ onDone(output) {
4839
+ const next = combine(state, output)
4840
+ return isEffect(next) ? effect.flatMap(next, Cause.done) : Cause.done(next)
4841
+ }
4837
4842
  })
4838
4843
  })))
4839
4844
 
@@ -5900,7 +5905,7 @@ const while_: {
5900
5905
  <Input, Output, Error2 = never, Env2 = never>(
5901
5906
  predicate: (
5902
5907
  metadata: Metadata<Output, Input>
5903
- ) => Effect<boolean, Error2, Env2>
5908
+ ) => boolean | Effect<boolean, Error2, Env2>
5904
5909
  ): <Error, Env>(
5905
5910
  self: Schedule<Output, Input, Error, Env>
5906
5911
  ) => Schedule<Output, Input, Error | Error2, Env | Env2>
@@ -5908,21 +5913,22 @@ const while_: {
5908
5913
  self: Schedule<Output, Input, Error, Env>,
5909
5914
  predicate: (
5910
5915
  metadata: Metadata<Output, Input>
5911
- ) => Effect<boolean, Error2, Env2>
5916
+ ) => boolean | Effect<boolean, Error2, Env2>
5912
5917
  ): Schedule<Output, Input, Error | Error2, Env | Env2>
5913
5918
  } = dual(2, <Output, Input, Error, Env, Error2 = never, Env2 = never>(
5914
5919
  self: Schedule<Output, Input, Error, Env>,
5915
5920
  predicate: (
5916
5921
  metadata: Metadata<Output, Input>
5917
- ) => Effect<boolean, Error2, Env2>
5922
+ ) => boolean | Effect<boolean, Error2, Env2>
5918
5923
  ): Schedule<Output, Input, Error | Error2, Env | Env2> =>
5919
5924
  fromStep(effect.map(toStep(self), (step) => {
5920
5925
  const meta = metadataFn()
5921
5926
  return (now, input) =>
5922
5927
  effect.flatMap(step(now, input), (result) => {
5923
5928
  const [output, duration] = result
5929
+ const eff = predicate({ ...meta(now, input), output, duration })
5924
5930
  return effect.flatMap(
5925
- predicate({ ...meta(now, input), output, duration }),
5931
+ isEffect(eff) ? eff : effect.succeed(eff),
5926
5932
  (check) => (check ? effect.succeed(result) : Cause.done(output))
5927
5933
  )
5928
5934
  })
@@ -6068,6 +6074,16 @@ export const satisfiesInputType = <T>() =>
6068
6074
  self: Schedule<Output, Input, Error, Env>
6069
6075
  ): Schedule<Output, Input, Error, Env> => self
6070
6076
 
6077
+ /**
6078
+ * Sets the input type of the provided schedule to a specified type, without
6079
+ * altering the schedule's behavior.
6080
+ *
6081
+ * @since 2.0.0
6082
+ * @category ensuring types
6083
+ */
6084
+ export const setInputType =
6085
+ <T>() => <Output, Error, Env>(self: Schedule<Output, T, Error, Env>): Schedule<Output, T, Error, Env> => self
6086
+
6071
6087
  /**
6072
6088
  * Ensures that the provided schedule respects a specified output type.
6073
6089
  *
package/src/Schema.ts CHANGED
@@ -1636,6 +1636,27 @@ export interface Struct<Fields extends Struct.Fields> extends
1636
1636
  >
1637
1637
  {
1638
1638
  readonly "~rebuild.out": this
1639
+ /**
1640
+ * The field definitions of this struct. Spread them into a new struct to
1641
+ * reuse fields across schemas.
1642
+ *
1643
+ * **Example** (Reusing fields across structs)
1644
+ *
1645
+ * ```ts
1646
+ * import { Schema } from "effect"
1647
+ *
1648
+ * const Timestamped = Schema.Struct({
1649
+ * createdAt: Schema.Date,
1650
+ * updatedAt: Schema.Date
1651
+ * })
1652
+ *
1653
+ * const User = Schema.Struct({
1654
+ * ...Timestamped.fields,
1655
+ * name: Schema.String,
1656
+ * email: Schema.String
1657
+ * })
1658
+ * ```
1659
+ */
1639
1660
  readonly fields: Fields
1640
1661
  /**
1641
1662
  * Returns a new struct with the fields modified by the provided function.