Skip to content
This repository has been archived by the owner on Jan 5, 2023. It is now read-only.

Commit

Permalink
Drop Morphic in favour of Schema.
Browse files Browse the repository at this point in the history
  • Loading branch information
patroza committed May 16, 2021
1 parent 6eb5083 commit 77116fd
Show file tree
Hide file tree
Showing 20 changed files with 44 additions and 1,913 deletions.
9 changes: 1 addition & 8 deletions .vscode/common-imports.code-snippets
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,10 @@
"Model": {
"prefix": "+MO",
"body": [
"import * as MO from \"@effect-ts-demo/core/ext/Model\""
"import * as MO from \"@effect-ts-demo/core/ext/Schema\""
],
"description": "Schema as MO"
},
"Morphic": {
"prefix": "+MOR",
"body": [
"import * as MO from \"@effect-ts-demo/core/ext/Morphic\""
],
"description": "Morphic as MO"
},
"Effect": {
"prefix": "+T",
"body": [
Expand Down
85 changes: 0 additions & 85 deletions .vscode/morphic.code-snippets

This file was deleted.

9 changes: 0 additions & 9 deletions apps/api/Tasks/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { NotLoggedInError } from "@effect-ts-demo/infra/errors"
import { UserSVC } from "@effect-ts-demo/infra/services"
import { TaskList, UserId } from "@effect-ts-demo/todo-types/"
import * as T from "@effect-ts/core/Effect"
import { AType, M } from "@effect-ts/morphic"
import { SchemaAny } from "@effect-ts/schema"
import { Chunk } from "@effect-ts/system/Collections/Immutable/Chunk"

Expand All @@ -27,14 +26,6 @@ export const getLoggedInUser = T.gen(function* ($) {
)
})

export function makeHandler<
TReq extends M<{}, any, any>,
TRes extends M<{}, any, any>
>(_: { Request: TReq; Response: TRes }) {
// TODO: Prevent over providing, although strict encoding removes it already.
return <R, E>(h: (r: AType<TReq>) => T.Effect<R, E, AType<TRes>>) => h
}

export function handle<
TReq extends { Model: SchemaAny },
TRes extends { Model: SchemaAny } | SchemaAny = typeof S.Void
Expand Down
1 change: 0 additions & 1 deletion apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"@effect-ts/core": "^0.39.0",
"@effect-ts/express": "^0.19.0",
"@effect-ts/monocle": "^0.32.0",
"@effect-ts/morphic": "^0.35.0",
"@effect-ts/node": "^0.24.0",
"@effect-ts/schema": "^0.7.1",
"body-parser": "^1.19.0",
Expand Down
1 change: 0 additions & 1 deletion apps/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"@effect-ts-demo/todo-types": "*",
"@effect-ts/core": "^0.39.0",
"@effect-ts/monocle": "^0.32.0",
"@effect-ts/morphic": "^0.35.0",
"@effect-ts/react": "^0.2.0",
"@effect-ts/schema": "^0.7.1",
"@emotion/react": "^11.4.0",
Expand Down
1 change: 1 addition & 0 deletions packages/atlas-plutus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"lint": "eslint . --ext .ts,.tsx"
},
"dependencies": {
"@effect-ts/morphic": "^0.35.0",
"redoc-express": "^1.0.0"
}
}
36 changes: 0 additions & 36 deletions packages/client/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ import * as S from "@effect-ts-demo/core/ext/Schema"
import * as H from "@effect-ts-demo/core/http/http-client"
import { pipe } from "@effect-ts/core"
import { flow } from "@effect-ts/core/Function"
import { M } from "@effect-ts/morphic"
import { Decode, decode, Errors } from "@effect-ts/morphic/Decoder"
import * as MO from "@effect-ts/morphic/Encoder"
import { Path } from "path-parser"

import { getConfig } from "./config"
Expand All @@ -28,7 +25,6 @@ export class ResponseError {
constructor(public readonly error: unknown) {}
}

export const mapResponseError = T.mapError((err: Errors) => new ResponseError(err))
export const mapResponseErrorS = T.mapError((err: unknown) => new ResponseError(err))

export function fetchApi(method: H.Method, path: string, body?: unknown) {
Expand All @@ -44,21 +40,6 @@ export function fetchApi(method: H.Method, path: string, body?: unknown) {
)
}

type Encode<A, E> = MO.Encoder<A, E>["encode"]

export function fetchApi2<RequestA, RequestE, ResponseA>(
encodeRequest: Encode<RequestA, RequestE>,
decodeResponse: Decode<ResponseA>
) {
const decodeRes = flow(decodeResponse, mapResponseError)
return (method: H.Method, path: string) => (req: RequestA) =>
pipe(
encodeRequest(req),
T.chain((r) => fetchApi(method, path, r)),
T.chain(decodeRes)
)
}

type ComputeUnlessClass<T> = T extends { new (...args: any[]): any } ? T : Compute<T>

export function fetchApi2S<RequestA, RequestE, ResponseA>(
Expand All @@ -79,23 +60,6 @@ export function fetchApi2S<RequestA, RequestE, ResponseA>(
)
}

export function fetchApi3<RequestA, RequestE, ResponseE, ResponseA>(
{
Request,
Response,
}: {
// eslint-disable-next-line @typescript-eslint/ban-types
Request: M<{}, RequestE, RequestA>
// eslint-disable-next-line @typescript-eslint/ban-types
Response: M<{}, ResponseE, ResponseA>
},
method: H.Method = "POST"
) {
const encodeRequest = MO.encode(Request)
const decodeResponse = decode(Response)
return (path: string) => fetchApi2(encodeRequest, decodeResponse)(method, path)
}

// TODO: validate headers vs path vs body vs query?
export function fetchApi3S<RequestA, RequestE, ResponseE = unknown, ResponseA = void>({
Request,
Expand Down
1 change: 0 additions & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"@effect-ts-demo/todo-types": "*",
"@effect-ts/core": "^0.39.0",
"@effect-ts/monocle": "^0.32.0",
"@effect-ts/morphic": "^0.35.0",
"cross-fetch": "^3.1.4",
"path-parser": "^6.1.0"
},
Expand Down
11 changes: 0 additions & 11 deletions packages/core/ext/Morphic/array.ts

This file was deleted.

4 changes: 0 additions & 4 deletions packages/core/ext/Morphic/index.ts

This file was deleted.

Loading

0 comments on commit 77116fd

Please sign in to comment.