@fragno-dev/corpus 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,7 +7,7 @@ CRUD operations and querying with conditions.
7
7
  import { defineFragment, instantiate } from "@fragno-dev/core";
8
8
  import { withDatabase } from "@fragno-dev/db";
9
9
  import { schema, idColumn, column } from "@fragno-dev/db/schema";
10
- import type { AbstractQuery } from "@fragno-dev/db/query";
10
+ import type { SimpleQueryInterface } from "@fragno-dev/db/query";
11
11
  import { buildDatabaseFragmentsTest } from "@fragno-dev/test";
12
12
  ```
13
13
 
@@ -39,7 +39,7 @@ type UserSchema = typeof userSchema;
39
39
 
40
40
  ```typescript @fragno-test-init
41
41
  // Create a test fragment with database
42
- const testFragmentDef = defineFragment<{}>("test-db-fragment")
42
+ const testFragmentDef = defineFragment<{}>("test-fragment")
43
43
  .extend(withDatabase(userSchema))
44
44
  .providesBaseService(() => ({}))
45
45
  .build();
@@ -7,54 +7,3 @@ import { DrizzleAdapter } from "@fragno-dev/db/adapters/drizzle";
7
7
  import type { NodePgDatabase } from "drizzle-orm/node-postgres";
8
8
  import type { PgliteDatabase } from "drizzle-orm/pglite";
9
9
  ```
10
-
11
- ## Basic Setup
12
-
13
- Create a DrizzleAdapter with your Drizzle database instance and provider.
14
-
15
- ```typescript @fragno-test:basic-setup types-only
16
- interface MyDatabase extends Record<string, unknown> {
17
- users: {
18
- id: string;
19
- email: string;
20
- name: string;
21
- };
22
- posts: {
23
- id: string;
24
- title: string;
25
- content: string;
26
- authorId: string;
27
- };
28
- }
29
-
30
- declare const db: NodePgDatabase<MyDatabase>;
31
-
32
- export const adapter = new DrizzleAdapter({
33
- db,
34
- provider: "postgresql",
35
- });
36
- ```
37
-
38
- The adapter requires your Drizzle instance and the database provider (`"postgresql"`, `"mysql"`, or
39
- `"sqlite"`).
40
-
41
- ## Factory Function
42
-
43
- For async or sync database initialization, pass a factory function instead of a direct instance.
44
-
45
- ```typescript @fragno-test:factory-function types-only
46
- import type { PgliteDatabase } from "drizzle-orm/pglite";
47
-
48
- async function createDatabase(): Promise<PgliteDatabase> {
49
- // Async initialization logic
50
- const db = {} as PgliteDatabase;
51
- return db;
52
- }
53
-
54
- export const adapter = new DrizzleAdapter({
55
- db: createDatabase,
56
- provider: "postgresql",
57
- });
58
- ```
59
-
60
- Factory functions can also be synchronous for lazy initialization scenarios.
@@ -4,56 +4,54 @@ The KyselyAdapter connects Fragno's database API to your Kysely database instanc
4
4
 
5
5
  ```typescript @fragno-imports
6
6
  import { KyselyAdapter } from "@fragno-dev/db/adapters/kysely";
7
- import { Kysely } from "kysely";
8
- import type { Dialect } from "kysely";
7
+ import {
8
+ PGLiteDriverConfig,
9
+ SQLocalDriverConfig,
10
+ BetterSQLite3DriverConfig,
11
+ } from "@fragno-dev/db/drivers";
12
+ import { SqliteDialect, PostgresDialect, MysqlDialect } from "@fragno-dev/db/dialects";
13
+ import type { Dialect } from "@fragno-dev/db/sql-driver";
14
+ import SQLite from "better-sqlite3";
15
+ import { KyselyPGlite } from "kysely-pglite";
9
16
  ```
10
17
 
11
18
  ## Basic Setup
12
19
 
13
- Create a KyselyAdapter with your Kysely database instance and provider.
20
+ Create a KyselyAdapter with your Kysely dialect and driver configuration.
14
21
 
15
22
  ```typescript @fragno-test:basic-setup types-only
16
- interface MyDatabase {
17
- users: {
18
- id: string;
19
- email: string;
20
- name: string;
21
- };
22
- posts: {
23
- id: string;
24
- title: string;
25
- content: string;
26
- authorId: string;
27
- };
28
- }
29
-
30
- declare const dialect: Dialect;
31
-
32
- export const db = new Kysely<MyDatabase>({
33
- dialect,
23
+ const dialect = new SqliteDialect({
24
+ database: new SQLite(":memory:"),
34
25
  });
35
26
 
36
27
  export const adapter = new KyselyAdapter({
37
- db,
38
- provider: "postgresql",
28
+ dialect,
29
+ driverConfig: new BetterSQLite3DriverConfig(),
39
30
  });
40
31
  ```
41
32
 
42
- The adapter requires your Kysely instance and the database provider (`"postgresql"`, `"mysql"`, or
43
- `"sqlite"`).
33
+ The adapter requires:
44
34
 
45
- ## Factory Function
35
+ - `dialect`: A Kysely dialect instance for your database
36
+ - `driverConfig`: A driver configuration matching your database type (`PGLiteDriverConfig`,
37
+ `SQLocalDriverConfig`, or `BetterSQLite3DriverConfig`)
46
38
 
47
- For async database initialization, pass a factory function instead of a direct instance.
39
+ ## First Party Kysely Dialects
48
40
 
49
- ```typescript @fragno-test:factory-function types-only
50
- async function createDatabase() {
51
- // Async initialization logic
52
- return new Kysely({ dialect: {} as Dialect });
53
- }
41
+ Fragno re-exports the "first party" Kysely dialects for SQLite, PostgreSQL, and MySQL. This means
42
+ you can use these dialects without installing them yourself.
43
+
44
+ ```typescript @fragno-test:first-party-kysely-dialects types-only
45
+ import { SqliteDialect, PostgresDialect, MysqlDialect } from "@fragno-dev/db/dialects";
46
+ ```
47
+
48
+ ## PGLite Example
49
+
50
+ ```typescript @fragno-test:postgresql-example types-only
51
+ const { dialect } = await KyselyPGlite.create();
54
52
 
55
53
  export const adapter = new KyselyAdapter({
56
- db: createDatabase,
57
- provider: "postgresql",
54
+ dialect,
55
+ driverConfig: new PGLiteDriverConfig(),
58
56
  });
59
57
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fragno-dev/corpus",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -16,14 +16,17 @@
16
16
  "dist"
17
17
  ],
18
18
  "devDependencies": {
19
+ "@types/better-sqlite3": "^7.6.13",
19
20
  "@types/marked-terminal": "^6.1.1",
20
21
  "@types/node": "^22",
22
+ "better-sqlite3": "^12.5.0",
21
23
  "drizzle-orm": "^0.44.7",
22
24
  "kysely": "^0.28.0",
25
+ "kysely-pglite": "^0.6.1",
23
26
  "zod": "^4.0.5",
24
- "@fragno-dev/core": "0.1.9",
25
- "@fragno-dev/db": "0.1.15",
26
- "@fragno-dev/test": "0.1.13",
27
+ "@fragno-dev/core": "0.1.11",
28
+ "@fragno-dev/db": "0.2.0",
29
+ "@fragno-dev/test": "1.0.0",
27
30
  "@fragno-private/typescript-config": "0.0.1",
28
31
  "@fragno-private/vitest-config": "0.0.0"
29
32
  },