@schemavaults/dbh 0.10.2 → 0.11.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/README.md +15 -1
- package/dist/utils/validateMigrationDirectory.d.ts +35 -0
- package/dist/utils/validateMigrationDirectory.js +157 -0
- package/dist/utils/validateMigrationDirectory.js.map +1 -0
- package/dist-cli/cli.js +21 -21
- package/package.json +2 -2
- package/.claude/hooks/install-deps-in-fresh-environment.sh +0 -5
- package/.claude/settings.json +0 -15
- package/CLAUDE.md +0 -41
- package/eslint.config.cjs +0 -56
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@schemavaults/dbh",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"description": "Easily connect to PostgresDB from serverless environment",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"private": false,
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"build:pkg": "tsc --project tsconfig.json && tsc-alias --project tsconfig.json",
|
|
35
35
|
"build:cli": "bun build ./src/cli.ts --outdir dist-cli --format esm --target node --minify && echo '#!/usr/bin/env node' | cat - dist-cli/cli.js > dist-cli/cli.tmp && mv dist-cli/cli.tmp dist-cli/cli.js",
|
|
36
36
|
"build:build-db-migrations": "bun build ./src/build-db-migrations.ts --outdir dist-cli --format esm --target bun --minify",
|
|
37
|
-
"test:unit": "bun test ./src/tests/SchemaVaultsPostgresAdapterInit.test.ts && bun test src/tests/SchemaVaultsPostgresNeonProxyAdapterInit.test.ts",
|
|
37
|
+
"test:unit": "bun test ./src/tests/SchemaVaultsPostgresAdapterInit.test.ts && bun test src/tests/SchemaVaultsPostgresNeonProxyAdapterInit.test.ts && bun test ./src/tests/ValidateMigrationDirectory.test.ts",
|
|
38
38
|
"test": "bun run test:unit",
|
|
39
39
|
"test:e2e": "bun test ./src/tests/e2e/ConnectToLocalDatabaseWithPostgresAdapter.test.ts && bun test ./src/tests/e2e/ConnectToLocalDatabaseWithPostgresNeonProxyAdapter.test.ts && bun test ./src/tests/e2e/MigrateUpAndDown.test.ts",
|
|
40
40
|
"test:e2e:cli": "/bin/bash ./tests/run_cli_e2e_tests.sh",
|
package/.claude/settings.json
DELETED
package/CLAUDE.md
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
# CLAUDE.md
|
|
2
|
-
|
|
3
|
-
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
-
|
|
5
|
-
## What This Is
|
|
6
|
-
|
|
7
|
-
`@schemavaults/dbh` is an npm package that provides a Kysely-based adapter for connecting to Postgres databases through a Neon-compatible WebSocket proxy. It works with both Neon-hosted serverless Postgres and local Postgres instances (via a bundled WS proxy).
|
|
8
|
-
|
|
9
|
-
## Commands
|
|
10
|
-
|
|
11
|
-
Ensure dependencies are installed with `bun install` before attempting to run any other commands.
|
|
12
|
-
|
|
13
|
-
- **Build:** `bun run build` (runs tsc + tsc-alias, then cleans test files from dist/)
|
|
14
|
-
- **Lint:** `bun run lint` (eslint on src/)
|
|
15
|
-
- **Unit tests:** `bun run test` or `bun run test:unit`
|
|
16
|
-
- **Single test:** `bun test --test-name-pattern '<pattern>'`
|
|
17
|
-
- **E2E tests:** `cd tests && /bin/bash ./run_e2e_tests.sh` (requires Docker Compose — spins up postgres, ws-proxy, and test-runner containers)
|
|
18
|
-
- **CLI:** `bun run cli --help` locally or `bunx @schemavaults/dbh --help` remotely.
|
|
19
|
-
|
|
20
|
-
## Architecture
|
|
21
|
-
|
|
22
|
-
The core adapter is `SchemaVaultsPostgresNeonProxyAdapter<T>` (generic over Kysely table types). It wraps Kysely with a `NeonDialect` and handles credential parsing, WS proxy URL resolution, and debug logging. Consumers extend or instantiate it, passing an environment (`development|test|staging|production`), optional credentials (defaults to env vars), and an optional `wsProxyUrl` (string or generator function).
|
|
23
|
-
|
|
24
|
-
Key modules:
|
|
25
|
-
- `src/schemavaults-postgres-neon-proxy-adapter.ts` — the main adapter class
|
|
26
|
-
- `src/migrate.ts` — Kysely migration helpers (`migrate`, `reverse`), exported as a separate entrypoint (`@schemavaults/dbh/migrate`)
|
|
27
|
-
- `src/sql.ts` — re-exports Kysely's `sql` tag
|
|
28
|
-
- `src/utils/parseDatabaseCredentials.ts` — parses/validates DB credentials from an object or `process.env`
|
|
29
|
-
|
|
30
|
-
The package has two export entrypoints: `.` (adapter + sql + types), `./sql` (Kysely template tag re-export), `./migrate` (migration utilities), and `./cli` (@schemavaults/dbh command-line utility).
|
|
31
|
-
|
|
32
|
-
## Local Dev Environment
|
|
33
|
-
|
|
34
|
-
- Runtime/package manager: **Bun** (v1.3.6)
|
|
35
|
-
- TypeScript with path alias `@/*` → `src/*` (resolved by tsc-alias at build time)
|
|
36
|
-
- E2E tests run inside Docker containers (postgres:17.7 + a Go-based WS proxy on port 5433)
|
|
37
|
-
|
|
38
|
-
## Environment Variables
|
|
39
|
-
|
|
40
|
-
The adapter reads these from `process.env` when credentials aren't passed directly:
|
|
41
|
-
`POSTGRES_USER`, `POSTGRES_PASSWORD`, `POSTGRES_URL`, `POSTGRES_URL_NON_POOLING` (optional), `POSTGRES_HOST`, `POSTGRES_PORT`, `POSTGRES_DATABASE`. Debug mode via `SCHEMAVAULTS_DBH_DEBUG=true`.
|
package/eslint.config.cjs
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
// @schemavaults/dbh - eslint.config.cjs
|
|
2
|
-
|
|
3
|
-
const js = require("@eslint/js");
|
|
4
|
-
const tsParser = require("@typescript-eslint/parser");
|
|
5
|
-
const tsPlugin = require("@typescript-eslint/eslint-plugin");
|
|
6
|
-
const globals = require("globals");
|
|
7
|
-
|
|
8
|
-
module.exports = [
|
|
9
|
-
// Base recommended configs
|
|
10
|
-
js.configs.recommended,
|
|
11
|
-
|
|
12
|
-
// Main config
|
|
13
|
-
{
|
|
14
|
-
files: ["src/**/*.{ts,tsx,js,jsx}"],
|
|
15
|
-
|
|
16
|
-
languageOptions: {
|
|
17
|
-
parser: tsParser,
|
|
18
|
-
parserOptions: {
|
|
19
|
-
ecmaVersion: "latest",
|
|
20
|
-
sourceType: "module",
|
|
21
|
-
ecmaFeatures: {
|
|
22
|
-
jsx: false,
|
|
23
|
-
},
|
|
24
|
-
project: "./tsconfig.json",
|
|
25
|
-
},
|
|
26
|
-
globals: {
|
|
27
|
-
...globals.browser,
|
|
28
|
-
...globals.es2021,
|
|
29
|
-
...globals.node,
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
plugins: {
|
|
34
|
-
"@typescript-eslint": tsPlugin,
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
rules: {
|
|
38
|
-
// TypeScript recommended rules
|
|
39
|
-
...tsPlugin.configs.recommended.rules,
|
|
40
|
-
|
|
41
|
-
"@typescript-eslint/no-unused-vars": [
|
|
42
|
-
"warn",
|
|
43
|
-
{ argsIgnorePattern: "^_" },
|
|
44
|
-
],
|
|
45
|
-
"@typescript-eslint/no-explicit-any": "off",
|
|
46
|
-
"@typescript-eslint/no-namespace": "off",
|
|
47
|
-
"@typescript-eslint/no-empty-object-type": "off",
|
|
48
|
-
"no-redeclare": "off",
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
// Ignore patterns
|
|
53
|
-
{
|
|
54
|
-
ignores: ["dist/**", "node_modules/**", "*.config.js", "*.config.cjs"],
|
|
55
|
-
},
|
|
56
|
-
];
|