Effect-TS / effect

An ecosystem of tools to build robust applications in TypeScript
https://effect.website
MIT License
7.71k stars 245 forks source link

add UriComponent schemas and encoding #3982

Open titouancreach opened 4 days ago

titouancreach commented 4 days ago

Sorry I resubmit https://github.com/Effect-TS/effect/pull/3851 but from a different branch of my fork so that, I can reuse main


Type

Description

Add schema (and encoding) for encodeUriComponent and decodeUriComponent.

Very useful for storing data in the url with a Schema :

import {ย Schema as S } from "effect"

const PaginationSchema = S.Struct({
  maxItemPerPage: S.Number,
  page: S.Number
})

const UrlSchema = S.compose(S.encodeUriComponent, S.parseJson(PaginationSchema))

const queryComponent = S.encodeSync(UrlSchema)({ maxItemPerPage: 10, page: 1 });

Related

changeset-bot[bot] commented 4 days ago

๐Ÿฆ‹ Changeset detected

Latest commit: 188a06b04f7c7eddb0d773d0384268ca50e43121

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 34 packages | Name | Type | | ------------------------------- | ----- | | effect | Minor | | @effect/cli | Major | | @effect/cluster-browser | Major | | @effect/cluster-node | Major | | @effect/cluster-workflow | Major | | @effect/cluster | Major | | @effect/experimental | Major | | @effect/opentelemetry | Major | | @effect/platform-browser | Major | | @effect/platform-bun | Major | | @effect/platform-node-shared | Major | | @effect/platform-node | Major | | @effect/platform | Major | | @effect/printer-ansi | Major | | @effect/printer | Major | | @effect/rpc-http | Major | | @effect/rpc | Major | | @effect/sql-clickhouse | Major | | @effect/sql-d1 | Major | | @effect/sql-drizzle | Major | | @effect/sql-kysely | Major | | @effect/sql-libsql | Major | | @effect/sql-mssql | Major | | @effect/sql-mysql2 | Major | | @effect/sql-pg | Major | | @effect/sql-sqlite-bun | Major | | @effect/sql-sqlite-node | Major | | @effect/sql-sqlite-react-native | Major | | @effect/sql-sqlite-wasm | Major | | @effect/sql | Major | | @effect/typeclass | Major | | @effect/vitest | Major | | @effect/ai | Major | | @effect/ai-openai | Major |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR