effect 3.13.11 → 3.14.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.
- package/LayerMap/package.json +6 -0
- package/dist/cjs/Array.js +29 -2
- package/dist/cjs/Array.js.map +1 -1
- package/dist/cjs/DateTime.js +16 -1
- package/dist/cjs/DateTime.js.map +1 -1
- package/dist/cjs/Effect.js +45 -3
- package/dist/cjs/Effect.js.map +1 -1
- package/dist/cjs/Either.js +35 -1
- package/dist/cjs/Either.js.map +1 -1
- package/dist/cjs/FiberSet.js +14 -2
- package/dist/cjs/FiberSet.js.map +1 -1
- package/dist/cjs/HashMap.js +11 -1
- package/dist/cjs/HashMap.js.map +1 -1
- package/dist/cjs/JSONSchema.js +6 -1
- package/dist/cjs/JSONSchema.js.map +1 -1
- package/dist/cjs/Layer.js +6 -1
- package/dist/cjs/Layer.js.map +1 -1
- package/dist/cjs/LayerMap.js +183 -0
- package/dist/cjs/LayerMap.js.map +1 -0
- package/dist/cjs/MutableHashMap.js +36 -4
- package/dist/cjs/MutableHashMap.js.map +1 -1
- package/dist/cjs/MutableRef.js.map +1 -1
- package/dist/cjs/Runtime.js.map +1 -1
- package/dist/cjs/Schema.js +2 -2
- package/dist/cjs/Schema.js.map +1 -1
- package/dist/cjs/SchemaAST.js +37 -33
- package/dist/cjs/SchemaAST.js.map +1 -1
- package/dist/cjs/TestClock.js +3 -2
- package/dist/cjs/TestClock.js.map +1 -1
- package/dist/cjs/Tracer.js.map +1 -1
- package/dist/cjs/index.js +4 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/internal/channel/channelExecutor.js +6 -1
- package/dist/cjs/internal/channel/channelExecutor.js.map +1 -1
- package/dist/cjs/internal/core-effect.js +13 -2
- package/dist/cjs/internal/core-effect.js.map +1 -1
- package/dist/cjs/internal/core.js +2 -1
- package/dist/cjs/internal/core.js.map +1 -1
- package/dist/cjs/internal/dateTime.js +3 -1
- package/dist/cjs/internal/dateTime.js.map +1 -1
- package/dist/cjs/internal/effect/circular.js +5 -0
- package/dist/cjs/internal/effect/circular.js.map +1 -1
- package/dist/cjs/internal/hashMap.js +3 -1
- package/dist/cjs/internal/hashMap.js.map +1 -1
- package/dist/cjs/internal/layer.js +7 -3
- package/dist/cjs/internal/layer.js.map +1 -1
- package/dist/cjs/internal/rcMap.js +11 -1
- package/dist/cjs/internal/rcMap.js.map +1 -1
- package/dist/cjs/internal/runtime.js +21 -21
- package/dist/cjs/internal/runtime.js.map +1 -1
- package/dist/cjs/internal/schema/errors.js +1 -4
- package/dist/cjs/internal/schema/errors.js.map +1 -1
- package/dist/cjs/internal/tracer.js +6 -2
- package/dist/cjs/internal/tracer.js.map +1 -1
- package/dist/cjs/internal/version.js +1 -1
- package/dist/cjs/internal/version.js.map +1 -1
- package/dist/dts/Array.d.ts +58 -0
- package/dist/dts/Array.d.ts.map +1 -1
- package/dist/dts/Data.d.ts +4 -4
- package/dist/dts/Data.d.ts.map +1 -1
- package/dist/dts/DateTime.d.ts +15 -0
- package/dist/dts/DateTime.d.ts.map +1 -1
- package/dist/dts/Effect.d.ts +66 -0
- package/dist/dts/Effect.d.ts.map +1 -1
- package/dist/dts/Either.d.ts +30 -0
- package/dist/dts/Either.d.ts.map +1 -1
- package/dist/dts/FiberSet.d.ts.map +1 -1
- package/dist/dts/HashMap.d.ts +31 -0
- package/dist/dts/HashMap.d.ts.map +1 -1
- package/dist/dts/Layer.d.ts +12 -0
- package/dist/dts/Layer.d.ts.map +1 -1
- package/dist/dts/LayerMap.d.ts +242 -0
- package/dist/dts/LayerMap.d.ts.map +1 -0
- package/dist/dts/MutableHashMap.d.ts +22 -0
- package/dist/dts/MutableHashMap.d.ts.map +1 -1
- package/dist/dts/MutableRef.d.ts +1 -0
- package/dist/dts/MutableRef.d.ts.map +1 -1
- package/dist/dts/Runtime.d.ts +144 -10
- package/dist/dts/Runtime.d.ts.map +1 -1
- package/dist/dts/SchemaAST.d.ts +1 -1
- package/dist/dts/SchemaAST.d.ts.map +1 -1
- package/dist/dts/TestClock.d.ts +3 -2
- package/dist/dts/TestClock.d.ts.map +1 -1
- package/dist/dts/Tracer.d.ts +1 -0
- package/dist/dts/Tracer.d.ts.map +1 -1
- package/dist/dts/index.d.ts +4 -0
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/dts/internal/channel/channelExecutor.d.ts.map +1 -1
- package/dist/dts/internal/core-effect.d.ts.map +1 -1
- package/dist/dts/internal/layer.d.ts.map +1 -1
- package/dist/esm/Array.js +28 -1
- package/dist/esm/Array.js.map +1 -1
- package/dist/esm/DateTime.js +15 -0
- package/dist/esm/DateTime.js.map +1 -1
- package/dist/esm/Effect.js +42 -0
- package/dist/esm/Effect.js.map +1 -1
- package/dist/esm/Either.js +33 -0
- package/dist/esm/Either.js.map +1 -1
- package/dist/esm/FiberSet.js +13 -1
- package/dist/esm/FiberSet.js.map +1 -1
- package/dist/esm/HashMap.js +10 -0
- package/dist/esm/HashMap.js.map +1 -1
- package/dist/esm/JSONSchema.js +6 -1
- package/dist/esm/JSONSchema.js.map +1 -1
- package/dist/esm/Layer.js +5 -0
- package/dist/esm/Layer.js.map +1 -1
- package/dist/esm/LayerMap.js +172 -0
- package/dist/esm/LayerMap.js.map +1 -0
- package/dist/esm/MutableHashMap.js +33 -3
- package/dist/esm/MutableHashMap.js.map +1 -1
- package/dist/esm/MutableRef.js.map +1 -1
- package/dist/esm/Runtime.js.map +1 -1
- package/dist/esm/Schema.js +2 -2
- package/dist/esm/Schema.js.map +1 -1
- package/dist/esm/SchemaAST.js +31 -27
- package/dist/esm/SchemaAST.js.map +1 -1
- package/dist/esm/TestClock.js +3 -2
- package/dist/esm/TestClock.js.map +1 -1
- package/dist/esm/Tracer.js.map +1 -1
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/internal/channel/channelExecutor.js +6 -1
- package/dist/esm/internal/channel/channelExecutor.js.map +1 -1
- package/dist/esm/internal/core-effect.js +10 -0
- package/dist/esm/internal/core-effect.js.map +1 -1
- package/dist/esm/internal/core.js +2 -1
- package/dist/esm/internal/core.js.map +1 -1
- package/dist/esm/internal/dateTime.js +2 -0
- package/dist/esm/internal/dateTime.js.map +1 -1
- package/dist/esm/internal/effect/circular.js +5 -0
- package/dist/esm/internal/effect/circular.js.map +1 -1
- package/dist/esm/internal/hashMap.js +2 -0
- package/dist/esm/internal/hashMap.js.map +1 -1
- package/dist/esm/internal/layer.js +6 -2
- package/dist/esm/internal/layer.js.map +1 -1
- package/dist/esm/internal/rcMap.js +11 -1
- package/dist/esm/internal/rcMap.js.map +1 -1
- package/dist/esm/internal/runtime.js +21 -15
- package/dist/esm/internal/runtime.js.map +1 -1
- package/dist/esm/internal/schema/errors.js +0 -2
- package/dist/esm/internal/schema/errors.js.map +1 -1
- package/dist/esm/internal/tracer.js +6 -2
- package/dist/esm/internal/tracer.js.map +1 -1
- package/dist/esm/internal/version.js +1 -1
- package/dist/esm/internal/version.js.map +1 -1
- package/package.json +9 -1
- package/src/Array.ts +69 -1
- package/src/Data.ts +4 -4
- package/src/DateTime.ts +16 -0
- package/src/Effect.ts +143 -0
- package/src/Either.ts +36 -0
- package/src/FiberSet.ts +14 -1
- package/src/HashMap.ts +32 -0
- package/src/JSONSchema.ts +6 -2
- package/src/Layer.ts +14 -0
- package/src/LayerMap.ts +396 -0
- package/src/MutableHashMap.ts +45 -3
- package/src/MutableRef.ts +0 -2
- package/src/Runtime.ts +158 -20
- package/src/Schema.ts +2 -2
- package/src/SchemaAST.ts +45 -30
- package/src/TestClock.ts +10 -3
- package/src/Tracer.ts +1 -0
- package/src/index.ts +5 -0
- package/src/internal/channel/channelExecutor.ts +11 -4
- package/src/internal/core-effect.ts +15 -0
- package/src/internal/core.ts +2 -1
- package/src/internal/dateTime.ts +3 -0
- package/src/internal/effect/circular.ts +5 -0
- package/src/internal/hashMap.ts +9 -0
- package/src/internal/layer.ts +14 -2
- package/src/internal/rcMap.ts +13 -3
- package/src/internal/runtime.ts +104 -38
- package/src/internal/schema/errors.ts +0 -6
- package/src/internal/tracer.ts +8 -1
- package/src/internal/version.ts +1 -1
package/src/Runtime.ts
CHANGED
|
@@ -81,9 +81,28 @@ export interface RunForkOptions {
|
|
|
81
81
|
* @since 2.0.0
|
|
82
82
|
* @category execution
|
|
83
83
|
*/
|
|
84
|
-
export const runFork:
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
export const runFork: {
|
|
85
|
+
/**
|
|
86
|
+
* Executes the effect using the provided Scheduler or using the global
|
|
87
|
+
* Scheduler if not provided
|
|
88
|
+
*
|
|
89
|
+
* @since 2.0.0
|
|
90
|
+
* @category execution
|
|
91
|
+
*/
|
|
92
|
+
<R>(runtime: Runtime<R>): <A, E>(effect: Effect.Effect<A, E, R>, options?: RunForkOptions | undefined) => Fiber.RuntimeFiber<A, E>
|
|
93
|
+
/**
|
|
94
|
+
* Executes the effect using the provided Scheduler or using the global
|
|
95
|
+
* Scheduler if not provided
|
|
96
|
+
*
|
|
97
|
+
* @since 2.0.0
|
|
98
|
+
* @category execution
|
|
99
|
+
*/
|
|
100
|
+
<R, A, E>(
|
|
101
|
+
runtime: Runtime<R>,
|
|
102
|
+
effect: Effect.Effect<A, E, R>,
|
|
103
|
+
options?: RunForkOptions | undefined
|
|
104
|
+
): Fiber.RuntimeFiber<A, E>
|
|
105
|
+
} = internal.unsafeFork
|
|
87
106
|
|
|
88
107
|
/**
|
|
89
108
|
* Executes the effect synchronously returning the exit.
|
|
@@ -94,8 +113,28 @@ export const runFork: <R>(
|
|
|
94
113
|
* @since 2.0.0
|
|
95
114
|
* @category execution
|
|
96
115
|
*/
|
|
97
|
-
export const runSyncExit:
|
|
98
|
-
|
|
116
|
+
export const runSyncExit: {
|
|
117
|
+
/**
|
|
118
|
+
* Executes the effect synchronously returning the exit.
|
|
119
|
+
*
|
|
120
|
+
* This method is effectful and should only be invoked at the edges of your
|
|
121
|
+
* program.
|
|
122
|
+
*
|
|
123
|
+
* @since 2.0.0
|
|
124
|
+
* @category execution
|
|
125
|
+
*/
|
|
126
|
+
<A, E, R>(runtime: Runtime<R>, effect: Effect.Effect<A, E, R>): Exit.Exit<A, E>
|
|
127
|
+
/**
|
|
128
|
+
* Executes the effect synchronously returning the exit.
|
|
129
|
+
*
|
|
130
|
+
* This method is effectful and should only be invoked at the edges of your
|
|
131
|
+
* program.
|
|
132
|
+
*
|
|
133
|
+
* @since 2.0.0
|
|
134
|
+
* @category execution
|
|
135
|
+
*/
|
|
136
|
+
<R>(runtime: Runtime<R>): <A, E>(effect: Effect.Effect<A, E, R>) => Exit.Exit<A, E>
|
|
137
|
+
} = internal.unsafeRunSyncExit
|
|
99
138
|
|
|
100
139
|
/**
|
|
101
140
|
* Executes the effect synchronously throwing in case of errors or async boundaries.
|
|
@@ -106,7 +145,28 @@ export const runSyncExit: <R>(runtime: Runtime<R>) => <A, E>(effect: Effect.Effe
|
|
|
106
145
|
* @since 2.0.0
|
|
107
146
|
* @category execution
|
|
108
147
|
*/
|
|
109
|
-
export const runSync:
|
|
148
|
+
export const runSync: {
|
|
149
|
+
/**
|
|
150
|
+
* Executes the effect synchronously throwing in case of errors or async boundaries.
|
|
151
|
+
*
|
|
152
|
+
* This method is effectful and should only be invoked at the edges of your
|
|
153
|
+
* program.
|
|
154
|
+
*
|
|
155
|
+
* @since 2.0.0
|
|
156
|
+
* @category execution
|
|
157
|
+
*/
|
|
158
|
+
<A, E, R>(runtime: Runtime<R>, effect: Effect.Effect<A, E, R>): A
|
|
159
|
+
/**
|
|
160
|
+
* Executes the effect synchronously throwing in case of errors or async boundaries.
|
|
161
|
+
*
|
|
162
|
+
* This method is effectful and should only be invoked at the edges of your
|
|
163
|
+
* program.
|
|
164
|
+
*
|
|
165
|
+
* @since 2.0.0
|
|
166
|
+
* @category execution
|
|
167
|
+
*/
|
|
168
|
+
<R>(runtime: Runtime<R>): <A, E>(effect: Effect.Effect<A, E, R>) => A
|
|
169
|
+
} = internal.unsafeRunSync
|
|
110
170
|
|
|
111
171
|
/**
|
|
112
172
|
* @since 2.0.0
|
|
@@ -126,10 +186,37 @@ export interface RunCallbackOptions<in A, in E = never> extends RunForkOptions {
|
|
|
126
186
|
* @since 2.0.0
|
|
127
187
|
* @category execution
|
|
128
188
|
*/
|
|
129
|
-
export const runCallback:
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
189
|
+
export const runCallback: {
|
|
190
|
+
/**
|
|
191
|
+
* Executes the effect asynchronously, eventually passing the exit value to
|
|
192
|
+
* the specified callback.
|
|
193
|
+
*
|
|
194
|
+
* This method is effectful and should only be invoked at the edges of your
|
|
195
|
+
* program.
|
|
196
|
+
*
|
|
197
|
+
* @since 2.0.0
|
|
198
|
+
* @category execution
|
|
199
|
+
*/
|
|
200
|
+
<R>(runtime: Runtime<R>): <A, E>(
|
|
201
|
+
effect: Effect.Effect<A, E, R>,
|
|
202
|
+
options?: RunCallbackOptions<A, E> | undefined
|
|
203
|
+
) => (fiberId?: FiberId.FiberId, options?: RunCallbackOptions<A, E> | undefined) => void
|
|
204
|
+
/**
|
|
205
|
+
* Executes the effect asynchronously, eventually passing the exit value to
|
|
206
|
+
* the specified callback.
|
|
207
|
+
*
|
|
208
|
+
* This method is effectful and should only be invoked at the edges of your
|
|
209
|
+
* program.
|
|
210
|
+
*
|
|
211
|
+
* @since 2.0.0
|
|
212
|
+
* @category execution
|
|
213
|
+
*/
|
|
214
|
+
<R, A, E>(
|
|
215
|
+
runtime: Runtime<R>,
|
|
216
|
+
effect: Effect.Effect<A, E, R>,
|
|
217
|
+
options?: RunCallbackOptions<A, E> | undefined
|
|
218
|
+
): (fiberId?: FiberId.FiberId, options?: RunCallbackOptions<A, E> | undefined) => void
|
|
219
|
+
} = internal.unsafeRunCallback
|
|
133
220
|
|
|
134
221
|
/**
|
|
135
222
|
* Runs the `Effect`, returning a JavaScript `Promise` that will be resolved
|
|
@@ -142,10 +229,36 @@ export const runCallback: <R>(
|
|
|
142
229
|
* @since 2.0.0
|
|
143
230
|
* @category execution
|
|
144
231
|
*/
|
|
145
|
-
export const runPromise:
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
232
|
+
export const runPromise: {
|
|
233
|
+
/**
|
|
234
|
+
* Runs the `Effect`, returning a JavaScript `Promise` that will be resolved
|
|
235
|
+
* with the value of the effect once the effect has been executed, or will be
|
|
236
|
+
* rejected with the first error or exception throw by the effect.
|
|
237
|
+
*
|
|
238
|
+
* This method is effectful and should only be used at the edges of your
|
|
239
|
+
* program.
|
|
240
|
+
*
|
|
241
|
+
* @since 2.0.0
|
|
242
|
+
* @category execution
|
|
243
|
+
*/
|
|
244
|
+
<R>(runtime: Runtime<R>): <A, E>(effect: Effect.Effect<A, E, R>, options?: { readonly signal?: AbortSignal } | undefined) => Promise<A>
|
|
245
|
+
/**
|
|
246
|
+
* Runs the `Effect`, returning a JavaScript `Promise` that will be resolved
|
|
247
|
+
* with the value of the effect once the effect has been executed, or will be
|
|
248
|
+
* rejected with the first error or exception throw by the effect.
|
|
249
|
+
*
|
|
250
|
+
* This method is effectful and should only be used at the edges of your
|
|
251
|
+
* program.
|
|
252
|
+
*
|
|
253
|
+
* @since 2.0.0
|
|
254
|
+
* @category execution
|
|
255
|
+
*/
|
|
256
|
+
<R, A, E>(
|
|
257
|
+
runtime: Runtime<R>,
|
|
258
|
+
effect: Effect.Effect<A, E, R>,
|
|
259
|
+
options?: { readonly signal?: AbortSignal } | undefined
|
|
260
|
+
): Promise<A>
|
|
261
|
+
} = internal.unsafeRunPromise
|
|
149
262
|
|
|
150
263
|
/**
|
|
151
264
|
* Runs the `Effect`, returning a JavaScript `Promise` that will be resolved
|
|
@@ -157,12 +270,37 @@ export const runPromise: <R>(
|
|
|
157
270
|
* @since 2.0.0
|
|
158
271
|
* @category execution
|
|
159
272
|
*/
|
|
160
|
-
export const runPromiseExit:
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
273
|
+
export const runPromiseExit: {
|
|
274
|
+
/**
|
|
275
|
+
* Runs the `Effect`, returning a JavaScript `Promise` that will be resolved
|
|
276
|
+
* with the `Exit` state of the effect once the effect has been executed.
|
|
277
|
+
*
|
|
278
|
+
* This method is effectful and should only be used at the edges of your
|
|
279
|
+
* program.
|
|
280
|
+
*
|
|
281
|
+
* @since 2.0.0
|
|
282
|
+
* @category execution
|
|
283
|
+
*/
|
|
284
|
+
<R>(runtime: Runtime<R>): <A, E>(
|
|
285
|
+
effect: Effect.Effect<A, E, R>,
|
|
286
|
+
options?: { readonly signal?: AbortSignal } | undefined
|
|
287
|
+
) => Promise<Exit.Exit<A, E>>
|
|
288
|
+
/**
|
|
289
|
+
* Runs the `Effect`, returning a JavaScript `Promise` that will be resolved
|
|
290
|
+
* with the `Exit` state of the effect once the effect has been executed.
|
|
291
|
+
*
|
|
292
|
+
* This method is effectful and should only be used at the edges of your
|
|
293
|
+
* program.
|
|
294
|
+
*
|
|
295
|
+
* @since 2.0.0
|
|
296
|
+
* @category execution
|
|
297
|
+
*/
|
|
298
|
+
<R, A, E>(
|
|
299
|
+
runtime: Runtime<R>,
|
|
300
|
+
effect: Effect.Effect<A, E, R>,
|
|
301
|
+
options?: { readonly signal?: AbortSignal } | undefined
|
|
302
|
+
): Promise<Exit.Exit<A, E>>
|
|
303
|
+
} = internal.unsafeRunPromiseExit
|
|
166
304
|
|
|
167
305
|
/**
|
|
168
306
|
* @since 2.0.0
|
package/src/Schema.ts
CHANGED
|
@@ -2831,7 +2831,7 @@ export interface TypeLiteral<
|
|
|
2831
2831
|
): Simplify<TypeLiteral.Type<Fields, Records>>
|
|
2832
2832
|
}
|
|
2833
2833
|
|
|
2834
|
-
const preserveMissingMessageAnnotation = AST.
|
|
2834
|
+
const preserveMissingMessageAnnotation = AST.pickAnnotations([AST.MissingMessageAnnotationId])
|
|
2835
2835
|
|
|
2836
2836
|
const getDefaultTypeLiteralAST = <
|
|
2837
2837
|
Fields extends Struct.Fields,
|
|
@@ -3513,7 +3513,7 @@ const intersectTypeLiterals = (
|
|
|
3513
3513
|
throw new Error(errors_.getSchemaExtendErrorMessage(x, y, path))
|
|
3514
3514
|
}
|
|
3515
3515
|
|
|
3516
|
-
const preserveRefinementAnnotations = AST.
|
|
3516
|
+
const preserveRefinementAnnotations = AST.omitAnnotations([AST.IdentifierAnnotationId])
|
|
3517
3517
|
|
|
3518
3518
|
const addRefinementToMembers = (refinement: AST.Refinement, asts: ReadonlyArray<AST.AST>): Array<AST.Refinement> =>
|
|
3519
3519
|
asts.map((ast) => new AST.Refinement(ast, refinement.filter, preserveRefinementAnnotations(refinement)))
|
package/src/SchemaAST.ts
CHANGED
|
@@ -2082,12 +2082,12 @@ export const isTypeLiteralTransformation: (ast: TransformationKind) => ast is Ty
|
|
|
2082
2082
|
*
|
|
2083
2083
|
* @since 3.10.0
|
|
2084
2084
|
*/
|
|
2085
|
-
export const annotations = (ast: AST,
|
|
2085
|
+
export const annotations = (ast: AST, overrides: Annotations): AST => {
|
|
2086
2086
|
const d = Object.getOwnPropertyDescriptors(ast)
|
|
2087
|
-
const value = { ...ast.annotations, ...
|
|
2087
|
+
const value = { ...ast.annotations, ...overrides }
|
|
2088
2088
|
const surrogate = getSurrogateAnnotation(ast)
|
|
2089
2089
|
if (Option.isSome(surrogate)) {
|
|
2090
|
-
value[SurrogateAnnotationId] = annotations(surrogate.value,
|
|
2090
|
+
value[SurrogateAnnotationId] = annotations(surrogate.value, overrides)
|
|
2091
2091
|
}
|
|
2092
2092
|
d.annotations.value = value
|
|
2093
2093
|
return Object.create(Object.getPrototypeOf(ast), d)
|
|
@@ -2611,6 +2611,40 @@ export const getCompiler = <A>(match: Match<A>): Compiler<A> => {
|
|
|
2611
2611
|
return compile
|
|
2612
2612
|
}
|
|
2613
2613
|
|
|
2614
|
+
/** @internal */
|
|
2615
|
+
export const pickAnnotations =
|
|
2616
|
+
(annotationIds: ReadonlyArray<symbol>) => (annotated: Annotated): Annotations | undefined => {
|
|
2617
|
+
let out: { [_: symbol]: unknown } | undefined = undefined
|
|
2618
|
+
for (const id of annotationIds) {
|
|
2619
|
+
if (Object.prototype.hasOwnProperty.call(annotated.annotations, id)) {
|
|
2620
|
+
if (out === undefined) {
|
|
2621
|
+
out = {}
|
|
2622
|
+
}
|
|
2623
|
+
out[id] = annotated.annotations[id]
|
|
2624
|
+
}
|
|
2625
|
+
}
|
|
2626
|
+
return out
|
|
2627
|
+
}
|
|
2628
|
+
|
|
2629
|
+
/** @internal */
|
|
2630
|
+
export const omitAnnotations =
|
|
2631
|
+
(annotationIds: ReadonlyArray<symbol>) => (annotated: Annotated): Annotations | undefined => {
|
|
2632
|
+
const out = { ...annotated.annotations }
|
|
2633
|
+
for (const id of annotationIds) {
|
|
2634
|
+
delete out[id]
|
|
2635
|
+
}
|
|
2636
|
+
return out
|
|
2637
|
+
}
|
|
2638
|
+
|
|
2639
|
+
const preserveTransformationAnnotations = pickAnnotations([
|
|
2640
|
+
ExamplesAnnotationId,
|
|
2641
|
+
DefaultAnnotationId,
|
|
2642
|
+
JSONSchemaAnnotationId,
|
|
2643
|
+
ArbitraryAnnotationId,
|
|
2644
|
+
PrettyAnnotationId,
|
|
2645
|
+
EquivalenceAnnotationId
|
|
2646
|
+
])
|
|
2647
|
+
|
|
2614
2648
|
/**
|
|
2615
2649
|
* @since 3.10.0
|
|
2616
2650
|
*/
|
|
@@ -2658,37 +2692,18 @@ export const typeAST = (ast: AST): AST => {
|
|
|
2658
2692
|
ast :
|
|
2659
2693
|
new Refinement(from, ast.filter, ast.annotations)
|
|
2660
2694
|
}
|
|
2661
|
-
case "Transformation":
|
|
2662
|
-
|
|
2695
|
+
case "Transformation": {
|
|
2696
|
+
const preserve = preserveTransformationAnnotations(ast)
|
|
2697
|
+
return typeAST(
|
|
2698
|
+
preserve !== undefined ?
|
|
2699
|
+
annotations(ast.to, preserve) :
|
|
2700
|
+
ast.to
|
|
2701
|
+
)
|
|
2702
|
+
}
|
|
2663
2703
|
}
|
|
2664
2704
|
return ast
|
|
2665
2705
|
}
|
|
2666
2706
|
|
|
2667
|
-
/** @internal */
|
|
2668
|
-
export const whiteListAnnotations =
|
|
2669
|
-
(annotationIds: ReadonlyArray<symbol>) => (annotated: Annotated): Annotations | undefined => {
|
|
2670
|
-
let out: { [_: symbol]: unknown } | undefined = undefined
|
|
2671
|
-
for (const id of annotationIds) {
|
|
2672
|
-
if (Object.prototype.hasOwnProperty.call(annotated.annotations, id)) {
|
|
2673
|
-
if (out === undefined) {
|
|
2674
|
-
out = {}
|
|
2675
|
-
}
|
|
2676
|
-
out[id] = annotated.annotations[id]
|
|
2677
|
-
}
|
|
2678
|
-
}
|
|
2679
|
-
return out
|
|
2680
|
-
}
|
|
2681
|
-
|
|
2682
|
-
/** @internal */
|
|
2683
|
-
export const blackListAnnotations =
|
|
2684
|
-
(annotationIds: ReadonlyArray<symbol>) => (annotated: Annotated): Annotations | undefined => {
|
|
2685
|
-
const out = { ...annotated.annotations }
|
|
2686
|
-
for (const id of annotationIds) {
|
|
2687
|
-
delete out[id]
|
|
2688
|
-
}
|
|
2689
|
-
return out
|
|
2690
|
-
}
|
|
2691
|
-
|
|
2692
2707
|
// To generate a JSON Schema from a recursive schema, an `identifier` annotation
|
|
2693
2708
|
// is required. So, when we calculate the encodedAST, we need to preserve the
|
|
2694
2709
|
// annotation in the form of an internal custom annotation that acts as a
|
package/src/TestClock.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import * as Chunk from "./Chunk.js"
|
|
5
5
|
import type * as Clock from "./Clock.js"
|
|
6
6
|
import * as Context from "./Context.js"
|
|
7
|
+
import * as DateTime from "./DateTime.js"
|
|
7
8
|
import type * as Deferred from "./Deferred.js"
|
|
8
9
|
import * as Duration from "./Duration.js"
|
|
9
10
|
import type * as Effect from "./Effect.js"
|
|
@@ -499,13 +500,19 @@ export const save = (): Effect.Effect<Effect.Effect<void>> => testClockWith((tes
|
|
|
499
500
|
|
|
500
501
|
/**
|
|
501
502
|
* Accesses a `TestClock` instance in the context and sets the clock time
|
|
502
|
-
* to the specified `Instant`, running any actions scheduled for on or before
|
|
503
|
+
* to the specified `Instant` or `Date`, running any actions scheduled for on or before
|
|
503
504
|
* the new time in order.
|
|
504
505
|
*
|
|
505
506
|
* @since 2.0.0
|
|
506
507
|
*/
|
|
507
|
-
export const setTime = (
|
|
508
|
-
testClockWith((testClock) =>
|
|
508
|
+
export const setTime = (input: DateTime.DateTime.Input): Effect.Effect<void> =>
|
|
509
|
+
testClockWith((testClock) =>
|
|
510
|
+
testClock.setTime(
|
|
511
|
+
typeof input === "number"
|
|
512
|
+
? input
|
|
513
|
+
: DateTime.unsafeMake(input).epochMillis
|
|
514
|
+
)
|
|
515
|
+
)
|
|
509
516
|
|
|
510
517
|
/**
|
|
511
518
|
* Semantically blocks the current fiber until the clock time is equal to or
|
package/src/Tracer.ts
CHANGED
|
@@ -121,6 +121,7 @@ export interface Span {
|
|
|
121
121
|
end(endTime: bigint, exit: Exit.Exit<unknown, unknown>): void
|
|
122
122
|
attribute(key: string, value: unknown): void
|
|
123
123
|
event(name: string, startTime: bigint, attributes?: Record<string, unknown>): void
|
|
124
|
+
addLinks(links: ReadonlyArray<SpanLink>): void
|
|
124
125
|
}
|
|
125
126
|
|
|
126
127
|
/**
|
package/src/index.ts
CHANGED
|
@@ -406,6 +406,11 @@ export * as KeyedPool from "./KeyedPool.js"
|
|
|
406
406
|
*/
|
|
407
407
|
export * as Layer from "./Layer.js"
|
|
408
408
|
|
|
409
|
+
/**
|
|
410
|
+
* @since 3.14.0
|
|
411
|
+
*/
|
|
412
|
+
export * as LayerMap from "./LayerMap.js"
|
|
413
|
+
|
|
409
414
|
/**
|
|
410
415
|
* A data type for immutable linked lists representing ordered collections of elements of type `A`.
|
|
411
416
|
*
|
|
@@ -7,7 +7,9 @@ import * as Effect from "../../Effect.js"
|
|
|
7
7
|
import * as ExecutionStrategy from "../../ExecutionStrategy.js"
|
|
8
8
|
import * as Exit from "../../Exit.js"
|
|
9
9
|
import * as Fiber from "../../Fiber.js"
|
|
10
|
+
import * as FiberId from "../../FiberId.js"
|
|
10
11
|
import { dual, identity, pipe } from "../../Function.js"
|
|
12
|
+
import * as HashSet from "../../HashSet.js"
|
|
11
13
|
import * as Option from "../../Option.js"
|
|
12
14
|
import * as Scope from "../../Scope.js"
|
|
13
15
|
import type * as UpstreamPullStrategy from "../../UpstreamPullStrategy.js"
|
|
@@ -1143,8 +1145,9 @@ export const runIn = dual<
|
|
|
1143
1145
|
restore(run(channelDeferred, scopeDeferred, child)).pipe(
|
|
1144
1146
|
Effect.forkIn(scope),
|
|
1145
1147
|
Effect.flatMap((fiber) =>
|
|
1146
|
-
scope.addFinalizer(() =>
|
|
1147
|
-
|
|
1148
|
+
scope.addFinalizer((exit) => {
|
|
1149
|
+
const interruptors = Exit.isFailure(exit) ? Cause.interruptors(exit.cause) : undefined
|
|
1150
|
+
return Deferred.isDone(channelDeferred).pipe(
|
|
1148
1151
|
Effect.flatMap((isDone) =>
|
|
1149
1152
|
isDone
|
|
1150
1153
|
? Deferred.succeed(scopeDeferred, void 0).pipe(
|
|
@@ -1152,12 +1155,16 @@ export const runIn = dual<
|
|
|
1152
1155
|
Effect.zipRight(Fiber.inheritAll(fiber))
|
|
1153
1156
|
)
|
|
1154
1157
|
: Deferred.succeed(scopeDeferred, void 0).pipe(
|
|
1155
|
-
Effect.zipRight(
|
|
1158
|
+
Effect.zipRight(
|
|
1159
|
+
interruptors && HashSet.size(interruptors) > 0
|
|
1160
|
+
? Fiber.interruptAs(fiber, FiberId.combineAll(interruptors))
|
|
1161
|
+
: Fiber.interrupt(fiber)
|
|
1162
|
+
),
|
|
1156
1163
|
Effect.zipRight(Fiber.inheritAll(fiber))
|
|
1157
1164
|
)
|
|
1158
1165
|
)
|
|
1159
1166
|
)
|
|
1160
|
-
).pipe(Effect.zipRight(restore(Deferred.await(channelDeferred))))
|
|
1167
|
+
}).pipe(Effect.zipRight(restore(Deferred.await(channelDeferred))))
|
|
1161
1168
|
)
|
|
1162
1169
|
)
|
|
1163
1170
|
))
|
|
@@ -1950,6 +1950,21 @@ export const annotateCurrentSpan: {
|
|
|
1950
1950
|
))
|
|
1951
1951
|
}
|
|
1952
1952
|
|
|
1953
|
+
/* @internal */
|
|
1954
|
+
export const linkSpanCurrent: {
|
|
1955
|
+
(span: Tracer.AnySpan, attributes?: Readonly<Record<string, unknown>> | undefined): Effect.Effect<void>
|
|
1956
|
+
(links: ReadonlyArray<Tracer.SpanLink>): Effect.Effect<void>
|
|
1957
|
+
} = function(): Effect.Effect<void> {
|
|
1958
|
+
const args = arguments
|
|
1959
|
+
const links: ReadonlyArray<Tracer.SpanLink> = Array.isArray(args[0])
|
|
1960
|
+
? args[0]
|
|
1961
|
+
: [{ _tag: "SpanLink", span: args[0], attributes: args[1] ?? {} }]
|
|
1962
|
+
return ignore(core.flatMap(
|
|
1963
|
+
currentSpan,
|
|
1964
|
+
(span) => core.sync(() => span.addLinks(links))
|
|
1965
|
+
))
|
|
1966
|
+
}
|
|
1967
|
+
|
|
1953
1968
|
/* @internal */
|
|
1954
1969
|
export const annotateSpans = dual<
|
|
1955
1970
|
{
|
package/src/internal/core.ts
CHANGED
package/src/internal/dateTime.ts
CHANGED
|
@@ -299,6 +299,9 @@ export const makeZonedFromString = (input: string): Option.Option<DateTime.Zoned
|
|
|
299
299
|
/** @internal */
|
|
300
300
|
export const now: Effect.Effect<DateTime.Utc> = core.map(Clock.currentTimeMillis, makeUtc)
|
|
301
301
|
|
|
302
|
+
/** @internal */
|
|
303
|
+
export const nowAsDate: Effect.Effect<Date> = core.map(Clock.currentTimeMillis, (millis) => new Date(millis))
|
|
304
|
+
|
|
302
305
|
/** @internal */
|
|
303
306
|
export const unsafeNow: LazyArg<DateTime.Utc> = () => makeUtc(Date.now())
|
|
304
307
|
|
|
@@ -146,6 +146,11 @@ class Latch extends Effectable.Class<void> implements Effect.Latch {
|
|
|
146
146
|
this.isOpen = true
|
|
147
147
|
return this.unsafeSchedule(fiber)
|
|
148
148
|
})
|
|
149
|
+
unsafeOpen() {
|
|
150
|
+
if (this.isOpen) return
|
|
151
|
+
this.isOpen = true
|
|
152
|
+
this.flushWaiters()
|
|
153
|
+
}
|
|
149
154
|
release = core.withFiberRuntime<void>((fiber) => {
|
|
150
155
|
if (this.isOpen) {
|
|
151
156
|
return core.void
|
package/src/internal/hashMap.ts
CHANGED
|
@@ -555,3 +555,12 @@ export const some: {
|
|
|
555
555
|
return false
|
|
556
556
|
}
|
|
557
557
|
)
|
|
558
|
+
|
|
559
|
+
/** @internal */
|
|
560
|
+
export const every: {
|
|
561
|
+
<K, A>(predicate: (a: NoInfer<A>, k: K) => boolean): (self: HM.HashMap<K, A>) => boolean
|
|
562
|
+
<K, A>(self: HM.HashMap<K, A>, predicate: (a: A, k: K) => boolean): boolean
|
|
563
|
+
} = Dual.dual(
|
|
564
|
+
2,
|
|
565
|
+
<K, A>(self: HM.HashMap<K, A>, predicate: (a: A, k: K) => boolean): boolean => !some(self, (a, k) => !predicate(a, k))
|
|
566
|
+
)
|
package/src/internal/layer.ts
CHANGED
|
@@ -67,6 +67,11 @@ export const MemoMapTypeId: Layer.MemoMapTypeId = Symbol.for(
|
|
|
67
67
|
MemoMapTypeIdKey
|
|
68
68
|
) as Layer.MemoMapTypeId
|
|
69
69
|
|
|
70
|
+
/** @internal */
|
|
71
|
+
export const CurrentMemoMap = Context.Reference<Layer.CurrentMemoMap>()("effect/Layer/CurrentMemoMap", {
|
|
72
|
+
defaultValue: () => unsafeMakeMemoMap()
|
|
73
|
+
})
|
|
74
|
+
|
|
70
75
|
/** @internal */
|
|
71
76
|
export type Primitive =
|
|
72
77
|
| ExtendScope
|
|
@@ -337,7 +342,7 @@ export const buildWithScope = dual<
|
|
|
337
342
|
>(2, (self, scope) =>
|
|
338
343
|
core.flatMap(
|
|
339
344
|
makeMemoMap,
|
|
340
|
-
(memoMap) =>
|
|
345
|
+
(memoMap) => buildWithMemoMap(self, memoMap, scope)
|
|
341
346
|
))
|
|
342
347
|
|
|
343
348
|
/** @internal */
|
|
@@ -351,7 +356,14 @@ export const buildWithMemoMap = dual<
|
|
|
351
356
|
memoMap: Layer.MemoMap,
|
|
352
357
|
scope: Scope.Scope
|
|
353
358
|
) => Effect.Effect<Context.Context<ROut>, E, RIn>
|
|
354
|
-
>(
|
|
359
|
+
>(
|
|
360
|
+
3,
|
|
361
|
+
(self, memoMap, scope) =>
|
|
362
|
+
core.flatMap(
|
|
363
|
+
makeBuilder(self, scope),
|
|
364
|
+
(run) => effect.provideService(run(memoMap), CurrentMemoMap, memoMap)
|
|
365
|
+
)
|
|
366
|
+
)
|
|
355
367
|
|
|
356
368
|
const makeBuilder = <RIn, E, ROut>(
|
|
357
369
|
self: Layer.Layer<ROut, E, RIn>,
|
package/src/internal/rcMap.ts
CHANGED
|
@@ -154,10 +154,16 @@ const acquire = core.fnUntraced(function*<K, A, E>(self: RcMapImpl<K, A, E>, key
|
|
|
154
154
|
const scope = yield* fiberRuntime.scopeMake()
|
|
155
155
|
const deferred = yield* core.deferredMake<A, E>()
|
|
156
156
|
const acquire = self.lookup(key)
|
|
157
|
-
|
|
157
|
+
const contextMap = new Map(self.context.unsafeMap)
|
|
158
|
+
yield* restore(core.mapInputContext(
|
|
158
159
|
acquire as Effect<A, E>,
|
|
159
|
-
|
|
160
|
-
|
|
160
|
+
(inputContext: Context.Context<never>) => {
|
|
161
|
+
inputContext.unsafeMap.forEach((value, key) => {
|
|
162
|
+
contextMap.set(key, value)
|
|
163
|
+
})
|
|
164
|
+
contextMap.set(fiberRuntime.scopeTag.key, scope)
|
|
165
|
+
return Context.unsafeMake(contextMap)
|
|
166
|
+
}
|
|
161
167
|
)).pipe(
|
|
162
168
|
core.exit,
|
|
163
169
|
core.flatMap((exit) => core.deferredDone(deferred, exit)),
|
|
@@ -194,6 +200,10 @@ const release = <K, A, E>(self: RcMapImpl<K, A, E>, key: K, entry: State.Entry<A
|
|
|
194
200
|
return core.scopeClose(entry.scope, core.exitVoid)
|
|
195
201
|
}
|
|
196
202
|
|
|
203
|
+
if (!Duration.isFinite(self.idleTimeToLive)) {
|
|
204
|
+
return core.void
|
|
205
|
+
}
|
|
206
|
+
|
|
197
207
|
entry.expiresAt = clock.unsafeCurrentTimeMillis() + Duration.toMillis(self.idleTimeToLive)
|
|
198
208
|
if (entry.fiber) return core.void
|
|
199
209
|
|