vibeorm 1.1.7 → 1.1.9
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/README.md +77 -3
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -371,7 +371,11 @@ import { bunAdapter } from "@vibeorm/adapter-bun";
|
|
|
371
371
|
|
|
372
372
|
const db = VibeClient({
|
|
373
373
|
// Required
|
|
374
|
-
adapter: bunAdapter({
|
|
374
|
+
adapter: bunAdapter({
|
|
375
|
+
url: "postgres://...",
|
|
376
|
+
statementTimeout: 30000, // 30s default query timeout (recommended)
|
|
377
|
+
connectionTimeout: 5000, // 5s connection establishment timeout
|
|
378
|
+
}),
|
|
375
379
|
// Or let it read DATABASE_URL from env:
|
|
376
380
|
// adapter: bunAdapter(),
|
|
377
381
|
|
|
@@ -395,7 +399,11 @@ With `node-postgres`:
|
|
|
395
399
|
import { pgAdapter } from "@vibeorm/adapter-pg";
|
|
396
400
|
|
|
397
401
|
const db = VibeClient({
|
|
398
|
-
adapter: pgAdapter({
|
|
402
|
+
adapter: pgAdapter({
|
|
403
|
+
connectionString: "postgres://...",
|
|
404
|
+
statementTimeout: 30000,
|
|
405
|
+
connectionTimeout: 5000,
|
|
406
|
+
}),
|
|
399
407
|
});
|
|
400
408
|
```
|
|
401
409
|
|
|
@@ -1041,6 +1049,64 @@ try {
|
|
|
1041
1049
|
}
|
|
1042
1050
|
```
|
|
1043
1051
|
|
|
1052
|
+
### Timeouts
|
|
1053
|
+
|
|
1054
|
+
Both adapters support `statementTimeout` and `connectionTimeout` at the adapter level:
|
|
1055
|
+
|
|
1056
|
+
```ts
|
|
1057
|
+
const db = VibeClient({
|
|
1058
|
+
adapter: bunAdapter({
|
|
1059
|
+
url: "postgres://...",
|
|
1060
|
+
statementTimeout: 30000, // Cancel any query exceeding 30s
|
|
1061
|
+
connectionTimeout: 5000, // Fail if connection takes > 5s
|
|
1062
|
+
}),
|
|
1063
|
+
});
|
|
1064
|
+
```
|
|
1065
|
+
|
|
1066
|
+
- **`statementTimeout`** — PostgreSQL cancels queries exceeding this duration (SQLSTATE `57014`), surfaced as `VibeTransientError` with code `STATEMENT_TIMEOUT`.
|
|
1067
|
+
- **`connectionTimeout`** — Limits initial connection establishment (bun adapter) or pool checkout (pg adapter).
|
|
1068
|
+
- **Transaction-level override** — `db.$transaction(fn, { timeout: 5000 })` overrides the default for that transaction using `SET LOCAL statement_timeout`.
|
|
1069
|
+
|
|
1070
|
+
### Retry
|
|
1071
|
+
|
|
1072
|
+
Use `withRetry` from `@vibeorm/runtime` to automatically retry operations that fail with transient errors:
|
|
1073
|
+
|
|
1074
|
+
```ts
|
|
1075
|
+
import { withRetry } from "@vibeorm/runtime";
|
|
1076
|
+
|
|
1077
|
+
// Basic — 3 retries with exponential backoff + jitter
|
|
1078
|
+
const users = await withRetry(() =>
|
|
1079
|
+
db.user.findMany({ where: { active: true } })
|
|
1080
|
+
);
|
|
1081
|
+
|
|
1082
|
+
// Custom options
|
|
1083
|
+
const user = await withRetry(
|
|
1084
|
+
() => db.user.create({ data: { email: "new@example.com" } }),
|
|
1085
|
+
{ maxRetries: 5, baseDelay: 100, maxDelay: 10000 },
|
|
1086
|
+
);
|
|
1087
|
+
|
|
1088
|
+
// Retry only specific transient errors
|
|
1089
|
+
const result = await withRetry(
|
|
1090
|
+
() => db.$transaction(async (tx) => {
|
|
1091
|
+
const user = await tx.user.findUniqueOrThrow({ where: { id: 1 } });
|
|
1092
|
+
await tx.user.update({ where: { id: 1 }, data: { balance: user.balance - 100 } });
|
|
1093
|
+
}, { isolationLevel: "Serializable" }),
|
|
1094
|
+
{ retryOn: ["SERIALIZATION_FAILURE", "DEADLOCK"] },
|
|
1095
|
+
);
|
|
1096
|
+
```
|
|
1097
|
+
|
|
1098
|
+
`withRetry` only retries `VibeTransientError` instances. Deterministic errors (`VibeRequestError` — unique constraint violations, validation errors, not found, etc.) are thrown immediately.
|
|
1099
|
+
|
|
1100
|
+
| Option | Default | Description |
|
|
1101
|
+
|--------|---------|-------------|
|
|
1102
|
+
| `maxRetries` | `3` | Max retry attempts |
|
|
1103
|
+
| `baseDelay` | `50ms` | Base delay for exponential backoff |
|
|
1104
|
+
| `maxDelay` | `5000ms` | Delay cap |
|
|
1105
|
+
| `maxJitter` | `50ms` | Random jitter per retry |
|
|
1106
|
+
| `signal` | — | `AbortSignal` to cancel retries |
|
|
1107
|
+
| `retryOn` | — | Filter by `VibeTransientErrorCode` |
|
|
1108
|
+
| `onRetry` | — | Callback for logging/metrics |
|
|
1109
|
+
|
|
1044
1110
|
---
|
|
1045
1111
|
|
|
1046
1112
|
## Validation
|
|
@@ -1190,7 +1256,10 @@ import { bunAdapter } from "@vibeorm/adapter-bun";
|
|
|
1190
1256
|
|
|
1191
1257
|
const db = VibeClient({
|
|
1192
1258
|
adapter: bunAdapter({
|
|
1193
|
-
url: "postgres://...",
|
|
1259
|
+
url: "postgres://...", // Or reads DATABASE_URL
|
|
1260
|
+
max: 20, // Pool size (default: 10)
|
|
1261
|
+
statementTimeout: 30000, // 30s query timeout
|
|
1262
|
+
connectionTimeout: 5000, // 5s connection timeout
|
|
1194
1263
|
}),
|
|
1195
1264
|
});
|
|
1196
1265
|
```
|
|
@@ -1209,10 +1278,15 @@ import { pgAdapter } from "@vibeorm/adapter-pg";
|
|
|
1209
1278
|
const db = VibeClient({
|
|
1210
1279
|
adapter: pgAdapter({
|
|
1211
1280
|
connectionString: "postgres://...",
|
|
1281
|
+
max: 20, // Pool size (default: 10)
|
|
1282
|
+
statementTimeout: 30000, // 30s query timeout
|
|
1283
|
+
connectionTimeout: 5000, // 5s connection timeout
|
|
1212
1284
|
}),
|
|
1213
1285
|
});
|
|
1214
1286
|
```
|
|
1215
1287
|
|
|
1288
|
+
Both adapters support `statementTimeout` and `connectionTimeout`. See the adapter package READMEs for full option details.
|
|
1289
|
+
|
|
1216
1290
|
---
|
|
1217
1291
|
|
|
1218
1292
|
## ID Generation
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vibeorm",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.9",
|
|
4
4
|
"description": "CLI for VibeORM — generate clients, run migrations, introspect databases",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -41,10 +41,10 @@
|
|
|
41
41
|
"bun": ">=1.1.0"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@vibeorm/parser": "1.1.
|
|
45
|
-
"@vibeorm/generator": "1.1.
|
|
46
|
-
"@vibeorm/migrate": "1.1.
|
|
47
|
-
"@vibeorm/runtime": "1.1.
|
|
48
|
-
"@vibeorm/adapter-bun": "1.1.
|
|
44
|
+
"@vibeorm/parser": "1.1.6",
|
|
45
|
+
"@vibeorm/generator": "1.1.7",
|
|
46
|
+
"@vibeorm/migrate": "1.1.7",
|
|
47
|
+
"@vibeorm/runtime": "1.1.6",
|
|
48
|
+
"@vibeorm/adapter-bun": "1.1.6"
|
|
49
49
|
}
|
|
50
50
|
}
|