@venturekit/data 0.0.0-dev.20260308002709 → 0.0.0-dev.20260310105525

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.
Files changed (2) hide show
  1. package/README.md +107 -0
  2. package/package.json +2 -2
package/README.md ADDED
@@ -0,0 +1,107 @@
1
+ # @venturekit/data
2
+
3
+ > **Warning:** This package is in active development and not production-ready. APIs may change without notice.
4
+
5
+ Database and data layer for [VentureKit](https://venturekit.dev) — RDS configuration, migrations, query utilities, and transactions.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @venturekit/data@dev
11
+ ```
12
+
13
+ ## Overview
14
+
15
+ `@venturekit/data` provides:
16
+
17
+ - **RDS configuration** — `createRdsConfig()`, `buildRdsConfig()` for PostgreSQL and MySQL
18
+ - **Migration utilities** — `createMigrationConfig()`, Flyway environment helpers
19
+ - **Query utilities** — `query()`, `getPool()`, `mapResults()`, `mapRow()`
20
+ - **Transaction support** — `beginTransaction()`, `withTransaction()`, `buildTransaction()`
21
+
22
+ ## Query Utilities
23
+
24
+ ```typescript
25
+ import { query, getPool, mapResults } from '@venturekit/data';
26
+
27
+ // Simple query
28
+ const result = await query('SELECT * FROM tasks WHERE id = $1', [taskId]);
29
+
30
+ // Get the connection pool
31
+ const pool = getPool();
32
+
33
+ // Map results with a custom mapper
34
+ const tasks = mapResults(result, row => ({
35
+ id: row.id,
36
+ title: row.title,
37
+ completed: row.completed,
38
+ }));
39
+ ```
40
+
41
+ ## Transactions
42
+
43
+ ```typescript
44
+ import { withTransaction, beginTransaction } from '@venturekit/data';
45
+
46
+ // Automatic commit/rollback
47
+ const result = await withTransaction(async (tx) => {
48
+ await tx.query('INSERT INTO tasks (title) VALUES ($1)', ['New task']);
49
+ await tx.query('UPDATE counters SET count = count + 1 WHERE name = $1', ['tasks']);
50
+ return { created: true };
51
+ });
52
+
53
+ // Manual transaction control
54
+ const tx = await beginTransaction();
55
+ try {
56
+ await tx.query('INSERT INTO tasks (title) VALUES ($1)', ['New task']);
57
+ await tx.commit();
58
+ } catch (error) {
59
+ await tx.rollback();
60
+ throw error;
61
+ }
62
+ ```
63
+
64
+ ### Transactional Handlers
65
+
66
+ When used with `@venturekit/runtime`, enable automatic transactions per request:
67
+
68
+ ```typescript
69
+ import { handler } from '@venturekit/runtime';
70
+
71
+ export const main = handler(async (body, ctx, logger) => {
72
+ // ctx.tx is available — auto-commits on success, rolls back on error
73
+ await ctx.tx.query('INSERT INTO tasks (title) VALUES ($1)', [body.title]);
74
+ return { created: true };
75
+ }, { scopes: ['tasks.write'], transactional: true });
76
+ ```
77
+
78
+ ## RDS Configuration
79
+
80
+ ```typescript
81
+ import { createRdsConfig, DEFAULT_RDS_CONFIG } from '@venturekit/data';
82
+
83
+ const rdsConfig = createRdsConfig({
84
+ engine: 'postgres',
85
+ instanceSize: 'small',
86
+ databaseName: 'mydb',
87
+ });
88
+ ```
89
+
90
+ ## Migrations
91
+
92
+ VentureKit uses [Drizzle Kit](https://orm.drizzle.team) for migrations. Use the CLI:
93
+
94
+ ```bash
95
+ vk migrate generate # Generate from schema changes
96
+ vk migrate up # Apply pending migrations
97
+ vk migrate status # Check migration status
98
+ vk migrate studio # Open Drizzle Studio GUI
99
+ ```
100
+
101
+ ## API Reference
102
+
103
+ See the [API reference](https://venturekit.dev/api-reference/data) for full documentation.
104
+
105
+ ## License
106
+
107
+ Apache-2.0 — see [LICENSE](../../LICENSE) for details.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@venturekit/data",
3
- "version": "0.0.0-dev.20260308002709",
3
+ "version": "0.0.0-dev.20260310105525",
4
4
  "description": "Database and data layer for VentureKit",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -25,7 +25,7 @@
25
25
  }
26
26
  },
27
27
  "dependencies": {
28
- "@venturekit/core": "0.0.0-dev.20260308002709",
28
+ "@venturekit/core": "0.0.0-dev.20260310105525",
29
29
  "pg": "^8.12.0"
30
30
  },
31
31
  "devDependencies": {