Skip to content

Commit

Permalink
Update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
steida committed Dec 13, 2023
1 parent 6fad9f4 commit d5b0df5
Show file tree
Hide file tree
Showing 10 changed files with 739 additions and 839 deletions.
8 changes: 5 additions & 3 deletions apps/native/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import {
String,
cast,
createEvolu,
database,
id,
jsonArrayFrom,
parseMnemonic,
table,
useEvolu,
useEvoluError,
useOwner,
Expand Down Expand Up @@ -47,7 +49,7 @@ const NonEmptyString50 = String.pipe(
);
type NonEmptyString50 = S.Schema.To<typeof NonEmptyString50>;

const TodoTable = S.struct({
const TodoTable = table({
id: TodoId,
title: NonEmptyString1000,
isCompleted: S.nullable(SqliteBoolean),
Expand All @@ -58,14 +60,14 @@ type TodoTable = S.Schema.To<typeof TodoTable>;
const SomeJson = S.struct({ foo: S.string, bar: S.boolean });
type SomeJson = S.Schema.To<typeof SomeJson>;

const TodoCategoryTable = S.struct({
const TodoCategoryTable = table({
id: TodoCategoryId,
name: NonEmptyString50,
json: S.nullable(SomeJson),
});
type TodoCategoryTable = S.Schema.To<typeof TodoCategoryTable>;

const Database = S.struct({
const Database = database({
todo: TodoTable,
todoCategory: TodoCategoryTable,
});
Expand Down
22 changes: 11 additions & 11 deletions examples/electron-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,27 @@
},
"license": "MIT",
"devDependencies": {
"@electron-forge/cli": "7.1.0",
"@electron-forge/maker-deb": "7.1.0",
"@electron-forge/maker-rpm": "7.1.0",
"@electron-forge/maker-squirrel": "7.1.0",
"@electron-forge/maker-zip": "7.1.0",
"@electron-forge/plugin-auto-unpack-natives": "7.1.0",
"@electron-forge/plugin-webpack": "7.1.0",
"@electron-forge/cli": "7.2.0",
"@electron-forge/maker-deb": "7.2.0",
"@electron-forge/maker-rpm": "7.2.0",
"@electron-forge/maker-squirrel": "7.2.0",
"@electron-forge/maker-zip": "7.2.0",
"@electron-forge/plugin-auto-unpack-natives": "7.2.0",
"@electron-forge/plugin-webpack": "7.2.0",
"@vercel/webpack-asset-relocator-loader": "1.7.3",
"css-loader": "6.8.1",
"electron": "27.1.2",
"electron": "28.0.0",
"eslint": "^8.54.0",
"eslint-plugin-import": "^2.29.0",
"fork-ts-checker-webpack-plugin": "9.0.2",
"node-loader": "2.0.0",
"style-loader": "3.3.3",
"ts-loader": "9.5.1",
"ts-node": "10.9.1",
"typescript": "5.3.2"
"ts-node": "10.9.2",
"typescript": "5.3.3"
},
"dependencies": {
"@evolu/react": "3.0.0",
"@evolu/react": "^4.0.0",
"@types/react-dom": "^18.2.17",
"electron-squirrel-startup": "1.0.0",
"react": "18.2.0",
Expand Down
22 changes: 12 additions & 10 deletions examples/electron-app/src/Example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import {
canUseDom,
cast,
createEvolu,
database,
EvoluProvider,
id,
jsonArrayFrom,
NonEmptyString1000,
parseMnemonic,
SqliteBoolean,
String,
table,
useEvolu,
useEvoluError,
useOwner,
Expand All @@ -36,11 +38,11 @@ type TodoCategoryId = S.Schema.To<typeof TodoCategoryId>;
const NonEmptyString50 = String.pipe(
S.minLength(1),
S.maxLength(50),
S.brand("NonEmptyString50"),
S.brand("NonEmptyString50")
);
type NonEmptyString50 = S.Schema.To<typeof NonEmptyString50>;

const TodoTable = S.struct({
const TodoTable = table({
id: TodoId,
title: NonEmptyString1000,
isCompleted: S.nullable(SqliteBoolean),
Expand All @@ -51,14 +53,14 @@ type TodoTable = S.Schema.To<typeof TodoTable>;
const SomeJson = S.struct({ foo: S.string, bar: S.boolean });
type SomeJson = S.Schema.To<typeof SomeJson>;

const TodoCategoryTable = S.struct({
const TodoCategoryTable = table({
id: TodoCategoryId,
name: NonEmptyString50,
json: S.nullable(SomeJson),
});
type TodoCategoryTable = S.Schema.To<typeof TodoCategoryTable>;

const Database = S.struct({
const Database = database({
todo: TodoTable,
todoCategory: TodoCategoryTable,
});
Expand All @@ -71,7 +73,7 @@ const createFixtures = (): Promise<void> =>
evolu.loadQueries([
evolu.createQuery((db) => db.selectFrom("todo").selectAll()),
evolu.createQuery((db) => db.selectFrom("todoCategory").selectAll()),
]),
])
).then(([todos, categories]) => {
if (todos.row || categories.row) return;

Expand Down Expand Up @@ -165,9 +167,9 @@ const todosWithCategories = evolu.createQuery((db) =>
.selectFrom("todoCategory")
.select(["todoCategory.id", "todoCategory.name"])
.where("isDeleted", "is not", cast(true))
.orderBy("createdAt"),
.orderBy("createdAt")
).as("categories"),
]),
])
);

const Todos: FC = () => {
Expand Down Expand Up @@ -283,7 +285,7 @@ const todoCategories = evolu.createQuery((db) =>
// Filter null value and ensure non-null type. Evolu will provide a helper.
.where("name", "is not", null)
.$narrowType<{ name: NonEmptyString50 }>()
.orderBy("createdAt"),
.orderBy("createdAt")
);

const TodoCategories: FC = () => {
Expand Down Expand Up @@ -358,7 +360,7 @@ const OwnerActions: FC = () => {
isRestoringOwner(true);
evolu.restoreOwner(mnemonic);
},
}),
})
);
});
};
Expand Down Expand Up @@ -413,7 +415,7 @@ const Button: FC<{
const prompt = <From extends string, To>(
schema: S.Schema<From, To>,
message: string,
onSuccess: (value: To) => void,
onSuccess: (value: To) => void
): void => {
const value = window.prompt(message);
if (value == null) return; // on cancel
Expand Down
22 changes: 12 additions & 10 deletions examples/nextjs/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ import {
canUseDom,
cast,
createEvolu,
database,
id,
jsonArrayFrom,
parseMnemonic,
table,
useEvolu,
useEvoluError,
useOwner,
Expand All @@ -38,11 +40,11 @@ type TodoCategoryId = S.Schema.To<typeof TodoCategoryId>;
const NonEmptyString50 = String.pipe(
S.minLength(1),
S.maxLength(50),
S.brand("NonEmptyString50"),
S.brand("NonEmptyString50")
);
type NonEmptyString50 = S.Schema.To<typeof NonEmptyString50>;

const TodoTable = S.struct({
const TodoTable = table({
id: TodoId,
title: NonEmptyString1000,
isCompleted: S.nullable(SqliteBoolean),
Expand All @@ -53,14 +55,14 @@ type TodoTable = S.Schema.To<typeof TodoTable>;
const SomeJson = S.struct({ foo: S.string, bar: S.boolean });
type SomeJson = S.Schema.To<typeof SomeJson>;

const TodoCategoryTable = S.struct({
const TodoCategoryTable = table({
id: TodoCategoryId,
name: NonEmptyString50,
json: S.nullable(SomeJson),
});
type TodoCategoryTable = S.Schema.To<typeof TodoCategoryTable>;

const Database = S.struct({
const Database = database({
todo: TodoTable,
todoCategory: TodoCategoryTable,
});
Expand All @@ -73,7 +75,7 @@ const createFixtures = (): Promise<void> =>
evolu.loadQueries([
evolu.createQuery((db) => db.selectFrom("todo").selectAll()),
evolu.createQuery((db) => db.selectFrom("todoCategory").selectAll()),
]),
])
).then(([todos, categories]) => {
if (todos.row || categories.row) return;

Expand Down Expand Up @@ -167,9 +169,9 @@ const todosWithCategories = evolu.createQuery((db) =>
.selectFrom("todoCategory")
.select(["todoCategory.id", "todoCategory.name"])
.where("isDeleted", "is not", cast(true))
.orderBy("createdAt"),
.orderBy("createdAt")
).as("categories"),
]),
])
);

const Todos: FC = () => {
Expand Down Expand Up @@ -285,7 +287,7 @@ const todoCategories = evolu.createQuery((db) =>
// Filter null value and ensure non-null type. Evolu will provide a helper.
.where("name", "is not", null)
.$narrowType<{ name: NonEmptyString50 }>()
.orderBy("createdAt"),
.orderBy("createdAt")
);

const TodoCategories: FC = () => {
Expand Down Expand Up @@ -360,7 +362,7 @@ const OwnerActions: FC = () => {
isRestoringOwner(true);
evolu.restoreOwner(mnemonic);
},
}),
})
);
});
};
Expand Down Expand Up @@ -415,7 +417,7 @@ const Button: FC<{
const prompt = <From extends string, To>(
schema: S.Schema<From, To>,
message: string,
onSuccess: (value: To) => void,
onSuccess: (value: To) => void
): void => {
const value = window.prompt(message);
if (value == null) return; // on cancel
Expand Down
6 changes: 3 additions & 3 deletions examples/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"lint": "next lint"
},
"dependencies": {
"@evolu/react": "^3.0.0",
"next": "14.0.3",
"@evolu/react": "^4.0.0",
"next": "^14.0.4",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
Expand All @@ -20,7 +20,7 @@
"@types/react-dom": "^18.2.17",
"autoprefixer": "^10.4.16",
"eslint": "^8.55.0",
"eslint-config-next": "14.0.3",
"eslint-config-next": "^14.0.4",
"postcss": "^8.4.32",
"tailwindcss": "^3.3.6",
"typescript": "^5.3.2"
Expand Down
22 changes: 12 additions & 10 deletions examples/remix/app/routes/_index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ import {
canUseDom,
cast,
createEvolu,
database,
id,
jsonArrayFrom,
parseMnemonic,
table,
useEvolu,
useEvoluError,
useOwner,
Expand All @@ -36,11 +38,11 @@ type TodoCategoryId = S.Schema.To<typeof TodoCategoryId>;
const NonEmptyString50 = String.pipe(
S.minLength(1),
S.maxLength(50),
S.brand("NonEmptyString50"),
S.brand("NonEmptyString50")
);
type NonEmptyString50 = S.Schema.To<typeof NonEmptyString50>;

const TodoTable = S.struct({
const TodoTable = table({
id: TodoId,
title: NonEmptyString1000,
isCompleted: S.nullable(SqliteBoolean),
Expand All @@ -51,14 +53,14 @@ type TodoTable = S.Schema.To<typeof TodoTable>;
const SomeJson = S.struct({ foo: S.string, bar: S.boolean });
type SomeJson = S.Schema.To<typeof SomeJson>;

const TodoCategoryTable = S.struct({
const TodoCategoryTable = table({
id: TodoCategoryId,
name: NonEmptyString50,
json: S.nullable(SomeJson),
});
type TodoCategoryTable = S.Schema.To<typeof TodoCategoryTable>;

const Database = S.struct({
const Database = database({
todo: TodoTable,
todoCategory: TodoCategoryTable,
});
Expand All @@ -75,7 +77,7 @@ const createFixtures = (): Promise<void> =>
evolu.loadQueries([
evolu.createQuery((db) => db.selectFrom("todo").selectAll()),
evolu.createQuery((db) => db.selectFrom("todoCategory").selectAll()),
]),
])
).then(([todos, categories]) => {
if (todos.row || categories.row) return;

Expand Down Expand Up @@ -169,9 +171,9 @@ const todosWithCategories = evolu.createQuery((db) =>
.selectFrom("todoCategory")
.select(["todoCategory.id", "todoCategory.name"])
.where("isDeleted", "is not", cast(true))
.orderBy("createdAt"),
.orderBy("createdAt")
).as("categories"),
]),
])
);

const Todos: FC = () => {
Expand Down Expand Up @@ -287,7 +289,7 @@ const todoCategories = evolu.createQuery((db) =>
// Filter null value and ensure non-null type. Evolu will provide a helper.
.where("name", "is not", null)
.$narrowType<{ name: NonEmptyString50 }>()
.orderBy("createdAt"),
.orderBy("createdAt")
);

const TodoCategories: FC = () => {
Expand Down Expand Up @@ -362,7 +364,7 @@ const OwnerActions: FC = () => {
isRestoringOwner(true);
evolu.restoreOwner(mnemonic);
},
}),
})
);
});
};
Expand Down Expand Up @@ -417,7 +419,7 @@ const Button: FC<{
const prompt = <From extends string, To>(
schema: S.Schema<From, To>,
message: string,
onSuccess: (value: To) => void,
onSuccess: (value: To) => void
): void => {
const value = window.prompt(message);
if (value == null) return; // on cancel
Expand Down
4 changes: 2 additions & 2 deletions examples/remix/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"typecheck": "tsc"
},
"dependencies": {
"@evolu/react": "^3.0.0",
"@evolu/server": "^2.0.0",
"@evolu/react": "^4.0.0",
"@evolu/server": "^3.0.0",
"@remix-run/dev": "^2.3.1",
"@remix-run/express": "^2.3.1",
"@remix-run/node": "^2.3.1",
Expand Down
2 changes: 1 addition & 1 deletion examples/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"preview": "vite preview"
},
"dependencies": {
"@evolu/react": "^3.0.1",
"@evolu/react": "^4.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
Expand Down
Loading

1 comment on commit d5b0df5

@vercel
Copy link

@vercel vercel bot commented on d5b0df5 Dec 13, 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.dev
evolu-git-main-evolu.vercel.app
evolu-evolu.vercel.app
www.evolu.dev
evolu.vercel.app

Please sign in to comment.