Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ jobs:
node-version-file: ".node-version"
cache: true

- uses: oven-sh/setup-bun@v2

- name: Install Dependencies
run: vp install --frozen-lockfile

Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ jobs:
node-version-file: ".node-version"
cache: true

- uses: oven-sh/setup-bun@v2

- name: Install Dependencies
run: vp install --frozen-lockfile

Expand Down
6 changes: 3 additions & 3 deletions WORKSPACE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Workspace Structure

This project uses a pnpm workspace and Vite+ for task orchestration, formatting,
and linting. Bun remains the test runtime.
linting, and testing.

## Structure

Expand Down Expand Up @@ -36,7 +36,7 @@ fractional-indexing/
Contains the main fraci library code. This is what gets published to npm.

- All source code (`src/`)
- Build configuration (`tsup.config.ts`)
- Vite+ package configuration (`vite.config.ts`)
- Documentation generation (`typedoc.json`)
- Core tests (`test/`)

Expand Down Expand Up @@ -94,7 +94,7 @@ The workspace uses:

- **pnpm workspaces** for dependency management
- **Vite+** for tasks, formatting, and linting
- **Bun** as the test runtime
- **Vite+ Test** as the test and benchmark runner
- **Workspace references** (`workspace:*`) for core library dependencies
- **Version-local fixtures** so TypeScript validates against each installed ORM version

Expand Down
20 changes: 10 additions & 10 deletions packages/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ See the detailed examples below for more information.
| -------------------- | ------------------------------------- | ---------------------------------------- |
| **Storage** | Stored as text strings | Stored as binary data (`Uint8Array`) |
| **Performance** | Good | Better (faster comparisons, less memory) |
| **Bundle Size** | 2.06 KiB (Core-only, gzipped) | 1.55 KiB (Core-only, gzipped) |
| **Bundle Size** | 1.82 KiB (Core-only, gzipped) | 1.45 KiB (Core-only, gzipped) |
| **Database Column** | `text` or `varchar` | `blob` or `bytea` |
| **Visual Debugging** | Easier (human-readable) | Harder (requires conversion) |
| **Configuration** | Requires `digitBase` and `lengthBase` | Simpler configuration |
Expand All @@ -115,13 +115,13 @@ each example.

| Integration | Total Size (minified) | Total Size (minified + gzipped) |
| ------------------------ | ------------------------- | ------------------------------- |
| **Core only (Binary)** | 3.50 KiB | **1.56 KiB** |
| **Core only (String)** | 4.86 KiB | **2.07 KiB** |
| **Core only (Both)** | 7.96 KiB | **3.02 KiB** |
| **Drizzle ORM (Binary)** | 4.56 KiB (Core +1.06 KiB) | **2.01 KiB** (Core +0.46 KiB) |
| **Drizzle ORM (String)** | 5.93 KiB (Core +1.07 KiB) | **2.51 KiB** (Core +0.44 KiB) |
| **Drizzle ORM (Both)** | 8.99 KiB (Core +1.03 KiB) | **3.46 KiB** (Core +0.44 KiB) |
| **Prisma ORM (Both)** | 9.30 KiB (Core +1.35 KiB) | **3.64 KiB** (Core +0.62 KiB) |
| **Core only (Binary)** | 3.37 KiB | **1.45 KiB** |
| **Core only (String)** | 4.15 KiB | **1.82 KiB** |
| **Core only (Both)** | 7.24 KiB | **2.76 KiB** |
| **Drizzle ORM (Binary)** | 4.36 KiB (Core +1.00 KiB) | **1.90 KiB** (Core +0.45 KiB) |
| **Drizzle ORM (String)** | 5.15 KiB (Core +1.00 KiB) | **2.25 KiB** (Core +0.42 KiB) |
| **Drizzle ORM (Both)** | 8.21 KiB (Core +0.97 KiB) | **3.19 KiB** (Core +0.43 KiB) |
| **Prisma ORM (Both)** | 8.56 KiB (Core +1.32 KiB) | **3.39 KiB** (Core +0.63 KiB) |

## Security Considerations

Expand Down Expand Up @@ -155,7 +155,7 @@ yarn add fraci
pnpm add fraci

# or
bun add fraci
pnpm add fraci
```

> [!NOTE]
Expand Down Expand Up @@ -273,7 +273,7 @@ export const fiArticles = defineDrizzleFraci(
```typescript
import { getFraciErrorCode } from "fraci";
import { drizzleFraci } from "fraci/drizzle";
// Or import `drizzleFraciSync` if you're using synchronous database (i.e. Bun SQLite)
// Or import `drizzleFraciSync` if you're using a synchronous database driver
import { articles, fiArticles } from "./schema";

// Create your own function to check if the error is a unique constraint error
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": "6",
"dialect": "sqlite",
"id": "9eb3cf68-7056-4453-8cfb-12501dd1d568",
"id": "afaf7426-98e3-42a1-8a47-f33728292ba3",
"prevId": "00000000-0000-0000-0000-000000000000",
"tables": {
"exampleItem": {
Expand Down Expand Up @@ -55,7 +55,10 @@
"indexes": {
"group_id_fi_idx": {
"name": "group_id_fi_idx",
"columns": ["group_id", "fi"],
"columns": [
"group_id",
"fi"
],
"isUnique": true
}
},
Expand All @@ -75,4 +78,4 @@
"internal": {
"indexes": {}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
{
"idx": 0,
"version": "6",
"when": 1742387144991,
"when": 1785435581031,
"tag": "0000_init",
"breakpoints": true
}
]
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": "6",
"dialect": "sqlite",
"id": "ea494bc0-2dd1-4652-84b1-33207ad9b5b2",
"id": "47bbb0c1-1652-47c2-acf8-8fe63545a4b7",
"prevId": "00000000-0000-0000-0000-000000000000",
"tables": {
"exampleItem": {
Expand Down Expand Up @@ -55,7 +55,10 @@
"indexes": {
"group_id_fi_idx": {
"name": "group_id_fi_idx",
"columns": ["group_id", "fi"],
"columns": [
"group_id",
"fi"
],
"isUnique": true
}
},
Expand All @@ -75,4 +78,4 @@
"internal": {
"indexes": {}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
{
"idx": 0,
"version": "6",
"when": 1742387146992,
"when": 1785435581856,
"tag": "0000_init",
"breakpoints": true
}
]
}
}
72 changes: 54 additions & 18 deletions packages/core/drizzle/migrations/meta/0000_snapshot.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": "6",
"dialect": "sqlite",
"id": "313dfcaa-b5d1-4940-946d-a502d899331e",
"id": "236f29c5-2306-4e3a-b0c6-84cb122d2864",
"prevId": "00000000-0000-0000-0000-000000000000",
"tables": {
"article": {
Expand Down Expand Up @@ -62,7 +62,10 @@
"indexes": {
"user_id_fi_idx": {
"name": "user_id_fi_idx",
"columns": ["user_id", "fi"],
"columns": [
"user_id",
"fi"
],
"isUnique": true
}
},
Expand All @@ -71,8 +74,12 @@
"name": "article_user_id_user_id_fk",
"tableFrom": "article",
"tableTo": "user",
"columnsFrom": ["user_id"],
"columnsTo": ["id"],
"columnsFrom": [
"user_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
Expand Down Expand Up @@ -146,12 +153,17 @@
"indexes": {
"article_id_fi_idx": {
"name": "article_id_fi_idx",
"columns": ["article_id", "fi"],
"columns": [
"article_id",
"fi"
],
"isUnique": true
},
"user_id_idx": {
"name": "user_id_idx",
"columns": ["user_id"],
"columns": [
"user_id"
],
"isUnique": false
}
},
Expand All @@ -160,17 +172,25 @@
"name": "photo_article_id_article_id_fk",
"tableFrom": "photo",
"tableTo": "article",
"columnsFrom": ["article_id"],
"columnsTo": ["id"],
"columnsFrom": [
"article_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"photo_user_id_user_id_fk": {
"name": "photo_user_id_user_id_fk",
"tableFrom": "photo",
"tableTo": "user",
"columnsFrom": ["user_id"],
"columnsTo": ["id"],
"columnsFrom": [
"user_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
Expand Down Expand Up @@ -216,7 +236,9 @@
"indexes": {
"name_idx": {
"name": "name_idx",
"columns": ["name"],
"columns": [
"name"
],
"isUnique": false
}
},
Expand Down Expand Up @@ -283,12 +305,18 @@
"indexes": {
"tag_id_photo_fi_idx": {
"name": "tag_id_photo_fi_idx",
"columns": ["tag_id", "photo_fi"],
"columns": [
"tag_id",
"photo_fi"
],
"isUnique": true
},
"photo_id_tag_fi_idx": {
"name": "photo_id_tag_fi_idx",
"columns": ["photo_id", "tag_fi"],
"columns": [
"photo_id",
"tag_fi"
],
"isUnique": true
}
},
Expand All @@ -297,17 +325,25 @@
"name": "tagsOnPhotos_photo_id_photo_id_fk",
"tableFrom": "tagsOnPhotos",
"tableTo": "photo",
"columnsFrom": ["photo_id"],
"columnsTo": ["id"],
"columnsFrom": [
"photo_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"tagsOnPhotos_tag_id_tag_id_fk": {
"name": "tagsOnPhotos_tag_id_tag_id_fk",
"tableFrom": "tagsOnPhotos",
"tableTo": "tag",
"columnsFrom": ["tag_id"],
"columnsTo": ["id"],
"columnsFrom": [
"tag_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
Expand Down Expand Up @@ -374,4 +410,4 @@
"internal": {
"indexes": {}
}
}
}
4 changes: 2 additions & 2 deletions packages/core/drizzle/migrations/meta/_journal.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
{
"idx": 0,
"version": "6",
"when": 1742387143559,
"when": 1785435580114,
"tag": "0000_init",
"breakpoints": true
}
]
}
}
2 changes: 1 addition & 1 deletion packages/core/examples/common/client-base.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect } from "bun:test";
import { expect } from "vite-plus/test";
import { hc } from "hono/client";
import type { ServerType } from "./server-base.js";

Expand Down
2 changes: 1 addition & 1 deletion packages/core/examples/core-only/client.string.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Note that this test needs the package to be built before running and type checking.
import { test } from "bun:test";
import { test } from "vite-plus/test";
import { runTest } from "../common/client-base.js";
import app from "./server.string.js";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Note that this test needs the package to be built before running and type checking.
import { test } from "bun:test";
import { test } from "vite-plus/test";
import { runTest } from "../common/client-base.js";
import app from "./server.binary.js";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Note that this test needs the package to be built before running and type checking.
import { test } from "bun:test";
import { test } from "vite-plus/test";
import { runTest } from "../common/client-base.js";
import app from "./server.string.js";

Expand Down
8 changes: 4 additions & 4 deletions packages/core/examples/drizzle-orm-sync/entrypoint.all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import {
exampleItems as exampleItemsString,
fiExampleItems as fiExampleItemsString,
} from "../../drizzle/schema.e2e-string.js";
import { setupDrizzleDBBunSQLite as setupDrizzleDBBunSQLiteBinary } from "../../test/drizzle.e2e-binary.js";
import { setupDrizzleDBBunSQLite as setupDrizzleDBBunSQLiteString } from "../../test/drizzle.e2e-string.js";
import { setupDrizzleDBBetterSQLite as setupDrizzleDBBetterSQLiteBinary } from "../../test/drizzle.e2e-binary.js";
import { setupDrizzleDBBetterSQLite as setupDrizzleDBBetterSQLiteString } from "../../test/drizzle.e2e-string.js";

const dbBinary = setupDrizzleDBBunSQLiteBinary();
const dbString = setupDrizzleDBBunSQLiteString();
const dbBinary = setupDrizzleDBBetterSQLiteBinary();
const dbString = setupDrizzleDBBetterSQLiteString();

const app = new Hono().get("/test", async (c) => {
const [binaryFI] = drizzleFraciSync(
Expand Down
4 changes: 2 additions & 2 deletions packages/core/examples/drizzle-orm-sync/server.binary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import {
exampleItems,
fiExampleItems,
} from "../../drizzle/schema.e2e-binary.js";
import { setupDrizzleDBBunSQLite } from "../../test/drizzle.e2e-binary.js";
import { setupDrizzleDBBetterSQLite } from "../../test/drizzle.e2e-binary.js";
import type { ServerType } from "../common/server-base.js";

const db = setupDrizzleDBBunSQLite();
const db = setupDrizzleDBBetterSQLite();

// Fraci does not have a built-in function to detect index conflict errors for Drizzle ORM, since Drizzle ORM does not have a unified error handling mechanism.
function isIndexConflictError(error: unknown): boolean {
Expand Down
Loading