effect 3.13.4 → 3.13.7

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 (54) hide show
  1. package/dist/cjs/ConfigProvider.js +6 -2
  2. package/dist/cjs/ConfigProvider.js.map +1 -1
  3. package/dist/cjs/JSONSchema.js +43 -6
  4. package/dist/cjs/JSONSchema.js.map +1 -1
  5. package/dist/cjs/Match.js.map +1 -1
  6. package/dist/cjs/STM.js.map +1 -1
  7. package/dist/cjs/Schema.js +22 -21
  8. package/dist/cjs/Schema.js.map +1 -1
  9. package/dist/cjs/internal/configProvider.js +2 -2
  10. package/dist/cjs/internal/configProvider.js.map +1 -1
  11. package/dist/cjs/internal/matcher.js.map +1 -1
  12. package/dist/cjs/internal/version.js +1 -1
  13. package/dist/dts/ConfigProvider.d.ts +7 -3
  14. package/dist/dts/ConfigProvider.d.ts.map +1 -1
  15. package/dist/dts/Effect.d.ts +16 -16
  16. package/dist/dts/Effect.d.ts.map +1 -1
  17. package/dist/dts/JSONSchema.d.ts +9 -4
  18. package/dist/dts/JSONSchema.d.ts.map +1 -1
  19. package/dist/dts/Match.d.ts +4 -4
  20. package/dist/dts/Match.d.ts.map +1 -1
  21. package/dist/dts/Micro.d.ts +5 -5
  22. package/dist/dts/Micro.d.ts.map +1 -1
  23. package/dist/dts/STM.d.ts +2 -2
  24. package/dist/dts/STM.d.ts.map +1 -1
  25. package/dist/dts/Schema.d.ts.map +1 -1
  26. package/dist/dts/Types.d.ts +1 -1
  27. package/dist/dts/Types.d.ts.map +1 -1
  28. package/dist/esm/ConfigProvider.js +6 -2
  29. package/dist/esm/ConfigProvider.js.map +1 -1
  30. package/dist/esm/JSONSchema.js +43 -6
  31. package/dist/esm/JSONSchema.js.map +1 -1
  32. package/dist/esm/Match.js.map +1 -1
  33. package/dist/esm/STM.js.map +1 -1
  34. package/dist/esm/Schema.js +22 -21
  35. package/dist/esm/Schema.js.map +1 -1
  36. package/dist/esm/internal/configProvider.js +2 -2
  37. package/dist/esm/internal/configProvider.js.map +1 -1
  38. package/dist/esm/internal/matcher.js.map +1 -1
  39. package/dist/esm/internal/version.js +1 -1
  40. package/package.json +1 -1
  41. package/src/ConfigProvider.ts +7 -3
  42. package/src/Effect.ts +16 -16
  43. package/src/JSONSchema.ts +55 -15
  44. package/src/Match.ts +23 -13
  45. package/src/Micro.ts +5 -5
  46. package/src/STM.ts +5 -2
  47. package/src/Schema.ts +51 -52
  48. package/src/Types.ts +1 -1
  49. package/src/internal/configProvider.ts +2 -2
  50. package/src/internal/effect/circular.ts +6 -6
  51. package/src/internal/fiberRuntime.ts +5 -5
  52. package/src/internal/matcher.ts +46 -32
  53. package/src/internal/schedule.ts +4 -4
  54. package/src/internal/version.ts +1 -1
package/src/STM.ts CHANGED
@@ -14,7 +14,7 @@ import * as stm from "./internal/stm/stm.js"
14
14
  import type * as Option from "./Option.js"
15
15
  import type { Pipeable } from "./Pipeable.js"
16
16
  import type { Predicate, Refinement } from "./Predicate.js"
17
- import type { Covariant, MergeRecord, NoInfer } from "./Types.js"
17
+ import type { Covariant, MergeRecord, NoExcessProperties, NoInfer } from "./Types.js"
18
18
  import type * as Unify from "./Unify.js"
19
19
  import type { YieldWrap } from "./Utils.js"
20
20
 
@@ -248,7 +248,10 @@ export declare namespace All {
248
248
  * @category utils
249
249
  */
250
250
  export interface Signature {
251
- <Arg extends ReadonlyArray<STMAny> | Iterable<STMAny> | Record<string, STMAny>, O extends Options>(
251
+ <
252
+ Arg extends ReadonlyArray<STMAny> | Iterable<STMAny> | Record<string, STMAny>,
253
+ O extends NoExcessProperties<Options, O>
254
+ >(
252
255
  arg: Narrow<Arg>,
253
256
  options?: O
254
257
  ): [Arg] extends [ReadonlyArray<STMAny>] ? ReturnTuple<Arg, IsDiscard<O>>
package/src/Schema.ts CHANGED
@@ -3469,18 +3469,13 @@ const intersectTypeLiterals = (
3469
3469
  throw new Error(errors_.getSchemaExtendErrorMessage(x, y, path))
3470
3470
  }
3471
3471
 
3472
- const preserveRefinementAnnotations = AST.blackListAnnotations([
3473
- AST.IdentifierAnnotationId
3474
- ])
3472
+ const preserveRefinementAnnotations = AST.blackListAnnotations([AST.IdentifierAnnotationId])
3475
3473
 
3476
3474
  const addRefinementToMembers = (refinement: AST.Refinement, asts: ReadonlyArray<AST.AST>): Array<AST.Refinement> =>
3477
3475
  asts.map((ast) => new AST.Refinement(ast, refinement.filter, preserveRefinementAnnotations(refinement)))
3478
3476
 
3479
- const extendAST = (
3480
- x: AST.AST,
3481
- y: AST.AST,
3482
- path: ReadonlyArray<PropertyKey>
3483
- ): AST.AST => AST.Union.make(intersectUnionMembers([x], [y], path))
3477
+ const extendAST = (x: AST.AST, y: AST.AST, path: ReadonlyArray<PropertyKey>): AST.AST =>
3478
+ AST.Union.make(intersectUnionMembers([x], [y], path))
3484
3479
 
3485
3480
  const getTypes = (ast: AST.AST): ReadonlyArray<AST.AST> => AST.isUnion(ast) ? ast.types : [ast]
3486
3481
 
@@ -3555,59 +3550,63 @@ const intersectUnionMembers = (
3555
3550
  case "TypeLiteral":
3556
3551
  return [intersectTypeLiterals(x, y, path)]
3557
3552
  case "Transformation": {
3558
- if (AST.isTypeLiteralTransformation(x.transformation)) {
3559
- return [
3560
- new AST.Transformation(
3561
- intersectTypeLiterals(x.from, y, path),
3562
- intersectTypeLiterals(x.to, AST.typeAST(y), path),
3563
- new AST.TypeLiteralTransformation(
3564
- x.transformation.propertySignatureTransformations
3553
+ const transformation = x.transformation
3554
+ const from = intersectTypeLiterals(x.from, y, path)
3555
+ const to = intersectTypeLiterals(x.to, AST.typeAST(y), path)
3556
+ switch (transformation._tag) {
3557
+ case "TypeLiteralTransformation":
3558
+ return [
3559
+ new AST.Transformation(
3560
+ from,
3561
+ to,
3562
+ new AST.TypeLiteralTransformation(transformation.propertySignatureTransformations)
3565
3563
  )
3566
- )
3567
- ]
3564
+ ]
3565
+ case "ComposeTransformation":
3566
+ return [new AST.Transformation(from, to, AST.composeTransformation)]
3567
+ case "FinalTransformation":
3568
+ return [
3569
+ new AST.Transformation(
3570
+ from,
3571
+ to,
3572
+ new AST.FinalTransformation(
3573
+ (fromA, options, ast, fromI) =>
3574
+ ParseResult.map(
3575
+ transformation.decode(fromA, options, ast, fromI),
3576
+ (partial) => ({ ...fromA, ...partial })
3577
+ ),
3578
+ (toI, options, ast, toA) =>
3579
+ ParseResult.map(
3580
+ transformation.encode(toI, options, ast, toA),
3581
+ (partial) => ({ ...toI, ...partial })
3582
+ )
3583
+ )
3584
+ )
3585
+ ]
3568
3586
  }
3569
- break
3570
3587
  }
3571
3588
  }
3572
3589
  break
3573
3590
  }
3574
3591
  case "Transformation": {
3575
- if (AST.isTypeLiteralTransformation(y.transformation)) {
3576
- switch (x._tag) {
3577
- case "Union":
3578
- return intersectUnionMembers(x.types, [y], path)
3579
- case "Suspend":
3580
- return [new AST.Suspend(() => extendAST(x.f(), y, path))]
3581
- case "Refinement":
3582
- return addRefinementToMembers(x, intersectUnionMembers(getTypes(x.from), [y], path))
3583
- case "TypeLiteral":
3584
- return [
3585
- new AST.Transformation(
3586
- intersectTypeLiterals(x, y.from, path),
3587
- intersectTypeLiterals(AST.typeAST(x), y.to, path),
3588
- new AST.TypeLiteralTransformation(
3589
- y.transformation.propertySignatureTransformations
3592
+ if (AST.isTransformation(x)) {
3593
+ if (
3594
+ AST.isTypeLiteralTransformation(y.transformation) && AST.isTypeLiteralTransformation(x.transformation)
3595
+ ) {
3596
+ return [
3597
+ new AST.Transformation(
3598
+ intersectTypeLiterals(x.from, y.from, path),
3599
+ intersectTypeLiterals(x.to, y.to, path),
3600
+ new AST.TypeLiteralTransformation(
3601
+ y.transformation.propertySignatureTransformations.concat(
3602
+ x.transformation.propertySignatureTransformations
3590
3603
  )
3591
3604
  )
3592
- ]
3593
- case "Transformation":
3594
- {
3595
- if (AST.isTypeLiteralTransformation(x.transformation)) {
3596
- return [
3597
- new AST.Transformation(
3598
- intersectTypeLiterals(x.from, y.from, path),
3599
- intersectTypeLiterals(x.to, y.to, path),
3600
- new AST.TypeLiteralTransformation(
3601
- y.transformation.propertySignatureTransformations.concat(
3602
- x.transformation.propertySignatureTransformations
3603
- )
3604
- )
3605
- )
3606
- ]
3607
- }
3608
- }
3609
- break
3605
+ )
3606
+ ]
3610
3607
  }
3608
+ } else {
3609
+ return intersectUnionMembers([y], [x], path)
3611
3610
  }
3612
3611
  break
3613
3612
  }
@@ -9385,7 +9384,7 @@ const makeClass = <Fields extends Struct.Fields>(
9385
9384
  }
9386
9385
 
9387
9386
  const declaration: Schema.Any = declare(
9388
- [typeSide],
9387
+ [schema],
9389
9388
  {
9390
9389
  decode: () => (input, _, ast) =>
9391
9390
  input instanceof this || fallbackInstanceOf(input)
package/src/Types.ts CHANGED
@@ -251,7 +251,7 @@ export type Mutable<T> = {
251
251
  */
252
252
  export type DeepMutable<T> = T extends ReadonlyMap<infer K, infer V> ? Map<DeepMutable<K>, DeepMutable<V>>
253
253
  : T extends ReadonlySet<infer V> ? Set<DeepMutable<V>>
254
- : [keyof T] extends [never] ? T
254
+ : T extends string | number | boolean | bigint | symbol ? T
255
255
  : { -readonly [K in keyof T]: DeepMutable<T[K]> }
256
256
 
257
257
  /**
@@ -102,9 +102,9 @@ export const fromFlat = (flat: ConfigProvider.ConfigProvider.Flat): ConfigProvid
102
102
 
103
103
  /** @internal */
104
104
  export const fromEnv = (
105
- config?: Partial<ConfigProvider.ConfigProvider.FromEnvConfig>
105
+ options?: Partial<ConfigProvider.ConfigProvider.FromEnvConfig>
106
106
  ): ConfigProvider.ConfigProvider => {
107
- const { pathDelim, seqDelim } = Object.assign({}, { pathDelim: "_", seqDelim: "," }, config)
107
+ const { pathDelim, seqDelim } = Object.assign({}, { pathDelim: "_", seqDelim: "," }, options)
108
108
  const makePathString = (path: ReadonlyArray<string>): string => pipe(path, Arr.join(pathDelim))
109
109
  const unmakePathString = (pathString: string): ReadonlyArray<string> => pathString.split(pathDelim)
110
110
 
@@ -805,12 +805,12 @@ export const bindAll: {
805
805
  <
806
806
  A extends object,
807
807
  X extends Record<string, Effect.Effect<any, any, any>>,
808
- O extends {
808
+ O extends Types.NoExcessProperties<{
809
809
  readonly concurrency?: Types.Concurrency | undefined
810
810
  readonly batching?: boolean | "inherit" | undefined
811
811
  readonly mode?: "default" | "validate" | "either" | undefined
812
812
  readonly concurrentFinalizers?: boolean | undefined
813
- }
813
+ }, O>
814
814
  >(
815
815
  f: (a: A) => [Extract<keyof X, keyof A>] extends [never] ? X : `Duplicate keys`,
816
816
  options?: undefined | O
@@ -832,12 +832,12 @@ export const bindAll: {
832
832
  <
833
833
  A extends object,
834
834
  X extends Record<string, Effect.Effect<any, any, any>>,
835
- O extends {
835
+ O extends Types.NoExcessProperties<{
836
836
  readonly concurrency?: Types.Concurrency | undefined
837
837
  readonly batching?: boolean | "inherit" | undefined
838
838
  readonly mode?: "default" | "validate" | "either" | undefined
839
839
  readonly concurrentFinalizers?: boolean | undefined
840
- },
840
+ }, O>,
841
841
  E1,
842
842
  R1
843
843
  >(
@@ -864,12 +864,12 @@ export const bindAll: {
864
864
  } = dual((args) => core.isEffect(args[0]), <
865
865
  A extends object,
866
866
  X extends Record<string, Effect.Effect<any, any, any>>,
867
- O extends {
867
+ O extends Types.NoExcessProperties<{
868
868
  readonly concurrency?: Types.Concurrency | undefined
869
869
  readonly batching?: boolean | "inherit" | undefined
870
870
  readonly mode?: "default" | "validate" | "either" | undefined
871
871
  readonly concurrentFinalizers?: boolean | undefined
872
- },
872
+ }, O>,
873
873
  E1,
874
874
  R1
875
875
  >(
@@ -43,7 +43,7 @@ import { currentScheduler, type Scheduler } from "../Scheduler.js"
43
43
  import type * as Scope from "../Scope.js"
44
44
  import type * as Supervisor from "../Supervisor.js"
45
45
  import type * as Tracer from "../Tracer.js"
46
- import type { Concurrency, NoInfer } from "../Types.js"
46
+ import type { Concurrency, NoExcessProperties, NoInfer } from "../Types.js"
47
47
  import { internalCall, yieldWrapGet } from "../Utils.js"
48
48
  import * as RequestBlock_ from "./blockedRequests.js"
49
49
  import * as internalCause from "./cause.js"
@@ -1945,13 +1945,13 @@ const allEither = (
1945
1945
  /* @internal */
1946
1946
  export const all = <
1947
1947
  const Arg extends Iterable<Effect.Effect<any, any, any>> | Record<string, Effect.Effect<any, any, any>>,
1948
- O extends {
1948
+ O extends NoExcessProperties<{
1949
1949
  readonly concurrency?: Concurrency | undefined
1950
1950
  readonly batching?: boolean | "inherit" | undefined
1951
1951
  readonly discard?: boolean | undefined
1952
1952
  readonly mode?: "default" | "validate" | "either" | undefined
1953
1953
  readonly concurrentFinalizers?: boolean | undefined
1954
- }
1954
+ }, O>
1955
1955
  >(
1956
1956
  arg: Arg,
1957
1957
  options?: O
@@ -1974,13 +1974,13 @@ export const all = <
1974
1974
 
1975
1975
  /* @internal */
1976
1976
  export const allWith = <
1977
- O extends {
1977
+ O extends NoExcessProperties<{
1978
1978
  readonly concurrency?: Concurrency | undefined
1979
1979
  readonly batching?: boolean | "inherit" | undefined
1980
1980
  readonly discard?: boolean | undefined
1981
1981
  readonly mode?: "default" | "validate" | "either" | undefined
1982
1982
  readonly concurrentFinalizers?: boolean | undefined
1983
- }
1983
+ }, O>
1984
1984
  >(options?: O) =>
1985
1985
  <const Arg extends Iterable<Effect.Effect<any, any, any>> | Record<string, Effect.Effect<any, any, any>>>(
1986
1986
  arg: Arg
@@ -321,38 +321,47 @@ export const whenAnd = <
321
321
  }
322
322
 
323
323
  /** @internal */
324
- export const discriminator =
325
- <D extends string>(field: D) =>
326
- <R, P extends Types.Tags<D, R> & string, Ret, B extends Ret>(
327
- ...pattern: [
328
- first: P,
329
- ...values: Array<P>,
330
- f: (_: Extract<R, Record<D, P>>) => B
331
- ]
332
- ) => {
333
- const f = pattern[pattern.length - 1]
334
- const values: Array<P> = pattern.slice(0, -1) as any
335
- const pred = values.length === 1
336
- ? (_: any) => _[field] === values[0]
337
- : (_: any) => values.includes(_[field])
338
-
339
- return <I, F, A, Pr>(
340
- self: Matcher<I, F, R, A, Pr, Ret>
341
- ): Matcher<
342
- I,
343
- Types.AddWithout<F, Extract<R, Record<D, P>>>,
344
- Types.ApplyFilters<I, Types.AddWithout<F, Extract<R, Record<D, P>>>>,
345
- A | B,
346
- Pr,
347
- Ret
348
- > => (self as any).add(makeWhen(pred, f as any)) as any
349
- }
324
+ export const discriminator = <D extends string>(field: D) =>
325
+ <
326
+ R,
327
+ P extends Types.Tags<D, R> & string,
328
+ Ret,
329
+ Fn extends (_: Extract<R, Record<D, P>>) => Ret
330
+ >(
331
+ ...pattern: [
332
+ first: P,
333
+ ...values: Array<P>,
334
+ f: Fn
335
+ ]
336
+ ) => {
337
+ const f = pattern[pattern.length - 1]
338
+ const values: Array<P> = pattern.slice(0, -1) as any
339
+ const pred = values.length === 1
340
+ ? (_: any) => _[field] === values[0]
341
+ : (_: any) => values.includes(_[field])
342
+
343
+ return <I, F, A, Pr>(
344
+ self: Matcher<I, F, R, A, Pr, Ret>
345
+ ): Matcher<
346
+ I,
347
+ Types.AddWithout<F, Extract<R, Record<D, P>>>,
348
+ Types.ApplyFilters<I, Types.AddWithout<F, Extract<R, Record<D, P>>>>,
349
+ A | ReturnType<Fn>,
350
+ Pr,
351
+ Ret
352
+ > => (self as any).add(makeWhen(pred, f as any)) as any
353
+ }
350
354
 
351
355
  /** @internal */
352
356
  export const discriminatorStartsWith = <D extends string>(field: D) =>
353
- <R, P extends string, Ret, B extends Ret>(
357
+ <
358
+ R,
359
+ P extends string,
360
+ Ret,
361
+ Fn extends (_: Extract<R, Record<D, `${P}${string}`>>) => Ret
362
+ >(
354
363
  pattern: P,
355
- f: (_: Extract<R, Record<D, `${P}${string}`>>) => B
364
+ f: Fn
356
365
  ) => {
357
366
  const pred = (_: any) => typeof _[field] === "string" && _[field].startsWith(pattern)
358
367
 
@@ -365,7 +374,7 @@ export const discriminatorStartsWith = <D extends string>(field: D) =>
365
374
  I,
366
375
  Types.AddWithout<F, Extract<R, Record<D, `${P}${string}`>>>
367
376
  >,
368
- A | B,
377
+ A | ReturnType<Fn>,
369
378
  Pr,
370
379
  Ret
371
380
  > => (self as any).add(makeWhen(pred, f as any)) as any
@@ -427,11 +436,16 @@ export const discriminatorsExhaustive: <D extends string>(
427
436
  }
428
437
 
429
438
  /** @internal */
430
- export const tag: <R, P extends Types.Tags<"_tag", R> & string, Ret, B extends Ret>(
439
+ export const tag: <
440
+ R,
441
+ P extends Types.Tags<"_tag", R> & string,
442
+ Ret,
443
+ Fn extends (_: Extract<R, Record<"_tag", P>>) => Ret
444
+ >(
431
445
  ...pattern: [
432
446
  first: P,
433
447
  ...values: Array<P>,
434
- f: (_: Extract<R, Record<"_tag", P>>) => B
448
+ f: Fn
435
449
  ]
436
450
  ) => <I, F, A, Pr>(
437
451
  self: Matcher<I, F, R, A, Pr, Ret>
@@ -439,7 +453,7 @@ export const tag: <R, P extends Types.Tags<"_tag", R> & string, Ret, B extends R
439
453
  I,
440
454
  Types.AddWithout<F, Extract<R, Record<"_tag", P>>>,
441
455
  Types.ApplyFilters<I, Types.AddWithout<F, Extract<R, Record<"_tag", P>>>>,
442
- B | A,
456
+ ReturnType<Fn> | A,
443
457
  Pr,
444
458
  Ret
445
459
  > = discriminator("_tag")
@@ -1810,14 +1810,14 @@ export const repeat_Effect = dual<
1810
1810
 
1811
1811
  /** @internal */
1812
1812
  export const repeat_combined = dual<{
1813
- <O extends Effect.Repeat.Options<A>, A>(
1813
+ <O extends Types.NoExcessProperties<Effect.Repeat.Options<A>, O>, A>(
1814
1814
  options: O
1815
1815
  ): <E, R>(self: Effect.Effect<A, E, R>) => Effect.Repeat.Return<R, E, A, O>
1816
1816
  <B, A, R1>(
1817
1817
  schedule: Schedule.Schedule<B, A, R1>
1818
1818
  ): <E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<B, E, R | R1>
1819
1819
  }, {
1820
- <A, E, R, O extends Effect.Repeat.Options<A>>(
1820
+ <A, E, R, O extends Types.NoExcessProperties<Effect.Repeat.Options<A>, O>>(
1821
1821
  self: Effect.Effect<A, E, R>,
1822
1822
  options: O
1823
1823
  ): Effect.Repeat.Return<R, E, A, O>
@@ -1907,7 +1907,7 @@ export const retry_Effect = dual<
1907
1907
 
1908
1908
  /** @internal */
1909
1909
  export const retry_combined: {
1910
- <E, O extends Effect.Retry.Options<E>>(
1910
+ <E, O extends Types.NoExcessProperties<Effect.Retry.Options<E>, O>>(
1911
1911
  options: O
1912
1912
  ): <A, R>(
1913
1913
  self: Effect.Effect<A, E, R>
@@ -1915,7 +1915,7 @@ export const retry_combined: {
1915
1915
  <B, E, R1>(
1916
1916
  policy: Schedule.Schedule<B, Types.NoInfer<E>, R1>
1917
1917
  ): <A, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R1 | R>
1918
- <A, E, R, O extends Effect.Retry.Options<E>>(
1918
+ <A, E, R, O extends Types.NoExcessProperties<Effect.Retry.Options<E>, O>>(
1919
1919
  self: Effect.Effect<A, E, R>,
1920
1920
  options: O
1921
1921
  ): Effect.Retry.Return<R, E, A, O>
@@ -1,4 +1,4 @@
1
- let moduleVersion = "3.13.4"
1
+ let moduleVersion = "3.13.7"
2
2
 
3
3
  export const getCurrentVersion = () => moduleVersion
4
4