Skip to content

Commit

Permalink
Upgrade to the latest Effect (and all other deps), rewrite of @typed/…
Browse files Browse the repository at this point in the history
…server (#64)

* WIP: update effect to latest

* WIP: rebuilding server atop of @effect/platform

* WIP: add support for more complex security schemes

* chore: upgrade deps

* feat: finish upgrades to latest Effect

* chore: fix eslint

* chore: remove realworld for now

* Upgrade to latest Effect + Rewrite @typed/server in HttpApiBuilder style

* docs: remove mention of mocks for now

* docs: rebuild docs

* chore: lint fixes

* fix: build before all steps

* chore: Don't build twice

* chore: github ci fix
  • Loading branch information
TylorS authored Oct 5, 2024
1 parent 933e5b3 commit 3a6453d
Show file tree
Hide file tree
Showing 318 changed files with 16,814 additions and 18,732 deletions.
25 changes: 25 additions & 0 deletions .changeset/breezy-months-sin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
"@typed/vite-plugin-types": minor
"@typed/environment": minor
"@typed/vite-plugin": minor
"@typed/async-data": minor
"@typed/navigation": minor
"@typed/storybook": minor
"@typed/compiler": minor
"@typed/template": minor
"@typed/context": minor
"@typed/decoder": minor
"@typed/router": minor
"@typed/server": minor
"@typed/guard": minor
"@typed/route": minor
"@typed/core": minor
"@typed/path": minor
"@typed/wire": minor
"@typed/dom": minor
"@typed/fx": minor
"@typed/id": minor
"@typed/ui": minor
---

Upgrade to latest Effect + Rewrite @typed/server in HttpApiBuilder style
2 changes: 2 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ module.exports = {
"@typescript-eslint/no-array-constructor": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-empty-object-type": "off",
"@typescript-eslint/no-unsafe-function-type": "off",
"@effect/dprint": [
"error",
{
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ jobs:
fetch-depth: 0
- uses: ./.github/workflows/setup-repo
name: Setup Repo
- run: pnpm run build
- run: pnpm run circular

test:
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/setup-repo/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'Setup Repo'
description: 'Setup Typed Repo'
name: "Setup Repo"
description: "Setup Typed Repo"
runs:
using: "composite"
steps:
Expand All @@ -26,5 +26,6 @@ runs:
${{ runner.os }}-pnpm-store-
- run: pnpm install
shell: bash


- name: Build
run: pnpm run build
shell: bash
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[typescript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescriptreact]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
Expand Down
2 changes: 1 addition & 1 deletion docs/async-data/Schema.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Added in v1.0.0
```ts
export type FailureFrom<E> = {
readonly _tag: "Failure"
readonly cause: Schema.CauseEncoded<E>
readonly cause: Schema.CauseEncoded<E, unknown>
readonly timestamp: number
readonly refreshing?: LoadingFrom | undefined
}
Expand Down
8 changes: 4 additions & 4 deletions docs/context/Context.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -350,10 +350,10 @@ Get multiple services from the context that corresponds to the given tags.

```ts
export declare const getMany: {
<Services, T extends readonly ValidTagsById<Services>[]>(
<Services, T extends ReadonlyArray<ValidTagsById<Services>>>(
...tags: T
): (self: Context<Services>) => { readonly [K in keyof T]: Tag.Service<T[K]> }
<Services, T extends readonly ValidTagsById<Services>[]>(
<Services, T extends ReadonlyArray<ValidTagsById<Services>>>(
self: Context<Services>,
...tags: T
): { readonly [K in keyof T]: Tag.Service<T[K]> }
Expand Down Expand Up @@ -401,7 +401,7 @@ Omits specified services from a given `Context`.
**Signature**

```ts
export declare const omit: <Services, S extends ValidTagsById<Services>[]>(
export declare const omit: <Services, S extends Array<ValidTagsById<Services>>>(
...tags: S
) => (self: Context<Services>) => Context<Exclude<Services, { [k in keyof S]: Tag.Identifier<S[k]> }[keyof S]>>
```
Expand All @@ -415,7 +415,7 @@ Returns a new `Context` that contains only the specified services.
**Signature**
```ts
export declare const pick: <Services, S extends ValidTagsById<Services>[]>(
export declare const pick: <Services, S extends Array<ValidTagsById<Services>>>(
...tags: S
) => (self: Context<Services>) => Context<{ [k in keyof S]: Tag.Identifier<S[k]> }[number]>
```
Expand Down
8 changes: 4 additions & 4 deletions docs/core/CoreServices.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ export declare const server: Layer.Layer<
| CurrentEnvironment
| CurrentRoute
| GetRandomValues
| RenderTemplate
| RenderContext.RenderContext
| RenderQueue.RenderQueue,
| RenderQueue.RenderQueue
| RenderTemplate,
never,
never
>
Expand All @@ -95,9 +95,9 @@ export declare const static: Layer.Layer<
| CurrentEnvironment
| CurrentRoute
| GetRandomValues
| RenderTemplate
| RenderContext.RenderContext
| RenderQueue.RenderQueue,
| RenderQueue.RenderQueue
| RenderTemplate,
never,
never
>
Expand Down
10 changes: 5 additions & 5 deletions docs/core/Fx.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ Added in v1.0.0
```ts
export declare const takeOneIfEnvironment: {
(environments: ReadonlyArray<Environment>): <A, E, R>(fx: Fx.Fx<A, E, R>) => Fx.Fx<A, E, CurrentEnvironment | R>
<A, E, R>(fx: Fx.Fx<A, E, R>, environments: ReadonlyArray<Environment>): Fx.Fx<A, E, CurrentEnvironment | R>
(environments: ReadonlyArray<Environment>): <A, E, R>(fx: Fx.Fx<A, E, R>) => Fx.Fx<A, E, R | CurrentEnvironment>
<A, E, R>(fx: Fx.Fx<A, E, R>, environments: ReadonlyArray<Environment>): Fx.Fx<A, E, R | CurrentEnvironment>
}
```
Expand All @@ -72,7 +72,7 @@ Added in v1.0.0
**Signature**
```ts
export declare const takeOneIfNotDomEnvironment: <A, E, R>(fx: Fx.Fx<A, E, R>) => Fx.Fx<A, E, CurrentEnvironment | R>
export declare const takeOneIfNotDomEnvironment: <A, E, R>(fx: Fx.Fx<A, E, R>) => Fx.Fx<A, E, R | CurrentEnvironment>
```
Added in v1.0.0
Expand All @@ -83,8 +83,8 @@ Added in v1.0.0
```ts
export declare const takeOneIfNotEnvironment: {
(environments: ReadonlyArray<Environment>): <A, E, R>(fx: Fx.Fx<A, E, R>) => Fx.Fx<A, E, CurrentEnvironment | R>
<A, E, R>(fx: Fx.Fx<A, E, R>, environments: ReadonlyArray<Environment>): Fx.Fx<A, E, CurrentEnvironment | R>
(environments: ReadonlyArray<Environment>): <A, E, R>(fx: Fx.Fx<A, E, R>) => Fx.Fx<A, E, R | CurrentEnvironment>
<A, E, R>(fx: Fx.Fx<A, E, R>, environments: ReadonlyArray<Environment>): Fx.Fx<A, E, R | CurrentEnvironment>
}
```
Expand Down
32 changes: 15 additions & 17 deletions docs/core/Node.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,42 +60,40 @@ export declare const listen: {
(
options: Options
): <E, R>(
app: Http.app.Default<E, R>
app: HttpApp.Default<E, R>
) => Effect.Effect<
never,
Http.error.ServeError,
HttpServerError.HttpServerError,
Exclude<
R,
| HttpServerRequest.HttpServerRequest
| Scope.Scope
| HttpServer.HttpServer
| HttpPlatform
| CurrentEnvironment
| GetRandomValues
| RenderTemplate
| Http.request.ServerRequest
| Scope.Scope
| Http.server.Server
| Http.platform.Platform
| Http.etag.Generator
| RenderContext.RenderContext
| RenderQueue.RenderQueue
| RenderTemplate
>
>
<E, R>(
app: Http.app.Default<E, R>,
app: HttpApp.Default<E, R>,
options: Options
): Effect.Effect<
never,
Http.error.ServeError,
HttpServerError.HttpServerError,
Exclude<
R,
| HttpServerRequest.HttpServerRequest
| Scope.Scope
| HttpServer.HttpServer
| HttpPlatform
| CurrentEnvironment
| GetRandomValues
| RenderTemplate
| Http.request.ServerRequest
| Scope.Scope
| Http.server.Server
| Http.platform.Platform
| Http.etag.Generator
| RenderContext.RenderContext
| RenderQueue.RenderQueue
| RenderTemplate
>
>
}
Expand All @@ -109,7 +107,7 @@ Added in v1.0.0

```ts
export declare const run: <A, E>(
effect: Effect.Effect<A, E, CurrentEnvironment | NodeContext.NodeContext | CurrentRoute>,
effect: Effect.Effect<A, E, NodeContext.NodeContext | CurrentEnvironment | CurrentRoute>,
options?: RunForkOptions & { readonly static?: boolean; readonly base?: string }
) => Disposable
```
Expand Down
16 changes: 8 additions & 8 deletions docs/core/Platform.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Added in v1.0.0
```ts
export type LayoutParams<Content extends Fx.Fx<RenderEvent | null, any, any>> = {
readonly content: Content
readonly request: ServerRequest
readonly request: HttpServerRequest
readonly head: Fx.Fx<
RenderEvent | null,
never,
Expand Down Expand Up @@ -101,11 +101,11 @@ export declare function staticFiles({
readonly immutable?: boolean
}
}): <E, R>(
self: Http.app.Default<E, R>
self: HttpApp.Default<E, R>
) => Effect.Effect<
Http.response.ServerResponse,
HttpServerResponse.HttpServerResponse,
E | BadArgument | PlatformError,
ServerRequest | R | Http.platform.Platform | FileSystem | Path
HttpServerRequest | R | HttpPlatform | FileSystem | Path
>
```

Expand All @@ -132,9 +132,9 @@ export declare function toHttpRouter<
base?: string
environment?: "server" | "static"
}
): Http.router.Router<
): HttpRouter.HttpRouter<
Router.RouteMatch.RouteMatch.Error<M> | E2 | GuardsNotMatched,
ServerRequest | Exclude<Router.RouteMatch.RouteMatch.Context<M> | R2, Navigation.Navigation | Router.CurrentRoute>
HttpServerRequest | Exclude<Router.RouteMatch.RouteMatch.Context<M> | R2, Navigation.Navigation | Router.CurrentRoute>
>
```

Expand All @@ -160,9 +160,9 @@ export declare function toServerRouter<
>
base?: string
}
): ServerRouter.Router<
): ServerRouter.HttpRouter<
Router.RouteMatch.RouteMatch.Error<M> | E2 | GuardsNotMatched,
ServerRequest | Exclude<Router.RouteMatch.RouteMatch.Context<M> | R2, Navigation.Navigation | Router.CurrentRoute>
HttpServerRequest | Exclude<Router.RouteMatch.RouteMatch.Context<M> | R2, Navigation.Navigation | Router.CurrentRoute>
>
```

Expand Down
6 changes: 3 additions & 3 deletions docs/core/RefSubject.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Added in v1.0.0
```ts
export declare const takeOneIfNotDomEnvironment: <A, E, R>(
fx: RefSubject.RefSubject<A, E, R>
) => RefSubject.RefSubject<A, E, CurrentEnvironment | R>
) => RefSubject.RefSubject<A, E, R | CurrentEnvironment>
```
Added in v1.0.0
Expand All @@ -94,11 +94,11 @@ Added in v1.0.0
export declare const takeOneIfNotEnvironment: {
(
environments: ReadonlyArray<Environment>
): <A, E, R>(fx: RefSubject.RefSubject<A, E, R>) => RefSubject.RefSubject<A, E, CurrentEnvironment | R>
): <A, E, R>(fx: RefSubject.RefSubject<A, E, R>) => RefSubject.RefSubject<A, E, R | CurrentEnvironment>
<A, E, R>(
fx: RefSubject.RefSubject<A, E, R>,
environments: ReadonlyArray<Environment>
): RefSubject.RefSubject<A, E, CurrentEnvironment | R>
): RefSubject.RefSubject<A, E, R | CurrentEnvironment>
}
```
Expand Down
34 changes: 17 additions & 17 deletions docs/decoder/index.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,27 +84,27 @@ export declare const compose: {
<O, B, E2, R2>(
to: Decoder<O, B, E2, R2>
): {
<I, R, E>(from: Decoder<I, O, E, R>): Decoder<I, B, E2 | E, R2 | R>
<I, R>(from: Schema.Schema<O, I, R>): Decoder<I, B, ParseError | E2, R>
<I, R, E>(from: Decoder<I, O, E, R> | Schema.Schema<O, I, R>): Decoder<I, B, ParseError | E2 | E, R2 | R>
<I, R, E>(from: Decoder<I, O, E, R>): Decoder<I, B, E | E2, R | R2>
<I, R>(from: Schema.Schema<O, I, R>): Decoder<I, B, E2 | ParseError, R>
<I, R, E>(from: Decoder<I, O, E, R> | Schema.Schema<O, I, R>): Decoder<I, B, E | E2 | ParseError, R | R2>
}
<O, B>(
to: Schema.Schema<O, B, never>
to: Schema.Schema<O, B>
): {
<I, R, E>(from: Decoder<I, O, E, R>): Decoder<I, B, ParseError | E, R>
<I, R>(from: Schema.Schema<O, I, R>): Decoder<I, B, ParseError, never>
<I, R, E>(from: Decoder<I, O, E, R> | Schema.Schema<O, I, R>): Decoder<I, R, ParseError | E, B>
<I, R, E>(from: Decoder<I, O, E, R>): Decoder<I, B, E | ParseError, R>
<I, R>(from: Schema.Schema<O, I, R>): Decoder<I, B, ParseError>
<I, R, E>(from: Decoder<I, O, E, R> | Schema.Schema<O, I, R>): Decoder<I, R, E | ParseError, B>
}
<O, B, E2, R2>(
to: Decoder<O, B, E2, R2> | Schema.Schema<B, O, R2>
): {
<I, R, E>(from: Decoder<I, O, E, R>): Decoder<I, R2 | R, ParseError | E2 | E, B>
<I, R>(from: Schema.Schema<I, O, R>): Decoder<I, B, ParseError | E2, R>
<I, R, E>(from: Decoder<I, O, E, R> | Schema.Schema<I, O, never>): Decoder<I, R2 | R, ParseError | E2 | E, B>
<I, R, E>(from: Decoder<I, O, E, R>): Decoder<I, R | R2, E | E2 | ParseError, B>
<I, R>(from: Schema.Schema<I, O, R>): Decoder<I, B, E2 | ParseError, R>
<I, R, E>(from: Decoder<I, O, E, R> | Schema.Schema<I, O>): Decoder<I, R | R2, E | E2 | ParseError, B>
}
<I, R, E, O, B, E2, R2>(from: Decoder<I, O, E, R>, to: Decoder<O, B, E2, R2>): Decoder<I, B, E | E2, R | R2>
<O, I, R, B, E2, R2>(from: Schema.Schema<O, I, R>, to: Decoder<O, B, E2, R2>): Decoder<I, B, ParseError | E2, R | R2>
<I, R, E, R2, O, B>(from: Decoder<I, O, E, R>, to: Schema.Schema<B, O, R2>): Decoder<I, B, ParseError | E, R | R2>
<O, I, R, B, E2, R2>(from: Schema.Schema<O, I, R>, to: Decoder<O, B, E2, R2>): Decoder<I, B, E2 | ParseError, R | R2>
<I, R, E, R2, O, B>(from: Decoder<I, O, E, R>, to: Schema.Schema<B, O, R2>): Decoder<I, B, E | ParseError, R | R2>
<O, I, R, R2, B>(from: Schema.Schema<O, I, R>, to: Schema.Schema<B, O, R2>): Decoder<I, B, ParseError, R | R2>
<I, R, E, O, B, E2, R2>(
from: Decoder<I, O, E, R> | Schema.Schema<O, I, R>,
Expand Down Expand Up @@ -139,7 +139,7 @@ export declare const getDecoder: {
<O, I, R>(schema: Schema.Schema<O, I, R>): Decoder<I, O, ParseError, R>
<I, O = never, E = never, R = never>(
decoder: Decoder<I, O, E, R> | Schema.Schema<O, I, R>
): Decoder<I, O, ParseError | E, R>
): Decoder<I, O, E | ParseError, R>
}
```

Expand Down Expand Up @@ -185,10 +185,10 @@ export declare const map: {
): {
<I, E, R>(input: Decoder<I, O, E, R>): Decoder<I, B, E, R>
<I, R>(input: Schema.Schema<O, I, R>): Decoder<I, B, ParseError, R>
<I, E, R>(input: Decoder<I, O, E, R> | Schema.Schema<O, I, R>): Decoder<I, B, ParseError | E, R>
<I, E, R>(input: Decoder<I, O, E, R> | Schema.Schema<O, I, R>): Decoder<I, B, E | ParseError, R>
}
<I, O, E, R, B>(input: Decoder<I, O, E, R>, f: (o: O) => B): Decoder<I, B, E, R>
<O, I, R, B>(input: Schema.Schema<O, I, R>, f: (o: O) => B): Decoder<I, B, ParseError, never>
<O, I, R, B>(input: Schema.Schema<O, I, R>, f: (o: O) => B): Decoder<I, B, ParseError>
<I, O, E, R, B>(input: Decoder<I, O, E, R> | Schema.Schema<O, I, R>, f: (o: O) => B): Decoder<I, B, ParseError | E, R>
}
```
Expand All @@ -206,9 +206,9 @@ export declare const mapEffect: {
<O, B, E2, R2>(
f: (value: O) => Effect.Effect<B, E2, R2>
): {
<I, E, R>(input: Decoder<I, O, E, R>): Decoder<I, B, E2 | E | ParseError, R2 | R>
<I, E, R>(input: Decoder<I, O, E, R>): Decoder<I, B, E | E2 | ParseError, R | R2>
<I, R>(input: Schema.Schema<O, I, R>): Decoder<I, B, E2 | ParseError, R2>
<I, R, E>(input: Decoder<I, O, E, R> | Schema.Schema<O, I, R>): Decoder<I, B, E2 | ParseError | E, R2 | R>
<I, R, E>(input: Decoder<I, O, E, R> | Schema.Schema<O, I, R>): Decoder<I, B, E | E2 | ParseError, R | R2>
}
<I, O, E, R, B, E2, R2>(
input: Decoder<I, O, E, R>,
Expand Down
2 changes: 1 addition & 1 deletion docs/dom/Document.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ Add an event listener to the document
```ts
export declare const addDocumentListener: <EventName extends string, R = never>(
options: AddEventListenerOptions<Document, EventName, R>
) => Effect.Effect<void, never, Scope.Scope | Document | R>
) => Effect.Effect<void, never, R | Document | Scope.Scope>
```
Added in v8.19.0
Expand Down
2 changes: 1 addition & 1 deletion docs/dom/DomServices.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Provide DOM services to an Effect
export declare const provideDomServices: (
window: Window & GlobalThis,
params?: DomServicesElementParams
) => <A, E, R>(effect: Effect.Effect<A, E, DomServices | R>) => Effect.Effect<A, E, Exclude<R, DomServices>>
) => <A, E, R>(effect: Effect.Effect<A, E, R | DomServices>) => Effect.Effect<A, E, Exclude<R, DomServices>>
```
Added in v8.19.0
Expand Down
Loading

0 comments on commit 3a6453d

Please sign in to comment.