@btravstack/prisma 0.4.0 → 0.5.0

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 CHANGED
@@ -15,7 +15,7 @@ pnpm add @btravstack/prisma @btravstack/core @btravstack/config @btravstack/di u
15
15
  Five peer dependencies — install every one, so the application holds a single
16
16
  copy of each. Your own `@prisma/client`, `prisma` and (if you want the `try*`
17
17
  twins) `@unthrown/prisma` are yours, not this package's: the client is
18
- generated from your schema. Node `>=20`.
18
+ generated from your schema. Node `>=22`.
19
19
 
20
20
  ## A worked example
21
21
 
@@ -88,10 +88,9 @@ package's.
88
88
 
89
89
  ## Options
90
90
 
91
- | Option | Default | What it does |
92
- | -------- | ---------------- | -------------------------------------------------- |
93
- | `client` | — | Builds the client from the driver adapter and URL. |
94
- | `urlVar` | `"DATABASE_URL"` | The variable the connection string is read from. |
91
+ | Option | Default | What it does |
92
+ | -------- | ------- | -------------------------------------------------- |
93
+ | `client` | — | Builds the client from the driver adapter and URL. |
95
94
 
96
95
  ## License
97
96
 
package/dist/index.cjs CHANGED
@@ -109,10 +109,10 @@ const enableTracing = async (logger, load = defaultLoader) => {
109
109
  * against this same URL *before the process starts*; an application that
110
110
  * migrates itself at boot races every other replica.
111
111
  */
112
- const prismaDatabase = (name) => ({ client, urlVar = "DATABASE_URL", instrumented }) => {
113
- const config = _btravstack_config.Config.provider(`${name}Config`)(_btravstack_config.Config.object({ url: _btravstack_config.Config.string(urlVar) }));
112
+ const prismaDatabase = (name) => ({ client, instrumented }) => {
113
+ const config = _btravstack_config.Config.provider(`${name}Config`)(_btravstack_config.Config.object({ url: _btravstack_config.Config.string("DATABASE_URL") }));
114
114
  const DatabasePort = (0, _btravstack_di.Port)(name);
115
- const open = (url) => client(new _prisma_adapter_pg.PrismaPg({ connectionString: url }), url);
115
+ const open = (url) => client(new _prisma_adapter_pg.PrismaPg({ connectionString: url }));
116
116
  const port = DatabasePort;
117
117
  const instrumentedProvider = (0, _btravstack_di.Provider)(port)({
118
118
  settings: config.port,
package/dist/index.d.cts CHANGED
@@ -15,18 +15,15 @@ type PrismaLike = {
15
15
  /** What {@link prismaDatabase} is handed. */
16
16
  type PrismaOptions<C extends PrismaLike, Instrumented extends boolean> = {
17
17
  /**
18
- * Builds the client. The driver adapter is already constructed from the
19
- * environment's URL; the second argument is that URL, for a client that wants
20
- * it directly.
18
+ * Builds the client from the driver adapter, which is already constructed
19
+ * from the environment's URL.
21
20
  *
22
21
  * This is the one thing the starter cannot own: a Prisma client is
23
22
  * **generated per application** from its own schema, so there is no client
24
23
  * type to ship. Applying `@unthrown/prisma`'s extension belongs here too, so
25
24
  * the returned type is exactly the one the application will hold.
26
25
  */
27
- readonly client: (adapter: PrismaPg, url: string) => C;
28
- /** The variable the connection string is read from. `DATABASE_URL` by 12-factor convention. */
29
- readonly urlVar?: string;
26
+ readonly client: (adapter: PrismaPg) => C;
30
27
  /**
31
28
  * Span, count and log every query. **Default `true`**, `false` opts out — the
32
29
  * same shape as `cache`, `mailer` and `storage`, and as `StartOptions`'
@@ -59,7 +56,7 @@ type PrismaOptions<C extends PrismaLike, Instrumented extends boolean> = {
59
56
  * against this same URL *before the process starts*; an application that
60
57
  * migrates itself at boot races every other replica.
61
58
  */
62
- declare const prismaDatabase: <const N extends string>(name: N) => <C extends PrismaLike, Instrumented extends boolean = true>({ client, urlVar, instrumented }: PrismaOptions<C, Instrumented>) => (Instrumented extends true ? Module<PortClassOf<N, C> extends (infer T) ? T extends PortClassOf<N, C> ? T extends import("@btravstack/di").AnyPort ? InstanceType<T> : T extends import("@btravstack/di").AnyProvider ? InstanceType<T["port"]> : never : never : never, import("@btravstack/config").ConfigInvalid, Exclude<Env, import("@btravstack/di").PortInstance<string, C> | import("@btravstack/di").PortInstance<`${N}Config`, {
59
+ declare const prismaDatabase: <const N extends string>(name: N) => <C extends PrismaLike, Instrumented extends boolean = true>({ client, instrumented }: PrismaOptions<C, Instrumented>) => (Instrumented extends true ? Module<PortClassOf<N, C> extends (infer T) ? T extends PortClassOf<N, C> ? T extends import("@btravstack/di").AnyPort ? InstanceType<T> : T extends import("@btravstack/di").AnyProvider ? InstanceType<T["port"]> : never : never : never, import("@btravstack/config").ConfigInvalid, Exclude<Env, import("@btravstack/di").PortInstance<string, C> | import("@btravstack/di").PortInstance<`${N}Config`, {
63
60
  readonly url: string;
64
61
  }>> | Exclude<Logger, import("@btravstack/di").PortInstance<string, C> | import("@btravstack/di").PortInstance<`${N}Config`, {
65
62
  readonly url: string;
package/dist/index.d.mts CHANGED
@@ -15,18 +15,15 @@ type PrismaLike = {
15
15
  /** What {@link prismaDatabase} is handed. */
16
16
  type PrismaOptions<C extends PrismaLike, Instrumented extends boolean> = {
17
17
  /**
18
- * Builds the client. The driver adapter is already constructed from the
19
- * environment's URL; the second argument is that URL, for a client that wants
20
- * it directly.
18
+ * Builds the client from the driver adapter, which is already constructed
19
+ * from the environment's URL.
21
20
  *
22
21
  * This is the one thing the starter cannot own: a Prisma client is
23
22
  * **generated per application** from its own schema, so there is no client
24
23
  * type to ship. Applying `@unthrown/prisma`'s extension belongs here too, so
25
24
  * the returned type is exactly the one the application will hold.
26
25
  */
27
- readonly client: (adapter: PrismaPg, url: string) => C;
28
- /** The variable the connection string is read from. `DATABASE_URL` by 12-factor convention. */
29
- readonly urlVar?: string;
26
+ readonly client: (adapter: PrismaPg) => C;
30
27
  /**
31
28
  * Span, count and log every query. **Default `true`**, `false` opts out — the
32
29
  * same shape as `cache`, `mailer` and `storage`, and as `StartOptions`'
@@ -59,7 +56,7 @@ type PrismaOptions<C extends PrismaLike, Instrumented extends boolean> = {
59
56
  * against this same URL *before the process starts*; an application that
60
57
  * migrates itself at boot races every other replica.
61
58
  */
62
- declare const prismaDatabase: <const N extends string>(name: N) => <C extends PrismaLike, Instrumented extends boolean = true>({ client, urlVar, instrumented }: PrismaOptions<C, Instrumented>) => (Instrumented extends true ? Module<PortClassOf<N, C> extends (infer T) ? T extends PortClassOf<N, C> ? T extends import("@btravstack/di").AnyPort ? InstanceType<T> : T extends import("@btravstack/di").AnyProvider ? InstanceType<T["port"]> : never : never : never, import("@btravstack/config").ConfigInvalid, Exclude<Env, import("@btravstack/di").PortInstance<string, C> | import("@btravstack/di").PortInstance<`${N}Config`, {
59
+ declare const prismaDatabase: <const N extends string>(name: N) => <C extends PrismaLike, Instrumented extends boolean = true>({ client, instrumented }: PrismaOptions<C, Instrumented>) => (Instrumented extends true ? Module<PortClassOf<N, C> extends (infer T) ? T extends PortClassOf<N, C> ? T extends import("@btravstack/di").AnyPort ? InstanceType<T> : T extends import("@btravstack/di").AnyProvider ? InstanceType<T["port"]> : never : never : never, import("@btravstack/config").ConfigInvalid, Exclude<Env, import("@btravstack/di").PortInstance<string, C> | import("@btravstack/di").PortInstance<`${N}Config`, {
63
60
  readonly url: string;
64
61
  }>> | Exclude<Logger, import("@btravstack/di").PortInstance<string, C> | import("@btravstack/di").PortInstance<`${N}Config`, {
65
62
  readonly url: string;
package/dist/index.mjs CHANGED
@@ -108,10 +108,10 @@ const enableTracing = async (logger, load = defaultLoader) => {
108
108
  * against this same URL *before the process starts*; an application that
109
109
  * migrates itself at boot races every other replica.
110
110
  */
111
- const prismaDatabase = (name) => ({ client, urlVar = "DATABASE_URL", instrumented }) => {
112
- const config = Config.provider(`${name}Config`)(Config.object({ url: Config.string(urlVar) }));
111
+ const prismaDatabase = (name) => ({ client, instrumented }) => {
112
+ const config = Config.provider(`${name}Config`)(Config.object({ url: Config.string("DATABASE_URL") }));
113
113
  const DatabasePort = Port(name);
114
- const open = (url) => client(new PrismaPg({ connectionString: url }), url);
114
+ const open = (url) => client(new PrismaPg({ connectionString: url }));
115
115
  const port = DatabasePort;
116
116
  const instrumentedProvider = Provider(port)({
117
117
  settings: config.port,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@btravstack/prisma",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "The Prisma starter for @btravstack/core: DATABASE_URL through Config, the Postgres driver adapter, and a client whose pool is the application scope's",
5
5
  "keywords": [
6
6
  "database",
@@ -53,17 +53,17 @@
53
53
  "typescript": "7.0.2",
54
54
  "unthrown": "5.7.0",
55
55
  "vitest": "4.1.11",
56
- "@btravstack/config": "0.4.0",
57
- "@btravstack/core": "0.4.0",
58
- "@btravstack/di": "0.4.0"
56
+ "@btravstack/config": "0.5.0",
57
+ "@btravstack/core": "0.5.0",
58
+ "@btravstack/di": "0.5.0"
59
59
  },
60
60
  "peerDependencies": {
61
61
  "@prisma/adapter-pg": "^7.0.0",
62
62
  "@prisma/instrumentation": "^7.0.0",
63
63
  "unthrown": "^5.0.0",
64
- "@btravstack/config": "^0.4.0",
65
- "@btravstack/core": "^0.4.0",
66
- "@btravstack/di": "^0.4.0"
64
+ "@btravstack/config": "^0.5.0",
65
+ "@btravstack/core": "^0.5.0",
66
+ "@btravstack/di": "^0.5.0"
67
67
  },
68
68
  "peerDependenciesMeta": {
69
69
  "@prisma/instrumentation": {
@@ -71,13 +71,13 @@
71
71
  }
72
72
  },
73
73
  "engines": {
74
- "node": ">=20"
74
+ "node": ">=22"
75
75
  },
76
76
  "scripts": {
77
77
  "build": "tsdown src/index.ts --format cjs,esm --dts --clean",
78
78
  "dev": "tsdown src/index.ts --format cjs,esm --dts --watch",
79
79
  "test": "vitest run --coverage",
80
80
  "test:types": "tsc -p tsconfig.test-d.json --noEmit",
81
- "typecheck": "tsc --noEmit"
81
+ "typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.test-d.json"
82
82
  }
83
83
  }