-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(deps): update effect schema 0.70 #98
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- [#3380](Effect-TS/effect#3380) [`8135294`](Effect-TS/effect@8135294) - add schemas for working with the DateTime module - Updated dependencies [[`1e0fe80`](Effect-TS/effect@1e0fe80), [`8135294`](Effect-TS/effect@8135294), [`cd255a4`](Effect-TS/effect@cd255a4), [`3845646`](Effect-TS/effect@3845646), [`2d09078`](Effect-TS/effect@2d09078), [`4bce5a0`](Effect-TS/effect@4bce5a0), [`4ddbff0`](Effect-TS/effect@4ddbff0), [`e74cc38`](Effect-TS/effect@e74cc38), [`bb069b4`](Effect-TS/effect@bb069b4), [`cd255a4`](Effect-TS/effect@cd255a4), [`7d02174`](Effect-TS/effect@7d02174)]: - effect@3.6.0 Signed-off-by: Giovanni Ravalico <15946771+suddenlyGiovanni@users.noreply.github.com>
🦋 Changeset detectedLatest commit: af30a76 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
suddenlyGiovanni
changed the title
chore(deps): update effect schema 0.79
chore(deps): update effect schema 0.70
Sep 3, 2024
## 0.70.1 ### Patch Changes - [#3347](Effect-TS/effect#3347) [`3dce357`](Effect-TS/effect@3dce357) - Enhanced Parsing with `TemplateLiteralParser`, closes #3307 In this update we've introduced a sophisticated API for more refined string parsing: `TemplateLiteralParser`. This enhancement stems from recognizing limitations in the `Schema.TemplateLiteral` and `Schema.pattern` functionalities, which effectively validate string formats without extracting structured data. **Overview of Existing Limitations** The `Schema.TemplateLiteral` function, while useful as a simple validator, only verifies that an input conforms to a specific string pattern by converting template literal definitions into regular expressions. Similarly, `Schema.pattern` employs regular expressions directly for the same purpose. Post-validation, both methods require additional manual parsing to convert the validated string into a usable data format. **Introducing TemplateLiteralParser** To address these limitations and eliminate the need for manual post-validation parsing, the new `TemplateLiteralParser` API has been developed. It not only validates the input format but also automatically parses it into a more structured and type-safe output, specifically into a **tuple** format. This new approach enhances developer productivity by reducing boilerplate code and simplifying the process of working with complex string inputs. **Example** (string based schemas) ```ts import { Schema } from "@effect/schema" // const schema: Schema.Schema<readonly [number, "a", string], `${string}a${string}`, never> const schema = Schema.TemplateLiteralParser( Schema.NumberFromString, "a", Schema.NonEmptyString ) console.log(Schema.decodeEither(schema)("100ab")) // { _id: 'Either', _tag: 'Right', right: [ 100, 'a', 'b' ] } console.log(Schema.encode(schema)([100, "a", "b"])) // { _id: 'Either', _tag: 'Right', right: '100ab' } ``` **Example** (number based schemas) ```ts import { Schema } from "@effect/schema" // const schema: Schema.Schema<readonly [number, "a"], `${number}a`, never> const schema = Schema.TemplateLiteralParser(Schema.Int, "a") console.log(Schema.decodeEither(schema)("1a")) // { _id: 'Either', _tag: 'Right', right: [ 1, 'a' ] } console.log(Schema.encode(schema)([1, "a"])) // { _id: 'Either', _tag: 'Right', right: '1a' } ``` - [#3346](Effect-TS/effect#3346) [`657fc48`](Effect-TS/effect@657fc48) - Implement `DecodingFallbackAnnotation` to manage decoding errors. ```ts export type DecodingFallbackAnnotation<A> = ( issue: ParseIssue ) => Effect<A, ParseIssue> ``` This update introduces a `decodingFallback` annotation, enabling custom handling of decoding failures in schemas. This feature allows developers to specify fallback behaviors when decoding operations encounter issues. **Example** ```ts import { Schema } from "@effect/schema" import { Effect, Either } from "effect" // Basic Fallback const schema = Schema.String.annotations({ decodingFallback: () => Either.right("<fallback>") }) console.log(Schema.decodeUnknownSync(schema)("valid input")) // Output: valid input console.log(Schema.decodeUnknownSync(schema)(null)) // Output: <fallback value> // Advanced Fallback with Logging const schemaWithLog = Schema.String.annotations({ decodingFallback: (issue) => Effect.gen(function* () { yield* Effect.log(issue._tag) yield* Effect.sleep(10) return yield* Effect.succeed("<fallback2>") }) }) Effect.runPromise(Schema.decodeUnknown(schemaWithLog)(null)).then(console.log) /* Output: timestamp=2024-07-25T13:22:37.706Z level=INFO fiber=#0 message=Type <fallback2> */ ``` Signed-off-by: Giovanni Ravalico <15946771+suddenlyGiovanni@users.noreply.github.com>
- Updated dependencies [[`510a34d`](Effect-TS/effect@510a34d), [`45dbb9f`](Effect-TS/effect@45dbb9f)]: - effect@3.6.1 Signed-off-by: Giovanni Ravalico <15946771+suddenlyGiovanni@users.noreply.github.com>
- [#3430](Effect-TS/effect#3430) [`99ad841`](Effect-TS/effect@99ad841) - Fix return types for `attachPropertySignature` function. This commit addresses an inconsistency in the return types between the curried and non-curried versions of the `attachPropertySignature` function. Previously, the curried version returned a `Schema`, while the non-curried version returned a `SchemaClass`. - Updated dependencies [[`fd4b2f6`](Effect-TS/effect@fd4b2f6)]: - effect@3.6.2 Signed-off-by: Giovanni Ravalico <15946771+suddenlyGiovanni@users.noreply.github.com>
- Updated dependencies [[`04adcac`](Effect-TS/effect@04adcac)]: - effect@3.6.3 Signed-off-by: Giovanni Ravalico <15946771+suddenlyGiovanni@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.