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

Commit

Permalink
Extract to core and prepare infra.
Browse files Browse the repository at this point in the history
  • Loading branch information
patroza committed May 1, 2021
1 parent 94bf5b6 commit 1c54706
Show file tree
Hide file tree
Showing 76 changed files with 4,131 additions and 107 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
25 changes: 23 additions & 2 deletions .vscode/common-imports.code-snippets
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,35 @@
"EffectOption": {
"prefix": "+EO",
"body": [
"import * as EO from \"@effect-ts-demo/todo-types/ext/EffectOption\""
"import * as EO from \"@effect-ts-demo/core/ext/EffectOption\""
],
"description": "EffectOption as EO"
},
"SyncOption": {
"prefix": "+SO",
"body": [
"import * as SO from \"@effect-ts-demo/core/ext/SyncOption\""
],
"description": "SyncOption as SO"
},
"Equal": {
"prefix": "+Eq",
"body": [
"import * as Eq from \"@effect-ts/core/Equal\""
],
"description": "Equal as Eq"
},
"Order": {
"prefix": "+Ord",
"body": [
"import * as Ord from \"@effect-ts/core/Ord\""
],
"description": "Order as Ord"
},
"Model": {
"prefix": "+MO",
"body": [
"import * as MO from \"@effect-ts/morphic\""
"import * as MO from \"@effect-ts-demo/core/ext/Model\""
],
"description": "Morphic as MO"
},
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ COPY apps/frontend/package.json ./apps/frontend/
COPY apps/api/package.json ./apps/api/
COPY packages/client/package.json ./packages/client/
COPY packages/types/package.json ./packages/types/
COPY packages/core/package.json ./packages/core/
COPY packages/infra/package.json ./packages/infra/
COPY packages/atlas-plutus/package.json ./packages/atlas-plutus/
RUN yarn install --frozen-lockfile

Expand Down
2 changes: 1 addition & 1 deletion apps/api/Tasks/TaskContext.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as EO from "@effect-ts-demo/core/ext/EffectOption"
import { Step, Task, TaskE } from "@effect-ts-demo/todo-types"
import * as EO from "@effect-ts-demo/todo-types/ext/EffectOption"
import { NonEmptyString } from "@effect-ts-demo/todo-types/shared"
import * as A from "@effect-ts/core/Collections/Immutable/Array"
import * as Chunk from "@effect-ts/core/Collections/Immutable/Chunk"
Expand Down
4 changes: 4 additions & 0 deletions apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"main": "index.js",
"license": "MIT",
"dependencies": {
"@effect-ts-demo/core": "*",
"@effect-ts-demo/infra": "*",
"@effect-ts-demo/todo-client": "*",
"@effect-ts-demo/todo-types": "*",
"@effect-ts/core": "^0.37.3",
Expand All @@ -23,6 +25,8 @@
"circular": "madge --circular --ts-config ./tsconfig.json --extensions ts ./",
"compile": "tsc --noEmit",
"lint": "eslint .",
"prettier": "prettier \"**/*.ts\"",
"autofix": "yarn lint --fix && yarn prettier --write",
"test": "echo 'no tests yet'",
"testsuite": "yarn compile && yarn lint && yarn test && yarn circular",
"start": "TSC_WATCHFILE=UseFsEventsWithFallbackDynamicPolling NODE_ENV=development nodemon --watch . --watch ../../packages --exec ts-node -r tsconfig-paths/register --transpile-only ./start-server.ts"
Expand Down
22 changes: 11 additions & 11 deletions apps/api/requestHandler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/ban-types */
import * as EO from "@effect-ts-demo/todo-types/ext/EffectOption"
import * as SO from "@effect-ts-demo/core/ext/SyncOption"
import { DSL } from "@effect-ts/core"
import { makeAssociative } from "@effect-ts/core/Associative"
import * as A from "@effect-ts/core/Collections/Immutable/Array"
Expand Down Expand Up @@ -267,35 +267,35 @@ function makeRequestParsers<
const ph = O.fromNullable(Request.Headers)
["|>"](O.map(strictDecoder))
["|>"](O.map((x) => x.decode))
["|>"](EO.fromOption)
["|>"](SO.fromOption)
const parseHeaders = (u: unknown) =>
ph["|>"](EO.chain((d) => d(u)["|>"](EO.fromEffect)))
ph["|>"](SO.chain((d) => d(u)["|>"](SO.fromEffect)))

const pq = O.fromNullable(Request.Query)
["|>"](O.map(strictDecoder))
["|>"](O.map((x) => x.decode))
["|>"](EO.fromOption)
["|>"](SO.fromOption)
const parseQuery = (u: unknown) =>
pq["|>"](EO.chain((d) => d(u)["|>"](EO.fromEffect)))
pq["|>"](SO.chain((d) => d(u)["|>"](SO.fromEffect)))

const pb = O.fromNullable(Request.Body)
["|>"](O.map(strictDecoder))
["|>"](O.map((x) => x.decode))
["|>"](EO.fromOption)
const parseBody = (u: unknown) => pb["|>"](EO.chain((d) => d(u)["|>"](EO.fromEffect)))
["|>"](SO.fromOption)
const parseBody = (u: unknown) => pb["|>"](SO.chain((d) => d(u)["|>"](SO.fromEffect)))

const pp = O.fromNullable(Request.Path)
["|>"](O.map(strictDecoder))
["|>"](O.map((x) => x.decode))
["|>"](EO.fromOption)
const parsePath = (u: unknown) => pp["|>"](EO.chain((d) => d(u)["|>"](EO.fromEffect)))
["|>"](SO.fromOption)
const parsePath = (u: unknown) => pp["|>"](SO.chain((d) => d(u)["|>"](SO.fromEffect)))

const pc = O.fromNullable(Request.Cookie)
["|>"](O.map(strictDecoder))
["|>"](O.map((x) => x.decode))
["|>"](EO.fromOption)
["|>"](SO.fromOption)
const parseCookie = (u: unknown) =>
pc["|>"](EO.chain((d) => d(u)["|>"](EO.fromEffect)))
pc["|>"](SO.chain((d) => d(u)["|>"](SO.fromEffect)))

return {
parseBody,
Expand Down
2 changes: 1 addition & 1 deletion apps/api/routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
SubSchema,
} from "@atlas-ts/plutus"
import { schema } from "@atlas-ts/plutus/Schema"
import * as EO from "@effect-ts-demo/todo-types/ext/EffectOption"
import * as EO from "@effect-ts-demo/core/ext/EffectOption"
import { Void } from "@effect-ts-demo/todo-types/shared"
import { pipe } from "@effect-ts/core"
import * as A from "@effect-ts/core/Collections/Immutable/Array"
Expand Down
1 change: 1 addition & 0 deletions apps/api/types/swagger-ui-express.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module "swagger-ui-express"
2 changes: 1 addition & 1 deletion apps/frontend/Todo.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as A from "@effect-ts-demo/core/ext/Array"
import * as Todo from "@effect-ts-demo/todo-types"
import * as A from "@effect-ts-demo/todo-types/ext/Array"
import { NonEmptyString } from "@effect-ts-demo/todo-types/shared"
import { flow } from "@effect-ts/core/Function"
import * as O from "@effect-ts/core/Option"
Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/data.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as A from "@effect-ts-demo/todo-types/ext/Array"
import * as A from "@effect-ts-demo/core/ext/Array"
import { Fiber, Semaphore } from "@effect-ts/core"
import * as T from "@effect-ts/core/Effect"
import { Cause } from "@effect-ts/core/Effect/Cause"
Expand Down
1 change: 1 addition & 0 deletions apps/frontend/features/Tasks/FolderList/FolderList.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable react/display-name */
import * as O from "@effect-ts/core/Option"
import { List, ListItem, ListItemIcon, ListItemText } from "@material-ui/core"
import CalendarToday from "@material-ui/icons/CalendarToday"
Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/features/Tasks/TaskList/Task.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as A from "@effect-ts-demo/todo-types/ext/Array"
import * as A from "@effect-ts-demo/core/ext/Array"
import * as O from "@effect-ts/core/Option"
import { UUID } from "@effect-ts/morphic/Algebra/Primitives"
import { Box, Card, Checkbox } from "@material-ui/core"
Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/features/Tasks/TaskList/TaskList.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as A from "@effect-ts-demo/core/ext/Array"
import * as TodoClient from "@effect-ts-demo/todo-client"
import * as A from "@effect-ts-demo/todo-types/ext/Array"
import * as O from "@effect-ts/core/Option"
import { UUID } from "@effect-ts/morphic/Algebra/Primitives"
import { Typography } from "@material-ui/core"
Expand Down
6 changes: 3 additions & 3 deletions apps/frontend/features/Tasks/TaskList/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as A from "@effect-ts-demo/todo-types/ext/Array"
import * as T from "@effect-ts-demo/todo-types/ext/Effect"
import * as EO from "@effect-ts-demo/todo-types/ext/EffectOption"
import * as A from "@effect-ts-demo/core/ext/Array"
import * as T from "@effect-ts-demo/core/ext/Effect"
import * as EO from "@effect-ts-demo/core/ext/EffectOption"
import * as NA from "@effect-ts/core/Collections/Immutable/NonEmptyArray"
import { flow } from "@effect-ts/core/Function"
import * as O from "@effect-ts/core/Option"
Expand Down
4 changes: 2 additions & 2 deletions apps/frontend/features/Tasks/data.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as T from "@effect-ts-demo/core/ext/Effect"
import * as EO from "@effect-ts-demo/core/ext/EffectOption"
import * as TodoClient from "@effect-ts-demo/todo-client"
import * as T from "@effect-ts-demo/todo-types/ext/Effect"
import * as EO from "@effect-ts-demo/todo-types/ext/EffectOption"
import { NonEmptyString } from "@effect-ts-demo/todo-types/shared"
import * as A from "@effect-ts/core/Collections/Immutable/Array"
import { constant, flow, identity, pipe } from "@effect-ts/core/Function"
Expand Down
3 changes: 1 addition & 2 deletions apps/frontend/features/Tasks/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { UUID } from "@effect-ts-demo/todo-types/shared"
import * as O from "@effect-ts/core/Option"
import { Box, Hidden, Link, Typography } from "@material-ui/core"
import ArrowLeft from "@material-ui/icons/ArrowLeft"
Expand All @@ -12,8 +13,6 @@ import TaskDetail from "./TaskDetail"
import TaskList from "./TaskList"
import { Ordery, TaskView } from "./data"

import { UUID } from "@/../../packages/types/shared"

const TasksScreen = memo(function ({
category,
order,
Expand Down
8 changes: 7 additions & 1 deletion apps/frontend/next.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
const withTM = require('next-transpile-modules')(['fp-ts', '@nll/datum', '@effect-ts-demo/todo-client', '@effect-ts-demo/todo-types']);
const withTM = require('next-transpile-modules')([
'fp-ts',
'@nll/datum',
'@effect-ts-demo/core',
'@effect-ts-demo/todo-client',
'@effect-ts-demo/todo-types'
]);

const { API_ROOT = "http://localhost:3330" } = process.env

Expand Down
13 changes: 8 additions & 5 deletions apps/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"private": true,
"dependencies": {
"@babel/core": "7.14.0",
"@effect-ts-demo/core": "*",
"@effect-ts-demo/todo-client": "*",
"@effect-ts-demo/todo-types": "*",
"@effect-ts/core": "^0.37.3",
"@effect-ts/monocle": "^0.30.0",
"@effect-ts/morphic": "^0.33.0",
Expand Down Expand Up @@ -74,12 +77,12 @@
"circular": "madge --circular --ts-config ./tsconfig.json --extensions ts ./",
"compile": "tsc --noEmit",
"lint": "eslint .",
"test": "yarn test:runner --watchAll=false",
"testsuite": "yarn compile && yarn lint && yarn test && yarn circular",
"prettier": "prettier \"**/*.ts\"",
"autofix": "yarn lint --fix && yarn prettier --write",
"testsuite": "yarn compile && yarn lint && yarn circular",
"dev": "next dev -p 3133",
"build": "next build",
"start": "next start",
"test:runner": "node scripts/test.js"
"start": "next start"
},
"browserslist": {
"production": [
Expand All @@ -93,4 +96,4 @@
"last 1 safari version"
]
}
}
}
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
"typescript": "^4.2.4",
"ultra-runner": "^3.10.5"
},
"resolutions": {
"typescript": "^4.2.4"
},
"scripts": {
"start": "concurrently -k -p \"[{name}]\" -n \"API,Frontend\" -c \"cyan.bold,green.bold,blue.bold\" \"yarn start:api\" \"yarn start:frontend\"",
"start:api": "cd apps/api && yarn start",
Expand Down
2 changes: 2 additions & 0 deletions packages/atlas-plutus/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/*.js
node_modules/
9 changes: 9 additions & 0 deletions packages/atlas-plutus/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const base = require("../../.eslintrc.base")

module.exports = {
...base,
rules: {
...base.rules,
"@typescript-eslint/ban-ts-comment": "warn"
}
}
2 changes: 1 addition & 1 deletion packages/atlas-plutus/Schema/interpreter/tagged-union.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { TaggedUnionURI } from "@effect-ts/morphic/Algebra/TaggedUnion"
import { interpreter } from "@effect-ts/morphic/HKT"
import { mapRecord } from "@effect-ts/morphic/Utils"

import { isTypeRef } from "../../JsonSchema"
//import { isTypeRef } from "../../JsonSchema"
import * as X from "../base"

export const SchemaTaggedUnionInterpreter = interpreter<X.SchemaURI, TaggedUnionURI>()(
Expand Down
3 changes: 1 addition & 2 deletions packages/atlas-plutus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
"scripts": {
"build": "rimraf lib; ttsc --p tsconfig.build.json; yarn prettier:lib;",
"type-check": "tsc --noEmit",
"autofix": "yarn prettier && yarn lint --fix && yarn prettier",
"prettier": "prettier --write \"./{src,test,demo}/**/*.ts\"",
"prettier:lib": "prettier --write \"./lib/**/*.js\"",
"lint": "eslint . --ext .ts,.tsx"
},
"dependencies": {
"redoc-express": "^1.0.0"
}
}
}
28 changes: 14 additions & 14 deletions packages/atlas-plutus/test/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ const A = MO.make((F) =>
a: F.string({
conf: {
[Api.SchemaURI]: (_) =>
Api.succeed({ type: "string", description: "my description" })
}
Api.succeed({ type: "string", description: "my description" }),
},
}),
b: F.number(),
c: F.date()
c: F.date(),
},
{
extensions: {
openapiRef: "RefA"
}
openapiRef: "RefA",
},
}
)
)
Expand All @@ -33,12 +33,12 @@ const B = MO.make((F) =>
_tag: F.stringLiteral("B"),
a: F.string(),
b: F.number(),
c: F.date()
c: F.date(),
},
{
extensions: {
openapiRef: "RefB"
}
openapiRef: "RefB",
},
}
)
)
Expand All @@ -58,7 +58,7 @@ describe("Morphic OpenAPI Schemas", () => {
T.runPromise
)
).toEqual({
$ref: "#/components/schemas/RefA"
$ref: "#/components/schemas/RefA",
})
})
it("should derive schema union", async () => {
Expand All @@ -76,15 +76,15 @@ describe("Morphic OpenAPI Schemas", () => {
).toEqual({
oneOf: [
{
$ref: "#/components/schemas/RefA"
$ref: "#/components/schemas/RefA",
},
{
$ref: "#/components/schemas/RefB"
}
$ref: "#/components/schemas/RefB",
},
],
discriminator: {
propertyName: "_tag"
}
propertyName: "_tag",
},
})
})
})
2 changes: 1 addition & 1 deletion packages/client/fetch.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as T from "@effect-ts-demo/todo-types/ext/Effect"
import * as T from "@effect-ts-demo/core/ext/Effect"
import { pipe } from "@effect-ts/core"
import { flow } from "@effect-ts/core/Function"
import { M } from "@effect-ts/morphic"
Expand Down
3 changes: 3 additions & 0 deletions packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"main": "index.js",
"license": "MIT",
"dependencies": {
"@effect-ts-demo/core": "*",
"@effect-ts-demo/todo-types": "*",
"@effect-ts/core": "^0.37.3",
"@effect-ts/monocle": "^0.30.0",
Expand All @@ -14,6 +15,8 @@
"circular": "madge --circular --ts-config ./tsconfig.json --extensions ts ./",
"compile": "tsc --noEmit",
"lint": "eslint .",
"prettier": "prettier \"**/*.ts\"",
"autofix": "yarn lint --fix && yarn prettier --write",
"test": "echo 'no tests yet'",
"testsuite": "yarn compile && yarn lint && yarn test && yarn circular"
}
Expand Down
2 changes: 2 additions & 0 deletions packages/core/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/*.js
node_modules/
5 changes: 5 additions & 0 deletions packages/core/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const base = require("../../.eslintrc.base")

module.exports = {
...base
}
File renamed without changes.
Loading

1 comment on commit 1c54706

@vercel
Copy link

@vercel vercel bot commented on 1c54706 May 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.