Skip to content

Commit

Permalink
Merge branch 'main' into next-minor
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart committed Mar 11, 2024
2 parents a7860b5 + bdff193 commit 81896fe
Show file tree
Hide file tree
Showing 307 changed files with 16,666 additions and 6,894 deletions.
142 changes: 142 additions & 0 deletions .changeset/blue-apples-peel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
---
"@effect/schema": minor
---

# Breaking Changes

- The `Format` module has been removed

## `AST` module

- `Tuple` has been refactored to `TupleType`, and its `_tag` has consequently been renamed. The type of its `rest` property has changed from `Option.Option<ReadonlyArray.NonEmptyReadonlyArray<AST>>` to `ReadonlyArray<AST>`.
- `Transform` has been refactored to `Transformation`, and its `_tag` property has consequently been renamed. Its property `transformation` has now the type `TransformationKind = FinalTransformation | ComposeTransformation | TypeLiteralTransformation`.
- `createRecord` has been removed
- `AST.to` has been renamed to `AST.typeAST`
- `AST.from` has been renamed to `AST.encodedAST`
- `ExamplesAnnotation` and `DefaultAnnotation` now accept a type parameter
- `format` has been removed:
Before

```ts
AST.format(ast, verbose?)
```
Now
```ts
ast.toString(verbose?)
```
- `setAnnotation` has been removed (use `annotations` instead)
- `mergeAnnotations` has been renamed to `annotations`
- move `defaultParseOption` from `Parser.ts` to `AST.ts`
## `ParseResult` module
- The `ParseResult` module now uses classes and custom constructors have been removed:
Before
```ts
import * as ParseResult from "@effect/schema/ParseResult";

ParseResult.type(ast, actual);
```
Now
```ts
import * as ParseResult from "@effect/schema/ParseResult";

new ParseResult.Type(ast, actual);
```
- `Transform` has been refactored to `Transformation`, and its `kind` property now accepts `"Encoded"`, `"Transformation"`, or `"Type"` as values
## `Schema` module
- `uniqueSymbol` has been renamed to `uniqueSymbolFromSelf`
- `Schema.Schema.To` has been renamed to `Schema.Schema.Type`, and `Schema.to` to `Schema.typeSchema`
- `Schema.Schema.From` has been renamed to `Schema.Schema.Encoded`, and `Schema.from` to `Schema.encodedSchema`
- The type parameters of `TaggedRequest` have been swapped
- The signature of `PropertySignature` has been changed from `PropertySignature<From, FromOptional, To, ToOptional>` to `PropertySignature<ToToken extends Token, To, Key extends PropertyKey, FromToken extends Token, From, R>`
- Class APIs
- Class APIs now expose `fields` and require an identifier
```diff
-class A extends S.Class<A>()({ a: S.string }) {}
+class A extends S.Class<A>("A")({ a: S.string }) {}
```
- `element` and `rest` have been removed in favor of `array` and `tuple`:
Before
```ts
import * as S from "@effect/schema/Schema";

const schema1 = S.tuple().pipe(S.rest(S.number), S.element(S.boolean));

const schema2 = S.tuple(S.string).pipe(
S.rest(S.number),
S.element(S.boolean)
);
```
Now
```ts
import * as S from "@effect/schema/Schema";

const schema1 = S.array(S.number, S.boolean);

const schema2 = S.tuple([S.string], S.number, S.boolean);
```
- `optionalElement` has been refactored:
Before
```ts
import * as S from "@effect/schema/Schema";

const schema = S.tuple(S.string).pipe(S.optionalElement(S.number));
```
Now
```ts
import * as S from "@effect/schema/Schema";

const schema = S.tuple(S.string, S.optionalElement(S.number));
```
- use `TreeFormatter` in `BrandSchema`s
- Schema annotations interfaces have been refactored:
- add `PropertySignatureAnnotations` (baseline)
- remove `DocAnnotations`
- rename `DeclareAnnotations` to `Annotations`
- `propertySignatureAnnotations` has been replaced by the `propertySignature` constructor which owns a `annotations` method
Before
```ts
S.string.pipe(S.propertySignatureAnnotations({ description: "description" }));

S.optional(S.string, {
exact: true,
annotations: { description: "description" },
});
```
Now
```ts
S.propertySignatureDeclaration(S.string).annotations({
description: "description",
});

S.optional(S.string, { exact: true }).annotations({
description: "description",
});
```
## `Serializable` module
- The type parameters of `SerializableWithResult` and `WithResult` have been swapped
11 changes: 11 additions & 0 deletions .changeset/eight-clouds-know.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"effect": patch
---

Brand: add `refined` overload

```ts
export function refined<A extends Brand<any>>(
f: (unbranded: Brand.Unbranded<A>) => Option.Option<Brand.BrandErrors>
): Brand.Constructor<A>;
```
49 changes: 49 additions & 0 deletions .changeset/famous-ghosts-sleep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
"@effect/schema": patch
---

## `Schema` module

- enhance the `struct` API to allow records:
```ts
const schema1 = S.struct({ a: S.number }, { key: S.string, value: S.number });
// or
const schema2 = S.struct({ a: S.number }, S.record(S.string, S.number));
```
- enhance the `extend` API to allow nested (non-overlapping) fields:
```ts
const A = S.struct({ a: S.struct({ b: S.string }) });
const B = S.struct({ a: S.struct({ c: S.number }) });
const schema = S.extend(A, B);
/*
same as:
const schema = S.struct({
a: S.struct({
b: S.string,
c: S.number
})
})
*/
```
- add `Annotable` interface
- add `asSchema`
- add add `Schema.Any`, `Schema.All`, `Schema.AnyNoContext` helpers
- refactor `annotations` API to be a method within the `Schema` interface
- add support for `AST.keyof`, `AST.getPropertySignatures`, `Parser.getSearchTree` to Classes
- fix `BrandAnnotation` type and add `getBrandAnnotation`
- add `annotations?` parameter to Class constructors:

```ts
import * as AST from "@effect/schema/AST";
import * as S from "@effect/schema/Schema";

class A extends S.Class<A>()(
{
a: S.string,
},
{ description: "some description..." } // <= annotations
) {}

console.log(AST.getDescriptionAnnotation((A.ast as AST.Transform).to));
// => { _id: 'Option', _tag: 'Some', value: 'some description...' }
```
8 changes: 8 additions & 0 deletions .changeset/fresh-lizards-attend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@effect/experimental": minor
---

- `src/DevTools/Domain.ts`
- use `OptionEncoded` in `SpanFrom`
- `src/Machine.ts`
- use `ExitEncoded` in `SerializableActor` and `boot`
6 changes: 6 additions & 0 deletions .changeset/heavy-apples-sip.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@effect/rpc": minor
---

- `src/Router.ts`
- use `ExitEncoded` in `Response` and `ResponseEffect`
8 changes: 8 additions & 0 deletions .changeset/violet-rivers-repair.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@effect/platform": minor
---

- `src/Worker.ts`
- use `CauseEncoded` in `Worker` namespace
- `src/WorkerError.ts`
- use `CauseEncoded` in `Cause`
4 changes: 2 additions & 2 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ runs:
using: composite
steps:
- name: Install pnpm
uses: pnpm/action-setup@v2
uses: pnpm/action-setup@v3
- name: Install node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
cache: pnpm
node-version: ${{ inputs.node-version }}
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install dependencies
uses: ./.github/actions/setup
- run: pnpm build
Expand All @@ -28,7 +28,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install dependencies
uses: ./.github/actions/setup
- run: pnpm check
Expand All @@ -39,7 +39,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install dependencies
uses: ./.github/actions/setup
- run: pnpm circular
Expand All @@ -55,7 +55,7 @@ jobs:
shard: [1/3, 2/3, 3/3]
runtime: [Node, Bun]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install dependencies
uses: ./.github/actions/setup
- uses: oven-sh/setup-bun@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install dependencies
uses: ./.github/actions/setup
- run: pnpm docgen
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-queue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- run: gh pr checkout ${{ github.event.pull_request.number }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
id-token: write
pull-requests: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install dependencies
uses: ./.github/actions/setup
- name: Create Release Pull Request or Publish
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Initial comment
id: comment
uses: peter-evans/create-or-update-comment@v3
uses: peter-evans/create-or-update-comment@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand All @@ -42,7 +42,7 @@ jobs:
You can follow the progress [here](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}).
- name: Checkout default branch
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Checkout pull request branch
run: gh pr checkout ${{ github.event.issue.number }}
Expand Down Expand Up @@ -81,7 +81,7 @@ jobs:
echo "tags=[$output]" >> $GITHUB_OUTPUT
- name: Update comment (success)
uses: actions/github-script@v6
uses: actions/github-script@v7
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand All @@ -99,7 +99,7 @@ jobs:
- name: Update comment (failure)
if: failure()
uses: peter-evans/create-or-update-comment@v3
uses: peter-evans/create-or-update-comment@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand Down
34 changes: 0 additions & 34 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 81896fe

Please sign in to comment.