diff --git a/.changeset/light-foxes-buy.md b/.changeset/light-foxes-buy.md new file mode 100644 index 0000000000..257899bdd9 --- /dev/null +++ b/.changeset/light-foxes-buy.md @@ -0,0 +1,5 @@ +--- +"@effect/platform": minor +--- + +Revise the ordering of type parameters within the `SchemaStore` interface to enhance consistency diff --git a/packages/platform/src/Http/Client.ts b/packages/platform/src/Http/Client.ts index b652f13cbb..604f899978 100644 --- a/packages/platform/src/Http/Client.ts +++ b/packages/platform/src/Http/Client.ts @@ -133,7 +133,7 @@ export const catchTag: { tag: K, f: (e: Extract) => Effect.Effect ): (self: Client) => Client, R1 | R> - ( + ( self: Client, tag: K, f: (e: Extract) => Effect.Effect diff --git a/packages/platform/src/Http/IncomingMessage.ts b/packages/platform/src/Http/IncomingMessage.ts index 8e7e18e00f..3618a24322 100644 --- a/packages/platform/src/Http/IncomingMessage.ts +++ b/packages/platform/src/Http/IncomingMessage.ts @@ -69,7 +69,7 @@ export const schemaBodyJsonScoped = (schema: Schema.Schema, op * @since 1.0.0 * @category schema */ -export const schemaBodyUrlParams = >, A>( +export const schemaBodyUrlParams = >, R>( schema: Schema.Schema, options?: ParseOptions | undefined ) => { @@ -82,7 +82,7 @@ export const schemaBodyUrlParams = * @since 1.0.0 * @category schema */ -export const schemaBodyUrlParamsScoped = >, A>( +export const schemaBodyUrlParamsScoped = >, R>( schema: Schema.Schema, options?: ParseOptions | undefined ) => { @@ -97,7 +97,7 @@ export const schemaBodyUrlParamsScoped = >, A>( +export const schemaHeaders = >, R>( schema: Schema.Schema, options?: ParseOptions | undefined ) => { @@ -109,7 +109,7 @@ export const schemaHeaders = >, A>( +export const schemaHeadersScoped = >, R>( schema: Schema.Schema, options?: ParseOptions | undefined ) => { diff --git a/packages/platform/src/Http/Multipart.ts b/packages/platform/src/Http/Multipart.ts index 8f999d63bd..9bc93a1287 100644 --- a/packages/platform/src/Http/Multipart.ts +++ b/packages/platform/src/Http/Multipart.ts @@ -248,7 +248,7 @@ export const schemaJson: ( * @since 1.0.0 * @category schema */ -export const schemaPersisted: , A>( +export const schemaPersisted: , R>( schema: Schema.Schema, options?: ParseOptions | undefined ) => (persisted: Persisted) => Effect.Effect = internal.schemaPersisted diff --git a/packages/platform/src/Http/Router.ts b/packages/platform/src/Http/Router.ts index 4f71d983d4..0a83315374 100644 --- a/packages/platform/src/Http/Router.ts +++ b/packages/platform/src/Http/Router.ts @@ -194,7 +194,7 @@ export const schemaNoBody: < * @since 1.0.0 * @category route context */ -export const schemaParams: | undefined>>, A>( +export const schemaParams: | undefined>>, R>( schema: Schema.Schema, options?: ParseOptions | undefined ) => Effect.Effect = @@ -204,7 +204,7 @@ export const schemaParams: >, A>( +export const schemaPathParams: >, R>( schema: Schema.Schema, options?: ParseOptions | undefined ) => Effect.Effect = internal.schemaPathParams diff --git a/packages/platform/src/Http/ServerRequest.ts b/packages/platform/src/Http/ServerRequest.ts index a0f4861c37..509545a506 100644 --- a/packages/platform/src/Http/ServerRequest.ts +++ b/packages/platform/src/Http/ServerRequest.ts @@ -133,7 +133,7 @@ export const upgradeChannel: () => Channel< * @since 1.0.0 * @category schema */ -export const schemaCookies: >, A>( +export const schemaCookies: >, R>( schema: Schema.Schema, options?: ParseOptions | undefined ) => Effect.Effect = internal.schemaCookies @@ -142,7 +142,7 @@ export const schemaCookies: >, A>( * @since 1.0.0 * @category schema */ -export const schemaHeaders: >, A>( +export const schemaHeaders: >, R>( schema: Schema.Schema, options?: ParseOptions | undefined ) => Effect.Effect = internal.schemaHeaders @@ -151,7 +151,7 @@ export const schemaHeaders: >, A>( * @since 1.0.0 * @category schema */ -export const schemaSearchParams: | undefined>>, A>( +export const schemaSearchParams: | undefined>>, R>( schema: Schema.Schema, options?: ParseOptions | undefined ) => Effect.Effect = internal.schemaSearchParams @@ -169,7 +169,7 @@ export const schemaBodyJson: ( * @since 1.0.0 * @category schema */ -export const schemaBodyForm: , A>( +export const schemaBodyForm: , R>( schema: Schema.Schema, options?: ParseOptions | undefined ) => Effect.Effect< @@ -182,7 +182,7 @@ export const schemaBodyForm: , A>( * @since 1.0.0 * @category schema */ -export const schemaBodyUrlParams: >, A>( +export const schemaBodyUrlParams: >, R>( schema: Schema.Schema, options?: ParseOptions | undefined ) => Effect.Effect = internal.schemaBodyUrlParams @@ -191,7 +191,7 @@ export const schemaBodyUrlParams: > * @since 1.0.0 * @category schema */ -export const schemaBodyMultipart: , A>( +export const schemaBodyMultipart: , R>( schema: Schema.Schema, options?: ParseOptions | undefined ) => Effect.Effect< diff --git a/packages/platform/src/KeyValueStore.ts b/packages/platform/src/KeyValueStore.ts index bf844264d0..c974cacae9 100644 --- a/packages/platform/src/KeyValueStore.ts +++ b/packages/platform/src/KeyValueStore.ts @@ -76,7 +76,7 @@ export interface KeyValueStore { /** * Create a SchemaStore for the specified schema. */ - readonly forSchema: (schema: Schema.Schema) => SchemaStore + readonly forSchema: (schema: Schema.Schema) => SchemaStore } /** @@ -143,7 +143,7 @@ export type SchemaStoreTypeId = typeof SchemaStoreTypeId * @since 1.0.0 * @category models */ -export interface SchemaStore { +export interface SchemaStore { readonly [SchemaStoreTypeId]: SchemaStoreTypeId /** * Returns the value of the specified key if it exists. @@ -202,6 +202,6 @@ export const layerSchema: ( schema: Schema.Schema, tagIdentifier: string ) => { - readonly tag: Context.Tag, SchemaStore> - readonly layer: Layer.Layer, never, KeyValueStore> + readonly tag: Context.Tag, SchemaStore> + readonly layer: Layer.Layer, never, KeyValueStore> } = internal.layerSchema diff --git a/packages/platform/src/Transferable.ts b/packages/platform/src/Transferable.ts index 5d4a3ce9ee..2e2eebdafb 100644 --- a/packages/platform/src/Transferable.ts +++ b/packages/platform/src/Transferable.ts @@ -82,11 +82,11 @@ export const schema: { ( f: (_: I) => Iterable ): (self: Schema.Schema) => Schema.Schema - ( + ( self: Schema.Schema, f: (_: I) => Iterable ): Schema.Schema -} = dual(2, ( +} = dual(2, ( self: Schema.Schema, f: (_: I) => Iterable ) => diff --git a/packages/platform/src/internal/http/multipart.ts b/packages/platform/src/internal/http/multipart.ts index 12131ca659..79c16bd1f5 100644 --- a/packages/platform/src/internal/http/multipart.ts +++ b/packages/platform/src/internal/http/multipart.ts @@ -118,7 +118,7 @@ export const SingleFileSchema: Schema.transform< }) /** @internal */ -export const schemaPersisted = , A>( +export const schemaPersisted = , R>( schema: Schema.Schema, options?: ParseOptions | undefined ) => { diff --git a/packages/platform/src/internal/http/router.ts b/packages/platform/src/internal/http/router.ts index f46e302cce..8314ab8cfd 100644 --- a/packages/platform/src/internal/http/router.ts +++ b/packages/platform/src/internal/http/router.ts @@ -112,7 +112,7 @@ export const schemaNoBody = < } /** @internal */ -export const schemaParams = | undefined>>, A>( +export const schemaParams = | undefined>>, R>( schema: Schema.Schema, options?: ParseOptions | undefined ) => { @@ -128,7 +128,7 @@ export const schemaParams = >, A>( +export const schemaPathParams = >, R>( schema: Schema.Schema, options?: ParseOptions | undefined ) => { diff --git a/packages/platform/src/internal/http/serverRequest.ts b/packages/platform/src/internal/http/serverRequest.ts index 5783244914..f34c9629cd 100644 --- a/packages/platform/src/internal/http/serverRequest.ts +++ b/packages/platform/src/internal/http/serverRequest.ts @@ -61,7 +61,7 @@ export const searchParamsFromURL = (url: URL): ReadonlyRecord>, A>( +export const schemaCookies = >, R>( schema: Schema.Schema, options?: ParseOptions | undefined ) => { @@ -70,7 +70,7 @@ export const schemaCookies = >, A>( } /** @internal */ -export const schemaHeaders = >, A>( +export const schemaHeaders = >, R>( schema: Schema.Schema, options?: ParseOptions | undefined ) => { @@ -79,7 +79,7 @@ export const schemaHeaders = >, A>( } /** @internal */ -export const schemaSearchParams = | undefined>>, A>( +export const schemaSearchParams = | undefined>>, R>( schema: Schema.Schema, options?: ParseOptions | undefined ) => { @@ -97,7 +97,7 @@ const isMultipart = (request: ServerRequest.ServerRequest) => request.headers["content-type"]?.toLowerCase().includes("multipart/form-data") /** @internal */ -export const schemaBodyForm = , A>( +export const schemaBodyForm = , R>( schema: Schema.Schema, options?: ParseOptions | undefined ) => { @@ -116,7 +116,7 @@ export const schemaBodyForm = , A>( } /** @internal */ -export const schemaBodyUrlParams = >, A>( +export const schemaBodyUrlParams = >, R>( schema: Schema.Schema, options?: ParseOptions | undefined ) => { @@ -125,7 +125,7 @@ export const schemaBodyUrlParams = } /** @internal */ -export const schemaBodyMultipart = , A>( +export const schemaBodyMultipart = , R>( schema: Schema.Schema, options?: ParseOptions | undefined ) => { diff --git a/packages/platform/src/internal/keyValueStore.ts b/packages/platform/src/internal/keyValueStore.ts index dbba27c3eb..1ecabebaf4 100644 --- a/packages/platform/src/internal/keyValueStore.ts +++ b/packages/platform/src/internal/keyValueStore.ts @@ -71,7 +71,7 @@ export const SchemaStoreTypeId: KeyValueStore.SchemaStoreTypeId = Symbol.for( const makeSchemaStore = ( store: KeyValueStore.KeyValueStore, schema: Schema.Schema -): KeyValueStore.SchemaStore => { +): KeyValueStore.SchemaStore => { const jsonSchema = Schema.parseJson(schema) const parse = Schema.decodeUnknown(jsonSchema) const encode = Schema.encode(jsonSchema) @@ -170,7 +170,7 @@ export const layerSchema = ( schema: Schema.Schema, tagIdentifier: string ) => { - const tag = Context.GenericTag>(tagIdentifier) + const tag = Context.GenericTag>(tagIdentifier) const layer = Layer.effect(tag, Effect.map(keyValueStoreTag, (store) => store.forSchema(schema))) return { tag, layer } as const } diff --git a/packages/platform/test/KeyValueStore.test.ts b/packages/platform/test/KeyValueStore.test.ts index 1ae4c4e22d..8e66a2bce2 100644 --- a/packages/platform/test/KeyValueStore.test.ts +++ b/packages/platform/test/KeyValueStore.test.ts @@ -115,7 +115,7 @@ class User extends Schema.Class("User")({ age: Schema.Number }) {} const UserStore = KeyValueStore.layerSchema(User, "UserStore") -const runUserStore = (effect: Effect.Effect>) => +const runUserStore = (effect: Effect.Effect>) => Effect.runPromise(Effect.provide(effect, UserStore.layer.pipe(Layer.provide(KeyValueStore.layerMemory)))) describe("KeyValueStore / SchemaStore", () => {