@fragno-dev/db 0.1.0 → 0.1.1
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.
- package/.turbo/turbo-build.log +6 -6
- package/.turbo/turbo-test.log +27 -26
- package/CHANGELOG.md +6 -0
- package/dist/adapters/drizzle/drizzle-uow-compiler.js +1 -1
- package/dist/adapters/kysely/kysely-query.js.map +1 -1
- package/dist/query/query.d.ts +2 -2
- package/dist/query/query.d.ts.map +1 -1
- package/package.json +4 -6
- package/src/adapters/drizzle/drizzle-uow-compiler.test.ts +1 -1
- package/src/adapters/kysely/kysely-query.ts +1 -1
- package/src/fragment.test.ts +47 -1
- package/src/query/query.ts +4 -2
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
$ tsdown
|
|
2
2
|
[34mℹ[39m tsdown [2mv0.15.9[22m powered by rolldown [2mv1.0.0-beta.44[22m
|
|
3
3
|
[34mℹ[39m Using tsdown config: [4m/home/runner/work/fragno/fragno/packages/fragno-db/tsdown.config.ts[24m
|
|
4
|
-
[34mℹ[39m entry: [34msrc/fragment.ts, src/id.ts, src/mod.ts, src/query/cursor.ts, src/query/query.ts, src/query/unit-of-work.ts, src/schema/create.ts, src/adapters/
|
|
4
|
+
[34mℹ[39m entry: [34msrc/fragment.ts, src/id.ts, src/mod.ts, src/query/cursor.ts, src/query/query.ts, src/query/unit-of-work.ts, src/schema/create.ts, src/adapters/kysely/kysely-adapter.ts, src/adapters/drizzle/drizzle-adapter.ts[39m
|
|
5
5
|
[34mℹ[39m tsconfig: [34mtsconfig.json[39m
|
|
6
6
|
[34mℹ[39m Build start
|
|
7
7
|
[34mℹ[39m [2mdist/[22m[1mschema/create.js[22m [2m17.16 kB[22m [2m│ gzip: 4.51 kB[22m
|
|
@@ -22,7 +22,7 @@ $ tsdown
|
|
|
22
22
|
[34mℹ[39m [2mdist/[22madapters/kysely/migration/execute.js.map [2m16.41 kB[22m [2m│ gzip: 4.67 kB[22m
|
|
23
23
|
[34mℹ[39m [2mdist/[22madapters/drizzle/drizzle-uow-compiler.js [2m13.37 kB[22m [2m│ gzip: 3.43 kB[22m
|
|
24
24
|
[34mℹ[39m [2mdist/[22madapters/kysely/kysely-uow-compiler.js.map [2m13.33 kB[22m [2m│ gzip: 3.78 kB[22m
|
|
25
|
-
[34mℹ[39m [2mdist/[22madapters/kysely/kysely-query.js.map [2m12.
|
|
25
|
+
[34mℹ[39m [2mdist/[22madapters/kysely/kysely-query.js.map [2m12.66 kB[22m [2m│ gzip: 3.40 kB[22m
|
|
26
26
|
[34mℹ[39m [2mdist/[22mschema/create.d.ts.map [2m12.26 kB[22m [2m│ gzip: 4.66 kB[22m
|
|
27
27
|
[34mℹ[39m [2mdist/[22madapters/kysely/kysely-query-builder.js [2m12.02 kB[22m [2m│ gzip: 3.47 kB[22m
|
|
28
28
|
[34mℹ[39m [2mdist/[22mschema/serialize.js.map [2m11.74 kB[22m [2m│ gzip: 2.73 kB[22m
|
|
@@ -43,7 +43,7 @@ $ tsdown
|
|
|
43
43
|
[34mℹ[39m [2mdist/[22madapters/kysely/kysely-uow-executor.js.map [2m 7.10 kB[22m [2m│ gzip: 2.53 kB[22m
|
|
44
44
|
[34mℹ[39m [2mdist/[22madapters/drizzle/drizzle-uow-decoder.js.map [2m 7.00 kB[22m [2m│ gzip: 2.58 kB[22m
|
|
45
45
|
[34mℹ[39m [2mdist/[22mnode_modules/.bun/drizzle-orm@0.44.6_4fae081eecb963e2/node_modules/drizzle-orm/sql/expressions/conditions.js.map [2m 6.92 kB[22m [2m│ gzip: 1.53 kB[22m
|
|
46
|
-
[34mℹ[39m [2mdist/[22mquery/query.d.ts.map [2m 6.
|
|
46
|
+
[34mℹ[39m [2mdist/[22mquery/query.d.ts.map [2m 6.51 kB[22m [2m│ gzip: 2.43 kB[22m
|
|
47
47
|
[34mℹ[39m [2mdist/[22madapters/kysely/kysely-query-compiler.js.map [2m 6.10 kB[22m [2m│ gzip: 1.48 kB[22m
|
|
48
48
|
[34mℹ[39m [2mdist/[22madapters/kysely/kysely-query.js [2m 5.92 kB[22m [2m│ gzip: 1.65 kB[22m
|
|
49
49
|
[34mℹ[39m [2mdist/[22madapters/kysely/kysely-uow-compiler.js [2m 5.84 kB[22m [2m│ gzip: 1.77 kB[22m
|
|
@@ -120,7 +120,7 @@ $ tsdown
|
|
|
120
120
|
[34mℹ[39m [2mdist/[22mshared/providers.d.ts.map [2m 0.15 kB[22m [2m│ gzip: 0.13 kB[22m
|
|
121
121
|
[34mℹ[39m [2mdist/[22m[32m[1mquery/unit-of-work.d.ts[22m[39m [2m17.49 kB[22m [2m│ gzip: 4.26 kB[22m
|
|
122
122
|
[34mℹ[39m [2mdist/[22m[32m[1mschema/create.d.ts[22m[39m [2m17.28 kB[22m [2m│ gzip: 4.20 kB[22m
|
|
123
|
-
[34mℹ[39m [2mdist/[22m[32m[1mquery/query.d.ts[22m[39m [2m 6.
|
|
123
|
+
[34mℹ[39m [2mdist/[22m[32m[1mquery/query.d.ts[22m[39m [2m 6.19 kB[22m [2m│ gzip: 1.59 kB[22m
|
|
124
124
|
[34mℹ[39m [2mdist/[22m[32m[1mquery/cursor.d.ts[22m[39m [2m 2.57 kB[22m [2m│ gzip: 0.93 kB[22m
|
|
125
125
|
[34mℹ[39m [2mdist/[22m[32m[1mfragment.d.ts[22m[39m [2m 2.39 kB[22m [2m│ gzip: 0.75 kB[22m
|
|
126
126
|
[34mℹ[39m [2mdist/[22m[32m[1mmod.d.ts[22m[39m [2m 2.38 kB[22m [2m│ gzip: 0.78 kB[22m
|
|
@@ -137,5 +137,5 @@ $ tsdown
|
|
|
137
137
|
[34mℹ[39m [2mdist/[22m[32mshared/providers.d.ts[39m [2m 0.26 kB[22m [2m│ gzip: 0.19 kB[22m
|
|
138
138
|
[34mℹ[39m [2mdist/[22m[32mutil/types.d.ts[39m [2m 0.26 kB[22m [2m│ gzip: 0.21 kB[22m
|
|
139
139
|
[34mℹ[39m [2mdist/[22m[32madapters/drizzle/drizzle-uow-compiler.d.ts[39m [2m 0.22 kB[22m [2m│ gzip: 0.17 kB[22m
|
|
140
|
-
[34mℹ[39m 133 files, total: 687.
|
|
141
|
-
[32m✔[39m Build complete in [
|
|
140
|
+
[34mℹ[39m 133 files, total: 687.12 kB
|
|
141
|
+
[32m✔[39m Build complete in [32m12650ms[39m
|
package/.turbo/turbo-test.log
CHANGED
|
@@ -3,34 +3,35 @@ $ vitest run
|
|
|
3
3
|
[1m[46m RUN [49m[22m [36mv3.2.4 [39m[90m/home/runner/work/fragno/fragno/packages/fragno-db[39m
|
|
4
4
|
[2mCoverage enabled with [22m[33mistanbul[39m
|
|
5
5
|
|
|
6
|
-
[32m✓[39m src/adapters/kysely/
|
|
7
|
-
[32m✓[39m src/adapters/kysely/
|
|
8
|
-
[32m✓[39m src/adapters/kysely/kysely-uow-joins.test.ts [2m([22m[2m26 tests[22m[2m)[22m[33m
|
|
9
|
-
[32m✓[39m src/adapters/kysely/kysely-uow-compiler.test.ts [2m([22m[2m42 tests[22m[2m)[22m[33m
|
|
10
|
-
[32m✓[39m src/schema/create.test.ts [2m([22m[2m28 tests[22m[2m)[22m[32m
|
|
11
|
-
[32m✓[39m src/adapters/kysely/migration/execute-mysql.test.ts [2m([22m[2m36 tests[22m[2m)[22m[33m
|
|
6
|
+
[32m✓[39m src/adapters/kysely/migration/execute-postgres.test.ts [2m([22m[2m50 tests[22m[2m)[22m[33m 779[2mms[22m[39m
|
|
7
|
+
[32m✓[39m src/adapters/kysely/kysely-query-builder.test.ts [2m([22m[2m83 tests[22m[2m)[22m[33m 575[2mms[22m[39m
|
|
8
|
+
[32m✓[39m src/adapters/kysely/kysely-uow-joins.test.ts [2m([22m[2m26 tests[22m[2m)[22m[33m 422[2mms[22m[39m
|
|
9
|
+
[32m✓[39m src/adapters/kysely/kysely-uow-compiler.test.ts [2m([22m[2m42 tests[22m[2m)[22m[33m 467[2mms[22m[39m
|
|
10
|
+
[32m✓[39m src/schema/create.test.ts [2m([22m[2m28 tests[22m[2m)[22m[32m 208[2mms[22m[39m
|
|
11
|
+
[32m✓[39m src/adapters/kysely/migration/execute-mysql.test.ts [2m([22m[2m36 tests[22m[2m)[22m[33m 331[2mms[22m[39m
|
|
12
12
|
[32m✓[39m src/query/unit-of-work.test.ts [2m([22m[2m30 tests[22m[2m)[22m[32m 262[2mms[22m[39m
|
|
13
|
-
[32m✓[39m src/adapters/drizzle/generate.test.ts [2m([22m[2m13 tests[22m[2m)[22m[32m
|
|
14
|
-
[32m✓[39m src/query/result-transform.test.ts [2m([22m[2m47 tests[22m[2m)[22m[32m
|
|
15
|
-
[32m✓[39m src/schema/serialize.test.ts [2m([22m[2m86 tests[22m[2m)[22m[32m
|
|
16
|
-
[32m✓[39m src/adapters/drizzle/drizzle-uow-compiler.test.ts [2m([22m[2m45 tests[22m[2m)[22m[33m
|
|
17
|
-
[32m✓[39m src/adapters/kysely/kysely-adapter-pglite.test.ts [2m([22m[2m7 tests[22m[2m)[22m[33m
|
|
18
|
-
[33m[2m✓[22m[39m KyselyAdapter PGLite[2m > [22mshould run migrations and basic queries [33m
|
|
19
|
-
|
|
20
|
-
[32m✓[39m src/query/
|
|
21
|
-
[32m✓[39m src/
|
|
22
|
-
[32m✓[39m src/migration-engine/
|
|
23
|
-
[32m✓[39m src/
|
|
24
|
-
[32m✓[39m src/
|
|
25
|
-
[32m✓[39m src/adapters/drizzle/migrate-drizzle.test.ts [2m([22m[2m1 test[22m[2m)[22m[33m
|
|
26
|
-
[32m✓[39m src/
|
|
27
|
-
[32m✓[39m src/query/
|
|
28
|
-
[32m✓[39m src/
|
|
29
|
-
[32m✓[39m src/adapters/
|
|
30
|
-
[32m✓[39m src/adapters/drizzle/
|
|
13
|
+
[32m✓[39m src/adapters/drizzle/generate.test.ts [2m([22m[2m13 tests[22m[2m)[22m[32m 154[2mms[22m[39m
|
|
14
|
+
[32m✓[39m src/query/result-transform.test.ts [2m([22m[2m47 tests[22m[2m)[22m[32m 173[2mms[22m[39m
|
|
15
|
+
[32m✓[39m src/schema/serialize.test.ts [2m([22m[2m86 tests[22m[2m)[22m[32m 206[2mms[22m[39m
|
|
16
|
+
[32m✓[39m src/adapters/drizzle/drizzle-uow-compiler.test.ts [2m([22m[2m45 tests[22m[2m)[22m[33m 24852[2mms[22m[39m
|
|
17
|
+
[32m✓[39m src/adapters/kysely/kysely-adapter-pglite.test.ts [2m([22m[2m7 tests[22m[2m)[22m[33m 10686[2mms[22m[39m
|
|
18
|
+
[33m[2m✓[22m[39m KyselyAdapter PGLite[2m > [22mshould run migrations and basic queries [33m 623[2mms[22m[39m
|
|
19
|
+
[33m[2m✓[22m[39m KyselyAdapter PGLite[2m > [22mshould support many-to-many queries through junction table [33m 343[2mms[22m[39m
|
|
20
|
+
[32m✓[39m src/query/query-type.test.ts [2m([22m[2m29 tests[22m[2m)[22m[32m 29[2mms[22m[39m
|
|
21
|
+
[32m✓[39m src/query/condition-builder.test.ts [2m([22m[2m20 tests[22m[2m)[22m[32m 34[2mms[22m[39m
|
|
22
|
+
[32m✓[39m src/migration-engine/create.test.ts [2m([22m[2m20 tests[22m[2m)[22m[32m 56[2mms[22m[39m
|
|
23
|
+
[32m✓[39m src/migration-engine/auto-from-schema.test.ts [2m([22m[2m13 tests[22m[2m)[22m[32m 76[2mms[22m[39m
|
|
24
|
+
[32m✓[39m src/adapters/drizzle/drizzle-adapter-pglite.test.ts [2m([22m[2m5 tests[22m[2m)[22m[33m 8905[2mms[22m[39m
|
|
25
|
+
[32m✓[39m src/adapters/drizzle/migrate-drizzle.test.ts [2m([22m[2m1 test[22m[2m)[22m[33m 491[2mms[22m[39m
|
|
26
|
+
[32m✓[39m src/fragment.test.ts [2m([22m[2m11 tests[22m[2m)[22m[32m 57[2mms[22m[39m
|
|
27
|
+
[32m✓[39m src/query/cursor.test.ts [2m([22m[2m18 tests[22m[2m)[22m[32m 41[2mms[22m[39m
|
|
28
|
+
[32m✓[39m src/query/unit-of-work-types.test.ts [2m([22m[2m5 tests[22m[2m)[22m[32m 37[2mms[22m[39m
|
|
29
|
+
[32m✓[39m src/adapters/kysely/migration/kysely-migrator.test.ts [2m([22m[2m9 tests[22m[2m)[22m[32m 142[2mms[22m[39m
|
|
30
|
+
[32m✓[39m src/adapters/drizzle/drizzle-adapter.test.ts [2m([22m[2m4 tests[22m[2m)[22m[32m 53[2mms[22m[39m
|
|
31
|
+
[32m✓[39m src/adapters/drizzle/join-column-utils.test.ts [2m([22m[2m8 tests[22m[2m)[22m[32m 23[2mms[22m[39m
|
|
31
32
|
|
|
32
33
|
[2m Test Files [22m [1m[32m24 passed[39m[22m[90m (24)[39m
|
|
33
34
|
[2m Tests [22m [1m[32m636 passed[39m[22m[90m (636)[39m
|
|
34
|
-
[2m Start at [22m
|
|
35
|
-
[2m Duration [22m
|
|
35
|
+
[2m Start at [22m 12:33:42
|
|
36
|
+
[2m Duration [22m 47.25s[2m (transform 20.15s, setup 0ms, collect 51.86s, tests 49.06s, environment 119ms, prepare 11.76s)[22m
|
|
36
37
|
|
package/CHANGELOG.md
CHANGED
|
@@ -2,12 +2,12 @@ import { Column } from "../../schema/create.js";
|
|
|
2
2
|
import { serialize } from "../../schema/serialize.js";
|
|
3
3
|
import { decodeCursor, serializeCursorValues } from "../../query/cursor.js";
|
|
4
4
|
import { buildCondition } from "../../query/condition-builder.js";
|
|
5
|
+
import { ReferenceSubquery, encodeValues } from "../../query/result-transform.js";
|
|
5
6
|
import { sql } from "../../node_modules/.bun/drizzle-orm@0.44.6_4fae081eecb963e2/node_modules/drizzle-orm/sql/sql.js";
|
|
6
7
|
import { and, eq, gt, gte, inArray, isNotNull, isNull, like, lt, lte, ne, not, notInArray, notLike, or } from "../../node_modules/.bun/drizzle-orm@0.44.6_4fae081eecb963e2/node_modules/drizzle-orm/sql/expressions/conditions.js";
|
|
7
8
|
import { asc, desc } from "../../node_modules/.bun/drizzle-orm@0.44.6_4fae081eecb963e2/node_modules/drizzle-orm/sql/expressions/select.js";
|
|
8
9
|
import { count } from "../../node_modules/.bun/drizzle-orm@0.44.6_4fae081eecb963e2/node_modules/drizzle-orm/sql/functions/aggregate.js";
|
|
9
10
|
import { parseDrizzle } from "./shared.js";
|
|
10
|
-
import { ReferenceSubquery, encodeValues } from "../../query/result-transform.js";
|
|
11
11
|
import { getOrderedJoinColumns } from "./join-column-utils.js";
|
|
12
12
|
|
|
13
13
|
//#region src/adapters/drizzle/drizzle-uow-compiler.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kysely-query.js","names":["executor: UOWExecutor<CompiledQuery, unknown>","decoder: UOWDecoder<T>","whereConfig: { indexName?: string; condition?: unknown }","setValues: unknown"],"sources":["../../../src/adapters/kysely/kysely-query.ts"],"sourcesContent":["import type { AbstractQuery } from \"../../query/query\";\nimport type { AnySchema } from \"../../schema/create\";\nimport type { KyselyConfig } from \"./kysely-adapter\";\nimport type { CompiledMutation, UOWDecoder, UOWExecutor } from \"../../query/unit-of-work\";\nimport { decodeResult } from \"../../query/result-transform\";\nimport { createKyselyUOWCompiler } from \"./kysely-uow-compiler\";\nimport { executeKyselyRetrievalPhase, executeKyselyMutationPhase } from \"./kysely-uow-executor\";\nimport { UnitOfWork } from \"../../query/unit-of-work\";\nimport type { CompiledQuery } from \"kysely\";\n\n/**\n * Creates a Kysely-based query engine for the given schema.\n *\n * This is the main entry point for creating a database query interface using Kysely.\n * It uses a compiler-based architecture where queries are compiled to SQL and then executed,\n * enabling features like SQL snapshot testing.\n *\n * @param schema - The database schema definition\n * @param config - Kysely configuration containing the database instance and provider\n * @returns An AbstractQuery instance for performing database operations\n *\n * @example\n * ```ts\n * const queryEngine = fromKysely(mySchema, {\n * db: kysely,\n * provider: 'postgresql'\n * });\n *\n * const users = await queryEngine.findMany('users', {\n * where: (b) => b('age', '>', 18),\n * orderBy: [['name', 'asc']]\n * });\n * ```\n */\nexport function fromKysely<T extends AnySchema>(schema: T, config: KyselyConfig): AbstractQuery<T> {\n const { db: kysely, provider } = config;\n const uowCompiler = createKyselyUOWCompiler(schema, config);\n\n function createUOW(name?: string): UnitOfWork<T, []> {\n const executor: UOWExecutor<CompiledQuery, unknown> = {\n executeRetrievalPhase: (retrievalBatch: CompiledQuery[]) =>\n executeKyselyRetrievalPhase(kysely, retrievalBatch),\n executeMutationPhase: (mutationBatch: CompiledMutation<CompiledQuery>[]) =>\n executeKyselyMutationPhase(kysely, mutationBatch),\n };\n\n // Create a decoder function to transform raw results into application format\n const decoder: UOWDecoder<T> = (rawResults, ops) => {\n if (rawResults.length !== ops.length) {\n throw new Error(\"rawResults and ops must have the same length\");\n }\n\n return rawResults.map((rows, index) => {\n const op = ops[index];\n if (!op) {\n throw new Error(\"op must be defined\");\n }\n\n // Handle count operations differently - return the count number directly\n if (op.type === \"count\") {\n const rowArray = rows as Record<string, unknown>[];\n const firstRow = rowArray[0];\n if (!firstRow) {\n return 0;\n }\n const count = Number(firstRow[\"count\"]);\n if (Number.isNaN(count)) {\n throw new Error(`Unexpected result for count, received: ${count}`);\n }\n return count;\n }\n\n // Each result is an array of rows - decode each row\n const rowArray = rows as Record<string, unknown>[];\n return rowArray.map((row) => decodeResult(row, op.table, provider));\n });\n };\n\n return new UnitOfWork(schema, uowCompiler, executor, decoder, name);\n }\n\n return {\n async find(tableName, builderFn) {\n const uow = createUOW();\n uow.find(tableName, builderFn);\n // executeRetrieve returns an array of results (one per find operation)\n // Since we only have one find, unwrap the first result\n const [result]: unknown[][] = await uow.executeRetrieve();\n return result ?? [];\n },\n\n async findFirst(tableName, builderFn) {\n const uow = createUOW();\n if (builderFn) {\n uow.find(tableName, (b) => builderFn(b as never).pageSize(1));\n } else {\n uow.find(tableName, (b) => b.whereIndex(\"primary\").pageSize(1));\n }\n // executeRetrieve runs an array of `find` operation results, which each return an array of rows\n const [result]: unknown[][] = await uow.executeRetrieve();\n return result?.[0] ?? null;\n },\n\n async create(tableName, values) {\n const uow = createUOW();\n uow.create(tableName, values);\n const { success } = await uow.executeMutations();\n if (!success) {\n // This should not happen because we don't `.check()` this call.\n // TODO: Verify what happens when there are unique constraints\n throw new Error(\"Failed to create record\");\n }\n\n const [createdId] = uow.getCreatedIds();\n if (!createdId) {\n throw new Error(\"Failed to get created ID\");\n }\n return createdId;\n },\n\n async createMany(tableName, valuesArray) {\n const uow = createUOW();\n for (const values of valuesArray) {\n uow.create(tableName, values);\n }\n const { success } = await uow.executeMutations();\n if (!success) {\n throw new Error(\"Failed to create records\");\n }\n\n return uow.getCreatedIds();\n },\n\n async update(tableName, id, builderFn) {\n const uow = createUOW();\n uow.update(tableName, id, builderFn);\n const { success } = await uow.executeMutations();\n if (!success) {\n throw new Error(\"Failed to update record (version conflict or record not found)\");\n }\n },\n\n async updateMany(tableName, builderFn) {\n // Create a special builder that captures both where and set operations\n let whereConfig: { indexName?: string; condition?: unknown } = {};\n let setValues: unknown;\n\n const specialBuilder = {\n whereIndex(indexName: string, condition?: unknown) {\n whereConfig = { indexName, condition };\n return this;\n },\n set(values: unknown) {\n setValues = values;\n return this;\n },\n };\n\n builderFn(specialBuilder);\n\n if (!whereConfig.indexName) {\n throw new Error(\"whereIndex() must be called in updateMany\");\n }\n if (!setValues) {\n throw new Error(\"set() must be called in updateMany\");\n }\n\n // First, find all matching records\n const findUow = createUOW();\n findUow.find(tableName, (b) => {\n if (whereConfig.condition) {\n return b.whereIndex(whereConfig.indexName as never, whereConfig.condition as never);\n }\n return b.whereIndex(whereConfig.indexName as never);\n });\n const findResults: unknown[][] = await findUow.executeRetrieve();\n const records = findResults[0];\n\n if (!records || records.length === 0) {\n return;\n }\n\n // Now update all found records\n const updateUow = createUOW();\n for (const record of records as never as Array<{ id: unknown }>) {\n updateUow.update(tableName as string, record.id as string, (b) =>\n b.set(setValues as never),\n );\n }\n const { success } = await updateUow.executeMutations();\n if (!success) {\n throw new Error(\"Failed to update records (version conflict)\");\n }\n },\n\n async delete(tableName, id, builderFn) {\n const uow = createUOW();\n uow.delete(tableName, id, builderFn as never);\n const { success } = await uow.executeMutations();\n if (!success) {\n throw new Error(\"Failed to delete record (version conflict or record not found)\");\n }\n },\n\n async deleteMany(tableName, builderFn) {\n // Create a special builder that captures where configuration\n let whereConfig: { indexName?: string; condition?: unknown } = {};\n\n const specialBuilder = {\n whereIndex(indexName: string, condition?: unknown) {\n whereConfig = { indexName, condition };\n return this;\n },\n };\n\n // Safe: Call builderFn to capture the configuration\n builderFn(specialBuilder as never);\n\n if (!whereConfig.indexName) {\n throw new Error(\"whereIndex() must be called in deleteMany\");\n }\n\n // First, find all matching records\n const findUow = createUOW();\n findUow.find(tableName as string, (b) => {\n if (whereConfig.condition) {\n return b.whereIndex(whereConfig.indexName as never, whereConfig.condition as never);\n }\n return b.whereIndex(whereConfig.indexName as never);\n });\n const findResults2 = await findUow.executeRetrieve();\n const records = (findResults2 as unknown as [unknown])[0];\n\n // @ts-expect-error - Type narrowing doesn't work through unknown cast\n if (!records || records.length === 0) {\n return;\n }\n\n // Now delete all found records\n const deleteUow = createUOW();\n for (const record of records as never as Array<{ id: unknown }>) {\n deleteUow.delete(tableName as string, record.id as string);\n }\n const { success } = await deleteUow.executeMutations();\n if (!success) {\n throw new Error(\"Failed to delete records (version conflict)\");\n }\n },\n\n createUnitOfWork(name) {\n return createUOW(name);\n },\n } as AbstractQuery<T>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,SAAgB,WAAgC,QAAW,QAAwC;CACjG,MAAM,EAAE,IAAI,QAAQ,aAAa;CACjC,MAAM,cAAc,wBAAwB,QAAQ,OAAO;CAE3D,SAAS,UAAU,MAAkC;EACnD,MAAMA,WAAgD;GACpD,wBAAwB,mBACtB,4BAA4B,QAAQ,eAAe;GACrD,uBAAuB,kBACrB,2BAA2B,QAAQ,cAAc;GACpD;EAGD,MAAMC,WAA0B,YAAY,QAAQ;AAClD,OAAI,WAAW,WAAW,IAAI,OAC5B,OAAM,IAAI,MAAM,+CAA+C;AAGjE,UAAO,WAAW,KAAK,MAAM,UAAU;IACrC,MAAM,KAA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AAY,MAAM,IAAI,kBAAkB;AAChD,OAAI,CAAC,QACH,OAAM,IAAI,MAAM,iEAAiE;;EAIrF,MAAM,WAAW,WAAW,WAAW;GAErC,IAAID,cAA2D,EAAE;AAUjE,aARuB,EACrB,WAAW,WAAmB,WAAqB;AACjD,kBAAc;KAAE;KAAW;KAAW;AACtC,WAAO;MAEV,CAGiC;AAElC,OAAI,CAAC,YAAY,UACf,OAAM,IAAI,MAAM,4CAA4C;GAI9D,MAAM,UAAU,WAAW;AAC3B,WAAQ,KAAK,YAAsB,MAAM;AACvC,QAAI,YAAY,UACd,QAAO,EAAE,WAAW,YAAY,WAAoB,YAAY,UAAmB;AAErF,WAAO,EAAE,WAAW,YAAY,UAAmB;KACnD;GAEF,MAAM,WADe,MAAM,QAAQ,iBAAiB,EACG;AAGvD,OAAI,CAAC,WAAW,QAAQ,WAAW,EACjC;GAIF,MAAM,YAAY,WAAW;AAC7B,QAAK,MAAM,UAAU,QACnB,WAAU,OAAO,WAAqB,OAAO,GAAa;GAE5D,MAAM,EAAE,YAAY,MAAM,UAAU,kBAAkB;AACtD,OAAI,CAAC,QACH,OAAM,IAAI,MAAM,8CAA8C;;EAIlE,iBAAiB,MAAM;AACrB,UAAO,UAAU,KAAK;;EAEzB"}
|
|
1
|
+
{"version":3,"file":"kysely-query.js","names":["executor: UOWExecutor<CompiledQuery, unknown>","decoder: UOWDecoder<T>","whereConfig: { indexName?: string; condition?: unknown }","setValues: unknown"],"sources":["../../../src/adapters/kysely/kysely-query.ts"],"sourcesContent":["import type { AbstractQuery } from \"../../query/query\";\nimport type { AnySchema } from \"../../schema/create\";\nimport type { KyselyConfig } from \"./kysely-adapter\";\nimport type { CompiledMutation, UOWDecoder, UOWExecutor } from \"../../query/unit-of-work\";\nimport { decodeResult } from \"../../query/result-transform\";\nimport { createKyselyUOWCompiler } from \"./kysely-uow-compiler\";\nimport { executeKyselyRetrievalPhase, executeKyselyMutationPhase } from \"./kysely-uow-executor\";\nimport { UnitOfWork } from \"../../query/unit-of-work\";\nimport type { CompiledQuery } from \"kysely\";\n\n/**\n * Creates a Kysely-based query engine for the given schema.\n *\n * This is the main entry point for creating a database query interface using Kysely.\n * It uses a compiler-based architecture where queries are compiled to SQL and then executed,\n * enabling features like SQL snapshot testing.\n *\n * @param schema - The database schema definition\n * @param config - Kysely configuration containing the database instance and provider\n * @returns An AbstractQuery instance for performing database operations\n *\n * @example\n * ```ts\n * const queryEngine = fromKysely(mySchema, {\n * db: kysely,\n * provider: 'postgresql'\n * });\n *\n * const users = await queryEngine.findMany('users', {\n * where: (b) => b('age', '>', 18),\n * orderBy: [['name', 'asc']]\n * });\n * ```\n */\nexport function fromKysely<T extends AnySchema>(schema: T, config: KyselyConfig): AbstractQuery<T> {\n const { db: kysely, provider } = config;\n const uowCompiler = createKyselyUOWCompiler(schema, config);\n\n function createUOW(name?: string): UnitOfWork<T, []> {\n const executor: UOWExecutor<CompiledQuery, unknown> = {\n executeRetrievalPhase: (retrievalBatch: CompiledQuery[]) =>\n executeKyselyRetrievalPhase(kysely, retrievalBatch),\n executeMutationPhase: (mutationBatch: CompiledMutation<CompiledQuery>[]) =>\n executeKyselyMutationPhase(kysely, mutationBatch),\n };\n\n // Create a decoder function to transform raw results into application format\n const decoder: UOWDecoder<T> = (rawResults, ops) => {\n if (rawResults.length !== ops.length) {\n throw new Error(\"rawResults and ops must have the same length\");\n }\n\n return rawResults.map((rows, index) => {\n const op = ops[index];\n if (!op) {\n throw new Error(\"op must be defined\");\n }\n\n // Handle count operations differently - return the count number directly\n if (op.type === \"count\") {\n const rowArray = rows as Record<string, unknown>[];\n const firstRow = rowArray[0];\n if (!firstRow) {\n return 0;\n }\n const count = Number(firstRow[\"count\"]);\n if (Number.isNaN(count)) {\n throw new Error(`Unexpected result for count, received: ${count}`);\n }\n return count;\n }\n\n // Each result is an array of rows - decode each row\n const rowArray = rows as Record<string, unknown>[];\n return rowArray.map((row) => decodeResult(row, op.table, provider));\n });\n };\n\n return new UnitOfWork(schema, uowCompiler, executor, decoder, name);\n }\n\n return {\n async find(tableName, builderFn) {\n const uow = createUOW();\n uow.find(tableName, builderFn);\n // executeRetrieve returns an array of results (one per find operation)\n // Since we only have one find, unwrap the first result\n const [result]: unknown[][] = await uow.executeRetrieve();\n return result ?? [];\n },\n\n async findFirst(tableName, builderFn) {\n const uow = createUOW();\n if (builderFn) {\n uow.find(tableName, (b) => builderFn(b as never).pageSize(1));\n } else {\n uow.find(tableName, (b) => b.whereIndex(\"primary\").pageSize(1));\n }\n // executeRetrieve runs an array of `find` operation results, which each return an array of rows\n const [result]: unknown[][] = await uow.executeRetrieve();\n return result?.[0] ?? null;\n },\n\n async create(tableName, values) {\n const uow = createUOW();\n uow.create(tableName, values);\n const { success } = await uow.executeMutations();\n if (!success) {\n // This should not happen because we don't `.check()` this call.\n // TODO: Verify what happens when there are unique constraints\n throw new Error(\"Failed to create record\");\n }\n\n const [createdId] = uow.getCreatedIds();\n if (!createdId) {\n throw new Error(\"Failed to get created ID\");\n }\n return createdId;\n },\n\n async createMany(tableName, valuesArray) {\n const uow = createUOW();\n for (const values of valuesArray) {\n uow.create(tableName, values);\n }\n const { success } = await uow.executeMutations();\n if (!success) {\n throw new Error(\"Failed to create records\");\n }\n\n return uow.getCreatedIds();\n },\n\n async update(tableName, id, builderFn) {\n const uow = createUOW();\n uow.update(tableName, id, builderFn as never);\n const { success } = await uow.executeMutations();\n if (!success) {\n throw new Error(\"Failed to update record (version conflict or record not found)\");\n }\n },\n\n async updateMany(tableName, builderFn) {\n // Create a special builder that captures both where and set operations\n let whereConfig: { indexName?: string; condition?: unknown } = {};\n let setValues: unknown;\n\n const specialBuilder = {\n whereIndex(indexName: string, condition?: unknown) {\n whereConfig = { indexName, condition };\n return this;\n },\n set(values: unknown) {\n setValues = values;\n return this;\n },\n };\n\n builderFn(specialBuilder);\n\n if (!whereConfig.indexName) {\n throw new Error(\"whereIndex() must be called in updateMany\");\n }\n if (!setValues) {\n throw new Error(\"set() must be called in updateMany\");\n }\n\n // First, find all matching records\n const findUow = createUOW();\n findUow.find(tableName, (b) => {\n if (whereConfig.condition) {\n return b.whereIndex(whereConfig.indexName as never, whereConfig.condition as never);\n }\n return b.whereIndex(whereConfig.indexName as never);\n });\n const findResults: unknown[][] = await findUow.executeRetrieve();\n const records = findResults[0];\n\n if (!records || records.length === 0) {\n return;\n }\n\n // Now update all found records\n const updateUow = createUOW();\n for (const record of records as never as Array<{ id: unknown }>) {\n updateUow.update(tableName as string, record.id as string, (b) =>\n b.set(setValues as never),\n );\n }\n const { success } = await updateUow.executeMutations();\n if (!success) {\n throw new Error(\"Failed to update records (version conflict)\");\n }\n },\n\n async delete(tableName, id, builderFn) {\n const uow = createUOW();\n uow.delete(tableName, id, builderFn as never);\n const { success } = await uow.executeMutations();\n if (!success) {\n throw new Error(\"Failed to delete record (version conflict or record not found)\");\n }\n },\n\n async deleteMany(tableName, builderFn) {\n // Create a special builder that captures where configuration\n let whereConfig: { indexName?: string; condition?: unknown } = {};\n\n const specialBuilder = {\n whereIndex(indexName: string, condition?: unknown) {\n whereConfig = { indexName, condition };\n return this;\n },\n };\n\n // Safe: Call builderFn to capture the configuration\n builderFn(specialBuilder as never);\n\n if (!whereConfig.indexName) {\n throw new Error(\"whereIndex() must be called in deleteMany\");\n }\n\n // First, find all matching records\n const findUow = createUOW();\n findUow.find(tableName as string, (b) => {\n if (whereConfig.condition) {\n return b.whereIndex(whereConfig.indexName as never, whereConfig.condition as never);\n }\n return b.whereIndex(whereConfig.indexName as never);\n });\n const findResults2 = await findUow.executeRetrieve();\n const records = (findResults2 as unknown as [unknown])[0];\n\n // @ts-expect-error - Type narrowing doesn't work through unknown cast\n if (!records || records.length === 0) {\n return;\n }\n\n // Now delete all found records\n const deleteUow = createUOW();\n for (const record of records as never as Array<{ id: unknown }>) {\n deleteUow.delete(tableName as string, record.id as string);\n }\n const { success } = await deleteUow.executeMutations();\n if (!success) {\n throw new Error(\"Failed to delete records (version conflict)\");\n }\n },\n\n createUnitOfWork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,MAAM;AACrB,UAAO,UAAU,KAAK;;EAEzB"}
|
package/dist/query/query.d.ts
CHANGED
|
@@ -55,7 +55,7 @@ interface AbstractQuery<TSchema extends AnySchema, TUOWConfig = void> {
|
|
|
55
55
|
* Update a single record by ID
|
|
56
56
|
* Note: you cannot update the id of a row, some databases don't support that (including MongoDB).
|
|
57
57
|
*/
|
|
58
|
-
update: <TableName extends keyof TSchema["tables"] & string>(table: TableName, id: FragnoId | string, builderFn: (builder: Omit<UpdateBuilder<TSchema["tables"][TableName]>, "build" | "check">) => Omit<UpdateBuilder<TSchema["tables"][TableName]>, "build">) => Promise<void>;
|
|
58
|
+
update: <TableName extends keyof TSchema["tables"] & string>(table: TableName, id: FragnoId | string, builderFn: (builder: Omit<UpdateBuilder<TSchema["tables"][TableName]>, "build" | "check">) => Omit<UpdateBuilder<TSchema["tables"][TableName]>, "build" | "check">) => Promise<void>;
|
|
59
59
|
/**
|
|
60
60
|
* Update multiple records matching a where clause
|
|
61
61
|
* Note: you cannot update the id of a row, some databases don't support that (including MongoDB).
|
|
@@ -64,7 +64,7 @@ interface AbstractQuery<TSchema extends AnySchema, TUOWConfig = void> {
|
|
|
64
64
|
/**
|
|
65
65
|
* Delete a single record by ID
|
|
66
66
|
*/
|
|
67
|
-
delete: <TableName extends keyof TSchema["tables"] & string>(table: TableName, id: FragnoId | string, builderFn?: (builder: Omit<DeleteBuilder, "build">) => Omit<DeleteBuilder, "build" | "check">) => Promise<void>;
|
|
67
|
+
delete: <TableName extends keyof TSchema["tables"] & string>(table: TableName, id: FragnoId | string, builderFn?: (builder: Omit<DeleteBuilder, "build" | "check">) => Omit<DeleteBuilder, "build" | "check">) => Promise<void>;
|
|
68
68
|
/**
|
|
69
69
|
* Delete multiple records matching a where clause
|
|
70
70
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","names":[],"sources":["../../src/query/query.ts"],"sourcesContent":[],"mappings":";;;;;;KAWY,eAAA,GAAkB,aAAa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no-dev/db",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -67,19 +67,17 @@
|
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@electric-sql/pglite": "^0.3.10",
|
|
70
|
+
"@fragno-dev/core": "0.1.1",
|
|
70
71
|
"@fragno-private/typescript-config": "0.0.1",
|
|
71
72
|
"@fragno-private/vitest-config": "0.0.0",
|
|
72
|
-
"@fragno-dev/core": "0.0.7",
|
|
73
73
|
"@types/bun": "^1.2.23",
|
|
74
74
|
"@types/node": "^22",
|
|
75
75
|
"@vitest/coverage-istanbul": "^3.2.4",
|
|
76
76
|
"drizzle-kit": "^0.31.5",
|
|
77
77
|
"drizzle-orm": "^0.44.6",
|
|
78
78
|
"kysely-pglite": "^0.6.1",
|
|
79
|
-
"vitest": "^3.2.4"
|
|
80
|
-
|
|
81
|
-
"peerDependencies": {
|
|
82
|
-
"@fragno-dev/core": "0.0.7"
|
|
79
|
+
"vitest": "^3.2.4",
|
|
80
|
+
"zod": "^4.1.12"
|
|
83
81
|
},
|
|
84
82
|
"repository": {
|
|
85
83
|
"type": "git",
|
|
@@ -133,7 +133,7 @@ export function fromKysely<T extends AnySchema>(schema: T, config: KyselyConfig)
|
|
|
133
133
|
|
|
134
134
|
async update(tableName, id, builderFn) {
|
|
135
135
|
const uow = createUOW();
|
|
136
|
-
uow.update(tableName, id, builderFn);
|
|
136
|
+
uow.update(tableName, id, builderFn as never);
|
|
137
137
|
const { success } = await uow.executeMutations();
|
|
138
138
|
if (!success) {
|
|
139
139
|
throw new Error("Failed to update record (version conflict or record not found)");
|
package/src/fragment.test.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { test, expect, describe, expectTypeOf } from "vitest";
|
|
2
2
|
import { defineFragmentWithDatabase, type FragnoPublicConfigWithDatabase } from "./fragment";
|
|
3
|
-
import { createFragment } from "@fragno-dev/core";
|
|
3
|
+
import { createFragment, defineRoute, type FragnoPublicClientConfig } from "@fragno-dev/core";
|
|
4
|
+
import { createClientBuilder } from "@fragno-dev/core/client";
|
|
4
5
|
import { schema, idColumn, column } from "./schema/create";
|
|
5
6
|
import type { AbstractQuery } from "./query/query";
|
|
6
7
|
import type { DatabaseAdapter } from "./mod";
|
|
8
|
+
import { z } from "zod";
|
|
7
9
|
|
|
8
10
|
type Empty = Record<never, never>;
|
|
9
11
|
|
|
@@ -284,4 +286,48 @@ describe("DatabaseFragmentBuilder", () => {
|
|
|
284
286
|
expect(servicesOrm).toBeDefined();
|
|
285
287
|
});
|
|
286
288
|
});
|
|
289
|
+
|
|
290
|
+
describe("Client builder integration", () => {
|
|
291
|
+
test("createClientBuilder works with database fragment", () => {
|
|
292
|
+
const testSchema = schema((s) =>
|
|
293
|
+
s.addTable("users", (t) =>
|
|
294
|
+
t.addColumn("id", idColumn()).addColumn("name", column("string")),
|
|
295
|
+
),
|
|
296
|
+
);
|
|
297
|
+
|
|
298
|
+
const fragmentDef = defineFragmentWithDatabase("test-db")
|
|
299
|
+
.withDatabase(testSchema)
|
|
300
|
+
.withServices(({ orm }) => ({
|
|
301
|
+
getUserById: (id: string) =>
|
|
302
|
+
orm.findFirst("users", (b) => b.whereIndex("primary", (eb) => eb("id", "=", id))),
|
|
303
|
+
}));
|
|
304
|
+
|
|
305
|
+
const routes = [
|
|
306
|
+
defineRoute({
|
|
307
|
+
method: "GET",
|
|
308
|
+
path: "/users",
|
|
309
|
+
outputSchema: z.array(
|
|
310
|
+
z.object({
|
|
311
|
+
id: z.string(),
|
|
312
|
+
name: z.string(),
|
|
313
|
+
}),
|
|
314
|
+
),
|
|
315
|
+
handler: async (_ctx, { json }) => json([]),
|
|
316
|
+
}),
|
|
317
|
+
] as const;
|
|
318
|
+
|
|
319
|
+
const clientConfig: FragnoPublicClientConfig = {
|
|
320
|
+
baseUrl: "http://localhost:3000",
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
const builder = createClientBuilder(fragmentDef, clientConfig, routes);
|
|
324
|
+
|
|
325
|
+
expect(builder).toBeDefined();
|
|
326
|
+
expectTypeOf(builder.createHook).toBeFunction();
|
|
327
|
+
|
|
328
|
+
const useUsers = builder.createHook("/users");
|
|
329
|
+
expect(useUsers).toHaveProperty("route");
|
|
330
|
+
expect(useUsers.route.path).toBe("/users");
|
|
331
|
+
});
|
|
332
|
+
});
|
|
287
333
|
});
|
package/src/query/query.ts
CHANGED
|
@@ -162,7 +162,7 @@ export interface AbstractQuery<TSchema extends AnySchema, TUOWConfig = void> {
|
|
|
162
162
|
id: FragnoId | string,
|
|
163
163
|
builderFn: (
|
|
164
164
|
builder: Omit<UpdateBuilder<TSchema["tables"][TableName]>, "build" | "check">,
|
|
165
|
-
) => Omit<UpdateBuilder<TSchema["tables"][TableName]>, "build">,
|
|
165
|
+
) => Omit<UpdateBuilder<TSchema["tables"][TableName]>, "build" | "check">,
|
|
166
166
|
) => Promise<void>;
|
|
167
167
|
|
|
168
168
|
/**
|
|
@@ -180,7 +180,9 @@ export interface AbstractQuery<TSchema extends AnySchema, TUOWConfig = void> {
|
|
|
180
180
|
delete: <TableName extends keyof TSchema["tables"] & string>(
|
|
181
181
|
table: TableName,
|
|
182
182
|
id: FragnoId | string,
|
|
183
|
-
builderFn?: (
|
|
183
|
+
builderFn?: (
|
|
184
|
+
builder: Omit<DeleteBuilder, "build" | "check">,
|
|
185
|
+
) => Omit<DeleteBuilder, "build" | "check">,
|
|
184
186
|
) => Promise<void>;
|
|
185
187
|
|
|
186
188
|
/**
|