effect 3.2.9 → 3.3.1
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/Redacted/package.json +6 -0
- package/dist/cjs/Chunk.js +16 -6
- package/dist/cjs/Chunk.js.map +1 -1
- package/dist/cjs/Config.js +9 -1
- package/dist/cjs/Config.js.map +1 -1
- package/dist/cjs/Either.js +3 -2
- package/dist/cjs/Either.js.map +1 -1
- package/dist/cjs/Iterable.js +15 -2
- package/dist/cjs/Iterable.js.map +1 -1
- package/dist/cjs/Layer.js +11 -1
- package/dist/cjs/Layer.js.map +1 -1
- package/dist/cjs/Option.js +8 -2
- package/dist/cjs/Option.js.map +1 -1
- package/dist/cjs/Pool.js +26 -0
- package/dist/cjs/Pool.js.map +1 -1
- package/dist/cjs/Predicate.js +92 -2
- package/dist/cjs/Predicate.js.map +1 -1
- package/dist/cjs/Redacted.js +114 -0
- package/dist/cjs/Redacted.js.map +1 -0
- package/dist/cjs/STM.js.map +1 -1
- package/dist/cjs/Secret.js +7 -0
- package/dist/cjs/Secret.js.map +1 -1
- package/dist/cjs/Stream.js +32 -1
- package/dist/cjs/Stream.js.map +1 -1
- package/dist/cjs/Struct.js.map +1 -1
- package/dist/cjs/Tuple.js +15 -1
- package/dist/cjs/Tuple.js.map +1 -1
- package/dist/cjs/Utils.js.map +1 -1
- package/dist/cjs/index.js +4 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/internal/config.js +9 -2
- package/dist/cjs/internal/config.js.map +1 -1
- package/dist/cjs/internal/layer.js +14 -2
- package/dist/cjs/internal/layer.js.map +1 -1
- package/dist/cjs/internal/pool.js +206 -235
- package/dist/cjs/internal/pool.js.map +1 -1
- package/dist/cjs/internal/redacted.js +87 -0
- package/dist/cjs/internal/redacted.js.map +1 -0
- package/dist/cjs/internal/secret.js +40 -23
- package/dist/cjs/internal/secret.js.map +1 -1
- package/dist/cjs/internal/stm/stm.js +2 -1
- package/dist/cjs/internal/stm/stm.js.map +1 -1
- package/dist/cjs/internal/stream.js +15 -7
- package/dist/cjs/internal/stream.js.map +1 -1
- package/dist/cjs/internal/version.js +1 -1
- package/dist/dts/Chunk.d.ts +11 -1
- package/dist/dts/Chunk.d.ts.map +1 -1
- package/dist/dts/Config.d.ts +10 -1
- package/dist/dts/Config.d.ts.map +1 -1
- package/dist/dts/Either.d.ts.map +1 -1
- package/dist/dts/Iterable.d.ts +7 -0
- package/dist/dts/Iterable.d.ts.map +1 -1
- package/dist/dts/Layer.d.ts +20 -0
- package/dist/dts/Layer.d.ts.map +1 -1
- package/dist/dts/Option.d.ts.map +1 -1
- package/dist/dts/Pool.d.ts +31 -0
- package/dist/dts/Pool.d.ts.map +1 -1
- package/dist/dts/Predicate.d.ts +99 -2
- package/dist/dts/Predicate.d.ts.map +1 -1
- package/dist/dts/Redacted.d.ts +122 -0
- package/dist/dts/Redacted.d.ts.map +1 -0
- package/dist/dts/STM.d.ts +4 -1
- package/dist/dts/STM.d.ts.map +1 -1
- package/dist/dts/Secret.d.ts +14 -1
- package/dist/dts/Secret.d.ts.map +1 -1
- package/dist/dts/Stream.d.ts +61 -4
- package/dist/dts/Stream.d.ts.map +1 -1
- package/dist/dts/Struct.d.ts +7 -7
- package/dist/dts/Struct.d.ts.map +1 -1
- package/dist/dts/Tuple.d.ts +51 -0
- package/dist/dts/Tuple.d.ts.map +1 -1
- package/dist/dts/Types.d.ts +46 -0
- package/dist/dts/Types.d.ts.map +1 -1
- package/dist/dts/Utils.d.ts +6 -5
- package/dist/dts/Utils.d.ts.map +1 -1
- package/dist/dts/index.d.ts +10 -0
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/dts/internal/layer.d.ts +15 -1
- package/dist/dts/internal/layer.d.ts.map +1 -1
- package/dist/dts/internal/redacted.d.ts +2 -0
- package/dist/dts/internal/redacted.d.ts.map +1 -0
- package/dist/dts/internal/stm/stm.d.ts.map +1 -1
- package/dist/dts/internal/stream.d.ts +1 -0
- package/dist/dts/internal/stream.d.ts.map +1 -1
- package/dist/esm/Chunk.js +16 -5
- package/dist/esm/Chunk.js.map +1 -1
- package/dist/esm/Config.js +8 -0
- package/dist/esm/Config.js.map +1 -1
- package/dist/esm/Either.js +3 -2
- package/dist/esm/Either.js.map +1 -1
- package/dist/esm/Iterable.js +12 -0
- package/dist/esm/Iterable.js.map +1 -1
- package/dist/esm/Layer.js +10 -0
- package/dist/esm/Layer.js.map +1 -1
- package/dist/esm/Option.js +8 -2
- package/dist/esm/Option.js.map +1 -1
- package/dist/esm/Pool.js +26 -0
- package/dist/esm/Pool.js.map +1 -1
- package/dist/esm/Predicate.js +91 -1
- package/dist/esm/Predicate.js.map +1 -1
- package/dist/esm/Redacted.js +82 -0
- package/dist/esm/Redacted.js.map +1 -0
- package/dist/esm/STM.js.map +1 -1
- package/dist/esm/Secret.js +7 -0
- package/dist/esm/Secret.js.map +1 -1
- package/dist/esm/Stream.js +31 -0
- package/dist/esm/Stream.js.map +1 -1
- package/dist/esm/Struct.js.map +1 -1
- package/dist/esm/Tuple.js +51 -0
- package/dist/esm/Tuple.js.map +1 -1
- package/dist/esm/Utils.js.map +1 -1
- package/dist/esm/index.js +10 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/internal/config.js +7 -1
- package/dist/esm/internal/config.js.map +1 -1
- package/dist/esm/internal/layer.js +12 -0
- package/dist/esm/internal/layer.js.map +1 -1
- package/dist/esm/internal/pool.js +205 -235
- package/dist/esm/internal/pool.js.map +1 -1
- package/dist/esm/internal/redacted.js +52 -0
- package/dist/esm/internal/redacted.js.map +1 -0
- package/dist/esm/internal/secret.js +39 -22
- package/dist/esm/internal/secret.js.map +1 -1
- package/dist/esm/internal/stm/stm.js +2 -1
- package/dist/esm/internal/stm/stm.js.map +1 -1
- package/dist/esm/internal/stream.js +13 -4
- package/dist/esm/internal/stream.js.map +1 -1
- package/dist/esm/internal/version.js +1 -1
- package/package.json +9 -1
- package/src/Chunk.ts +17 -5
- package/src/Config.ts +11 -1
- package/src/Either.ts +6 -4
- package/src/Iterable.ts +13 -0
- package/src/Layer.ts +22 -0
- package/src/Option.ts +8 -2
- package/src/Pool.ts +39 -6
- package/src/Predicate.ts +102 -3
- package/src/Redacted.ts +133 -0
- package/src/STM.ts +7 -2
- package/src/Secret.ts +14 -1
- package/src/Stream.ts +67 -7
- package/src/Struct.ts +8 -13
- package/src/Tuple.ts +53 -0
- package/src/Types.ts +48 -0
- package/src/Utils.ts +9 -6
- package/src/index.ts +11 -0
- package/src/internal/config.ts +13 -2
- package/src/internal/layer.ts +63 -0
- package/src/internal/pool.ts +320 -447
- package/src/internal/redacted.ts +69 -0
- package/src/internal/secret.ts +39 -28
- package/src/internal/stm/stm.ts +4 -1
- package/src/internal/stream.ts +111 -50
- package/src/internal/version.ts +1 -1
package/src/Stream.ts
CHANGED
|
@@ -3860,7 +3860,17 @@ export const toQueueOfElements: {
|
|
|
3860
3860
|
* @since 2.0.0
|
|
3861
3861
|
* @category destructors
|
|
3862
3862
|
*/
|
|
3863
|
-
export const toReadableStream:
|
|
3863
|
+
export const toReadableStream: {
|
|
3864
|
+
<A>(
|
|
3865
|
+
options?: { readonly strategy?: QueuingStrategy<A> | undefined }
|
|
3866
|
+
): <E>(
|
|
3867
|
+
self: Stream<A, E>
|
|
3868
|
+
) => ReadableStream<A>
|
|
3869
|
+
<A, E>(
|
|
3870
|
+
self: Stream<A, E>,
|
|
3871
|
+
options?: { readonly strategy?: QueuingStrategy<A> | undefined }
|
|
3872
|
+
): ReadableStream<A>
|
|
3873
|
+
} = internal.toReadableStream
|
|
3864
3874
|
|
|
3865
3875
|
/**
|
|
3866
3876
|
* Converts the stream to a `Effect<ReadableStream>`.
|
|
@@ -3870,8 +3880,17 @@ export const toReadableStream: <A, E>(self: Stream<A, E>) => ReadableStream<A> =
|
|
|
3870
3880
|
* @since 2.0.0
|
|
3871
3881
|
* @category destructors
|
|
3872
3882
|
*/
|
|
3873
|
-
export const toReadableStreamEffect:
|
|
3874
|
-
|
|
3883
|
+
export const toReadableStreamEffect: {
|
|
3884
|
+
<A>(
|
|
3885
|
+
options?: { readonly strategy?: QueuingStrategy<A> | undefined }
|
|
3886
|
+
): <E, R>(
|
|
3887
|
+
self: Stream<A, E, R>
|
|
3888
|
+
) => Effect.Effect<ReadableStream<A>, never, R>
|
|
3889
|
+
<A, E, R>(
|
|
3890
|
+
self: Stream<A, E, R>,
|
|
3891
|
+
options?: { readonly strategy?: QueuingStrategy<A> | undefined }
|
|
3892
|
+
): Effect.Effect<ReadableStream<A>, never, R>
|
|
3893
|
+
} = internal.toReadableStreamEffect
|
|
3875
3894
|
|
|
3876
3895
|
/**
|
|
3877
3896
|
* Converts the stream to a `ReadableStream` using the provided runtime.
|
|
@@ -3882,12 +3901,14 @@ export const toReadableStreamEffect: <A, E, R>(self: Stream<A, E, R>) => Effect.
|
|
|
3882
3901
|
* @category destructors
|
|
3883
3902
|
*/
|
|
3884
3903
|
export const toReadableStreamRuntime: {
|
|
3885
|
-
<XR>(
|
|
3886
|
-
runtime: Runtime<XR
|
|
3887
|
-
|
|
3904
|
+
<A, XR>(
|
|
3905
|
+
runtime: Runtime<XR>,
|
|
3906
|
+
options?: { readonly strategy?: QueuingStrategy<A> | undefined }
|
|
3907
|
+
): <E, R extends XR>(self: Stream<A, E, R>) => ReadableStream<A>
|
|
3888
3908
|
<A, E, XR, R extends XR>(
|
|
3889
3909
|
self: Stream<A, E, R>,
|
|
3890
|
-
runtime: Runtime<XR
|
|
3910
|
+
runtime: Runtime<XR>,
|
|
3911
|
+
options?: { readonly strategy?: QueuingStrategy<A> | undefined }
|
|
3891
3912
|
): ReadableStream<A>
|
|
3892
3913
|
} = internal.toReadableStreamRuntime
|
|
3893
3914
|
|
|
@@ -4329,6 +4350,45 @@ export const zipLatest: {
|
|
|
4329
4350
|
<A, E, R, A2, E2, R2>(self: Stream<A, E, R>, that: Stream<A2, E2, R2>): Stream<[A, A2], E | E2, R | R2>
|
|
4330
4351
|
} = internal.zipLatest
|
|
4331
4352
|
|
|
4353
|
+
/**
|
|
4354
|
+
* Zips multiple streams so that when a value is emitted by any of the streams,
|
|
4355
|
+
* it is combined with the latest values from the other streams to produce a result.
|
|
4356
|
+
*
|
|
4357
|
+
* Note: tracking the latest value is done on a per-chunk basis. That means
|
|
4358
|
+
* that emitted elements that are not the last value in chunks will never be
|
|
4359
|
+
* used for zipping.
|
|
4360
|
+
*
|
|
4361
|
+
* @example
|
|
4362
|
+
* import { Stream, Schedule, Console, Effect } from "effect"
|
|
4363
|
+
*
|
|
4364
|
+
* const stream = Stream.zipLatestAll(
|
|
4365
|
+
* Stream.fromSchedule(Schedule.spaced('1 millis')),
|
|
4366
|
+
* Stream.fromSchedule(Schedule.spaced('2 millis')),
|
|
4367
|
+
* Stream.fromSchedule(Schedule.spaced('4 millis')),
|
|
4368
|
+
* ).pipe(Stream.take(6), Stream.tap(Console.log))
|
|
4369
|
+
*
|
|
4370
|
+
* Effect.runPromise(Stream.runDrain(stream))
|
|
4371
|
+
* // Output:
|
|
4372
|
+
* // [ 0, 0, 0 ]
|
|
4373
|
+
* // [ 1, 0, 0 ]
|
|
4374
|
+
* // [ 1, 1, 0 ]
|
|
4375
|
+
* // [ 2, 1, 0 ]
|
|
4376
|
+
* // [ 3, 1, 0 ]
|
|
4377
|
+
* // [ 3, 1, 1 ]
|
|
4378
|
+
* // .....
|
|
4379
|
+
*
|
|
4380
|
+
* @since 3.3.0
|
|
4381
|
+
* @category zipping
|
|
4382
|
+
*/
|
|
4383
|
+
export const zipLatestAll: <T extends ReadonlyArray<Stream<any, any, any>>>(
|
|
4384
|
+
...streams: T
|
|
4385
|
+
) => Stream<
|
|
4386
|
+
[T[number]] extends [never] ? never
|
|
4387
|
+
: { [K in keyof T]: T[K] extends Stream<infer A, infer _E, infer _R> ? A : never },
|
|
4388
|
+
[T[number]] extends [never] ? never : T[number] extends Stream<infer _A, infer _E, infer _R> ? _E : never,
|
|
4389
|
+
[T[number]] extends [never] ? never : T[number] extends Stream<infer _A, infer _E, infer _R> ? _R : never
|
|
4390
|
+
> = internal.zipLatestAll
|
|
4391
|
+
|
|
4332
4392
|
/**
|
|
4333
4393
|
* Zips the two streams so that when a value is emitted by either of the two
|
|
4334
4394
|
* streams, it is combined with the latest value from the other stream to
|
package/src/Struct.ts
CHANGED
|
@@ -119,14 +119,14 @@ export const getOrder: <R extends { readonly [x: string]: order.Order<any> }>(
|
|
|
119
119
|
fields: R
|
|
120
120
|
) => order.Order<{ [K in keyof R]: [R[K]] extends [order.Order<infer A>] ? A : never }> = order.struct
|
|
121
121
|
|
|
122
|
-
type
|
|
123
|
-
|
|
124
|
-
type Transformed<O, T extends PartialTransform<O>> =
|
|
122
|
+
type Transformed<O, T> =
|
|
125
123
|
& unknown
|
|
126
124
|
& {
|
|
127
|
-
[K in keyof O]: K extends keyof T ? T[K] extends (...a: any) => any ? ReturnType<T[K]> : O[K] : O[K]
|
|
125
|
+
[K in keyof O]: K extends keyof T ? (T[K] extends (...a: any) => any ? ReturnType<T[K]> : O[K]) : O[K]
|
|
128
126
|
}
|
|
129
|
-
|
|
127
|
+
type PartialTransform<O, T> = {
|
|
128
|
+
[K in keyof T]: T[K] extends (a: O[K & keyof O]) => any ? T[K] : (a: O[K & keyof O]) => unknown
|
|
129
|
+
}
|
|
130
130
|
/**
|
|
131
131
|
* Transforms the values of a Struct provided a transformation function for each key.
|
|
132
132
|
* If no transformation function is provided for a key, it will return the origional value for that key.
|
|
@@ -148,16 +148,11 @@ type Transformed<O, T extends PartialTransform<O>> =
|
|
|
148
148
|
* @since 2.0.0
|
|
149
149
|
*/
|
|
150
150
|
export const evolve: {
|
|
151
|
-
<O, T
|
|
152
|
-
|
|
153
|
-
) => Transformed<O, T>
|
|
154
|
-
<O, T extends PartialTransform<O>>(obj: O, t: T): Transformed<O, T>
|
|
151
|
+
<O, T>(t: PartialTransform<O, T>): (obj: O) => Transformed<O, T>
|
|
152
|
+
<O, T>(obj: O, t: PartialTransform<O, T>): Transformed<O, T>
|
|
155
153
|
} = dual(
|
|
156
154
|
2,
|
|
157
|
-
<O, T
|
|
158
|
-
obj: O,
|
|
159
|
-
t: T
|
|
160
|
-
): unknown & Transformed<O, T> => {
|
|
155
|
+
<O, T>(obj: O, t: PartialTransform<O, T>): Transformed<O, T> => {
|
|
161
156
|
const out = { ...obj }
|
|
162
157
|
for (const k in t) {
|
|
163
158
|
if (Object.prototype.hasOwnProperty.call(obj, k)) {
|
package/src/Tuple.ts
CHANGED
|
@@ -202,3 +202,56 @@ export const appendElement: {
|
|
|
202
202
|
- swap
|
|
203
203
|
|
|
204
204
|
*/
|
|
205
|
+
|
|
206
|
+
export {
|
|
207
|
+
/**
|
|
208
|
+
* Determine if an `Array` is a tuple with exactly `N` elements, narrowing down the type to `TupleOf`.
|
|
209
|
+
*
|
|
210
|
+
* An `Array` is considered to be a `TupleOf` if its length is exactly `N`.
|
|
211
|
+
*
|
|
212
|
+
* @param self - The `Array` to check.
|
|
213
|
+
* @param n - The exact number of elements that the `Array` should have to be considered a `TupleOf`.
|
|
214
|
+
*
|
|
215
|
+
* @example
|
|
216
|
+
* import { isTupleOf } from "effect/Tuple"
|
|
217
|
+
*
|
|
218
|
+
* assert.deepStrictEqual(isTupleOf([1, 2, 3], 3), true);
|
|
219
|
+
* assert.deepStrictEqual(isTupleOf([1, 2, 3], 2), false);
|
|
220
|
+
* assert.deepStrictEqual(isTupleOf([1, 2, 3], 4), false);
|
|
221
|
+
*
|
|
222
|
+
* const arr: number[] = [1, 2, 3];
|
|
223
|
+
* if (isTupleOf(arr, 3)) {
|
|
224
|
+
* console.log(arr);
|
|
225
|
+
* // ^? [number, number, number]
|
|
226
|
+
* }
|
|
227
|
+
*
|
|
228
|
+
* @category guards
|
|
229
|
+
* @since 3.3.0
|
|
230
|
+
*/
|
|
231
|
+
isTupleOf,
|
|
232
|
+
/**
|
|
233
|
+
* Determine if an `Array` is a tuple with at least `N` elements, narrowing down the type to `TupleOfAtLeast`.
|
|
234
|
+
*
|
|
235
|
+
* An `Array` is considered to be a `TupleOfAtLeast` if its length is at least `N`.
|
|
236
|
+
*
|
|
237
|
+
* @param self - The `Array` to check.
|
|
238
|
+
* @param n - The minimum number of elements that the `Array` should have to be considered a `TupleOfAtLeast`.
|
|
239
|
+
*
|
|
240
|
+
* @example
|
|
241
|
+
* import { isTupleOfAtLeast } from "effect/Tuple"
|
|
242
|
+
*
|
|
243
|
+
* assert.deepStrictEqual(isTupleOfAtLeast([1, 2, 3], 3), true);
|
|
244
|
+
* assert.deepStrictEqual(isTupleOfAtLeast([1, 2, 3], 2), true);
|
|
245
|
+
* assert.deepStrictEqual(isTupleOfAtLeast([1, 2, 3], 4), false);
|
|
246
|
+
*
|
|
247
|
+
* const arr: number[] = [1, 2, 3, 4];
|
|
248
|
+
* if (isTupleOfAtLeast(arr, 3)) {
|
|
249
|
+
* console.log(arr);
|
|
250
|
+
* // ^? [number, number, number, ...number[]]
|
|
251
|
+
* }
|
|
252
|
+
*
|
|
253
|
+
* @category guards
|
|
254
|
+
* @since 3.3.0
|
|
255
|
+
*/
|
|
256
|
+
isTupleOfAtLeast
|
|
257
|
+
} from "./Predicate.js"
|
package/src/Types.ts
CHANGED
|
@@ -4,6 +4,54 @@
|
|
|
4
4
|
* @since 2.0.0
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
type _TupleOf<T, N extends number, R extends Array<unknown>> = R["length"] extends N ? R : _TupleOf<T, N, [T, ...R]>
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Represents a tuple with a fixed number of elements of type `T`.
|
|
11
|
+
*
|
|
12
|
+
* This type constructs a tuple that has exactly `N` elements of type `T`.
|
|
13
|
+
*
|
|
14
|
+
* @typeParam N - The number of elements in the tuple.
|
|
15
|
+
* @typeParam T - The type of elements in the tuple.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* import { TupleOf } from "effect/Types"
|
|
19
|
+
*
|
|
20
|
+
* // A tuple with exactly 3 numbers
|
|
21
|
+
* const example1: TupleOf<3, number> = [1, 2, 3]; // valid
|
|
22
|
+
* // @ts-expect-error
|
|
23
|
+
* const example2: TupleOf<3, number> = [1, 2]; // invalid
|
|
24
|
+
* // @ts-expect-error
|
|
25
|
+
* const example3: TupleOf<3, number> = [1, 2, 3, 4]; // invalid
|
|
26
|
+
*
|
|
27
|
+
* @category tuples
|
|
28
|
+
* @since 3.3.0
|
|
29
|
+
*/
|
|
30
|
+
export type TupleOf<N extends number, T> = N extends N ? number extends N ? Array<T> : _TupleOf<T, N, []> : never
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Represents a tuple with at least `N` elements of type `T`.
|
|
34
|
+
*
|
|
35
|
+
* This type constructs a tuple that has a fixed number of elements `N` of type `T` at the start,
|
|
36
|
+
* followed by any number (including zero) of additional elements of the same type `T`.
|
|
37
|
+
*
|
|
38
|
+
* @typeParam N - The minimum number of elements in the tuple.
|
|
39
|
+
* @typeParam T - The type of elements in the tuple.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* import { TupleOfAtLeast } from "effect/Types"
|
|
43
|
+
*
|
|
44
|
+
* // A tuple with at least 3 numbers
|
|
45
|
+
* const example1: TupleOfAtLeast<3, number> = [1, 2, 3]; // valid
|
|
46
|
+
* const example2: TupleOfAtLeast<3, number> = [1, 2, 3, 4, 5]; // valid
|
|
47
|
+
* // @ts-expect-error
|
|
48
|
+
* const example3: TupleOfAtLeast<3, number> = [1, 2]; // invalid
|
|
49
|
+
*
|
|
50
|
+
* @category tuples
|
|
51
|
+
* @since 3.3.0
|
|
52
|
+
*/
|
|
53
|
+
export type TupleOfAtLeast<N extends number, T> = [...TupleOf<N, T>, ...Array<T>]
|
|
54
|
+
|
|
7
55
|
/**
|
|
8
56
|
* Returns the tags in a type.
|
|
9
57
|
* @example
|
package/src/Utils.ts
CHANGED
|
@@ -172,17 +172,20 @@ export interface Variance<in out F extends TypeLambda, in R, out O, out E> {
|
|
|
172
172
|
readonly _E: Types.Covariant<E>
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
-
/**
|
|
176
|
-
* @category models
|
|
177
|
-
* @since 2.0.0
|
|
178
|
-
*/
|
|
179
175
|
/**
|
|
180
176
|
* @category models
|
|
181
177
|
* @since 2.0.0
|
|
182
178
|
*/
|
|
183
179
|
export interface Gen<F extends TypeLambda, Z> {
|
|
184
|
-
<K extends Variance<F, any, any, any> | YieldWrap<Kind<F, any, any, any, any>>, A>(
|
|
185
|
-
|
|
180
|
+
<Self, K extends Variance<F, any, any, any> | YieldWrap<Kind<F, any, any, any, any>>, A>(
|
|
181
|
+
...args:
|
|
182
|
+
| [
|
|
183
|
+
self: Self,
|
|
184
|
+
body: (this: Self, resume: Z) => Generator<K, A, never>
|
|
185
|
+
]
|
|
186
|
+
| [
|
|
187
|
+
body: (resume: Z) => Generator<K, A, never>
|
|
188
|
+
]
|
|
186
189
|
): Kind<
|
|
187
190
|
F,
|
|
188
191
|
[K] extends [Variance<F, infer R, any, any>] ? R
|
package/src/index.ts
CHANGED
|
@@ -614,6 +614,16 @@ export * as Record from "./Record.js"
|
|
|
614
614
|
*/
|
|
615
615
|
export * as RedBlackTree from "./RedBlackTree.js"
|
|
616
616
|
|
|
617
|
+
/**
|
|
618
|
+
* The Redacted module provides functionality for handling sensitive information
|
|
619
|
+
* securely within your application. By using the `Redacted` data type, you can
|
|
620
|
+
* ensure that sensitive values are not accidentally exposed in logs or error
|
|
621
|
+
* messages.
|
|
622
|
+
*
|
|
623
|
+
* @since 3.3.0
|
|
624
|
+
*/
|
|
625
|
+
export * as Redacted from "./Redacted.js"
|
|
626
|
+
|
|
617
627
|
/**
|
|
618
628
|
* @since 2.0.0
|
|
619
629
|
*/
|
|
@@ -713,6 +723,7 @@ export * as ScopedRef from "./ScopedRef.js"
|
|
|
713
723
|
|
|
714
724
|
/**
|
|
715
725
|
* @since 2.0.0
|
|
726
|
+
* @deprecated
|
|
716
727
|
*/
|
|
717
728
|
export * as Secret from "./Secret.js"
|
|
718
729
|
|
package/src/internal/config.ts
CHANGED
|
@@ -10,12 +10,14 @@ import * as HashSet from "../HashSet.js"
|
|
|
10
10
|
import type * as LogLevel from "../LogLevel.js"
|
|
11
11
|
import * as Option from "../Option.js"
|
|
12
12
|
import { hasProperty, type Predicate, type Refinement } from "../Predicate.js"
|
|
13
|
+
import type * as Redacted from "../Redacted.js"
|
|
13
14
|
import type * as Secret from "../Secret.js"
|
|
14
15
|
import * as configError from "./configError.js"
|
|
15
16
|
import * as core from "./core.js"
|
|
16
17
|
import * as defaultServices from "./defaultServices.js"
|
|
17
18
|
import * as effectable from "./effectable.js"
|
|
18
19
|
import * as OpCodes from "./opCodes/config.js"
|
|
20
|
+
import * as redacted_ from "./redacted.js"
|
|
19
21
|
import * as InternalSecret from "./secret.js"
|
|
20
22
|
|
|
21
23
|
const ConfigSymbolKey = "effect/Config"
|
|
@@ -178,8 +180,8 @@ export const boolean = (name?: string): Config.Config<boolean> => {
|
|
|
178
180
|
}
|
|
179
181
|
|
|
180
182
|
/** @internal */
|
|
181
|
-
export const array = <A>(config: Config.Config<A>, name?: string): Config.Config<
|
|
182
|
-
return pipe(chunk(config, name), map(Chunk.
|
|
183
|
+
export const array = <A>(config: Config.Config<A>, name?: string): Config.Config<Array<A>> => {
|
|
184
|
+
return pipe(chunk(config, name), map(Chunk.toArray))
|
|
183
185
|
}
|
|
184
186
|
|
|
185
187
|
/** @internal */
|
|
@@ -421,6 +423,15 @@ export const secret = (name?: string): Config.Config<Secret.Secret> => {
|
|
|
421
423
|
return name === undefined ? config : nested(config, name)
|
|
422
424
|
}
|
|
423
425
|
|
|
426
|
+
/** @internal */
|
|
427
|
+
export const redacted = (name?: string): Config.Config<Redacted.Redacted> => {
|
|
428
|
+
const config = primitive(
|
|
429
|
+
"a redacted property",
|
|
430
|
+
(text) => Either.right(redacted_.make(text))
|
|
431
|
+
)
|
|
432
|
+
return name === undefined ? config : nested(config, name)
|
|
433
|
+
}
|
|
434
|
+
|
|
424
435
|
/** @internal */
|
|
425
436
|
export const hashSet = <A>(config: Config.Config<A>, name?: string): Config.Config<HashSet.HashSet<A>> => {
|
|
426
437
|
const newConfig = map(chunk(config), HashSet.fromIterable)
|
package/src/internal/layer.ts
CHANGED
|
@@ -8,6 +8,7 @@ import type { FiberRef } from "../FiberRef.js"
|
|
|
8
8
|
import * as FiberRefsPatch from "../FiberRefsPatch.js"
|
|
9
9
|
import type { LazyArg } from "../Function.js"
|
|
10
10
|
import { dual, pipe } from "../Function.js"
|
|
11
|
+
import * as HashMap from "../HashMap.js"
|
|
11
12
|
import type * as Layer from "../Layer.js"
|
|
12
13
|
import { pipeArguments } from "../Pipeable.js"
|
|
13
14
|
import { hasProperty } from "../Predicate.js"
|
|
@@ -1108,10 +1109,72 @@ export const unwrapScoped = <A, E1, R1, E, R>(
|
|
|
1108
1109
|
return flatMap(scoped(tag, self), (context) => Context.get(context, tag))
|
|
1109
1110
|
}
|
|
1110
1111
|
|
|
1112
|
+
// -----------------------------------------------------------------------------
|
|
1113
|
+
// logging
|
|
1114
|
+
// -----------------------------------------------------------------------------
|
|
1115
|
+
|
|
1116
|
+
export const annotateLogs = dual<
|
|
1117
|
+
{
|
|
1118
|
+
(key: string, value: unknown): <A, E, R>(self: Layer.Layer<A, E, R>) => Layer.Layer<A, E, R>
|
|
1119
|
+
(
|
|
1120
|
+
values: Record<string, unknown>
|
|
1121
|
+
): <A, E, R>(self: Layer.Layer<A, E, R>) => Layer.Layer<A, E, R>
|
|
1122
|
+
},
|
|
1123
|
+
{
|
|
1124
|
+
<A, E, R>(self: Layer.Layer<A, E, R>, key: string, value: unknown): Layer.Layer<A, E, R>
|
|
1125
|
+
<A, E, R>(self: Layer.Layer<A, E, R>, values: Record<string, unknown>): Layer.Layer<A, E, R>
|
|
1126
|
+
}
|
|
1127
|
+
>(
|
|
1128
|
+
(args) => isLayer(args[0]),
|
|
1129
|
+
function<A, E, R>() {
|
|
1130
|
+
const args = arguments
|
|
1131
|
+
return fiberRefLocallyWith(
|
|
1132
|
+
args[0] as Layer.Layer<A, E, R>,
|
|
1133
|
+
core.currentLogAnnotations,
|
|
1134
|
+
typeof args[1] === "string"
|
|
1135
|
+
? HashMap.set(args[1], args[2])
|
|
1136
|
+
: (annotations) =>
|
|
1137
|
+
Object.entries(args[1] as Record<string, unknown>).reduce(
|
|
1138
|
+
(acc, [key, value]) => HashMap.set(acc, key, value),
|
|
1139
|
+
annotations
|
|
1140
|
+
)
|
|
1141
|
+
)
|
|
1142
|
+
}
|
|
1143
|
+
)
|
|
1144
|
+
|
|
1111
1145
|
// -----------------------------------------------------------------------------
|
|
1112
1146
|
// tracing
|
|
1113
1147
|
// -----------------------------------------------------------------------------
|
|
1114
1148
|
|
|
1149
|
+
export const annotateSpans = dual<
|
|
1150
|
+
{
|
|
1151
|
+
(key: string, value: unknown): <A, E, R>(self: Layer.Layer<A, E, R>) => Layer.Layer<A, E, R>
|
|
1152
|
+
(
|
|
1153
|
+
values: Record<string, unknown>
|
|
1154
|
+
): <A, E, R>(self: Layer.Layer<A, E, R>) => Layer.Layer<A, E, R>
|
|
1155
|
+
},
|
|
1156
|
+
{
|
|
1157
|
+
<A, E, R>(self: Layer.Layer<A, E, R>, key: string, value: unknown): Layer.Layer<A, E, R>
|
|
1158
|
+
<A, E, R>(self: Layer.Layer<A, E, R>, values: Record<string, unknown>): Layer.Layer<A, E, R>
|
|
1159
|
+
}
|
|
1160
|
+
>(
|
|
1161
|
+
(args) => isLayer(args[0]),
|
|
1162
|
+
function<A, E, R>() {
|
|
1163
|
+
const args = arguments
|
|
1164
|
+
return fiberRefLocallyWith(
|
|
1165
|
+
args[0] as Layer.Layer<A, E, R>,
|
|
1166
|
+
core.currentTracerSpanAnnotations,
|
|
1167
|
+
typeof args[1] === "string"
|
|
1168
|
+
? HashMap.set(args[1], args[2])
|
|
1169
|
+
: (annotations) =>
|
|
1170
|
+
Object.entries(args[1] as Record<string, unknown>).reduce(
|
|
1171
|
+
(acc, [key, value]) => HashMap.set(acc, key, value),
|
|
1172
|
+
annotations
|
|
1173
|
+
)
|
|
1174
|
+
)
|
|
1175
|
+
}
|
|
1176
|
+
)
|
|
1177
|
+
|
|
1115
1178
|
/** @internal */
|
|
1116
1179
|
export const withSpan: {
|
|
1117
1180
|
(
|