Files
effect/packages/schema/CHANGELOG.md
T
github-actions[bot]andgithub-actions[bot] e1e0b953c9 Version Packages (#2095)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-02-12 10:05:07 +13:00

108 KiB

@effect/schema

0.62.2

Patch Changes

0.62.1

Patch Changes

  • Updated dependencies [b5a8215]:
    • effect@2.3.1

0.62.0

Minor Changes

  • #2006 9a2d1c1 Thanks @github-actions! - With this change we now require a string key to be provided for all tags and renames the dear old Tag to GenericTag, so when previously you could do:

    import { Effect, Context } from "effect";
    interface Service {
      readonly _: unique symbol;
    }
    const Service = Context.Tag<
      Service,
      {
        number: Effect.Effect<never, never, number>;
      }
    >();
    

    you are now mandated to do:

    import { Effect, Context } from "effect";
    interface Service {
      readonly _: unique symbol;
    }
    const Service = Context.GenericTag<
      Service,
      {
        number: Effect.Effect<never, never, number>;
      }
    >("Service");
    

    This makes by default all tags globals and ensures better debuggaility when unexpected errors arise.

    Furthermore we introduce a new way of constructing tags that should be considered the new default:

    import { Effect, Context } from "effect";
    class Service extends Context.Tag("Service")<
      Service,
      {
        number: Effect.Effect<never, never, number>;
      }
    >() {}
    
    const program = Effect.flatMap(Service, ({ number }) => number).pipe(
      Effect.flatMap((_) => Effect.log(`number: ${_}`)),
    );
    

    this will use "Service" as the key and will create automatically an opaque identifier (the class) to be used at the type level, it does something similar to the above in a single shot.

  • #2006 1a77f72 Thanks @github-actions! - change Effect type parameters order from Effect<R, E, A> to Effect<A, E = never, R = never>

  • #2006 d3f9f4d Thanks @github-actions! - Schema: switch readonlyMapFromSelf, readonlyMap from positional arguments to a single options argument:

    Before:

    import * as S from "@effect/schema/Schema";
    
    S.readonlyMapFromSelf(S.string, S.number);
    S.readonlyMap(S.string, S.number);
    

    Now:

    import * as S from "@effect/schema/Schema";
    
    S.readonlyMapFromSelf({ key: S.string, value: S.number });
    S.readonlyMap({ key: S.string, value: S.number });
    
  • #2006 d3f9f4d Thanks @github-actions! - Schema: switch hashMapFromSelf, hashMap from positional arguments to a single options argument:

    Before:

    import * as S from "@effect/schema/Schema";
    
    S.hashMapFromSelf(S.string, S.number);
    S.hashMap(S.string, S.number);
    

    Now:

    import * as S from "@effect/schema/Schema";
    
    S.hashMapFromSelf({ key: S.string, value: S.number });
    S.hashMap({ key: S.string, value: S.number });
    
  • #2006 d3f9f4d Thanks @github-actions! - Schema: switch causeFromSelf, cause from positional arguments to a single options argument:

    Before:

    import * as S from "@effect/schema/Schema";
    
    S.causeFromSelf(S.string);
    S.causeFromSelf(S.string, S.unknown);
    S.cause(S.string);
    S.cause(S.string, S.unknown);
    

    Now:

    import * as S from "@effect/schema/Schema";
    
    S.causeFromSelf({ error: S.string });
    S.causeFromSelf({ error: S.string, defect: S.unknown });
    S.cause({ error: S.string });
    S.cause({ error: S.string, defect: S.unknown });
    
  • #2006 d3f9f4d Thanks @github-actions! - Schema: switch exitFromSelf, exit from positional arguments to a single options argument:

    Before:

    import * as S from "@effect/schema/Schema";
    
    S.exitFromSelf(S.string, S.number);
    S.exit(S.string, S.number);
    

    Now:

    import * as S from "@effect/schema/Schema";
    
    S.exitFromSelf({ failure: S.string, success: S.number });
    S.exit({ failure: S.string, success: S.number });
    
  • #2006 a34dbdc Thanks @github-actions! - - Schema: change type parameters order from Schema<R, I, A> to Schema<A, I = A, R = never>

    • Serializable: change type parameters order from Serializable<R, I, A> to Serializable<A, I, R>
    • Class: change type parameters order from Class<R, I, A, C, Self, Inherited> to Class<A, I, R, C, Self, Inherited>
    • PropertySignature: change type parameters order from PropertySignature<R, From, FromIsOptional, To, ToIsOptional> to PropertySignature<From, FromIsOptional, To, ToIsOptional, R = never>
  • #2006 d3f9f4d Thanks @github-actions! - Schema: switch eitherFromSelf, either, eitherFromUnion from positional arguments to a single options argument:

    Before:

    import * as S from "@effect/schema/Schema";
    
    S.eitherFromSelf(S.string, S.number);
    S.either(S.string, S.number);
    S.eitherFromUnion(S.string, S.number);
    

    Now:

    import * as S from "@effect/schema/Schema";
    
    S.eitherFromSelf({ left: S.string, right: S.number });
    S.either({ left: S.string, right: S.number });
    S.eitherFromUnion({ left: S.string, right: S.number });
    
  • #2006 02c3461 Thanks @github-actions! - With this change we remove the Data.Data type and we make Equal.Equal & Hash.Hash implicit traits.

    The main reason is that Data.Data<A> was structurally equivalent to A & Equal.Equal but extending Equal.Equal doesn't mean that the equality is implemented by-value, so the type was simply adding noise without gaining any level of safety.

    The module Data remains unchanged at the value level, all the functions previously available are supposed to work in exactly the same manner.

    At the type level instead the functions return Readonly variants, so for example we have:

    import { Data } from "effect";
    
    const obj = Data.struct({
      a: 0,
      b: 1,
    });
    

    will have the obj typed as:

    declare const obj: {
      readonly a: number;
      readonly b: number;
    };
    
  • #2006 9a2d1c1 Thanks @github-actions! - This change enables Effect.serviceConstants and Effect.serviceMembers to access any constant in the service, not only the effects, namely it is now possible to do:

    import { Effect, Context } from "effect";
    
    class NumberRepo extends Context.TagClass("NumberRepo")<
      NumberRepo,
      {
        readonly numbers: Array<number>;
      }
    >() {
      static numbers = Effect.serviceConstants(NumberRepo).numbers;
    }
    
  • #2006 56b8691 Thanks @github-actions! - Fix usage of Schema.TaggedError in combination with Unify.

    When used with Unify we previously had:

    import { Schema } from "@effect/schema";
    import type { Unify } from "effect";
    
    class Err extends Schema.TaggedError<Err>()("Err", {}) {}
    
    // $ExpectType Effect<unknown, unknown, unknown>
    export type IdErr = Unify.Unify<Err>;
    

    With this fix we now have:

    import { Schema } from "@effect/schema";
    import type { Unify } from "effect";
    
    class Err extends Schema.TaggedError<Err>()("Err", {}) {}
    
    // $ExpectType Err
    export type IdErr = Unify.Unify<Err>;
    

Patch Changes

0.61.7

Patch Changes

0.61.6

Patch Changes

0.61.5

Patch Changes

0.61.4

Patch Changes

0.61.3

Patch Changes

0.61.2

Patch Changes

  • #1988 64f710a Thanks @gcanti! - Class constructor: avoid overwriting props with additionalProps, closes #1987

0.61.1

Patch Changes

0.61.0

Minor Changes

  • #1922 62b40e8 Thanks @gcanti! - Refactoring:

    • Schema:
      • refactor Schema.declare API to make it safe
      • add Schema.declare overloads
      • add encodeUnknown* APIs
      • rename parse* APIs to decodeUnknown*
      • symplify brand implementation
      • rename params to annotation in typeId annotation
      • add optional { strict: false } parameter to compose
      • Class
        • rename transform to transformOrFail
        • rename transformFrom to transformOrFailFrom
      • add hashSet and hashSetFromSelf
      • add hashMap and hashMapFromSelf
      • add list and listFromSelf
    • AST:
      • return ParseResult.ParseIssue instead of ParseResult.ParseError in all APIs
      • Declaration
        • split decode into decodeUnknown / encodeUnknown
        • remove type field
    • ParseResult
      • align mapBoth with Effect (i.e. onFailure, onSuccess handlers)
      • add missing Declaration node in ParseIssue
  • #1922 62b40e8 Thanks @gcanti! - add context tracking to Schema, closes #1873

Patch Changes

0.60.7

Patch Changes

0.60.6

Patch Changes

  • Updated dependencies [21b9edd]:
    • effect@2.1.2

0.60.5

Patch Changes

0.60.4

Patch Changes

0.60.3

Patch Changes

0.60.2

Patch Changes

0.60.1

Patch Changes

  • Updated dependencies [f7f19f6]:
    • effect@2.0.5

0.60.0

Minor Changes

  • #1913 b557a10 Thanks @gcanti! - ParseResult refactoring:

    • remove ParseResult type
    • rename mapLeft to mapError
    • rename bimap to mapBoth

Patch Changes

0.59.1

Patch Changes

0.59.0

Minor Changes

  • #1878 c4b84f7 Thanks @gcanti! - Schema: remove from/to API in favour of make in:

    • Equivalence
    • JSONSchema
    • Pretty

Patch Changes

0.58.0

Minor Changes

  • #1877 a904a73 Thanks @gcanti! - Schema: Arbitrary remove from/to API in favour of make

  • #1842 7b2f874 Thanks @fubhy! - Schema: simplify AST.createRefinement return type

  • #1842 7b2f874 Thanks @fubhy! - Schema: refactor ParseResult module:

    • add Union issue, and replace UnionMember with Union
    • add Tuple issue, and replace Index with Tuple
    • add TypeLiteral issue
    • add Transform issue
    • add Refinement issue
    • add ast field to Member
    • rename UnionMember to Member
    • Type: rename expected to ast
    • ParseError replace errors field with error field and refactor parseError constructor accordingly
    • Index replace errors field with error field
    • Key replace errors field with error field
    • Member replace errors field with error field
    • ParseError replace errors field with error field
    • make ParseError a Data.TaggedError
    • Forbidden: add actual field

Patch Changes

0.57.2

Patch Changes

  • Updated dependencies [d5a1949]:
    • effect@2.0.2

0.57.1

Patch Changes

  • Updated dependencies [16bd87d]:
    • effect@2.0.1

0.57.0

Minor Changes

Patch Changes

0.56.1

Patch Changes

  • #684 6b9585b Thanks @patroza! - improve: Actually use Arbitrary interface in to/from/unsafe signature

  • #679 0f8a8f1 Thanks @gcanti! - Schema: add annotations argument to attachPropertySignature

0.56.0

Minor Changes

0.55.0

Minor Changes

  • #649 d80b933 Thanks @gcanti! - Arbitrary: should throw on declarations without annotations

  • #669 294dfad Thanks @gcanti! - Schema: refactor parseJson to replace ParseJson and fromJson

  • #649 d80b933 Thanks @gcanti! - Schema: refactor S.optional API.

    Upgrade Guide:

    • S.optional(schema, { exact: true }) replaces the old S.optional(schema)
    • S.optional(schema, { exact: true, default: () => A }) replaces the old S.optional(schema).withDefault(() => A)
    • S.optional(schema, { exact: true, as: "Option" }) replaces the old S.optional(schema).toOption()
  • #649 d80b933 Thanks @gcanti! - Schema: replace propertySignature constructor with propertySignatureAnnotations combinator

  • #669 294dfad Thanks @gcanti! - Schema: simplify split parameters to only accept separator

  • #669 294dfad Thanks @gcanti! - Schema: remove useless combinators

    • lowercase
    • uppercase
    • trim
    • numberFromString
    • symbolFromString
    • bigintFromString
    • bigintFromNumber
    • secret
    • durationFromHrTime
    • durationFromMillis
    • durationFromNanos
    • uint8ArrayFromNumbers
    • base64
    • base64url
    • hex
    • dateFromString
    • bigDecimalFromNumber
    • bigDecimalFromString
    • not

Patch Changes

0.54.1

Patch Changes

0.54.0

Minor Changes

0.53.3

Patch Changes

0.53.2

Patch Changes

0.53.1

Patch Changes

0.53.0

Minor Changes

Patch Changes

  • #645 ece6128 Thanks @gcanti! - ensure that JSON Schema annotations can be exclusively applied to refinements

0.52.0

Minor Changes

Patch Changes

0.51.5

Patch Changes

  • #629 f690ebe Thanks @gcanti! - Schema: add filter overloading returning Option

    For more complex scenarios, you can return an Option<ParseError> type instead of a boolean. In this context, None indicates success, and Some(error) rejects the input with a specific error

0.51.4

Patch Changes

0.51.3

Patch Changes

0.51.2

Patch Changes

0.51.1

Patch Changes

0.51.0

Minor Changes

Patch Changes

0.50.0

Minor Changes

  • #593 cbc2e3f Thanks @gcanti! - ParseResult: merge failure APIs into fail

  • #607 e85aefb Thanks @gcanti! - Bug Fix: align index signature behaviour to TypeScript

  • #589 3b99569 Thanks @gcanti! - - remove ValidDate (which is just an alias of Date)

    • add DateFromString (decodes from string, output: possibly invalid Date)
  • #593 cbc2e3f Thanks @gcanti! - ParseResult: rename success to succeed (standard naming)

Patch Changes

  • #597 caeed29 Thanks @jessekelly881! - added BigDecimal

  • #585 5b27f03 Thanks @gcanti! - improve JSON Schema output:

    • rename dependencies to $defs
    • remove "type" from const schemas
    • use "oneOf" for enums and add "title"s
    • add support for record(pattern, number)
    • add "$id" and "$comment" properties
    • literals should be converted to enum instead of anyOf, closes #579
  • #603 8e21d7e Thanks @gcanti! - TreeFormatter: enhance formatActual for data types with a custom toString implementation, closes #600

0.49.4

Patch Changes

0.49.3

Patch Changes

0.49.2

Patch Changes

  • #587 64fe91f Thanks @gcanti! - DateFromSelf: its arbitrary should also generate "Invalid Date"s

0.49.1

Patch Changes

0.49.0

Minor Changes

Patch Changes

0.48.4

Patch Changes

0.48.3

Patch Changes

0.48.2

Patch Changes

0.48.1

Patch Changes

0.48.0

Minor Changes

0.47.7

Patch Changes

0.47.6

Patch Changes

0.47.5

Patch Changes

  • #553 522161a Thanks @gcanti! - Fix bug in property signature transformations when used for renaming (old key/value pair was not removed)

0.47.4

Patch Changes

  • #550 5167e2d Thanks @gcanti! - attachPropertySignature: add support for symbols as values

0.47.3

Patch Changes

0.47.2

Patch Changes

0.47.1

Patch Changes

0.47.0

Minor Changes

0.46.4

Patch Changes

0.46.3

Patch Changes

0.46.2

Patch Changes

0.46.1

Patch Changes

0.46.0

Minor Changes

0.45.8

Patch Changes

0.45.7

Patch Changes

0.45.6

Patch Changes

0.45.5

Patch Changes

0.45.4

Patch Changes

0.45.3

Patch Changes

  • #500 e9ff876 Thanks @gcanti! - Arbitrary: remove NaN while generating numeric template literals

0.45.2

Patch Changes

0.45.1

Patch Changes

  • #496 ff360c6 Thanks @gcanti! - Arbitrary: fix issue with generating optional tuple elements

0.45.0

Minor Changes

Patch Changes

0.44.0

Minor Changes

0.43.2

Patch Changes

  • #485 0a20788 Thanks @gcanti! - Arbitrary: use Math.fround when creating number constraints, closes #484

0.43.1

Patch Changes

0.43.0

Minor Changes

0.42.0

Minor Changes

0.41.1

Patch Changes

0.41.0

Minor Changes

0.40.2

Patch Changes

0.40.1

Patch Changes

0.40.0

Minor Changes

0.39.2

Patch Changes

0.39.1

Patch Changes

0.39.0

Minor Changes

0.38.0

Minor Changes

  • #439 2197496 Thanks @gcanti! - Schema: remove *Result APIs

    • decodeResult (use decode instead)
    • encodeResult (use encode instead)
    • parseResult (use parse instead)
    • validateResult (use validate instead)

Patch Changes

  • #447 0252143 Thanks @gcanti! - int filter: use Number.isSafeInteger instead of Number.isInteger

0.37.2

Patch Changes

0.37.1

Patch Changes

0.37.0

Minor Changes

0.36.5

Patch Changes

0.36.4

Patch Changes

  • #434 994a37e Thanks @gcanti! - Exclude property signatures from index signatures validations, fix #433

0.36.3

Patch Changes

0.36.2

Patch Changes

0.36.1

Patch Changes

0.36.0

Minor Changes

0.35.1

Patch Changes

0.35.0

Minor Changes

  • #401 8b1ae6b Thanks @gcanti! - backport AST changes from POC:

    • change decode in Declaration- change decode in Refinement (to filter)
    • remove isReversed from Refinement
    • add transformation to Transform (and remove decode, encode, propertySignatureTransformations)
    • refactor PropertySignature
  • #401 8b1ae6b Thanks @gcanti! - refactor annotations: keys must be symbols

  • #411 2f6c4d1 Thanks @gcanti! - rename symbol to symbolFromSelf and add symbol which decodes/encodes from/to string

  • #401 8b1ae6b Thanks @gcanti! - remove Spread in favour of /data/Types#Simplify

  • #413 20ef377 Thanks @tim-smart! - update /io

  • #401 8b1ae6b Thanks @gcanti! - fix fromBrand definition (self is a Schema<I, A> now instead of Schema)

  • #401 8b1ae6b Thanks @gcanti! - rename bigint to bigintFromSelf and BigintFromString to bigint

  • #401 8b1ae6b Thanks @gcanti! - change transformation display in error messages (from A -> B to A <-> B)

  • #401 8b1ae6b Thanks @gcanti! - move From, To to Schema namespace (conforming to the ecosystem standard)

  • #401 8b1ae6b Thanks @gcanti! - rename transformResult to transformOrFail and change signature (add additional ast parameter to transformations)

Patch Changes

0.34.0

Minor Changes

Patch Changes

0.33.2

Patch Changes

0.33.1

Patch Changes

0.33.0

Minor Changes

Patch Changes

0.32.0

Minor Changes

0.31.0

Minor Changes

0.30.4

Patch Changes

0.30.3

Patch Changes

0.30.2

Patch Changes

0.30.1

Patch Changes

0.30.0

Minor Changes

0.29.1

Patch Changes

0.29.0

Minor Changes

0.28.0

Minor Changes

0.27.0

Minor Changes

0.26.1

Patch Changes

0.26.0

Minor Changes

0.25.0

Minor Changes

0.24.0

Minor Changes

Patch Changes

0.23.0

Minor Changes

0.22.0

Minor Changes

0.21.1

Patch Changes

0.21.0

Minor Changes

0.20.3

Patch Changes

0.20.2

Patch Changes

0.20.1

Patch Changes

0.20.0

Minor Changes

0.19.3

Patch Changes

  • #285 39d3c55 Thanks @gcanti! - AST: memoize createLazy

  • #285 39d3c55 Thanks @gcanti! - Arbitrary: fix maximum call stack size exceeded when producing nested arrays and records that are too deep

0.19.2

Patch Changes

0.19.1

Patch Changes

0.19.0

Minor Changes

0.18.0

Minor Changes

0.17.5

Patch Changes

  • #272 d91a7a7 Thanks @gcanti! - pick / omit: add support for structs with property signature transformations

0.17.4

Patch Changes

0.17.3

Patch Changes

0.17.2

Patch Changes

0.17.1

Patch Changes

  • #256 162e099 Thanks @gcanti! - leverage annotations (e.g. maxLength, int, between) to improve fast-check performance

0.17.0

Minor Changes

0.16.0

Minor Changes

0.15.0

Minor Changes

0.14.1

Patch Changes

0.14.0

Minor Changes

Patch Changes

0.13.1

Patch Changes

  • #234 9ed0ee2 Thanks @gcanti! - attachPropertySignature as PropertySignatureTransformation

0.13.0

Minor Changes

0.12.1

Patch Changes

0.12.0

Minor Changes

0.11.1

Patch Changes

0.11.0

Minor Changes

Patch Changes

0.10.0

Minor Changes

0.9.1

Patch Changes

0.9.0

Minor Changes

0.8.3

Patch Changes

0.8.2

Patch Changes

0.8.1

Patch Changes

0.8.0

Minor Changes

Patch Changes

0.7.1

Patch Changes

0.7.0

Minor Changes

0.6.0

Minor Changes

Patch Changes

0.5.0

Minor Changes

  • #178 f60341f Thanks @gcanti! - merge transformEither and transformEffect into transformResult

0.4.0

Minor Changes

Patch Changes

0.3.1

Patch Changes

0.3.0

Minor Changes

Patch Changes

0.2.1

Patch Changes

0.2.0

Minor Changes

Patch Changes

0.1.0

Minor Changes

Patch Changes

0.0.5

Patch Changes

0.0.4

Patch Changes

  • #115 1555a81 Thanks @gcanti! - Optimize decoding of unions using a heuristic based on literals

0.0.3

Patch Changes

0.0.2

Patch Changes

0.0.1

Patch Changes