Skip to content

Commit

Permalink
chore: upgrad Effect deps
Browse files Browse the repository at this point in the history
  • Loading branch information
TylorS committed May 16, 2024
1 parent 258c19a commit df4832b
Show file tree
Hide file tree
Showing 46 changed files with 2,555 additions and 2,340 deletions.
23 changes: 23 additions & 0 deletions .changeset/smooth-panthers-sparkle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
"@typed/vite-plugin-types": minor
"@typed/environment": minor
"@typed/vite-plugin": minor
"@typed/async-data": minor
"@typed/navigation": minor
"@typed/storybook": 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/dom": minor
"@typed/fx": minor
"@typed/id": minor
"@typed/ui": minor
---

Upgrade Effect deps to latest
4 changes: 2 additions & 2 deletions examples/counter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
"@typed/dom": "workspace:*",
"@typed/fx": "workspace:*",
"@typed/template": "workspace:*",
"effect": "3.0.7"
"effect": "3.1.5"
},
"devDependencies": {
"vite": "^5.2.10",
"vite": "^5.2.11",
"vite-plugin-compression": "^0.5.1",
"vite-tsconfig-paths": "^4.3.2"
}
Expand Down
12 changes: 6 additions & 6 deletions examples/fx-tracing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
"license": "MIT",
"sideEffects": [],
"dependencies": {
"@effect/opentelemetry": "^0.33.4",
"@opentelemetry/exporter-trace-otlp-http": "^0.51.0",
"@opentelemetry/otlp-exporter-base": "^0.51.0",
"@opentelemetry/sdk-node": "^0.51.0",
"@opentelemetry/sdk-trace-base": "^1.24.0",
"@effect/opentelemetry": "^0.34.5",
"@opentelemetry/exporter-trace-otlp-http": "^0.51.1",
"@opentelemetry/otlp-exporter-base": "^0.51.1",
"@opentelemetry/sdk-node": "^0.51.1",
"@opentelemetry/sdk-trace-base": "^1.24.1",
"@typed/context": "workspace:*",
"@typed/dom": "workspace:*",
"@typed/fx": "workspace:*",
"effect": "3.0.7"
"effect": "3.1.5"
}
}
34 changes: 17 additions & 17 deletions examples/realworld/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
"license": "MIT",
"sideEffects": [],
"dependencies": {
"@effect/opentelemetry": "^0.33.4",
"@effect/platform": "^0.50.7",
"@effect/platform-node": "^0.47.7",
"@effect/schema": "0.66.10",
"@effect/sql": "^0.1.12",
"@effect/sql-pg": "^0.1.12",
"@opentelemetry/exporter-trace-otlp-http": "^0.51.0",
"@opentelemetry/sdk-trace-base": "^1.24.0",
"@effect/opentelemetry": "^0.34.5",
"@effect/platform": "^0.53.8",
"@effect/platform-node": "^0.49.8",
"@effect/schema": "0.67.5",
"@effect/sql": "^0.2.10",
"@effect/sql-pg": "^0.2.10",
"@opentelemetry/exporter-trace-otlp-http": "^0.51.1",
"@opentelemetry/sdk-trace-base": "^1.24.1",
"@typed/async-data": "workspace:*",
"@typed/context": "workspace:*",
"@typed/core": "workspace:*",
Expand All @@ -48,10 +48,10 @@
"@types/source-map-support": "^0.5.10",
"bcrypt": "^5.1.1",
"date-fns": "^3.6.0",
"effect": "3.0.7",
"effect-http": "^0.64.1",
"effect-http-node": "^0.12.1",
"effect-log": "^0.31.0",
"effect": "3.1.5",
"effect-http": "^0.66.0",
"effect-http-node": "^0.13.0",
"effect-log": "^0.31.2",
"jsonwebtoken": "^9.0.2",
"path-to-regexp": "^6.2.2",
"postgres": "^3.4.4",
Expand All @@ -61,16 +61,16 @@
"devDependencies": {
"@types/bcrypt": "^5.0.2",
"@types/jsonwebtoken": "^9.0.6",
"happy-dom": "14.7.1",
"happy-dom": "14.11.0",
"mock-storage": "^1.1.0",
"rollup-plugin-visualizer": "^5.12.0",
"schema-openapi": "^0.37.1",
"schema-openapi": "^0.38.1",
"terser": "^5.31.0",
"tsx": "^4.7.3",
"tsx": "^4.10.3",
"vavite": "^4.1.1",
"vite": "^5.2.10",
"vite": "^5.2.11",
"vite-plugin-compression": "^0.5.1",
"vite-tsconfig-paths": "^4.3.2",
"vitest": "1.5.2"
"vitest": "1.6.0"
}
}
24 changes: 12 additions & 12 deletions examples/realworld/src/api/articles/infrastructure/ArticlesLive.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Schema } from "@effect/schema"
import * as Sql from "@effect/sql-pg"
import * as Sql from "@effect/sql"
import { makeNanoId } from "@typed/id"
import { getCurrentJwtUser, getOptionalCurrentJwtUser } from "@typed/realworld/api/common/infrastructure/CurrentJwt"
import { catchExpectedErrors } from "@typed/realworld/api/common/infrastructure/errors"
Expand Down Expand Up @@ -32,7 +32,7 @@ export const ArticlesLive = Articles.implement({
create: (input) =>
Effect.gen(function*(_) {
const user = yield* _(getCurrentJwtUser)
const sql = yield* _(Sql.client.PgClient)
const sql = yield* _(Sql.client.Client)
const dbArticle = yield* _(dbArticleFromCreateArticleInput(input, user.id))

yield* _(sql`insert into articles ${sql.insert(dbArticle)};`)
Expand Down Expand Up @@ -66,7 +66,7 @@ export const ArticlesLive = Articles.implement({
Effect.gen(function*(_) {
const user = yield* _(getCurrentJwtUser)
const current = yield* _(getArticleFromSlug(slug, user.id))
const sql = yield* _(Sql.client.PgClient)
const sql = yield* _(Sql.client.Client)
const updatedArticle: DbArticle = {
...current,
slug: input.title ? makeSlugFromTitle(input.title) : current.slug,
Expand Down Expand Up @@ -102,7 +102,7 @@ export const ArticlesLive = Articles.implement({
delete: ({ slug }) =>
Effect.gen(function*(_) {
const user = yield* _(getCurrentJwtUser)
const sql = yield* _(Sql.client.PgClient)
const sql = yield* _(Sql.client.Client)
const article = yield* _(getArticleFromSlug(slug, user.id))

yield* _(sql`delete from comments where article_id = ${article.id};`)
Expand All @@ -116,7 +116,7 @@ export const ArticlesLive = Articles.implement({
Effect.gen(function*(_) {
const user = yield* _(getCurrentJwtUser)
const { id } = yield* _(getArticleFromSlug(slug, user.id))
const sql = yield* _(Sql.client.PgClient)
const sql = yield* _(Sql.client.Client)

yield* _(
sql`insert into favorites ${sql.insert({ article_id: id, user_id: user.id })} on conflict do nothing;`
Expand All @@ -130,7 +130,7 @@ export const ArticlesLive = Articles.implement({
Effect.gen(function*(_) {
const user = yield* _(getCurrentJwtUser)
const { id } = yield* _(getArticleFromSlug(slug, user.id))
const sql = yield* _(Sql.client.PgClient)
const sql = yield* _(Sql.client.Client)

yield* _(
sql`delete from favorites where article_id = ${id} and user_id = ${user.id};`
Expand All @@ -142,7 +142,7 @@ export const ArticlesLive = Articles.implement({
}).pipe(catchExpectedErrors),
list: (input) =>
Effect.gen(function*(_) {
const sql = yield* _(Sql.client.PgClient)
const sql = yield* _(Sql.client.Client)
const user = yield* _(getOptionalCurrentJwtUser)
const limit = sql`limit ${Option.getOrElse(input.limit, () => 10)}`
const offset = sql`offset ${Option.getOrElse(input.offset, () => 0)}`
Expand Down Expand Up @@ -248,7 +248,7 @@ export const ArticlesLive = Articles.implement({
}).pipe(catchExpectedErrors),
feed: (input) =>
Effect.gen(function*(_) {
const sql = yield* _(Sql.client.PgClient)
const sql = yield* _(Sql.client.Client)
const user = yield* _(getCurrentJwtUser)
const limit = sql`limit ${Option.getOrElse(input.limit, () => 10)}`
const offset = sql`offset ${Option.getOrElse(input.offset, () => 0)}`
Expand Down Expand Up @@ -324,7 +324,7 @@ export const ArticlesLive = Articles.implement({

function dbArticleFromCreateArticleInput(input: CreateArticleInput, author_id: UserId) {
return Effect.gen(function*(_) {
const id = ArticleId(yield* _(makeNanoId))
const id = ArticleId.make(yield* _(makeNanoId))
const now = new Date(yield* _(Clock.currentTimeMillis))
const article: DbArticle = {
id,
Expand All @@ -343,7 +343,7 @@ function dbArticleFromCreateArticleInput(input: CreateArticleInput, author_id: U

function getArticleFromSlug(slug: ArticleSlug, currentUserId?: UserId) {
return Effect.gen(function*(_) {
const sql = yield* _(Sql.client.PgClient)
const sql = yield* _(Sql.client.Client)

if (currentUserId) {
return yield* _(
Expand Down Expand Up @@ -425,7 +425,7 @@ function tagListToTags(list: ReadonlyArray<ArticleTag>) {
list,
(tag) =>
Effect.gen(function*(_) {
const sql = yield* _(Sql.client.PgClient)
const sql = yield* _(Sql.client.Client)
const existing = yield* _(
tag,
Sql.schema.findOne({
Expand Down Expand Up @@ -454,5 +454,5 @@ function tagListToTags(list: ReadonlyArray<ArticleTag>) {
}

function makeSlugFromTitle(title: string) {
return ArticleSlug(title.toLowerCase().replace(/\s/g, "-"))
return ArticleSlug.make(title.toLowerCase().replace(/\s/g, "-"))
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Schema } from "@effect/schema"
import * as Pg from "@effect/sql-pg"
import * as Sql from "@effect/sql"
import { makeNanoId } from "@typed/id"
import { getCurrentJwtUser, getOptionalCurrentJwtUser } from "@typed/realworld/api/common/infrastructure/CurrentJwt"
import { catchExpectedErrors } from "@typed/realworld/api/common/infrastructure/errors"
Expand All @@ -16,10 +16,10 @@ export const CommentsLive = Comments.implement({
Effect.gen(function*(_) {
const user = yield* _(getOptionalCurrentJwtUser)

const sql = yield* _(Pg.client.PgClient)
const sql = yield* _(Sql.client.Client)
const dbComments = yield* _(
slug,
Pg.schema.findAll({
Sql.schema.findAll({
Request: ArticleSlug,
Result: DbCommentWithAuthor,
execute: (s) =>
Expand All @@ -45,7 +45,7 @@ export const CommentsLive = Comments.implement({
create: (slug, input) =>
Effect.gen(function*(_) {
const user = yield* _(getCurrentJwtUser)
const sql = yield* _(Pg.client.PgClient)
const sql = yield* _(Sql.client.Client)
const comment = yield* _(createDbComment(user, slug, input))

yield* _(
Expand All @@ -63,15 +63,15 @@ export const CommentsLive = Comments.implement({
}).pipe(catchExpectedErrors),
delete: (_, { id }) =>
Effect.gen(function*(_) {
const sql = yield* _(Pg.client.PgClient)
const sql = yield* _(Sql.client.Client)
const user = yield* _(getCurrentJwtUser)
yield* _(sql`DELETE FROM comments WHERE id = ${id} AND author_id = ${user.id};`)
}).pipe(catchExpectedErrors)
})

function createDbComment(user: User, slug: ArticleSlug, input: CreateCommentInput) {
return Effect.gen(function*(_) {
const id = CommentId(yield* _(makeNanoId))
const id = CommentId.make(yield* _(makeNanoId))
const article_id = yield* _(getArticleIdBySlug(slug))
const now = new Date(yield* _(Clock.currentTimeMillis))
const comment: DbComment = {
Expand All @@ -89,10 +89,10 @@ function createDbComment(user: User, slug: ArticleSlug, input: CreateCommentInpu

function getArticleIdBySlug(slug: ArticleSlug) {
return Effect.gen(function*(_) {
const sql = yield* _(Pg.client.PgClient)
const sql = yield* _(Sql.client.Client)
const { id } = yield* _(
slug,
Pg.schema.single(
Sql.schema.single(
{
Request: ArticleSlug,
Result: Schema.Struct({ id: ArticleId }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ export const getJwtTokenFromRequest = Effect.gen(function*(_) {
return ServerHeaders.get(headers, "cookie").pipe(
Option.map(Cookies.parseHeader),
Option.flatMap((_) => Option.fromNullable(_["conduit-token"])),
Option.map(JwtToken),
Option.map((token) => JwtToken.make(token)),
Option.orElse(() =>
ServerHeaders.get(headers, "authorization").pipe(
Option.map((authorization) => JwtToken(authorization.split(" ")[1]))
Option.map((authorization) => JwtToken.make(authorization.split(" ")[1]))
)
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const HashPasswordLive = HashPassword.implement((password) =>
Effect.gen(function*(_) {
const bcrypt = yield* _(Effect.promise(() => import("bcrypt")))
const hash = yield* _(Effect.promise(() => bcrypt.hash(Secret.value(password), 10)))
return PasswordHash(Secret.fromString(hash))
return PasswordHash.make(Secret.fromString(hash))
})
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Schema } from "@effect/schema"
import * as Pg from "@effect/sql-pg"
import * as Sql from "@effect/sql"
import { getCurrentJwtUser, getOptionalCurrentJwtUser } from "@typed/realworld/api/common/infrastructure/CurrentJwt"
import { catchExpectedErrors } from "@typed/realworld/api/common/infrastructure/errors"
import { DbProfile, DbUser } from "@typed/realworld/api/common/infrastructure/schema"
Expand All @@ -17,7 +17,7 @@ export const ProfilesLive = Profiles.implement({
follow: (username) =>
Effect.gen(function*(_) {
const currentUser = yield* _(getCurrentJwtUser)
const sql = yield* _(Pg.client.PgClient)
const sql = yield* _(Sql.client.Client)
const user = yield* _(getDbUserByUsername(username))

yield* _(sql`insert into follows (follower_id, followed_id) values (${currentUser.id}, ${user.id});`)
Expand All @@ -33,7 +33,7 @@ export const ProfilesLive = Profiles.implement({
unfollow: (username) =>
Effect.gen(function*(_) {
const currentUser = yield* _(getCurrentJwtUser)
const sql = yield* _(Pg.client.PgClient)
const sql = yield* _(Sql.client.Client)
const user = yield* _(getDbUserByUsername(username))

yield* _(sql`delete from follows where follower_id = ${currentUser.id} and followed_id = ${user.id};`)
Expand All @@ -50,11 +50,11 @@ export const ProfilesLive = Profiles.implement({

function getProfileByUsername(username: Username, userId?: UserId) {
return Effect.gen(function*(_) {
const sql = yield* _(Pg.client.PgClient)
const sql = yield* _(Sql.client.Client)

const dbProfile = yield* _(
username,
Pg.schema.single(
Sql.schema.single(
{
Request: Username,
Result: DbProfile.pipe(Schema.extend(Schema.Struct({ following: Schema.Boolean }))),
Expand All @@ -80,10 +80,10 @@ function getProfileByUsername(username: Username, userId?: UserId) {

function getDbUserByUsername(username: Username) {
return Effect.gen(function*(_) {
const sql = yield* _(Pg.client.PgClient)
const sql = yield* _(Sql.client.Client)
return yield* _(
username,
Pg.schema.single({
Sql.schema.single({
Request: Username,
Result: DbUser,
execute: (t) => sql`select * from users where username = ${t}`
Expand Down
6 changes: 3 additions & 3 deletions examples/realworld/src/api/tags/infrastructure/TagsLive.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Schema } from "@effect/schema"
import * as Pg from "@effect/sql-pg"
import * as Sql from "@effect/sql"
import { ArticleTag } from "@typed/realworld/model"
import { Tags } from "@typed/realworld/services"
import { Unprocessable } from "@typed/realworld/services/errors"
Expand All @@ -8,10 +8,10 @@ import { Effect } from "effect"
export const TagsLive = Tags.implement({
get: () =>
Effect.gen(function*(_) {
const sql = yield* _(Pg.client.PgClient)
const sql = yield* _(Sql.client.Client)
const tags = yield* _(
undefined,
Pg.schema.findAll({
Sql.schema.findAll({
Request: Schema.Void,
Result: Schema.Struct({ tag: ArticleTag }),
execute: () =>
Expand Down
Loading

0 comments on commit df4832b

Please sign in to comment.