effect 4.0.0-beta.93 → 4.0.0-beta.94
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/Config.d.ts +1 -1
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js.map +1 -1
- package/dist/Effect.d.ts +130 -0
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +43 -0
- package/dist/Effect.js.map +1 -1
- package/dist/FileSystem.d.ts +7 -0
- package/dist/FileSystem.d.ts.map +1 -1
- package/dist/FileSystem.js +3 -0
- package/dist/FileSystem.js.map +1 -1
- package/dist/Layer.d.ts +1 -1
- package/dist/Layer.d.ts.map +1 -1
- package/dist/Layer.js +6 -3
- package/dist/Layer.js.map +1 -1
- package/dist/LayerMap.js +1 -1
- package/dist/LayerMap.js.map +1 -1
- package/dist/LayerRef.d.ts +252 -0
- package/dist/LayerRef.d.ts.map +1 -0
- package/dist/LayerRef.js +171 -0
- package/dist/LayerRef.js.map +1 -0
- package/dist/Schema.d.ts +74 -30
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaParser.d.ts +1 -1
- package/dist/SchemaParser.d.ts.map +1 -1
- package/dist/SchemaParser.js.map +1 -1
- package/dist/internal/effect.js +2 -0
- package/dist/internal/effect.js.map +1 -1
- package/dist/testing/TestSchema.d.ts +2 -2
- package/dist/testing/TestSchema.d.ts.map +1 -1
- package/dist/testing/TestSchema.js.map +1 -1
- package/dist/unstable/ai/Chat.d.ts +1 -1
- package/dist/unstable/ai/Chat.d.ts.map +1 -1
- package/dist/unstable/ai/LanguageModel.d.ts +2 -2
- package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
- package/dist/unstable/cli/Argument.d.ts +2 -2
- package/dist/unstable/cli/Argument.d.ts.map +1 -1
- package/dist/unstable/cli/Argument.js.map +1 -1
- package/dist/unstable/cli/Flag.d.ts +2 -2
- package/dist/unstable/cli/Flag.d.ts.map +1 -1
- package/dist/unstable/cli/Flag.js.map +1 -1
- package/dist/unstable/cli/Param.d.ts +2 -2
- package/dist/unstable/cli/Param.d.ts.map +1 -1
- package/dist/unstable/cli/Param.js.map +1 -1
- package/dist/unstable/cli/Primitive.js.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js +1 -0
- package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/unstable/cluster/Entity.d.ts.map +1 -1
- package/dist/unstable/cluster/Entity.js +5 -3
- package/dist/unstable/cluster/Entity.js.map +1 -1
- package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
- package/dist/unstable/cluster/Sharding.js +3 -1
- package/dist/unstable/cluster/Sharding.js.map +1 -1
- package/dist/unstable/cluster/internal/entityManager.js +3 -2
- package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
- package/dist/unstable/cluster/internal/resourceMap.js +39 -14
- package/dist/unstable/cluster/internal/resourceMap.js.map +1 -1
- package/dist/unstable/encoding/Sse.d.ts +2 -2
- package/dist/unstable/encoding/Sse.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientResponse.d.ts +1 -1
- package/dist/unstable/http/HttpClientResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientResponse.js.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.d.ts +2 -2
- package/dist/unstable/http/HttpIncomingMessage.d.ts.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.js.map +1 -1
- package/dist/unstable/http/HttpRouter.d.ts +4 -4
- package/dist/unstable/http/HttpRouter.d.ts.map +1 -1
- package/dist/unstable/http/HttpRouter.js.map +1 -1
- package/dist/unstable/http/HttpServerRequest.d.ts +8 -8
- package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerRequest.js.map +1 -1
- package/dist/unstable/http/HttpServerResponse.d.ts +1 -1
- package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerResponse.js.map +1 -1
- package/dist/unstable/http/Multipart.d.ts +2 -2
- package/dist/unstable/http/Multipart.d.ts.map +1 -1
- package/dist/unstable/http/Multipart.js.map +1 -1
- package/dist/unstable/httpapi/HttpApi.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApi.js +2 -4
- package/dist/unstable/httpapi/HttpApi.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts +7 -7
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiSchema.d.ts +1 -1
- package/dist/unstable/httpapi/HttpApiSchema.d.ts.map +1 -1
- package/dist/unstable/reactivity/Atom.d.ts +4 -4
- package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
- package/dist/unstable/reactivity/Atom.js.map +1 -1
- package/package.json +1 -1
- package/src/Config.ts +1 -1
- package/src/Effect.ts +131 -0
- package/src/FileSystem.ts +13 -0
- package/src/Layer.ts +6 -6
- package/src/LayerMap.ts +1 -1
- package/src/LayerRef.ts +379 -0
- package/src/Schema.ts +80 -33
- package/src/SchemaParser.ts +2 -2
- package/src/internal/effect.ts +19 -0
- package/src/testing/TestSchema.ts +2 -2
- package/src/unstable/ai/Chat.ts +1 -1
- package/src/unstable/ai/LanguageModel.ts +3 -3
- package/src/unstable/cli/Argument.ts +14 -7
- package/src/unstable/cli/Flag.ts +6 -3
- package/src/unstable/cli/Param.ts +6 -3
- package/src/unstable/cli/Primitive.ts +2 -2
- package/src/unstable/cluster/ClusterWorkflowEngine.ts +1 -0
- package/src/unstable/cluster/Entity.ts +13 -14
- package/src/unstable/cluster/Sharding.ts +134 -131
- package/src/unstable/cluster/internal/entityManager.ts +11 -9
- package/src/unstable/cluster/internal/resourceMap.ts +59 -25
- package/src/unstable/encoding/Sse.ts +3 -3
- package/src/unstable/http/HttpClientResponse.ts +2 -3
- package/src/unstable/http/HttpIncomingMessage.ts +4 -5
- package/src/unstable/http/HttpRouter.ts +8 -10
- package/src/unstable/http/HttpServerRequest.ts +20 -19
- package/src/unstable/http/HttpServerResponse.ts +2 -2
- package/src/unstable/http/Multipart.ts +3 -3
- package/src/unstable/httpapi/HttpApi.ts +2 -4
- package/src/unstable/httpapi/HttpApiClient.ts +2 -2
- package/src/unstable/httpapi/HttpApiEndpoint.ts +7 -7
- package/src/unstable/httpapi/HttpApiSchema.ts +1 -1
- package/src/unstable/reactivity/Atom.ts +10 -7
|
@@ -313,10 +313,9 @@ export const schemaJson = <
|
|
|
313
313
|
readonly searchParams: Readonly<Record<string, string | ReadonlyArray<string> | undefined>>
|
|
314
314
|
readonly body: any
|
|
315
315
|
}>,
|
|
316
|
-
RD
|
|
317
|
-
RE
|
|
316
|
+
RD
|
|
318
317
|
>(
|
|
319
|
-
schema: Schema.
|
|
318
|
+
schema: Schema.ConstraintCodec<A, I, RD, unknown>,
|
|
320
319
|
options?: ParseOptions | undefined
|
|
321
320
|
): Effect.Effect<
|
|
322
321
|
A,
|
|
@@ -368,10 +367,9 @@ export const schemaNoBody = <
|
|
|
368
367
|
readonly pathParams: Readonly<Record<string, string | undefined>>
|
|
369
368
|
readonly searchParams: Readonly<Record<string, string | ReadonlyArray<string> | undefined>>
|
|
370
369
|
}>,
|
|
371
|
-
RD
|
|
372
|
-
RE
|
|
370
|
+
RD
|
|
373
371
|
>(
|
|
374
|
-
schema: Schema.
|
|
372
|
+
schema: Schema.ConstraintCodec<A, I, RD, unknown>,
|
|
375
373
|
options?: ParseOptions | undefined
|
|
376
374
|
): Effect.Effect<
|
|
377
375
|
A,
|
|
@@ -410,8 +408,8 @@ export const schemaNoBody = <
|
|
|
410
408
|
* @category schemas
|
|
411
409
|
* @since 4.0.0
|
|
412
410
|
*/
|
|
413
|
-
export const schemaParams = <A, I extends Readonly<Record<string, string | ReadonlyArray<string> | undefined>>, RD
|
|
414
|
-
schema: Schema.
|
|
411
|
+
export const schemaParams = <A, I extends Readonly<Record<string, string | ReadonlyArray<string> | undefined>>, RD>(
|
|
412
|
+
schema: Schema.ConstraintCodec<A, I, RD, unknown>,
|
|
415
413
|
options?: ParseOptions | undefined
|
|
416
414
|
): Effect.Effect<A, Schema.SchemaError, HttpServerRequest.ParsedSearchParams | RouteContext | RD> => {
|
|
417
415
|
const parse = Schema.decodeUnknownEffect(schema)
|
|
@@ -429,8 +427,8 @@ export const schemaParams = <A, I extends Readonly<Record<string, string | Reado
|
|
|
429
427
|
* @category schemas
|
|
430
428
|
* @since 4.0.0
|
|
431
429
|
*/
|
|
432
|
-
export const schemaPathParams = <A, I extends Readonly<Record<string, string | undefined>>, RD
|
|
433
|
-
schema: Schema.
|
|
430
|
+
export const schemaPathParams = <A, I extends Readonly<Record<string, string | undefined>>, RD>(
|
|
431
|
+
schema: Schema.ConstraintCodec<A, I, RD, unknown>,
|
|
434
432
|
options?: ParseOptions | undefined
|
|
435
433
|
): Effect.Effect<A, Schema.SchemaError, RouteContext | RD> => {
|
|
436
434
|
const parse = Schema.decodeUnknownEffect(schema)
|
|
@@ -191,8 +191,8 @@ export const upgradeChannel = <IE = never>(): Channel.Channel<
|
|
|
191
191
|
* @category schemas
|
|
192
192
|
* @since 4.0.0
|
|
193
193
|
*/
|
|
194
|
-
export const schemaCookies = <A, I extends Readonly<Record<string, string | undefined>>, RD
|
|
195
|
-
schema: Schema.
|
|
194
|
+
export const schemaCookies = <A, I extends Readonly<Record<string, string | undefined>>, RD>(
|
|
195
|
+
schema: Schema.ConstraintCodec<A, I, RD, unknown>,
|
|
196
196
|
options?: ParseOptions | undefined
|
|
197
197
|
): Effect.Effect<A, Schema.SchemaError, RD | HttpServerRequest> => {
|
|
198
198
|
const parse = Schema.decodeUnknownEffect(schema)
|
|
@@ -205,8 +205,8 @@ export const schemaCookies = <A, I extends Readonly<Record<string, string | unde
|
|
|
205
205
|
* @category schemas
|
|
206
206
|
* @since 4.0.0
|
|
207
207
|
*/
|
|
208
|
-
export const schemaHeaders = <A, I extends Readonly<Record<string, string | undefined>>, RD
|
|
209
|
-
schema: Schema.
|
|
208
|
+
export const schemaHeaders = <A, I extends Readonly<Record<string, string | undefined>>, RD>(
|
|
209
|
+
schema: Schema.ConstraintCodec<A, I, RD, unknown>,
|
|
210
210
|
options?: ParseOptions | undefined
|
|
211
211
|
): Effect.Effect<A, Schema.SchemaError, HttpServerRequest | RD> => {
|
|
212
212
|
const parse = Schema.decodeUnknownEffect(schema)
|
|
@@ -222,10 +222,9 @@ export const schemaHeaders = <A, I extends Readonly<Record<string, string | unde
|
|
|
222
222
|
export const schemaSearchParams = <
|
|
223
223
|
A,
|
|
224
224
|
I extends Readonly<Record<string, string | ReadonlyArray<string> | undefined>>,
|
|
225
|
-
RD
|
|
226
|
-
RE
|
|
225
|
+
RD
|
|
227
226
|
>(
|
|
228
|
-
schema: Schema.
|
|
227
|
+
schema: Schema.ConstraintCodec<A, I, RD, unknown>,
|
|
229
228
|
options?: ParseOptions | undefined
|
|
230
229
|
): Effect.Effect<A, Schema.SchemaError, ParsedSearchParams | RD> => {
|
|
231
230
|
const parse = Schema.decodeUnknownEffect(schema)
|
|
@@ -242,8 +241,8 @@ export const schemaSearchParams = <
|
|
|
242
241
|
* @category schemas
|
|
243
242
|
* @since 4.0.0
|
|
244
243
|
*/
|
|
245
|
-
export const schemaBodyJson = <A,
|
|
246
|
-
schema: Schema.
|
|
244
|
+
export const schemaBodyJson = <A, RD>(
|
|
245
|
+
schema: Schema.ConstraintDecoder<A, RD>,
|
|
247
246
|
options?: ParseOptions | undefined
|
|
248
247
|
): Effect.Effect<A, HttpServerError | Schema.SchemaError, HttpServerRequest | RD> => {
|
|
249
248
|
const parse = HttpIncomingMessage.schemaBodyJson(schema, options)
|
|
@@ -265,12 +264,15 @@ const isMultipart = (request: HttpServerRequest) =>
|
|
|
265
264
|
* @category schemas
|
|
266
265
|
* @since 4.0.0
|
|
267
266
|
*/
|
|
268
|
-
export const schemaBodyForm = <A, I extends Partial<Multipart.Persisted>, RD
|
|
269
|
-
schema: Schema.
|
|
267
|
+
export const schemaBodyForm = <A, I extends Partial<Multipart.Persisted>, RD>(
|
|
268
|
+
schema: Schema.ConstraintCodec<A, I, RD, unknown>,
|
|
270
269
|
options?: ParseOptions | undefined
|
|
271
270
|
) => {
|
|
272
271
|
const parseMultipart = Multipart.schemaPersisted(schema)
|
|
273
|
-
const parseUrlParams = HttpIncomingMessage.schemaBodyUrlParams(
|
|
272
|
+
const parseUrlParams = HttpIncomingMessage.schemaBodyUrlParams(
|
|
273
|
+
schema as Schema.ConstraintCodec<A, any, RD, unknown>,
|
|
274
|
+
options
|
|
275
|
+
)
|
|
274
276
|
return Effect.flatMap(HttpServerRequest, (request): Effect.Effect<
|
|
275
277
|
A,
|
|
276
278
|
Multipart.MultipartError | Schema.SchemaError | HttpServerError,
|
|
@@ -293,10 +295,9 @@ export const schemaBodyForm = <A, I extends Partial<Multipart.Persisted>, RD, RE
|
|
|
293
295
|
export const schemaBodyUrlParams = <
|
|
294
296
|
A,
|
|
295
297
|
I extends Readonly<Record<string, string | ReadonlyArray<string> | undefined>>,
|
|
296
|
-
RD
|
|
297
|
-
RE
|
|
298
|
+
RD
|
|
298
299
|
>(
|
|
299
|
-
schema: Schema.
|
|
300
|
+
schema: Schema.ConstraintCodec<A, I, RD, unknown>,
|
|
300
301
|
options?: ParseOptions | undefined
|
|
301
302
|
): Effect.Effect<A, HttpServerError | Schema.SchemaError, HttpServerRequest | RD> => {
|
|
302
303
|
const parse = HttpIncomingMessage.schemaBodyUrlParams(schema, options)
|
|
@@ -315,8 +316,8 @@ export const schemaBodyUrlParams = <
|
|
|
315
316
|
* @category schemas
|
|
316
317
|
* @since 4.0.0
|
|
317
318
|
*/
|
|
318
|
-
export const schemaBodyMultipart = <A, I extends Partial<Multipart.Persisted>, RD
|
|
319
|
-
schema: Schema.
|
|
319
|
+
export const schemaBodyMultipart = <A, I extends Partial<Multipart.Persisted>, RD>(
|
|
320
|
+
schema: Schema.ConstraintCodec<A, I, RD, unknown>,
|
|
320
321
|
options?: ParseOptions | undefined
|
|
321
322
|
): Effect.Effect<
|
|
322
323
|
A,
|
|
@@ -342,8 +343,8 @@ export const schemaBodyMultipart = <A, I extends Partial<Multipart.Persisted>, R
|
|
|
342
343
|
* @category schemas
|
|
343
344
|
* @since 4.0.0
|
|
344
345
|
*/
|
|
345
|
-
export const schemaBodyFormJson = <A,
|
|
346
|
-
schema: Schema.
|
|
346
|
+
export const schemaBodyFormJson = <A, RD>(
|
|
347
|
+
schema: Schema.ConstraintDecoder<A, RD>,
|
|
347
348
|
options?: ParseOptions | undefined
|
|
348
349
|
) => {
|
|
349
350
|
const parseMultipart = Multipart.schemaJson(schema, options)
|
|
@@ -334,8 +334,8 @@ export const json = (
|
|
|
334
334
|
* @category constructors
|
|
335
335
|
* @since 4.0.0
|
|
336
336
|
*/
|
|
337
|
-
export const schemaJson = <A,
|
|
338
|
-
schema: Schema.
|
|
337
|
+
export const schemaJson = <A, RE>(
|
|
338
|
+
schema: Schema.ConstraintCodec<A, unknown, unknown, RE>,
|
|
339
339
|
options?: ParseOptions | undefined
|
|
340
340
|
) => {
|
|
341
341
|
const encode = Body.jsonSchema(schema, options)
|
|
@@ -333,8 +333,8 @@ export const SingleFileSchema: Schema.decodeTo<PersistedFileSchema, Schema.$Arra
|
|
|
333
333
|
* @category schemas
|
|
334
334
|
* @since 4.0.0
|
|
335
335
|
*/
|
|
336
|
-
export const schemaPersisted = <A, I extends Partial<Persisted>, RD
|
|
337
|
-
schema: Schema.
|
|
336
|
+
export const schemaPersisted = <A, I extends Partial<Persisted>, RD>(
|
|
337
|
+
schema: Schema.ConstraintCodec<A, I, RD, unknown>
|
|
338
338
|
): (input: unknown, options?: ParseOptions) => Effect.Effect<A, Schema.SchemaError, RD> =>
|
|
339
339
|
Schema.decodeUnknownEffect(schema)
|
|
340
340
|
|
|
@@ -349,7 +349,7 @@ export const schemaPersisted = <A, I extends Partial<Persisted>, RD, RE>(
|
|
|
349
349
|
* @category schemas
|
|
350
350
|
* @since 4.0.0
|
|
351
351
|
*/
|
|
352
|
-
export const schemaJson = <A,
|
|
352
|
+
export const schemaJson = <A, RD>(schema: Schema.ConstraintDecoder<A, RD>, options?: ParseOptions | undefined): {
|
|
353
353
|
(
|
|
354
354
|
field: string
|
|
355
355
|
): (persisted: Persisted) => Effect.Effect<A, Schema.SchemaError, RD>
|
|
@@ -186,9 +186,7 @@ const makeProto = <Id extends string, Groups extends HttpApiGroup.Any>(
|
|
|
186
186
|
): HttpApi<Id, Groups> => {
|
|
187
187
|
function HttpApi() {}
|
|
188
188
|
Object.setPrototypeOf(HttpApi, Proto)
|
|
189
|
-
HttpApi
|
|
190
|
-
HttpApi.annotations = options.annotations
|
|
191
|
-
return HttpApi as any
|
|
189
|
+
return Object.assign(HttpApi, options) as any
|
|
192
190
|
}
|
|
193
191
|
|
|
194
192
|
/**
|
|
@@ -206,7 +204,7 @@ const makeProto = <Id extends string, Groups extends HttpApiGroup.Any>(
|
|
|
206
204
|
export const make = <const Id extends string>(identifier: Id): HttpApi<Id, never> =>
|
|
207
205
|
makeProto({
|
|
208
206
|
identifier,
|
|
209
|
-
groups:
|
|
207
|
+
groups: {},
|
|
210
208
|
annotations: Context.empty()
|
|
211
209
|
})
|
|
212
210
|
|
|
@@ -636,10 +636,10 @@ export const urlBuilder = <Api extends HttpApi.Any>(api: Api, options?: {
|
|
|
636
636
|
const makeUrl = compilePath(endpoint.path)
|
|
637
637
|
const encodeParams = endpoint.params === undefined
|
|
638
638
|
? undefined
|
|
639
|
-
: Schema.encodeSync(endpoint.params as Schema.
|
|
639
|
+
: Schema.encodeSync(endpoint.params as unknown as Schema.ConstraintEncoder<unknown>)
|
|
640
640
|
const encodeQuery = endpoint.query === undefined
|
|
641
641
|
? undefined
|
|
642
|
-
: Schema.encodeSync(endpoint.query as Schema.
|
|
642
|
+
: Schema.encodeSync(endpoint.query as unknown as Schema.ConstraintEncoder<unknown>)
|
|
643
643
|
|
|
644
644
|
const endpointBuilder = (request?: {
|
|
645
645
|
readonly params?: unknown
|
|
@@ -1037,8 +1037,8 @@ function makeProto<
|
|
|
1037
1037
|
* @since 4.0.0
|
|
1038
1038
|
*/
|
|
1039
1039
|
export type ParamsConstraint =
|
|
1040
|
-
| Record<string, Schema.
|
|
1041
|
-
| Schema.
|
|
1040
|
+
| Record<string, Schema.Encoder<string | undefined, unknown>>
|
|
1041
|
+
| Schema.Encoder<Record<string, string | undefined>, unknown>
|
|
1042
1042
|
|
|
1043
1043
|
/**
|
|
1044
1044
|
* Constraint for header schemas: each header must encode to `string | undefined`,
|
|
@@ -1048,8 +1048,8 @@ export type ParamsConstraint =
|
|
|
1048
1048
|
* @since 4.0.0
|
|
1049
1049
|
*/
|
|
1050
1050
|
export type HeadersConstraint =
|
|
1051
|
-
| Record<string, Schema.
|
|
1052
|
-
| Schema.
|
|
1051
|
+
| Record<string, Schema.Encoder<string | undefined, unknown>>
|
|
1052
|
+
| Schema.Encoder<Record<string, string | undefined>, unknown>
|
|
1053
1053
|
|
|
1054
1054
|
/**
|
|
1055
1055
|
* Constraint for query schemas: each field must encode to `string`, an array of
|
|
@@ -1059,8 +1059,8 @@ export type HeadersConstraint =
|
|
|
1059
1059
|
* @since 4.0.0
|
|
1060
1060
|
*/
|
|
1061
1061
|
export type QueryConstraint =
|
|
1062
|
-
| Record<string, Schema.
|
|
1063
|
-
| Schema.
|
|
1062
|
+
| Record<string, Schema.Encoder<string | ReadonlyArray<string> | undefined, unknown>>
|
|
1063
|
+
| Schema.Encoder<string | ReadonlyArray<string> | undefined, unknown>
|
|
1064
1064
|
|
|
1065
1065
|
/**
|
|
1066
1066
|
* Payload schema depends on the HTTP method:
|
|
@@ -1075,7 +1075,7 @@ export type QueryConstraint =
|
|
|
1075
1075
|
*/
|
|
1076
1076
|
export type PayloadConstraint<Method extends HttpMethod> = Method extends HttpMethod.NoBody ? Record<
|
|
1077
1077
|
string,
|
|
1078
|
-
Schema.
|
|
1078
|
+
Schema.Encoder<string | ReadonlyArray<string> | undefined, unknown>
|
|
1079
1079
|
> :
|
|
1080
1080
|
Schema.Top | ReadonlyArray<Schema.Top>
|
|
1081
1081
|
|
|
@@ -2604,7 +2604,7 @@ export const refreshOnWindowFocus: <A extends Atom<any>>(self: A) => WithoutSeri
|
|
|
2604
2604
|
* @category KeyValueStore
|
|
2605
2605
|
* @since 4.0.0
|
|
2606
2606
|
*/
|
|
2607
|
-
export const kvs = <S extends Schema.
|
|
2607
|
+
export const kvs = <S extends Schema.ConstraintCodec<any, any>, const Mode extends "sync" | "async" = never>(options: {
|
|
2608
2608
|
readonly runtime: AtomRuntime<KeyValueStore.KeyValueStore, any>
|
|
2609
2609
|
readonly key: string
|
|
2610
2610
|
readonly schema: S
|
|
@@ -2669,9 +2669,12 @@ export const kvs = <S extends Schema.Codec<any, any>, const Mode extends "sync"
|
|
|
2669
2669
|
* @category search params
|
|
2670
2670
|
* @since 4.0.0
|
|
2671
2671
|
*/
|
|
2672
|
-
export const searchParam = <S extends Schema.
|
|
2673
|
-
|
|
2674
|
-
|
|
2672
|
+
export const searchParam = <S extends Schema.ConstraintCodec<any, string> = never>(
|
|
2673
|
+
name: string,
|
|
2674
|
+
options?: {
|
|
2675
|
+
readonly schema?: S | undefined
|
|
2676
|
+
}
|
|
2677
|
+
): Writable<[S] extends [never] ? string : Option.Option<S["Type"]>> => {
|
|
2675
2678
|
const decode = options?.schema && Schema.decodeExit(options.schema)
|
|
2676
2679
|
const encode = options?.schema && Schema.encodeExit(options.schema)
|
|
2677
2680
|
return writable(
|
|
@@ -2986,7 +2989,7 @@ export const serializable: {
|
|
|
2986
2989
|
* @category combinators
|
|
2987
2990
|
* @since 4.0.0
|
|
2988
2991
|
*/
|
|
2989
|
-
<R extends Atom<any>, S extends Schema.
|
|
2992
|
+
<R extends Atom<any>, S extends Schema.ConstraintCodec<Type<R>, any>>(
|
|
2990
2993
|
options: {
|
|
2991
2994
|
readonly key: string
|
|
2992
2995
|
readonly schema: S
|
|
@@ -3003,7 +3006,7 @@ export const serializable: {
|
|
|
3003
3006
|
* @category combinators
|
|
3004
3007
|
* @since 4.0.0
|
|
3005
3008
|
*/
|
|
3006
|
-
<R extends Atom<any>, S extends Schema.
|
|
3009
|
+
<R extends Atom<any>, S extends Schema.ConstraintCodec<Type<R>, any>>(
|
|
3007
3010
|
self: R,
|
|
3008
3011
|
options: {
|
|
3009
3012
|
readonly key: string
|
|
@@ -3012,7 +3015,7 @@ export const serializable: {
|
|
|
3012
3015
|
): R & Serializable<S>
|
|
3013
3016
|
} = dual(2, <R extends Atom<any>, A, I>(self: R, options: {
|
|
3014
3017
|
readonly key: string
|
|
3015
|
-
readonly schema: Schema.
|
|
3018
|
+
readonly schema: Schema.ConstraintCodec<A, I>
|
|
3016
3019
|
}): R & Serializable<any> => {
|
|
3017
3020
|
const codecJson = Schema.toCodecJson(options.schema)
|
|
3018
3021
|
return Object.assign(Object.create(Object.getPrototypeOf(self)), {
|