{"_id":"@byebyebymyai/database-proxy-sdk-prisma","_rev":"2-b6f6bc0e126ad475f10aabdc70355b39","name":"@byebyebymyai/database-proxy-sdk-prisma","dist-tags":{"latest":"1.0.0"},"versions":{"0.1.0":{"name":"@byebyebymyai/database-proxy-sdk-prisma","version":"0.1.0","keywords":["prisma","database-proxy","connect","rpc","driver-adapter"],"author":{"name":"byebyebymyai"},"license":"MIT","_id":"@byebyebymyai/database-proxy-sdk-prisma@0.1.0","maintainers":[{"name":"byebyebymyai","email":"songchen345@gmail.com"}],"homepage":"https://github.com/byebyebymyai/database-proxy-sdk-prisma#readme","bugs":{"url":"https://github.com/byebyebymyai/database-proxy-sdk-prisma/issues"},"dist":{"shasum":"3665f40cb283b5d25d04b35981bf37569ee77d5c","tarball":"https://registry.npmjs.org/@byebyebymyai/database-proxy-sdk-prisma/-/database-proxy-sdk-prisma-0.1.0.tgz","fileCount":9,"integrity":"sha512-pnsxu96g/x8bc/UPv+FrhGfYLufHD3sTrONzA57+88naXCEActXiL6OP9fJlrrWzY7FwijmCMsl1yQzcNQZ4xA==","signatures":[{"sig":"MEQCIBtWw8FuAEMPcoGG2IoqgFbsdqDgrxwSN/10TYNaCmJ5AiBqm7l3zIZGuwCWKHM5jV5KqFaewfg1vKSvnsLcKnk7rQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@byebyebymyai%2fdatabase-proxy-sdk-prisma@0.1.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":164693},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"./package.json":"./package.json"},"gitHead":"e35263acd03fca49ba1537e3a47a8aeb427df1a9","scripts":{"lint":"biome check .","test":"vitest run","build":"tsup","format":"biome format --write .","codegen":"cd proto && npx --yes @bufbuild/buf@1.47.2 mod update && npx --yes @bufbuild/buf@1.47.2 generate","test:unit":"vitest run","typecheck":"tsc --noEmit","test:watch":"vitest","prepublishOnly":"npm run build && npm run test && npm run lint","typecheck:test":"DIRECT_DATABASE_URL=postgresql://127.0.0.1:5432/integration prisma generate --config test/integration/prisma/prisma.config.ts && tsc --noEmit -p tsconfig.test.json","test:integration":"prisma generate --config test/integration/prisma/prisma.config.ts && vitest run --config vitest.integration.config.ts"},"_npmUser":{"name":"byebyebymyai","email":"songchen345@gmail.com"},"repository":{"url":"git+https://github.com/byebyebymyai/database-proxy-sdk-prisma.git","type":"git"},"_npmVersion":"10.9.7","description":"Prisma driver adapter for database-proxy Connect RPC (multi-datasource SQL gateway)","directories":{},"sideEffects":false,"_nodeVersion":"22.22.2","dependencies":{"@bufbuild/protobuf":"^2.2.3","@connectrpc/connect":"^2.0.1","@connectrpc/connect-node":"^2.0.1"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.3.5","prisma":"^7.7.0","vitest":"^2.1.8","typescript":"^5.7.2","@types/node":"^22.10.2","@biomejs/biome":"^1.9.4","@prisma/client":"^7.7.0","@prisma/driver-adapter-utils":"^7.7.0"},"peerDependencies":{"@prisma/client":"^6.6.0 || ^7.0.0","@prisma/driver-adapter-utils":"^6.6.0 || ^7.0.0"},"peerDependenciesMeta":{"@prisma/client":{"optional":false}},"_npmOperationalInternal":{"tmp":"tmp/database-proxy-sdk-prisma_0.1.0_1775983694283_0.6687920375579717","host":"s3://npm-registry-packages-npm-production"}},"1.0.0":{"name":"@byebyebymyai/database-proxy-sdk-prisma","version":"1.0.0","description":"Prisma driver adapter for database-proxy Connect RPC (multi-datasource SQL gateway)","license":"MIT","author":{"name":"byebyebymyai"},"type":"module","sideEffects":false,"engines":{"node":">=18.0.0"},"main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"./package.json":"./package.json"},"scripts":{"codegen":"cd proto && npx --yes @bufbuild/buf@1.47.2 mod update && npx --yes @bufbuild/buf@1.47.2 generate","build":"tsup","typecheck":"tsc --noEmit","typecheck:test":"prisma generate --config test/integration/prisma/prisma.config.ts && tsc --noEmit -p tsconfig.test.json","lint":"biome check .","format":"biome format --write .","test":"vitest run","test:unit":"vitest run","test:integration":"prisma generate --config test/integration/prisma/prisma.config.ts && vitest run --config vitest.integration.config.ts","test:watch":"vitest","prepublishOnly":"npm run build && npm run test && npm run lint"},"dependencies":{"@bufbuild/protobuf":"^2.2.3","@connectrpc/connect":"^2.0.1","@connectrpc/connect-node":"^2.0.1"},"peerDependencies":{"@prisma/client":"^6.6.0 || ^7.0.0","@prisma/driver-adapter-utils":"^6.6.0 || ^7.0.0"},"peerDependenciesMeta":{"@prisma/client":{"optional":false}},"devDependencies":{"@biomejs/biome":"^1.9.4","@prisma/client":"^7.7.0","@prisma/driver-adapter-utils":"^7.7.0","@types/node":"^22.10.2","prisma":"^7.7.0","tsup":"^8.3.5","typescript":"^5.7.2","vitest":"^2.1.8"},"keywords":["prisma","database-proxy","connect","rpc","driver-adapter"],"repository":{"type":"git","url":"git+https://github.com/byebyebymyai/database-proxy-sdk-prisma.git"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org"},"_id":"@byebyebymyai/database-proxy-sdk-prisma@1.0.0","gitHead":"7ec38f881f7ec6895cf07307a048236fb41df034","bugs":{"url":"https://github.com/byebyebymyai/database-proxy-sdk-prisma/issues"},"homepage":"https://github.com/byebyebymyai/database-proxy-sdk-prisma#readme","_nodeVersion":"22.22.2","_npmVersion":"10.9.7","dist":{"integrity":"sha512-UkTj+kAELsolsBYcs10+evRGCcH/FX1ulNNbG0aso5ZwydNiNn1EzHgKF8wNdiG7GiHxgV8bTrOMl7N+YFdnEQ==","shasum":"cbd817f4e5425d6d707d4a193078868a1c3e3cd6","tarball":"https://registry.npmjs.org/@byebyebymyai/database-proxy-sdk-prisma/-/database-proxy-sdk-prisma-1.0.0.tgz","fileCount":9,"unpackedSize":168895,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@byebyebymyai%2fdatabase-proxy-sdk-prisma@1.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIDYCaOz+wtU/tI8+jLdZLyBuFzw8jRMN3lyGWBODcW2MAiEArUfgyCfmpcS589CKDuvAkNanNlah2WBjf5bXOdXoVVM="}]},"_npmUser":{"name":"byebyebymyai","email":"songchen345@gmail.com"},"directories":{},"maintainers":[{"name":"byebyebymyai","email":"songchen345@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/database-proxy-sdk-prisma_1.0.0_1776011793312_0.8588216567927001"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-12T08:48:14.219Z","modified":"2026-04-12T16:36:33.729Z","0.1.0":"2026-04-12T08:48:14.419Z","1.0.0":"2026-04-12T16:36:33.452Z"},"bugs":{"url":"https://github.com/byebyebymyai/database-proxy-sdk-prisma/issues"},"author":{"name":"byebyebymyai"},"license":"MIT","homepage":"https://github.com/byebyebymyai/database-proxy-sdk-prisma#readme","keywords":["prisma","database-proxy","connect","rpc","driver-adapter"],"repository":{"type":"git","url":"git+https://github.com/byebyebymyai/database-proxy-sdk-prisma.git"},"description":"Prisma driver adapter for database-proxy Connect RPC (multi-datasource SQL gateway)","maintainers":[{"name":"byebyebymyai","email":"songchen345@gmail.com"}],"readme":"# `@byebyebymyai/database-proxy-sdk-prisma`\n\nPrisma **driver adapter** that runs all SQL through [**database-proxy**](https://github.com/byebyebymyai/database-proxy) over [Connect RPC](https://connectrpc.com/). Use it when Prisma should talk to your databases only via the gateway (auth, audit, pooling, multi–data-source routing).\n\n## Requirements\n\n- Node.js 18+\n- Prisma ORM **6.6+** or **7.x** (driver adapters) with matching `@prisma/driver-adapter-utils` (integration tests in this repo use Prisma 7 config layout)\n- A running database-proxy instance compatible with `proto/sqlgateway/v1/sqlgateway.proto`\n- By default the client uses **Connect JSON** over HTTP (same as `curl` with `Content-Type: application/json`). Set `useBinaryFormat: true` only if your server expects the binary codec.\n\n## Install\n\n```bash\nnpm install @byebyebymyai/database-proxy-sdk-prisma\n```\n\nPeer dependencies (install in your app):\n\n- `@prisma/client`\n- `@prisma/driver-adapter-utils`\n\n## Prisma setup\n\n1. Set `datasource.provider` to the **real** SQL dialect behind the gateway (`postgresql`, `mysql`, etc.). Prisma still generates that dialect; the gateway only executes SQL.\n2. In Prisma 7, set `datasource.url` in `prisma.config.ts` to a **syntactically valid** URL for your provider (it can be a placeholder host; Prisma does not need a real TCP connection for `prisma generate`). Runtime SQL and migrations go through the adapter + gateway, not that URL.\n3. Pass `DatabaseProxyAdapterFactory` to `PrismaClient` as `adapter`.\n\n```prisma\ndatasource db {\n  provider = \"postgresql\"\n  url      = env(\"DATABASE_URL\")\n}\n\ngenerator client {\n  provider = \"prisma-client-js\"\n}\n\nmodel User {\n  id   Int    @id @default(autoincrement())\n  name String\n}\n```\n\n```typescript\nimport { PrismaClient } from \"@prisma/client\";\nimport { DatabaseProxyAdapterFactory } from \"@byebyebymyai/database-proxy-sdk-prisma\";\n\nconst prisma = new PrismaClient({\n  adapter: new DatabaseProxyAdapterFactory({\n    baseUrl: \"http://127.0.0.1:8080\",\n    datasource: \"dev\",\n    provider: \"postgres\",\n  }),\n});\n```\n\n## Multiple datasources\n\nUse **one factory (or adapter) per logical datasource**—for example two `PrismaClient` instances with different `datasource` ids, matching how you configure `DATABASE_PROXY_DATABASES_JSON` on the gateway.\n\n## Auth (JWT)\n\n```typescript\nimport {\n  DatabaseProxyAdapterFactory,\n  getAuthorizationBearerInterceptor,\n} from \"@byebyebymyai/database-proxy-sdk-prisma\";\n\nconst prisma = new PrismaClient({\n  adapter: new DatabaseProxyAdapterFactory({\n    baseUrl: \"https://gateway.example.com\",\n    datasource: \"prod\",\n    provider: \"postgres\",\n    interceptors: [getAuthorizationBearerInterceptor(() => process.env[\"GATEWAY_JWT\"]!)],\n  }),\n});\n```\n\nFor static headers (e.g. API keys), use `getStaticHeadersInterceptor`.\n\n## Migrations\n\n`executeScript` sends the **entire** migration SQL in one gateway `Execute` call. Whether multi-statement scripts work depends on your database-proxy / JDBC backend (same as a single client batch).\n\nFor `prisma migrate dev`, set **`shadowDatasource`** on `DatabaseProxyAdapterFactory` to a **second** logical datasource id on the gateway that points at an isolated shadow database. Without it, `connectToShadowDb` throws. Never use the same datasource id as your main database.\n\nPrisma + driver-adapter migrate remains sensitive to ORM version; this package is tested against the Prisma 7.x line used in this repo.\n\n## Updating generated RPC types\n\nProtos are vendored under `proto/` and compiled to `src/gen/` with [Buf](https://buf.build/).\n\n```bash\nnpm run codegen\n```\n\nWhen [upstream `sqlgateway.proto`](https://github.com/byebyebymyai/database-proxy/blob/main/proto/sqlgateway/v1/sqlgateway.proto) changes, copy the file into `proto/sqlgateway/v1/sqlgateway.proto`, then run `npm run codegen`, bump the package version, and test.\n\n## Testing\n\n- **Unit tests (CI default):** `npm test` / `npm run test:unit` — runs [`vitest.config.ts`](vitest.config.ts) (`src/**/*.test.ts`, `test/unit/**/*.test.ts`). No external services.\n- **Typecheck including tests:** `npm run typecheck:test` — runs `prisma generate` for the integration schema (placeholder URL in `test/integration/prisma/prisma.config.ts`), then `tsc -p tsconfig.test.json`.\n- **Integration tests (local / manual CI):** `npm run test:integration` — requires env vars and a live database-proxy; see [`test/integration/README.md`](test/integration/README.md). Migration-oriented checks (Connect JSON wire + `executeScript`) live in [`test/integration/migrations.integration.test.ts`](test/integration/migrations.integration.test.ts).\n\n## Scripts\n\n| Script        | Description                |\n| ------------- | -------------------------- |\n| `npm run build` | Build ESM + CJS + types  |\n| `npm run test` / `test:unit` | Unit tests (Vitest)   |\n| `npm run test:integration` | Integration tests + Prisma generate |\n| `npm run typecheck` | `tsc` for `src` only    |\n| `npm run typecheck:test` | `tsc` for `src` + tests |\n| `npm run lint`  | Biome check                |\n| `npm run codegen` | Regenerate `src/gen`     |\n\n## License\n\nMIT. See [LICENSE](./LICENSE).\n","readmeFilename":"README.md"}