effect 3.12.7 → 3.12.8
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.
- package/dist/cjs/BigDecimal.js +1 -1
- package/dist/cjs/BigDecimal.js.map +1 -1
- package/dist/cjs/Cause.js +630 -167
- package/dist/cjs/Cause.js.map +1 -1
- package/dist/cjs/Chunk.js +4 -8
- package/dist/cjs/Chunk.js.map +1 -1
- package/dist/cjs/ConfigProvider.js +1 -0
- package/dist/cjs/ConfigProvider.js.map +1 -1
- package/dist/cjs/Cron.js +26 -10
- package/dist/cjs/Cron.js.map +1 -1
- package/dist/cjs/Duration.js +7 -4
- package/dist/cjs/Duration.js.map +1 -1
- package/dist/cjs/Effect.js.map +1 -1
- package/dist/cjs/Either.js +5 -24
- package/dist/cjs/Either.js.map +1 -1
- package/dist/cjs/Layer.js.map +1 -1
- package/dist/cjs/Option.js +1042 -363
- package/dist/cjs/Option.js.map +1 -1
- package/dist/cjs/ParseResult.js +41 -18
- package/dist/cjs/ParseResult.js.map +1 -1
- package/dist/cjs/Schedule.js +8 -1
- package/dist/cjs/Schedule.js.map +1 -1
- package/dist/cjs/Schema.js +51 -10
- package/dist/cjs/Schema.js.map +1 -1
- package/dist/cjs/internal/cause.js +23 -108
- package/dist/cjs/internal/cause.js.map +1 -1
- package/dist/cjs/internal/core.js +4 -5
- package/dist/cjs/internal/core.js.map +1 -1
- package/dist/cjs/internal/layer.js.map +1 -1
- package/dist/cjs/internal/schedule.js.map +1 -1
- package/dist/cjs/internal/secret.js +6 -5
- package/dist/cjs/internal/secret.js.map +1 -1
- package/dist/cjs/internal/stream.js +21 -23
- package/dist/cjs/internal/stream.js.map +1 -1
- package/dist/cjs/internal/version.js +1 -1
- package/dist/dts/BigDecimal.d.ts.map +1 -1
- package/dist/dts/Cause.d.ts +1157 -304
- package/dist/dts/Cause.d.ts.map +1 -1
- package/dist/dts/Chunk.d.ts +3 -6
- package/dist/dts/Chunk.d.ts.map +1 -1
- package/dist/dts/ConfigProvider.d.ts.map +1 -1
- package/dist/dts/Cron.d.ts +25 -9
- package/dist/dts/Cron.d.ts.map +1 -1
- package/dist/dts/Duration.d.ts +1 -1
- package/dist/dts/Duration.d.ts.map +1 -1
- package/dist/dts/Effect.d.ts +3 -2
- package/dist/dts/Effect.d.ts.map +1 -1
- package/dist/dts/Either.d.ts.map +1 -1
- package/dist/dts/Layer.d.ts +1 -1
- package/dist/dts/Layer.d.ts.map +1 -1
- package/dist/dts/Option.d.ts +2288 -784
- package/dist/dts/Option.d.ts.map +1 -1
- package/dist/dts/ParseResult.d.ts +4 -4
- package/dist/dts/ParseResult.d.ts.map +1 -1
- package/dist/dts/Schedule.d.ts +7 -0
- package/dist/dts/Schedule.d.ts.map +1 -1
- package/dist/dts/Schema.d.ts +15 -4
- package/dist/dts/Schema.d.ts.map +1 -1
- package/dist/dts/internal/core.d.ts.map +1 -1
- package/dist/dts/internal/stream.d.ts +1 -1
- package/dist/dts/internal/stream.d.ts.map +1 -1
- package/dist/esm/BigDecimal.js +1 -1
- package/dist/esm/BigDecimal.js.map +1 -1
- package/dist/esm/Cause.js +630 -167
- package/dist/esm/Cause.js.map +1 -1
- package/dist/esm/Chunk.js +4 -8
- package/dist/esm/Chunk.js.map +1 -1
- package/dist/esm/ConfigProvider.js +1 -0
- package/dist/esm/ConfigProvider.js.map +1 -1
- package/dist/esm/Cron.js +27 -11
- package/dist/esm/Cron.js.map +1 -1
- package/dist/esm/Duration.js +7 -4
- package/dist/esm/Duration.js.map +1 -1
- package/dist/esm/Effect.js.map +1 -1
- package/dist/esm/Either.js +5 -24
- package/dist/esm/Either.js.map +1 -1
- package/dist/esm/Layer.js.map +1 -1
- package/dist/esm/Option.js +1041 -363
- package/dist/esm/Option.js.map +1 -1
- package/dist/esm/ParseResult.js +41 -18
- package/dist/esm/ParseResult.js.map +1 -1
- package/dist/esm/Schedule.js +7 -0
- package/dist/esm/Schedule.js.map +1 -1
- package/dist/esm/Schema.js +51 -10
- package/dist/esm/Schema.js.map +1 -1
- package/dist/esm/internal/cause.js +22 -108
- package/dist/esm/internal/cause.js.map +1 -1
- package/dist/esm/internal/core.js +4 -5
- package/dist/esm/internal/core.js.map +1 -1
- package/dist/esm/internal/layer.js.map +1 -1
- package/dist/esm/internal/schedule.js.map +1 -1
- package/dist/esm/internal/secret.js +5 -4
- package/dist/esm/internal/secret.js.map +1 -1
- package/dist/esm/internal/stream.js +21 -23
- package/dist/esm/internal/stream.js.map +1 -1
- package/dist/esm/internal/version.js +1 -1
- package/package.json +1 -1
- package/src/BigDecimal.ts +1 -1
- package/src/Cause.ts +1158 -304
- package/src/Chunk.ts +8 -11
- package/src/ConfigProvider.ts +1 -0
- package/src/Cron.ts +28 -11
- package/src/Duration.ts +10 -5
- package/src/Effect.ts +5 -2
- package/src/Either.ts +11 -28
- package/src/Layer.ts +1 -1
- package/src/Option.ts +2314 -820
- package/src/ParseResult.ts +53 -29
- package/src/Schedule.ts +8 -0
- package/src/Schema.ts +68 -12
- package/src/internal/cause.ts +38 -137
- package/src/internal/core.ts +4 -5
- package/src/internal/layer.ts +1 -1
- package/src/internal/schedule.ts +7 -6
- package/src/internal/secret.ts +6 -4
- package/src/internal/stream.ts +24 -37
- package/src/internal/version.ts +1 -1
package/src/Chunk.ts
CHANGED
|
@@ -242,9 +242,8 @@ export const empty: <A = never>() => Chunk<A> = () => _empty
|
|
|
242
242
|
* @category constructors
|
|
243
243
|
* @since 2.0.0
|
|
244
244
|
*/
|
|
245
|
-
export const make = <As extends readonly [any, ...ReadonlyArray<any>]>(
|
|
246
|
-
|
|
247
|
-
): NonEmptyChunk<As[number]> => as.length === 1 ? of(as[0]) : unsafeFromNonEmptyArray(as)
|
|
245
|
+
export const make = <As extends readonly [any, ...ReadonlyArray<any>]>(...as: As): NonEmptyChunk<As[number]> =>
|
|
246
|
+
unsafeFromNonEmptyArray(as)
|
|
248
247
|
|
|
249
248
|
/**
|
|
250
249
|
* Builds a `NonEmptyChunk` from a single element.
|
|
@@ -261,7 +260,7 @@ export const of = <A>(a: A): NonEmptyChunk<A> => makeChunk({ _tag: "ISingleton",
|
|
|
261
260
|
* @since 2.0.0
|
|
262
261
|
*/
|
|
263
262
|
export const fromIterable = <A>(self: Iterable<A>): Chunk<A> =>
|
|
264
|
-
isChunk(self) ? self :
|
|
263
|
+
isChunk(self) ? self : unsafeFromArray(RA.fromIterable(self))
|
|
265
264
|
|
|
266
265
|
const copyToArray = <A>(self: Chunk<A>, array: Array<any>, initial: number): void => {
|
|
267
266
|
switch (self.backing._tag) {
|
|
@@ -408,7 +407,8 @@ export const get: {
|
|
|
408
407
|
* @since 2.0.0
|
|
409
408
|
* @category unsafe
|
|
410
409
|
*/
|
|
411
|
-
export const unsafeFromArray = <A>(self: ReadonlyArray<A>): Chunk<A> =>
|
|
410
|
+
export const unsafeFromArray = <A>(self: ReadonlyArray<A>): Chunk<A> =>
|
|
411
|
+
self.length === 0 ? empty() : self.length === 1 ? of(self[0]) : makeChunk({ _tag: "IArray", array: self })
|
|
412
412
|
|
|
413
413
|
/**
|
|
414
414
|
* Wraps an array into a chunk without copying, unsafe on mutable arrays
|
|
@@ -1818,22 +1818,19 @@ export const zip: {
|
|
|
1818
1818
|
)
|
|
1819
1819
|
|
|
1820
1820
|
/**
|
|
1821
|
-
* Delete the element at the specified index, creating a new `Chunk
|
|
1822
|
-
* or returning the input if the index is out of bounds.
|
|
1821
|
+
* Delete the element at the specified index, creating a new `Chunk`.
|
|
1823
1822
|
*
|
|
1824
1823
|
* @since 2.0.0
|
|
1825
1824
|
*/
|
|
1826
1825
|
export const remove: {
|
|
1827
1826
|
/**
|
|
1828
|
-
* Delete the element at the specified index, creating a new `Chunk
|
|
1829
|
-
* or returning the input if the index is out of bounds.
|
|
1827
|
+
* Delete the element at the specified index, creating a new `Chunk`.
|
|
1830
1828
|
*
|
|
1831
1829
|
* @since 2.0.0
|
|
1832
1830
|
*/
|
|
1833
1831
|
(i: number): <A>(self: Chunk<A>) => Chunk<A>
|
|
1834
1832
|
/**
|
|
1835
|
-
* Delete the element at the specified index, creating a new `Chunk
|
|
1836
|
-
* or returning the input if the index is out of bounds.
|
|
1833
|
+
* Delete the element at the specified index, creating a new `Chunk`.
|
|
1837
1834
|
*
|
|
1838
1835
|
* @since 2.0.0
|
|
1839
1836
|
*/
|
package/src/ConfigProvider.ts
CHANGED
|
@@ -195,6 +195,7 @@ export const fromFlat: (flat: ConfigProvider.Flat) => ConfigProvider = internal.
|
|
|
195
195
|
*/
|
|
196
196
|
export const fromJson: (json: unknown) => ConfigProvider = internal.fromJson
|
|
197
197
|
|
|
198
|
+
// TODO(4.0): use `_` for nested configs instead of `.` in next major
|
|
198
199
|
/**
|
|
199
200
|
* Constructs a ConfigProvider using a map and the specified delimiter string,
|
|
200
201
|
* which determines how to split the keys in the map into path segments.
|
package/src/Cron.ts
CHANGED
|
@@ -7,7 +7,7 @@ import type * as DateTime from "./DateTime.js"
|
|
|
7
7
|
import * as Either from "./Either.js"
|
|
8
8
|
import * as Equal from "./Equal.js"
|
|
9
9
|
import * as equivalence from "./Equivalence.js"
|
|
10
|
-
import { constVoid, dual, pipe } from "./Function.js"
|
|
10
|
+
import { constVoid, dual, identity, pipe } from "./Function.js"
|
|
11
11
|
import * as Hash from "./Hash.js"
|
|
12
12
|
import { format, type Inspectable, NodeInspectSymbol } from "./Inspectable.js"
|
|
13
13
|
import * as dateTime from "./internal/dateTime.js"
|
|
@@ -284,28 +284,45 @@ export const parse = (cron: string, tz?: DateTime.TimeZone | string): Either.Eit
|
|
|
284
284
|
/**
|
|
285
285
|
* Parses a cron expression into a `Cron` instance.
|
|
286
286
|
*
|
|
287
|
-
*
|
|
287
|
+
* **Details**
|
|
288
288
|
*
|
|
289
|
-
*
|
|
289
|
+
* This function takes a cron expression as a string and attempts to parse it
|
|
290
|
+
* into a `Cron` instance. If the expression is valid, the resulting `Cron`
|
|
291
|
+
* instance will represent the schedule defined by the cron expression.
|
|
292
|
+
*
|
|
293
|
+
* If the expression is invalid, the function throws a `ParseError`.
|
|
294
|
+
*
|
|
295
|
+
* You can optionally provide a time zone (`tz`) to interpret the cron
|
|
296
|
+
* expression in a specific time zone. If no time zone is provided, the cron
|
|
297
|
+
* expression will use the default time zone.
|
|
290
298
|
*
|
|
291
299
|
* @example
|
|
292
300
|
* ```ts
|
|
293
301
|
* import { Cron } from "effect"
|
|
294
302
|
*
|
|
295
303
|
* // At 04:00 on every day-of-month from 8 through 14.
|
|
296
|
-
*
|
|
297
|
-
*
|
|
298
|
-
*
|
|
299
|
-
*
|
|
300
|
-
*
|
|
301
|
-
*
|
|
302
|
-
*
|
|
304
|
+
* console.log(Cron.unsafeParse("0 4 8-14 * *"))
|
|
305
|
+
* // Output:
|
|
306
|
+
* // {
|
|
307
|
+
* // _id: 'Cron',
|
|
308
|
+
* // tz: { _id: 'Option', _tag: 'None' },
|
|
309
|
+
* // seconds: [ 0 ],
|
|
310
|
+
* // minutes: [ 0 ],
|
|
311
|
+
* // hours: [ 4 ],
|
|
312
|
+
* // days: [
|
|
313
|
+
* // 8, 9, 10, 11,
|
|
314
|
+
* // 12, 13, 14
|
|
315
|
+
* // ],
|
|
316
|
+
* // months: [],
|
|
317
|
+
* // weekdays: []
|
|
318
|
+
* // }
|
|
303
319
|
* ```
|
|
304
320
|
*
|
|
305
321
|
* @since 2.0.0
|
|
306
322
|
* @category constructors
|
|
307
323
|
*/
|
|
308
|
-
export const unsafeParse = (cron: string, tz?: DateTime.TimeZone | string): Cron =>
|
|
324
|
+
export const unsafeParse = (cron: string, tz?: DateTime.TimeZone | string): Cron =>
|
|
325
|
+
Either.getOrThrowWith(parse(cron, tz), identity)
|
|
309
326
|
|
|
310
327
|
/**
|
|
311
328
|
* Checks if a given `Date` falls within an active `Cron` time window.
|
package/src/Duration.ts
CHANGED
|
@@ -83,7 +83,7 @@ export type DurationInput =
|
|
|
83
83
|
| Duration
|
|
84
84
|
| number // millis
|
|
85
85
|
| bigint // nanos
|
|
86
|
-
| [seconds: number, nanos: number]
|
|
86
|
+
| readonly [seconds: number, nanos: number]
|
|
87
87
|
| `${number} ${Unit}`
|
|
88
88
|
|
|
89
89
|
const DURATION_REGEX = /^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/
|
|
@@ -98,12 +98,17 @@ export const decode = (input: DurationInput): Duration => {
|
|
|
98
98
|
return millis(input)
|
|
99
99
|
} else if (isBigInt(input)) {
|
|
100
100
|
return nanos(input)
|
|
101
|
-
} else if (Array.isArray(input)) {
|
|
102
|
-
if (input
|
|
103
|
-
return
|
|
101
|
+
} else if (Array.isArray(input) && input.length === 2 && input.every(isNumber)) {
|
|
102
|
+
if (input[0] === -Infinity || input[1] === -Infinity || Number.isNaN(input[0]) || Number.isNaN(input[1])) {
|
|
103
|
+
return zero
|
|
104
104
|
}
|
|
105
|
+
|
|
106
|
+
if (input[0] === Infinity || input[1] === Infinity) {
|
|
107
|
+
return infinity
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return nanos(BigInt(Math.round(input[0] * 1_000_000_000)) + BigInt(Math.round(input[1])))
|
|
105
111
|
} else if (isString(input)) {
|
|
106
|
-
DURATION_REGEX.lastIndex = 0 // Reset the lastIndex before each use
|
|
107
112
|
const match = DURATION_REGEX.exec(input)
|
|
108
113
|
if (match) {
|
|
109
114
|
const [_, valueStr, unit] = match
|
package/src/Effect.ts
CHANGED
|
@@ -21641,7 +21641,9 @@ export const schedule: {
|
|
|
21641
21641
|
* @since 2.0.0
|
|
21642
21642
|
* @category Repetition / Recursion
|
|
21643
21643
|
*/
|
|
21644
|
-
<
|
|
21644
|
+
<A, R2, Out>(
|
|
21645
|
+
schedule: Schedule.Schedule<Out, NoInfer<A> | undefined, R2>
|
|
21646
|
+
): <E, R>(self: Effect<A, E, R>) => Effect<Out, E, R2 | R>
|
|
21645
21647
|
/**
|
|
21646
21648
|
* Repeats an effect based on a specified schedule.
|
|
21647
21649
|
*
|
|
@@ -21664,7 +21666,7 @@ export const schedule: {
|
|
|
21664
21666
|
* @since 2.0.0
|
|
21665
21667
|
* @category Repetition / Recursion
|
|
21666
21668
|
*/
|
|
21667
|
-
<A, E, R, R2, Out>(self: Effect<A, E, R>, schedule: Schedule.Schedule<Out,
|
|
21669
|
+
<A, E, R, R2, Out>(self: Effect<A, E, R>, schedule: Schedule.Schedule<Out, A | undefined, R2>): Effect<Out, E, R | R2>
|
|
21668
21670
|
} = schedule_.schedule_Effect
|
|
21669
21671
|
|
|
21670
21672
|
/**
|
|
@@ -24422,6 +24424,7 @@ export interface Semaphore {
|
|
|
24422
24424
|
/**
|
|
24423
24425
|
* Acquires the specified number of permits and returns the resulting
|
|
24424
24426
|
* available permits, suspending the task if they are not yet available.
|
|
24427
|
+
* Concurrent pending `take` calls are processed in a first-in, first-out manner.
|
|
24425
24428
|
*/
|
|
24426
24429
|
take(permits: number): Effect<number>
|
|
24427
24430
|
|
package/src/Either.ts
CHANGED
|
@@ -35,6 +35,7 @@ export const TypeId: unique symbol = either.TypeId
|
|
|
35
35
|
*/
|
|
36
36
|
export type TypeId = typeof TypeId
|
|
37
37
|
|
|
38
|
+
// TODO(4.0): flip the order of the type parameters
|
|
38
39
|
/**
|
|
39
40
|
* @category models
|
|
40
41
|
* @since 2.0.0
|
|
@@ -52,6 +53,7 @@ export interface Left<out L, out R> extends Pipeable, Inspectable {
|
|
|
52
53
|
[Unify.ignoreSymbol]?: EitherUnifyIgnore
|
|
53
54
|
}
|
|
54
55
|
|
|
56
|
+
// TODO(4.0): flip the order of the type parameters
|
|
55
57
|
/**
|
|
56
58
|
* @category models
|
|
57
59
|
* @since 2.0.0
|
|
@@ -1054,6 +1056,7 @@ export const getOrThrowWith: {
|
|
|
1054
1056
|
throw onLeft(self.left)
|
|
1055
1057
|
})
|
|
1056
1058
|
|
|
1059
|
+
// TODO(4.0): by default should throw `L` (i.e getOrThrowWith with the identity function)
|
|
1057
1060
|
/**
|
|
1058
1061
|
* Extracts the value of an `Either` or throws if the `Either` is `Left`.
|
|
1059
1062
|
*
|
|
@@ -1321,39 +1324,19 @@ const adapter = Gen.adapter<EitherTypeLambda>()
|
|
|
1321
1324
|
* @since 2.0.0
|
|
1322
1325
|
*/
|
|
1323
1326
|
export const gen: Gen.Gen<EitherTypeLambda, Gen.Adapter<EitherTypeLambda>> = (...args) => {
|
|
1324
|
-
const f =
|
|
1325
|
-
? args[0]
|
|
1326
|
-
: args[1].bind(args[0])
|
|
1327
|
+
const f = args.length === 1 ? args[0] : args[1].bind(args[0])
|
|
1327
1328
|
const iterator = f(adapter)
|
|
1328
|
-
let state:
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
if (Gen.isGenKind(current)) {
|
|
1334
|
-
current = current.value
|
|
1335
|
-
} else {
|
|
1336
|
-
current = Gen.yieldWrapGet(current)
|
|
1337
|
-
}
|
|
1329
|
+
let state: IteratorResult<any> = iterator.next()
|
|
1330
|
+
while (!state.done) {
|
|
1331
|
+
const current = Gen.isGenKind(state.value)
|
|
1332
|
+
? state.value.value
|
|
1333
|
+
: Gen.yieldWrapGet(state.value)
|
|
1338
1334
|
if (isLeft(current)) {
|
|
1339
1335
|
return current
|
|
1340
1336
|
}
|
|
1341
|
-
|
|
1342
|
-
state = iterator.next(current.right as never)
|
|
1343
|
-
if (!state.done) {
|
|
1344
|
-
current = state.value
|
|
1345
|
-
if (Gen.isGenKind(current)) {
|
|
1346
|
-
current = current.value
|
|
1347
|
-
} else {
|
|
1348
|
-
current = Gen.yieldWrapGet(current)
|
|
1349
|
-
}
|
|
1350
|
-
if (isLeft(current)) {
|
|
1351
|
-
return current
|
|
1352
|
-
}
|
|
1353
|
-
}
|
|
1354
|
-
}
|
|
1355
|
-
return right(state.value)
|
|
1337
|
+
state = iterator.next(current.right as never)
|
|
1356
1338
|
}
|
|
1339
|
+
return right(state.value) as any
|
|
1357
1340
|
}
|
|
1358
1341
|
|
|
1359
1342
|
// -------------------------------------------------------------------------------------
|
package/src/Layer.ts
CHANGED
|
@@ -888,7 +888,7 @@ export const retry: {
|
|
|
888
888
|
* @since 2.0.0
|
|
889
889
|
* @category constructors
|
|
890
890
|
*/
|
|
891
|
-
export const scope: Layer<Scope.
|
|
891
|
+
export const scope: Layer<Scope.Scope> = internal.scope
|
|
892
892
|
|
|
893
893
|
/**
|
|
894
894
|
* Constructs a layer from the specified scoped effect.
|