Skip to content

Commit

Permalink
Update Kysely to 0.27.0
Browse files Browse the repository at this point in the history
  • Loading branch information
steida committed Dec 31, 2023
1 parent d210555 commit 047b92e
Show file tree
Hide file tree
Showing 16 changed files with 860 additions and 837 deletions.
22 changes: 22 additions & 0 deletions .changeset/many-yaks-smile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
"@evolu/common-react": patch
"@evolu/react-native": patch
"@evolu/common": patch
"@evolu/server": patch
---

Update Kysely to 0.27.0

Check [Kysely release](https://github.com/kysely-org/kysely/releases/tag/0.27.0)

Note simplified `$narrowType` usage. Previous:

```ts
.$narrowType<{ title: NonEmptyString1000 }>()
```

Simplified:

```ts
.$narrowType<{ title: NotNull }>()
```
9 changes: 5 additions & 4 deletions apps/native/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as TreeFormatter from "@effect/schema/TreeFormatter";
import {
EvoluProvider,
NonEmptyString1000,
NotNull,
SqliteBoolean,
String,
cast,
Expand Down Expand Up @@ -188,9 +189,9 @@ const todosWithCategories = evolu.createQuery((db) =>
.selectFrom("todo")
.select(["id", "title", "isCompleted", "categoryId"])
.where("isDeleted", "is not", cast(true))
// Filter null value and ensure non-null type. Evolu will provide a helper.
// Filter null value and ensure non-null type.
.where("title", "is not", null)
.$narrowType<{ title: NonEmptyString1000 }>()
.$narrowType<{ title: NotNull }>()
.orderBy("createdAt")
// https://kysely.dev/docs/recipes/relations
.select((eb) => [
Expand Down Expand Up @@ -322,9 +323,9 @@ const todoCategories = evolu.createQuery((db) =>
.selectFrom("todoCategory")
.select(["id", "name", "json"])
.where("isDeleted", "is not", cast(true))
// Filter null value and ensure non-null type. Evolu will provide a helper.
// Filter null value and ensure non-null type.
.where("name", "is not", null)
.$narrowType<{ name: NonEmptyString50 }>()
.$narrowType<{ name: NotNull }>()
.orderBy("createdAt"),
);

Expand Down
4 changes: 2 additions & 2 deletions apps/native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"clean": "rm -rf .turbo .expo node_modules dist"
},
"dependencies": {
"@effect/schema": "^0.56.0",
"@effect/schema": "^0.56.1",
"@evolu/react-native": "workspace:*",
"@react-native-community/netinfo": "9.3.10",
"buffer": "^6.0.3",
Expand All @@ -32,7 +32,7 @@
"@babel/core": "^7.23.3",
"@babel/plugin-proposal-dynamic-import": "^7.18.6",
"@babel/plugin-transform-private-methods": "^7.23.3",
"@types/react": "^18.2.41",
"@types/react": "^18.2.46",
"eslint": "^8.56.0",
"eslint-config-evolu": "workspace:*",
"prettier": "^3.1.1",
Expand Down
2 changes: 1 addition & 1 deletion apps/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"devDependencies": {
"@evolu/tsconfig": "workspace:*",
"@types/node": "^20.10.5",
"@types/node": "^20.10.6",
"ts-node": "^10.9.1",
"typescript": "^5.3.3"
},
Expand Down
9 changes: 5 additions & 4 deletions apps/web/components/NextJsExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
EvoluProvider,
ExtractRow,
NonEmptyString1000,
NotNull,
SqliteBoolean,
String,
canUseDom,
Expand Down Expand Up @@ -162,9 +163,9 @@ const todosWithCategories = evolu.createQuery((db) =>
.selectFrom("todo")
.select(["id", "title", "isCompleted", "categoryId"])
.where("isDeleted", "is not", cast(true))
// Filter null value and ensure non-null type. Evolu will provide a helper.
// Filter null value and ensure non-null type.
.where("title", "is not", null)
.$narrowType<{ title: NonEmptyString1000 }>()
.$narrowType<{ title: NotNull }>()
.orderBy("createdAt")
// https://kysely.dev/docs/recipes/relations
.select((eb) => [
Expand Down Expand Up @@ -283,9 +284,9 @@ const todoCategories = evolu.createQuery((db) =>
.selectFrom("todoCategory")
.select(["id", "name", "json"])
.where("isDeleted", "is not", cast(true))
// Filter null value and ensure non-null type. Evolu will provide a helper.
// Filter null value and ensure non-null type.
.where("name", "is not", null)
.$narrowType<{ name: NonEmptyString50 }>()
.$narrowType<{ name: NotNull }>()
.orderBy("createdAt"),
);

Expand Down
10 changes: 5 additions & 5 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
"clean": "rm -rf .turbo .next node_modules"
},
"dependencies": {
"@effect/schema": "^0.56.0",
"@effect/schema": "^0.56.1",
"@evolu/common": "workspace:*",
"@evolu/react": "workspace:*",
"clsx": "^2.0.0",
"clsx": "^2.1.0",
"effect": "2.0.0-next.62",
"next": "14.0.4",
"nextra": "^2.13.2",
Expand All @@ -23,15 +23,15 @@
},
"devDependencies": {
"@evolu/tsconfig": "workspace:*",
"@types/node": "^20.10.5",
"@types/react": "^18.2.41",
"@types/node": "^20.10.6",
"@types/react": "^18.2.46",
"@types/react-dom": "^18.2.18",
"autoprefixer": "^10.4.16",
"eslint": "^8.56.0",
"eslint-config-evolu": "workspace:*",
"postcss": "^8.4.32",
"prettier": "^3.1.1",
"prettier-plugin-tailwindcss": "^0.5.9",
"prettier-plugin-tailwindcss": "^0.5.10",
"tailwindcss": "^3.4.0",
"typescript": "^5.3.3"
}
Expand Down
2 changes: 1 addition & 1 deletion apps/web/pages/docs/migrations.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const allTodos = evolu.createQuery((db) =>
.selectAll()
// Filter null value and ensure non-null type.
.where("title", "is not", null)
.$narrowType<{ title: NonEmptyString1000 }>()
.$narrowType<{ title: NotNull }>()
.orderBy("createdAt"),
);
```
Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-config-evolu/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
"clean": "rm -rf node_modules"
},
"dependencies": {
"@typescript-eslint/eslint-plugin": "^6.15.0",
"@typescript-eslint/parser": "^6.15.0",
"@typescript-eslint/eslint-plugin": "^6.16.0",
"@typescript-eslint/parser": "^6.16.0",
"eslint-config-next": "14.0.4",
"eslint-config-prettier": "^9.1.0",
"eslint-config-turbo": "^1.11.1",
"eslint-plugin-jsdoc": "^46.9.0",
"eslint-plugin-jsdoc": "^46.10.1",
"eslint-plugin-node": "^11.1.0",
"next": "14.0.4",
"react": "^18.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/evolu-common-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"devDependencies": {
"@evolu/common": "workspace:*",
"@evolu/tsconfig": "workspace:*",
"@types/react": "^18.2.41",
"@types/react": "^18.2.46",
"eslint": "^8.56.0",
"eslint-config-evolu": "workspace:*",
"react": "^18.2.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/evolu-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@
"@noble/hashes": "^1.3.3",
"@protobuf-ts/runtime": "^2.9.3",
"@scure/bip39": "^1.2.2",
"kysely": "^0.26.3",
"kysely": "^0.27.0",
"nanoid": "^5.0.4"
},
"devDependencies": {
"@effect/schema": "^0.56.0",
"@effect/schema": "^0.56.1",
"@evolu/tsconfig": "workspace:*",
"@protobuf-ts/plugin": "^2.9.3",
"@protobuf-ts/protoc": "^2.9.3",
Expand All @@ -73,7 +73,7 @@
"vitest": "^1.1.0"
},
"peerDependencies": {
"@effect/schema": "^0.56.0",
"@effect/schema": "^0.56.1",
"effect": "2.0.0-next.62"
},
"publishConfig": {
Expand Down
8 changes: 1 addition & 7 deletions packages/evolu-common/src/Evolu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,13 +286,7 @@ type CreateQuery<S extends DatabaseSchema> = <R extends Row>(
) => Query<R>;

type QueryCallback<S extends DatabaseSchema, R extends Row> = (
db: Pick<
Kysely.Kysely<QuerySchema<S>>,
| "selectFrom"
// TODO: Test.
// | "selectNoFrom"
| "fn"
>,
db: Pick<Kysely.Kysely<QuerySchema<S>>, "selectFrom" | "fn">,
) => Kysely.SelectQueryBuilder<any, any, R>;

type QuerySchema<S extends DatabaseSchema> = {
Expand Down
1 change: 1 addition & 0 deletions packages/evolu-common/src/Public.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export type { NotNull } from "kysely";
export { jsonArrayFrom, jsonObjectFrom } from "kysely/helpers/sqlite";
export type { Timestamp, TimestampError } from "./Crdt.js";
export type { InvalidMnemonicError, Mnemonic } from "./Crypto.js";
Expand Down
1 change: 1 addition & 0 deletions packages/evolu-react-native/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export type {
Timestamp,
TimestampError,
UnexpectedError,
NotNull,
} from "@evolu/common";
export { jsonArrayFrom, jsonObjectFrom } from "kysely/helpers/sqlite";

Expand Down
4 changes: 2 additions & 2 deletions packages/evolu-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@
"cors": "^2.8.5",
"effect": "2.0.0-next.62",
"express": "^4.18.2",
"kysely": "^0.26.3"
"kysely": "^0.27.0"
},
"devDependencies": {
"@evolu/tsconfig": "workspace:*",
"@types/better-sqlite3": "^7.6.8",
"@types/body-parser": "^1.19.5",
"@types/cors": "^2.8.17",
"@types/express": "^4.17.21",
"@types/node": "^20.10.5",
"@types/node": "^20.10.6",
"eslint": "^8.56.0",
"eslint-config-evolu": "workspace:*",
"typescript": "^5.3.3",
Expand Down
7 changes: 6 additions & 1 deletion packages/evolu-server/src/Server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
SyncRequest,
SyncResponse,
TimestampString,
diffMerkleTrees,
initialMerkleTree,
insertIntoMerkleTree,
Expand Down Expand Up @@ -139,7 +140,11 @@ export const ServerLive = Layer.effect(
.select(["timestamp", "content"])
.where("userId", "=", request.userId)
.where("timestamp", ">=", timestamp)
.where("timestamp", "not like", sql`'%' || ${request.nodeId}`)
.where(
"timestamp",
"not like",
sql<TimestampString>`'%' || ${request.nodeId}`,
)
.orderBy("timestamp")
.execute(),
),
Expand Down
Loading

1 comment on commit 047b92e

@vercel
Copy link

@vercel vercel bot commented on 047b92e Dec 31, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

evolu – ./

evolu-git-main-evolu.vercel.app
www.evolu.dev
evolu.vercel.app
evolu-evolu.vercel.app
evolu.dev

Please sign in to comment.