effect 3.9.1 → 3.10.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 (221) hide show
  1. package/Arbitrary/package.json +6 -0
  2. package/FastCheck/package.json +6 -0
  3. package/JSONSchema/package.json +6 -0
  4. package/ParseResult/package.json +6 -0
  5. package/Pretty/package.json +6 -0
  6. package/Schema/package.json +6 -0
  7. package/SchemaAST/package.json +6 -0
  8. package/TSubscriptionRef/package.json +6 -0
  9. package/dist/cjs/Arbitrary.js +490 -0
  10. package/dist/cjs/Arbitrary.js.map +1 -0
  11. package/dist/cjs/Effect.js +247 -16
  12. package/dist/cjs/Effect.js.map +1 -1
  13. package/dist/cjs/FastCheck.js +17 -0
  14. package/dist/cjs/FastCheck.js.map +1 -0
  15. package/dist/cjs/Inspectable.js +43 -3
  16. package/dist/cjs/Inspectable.js.map +1 -1
  17. package/dist/cjs/JSONSchema.js +418 -0
  18. package/dist/cjs/JSONSchema.js.map +1 -0
  19. package/dist/cjs/ParseResult.js +1539 -0
  20. package/dist/cjs/ParseResult.js.map +1 -0
  21. package/dist/cjs/Predicate.js +3 -1
  22. package/dist/cjs/Predicate.js.map +1 -1
  23. package/dist/cjs/Pretty.js +183 -0
  24. package/dist/cjs/Pretty.js.map +1 -0
  25. package/dist/cjs/Schema.js +5529 -0
  26. package/dist/cjs/Schema.js.map +1 -0
  27. package/dist/cjs/SchemaAST.js +2365 -0
  28. package/dist/cjs/SchemaAST.js.map +1 -0
  29. package/dist/cjs/Stream.js +17 -3
  30. package/dist/cjs/Stream.js.map +1 -1
  31. package/dist/cjs/TPubSub.js +9 -1
  32. package/dist/cjs/TPubSub.js.map +1 -1
  33. package/dist/cjs/TQueue.js.map +1 -1
  34. package/dist/cjs/TRef.js.map +1 -1
  35. package/dist/cjs/TSubscriptionRef.js +96 -0
  36. package/dist/cjs/TSubscriptionRef.js.map +1 -0
  37. package/dist/cjs/index.js +18 -2
  38. package/dist/cjs/index.js.map +1 -1
  39. package/dist/cjs/internal/cause.js +2 -2
  40. package/dist/cjs/internal/cause.js.map +1 -1
  41. package/dist/cjs/internal/core.js +4 -4
  42. package/dist/cjs/internal/core.js.map +1 -1
  43. package/dist/cjs/internal/doNotation.js.map +1 -1
  44. package/dist/cjs/internal/fiberRuntime.js +14 -12
  45. package/dist/cjs/internal/fiberRuntime.js.map +1 -1
  46. package/dist/cjs/internal/logger.js +7 -6
  47. package/dist/cjs/internal/logger.js.map +1 -1
  48. package/dist/cjs/internal/redacted.js +4 -0
  49. package/dist/cjs/internal/redacted.js.map +1 -1
  50. package/dist/cjs/internal/schema/errors.js +116 -0
  51. package/dist/cjs/internal/schema/errors.js.map +1 -0
  52. package/dist/cjs/internal/schema/filters.js +41 -0
  53. package/dist/cjs/internal/schema/filters.js.map +1 -0
  54. package/dist/cjs/internal/schema/util.js +96 -0
  55. package/dist/cjs/internal/schema/util.js.map +1 -0
  56. package/dist/cjs/internal/stm/core.js +2 -3
  57. package/dist/cjs/internal/stm/core.js.map +1 -1
  58. package/dist/cjs/internal/stm/tPubSub.js.map +1 -1
  59. package/dist/cjs/internal/stm/tQueue.js +1 -2
  60. package/dist/cjs/internal/stm/tQueue.js.map +1 -1
  61. package/dist/cjs/internal/stm/tRef.js +6 -2
  62. package/dist/cjs/internal/stm/tRef.js.map +1 -1
  63. package/dist/cjs/internal/stm/tSubscriptionRef.js +178 -0
  64. package/dist/cjs/internal/stm/tSubscriptionRef.js.map +1 -0
  65. package/dist/cjs/internal/stream.js +36 -16
  66. package/dist/cjs/internal/stream.js.map +1 -1
  67. package/dist/cjs/internal/version.js +1 -1
  68. package/dist/cjs/internal/version.js.map +1 -1
  69. package/dist/dts/Arbitrary.d.ts +45 -0
  70. package/dist/dts/Arbitrary.d.ts.map +1 -0
  71. package/dist/dts/Array.d.ts +4 -4
  72. package/dist/dts/Array.d.ts.map +1 -1
  73. package/dist/dts/Effect.d.ts +304 -36
  74. package/dist/dts/Effect.d.ts.map +1 -1
  75. package/dist/dts/Either.d.ts +4 -4
  76. package/dist/dts/Either.d.ts.map +1 -1
  77. package/dist/dts/FastCheck.d.ts +9 -0
  78. package/dist/dts/FastCheck.d.ts.map +1 -0
  79. package/dist/dts/Inspectable.d.ts +28 -0
  80. package/dist/dts/Inspectable.d.ts.map +1 -1
  81. package/dist/dts/JSONSchema.d.ts +181 -0
  82. package/dist/dts/JSONSchema.d.ts.map +1 -0
  83. package/dist/dts/Micro.d.ts +4 -4
  84. package/dist/dts/Micro.d.ts.map +1 -1
  85. package/dist/dts/Option.d.ts +4 -4
  86. package/dist/dts/Option.d.ts.map +1 -1
  87. package/dist/dts/ParseResult.d.ts +551 -0
  88. package/dist/dts/ParseResult.d.ts.map +1 -0
  89. package/dist/dts/Predicate.d.ts.map +1 -1
  90. package/dist/dts/Pretty.d.ts +26 -0
  91. package/dist/dts/Pretty.d.ts.map +1 -0
  92. package/dist/dts/STM.d.ts +4 -4
  93. package/dist/dts/STM.d.ts.map +1 -1
  94. package/dist/dts/Schema.d.ts +4562 -0
  95. package/dist/dts/Schema.d.ts.map +1 -0
  96. package/dist/dts/SchemaAST.d.ts +1321 -0
  97. package/dist/dts/SchemaAST.d.ts.map +1 -0
  98. package/dist/dts/Stream.d.ts +78 -13
  99. package/dist/dts/Stream.d.ts.map +1 -1
  100. package/dist/dts/TPubSub.d.ts +8 -0
  101. package/dist/dts/TPubSub.d.ts.map +1 -1
  102. package/dist/dts/TQueue.d.ts +7 -7
  103. package/dist/dts/TQueue.d.ts.map +1 -1
  104. package/dist/dts/TRef.d.ts +2 -1
  105. package/dist/dts/TRef.d.ts.map +1 -1
  106. package/dist/dts/TSubscriptionRef.d.ts +251 -0
  107. package/dist/dts/TSubscriptionRef.d.ts.map +1 -0
  108. package/dist/dts/index.d.ts +32 -0
  109. package/dist/dts/index.d.ts.map +1 -1
  110. package/dist/dts/internal/fiberRuntime.d.ts.map +1 -1
  111. package/dist/dts/internal/schema/errors.d.ts +2 -0
  112. package/dist/dts/internal/schema/errors.d.ts.map +1 -0
  113. package/dist/dts/internal/schema/filters.d.ts +2 -0
  114. package/dist/dts/internal/schema/filters.d.ts.map +1 -0
  115. package/dist/dts/internal/schema/util.d.ts +2 -0
  116. package/dist/dts/internal/schema/util.d.ts.map +1 -0
  117. package/dist/dts/internal/stm/tRef.d.ts +3 -1
  118. package/dist/dts/internal/stm/tRef.d.ts.map +1 -1
  119. package/dist/dts/internal/stm/tSubscriptionRef.d.ts +2 -0
  120. package/dist/dts/internal/stm/tSubscriptionRef.d.ts.map +1 -0
  121. package/dist/dts/internal/stream.d.ts.map +1 -1
  122. package/dist/esm/Arbitrary.js +472 -0
  123. package/dist/esm/Arbitrary.js.map +1 -0
  124. package/dist/esm/Effect.js +256 -18
  125. package/dist/esm/Effect.js.map +1 -1
  126. package/dist/esm/FastCheck.js +9 -0
  127. package/dist/esm/FastCheck.js.map +1 -0
  128. package/dist/esm/Inspectable.js +39 -2
  129. package/dist/esm/Inspectable.js.map +1 -1
  130. package/dist/esm/JSONSchema.js +408 -0
  131. package/dist/esm/JSONSchema.js.map +1 -0
  132. package/dist/esm/ParseResult.js +1503 -0
  133. package/dist/esm/ParseResult.js.map +1 -0
  134. package/dist/esm/Predicate.js +2 -1
  135. package/dist/esm/Predicate.js.map +1 -1
  136. package/dist/esm/Pretty.js +173 -0
  137. package/dist/esm/Pretty.js.map +1 -0
  138. package/dist/esm/Schema.js +5328 -0
  139. package/dist/esm/Schema.js.map +1 -0
  140. package/dist/esm/SchemaAST.js +2300 -0
  141. package/dist/esm/SchemaAST.js.map +1 -0
  142. package/dist/esm/Stream.js +14 -0
  143. package/dist/esm/Stream.js.map +1 -1
  144. package/dist/esm/TPubSub.js +8 -0
  145. package/dist/esm/TPubSub.js.map +1 -1
  146. package/dist/esm/TQueue.js.map +1 -1
  147. package/dist/esm/TRef.js.map +1 -1
  148. package/dist/esm/TSubscriptionRef.js +87 -0
  149. package/dist/esm/TSubscriptionRef.js.map +1 -0
  150. package/dist/esm/index.js +32 -0
  151. package/dist/esm/index.js.map +1 -1
  152. package/dist/esm/internal/cause.js +3 -3
  153. package/dist/esm/internal/cause.js.map +1 -1
  154. package/dist/esm/internal/core.js +4 -4
  155. package/dist/esm/internal/core.js.map +1 -1
  156. package/dist/esm/internal/doNotation.js.map +1 -1
  157. package/dist/esm/internal/fiberRuntime.js +14 -12
  158. package/dist/esm/internal/fiberRuntime.js.map +1 -1
  159. package/dist/esm/internal/logger.js +7 -6
  160. package/dist/esm/internal/logger.js.map +1 -1
  161. package/dist/esm/internal/redacted.js +4 -0
  162. package/dist/esm/internal/redacted.js.map +1 -1
  163. package/dist/esm/internal/schema/errors.js +87 -0
  164. package/dist/esm/internal/schema/errors.js.map +1 -0
  165. package/dist/esm/internal/schema/filters.js +35 -0
  166. package/dist/esm/internal/schema/filters.js.map +1 -0
  167. package/dist/esm/internal/schema/util.js +78 -0
  168. package/dist/esm/internal/schema/util.js.map +1 -0
  169. package/dist/esm/internal/stm/core.js +1 -2
  170. package/dist/esm/internal/stm/core.js.map +1 -1
  171. package/dist/esm/internal/stm/tPubSub.js.map +1 -1
  172. package/dist/esm/internal/stm/tQueue.js +1 -2
  173. package/dist/esm/internal/stm/tQueue.js.map +1 -1
  174. package/dist/esm/internal/stm/tRef.js +5 -1
  175. package/dist/esm/internal/stm/tRef.js.map +1 -1
  176. package/dist/esm/internal/stm/tSubscriptionRef.js +166 -0
  177. package/dist/esm/internal/stm/tSubscriptionRef.js.map +1 -0
  178. package/dist/esm/internal/stream.js +33 -15
  179. package/dist/esm/internal/stream.js.map +1 -1
  180. package/dist/esm/internal/version.js +1 -1
  181. package/dist/esm/internal/version.js.map +1 -1
  182. package/package.json +68 -1
  183. package/src/Arbitrary.ts +563 -0
  184. package/src/Array.ts +4 -4
  185. package/src/Effect.ts +308 -37
  186. package/src/Either.ts +4 -4
  187. package/src/FastCheck.ts +9 -0
  188. package/src/Inspectable.ts +56 -2
  189. package/src/JSONSchema.ts +601 -0
  190. package/src/Micro.ts +4 -4
  191. package/src/Option.ts +4 -4
  192. package/src/ParseResult.ts +2027 -0
  193. package/src/Predicate.ts +3 -1
  194. package/src/Pretty.ts +204 -0
  195. package/src/STM.ts +4 -4
  196. package/src/Schema.ts +10388 -0
  197. package/src/SchemaAST.ts +2827 -0
  198. package/src/Stream.ts +87 -23
  199. package/src/TPubSub.ts +9 -0
  200. package/src/TQueue.ts +7 -7
  201. package/src/TRef.ts +2 -1
  202. package/src/TSubscriptionRef.ts +284 -0
  203. package/src/index.ts +40 -0
  204. package/src/internal/cause.ts +3 -3
  205. package/src/internal/core-effect.ts +6 -6
  206. package/src/internal/core.ts +4 -4
  207. package/src/internal/doNotation.ts +7 -6
  208. package/src/internal/fiberRuntime.ts +14 -12
  209. package/src/internal/groupBy.ts +2 -2
  210. package/src/internal/logger.ts +7 -6
  211. package/src/internal/redacted.ts +4 -0
  212. package/src/internal/schema/errors.ts +189 -0
  213. package/src/internal/schema/filters.ts +86 -0
  214. package/src/internal/schema/util.ts +113 -0
  215. package/src/internal/stm/core.ts +1 -2
  216. package/src/internal/stm/tPubSub.ts +1 -0
  217. package/src/internal/stm/tQueue.ts +2 -2
  218. package/src/internal/stm/tRef.ts +7 -2
  219. package/src/internal/stm/tSubscriptionRef.ts +286 -0
  220. package/src/internal/stream.ts +101 -24
  221. package/src/internal/version.ts +1 -1
@@ -85,7 +85,7 @@ export const try_: {
85
85
  readonly try: LazyArg<A>
86
86
  readonly catch: (error: unknown) => E
87
87
  }): Effect.Effect<A, E>
88
- <A>(evaluate: LazyArg<A>): Effect.Effect<A, Cause.UnknownException>
88
+ <A>(thunk: LazyArg<A>): Effect.Effect<A, Cause.UnknownException>
89
89
  } = <A, E>(
90
90
  arg: LazyArg<A> | {
91
91
  readonly try: LazyArg<A>
@@ -375,14 +375,14 @@ export const Do: Effect.Effect<{}> = core.succeed({})
375
375
  export const bind: {
376
376
  <N extends string, A extends object, B, E2, R2>(
377
377
  name: Exclude<N, keyof A>,
378
- f: (a: A) => Effect.Effect<B, E2, R2>
378
+ f: (a: NoInfer<A>) => Effect.Effect<B, E2, R2>
379
379
  ): <E1, R1>(
380
380
  self: Effect.Effect<A, E1, R1>
381
381
  ) => Effect.Effect<{ [K in N | keyof A]: K extends keyof A ? A[K] : B }, E2 | E1, R2 | R1>
382
382
  <A extends object, N extends string, E1, R1, B, E2, R2>(
383
383
  self: Effect.Effect<A, E1, R1>,
384
384
  name: Exclude<N, keyof A>,
385
- f: (a: A) => Effect.Effect<B, E2, R2>
385
+ f: (a: NoInfer<A>) => Effect.Effect<B, E2, R2>
386
386
  ): Effect.Effect<{ [K in N | keyof A]: K extends keyof A ? A[K] : B }, E1 | E2, R1 | R2>
387
387
  } = doNotation.bind<Effect.EffectTypeLambda>(core.map, core.flatMap)
388
388
 
@@ -396,14 +396,14 @@ export const bindTo: {
396
396
  export const let_: {
397
397
  <N extends string, A extends object, B>(
398
398
  name: Exclude<N, keyof A>,
399
- f: (a: A) => B
399
+ f: (a: NoInfer<A>) => B
400
400
  ): <E, R>(
401
401
  self: Effect.Effect<A, E, R>
402
402
  ) => Effect.Effect<{ [K in N | keyof A]: K extends keyof A ? A[K] : B }, E, R>
403
403
  <A extends object, N extends string, E, R, B>(
404
404
  self: Effect.Effect<A, E, R>,
405
405
  name: Exclude<N, keyof A>,
406
- f: (a: A) => B
406
+ f: (a: NoInfer<A>) => B
407
407
  ): Effect.Effect<{ [K in N | keyof A]: K extends keyof A ? A[K] : B }, E, R>
408
408
  } = doNotation.let_<Effect.EffectTypeLambda>(core.map)
409
409
 
@@ -1656,7 +1656,7 @@ export const tryPromise: {
1656
1656
  readonly catch: (error: unknown) => E
1657
1657
  }
1658
1658
  ): Effect.Effect<A, E>
1659
- <A>(try_: (signal: AbortSignal) => PromiseLike<A>): Effect.Effect<A, Cause.UnknownException>
1659
+ <A>(evaluate: (signal: AbortSignal) => PromiseLike<A>): Effect.Effect<A, Cause.UnknownException>
1660
1660
  } = <A, E>(
1661
1661
  arg: ((signal: AbortSignal) => PromiseLike<A>) | {
1662
1662
  readonly try: (signal: AbortSignal) => PromiseLike<A>
@@ -521,13 +521,13 @@ export const unsafeAsync = <A, E = never, R = never>(
521
521
 
522
522
  /* @internal */
523
523
  export const async = <A, E = never, R = never>(
524
- register: (
524
+ resume: (
525
525
  callback: (_: Effect.Effect<A, E, R>) => void,
526
526
  signal: AbortSignal
527
527
  ) => void | Effect.Effect<void, never, R>,
528
528
  blockingOn: FiberId.FiberId = FiberId.none
529
529
  ): Effect.Effect<A, E, R> => {
530
- return custom(register, function() {
530
+ return custom(resume, function() {
531
531
  let backingResume: ((_: Effect.Effect<A, E, R>) => void) | undefined = undefined
532
532
  let pendingEffect: Effect.Effect<A, E, R> | undefined = undefined
533
533
  function proxyResume(effect: Effect.Effect<A, E, R>) {
@@ -1216,9 +1216,9 @@ export const suspend = <A, E, R>(effect: LazyArg<Effect.Effect<A, E, R>>): Effec
1216
1216
  flatMap(sync(effect), identity)
1217
1217
 
1218
1218
  /* @internal */
1219
- export const sync = <A>(evaluate: LazyArg<A>): Effect.Effect<A> => {
1219
+ export const sync = <A>(thunk: LazyArg<A>): Effect.Effect<A> => {
1220
1220
  const effect = new EffectPrimitive(OpCodes.OP_SYNC) as any
1221
- effect.effect_instruction_i0 = evaluate
1221
+ effect.effect_instruction_i0 = thunk
1222
1222
  return effect
1223
1223
  }
1224
1224
 
@@ -1,3 +1,4 @@
1
+ import type { NoInfer } from "effect/Types"
1
2
  import { dual } from "../Function.js"
2
3
  import type { Kind, TypeLambda } from "../HKT.js"
3
4
 
@@ -22,20 +23,20 @@ export const let_ = <F extends TypeLambda>(
22
23
  ): {
23
24
  <N extends string, A extends object, B>(
24
25
  name: Exclude<N, keyof A>,
25
- f: (a: A) => B
26
+ f: (a: NoInfer<A>) => B
26
27
  ): <R, O, E>(
27
28
  self: Kind<F, R, O, E, A>
28
29
  ) => Kind<F, R, O, E, { [K in keyof A | N]: K extends keyof A ? A[K] : B }>
29
30
  <R, O, E, A extends object, N extends string, B>(
30
31
  self: Kind<F, R, O, E, A>,
31
32
  name: Exclude<N, keyof A>,
32
- f: (a: A) => B
33
+ f: (a: NoInfer<A>) => B
33
34
  ): Kind<F, R, O, E, { [K in keyof A | N]: K extends keyof A ? A[K] : B }>
34
35
  } =>
35
36
  dual(3, <R, O, E, A extends object, N extends string, B>(
36
37
  self: Kind<F, R, O, E, A>,
37
38
  name: Exclude<N, keyof A>,
38
- f: (a: A) => B
39
+ f: (a: NoInfer<A>) => B
39
40
  ): Kind<F, R, O, E, { [K in keyof A | N]: K extends keyof A ? A[K] : B }> =>
40
41
  map(self, (a) => Object.assign({}, a, { [name]: f(a) }) as any))
41
42
 
@@ -58,20 +59,20 @@ export const bindTo = <F extends TypeLambda>(map: Map<F>): {
58
59
  export const bind = <F extends TypeLambda>(map: Map<F>, flatMap: FlatMap<F>): {
59
60
  <N extends string, A extends object, R2, O2, E2, B>(
60
61
  name: Exclude<N, keyof A>,
61
- f: (a: A) => Kind<F, R2, O2, E2, B>
62
+ f: (a: NoInfer<A>) => Kind<F, R2, O2, E2, B>
62
63
  ): <R1, O1, E1>(
63
64
  self: Kind<F, R1, O1, E1, A>
64
65
  ) => Kind<F, R1 & R2, O1 | O2, E1 | E2, { [K in keyof A | N]: K extends keyof A ? A[K] : B }>
65
66
  <R1, O1, E1, A extends object, N extends string, R2, O2, E2, B>(
66
67
  self: Kind<F, R1, O1, E1, A>,
67
68
  name: Exclude<N, keyof A>,
68
- f: (a: A) => Kind<F, R2, O2, E2, B>
69
+ f: (a: NoInfer<A>) => Kind<F, R2, O2, E2, B>
69
70
  ): Kind<F, R1 & R2, O1 | O2, E1 | E2, { [K in keyof A | N]: K extends keyof A ? A[K] : B }>
70
71
  } =>
71
72
  dual(3, <R1, O1, E1, A, N extends string, R2, O2, E2, B>(
72
73
  self: Kind<F, R1, O1, E1, A>,
73
74
  name: Exclude<N, keyof A>,
74
- f: (a: A) => Kind<F, R2, O2, E2, B>
75
+ f: (a: NoInfer<A>) => Kind<F, R2, O2, E2, B>
75
76
  ): Kind<F, R1 & R2, O1 | O2, E1 | E2, { [K in keyof A | N]: K extends keyof A ? A[K] : B }> =>
76
77
  flatMap(self, (a) =>
77
78
  map(f(a), (b) => Object.assign({}, a, { [name]: b }) as { [K in keyof A | N]: K extends keyof A ? A[K] : B })))
@@ -827,18 +827,20 @@ export class FiberRuntime<in out A, in out E = never> extends Effectable.Class<A
827
827
  if (HashSet.size(loggers) > 0) {
828
828
  const clockService = Context.get(this.getFiberRef(defaultServices.currentServices), clock.clockTag)
829
829
  const date = new Date(clockService.unsafeCurrentTimeMillis())
830
- for (const logger of loggers) {
831
- logger.log({
832
- fiberId: this.id(),
833
- logLevel,
834
- message,
835
- cause,
836
- context: contextMap,
837
- spans,
838
- annotations,
839
- date
840
- })
841
- }
830
+ Inspectable.withRedactableContext(contextMap, () => {
831
+ for (const logger of loggers) {
832
+ logger.log({
833
+ fiberId: this.id(),
834
+ logLevel,
835
+ message,
836
+ cause,
837
+ context: contextMap,
838
+ spans,
839
+ annotations,
840
+ date
841
+ })
842
+ }
843
+ })
842
844
  }
843
845
  }
844
846
 
@@ -277,7 +277,7 @@ export const mapEffectOptions = dual<
277
277
  export const bindEffect = dual<
278
278
  <N extends string, A, B, E2, R2>(
279
279
  tag: Exclude<N, keyof A>,
280
- f: (_: A) => Effect.Effect<B, E2, R2>,
280
+ f: (_: NoInfer<A>) => Effect.Effect<B, E2, R2>,
281
281
  options?: {
282
282
  readonly concurrency?: number | "unbounded" | undefined
283
283
  readonly bufferSize?: number | undefined
@@ -290,7 +290,7 @@ export const bindEffect = dual<
290
290
  <A, E, R, N extends string, B, E2, R2>(
291
291
  self: Stream.Stream<A, E, R>,
292
292
  tag: Exclude<N, keyof A>,
293
- f: (_: A) => Effect.Effect<B, E2, R2>,
293
+ f: (_: NoInfer<A>) => Effect.Effect<B, E2, R2>,
294
294
  options?: {
295
295
  readonly concurrency?: number | "unbounded" | undefined
296
296
  readonly unordered?: boolean | undefined
@@ -341,7 +341,7 @@ export const structuredMessage = (u: unknown): unknown => {
341
341
  return String(u)
342
342
  }
343
343
  default: {
344
- return u
344
+ return Inspectable.toJSON(u)
345
345
  }
346
346
  }
347
347
  }
@@ -488,13 +488,13 @@ const prettyLoggerTty = (options: {
488
488
 
489
489
  if (messageIndex < message.length) {
490
490
  for (; messageIndex < message.length; messageIndex++) {
491
- log(message[messageIndex])
491
+ log(Inspectable.redact(message[messageIndex]))
492
492
  }
493
493
  }
494
494
 
495
495
  if (HashMap.size(annotations) > 0) {
496
496
  for (const [key, value] of annotations) {
497
- log(color(`${key}:`, colors.bold, colors.white), value)
497
+ log(color(`${key}:`, colors.bold, colors.white), Inspectable.redact(value))
498
498
  }
499
499
  }
500
500
 
@@ -553,16 +553,17 @@ const prettyLoggerBrowser = (options: {
553
553
 
554
554
  if (messageIndex < message.length) {
555
555
  for (; messageIndex < message.length; messageIndex++) {
556
- console.log(message[messageIndex])
556
+ console.log(Inspectable.redact(message[messageIndex]))
557
557
  }
558
558
  }
559
559
 
560
560
  if (HashMap.size(annotations) > 0) {
561
561
  for (const [key, value] of annotations) {
562
+ const redacted = Inspectable.redact(value)
562
563
  if (options.colors) {
563
- console.log(`%c${key}:`, "color:gray", value)
564
+ console.log(`%c${key}:`, "color:gray", redacted)
564
565
  } else {
565
- console.log(`${key}:`, value)
566
+ console.log(`${key}:`, redacted)
566
567
  }
567
568
  }
568
569
  }
@@ -1,3 +1,4 @@
1
+ import { NodeInspectSymbol } from "effect/Inspectable"
1
2
  import * as Equal from "../Equal.js"
2
3
  import { pipe } from "../Function.js"
3
4
  import { globalValue } from "../GlobalValue.js"
@@ -34,6 +35,9 @@ export const proto = {
34
35
  toJSON() {
35
36
  return "<redacted>"
36
37
  },
38
+ [NodeInspectSymbol]() {
39
+ return "<redacted>"
40
+ },
37
41
  [Hash.symbol]<T>(this: Redacted.Redacted<T>): number {
38
42
  return pipe(
39
43
  Hash.hash(RedactedSymbolKey),
@@ -0,0 +1,189 @@
1
+ import * as array_ from "effect/Array"
2
+ import type * as AST from "../../SchemaAST.js"
3
+ import * as util_ from "./util.js"
4
+
5
+ const getErrorMessage = (
6
+ reason: string,
7
+ details?: string,
8
+ path?: ReadonlyArray<PropertyKey>,
9
+ ast?: AST.AST
10
+ ): string => {
11
+ let out = reason
12
+
13
+ if (path && array_.isNonEmptyReadonlyArray(path)) {
14
+ out += `\nat path: ${util_.formatPath(path)}`
15
+ }
16
+
17
+ if (details !== undefined) {
18
+ out += `\ndetails: ${details}`
19
+ }
20
+
21
+ if (ast) {
22
+ out += `\nschema (${ast._tag}): ${ast}`
23
+ }
24
+
25
+ return out
26
+ }
27
+
28
+ // ---------------------------------------------
29
+ // generic
30
+ // ---------------------------------------------
31
+
32
+ /** @internal */
33
+ export const getInvalidArgumentErrorMessage = (details: string) => getErrorMessage("Invalid Argument", details)
34
+
35
+ const getUnsupportedSchemaErrorMessage = (details?: string, path?: ReadonlyArray<PropertyKey>, ast?: AST.AST): string =>
36
+ getErrorMessage("Unsupported schema", details, path, ast)
37
+
38
+ const getMissingAnnotationErrorMessage = (details?: string, path?: ReadonlyArray<PropertyKey>, ast?: AST.AST): string =>
39
+ getErrorMessage("Missing annotation", details, path, ast)
40
+
41
+ // ---------------------------------------------
42
+ // Arbitrary
43
+ // ---------------------------------------------
44
+
45
+ /** @internal */
46
+ export const getArbitraryUnsupportedErrorMessage = (path: ReadonlyArray<PropertyKey>, ast: AST.AST) =>
47
+ getUnsupportedSchemaErrorMessage("Cannot build an Arbitrary for this schema", path, ast)
48
+
49
+ /** @internal */
50
+ export const getArbitraryMissingAnnotationErrorMessage = (
51
+ path: ReadonlyArray<PropertyKey>,
52
+ ast: AST.AST
53
+ ) =>
54
+ getMissingAnnotationErrorMessage(
55
+ `Generating an Arbitrary for this schema requires an "arbitrary" annotation`,
56
+ path,
57
+ ast
58
+ )
59
+
60
+ /** @internal */
61
+ export const getArbitraryEmptyEnumErrorMessage = (path: ReadonlyArray<PropertyKey>) =>
62
+ getErrorMessage("Empty Enums schema", "Generating an Arbitrary for this schema requires at least one enum", path)
63
+
64
+ // ---------------------------------------------
65
+ // Equivalence
66
+ // ---------------------------------------------
67
+
68
+ /** @internal */
69
+ export const getEquivalenceUnsupportedErrorMessage = (ast: AST.AST, path: ReadonlyArray<PropertyKey>) =>
70
+ getUnsupportedSchemaErrorMessage("Cannot build an Equivalence", path, ast)
71
+
72
+ // ---------------------------------------------
73
+ // JSON Schema
74
+ // ---------------------------------------------
75
+
76
+ /** @internal */
77
+ export const getJSONSchemaMissingAnnotationErrorMessage = (
78
+ path: ReadonlyArray<PropertyKey>,
79
+ ast: AST.AST
80
+ ) =>
81
+ getMissingAnnotationErrorMessage(
82
+ `Generating a JSON Schema for this schema requires a "jsonSchema" annotation`,
83
+ path,
84
+ ast
85
+ )
86
+
87
+ /** @internal */
88
+ export const getJSONSchemaMissingIdentifierAnnotationErrorMessage = (
89
+ path: ReadonlyArray<PropertyKey>,
90
+ ast: AST.AST
91
+ ) =>
92
+ getMissingAnnotationErrorMessage(
93
+ `Generating a JSON Schema for this schema requires an "identifier" annotation`,
94
+ path,
95
+ ast
96
+ )
97
+
98
+ /** @internal */
99
+ export const getJSONSchemaUnsupportedParameterErrorMessage = (
100
+ path: ReadonlyArray<PropertyKey>,
101
+ parameter: AST.AST
102
+ ): string => getErrorMessage("Unsupported index signature parameter", undefined, path, parameter)
103
+
104
+ /** @internal */
105
+ export const getJSONSchemaUnsupportedPostRestElementsErrorMessage = (path: ReadonlyArray<PropertyKey>): string =>
106
+ getErrorMessage(
107
+ "Generating a JSON Schema for post-rest elements is not currently supported. You're welcome to contribute by submitting a Pull Request",
108
+ undefined,
109
+ path
110
+ )
111
+
112
+ /** @internal */
113
+ export const getJSONSchemaUnsupportedKeyErrorMessage = (key: PropertyKey, path: ReadonlyArray<PropertyKey>): string =>
114
+ getErrorMessage("Unsupported key", `Cannot encode ${util_.formatPropertyKey(key)} key to JSON Schema`, path)
115
+
116
+ // ---------------------------------------------
117
+ // Pretty
118
+ // ---------------------------------------------
119
+
120
+ /** @internal */
121
+ export const getPrettyMissingAnnotationErrorMessage = (
122
+ path: ReadonlyArray<PropertyKey>,
123
+ ast: AST.AST
124
+ ) => getMissingAnnotationErrorMessage(`Generating a Pretty for this schema requires a "pretty" annotation`, path, ast)
125
+
126
+ /** @internal */
127
+ export const getPrettyNeverErrorMessage = "Cannot pretty print a `never` value"
128
+
129
+ /** @internal */
130
+ export const getPrettyNoMatchingSchemaErrorMessage = (
131
+ actual: unknown,
132
+ path: ReadonlyArray<PropertyKey>,
133
+ ast: AST.AST
134
+ ) => getErrorMessage("Unexpected Error", `Cannot find a matching schema for ${util_.formatUnknown(actual)}`, path, ast)
135
+
136
+ // ---------------------------------------------
137
+ // Schema
138
+ // ---------------------------------------------
139
+
140
+ /** @internal */
141
+ export const getSchemaExtendErrorMessage = (x: AST.AST, y: AST.AST, path: ReadonlyArray<PropertyKey>) =>
142
+ getErrorMessage("Unsupported schema or overlapping types", `cannot extend ${x} with ${y}`, path)
143
+
144
+ /** @internal */
145
+ export const getSchemaUnsupportedLiteralSpanErrorMessage = (ast: AST.AST) =>
146
+ getErrorMessage("Unsupported template literal span", undefined, undefined, ast)
147
+
148
+ // ---------------------------------------------
149
+ // AST
150
+ // ---------------------------------------------
151
+
152
+ /** @internal */
153
+ export const getASTUnsupportedSchema = (ast: AST.AST) => getUnsupportedSchemaErrorMessage(undefined, undefined, ast)
154
+
155
+ /** @internal */
156
+ export const getASTUnsupportedKeySchema = (ast: AST.AST) =>
157
+ getErrorMessage("Unsupported key schema", undefined, undefined, ast)
158
+
159
+ /** @internal */
160
+ export const getASTUnsupportedLiteral = (literal: AST.LiteralValue) =>
161
+ getErrorMessage("Unsupported literal", `literal value: ${util_.formatUnknown(literal)}`)
162
+
163
+ /** @internal */
164
+ export const getASTDuplicateIndexSignatureErrorMessage = (type: "string" | "symbol"): string =>
165
+ getErrorMessage("Duplicate index signature", `${type} index signature`)
166
+
167
+ /** @internal */
168
+ export const getASTIndexSignatureParameterErrorMessage = getErrorMessage(
169
+ "Unsupported index signature parameter",
170
+ "An index signature parameter type must be `string`, `symbol`, a template literal type or a refinement of the previous types"
171
+ )
172
+
173
+ /** @internal */
174
+ export const getASTRequiredElementFollowinAnOptionalElementErrorMessage = getErrorMessage(
175
+ "Invalid element",
176
+ "A required element cannot follow an optional element. ts(1257)"
177
+ )
178
+
179
+ /** @internal */
180
+ export const getASTDuplicatePropertySignatureTransformationErrorMessage = (key: PropertyKey): string =>
181
+ getErrorMessage("Duplicate property signature transformation", `Duplicate key ${util_.formatUnknown(key)}`)
182
+
183
+ /** @internal */
184
+ export const getASTUnsupportedRenameSchema = (ast: AST.AST): string =>
185
+ getUnsupportedSchemaErrorMessage(undefined, undefined, ast)
186
+
187
+ /** @internal */
188
+ export const getASTDuplicatePropertySignatureErrorMessage = (key: PropertyKey): string =>
189
+ getErrorMessage("Duplicate property signature", `Duplicate key ${util_.formatUnknown(key)}`)
@@ -0,0 +1,86 @@
1
+ import type * as Schema from "../../Schema.js"
2
+
3
+ /** @internal */
4
+ export const GreaterThanSchemaId: Schema.GreaterThanSchemaId = Symbol.for(
5
+ "effect/schema/GreaterThan"
6
+ ) as Schema.GreaterThanSchemaId
7
+
8
+ /** @internal */
9
+ export const GreaterThanOrEqualToSchemaId: Schema.GreaterThanOrEqualToSchemaId = Symbol.for(
10
+ "effect/schema/GreaterThanOrEqualTo"
11
+ ) as Schema.GreaterThanOrEqualToSchemaId
12
+
13
+ /** @internal */
14
+ export const LessThanSchemaId: Schema.LessThanSchemaId = Symbol.for(
15
+ "effect/schema/LessThan"
16
+ ) as Schema.LessThanSchemaId
17
+
18
+ /** @internal */
19
+ export const LessThanOrEqualToSchemaId: Schema.LessThanOrEqualToSchemaId = Symbol.for(
20
+ "effect/schema/LessThanOrEqualTo"
21
+ ) as Schema.LessThanOrEqualToSchemaId
22
+
23
+ /** @internal */
24
+ export const IntSchemaId: Schema.IntSchemaId = Symbol.for(
25
+ "effect/schema/Int"
26
+ ) as Schema.IntSchemaId
27
+
28
+ /** @internal */
29
+ export const BetweenSchemaId: Schema.BetweenSchemaId = Symbol.for(
30
+ "effect/schema/Between"
31
+ ) as Schema.BetweenSchemaId
32
+
33
+ /** @internal */
34
+ export const GreaterThanBigintSchemaId: Schema.GreaterThanBigIntSchemaId = Symbol.for(
35
+ "effect/schema/GreaterThanBigint"
36
+ ) as Schema.GreaterThanBigIntSchemaId
37
+
38
+ /** @internal */
39
+ export const GreaterThanOrEqualToBigIntSchemaId: Schema.GreaterThanOrEqualToBigIntSchemaId = Symbol.for(
40
+ "effect/schema/GreaterThanOrEqualToBigint"
41
+ ) as Schema.GreaterThanOrEqualToBigIntSchemaId
42
+
43
+ /** @internal */
44
+ export const LessThanBigIntSchemaId: Schema.LessThanBigIntSchemaId = Symbol.for(
45
+ "effect/schema/LessThanBigint"
46
+ ) as Schema.LessThanBigIntSchemaId
47
+
48
+ /** @internal */
49
+ export const LessThanOrEqualToBigIntSchemaId: Schema.LessThanOrEqualToBigIntSchemaId = Symbol.for(
50
+ "effect/schema/LessThanOrEqualToBigint"
51
+ ) as Schema.LessThanOrEqualToBigIntSchemaId
52
+
53
+ /** @internal */
54
+ export const BetweenBigintSchemaId: Schema.BetweenBigIntSchemaId = Symbol.for(
55
+ "effect/schema/BetweenBigint"
56
+ ) as Schema.BetweenBigIntSchemaId
57
+
58
+ /** @internal */
59
+ export const MinLengthSchemaId: Schema.MinLengthSchemaId = Symbol.for(
60
+ "effect/schema/MinLength"
61
+ ) as Schema.MinLengthSchemaId
62
+
63
+ /** @internal */
64
+ export const MaxLengthSchemaId: Schema.MaxLengthSchemaId = Symbol.for(
65
+ "effect/schema/MaxLength"
66
+ ) as Schema.MaxLengthSchemaId
67
+
68
+ /** @internal */
69
+ export const LengthSchemaId: Schema.LengthSchemaId = Symbol.for(
70
+ "effect/schema/Length"
71
+ ) as Schema.LengthSchemaId
72
+
73
+ /** @internal */
74
+ export const MinItemsSchemaId: Schema.MinItemsSchemaId = Symbol.for(
75
+ "effect/schema/MinItems"
76
+ ) as Schema.MinItemsSchemaId
77
+
78
+ /** @internal */
79
+ export const MaxItemsSchemaId: Schema.MaxItemsSchemaId = Symbol.for(
80
+ "effect/schema/MaxItems"
81
+ ) as Schema.MaxItemsSchemaId
82
+
83
+ /** @internal */
84
+ export const ItemsCountSchemaId: Schema.ItemsCountSchemaId = Symbol.for(
85
+ "effect/schema/ItemsCount"
86
+ ) as Schema.ItemsCountSchemaId
@@ -0,0 +1,113 @@
1
+ import * as array_ from "effect/Array"
2
+ import * as Predicate from "effect/Predicate"
3
+ import type * as ParseResult from "../../ParseResult.js"
4
+ import type * as AST from "../../SchemaAST.js"
5
+
6
+ /** @internal */
7
+ export const getKeysForIndexSignature = (
8
+ input: { readonly [x: PropertyKey]: unknown },
9
+ parameter: AST.Parameter
10
+ ): ReadonlyArray<string> | ReadonlyArray<symbol> => {
11
+ switch (parameter._tag) {
12
+ case "StringKeyword":
13
+ case "TemplateLiteral":
14
+ return Object.keys(input)
15
+ case "SymbolKeyword":
16
+ return Object.getOwnPropertySymbols(input)
17
+ case "Refinement":
18
+ return getKeysForIndexSignature(input, parameter.from)
19
+ }
20
+ }
21
+
22
+ /**
23
+ * JavaScript does not store the insertion order of properties in a way that
24
+ * combines both string and symbol keys. The internal order groups string keys
25
+ * and symbol keys separately. Hence concatenating the keys is fine.
26
+ *
27
+ * @internal
28
+ */
29
+ export const ownKeys = (o: object): Array<PropertyKey> =>
30
+ (Object.keys(o) as Array<PropertyKey>).concat(Object.getOwnPropertySymbols(o))
31
+
32
+ /** @internal */
33
+ export const memoizeThunk = <A>(f: () => A): () => A => {
34
+ let done = false
35
+ let a: A
36
+ return () => {
37
+ if (done) {
38
+ return a
39
+ }
40
+ a = f()
41
+ done = true
42
+ return a
43
+ }
44
+ }
45
+
46
+ /** @internal */
47
+ export const formatDate = (date: Date): string => {
48
+ try {
49
+ return date.toISOString()
50
+ } catch (e) {
51
+ return String(date)
52
+ }
53
+ }
54
+
55
+ /** @internal */
56
+ export const formatUnknown = (u: unknown): string => {
57
+ if (Predicate.isString(u)) {
58
+ return JSON.stringify(u)
59
+ } else if (
60
+ Predicate.isNumber(u)
61
+ || u == null
62
+ || Predicate.isBoolean(u)
63
+ || Predicate.isSymbol(u)
64
+ ) {
65
+ return String(u)
66
+ } else if (Predicate.isDate(u)) {
67
+ return formatDate(u)
68
+ } else if (Predicate.isBigInt(u)) {
69
+ return String(u) + "n"
70
+ } else if (
71
+ !array_.isArray(u)
72
+ && Predicate.hasProperty(u, "toString")
73
+ && Predicate.isFunction(u["toString"])
74
+ && u["toString"] !== Object.prototype.toString
75
+ ) {
76
+ return u["toString"]()
77
+ }
78
+ try {
79
+ JSON.stringify(u)
80
+ if (array_.isArray(u)) {
81
+ return `[${u.map(formatUnknown).join(",")}]`
82
+ } else {
83
+ return `{${
84
+ ownKeys(u).map((k) =>
85
+ `${Predicate.isString(k) ? JSON.stringify(k) : String(k)}:${formatUnknown((u as any)[k])}`
86
+ ).join(",")
87
+ }}`
88
+ }
89
+ } catch (e) {
90
+ return String(u)
91
+ }
92
+ }
93
+
94
+ /** @internal */
95
+ export const formatPropertyKey = (name: PropertyKey): string =>
96
+ typeof name === "string" ? JSON.stringify(name) : String(name)
97
+
98
+ /** @internal */
99
+ export type SingleOrArray<A> = A | ReadonlyArray<A>
100
+
101
+ /** @internal */
102
+ export const isNonEmpty = <A>(x: ParseResult.SingleOrNonEmpty<A>): x is array_.NonEmptyReadonlyArray<A> =>
103
+ Array.isArray(x)
104
+
105
+ /** @internal */
106
+ export const isSingle = <A>(x: A | ReadonlyArray<A>): x is A => !Array.isArray(x)
107
+
108
+ /** @internal */
109
+ export const formatPathKey = (key: PropertyKey): string => `[${formatPropertyKey(key)}]`
110
+
111
+ /** @internal */
112
+ export const formatPath = (path: ParseResult.Path): string =>
113
+ isNonEmpty(path) ? path.map(formatPathKey).join("") : formatPathKey(path)
@@ -15,11 +15,10 @@ import { pipeArguments } from "../../Pipeable.js"
15
15
  import { hasProperty } from "../../Predicate.js"
16
16
  import type * as Scheduler from "../../Scheduler.js"
17
17
  import type * as STM from "../../STM.js"
18
- import { StreamTypeId } from "../../Stream.js"
19
18
  import { YieldWrap } from "../../Utils.js"
20
19
  import { ChannelTypeId } from "../core-stream.js"
21
20
  import { withFiberRuntime } from "../core.js"
22
- import { effectVariance } from "../effectable.js"
21
+ import { effectVariance, StreamTypeId } from "../effectable.js"
23
22
  import { OP_COMMIT } from "../opCodes/effect.js"
24
23
  import { SingleShotGen } from "../singleShotGen.js"
25
24
  import { SinkTypeId } from "../sink.js"
@@ -201,6 +201,7 @@ class TPubSubSubscriptionImpl<in out A> implements TQueue.TDequeue<A> {
201
201
  capacity(): number {
202
202
  return this.requestedCapacity
203
203
  }
204
+
204
205
  size: STM.STM<number> = core.withSTMRuntime((runtime) => {
205
206
  let currentSubscriberHead = tRef.unsafeGet(this.subscriberHead, runtime.journal)
206
207
  if (currentSubscriberHead === undefined) {
@@ -3,7 +3,7 @@ import * as Chunk from "../../Chunk.js"
3
3
  import { dual, pipe } from "../../Function.js"
4
4
  import * as Option from "../../Option.js"
5
5
  import { hasProperty, type Predicate } from "../../Predicate.js"
6
- import * as STM from "../../STM.js"
6
+ import type * as STM from "../../STM.js"
7
7
  import type * as TQueue from "../../TQueue.js"
8
8
  import type * as TRef from "../../TRef.js"
9
9
  import * as core from "./core.js"
@@ -99,7 +99,7 @@ class TQueueImpl<in out A> implements TQueue.TQueue<A> {
99
99
  size: STM.STM<number> = core.withSTMRuntime((runtime) => {
100
100
  const queue = tRef.unsafeGet(this.ref, runtime.journal)
101
101
  if (queue === undefined) {
102
- return STM.interruptAs(runtime.fiberId)
102
+ return core.interruptAs(runtime.fiberId)
103
103
  }
104
104
  return core.succeed(queue.length)
105
105
  })