effect 4.0.0-rc.113 → 4.0.0-rc.114
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/Effect.d.ts +268 -7
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +33 -2
- package/dist/Effect.js.map +1 -1
- package/dist/Effectable.d.ts +1 -2
- package/dist/Effectable.d.ts.map +1 -1
- package/dist/Effectable.js.map +1 -1
- package/dist/FileSystem.d.ts +3 -4
- package/dist/FileSystem.d.ts.map +1 -1
- package/dist/FileSystem.js.map +1 -1
- package/dist/Match.d.ts +1 -14
- package/dist/Match.d.ts.map +1 -1
- package/dist/Schema.d.ts +4 -4
- package/dist/Schema.d.ts.map +1 -1
- package/dist/SchemaRepresentation.d.ts +39 -24
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +37 -23
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/internal/arbitrary/schema.js.map +1 -1
- package/dist/internal/effect.js +16 -8
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/schema/fromJsonSchemaDocument.js +221 -230
- package/dist/internal/schema/fromJsonSchemaDocument.js.map +1 -1
- package/dist/internal/schema/toCodeDocument.js +4 -4
- package/dist/internal/schema/toCodeDocument.js.map +1 -1
- package/dist/unstable/cli/Prompt.d.ts +6 -2
- package/dist/unstable/cli/Prompt.d.ts.map +1 -1
- package/dist/unstable/cli/Prompt.js +8 -7
- package/dist/unstable/cli/Prompt.js.map +1 -1
- package/dist/unstable/cli/internal/command.d.ts +1 -6
- package/dist/unstable/cli/internal/command.d.ts.map +1 -1
- package/dist/unstable/cli/internal/command.js +2 -0
- package/dist/unstable/cli/internal/command.js.map +1 -1
- package/package.json +1 -1
- package/src/Effect.ts +271 -7
- package/src/Effectable.ts +2 -2
- package/src/FileSystem.ts +3 -4
- package/src/Match.ts +1 -1
- package/src/Schema.ts +4 -7
- package/src/SchemaRepresentation.ts +39 -24
- package/src/internal/arbitrary/schema.ts +16 -16
- package/src/internal/effect.ts +34 -11
- package/src/internal/schema/fromJsonSchemaDocument.ts +294 -268
- package/src/internal/schema/toCodeDocument.ts +4 -4
- package/src/unstable/cli/Prompt.ts +22 -11
- package/src/unstable/cli/internal/command.ts +2 -0
package/src/Effect.ts
CHANGED
|
@@ -13941,8 +13941,8 @@ export const onExitFilter: {
|
|
|
13941
13941
|
export const cached: <A, E, R>(self: Effect<A, E, R>) => Effect<Effect<A, E, R>> = internal.cached
|
|
13942
13942
|
|
|
13943
13943
|
/**
|
|
13944
|
-
* Returns an effect that caches its result for a
|
|
13945
|
-
* known as "timeToLive" (TTL).
|
|
13944
|
+
* Returns an effect that caches its result for a fixed duration or a duration
|
|
13945
|
+
* computed from its `Exit`, known as "timeToLive" (TTL).
|
|
13946
13946
|
*
|
|
13947
13947
|
* **When to use**
|
|
13948
13948
|
*
|
|
@@ -13961,6 +13961,17 @@ export const cached: <A, E, R>(self: Effect<A, E, R>) => Effect<Effect<A, E, R>>
|
|
|
13961
13961
|
* After the specified duration has passed, the cache expires, and the effect
|
|
13962
13962
|
* will be recomputed upon the next evaluation.
|
|
13963
13963
|
*
|
|
13964
|
+
* `timeToLive` accepts a `Duration.Input` or a function from `Exit<A, E>` to
|
|
13965
|
+
* `Duration.Input`. The function runs once after each fresh computation,
|
|
13966
|
+
* including failures, so successes and failures can have different TTLs. It
|
|
13967
|
+
* does not run when the cache is created or when a cached result is reused.
|
|
13968
|
+
* The callback also receives interruption exits, which are cached for the
|
|
13969
|
+
* returned duration.
|
|
13970
|
+
*
|
|
13971
|
+
* The TTL starts when the computation completes. Concurrent callers share the
|
|
13972
|
+
* pending computation. A zero TTL expires immediately, and an infinite TTL
|
|
13973
|
+
* keeps the result indefinitely.
|
|
13974
|
+
*
|
|
13964
13975
|
* **Example** (Memoizing an effect with TTL)
|
|
13965
13976
|
*
|
|
13966
13977
|
* ```ts import.meta.vitest
|
|
@@ -13985,6 +13996,26 @@ export const cached: <A, E, R>(self: Effect<A, E, R>) => Effect<Effect<A, E, R>>
|
|
|
13985
13996
|
* output // => ["expensive task...", "result 1", "result 1", "result 1"]
|
|
13986
13997
|
* ```
|
|
13987
13998
|
*
|
|
13999
|
+
* **Example** (Caching successes while retrying failures)
|
|
14000
|
+
*
|
|
14001
|
+
* ```ts import.meta.vitest
|
|
14002
|
+
* import { Effect, Exit } from "effect"
|
|
14003
|
+
*
|
|
14004
|
+
* let attempts = 0
|
|
14005
|
+
* const task = Effect.suspend(() =>
|
|
14006
|
+
* ++attempts === 1 ? Effect.fail("temporary failure") : Effect.succeed(42)
|
|
14007
|
+
* )
|
|
14008
|
+
* const program = Effect.gen(function*() {
|
|
14009
|
+
* const cached = yield* task.pipe(
|
|
14010
|
+
* Effect.cachedWithTTL((exit) => Exit.isSuccess(exit) ? "1 hour" : 0)
|
|
14011
|
+
* )
|
|
14012
|
+
* yield* Effect.exit(cached)
|
|
14013
|
+
* return yield* cached
|
|
14014
|
+
* })
|
|
14015
|
+
*
|
|
14016
|
+
* Effect.runSync(program) // => 42
|
|
14017
|
+
* ```
|
|
14018
|
+
*
|
|
13988
14019
|
* @see {@link cached} for a similar function that caches the result
|
|
13989
14020
|
* indefinitely.
|
|
13990
14021
|
* @see {@link cachedInvalidateWithTTL} for a similar function that includes an
|
|
@@ -13994,8 +14025,8 @@ export const cached: <A, E, R>(self: Effect<A, E, R>) => Effect<Effect<A, E, R>>
|
|
|
13994
14025
|
*/
|
|
13995
14026
|
export const cachedWithTTL: {
|
|
13996
14027
|
/**
|
|
13997
|
-
* Returns an effect that caches its result for a
|
|
13998
|
-
* known as "timeToLive" (TTL).
|
|
14028
|
+
* Returns an effect that caches its result for a fixed duration or a duration
|
|
14029
|
+
* computed from its `Exit`, known as "timeToLive" (TTL).
|
|
13999
14030
|
*
|
|
14000
14031
|
* **When to use**
|
|
14001
14032
|
*
|
|
@@ -14014,6 +14045,17 @@ export const cachedWithTTL: {
|
|
|
14014
14045
|
* After the specified duration has passed, the cache expires, and the effect
|
|
14015
14046
|
* will be recomputed upon the next evaluation.
|
|
14016
14047
|
*
|
|
14048
|
+
* `timeToLive` accepts a `Duration.Input` or a function from `Exit<A, E>` to
|
|
14049
|
+
* `Duration.Input`. The function runs once after each fresh computation,
|
|
14050
|
+
* including failures, so successes and failures can have different TTLs. It
|
|
14051
|
+
* does not run when the cache is created or when a cached result is reused.
|
|
14052
|
+
* The callback also receives interruption exits, which are cached for the
|
|
14053
|
+
* returned duration.
|
|
14054
|
+
*
|
|
14055
|
+
* The TTL starts when the computation completes. Concurrent callers share the
|
|
14056
|
+
* pending computation. A zero TTL expires immediately, and an infinite TTL
|
|
14057
|
+
* keeps the result indefinitely.
|
|
14058
|
+
*
|
|
14017
14059
|
* **Example** (Memoizing an effect with TTL)
|
|
14018
14060
|
*
|
|
14019
14061
|
* ```ts import.meta.vitest
|
|
@@ -14038,6 +14080,110 @@ export const cachedWithTTL: {
|
|
|
14038
14080
|
* output // => ["expensive task...", "result 1", "result 1", "result 1"]
|
|
14039
14081
|
* ```
|
|
14040
14082
|
*
|
|
14083
|
+
* **Example** (Caching successes while retrying failures)
|
|
14084
|
+
*
|
|
14085
|
+
* ```ts import.meta.vitest
|
|
14086
|
+
* import { Effect, Exit } from "effect"
|
|
14087
|
+
*
|
|
14088
|
+
* let attempts = 0
|
|
14089
|
+
* const task = Effect.suspend(() =>
|
|
14090
|
+
* ++attempts === 1 ? Effect.fail("temporary failure") : Effect.succeed(42)
|
|
14091
|
+
* )
|
|
14092
|
+
* const program = Effect.gen(function*() {
|
|
14093
|
+
* const cached = yield* task.pipe(
|
|
14094
|
+
* Effect.cachedWithTTL((exit) => Exit.isSuccess(exit) ? "1 hour" : 0)
|
|
14095
|
+
* )
|
|
14096
|
+
* yield* Effect.exit(cached)
|
|
14097
|
+
* return yield* cached
|
|
14098
|
+
* })
|
|
14099
|
+
*
|
|
14100
|
+
* Effect.runSync(program) // => 42
|
|
14101
|
+
* ```
|
|
14102
|
+
*
|
|
14103
|
+
* @see {@link cached} for a similar function that caches the result
|
|
14104
|
+
* indefinitely.
|
|
14105
|
+
* @see {@link cachedInvalidateWithTTL} for a similar function that includes an
|
|
14106
|
+
* additional effect for manually invalidating the cached value.
|
|
14107
|
+
* @category caching
|
|
14108
|
+
* @since 2.0.0
|
|
14109
|
+
*/
|
|
14110
|
+
<A, E>(timeToLive: (exit: Exit.Exit<A, E>) => Duration.Input): <R>(self: Effect<A, E, R>) => Effect<Effect<A, E, R>>
|
|
14111
|
+
/**
|
|
14112
|
+
* Returns an effect that caches its result for a fixed duration or a duration
|
|
14113
|
+
* computed from its `Exit`, known as "timeToLive" (TTL).
|
|
14114
|
+
*
|
|
14115
|
+
* **When to use**
|
|
14116
|
+
*
|
|
14117
|
+
* Use when you need a costly effect result to be reused for a bounded duration
|
|
14118
|
+
* before being recomputed.
|
|
14119
|
+
*
|
|
14120
|
+
* **Details**
|
|
14121
|
+
*
|
|
14122
|
+
* This function is used to cache the result of an effect for a specified amount
|
|
14123
|
+
* of time. This means that the first time the effect is evaluated, its result
|
|
14124
|
+
* is computed and stored.
|
|
14125
|
+
*
|
|
14126
|
+
* If the effect is evaluated again within the specified `timeToLive`, the
|
|
14127
|
+
* cached result will be used, avoiding recomputation.
|
|
14128
|
+
*
|
|
14129
|
+
* After the specified duration has passed, the cache expires, and the effect
|
|
14130
|
+
* will be recomputed upon the next evaluation.
|
|
14131
|
+
*
|
|
14132
|
+
* `timeToLive` accepts a `Duration.Input` or a function from `Exit<A, E>` to
|
|
14133
|
+
* `Duration.Input`. The function runs once after each fresh computation,
|
|
14134
|
+
* including failures, so successes and failures can have different TTLs. It
|
|
14135
|
+
* does not run when the cache is created or when a cached result is reused.
|
|
14136
|
+
* The callback also receives interruption exits, which are cached for the
|
|
14137
|
+
* returned duration.
|
|
14138
|
+
*
|
|
14139
|
+
* The TTL starts when the computation completes. Concurrent callers share the
|
|
14140
|
+
* pending computation. A zero TTL expires immediately, and an infinite TTL
|
|
14141
|
+
* keeps the result indefinitely.
|
|
14142
|
+
*
|
|
14143
|
+
* **Example** (Memoizing an effect with TTL)
|
|
14144
|
+
*
|
|
14145
|
+
* ```ts import.meta.vitest
|
|
14146
|
+
* import { Effect } from "effect"
|
|
14147
|
+
* const output: Array<unknown> = []
|
|
14148
|
+
* const record = (value: unknown) => Effect.sync(() => { output.push(value) })
|
|
14149
|
+
*
|
|
14150
|
+
* let i = 1
|
|
14151
|
+
* const expensiveTask = Effect.sync(() => {
|
|
14152
|
+
* void output.push("expensive task...")
|
|
14153
|
+
* return `result ${i++}`
|
|
14154
|
+
* })
|
|
14155
|
+
*
|
|
14156
|
+
* const program = Effect.gen(function*() {
|
|
14157
|
+
* const cached = yield* Effect.cachedWithTTL(expensiveTask, "1 hour")
|
|
14158
|
+
* yield* cached.pipe(Effect.andThen(record))
|
|
14159
|
+
* yield* cached.pipe(Effect.andThen(record))
|
|
14160
|
+
* yield* cached.pipe(Effect.andThen(record))
|
|
14161
|
+
* })
|
|
14162
|
+
*
|
|
14163
|
+
* Effect.runSync(program)
|
|
14164
|
+
* output // => ["expensive task...", "result 1", "result 1", "result 1"]
|
|
14165
|
+
* ```
|
|
14166
|
+
*
|
|
14167
|
+
* **Example** (Caching successes while retrying failures)
|
|
14168
|
+
*
|
|
14169
|
+
* ```ts import.meta.vitest
|
|
14170
|
+
* import { Effect, Exit } from "effect"
|
|
14171
|
+
*
|
|
14172
|
+
* let attempts = 0
|
|
14173
|
+
* const task = Effect.suspend(() =>
|
|
14174
|
+
* ++attempts === 1 ? Effect.fail("temporary failure") : Effect.succeed(42)
|
|
14175
|
+
* )
|
|
14176
|
+
* const program = Effect.gen(function*() {
|
|
14177
|
+
* const cached = yield* task.pipe(
|
|
14178
|
+
* Effect.cachedWithTTL((exit) => Exit.isSuccess(exit) ? "1 hour" : 0)
|
|
14179
|
+
* )
|
|
14180
|
+
* yield* Effect.exit(cached)
|
|
14181
|
+
* return yield* cached
|
|
14182
|
+
* })
|
|
14183
|
+
*
|
|
14184
|
+
* Effect.runSync(program) // => 42
|
|
14185
|
+
* ```
|
|
14186
|
+
*
|
|
14041
14187
|
* @see {@link cached} for a similar function that caches the result
|
|
14042
14188
|
* indefinitely.
|
|
14043
14189
|
* @see {@link cachedInvalidateWithTTL} for a similar function that includes an
|
|
@@ -14047,8 +14193,92 @@ export const cachedWithTTL: {
|
|
|
14047
14193
|
*/
|
|
14048
14194
|
(timeToLive: Duration.Input): <A, E, R>(self: Effect<A, E, R>) => Effect<Effect<A, E, R>>
|
|
14049
14195
|
/**
|
|
14050
|
-
* Returns an effect that caches its result for a
|
|
14051
|
-
* known as "timeToLive" (TTL).
|
|
14196
|
+
* Returns an effect that caches its result for a fixed duration or a duration
|
|
14197
|
+
* computed from its `Exit`, known as "timeToLive" (TTL).
|
|
14198
|
+
*
|
|
14199
|
+
* **When to use**
|
|
14200
|
+
*
|
|
14201
|
+
* Use when you need a costly effect result to be reused for a bounded duration
|
|
14202
|
+
* before being recomputed.
|
|
14203
|
+
*
|
|
14204
|
+
* **Details**
|
|
14205
|
+
*
|
|
14206
|
+
* This function is used to cache the result of an effect for a specified amount
|
|
14207
|
+
* of time. This means that the first time the effect is evaluated, its result
|
|
14208
|
+
* is computed and stored.
|
|
14209
|
+
*
|
|
14210
|
+
* If the effect is evaluated again within the specified `timeToLive`, the
|
|
14211
|
+
* cached result will be used, avoiding recomputation.
|
|
14212
|
+
*
|
|
14213
|
+
* After the specified duration has passed, the cache expires, and the effect
|
|
14214
|
+
* will be recomputed upon the next evaluation.
|
|
14215
|
+
*
|
|
14216
|
+
* `timeToLive` accepts a `Duration.Input` or a function from `Exit<A, E>` to
|
|
14217
|
+
* `Duration.Input`. The function runs once after each fresh computation,
|
|
14218
|
+
* including failures, so successes and failures can have different TTLs. It
|
|
14219
|
+
* does not run when the cache is created or when a cached result is reused.
|
|
14220
|
+
* The callback also receives interruption exits, which are cached for the
|
|
14221
|
+
* returned duration.
|
|
14222
|
+
*
|
|
14223
|
+
* The TTL starts when the computation completes. Concurrent callers share the
|
|
14224
|
+
* pending computation. A zero TTL expires immediately, and an infinite TTL
|
|
14225
|
+
* keeps the result indefinitely.
|
|
14226
|
+
*
|
|
14227
|
+
* **Example** (Memoizing an effect with TTL)
|
|
14228
|
+
*
|
|
14229
|
+
* ```ts import.meta.vitest
|
|
14230
|
+
* import { Effect } from "effect"
|
|
14231
|
+
* const output: Array<unknown> = []
|
|
14232
|
+
* const record = (value: unknown) => Effect.sync(() => { output.push(value) })
|
|
14233
|
+
*
|
|
14234
|
+
* let i = 1
|
|
14235
|
+
* const expensiveTask = Effect.sync(() => {
|
|
14236
|
+
* void output.push("expensive task...")
|
|
14237
|
+
* return `result ${i++}`
|
|
14238
|
+
* })
|
|
14239
|
+
*
|
|
14240
|
+
* const program = Effect.gen(function*() {
|
|
14241
|
+
* const cached = yield* Effect.cachedWithTTL(expensiveTask, "1 hour")
|
|
14242
|
+
* yield* cached.pipe(Effect.andThen(record))
|
|
14243
|
+
* yield* cached.pipe(Effect.andThen(record))
|
|
14244
|
+
* yield* cached.pipe(Effect.andThen(record))
|
|
14245
|
+
* })
|
|
14246
|
+
*
|
|
14247
|
+
* Effect.runSync(program)
|
|
14248
|
+
* output // => ["expensive task...", "result 1", "result 1", "result 1"]
|
|
14249
|
+
* ```
|
|
14250
|
+
*
|
|
14251
|
+
* **Example** (Caching successes while retrying failures)
|
|
14252
|
+
*
|
|
14253
|
+
* ```ts import.meta.vitest
|
|
14254
|
+
* import { Effect, Exit } from "effect"
|
|
14255
|
+
*
|
|
14256
|
+
* let attempts = 0
|
|
14257
|
+
* const task = Effect.suspend(() =>
|
|
14258
|
+
* ++attempts === 1 ? Effect.fail("temporary failure") : Effect.succeed(42)
|
|
14259
|
+
* )
|
|
14260
|
+
* const program = Effect.gen(function*() {
|
|
14261
|
+
* const cached = yield* task.pipe(
|
|
14262
|
+
* Effect.cachedWithTTL((exit) => Exit.isSuccess(exit) ? "1 hour" : 0)
|
|
14263
|
+
* )
|
|
14264
|
+
* yield* Effect.exit(cached)
|
|
14265
|
+
* return yield* cached
|
|
14266
|
+
* })
|
|
14267
|
+
*
|
|
14268
|
+
* Effect.runSync(program) // => 42
|
|
14269
|
+
* ```
|
|
14270
|
+
*
|
|
14271
|
+
* @see {@link cached} for a similar function that caches the result
|
|
14272
|
+
* indefinitely.
|
|
14273
|
+
* @see {@link cachedInvalidateWithTTL} for a similar function that includes an
|
|
14274
|
+
* additional effect for manually invalidating the cached value.
|
|
14275
|
+
* @category caching
|
|
14276
|
+
* @since 2.0.0
|
|
14277
|
+
*/
|
|
14278
|
+
<A, E>(timeToLive: Duration.Input | ((exit: Exit.Exit<A, E>) => Duration.Input)): <R>(self: Effect<A, E, R>) => Effect<Effect<A, E, R>>
|
|
14279
|
+
/**
|
|
14280
|
+
* Returns an effect that caches its result for a fixed duration or a duration
|
|
14281
|
+
* computed from its `Exit`, known as "timeToLive" (TTL).
|
|
14052
14282
|
*
|
|
14053
14283
|
* **When to use**
|
|
14054
14284
|
*
|
|
@@ -14067,6 +14297,17 @@ export const cachedWithTTL: {
|
|
|
14067
14297
|
* After the specified duration has passed, the cache expires, and the effect
|
|
14068
14298
|
* will be recomputed upon the next evaluation.
|
|
14069
14299
|
*
|
|
14300
|
+
* `timeToLive` accepts a `Duration.Input` or a function from `Exit<A, E>` to
|
|
14301
|
+
* `Duration.Input`. The function runs once after each fresh computation,
|
|
14302
|
+
* including failures, so successes and failures can have different TTLs. It
|
|
14303
|
+
* does not run when the cache is created or when a cached result is reused.
|
|
14304
|
+
* The callback also receives interruption exits, which are cached for the
|
|
14305
|
+
* returned duration.
|
|
14306
|
+
*
|
|
14307
|
+
* The TTL starts when the computation completes. Concurrent callers share the
|
|
14308
|
+
* pending computation. A zero TTL expires immediately, and an infinite TTL
|
|
14309
|
+
* keeps the result indefinitely.
|
|
14310
|
+
*
|
|
14070
14311
|
* **Example** (Memoizing an effect with TTL)
|
|
14071
14312
|
*
|
|
14072
14313
|
* ```ts import.meta.vitest
|
|
@@ -14091,6 +14332,26 @@ export const cachedWithTTL: {
|
|
|
14091
14332
|
* output // => ["expensive task...", "result 1", "result 1", "result 1"]
|
|
14092
14333
|
* ```
|
|
14093
14334
|
*
|
|
14335
|
+
* **Example** (Caching successes while retrying failures)
|
|
14336
|
+
*
|
|
14337
|
+
* ```ts import.meta.vitest
|
|
14338
|
+
* import { Effect, Exit } from "effect"
|
|
14339
|
+
*
|
|
14340
|
+
* let attempts = 0
|
|
14341
|
+
* const task = Effect.suspend(() =>
|
|
14342
|
+
* ++attempts === 1 ? Effect.fail("temporary failure") : Effect.succeed(42)
|
|
14343
|
+
* )
|
|
14344
|
+
* const program = Effect.gen(function*() {
|
|
14345
|
+
* const cached = yield* task.pipe(
|
|
14346
|
+
* Effect.cachedWithTTL((exit) => Exit.isSuccess(exit) ? "1 hour" : 0)
|
|
14347
|
+
* )
|
|
14348
|
+
* yield* Effect.exit(cached)
|
|
14349
|
+
* return yield* cached
|
|
14350
|
+
* })
|
|
14351
|
+
*
|
|
14352
|
+
* Effect.runSync(program) // => 42
|
|
14353
|
+
* ```
|
|
14354
|
+
*
|
|
14094
14355
|
* @see {@link cached} for a similar function that caches the result
|
|
14095
14356
|
* indefinitely.
|
|
14096
14357
|
* @see {@link cachedInvalidateWithTTL} for a similar function that includes an
|
|
@@ -14098,7 +14359,10 @@ export const cachedWithTTL: {
|
|
|
14098
14359
|
* @category caching
|
|
14099
14360
|
* @since 2.0.0
|
|
14100
14361
|
*/
|
|
14101
|
-
<A, E, R>(
|
|
14362
|
+
<A, E, R>(
|
|
14363
|
+
self: Effect<A, E, R>,
|
|
14364
|
+
timeToLive: Duration.Input | ((exit: Exit.Exit<A, E>) => Duration.Input)
|
|
14365
|
+
): Effect<Effect<A, E, R>>
|
|
14102
14366
|
} = internal.cachedWithTTL
|
|
14103
14367
|
|
|
14104
14368
|
/**
|
package/src/Effectable.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import type * as Effect from "./Effect.ts"
|
|
10
10
|
import type * as Fiber from "./Fiber.ts"
|
|
11
|
-
import {
|
|
11
|
+
import { evaluate, makePrimitiveProto } from "./internal/core.ts"
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Create a low-level `Effect` prototype.
|
|
@@ -78,7 +78,7 @@ type AsEffectReturn<Self> = Self extends {
|
|
|
78
78
|
|
|
79
79
|
declare abstract class MixinBase extends Class<any, any, any> {
|
|
80
80
|
constructor(...args: ReadonlyArray<any>)
|
|
81
|
-
override readonly [
|
|
81
|
+
override readonly [Effect.TypeId]: AsEffectReturn<this>[Effect.TypeId]
|
|
82
82
|
override [Symbol.iterator](): Effect.EffectIterator<AsEffectReturn<this>>
|
|
83
83
|
}
|
|
84
84
|
|
package/src/FileSystem.ts
CHANGED
|
@@ -906,10 +906,9 @@ export declare namespace File {
|
|
|
906
906
|
* permissions, and size information. This structure is returned by file
|
|
907
907
|
* stat operations.
|
|
908
908
|
*
|
|
909
|
-
* Node and Bun preserve `size` and `blksize` exactly.
|
|
910
|
-
*
|
|
911
|
-
*
|
|
912
|
-
* can therefore prevent stat and HTTP file serving even for small files.
|
|
909
|
+
* Node and Bun preserve `size` and `blksize` exactly. Optional `number`
|
|
910
|
+
* metadata is `Option.none()` when absent or outside the safe integer range.
|
|
911
|
+
* Unsafe `dev` or `mode` values fail the stat operation with `BadArgument`.
|
|
913
912
|
*
|
|
914
913
|
* **Example** (Inspecting file information)
|
|
915
914
|
*
|
package/src/Match.ts
CHANGED
|
@@ -22,7 +22,7 @@ const TypeId = internal.TypeId
|
|
|
22
22
|
|
|
23
23
|
// The conditional must stay deferred until P is inferred. Replacing it with an
|
|
24
24
|
// intersection loses contextual typing for nested generic calls (microsoft/TypeScript#52864).
|
|
25
|
-
type Contextual<P, Fallback> =
|
|
25
|
+
type Contextual<P, Fallback> = [P] extends [never] ? Fallback : P
|
|
26
26
|
|
|
27
27
|
type TagHandlers<D extends string, R, Ret> = {
|
|
28
28
|
readonly [Tag in Types.Tags<D, R> & string]: (_: Extract<R, Record<D, Tag>>) => Ret
|
package/src/Schema.ts
CHANGED
|
@@ -15512,9 +15512,6 @@ export function resolveAnnotations<S extends Constraint>(
|
|
|
15512
15512
|
export function resolveAnnotationsKey<S extends Constraint>(schema: S): Annotations.Key<S["Type"]> | undefined {
|
|
15513
15513
|
return schema.ast.context?.annotations
|
|
15514
15514
|
}
|
|
15515
|
-
/** @internal */
|
|
15516
|
-
type AnnotationSchemaConstraint = Constraint
|
|
15517
|
-
|
|
15518
15515
|
/**
|
|
15519
15516
|
* The `Annotations` namespace groups all annotation interfaces used to attach
|
|
15520
15517
|
* metadata to schemas. Annotations control documentation, validation messages,
|
|
@@ -15833,7 +15830,7 @@ export declare namespace Annotations {
|
|
|
15833
15830
|
*
|
|
15834
15831
|
* @since 4.0.0
|
|
15835
15832
|
*/
|
|
15836
|
-
readonly arbitraryConstraint?: ToArbitrary.
|
|
15833
|
+
readonly arbitraryConstraint?: ToArbitrary.FilterConstraint<any> | undefined
|
|
15837
15834
|
/**
|
|
15838
15835
|
* Marks the filter as *structural*, meaning it applies to the shape or
|
|
15839
15836
|
* structure of the container (e.g., array length, object keys) rather than
|
|
@@ -15899,7 +15896,7 @@ export declare namespace Annotations {
|
|
|
15899
15896
|
* @category models
|
|
15900
15897
|
* @since 4.0.0
|
|
15901
15898
|
*/
|
|
15902
|
-
interface
|
|
15899
|
+
interface FilterConstraint<T = unknown> extends GenerationConstraint<T> {
|
|
15903
15900
|
readonly order?: Order.Order<T> | undefined
|
|
15904
15901
|
}
|
|
15905
15902
|
/**
|
|
@@ -15908,7 +15905,7 @@ export declare namespace Annotations {
|
|
|
15908
15905
|
* @category models
|
|
15909
15906
|
* @since 4.0.0
|
|
15910
15907
|
*/
|
|
15911
|
-
interface DeclarationInput<T, Parameters extends ReadonlyArray<
|
|
15908
|
+
interface DeclarationInput<T, Parameters extends ReadonlyArray<Constraint>> {
|
|
15912
15909
|
readonly typeParameters: TypeParameters.Type<Parameters>
|
|
15913
15910
|
readonly constraint: GenerationConstraint<T> | undefined
|
|
15914
15911
|
}
|
|
@@ -15918,7 +15915,7 @@ export declare namespace Annotations {
|
|
|
15918
15915
|
* @category models
|
|
15919
15916
|
* @since 4.0.0
|
|
15920
15917
|
*/
|
|
15921
|
-
interface Declaration<T, Parameters extends ReadonlyArray<
|
|
15918
|
+
interface Declaration<T, Parameters extends ReadonlyArray<Constraint>> {
|
|
15922
15919
|
(input: DeclarationInput<T, Parameters>): SchemaAST.Link
|
|
15923
15920
|
}
|
|
15924
15921
|
}
|
|
@@ -2175,7 +2175,8 @@ const jsonSchemaRevivers: ReadonlyArray<AnyReviver> = [
|
|
|
2175
2175
|
* **Gotchas**
|
|
2176
2176
|
*
|
|
2177
2177
|
* Use `patterns: "apply"` only for trusted documents because regular expression evaluation may block for an unbounded
|
|
2178
|
-
* amount of time. `patterns: "ignore"`
|
|
2178
|
+
* amount of time. `patterns: "ignore"` can admit values the source rejects, but can also reject previously valid
|
|
2179
|
+
* values inside `oneOf` when removing constraints makes multiple branches match.
|
|
2179
2180
|
* Ignoring `patternProperties` also skips its value constraints and `additionalProperties`, because matching keys cannot
|
|
2180
2181
|
* be determined without evaluating the patterns.
|
|
2181
2182
|
* `onEnter` must return a JSON Schema object. Its result is used directly, and exceptions raised by the callback pass
|
|
@@ -2835,30 +2836,39 @@ export function fromRepresentations(
|
|
|
2835
2836
|
*
|
|
2836
2837
|
* **Details**
|
|
2837
2838
|
*
|
|
2838
|
-
*
|
|
2839
|
-
*
|
|
2840
|
-
*
|
|
2839
|
+
* Translates a Draft 2020-12 subset using Effect schemas and built-in checks. Validation follows those checks and the
|
|
2840
|
+
* decoder's parse options, so import and re-export do not guarantee identical accepted values or a lossless round trip.
|
|
2841
|
+
* Import errors explain the unsupported constraint or reference and include its source path.
|
|
2841
2842
|
*
|
|
2842
2843
|
* **Gotchas**
|
|
2843
2844
|
*
|
|
2844
|
-
* -
|
|
2845
|
-
*
|
|
2845
|
+
* - `{ not: {} }` imports as `Never`. Other uses of `not` are unsupported.
|
|
2846
|
+
* - When `additionalProperties` is `true`, `{}`, or omitted, additional values use `Schema.Json` and are retained.
|
|
2847
|
+
* Closed objects normally strip excess properties by default; pass `onExcessProperty: "error"` to reject them.
|
|
2848
|
+
* Closed empty objects instead use `Schema.Record(Schema.String, Schema.Never)` and reject string-keyed entries
|
|
2849
|
+
* regardless of that option.
|
|
2850
|
+
* Object keyword scopes still constrain declared properties in intersections. Combinations requiring index
|
|
2851
|
+
* signatures that exclude explicit properties or patterned keys are rejected with an explanation of the limitation.
|
|
2852
|
+
* - Property count and name checks run on the decoded object, after excess properties have been stripped.
|
|
2853
|
+
* - String length checks count UTF-16 code units. `integer` uses `Schema.isInt`, which requires safe integers.
|
|
2854
|
+
* Applied patterns use `Schema.isPattern` without adding a Unicode flag.
|
|
2855
|
+
* - `$dynamicRef`, `contains`, `dependentRequired`, `dependentSchemas`, active `if` / `then` / `else`,
|
|
2856
|
+
* `unevaluatedItems`, and `unevaluatedProperties` are rejected with an error identifying the unsupported keyword. Inactive
|
|
2846
2857
|
* conditional keywords and `minContains` / `maxContains` without `contains` have no validation effect and are ignored.
|
|
2847
|
-
* - Objects and arrays used as `const` values or `enum` members
|
|
2848
|
-
*
|
|
2858
|
+
* - Objects and arrays used as `const` values or `enum` members are rejected. Only strings, numbers, booleans, and null
|
|
2859
|
+
* are supported.
|
|
2849
2860
|
* - Intersections of overlapping unions are limited to disjoint root-type partitions and finite primitive `anyOf`
|
|
2850
|
-
* literal sets. Other union intersections, including cases that would duplicate a nested choice,
|
|
2851
|
-
* `Unsupported intersection of overlapping unions` error.
|
|
2861
|
+
* literal sets. Other union intersections, including cases that would duplicate a nested choice, are rejected.
|
|
2852
2862
|
* - Unknown extension keywords are ignored and their semantics are not enforced.
|
|
2853
2863
|
* - Only direct local references to top-level definitions in the form `#/$defs/<escaped-token>` are supported. Root
|
|
2854
|
-
* references, external references, and pointers below a definition
|
|
2855
|
-
*
|
|
2864
|
+
* references, external references, and pointers below a definition are rejected with the supported reference format.
|
|
2865
|
+
* Missing definitions are reported by name. References reached inside nested schema
|
|
2866
|
+
* resources introduced by `$id` are rejected instead of resolved against the top-level definitions.
|
|
2856
2867
|
* - Built-in declarations and checks are reconstructed with importer-owned revivers.
|
|
2857
2868
|
* - Pattern constraints reached during translation cause an error by default. Use `patterns: "apply"` only for trusted
|
|
2858
|
-
* documents, or `patterns: "ignore"` to
|
|
2859
|
-
*
|
|
2860
|
-
* - `onEnter` results replace the corresponding input nodes
|
|
2861
|
-
* document.
|
|
2869
|
+
* documents, or `patterns: "ignore"` to skip them. Ignoring patterns can both admit invalid values and reject valid
|
|
2870
|
+
* values when `oneOf` branches start overlapping.
|
|
2871
|
+
* - `onEnter` results replace the corresponding input nodes before translation.
|
|
2862
2872
|
* - Callback results are used directly, and exceptions raised by a callback pass through unchanged.
|
|
2863
2873
|
*
|
|
2864
2874
|
* @see {@link fromJsonSchemaMultiDocument} for multiple roots sharing definitions
|
|
@@ -2881,21 +2891,26 @@ export function fromJsonSchemaDocument(
|
|
|
2881
2891
|
*
|
|
2882
2892
|
* Use when multiple imported roots share reachable definitions, aliases, or recursion.
|
|
2883
2893
|
*
|
|
2894
|
+
* **Details**
|
|
2895
|
+
*
|
|
2896
|
+
* Uses the same best-effort translation, built-in checks, and excess-property behavior as {@link fromJsonSchemaDocument}.
|
|
2897
|
+
*
|
|
2884
2898
|
* **Gotchas**
|
|
2885
2899
|
*
|
|
2886
2900
|
* - Only definitions reachable from a root are translated.
|
|
2887
|
-
* - Unsupported standard validation and applicator keywords
|
|
2901
|
+
* - Unsupported standard validation and applicator keywords are rejected with an error identifying the keyword. Unknown
|
|
2888
2902
|
* extension keywords are ignored and their semantics are not enforced.
|
|
2889
|
-
* - Objects and arrays used as `const` values or `enum` members
|
|
2890
|
-
*
|
|
2903
|
+
* - Objects and arrays used as `const` values or `enum` members are rejected. Only strings, numbers, booleans, and null
|
|
2904
|
+
* are supported.
|
|
2891
2905
|
* - Intersections of overlapping unions are limited to disjoint root-type partitions and finite primitive `anyOf`
|
|
2892
|
-
* literal sets. Other union intersections, including cases that would duplicate a nested choice,
|
|
2893
|
-
* `Unsupported intersection of overlapping unions` error.
|
|
2906
|
+
* literal sets. Other union intersections, including cases that would duplicate a nested choice, are rejected.
|
|
2894
2907
|
* - Only direct local references to top-level definitions in the form `#/$defs/<escaped-token>` are supported. Root
|
|
2895
|
-
* references, external references, and pointers below a definition
|
|
2896
|
-
*
|
|
2908
|
+
* references, external references, and pointers below a definition are rejected with the supported reference format.
|
|
2909
|
+
* Missing definitions are reported by name. References reached inside nested schema
|
|
2910
|
+
* resources introduced by `$id` are rejected instead of resolved against the top-level definitions.
|
|
2897
2911
|
* - Pattern constraints reached during translation cause an error by default. Use `patterns: "apply"` only for trusted
|
|
2898
|
-
* documents, or `patterns: "ignore"` to
|
|
2912
|
+
* documents, or `patterns: "ignore"` to skip them. Ignoring patterns can both admit invalid values and reject valid
|
|
2913
|
+
* values when `oneOf` branches start overlapping.
|
|
2899
2914
|
* - Callback results are used directly, and exceptions raised by a callback pass through unchanged.
|
|
2900
2915
|
*
|
|
2901
2916
|
* @see {@link fromJsonSchemaDocument} for a single root
|