Skip to content

Commit 3cb6e4d

Browse files
miccysteidaCopilotCopilot
authored
PR: Cherry-pick common-v8 from upstream (#22)
* Clarify ESLint 'Unsafe...' troubleshooting * Migrate to monorepo Vitest config Introduce a root vitest.config.ts and split package test configs into unit and browser projects (packages/common/vitest.unit.config.ts, packages/common/vitest.browser.config.ts). Remove the old combined common vitest config and migrate per-package coverage/test settings into the central config. Update package.json scripts to run Vitest from the repo root, remove per-package Vitest deps where appropriate, and add browser/playwright-related devDeps at the root. Adjust tsconfigs (add root tsconfig.json and include vitest.*.config.ts in packages/common) and simplify turbo.json task entries. Also add a README link to the Vitest VS Code extension. * Expand TDD guidance and add Vitest examples Replace the brief Test-driven development note with an expanded TDD section that explains how to run tests, test file locations, and filtering by test name. Add subsections on test structure, type testing (expectTypeOf), and inline snapshot usage with Vitest code examples. Remove the previous Vitest filtering CLI snippets and some commit-message examples to streamline the guidance and surface more actionable testing patterns for contributors. * Update TreeShaking.test.ts * Use 'observability' term in error comment * Rename vitest config to .mts and add scripts tests Rename vitest.config.ts → vitest.config.mts (switch to .mts/ESM), update tsconfig include to reference vitest.config.mts, and add a new "scripts" test project in the Vitest config to include tests matching scripts/**/*.test.mts. Also simplify package.json "verify" script by removing the generic "pnpm test" step. * Add createQueryBuilder, replace createQuery usage Introduce a standalone createQueryBuilder(Schema) to build typed Kysely queries without an Evolu instance. The createQuery implementation was moved into packages/common/src/local-first/Schema.ts and exported from index.ts; Evolu.createQuery was removed from the Evolu interface/instance. Updated usages across playgrounds to call createQuery(...) (created via createQueryBuilder) and adjusted types/docs in Query.ts. Added a changeset noting the API migration and guidance to replace evolu.createQuery with createQueryBuilder(Schema). * chore: format * update: minors * fix: missing dependencies and verified build * chore: Update Biome to version 2.3.14 and reflect this change in documentation and configuration schema. * Update packages/common/src/local-first/Evolu.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Miccy <code@miccy.dev> * Update packages/common/src/local-first/Evolu.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Miccy <code@miccy.dev> * Revert EvoluMinimalExample.tsx to working implementation (#24) * Initial plan * Revert EvoluMinimalExample.tsx to working state from 13fab62 Co-authored-by: miccy <9729864+miccy@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: miccy <9729864+miccy@users.noreply.github.com> * Fix CI: generate docs before typedoc-plugin tests (#23) * Initial plan * Update all examples to use createQueryBuilder instead of evolu.createQuery Co-authored-by: miccy <9729864+miccy@users.noreply.github.com> * Fix CI: add build:docs before typedoc-plugin tests in verify script Co-authored-by: miccy <9729864+miccy@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: miccy <9729864+miccy@users.noreply.github.com> * Fix CI: Exclude typedoc test from regular test run (#27) * fix: Correct `Uint8Array` type signature in `exportDatabase` and related callbacks. * chore: Update Angular and Svelte dependencies and enable documentation tests in the verify script. * refactor: improve schema difference calculation for columns and use a local constant for current schema. --------- Signed-off-by: Miccy <code@miccy.dev> Signed-off-by: Miccy <support@miccy.dev> Co-authored-by: Daniel Steigerwald <daniel@steigerwald.cz> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
1 parent e9f7a58 commit 3cb6e4d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+499
-492
lines changed

.ai/knowledge/02-dependencies.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ bunx <package> # Execute packages
2222

2323
### Development
2424
- **Turbo** 2.8.1 - Monorepo build orchestration
25-
- **Biome** 2.3.13 - Linting and formatting
25+
- **Biome** 2.3.14 - Linting and formatting
2626
- **Vitest** ^4.0.18 - Testing framework
2727
- **TypeDoc** ^0.28.16 - API documentation
2828

.ai/tasks/archive/cherry-pick-common-v8-SUPERSEDED.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Migrating changes from `upstream/common-v8` to our fork, while preserving our st
2222
| Tool | Before | After | Status |
2323
| ------- | ------ | ------ | ---------------- |
2424
| Bun | 1.3.6 | 1.3.8 | ✅ Done |
25-
| Biome | 2.3.13 | 2.3.13 | ✅ Current |
25+
| Biome | 2.3.14 | 2.3.14 | ✅ Current |
2626
| Turbo | 2.8.1 | 2.8.1 | ✅ Current |
2727
| Node.js | >=24 | >=24 | ✅ LTS 24 correct |
2828

.changeset/create-query-builder.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
"@evolu/common": major
3+
---
4+
5+
Replaced `evolu.createQuery` with standalone `createQueryBuilder` function
6+
7+
Queries are now created using a standalone `createQueryBuilder` function instead of `evolu.createQuery` method. This enables query creation without an Evolu instance, improving code organization and enabling schema-first development.
8+
9+
```ts
10+
// Before
11+
const todosQuery = evolu.createQuery((db) => db.selectFrom("todo").selectAll());
12+
13+
// After
14+
const createQuery = createQueryBuilder(Schema);
15+
const todosQuery = createQuery((db) => db.selectFrom("todo").selectAll());
16+
```

.github/copilot-instructions.md

Lines changed: 62 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,6 @@ apps/
7171

7272
Follow these specific conventions and patterns:
7373

74-
## Test-driven development
75-
76-
- Write a failing test before implementing a new feature or fixing a bug
77-
- Keep test code cleaner than production code — good tests let you refactor production code; nothing protects messy tests
78-
7974
## Code organization & imports
8075

8176
- **Use named imports only** - avoid default exports and namespace imports
@@ -498,6 +493,68 @@ const processTask: Task<void, ParseError | TimeoutError> = async (run) => {
498493
const result = await sleep("1s")(run);
499494
```
500495

496+
## Test-driven development
497+
498+
- Write a failing test before implementing a new feature or fixing a bug
499+
- Run tests using the `runTests` tool with the test file path
500+
- Test files are in `packages/*/test/*.test.ts`
501+
- Use `testNames` parameter to run specific tests by name
502+
- Run related tests after making code changes to verify correctness
503+
504+
### Test structure
505+
506+
- Use `describe` blocks to group related tests by feature or function
507+
- Use `test` or `it` for individual test cases (both are equivalent)
508+
- Test names should be descriptive phrases: `"returns true for non-empty array"`
509+
- Use nested `describe` for sub-categories
510+
511+
```ts
512+
import { describe, expect, expectTypeOf, test } from "vitest";
513+
514+
describe("arrayFrom", () => {
515+
test("creates array from iterable", () => {
516+
const result = arrayFrom(new Set([1, 2, 3]));
517+
expect(result).toEqual([1, 2, 3]);
518+
});
519+
520+
test("returns input unchanged if already an array", () => {
521+
const input = [1, 2, 3];
522+
const result = arrayFrom(input);
523+
expect(result).toBe(input);
524+
});
525+
});
526+
```
527+
528+
### Type testing
529+
530+
Use `expectTypeOf` from Vitest for compile-time type assertions:
531+
532+
```ts
533+
import { expectTypeOf } from "vitest";
534+
535+
test("returns readonly array", () => {
536+
const result = arrayFrom(2, () => "x");
537+
expectTypeOf(result).toEqualTypeOf<ReadonlyArray<string>>();
538+
});
539+
540+
test("NonEmptyArray requires at least one element", () => {
541+
const _valid: NonEmptyArray<number> = [1, 2, 3];
542+
// @ts-expect-error - empty array is not a valid NonEmptyArray
543+
const _invalid: NonEmptyArray<number> = [];
544+
});
545+
```
546+
547+
### Inline snapshots
548+
549+
Use `toMatchInlineSnapshot` for readable test output directly in the test file:
550+
551+
```ts
552+
test("Buffer", () => {
553+
const buffer = createBuffer([1, 2, 3]);
554+
expect(buffer.unwrap()).toMatchInlineSnapshot(`uint8:[1,2,3]`);
555+
});
556+
```
557+
501558
## Testing
502559

503560
- **Create deps per test** - use `testCreateDeps()` from `@evolu/common` for test isolation
@@ -564,18 +621,6 @@ bun run test --filter @evolu/common -- -t "yields and returns ok"
564621
- **No prefixes** - avoid `feat:`, `fix:`, `feature:` etc.
565622
- **Be descriptive** - explain what the change does
566623

567-
```bash
568-
# Good
569-
Add support for custom error formatters
570-
Fix memory leak in WebSocket reconnection
571-
Update schema validation to handle edge cases
572-
573-
# Avoid
574-
feat: add support for custom error formatters
575-
fix: memory leak in websocket reconnection
576-
Update schema validation to handle edge cases.
577-
```
578-
579624
## Changesets
580625

581626
- **Write in past tense** - describe what was done, not what will be done

AGENTS.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212

1313
## 📊 Quick Context
1414

15-
| Aspect | Value |
16-
|--------|-------|
17-
| Package Manager | Bun 1.3.8 |
18-
| Node.js | >=24.0.0 |
19-
| Linter/Formatter | Biome 2.3.13 |
20-
| Test Framework | Vitest |
21-
| Upstream | evoluhq/evolu |
15+
| Aspect | Value |
16+
| ---------------- | ------------- |
17+
| Package Manager | Bun 1.3.8 |
18+
| Node.js | >=24.0.0 |
19+
| Linter/Formatter | Biome 2.3.14 |
20+
| Test Framework | Vitest |
21+
| Upstream | evoluhq/evolu |
2222

2323
## 🗂️ Repository Structure
2424

@@ -92,13 +92,13 @@ bun run verify
9292

9393
## 📍 Related Resources
9494

95-
| Resource | Location |
96-
|----------|----------|
97-
| Issues | `../knowledge/05-Issues/` |
98-
| Roadmap | `../knowledge/05-Issues/roadmap.md` |
99-
| Architecture | `../knowledge/02-Architecture/` |
100-
| Bench Suite | `../bench-suite/` (sibling repo) |
101-
| Upstream | https://github.com/evoluhq/evolu |
95+
| Resource | Location |
96+
| ------------ | ----------------------------------- |
97+
| Issues | `../knowledge/05-Issues/` |
98+
| Roadmap | `../knowledge/05-Issues/roadmap.md` |
99+
| Architecture | `../knowledge/02-Architecture/` |
100+
| Bench Suite | `../bench-suite/` (sibling repo) |
101+
| Upstream | https://github.com/evoluhq/evolu |
102102

103103
## 🤖 For AI Agents
104104

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ Linting
7373
Testing
7474

7575
- `bun run test` - Run tests
76+
- [Vitest VS Code extension](https://github.com/vitest-dev/vscode)
7677

7778
Release
7879

apps/web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"@evolu/tsconfig": "workspace:*",
6262
"@types/mdx": "^2.0.13",
6363
"@types/node": "^24.10.9",
64-
"@types/react": "~19.2.10",
64+
"@types/react": "~19.2.11",
6565
"@types/react-dom": "~19.2.3",
6666
"@types/react-highlight-words": "^0.20.1",
6767
"@types/rss": "^0.0.32",

apps/web/src/app/(playgrounds)/playgrounds/full/EvoluFullExample.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
createEvolu,
66
createFormatTypeError,
77
createObjectURL,
8+
createQueryBuilder,
89
FiniteNumber,
910
id,
1011
idToIdBytes,
@@ -99,6 +100,8 @@ const Schema = {
99100
},
100101
};
101102

103+
const createQuery = createQueryBuilder(Schema);
104+
102105
const deps = createEvoluDeps();
103106

104107
const evolu = createEvolu(deps)(Schema, {
@@ -212,7 +215,7 @@ const App: FC = () => {
212215
);
213216
};
214217

215-
const projectsWithTodosQuery = evolu.createQuery(
218+
const projectsWithTodosQuery = createQuery(
216219
(db) =>
217220
db
218221
.selectFrom("project")
@@ -409,7 +412,7 @@ const HomeTabProjectSectionTodoItem: FC<{
409412

410413
// Demonstrate history tracking. Evolu automatically tracks all changes
411414
// in the evolu_history table, making it easy to build audit logs or undo features.
412-
const titleHistoryQuery = evolu.createQuery((db) =>
415+
const titleHistoryQuery = createQuery((db) =>
413416
db
414417
.selectFrom("evolu_history")
415418
.select(["value", "timestamp"])
@@ -503,7 +506,7 @@ const HomeTabProjectSectionTodoItem: FC<{
503506
);
504507
};
505508

506-
const projectsQuery = evolu.createQuery((db) =>
509+
const projectsQuery = createQuery((db) =>
507510
db
508511
.selectFrom("project")
509512
.select(["id", "name", "fooJson"])
@@ -716,7 +719,7 @@ const AccountTab: FC = () => {
716719
);
717720
};
718721

719-
const deletedProjectsQuery = evolu.createQuery((db) =>
722+
const deletedProjectsQuery = createQuery((db) =>
720723
db
721724
.selectFrom("project")
722725
.select(["id", "name", "updatedAt"])
@@ -728,7 +731,7 @@ const deletedProjectsQuery = evolu.createQuery((db) =>
728731

729732
type DeletedProjectsRow = typeof deletedProjectsQuery.Row;
730733

731-
const deletedTodosQuery = evolu.createQuery((db) =>
734+
const deletedTodosQuery = createQuery((db) =>
732735
db
733736
.selectFrom("todo")
734737
.select(["id", "title", "isCompleted", "projectId", "updatedAt"])

apps/web/src/app/(playgrounds)/playgrounds/multitenant/EvoluMultitenantExample.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ const Schema = {
2323

2424
const deps = createEvoluDeps();
2525

26+
// Create a typed query builder from the schema
27+
const createQuery = Evolu.createQueryBuilder(Schema);
28+
2629
deps.evoluError.subscribe(() => {
2730
const error = deps.evoluError.get();
2831
if (!error) return;
@@ -73,7 +76,7 @@ export const EvoluMultitenantExample: FC = () => (
7376
);
7477

7578
// Evolu uses Kysely for type-safe SQL (https://kysely.dev/).
76-
const todosQuery = evolu.createQuery((db) =>
79+
const todosQuery = createQuery((db) =>
7780
db
7881
// Type-safe SQL: try autocomplete for table and column names.
7982
.selectFrom("todo")

biome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://biomejs.dev/schemas/2.3.13/schema.json",
2+
"$schema": "https://biomejs.dev/schemas/2.3.14/schema.json",
33
"vcs": {
44
"enabled": true,
55
"clientKind": "git",

0 commit comments

Comments
 (0)