@prisma-next/postgres 0.3.0-dev.41 → 0.3.0-dev.44
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 +20 -14
- package/dist/runtime.d.mts +22 -4
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +55 -66
- package/dist/runtime.mjs.map +1 -1
- package/package.json +15 -24
- package/src/exports/runtime.ts +1 -1
- package/src/runtime/binding.ts +11 -46
- package/src/runtime/postgres.ts +74 -50
package/README.md
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
# @prisma-next/postgres
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Composition-root Postgres helper that builds a Prisma Next runtime client and exposes SQL, ORM, schema, and Kysely-integrated query access.
|
|
4
4
|
|
|
5
5
|
## Package Classification
|
|
6
6
|
|
|
7
|
-
- **Domain**:
|
|
8
|
-
- **Layer**:
|
|
7
|
+
- **Domain**: extensions
|
|
8
|
+
- **Layer**: adapters
|
|
9
9
|
- **Plane**: runtime
|
|
10
10
|
|
|
11
11
|
## Overview
|
|
12
12
|
|
|
13
|
-
`@prisma-next/postgres
|
|
13
|
+
`@prisma-next/postgres/runtime` exposes a single `postgres(...)` helper that composes the Postgres execution stack and returns query/runtime roots:
|
|
14
14
|
|
|
15
15
|
- `db.sql`
|
|
16
|
+
- `db.kysely(runtime)`
|
|
16
17
|
- `db.schema`
|
|
18
|
+
- `db.orm`
|
|
17
19
|
- `db.context`
|
|
18
20
|
- `db.stack`
|
|
19
21
|
|
|
20
|
-
Runtime and connection resources are deferred until `
|
|
22
|
+
Runtime and connection resources are deferred until `db.runtime()` is called.
|
|
21
23
|
|
|
22
24
|
When URL binding is used, pool timeouts are configurable via `poolOptions`:
|
|
23
25
|
|
|
@@ -27,11 +29,11 @@ When URL binding is used, pool timeouts are configurable via `poolOptions`:
|
|
|
27
29
|
## Responsibilities
|
|
28
30
|
|
|
29
31
|
- Build a static Postgres execution stack from target, adapter, and driver descriptors
|
|
30
|
-
- Build
|
|
32
|
+
- Build typed SQL and Kysely lane instances from the same execution context
|
|
33
|
+
- Build static schema and ORM roots from the execution context
|
|
31
34
|
- Normalize runtime binding input (`binding`, `url`, `pg`)
|
|
32
|
-
- Lazily instantiate
|
|
33
|
-
-
|
|
34
|
-
- Memoize runtime so repeated `await db.runtime()` calls return one instance
|
|
35
|
+
- Lazily instantiate runtime resources on first `db.runtime()` call
|
|
36
|
+
- Memoize runtime so repeated `db.runtime()` calls return one instance
|
|
35
37
|
|
|
36
38
|
## Dependencies
|
|
37
39
|
|
|
@@ -41,23 +43,26 @@ When URL binding is used, pool timeouts are configurable via `poolOptions`:
|
|
|
41
43
|
- `@prisma-next/adapter-postgres` for adapter descriptor
|
|
42
44
|
- `@prisma-next/driver-postgres` for driver descriptor
|
|
43
45
|
- `@prisma-next/sql-lane` for `sql(...)`
|
|
46
|
+
- `@prisma-next/integration-kysely` for `KyselyPrismaDialect` and contract-to-Kysely typing
|
|
44
47
|
- `@prisma-next/sql-relational-core` for `schema(...)`
|
|
48
|
+
- `@prisma-next/sql-orm-client` for `orm(...)`
|
|
45
49
|
- `@prisma-next/sql-contract` for `validateContract(...)` and contract types
|
|
46
|
-
- `
|
|
50
|
+
- `kysely` for query-builder API surface
|
|
51
|
+
- `pg` for lazy `Pool` construction when using URL binding
|
|
47
52
|
|
|
48
53
|
## Architecture
|
|
49
54
|
|
|
50
55
|
```mermaid
|
|
51
56
|
flowchart TD
|
|
52
57
|
App[App Code] --> Client[postgres(...)]
|
|
53
|
-
Client --> Static[
|
|
58
|
+
Client --> Static[Roots: sql kysely(runtime) schema orm context stack]
|
|
54
59
|
Client --> Lazy[runtime()]
|
|
55
60
|
|
|
56
61
|
Lazy --> Instantiate[instantiateExecutionStack]
|
|
57
62
|
Lazy --> Bind[Resolve binding: url or pg]
|
|
58
|
-
Bind -->
|
|
59
|
-
|
|
60
|
-
|
|
63
|
+
Bind --> Pool[pg.Pool for url binding]
|
|
64
|
+
Bind --> Reuse[Reuse Pool or Client for pg binding]
|
|
65
|
+
Lazy --> Runtime[createRuntime]
|
|
61
66
|
|
|
62
67
|
Runtime --> Target[@prisma-next/target-postgres]
|
|
63
68
|
Runtime --> Adapter[@prisma-next/adapter-postgres]
|
|
@@ -71,3 +76,4 @@ flowchart TD
|
|
|
71
76
|
- Spec: `agent-os/specs/2026-02-10-postgres-one-liner-lazy-client/spec.md`
|
|
72
77
|
- Architecture: `docs/Architecture Overview.md`
|
|
73
78
|
- Subsystem: `docs/architecture docs/subsystems/4. Runtime & Plugin Framework.md`
|
|
79
|
+
- Subsystem: `docs/architecture docs/subsystems/5. Adapters & Targets.md`
|
package/dist/runtime.d.mts
CHANGED
|
@@ -1,14 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { KyselifyContract } from "@prisma-next/integration-kysely";
|
|
2
2
|
import { SelectBuilder } from "@prisma-next/sql-lane";
|
|
3
|
+
import { orm } from "@prisma-next/sql-orm-client";
|
|
3
4
|
import { SchemaHandle } from "@prisma-next/sql-relational-core/schema";
|
|
4
5
|
import { ExecutionContext, Plugin, Runtime, RuntimeVerifyOptions, SqlExecutionStackWithDriver, SqlRuntimeExtensionDescriptor } from "@prisma-next/sql-runtime";
|
|
6
|
+
import { Kysely } from "kysely";
|
|
5
7
|
import { Client, Pool } from "pg";
|
|
6
8
|
import { ExtractCodecTypes, ExtractOperationTypes, SqlContract, SqlStorage } from "@prisma-next/sql-contract/types";
|
|
7
9
|
import { OperationTypeSignature, OperationTypes } from "@prisma-next/sql-relational-core/types";
|
|
8
10
|
|
|
9
11
|
//#region src/runtime/binding.d.ts
|
|
12
|
+
type PostgresBinding = {
|
|
13
|
+
readonly kind: 'url';
|
|
14
|
+
readonly url: string;
|
|
15
|
+
} | {
|
|
16
|
+
readonly kind: 'pgPool';
|
|
17
|
+
readonly pool: Pool;
|
|
18
|
+
} | {
|
|
19
|
+
readonly kind: 'pgClient';
|
|
20
|
+
readonly client: Client;
|
|
21
|
+
};
|
|
10
22
|
type PostgresBindingInput = {
|
|
11
|
-
readonly binding: PostgresBinding
|
|
23
|
+
readonly binding: PostgresBinding;
|
|
12
24
|
readonly url?: never;
|
|
13
25
|
readonly pg?: never;
|
|
14
26
|
} | {
|
|
@@ -25,18 +37,24 @@ type PostgresBindingInput = {
|
|
|
25
37
|
type NormalizeOperationTypes<T> = { [TypeId in keyof T]: { [Method in keyof T[TypeId]]: T[TypeId][Method] extends OperationTypeSignature ? T[TypeId][Method] : OperationTypeSignature } };
|
|
26
38
|
type ToSchemaOperationTypes<T> = T extends OperationTypes ? T : NormalizeOperationTypes<T>;
|
|
27
39
|
type PostgresTargetId = 'postgres';
|
|
40
|
+
type OrmClient<TContract extends SqlContract<SqlStorage>> = ReturnType<typeof orm<TContract>>;
|
|
28
41
|
interface PostgresClient<TContract extends SqlContract<SqlStorage>> {
|
|
29
42
|
readonly sql: SelectBuilder<TContract, unknown, ExtractCodecTypes<TContract>, ExtractOperationTypes<TContract>>;
|
|
43
|
+
kysely(runtime: Runtime): Kysely<KyselifyContract<TContract>>;
|
|
30
44
|
readonly schema: SchemaHandle<TContract, ExtractCodecTypes<TContract>, ToSchemaOperationTypes<ExtractOperationTypes<TContract>>>;
|
|
45
|
+
readonly orm: OrmClient<TContract>;
|
|
31
46
|
readonly context: ExecutionContext<TContract>;
|
|
32
47
|
readonly stack: SqlExecutionStackWithDriver<PostgresTargetId>;
|
|
33
|
-
runtime():
|
|
48
|
+
runtime(): Runtime;
|
|
34
49
|
}
|
|
35
50
|
interface PostgresOptionsBase<TContract extends SqlContract<SqlStorage>> {
|
|
36
51
|
readonly extensions?: readonly SqlRuntimeExtensionDescriptor<PostgresTargetId>[];
|
|
37
52
|
readonly plugins?: readonly Plugin<TContract>[];
|
|
38
53
|
readonly verify?: RuntimeVerifyOptions;
|
|
39
|
-
readonly
|
|
54
|
+
readonly poolOptions?: {
|
|
55
|
+
readonly connectionTimeoutMillis?: number;
|
|
56
|
+
readonly idleTimeoutMillis?: number;
|
|
57
|
+
};
|
|
40
58
|
}
|
|
41
59
|
type PostgresOptionsWithContract<TContract extends SqlContract<SqlStorage>> = PostgresBindingInput & PostgresOptionsBase<TContract> & {
|
|
42
60
|
readonly contract: TContract;
|
package/dist/runtime.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/runtime/binding.ts","../src/runtime/postgres.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/runtime/binding.ts","../src/runtime/postgres.ts"],"sourcesContent":[],"mappings":"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"}
|
package/dist/runtime.mjs
CHANGED
|
@@ -1,61 +1,38 @@
|
|
|
1
1
|
import postgresAdapter from "@prisma-next/adapter-postgres/runtime";
|
|
2
2
|
import { instantiateExecutionStack } from "@prisma-next/core-execution-plane/stack";
|
|
3
3
|
import postgresDriver from "@prisma-next/driver-postgres/runtime";
|
|
4
|
+
import { KyselyPrismaDialect } from "@prisma-next/integration-kysely";
|
|
4
5
|
import { validateContract } from "@prisma-next/sql-contract/validate";
|
|
5
6
|
import { sql } from "@prisma-next/sql-lane";
|
|
7
|
+
import { orm } from "@prisma-next/sql-orm-client";
|
|
6
8
|
import { schema } from "@prisma-next/sql-relational-core/schema";
|
|
7
9
|
import { createExecutionContext, createRuntime, createSqlExecutionStack } from "@prisma-next/sql-runtime";
|
|
8
10
|
import postgresTarget from "@prisma-next/target-postgres/runtime";
|
|
9
|
-
import {
|
|
11
|
+
import { Kysely } from "kysely";
|
|
10
12
|
import { Client, Pool } from "pg";
|
|
11
13
|
|
|
12
14
|
//#region src/runtime/binding.ts
|
|
13
|
-
function bindingError(message, details) {
|
|
14
|
-
const error = new Error(message);
|
|
15
|
-
Object.defineProperty(error, "name", {
|
|
16
|
-
value: "RuntimeError",
|
|
17
|
-
configurable: true
|
|
18
|
-
});
|
|
19
|
-
return Object.assign(error, {
|
|
20
|
-
code: "DRIVER.BINDING_INVALID",
|
|
21
|
-
category: "RUNTIME",
|
|
22
|
-
severity: "error",
|
|
23
|
-
message,
|
|
24
|
-
details
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
15
|
function validatePostgresUrl(url) {
|
|
28
16
|
const trimmed = url.trim();
|
|
29
|
-
if (trimmed.length === 0) throw
|
|
30
|
-
field: "url",
|
|
31
|
-
reason: "empty"
|
|
32
|
-
});
|
|
17
|
+
if (trimmed.length === 0) throw new Error("Postgres URL must be a non-empty string");
|
|
33
18
|
let parsed;
|
|
34
19
|
try {
|
|
35
20
|
parsed = new URL(trimmed);
|
|
36
21
|
} catch {
|
|
37
|
-
throw
|
|
38
|
-
field: "url",
|
|
39
|
-
reason: "invalid-url"
|
|
40
|
-
});
|
|
22
|
+
throw new Error("Postgres URL must be a valid URL");
|
|
41
23
|
}
|
|
42
|
-
if (parsed.protocol !== "postgres:" && parsed.protocol !== "postgresql:") throw
|
|
43
|
-
field: "url",
|
|
44
|
-
reason: "invalid-protocol",
|
|
45
|
-
protocol: parsed.protocol
|
|
46
|
-
});
|
|
24
|
+
if (parsed.protocol !== "postgres:" && parsed.protocol !== "postgresql:") throw new Error("Postgres URL must use postgres:// or postgresql://");
|
|
47
25
|
return trimmed;
|
|
48
26
|
}
|
|
49
27
|
function resolvePostgresBinding(options) {
|
|
50
|
-
|
|
51
|
-
if (providedCount !== 1) throw bindingError("Provide one binding input: binding, url, or pg", { providedCount });
|
|
28
|
+
if (Number(options.binding !== void 0) + Number(options.url !== void 0) + Number(options.pg !== void 0) !== 1) throw new Error("Provide one binding input: binding, url, or pg");
|
|
52
29
|
if (options.binding !== void 0) return options.binding;
|
|
53
30
|
if (options.url !== void 0) return {
|
|
54
31
|
kind: "url",
|
|
55
32
|
url: validatePostgresUrl(options.url)
|
|
56
33
|
};
|
|
57
34
|
const pgBinding = options.pg;
|
|
58
|
-
if (pgBinding === void 0) throw
|
|
35
|
+
if (pgBinding === void 0) throw new Error("Invariant violation: expected pg binding after validation");
|
|
59
36
|
if (pgBinding instanceof Pool) return {
|
|
60
37
|
kind: "pgPool",
|
|
61
38
|
pool: pgBinding
|
|
@@ -64,7 +41,7 @@ function resolvePostgresBinding(options) {
|
|
|
64
41
|
kind: "pgClient",
|
|
65
42
|
client: pgBinding
|
|
66
43
|
};
|
|
67
|
-
throw
|
|
44
|
+
throw new Error("Unable to determine pg binding type from pg input; use binding with explicit kind");
|
|
68
45
|
}
|
|
69
46
|
|
|
70
47
|
//#endregion
|
|
@@ -81,12 +58,7 @@ function postgres(options) {
|
|
|
81
58
|
const stack = createSqlExecutionStack({
|
|
82
59
|
target: postgresTarget,
|
|
83
60
|
adapter: postgresAdapter,
|
|
84
|
-
driver:
|
|
85
|
-
...postgresDriver,
|
|
86
|
-
create() {
|
|
87
|
-
return postgresDriver.create({ cursor: options.cursor });
|
|
88
|
-
}
|
|
89
|
-
},
|
|
61
|
+
driver: postgresDriver,
|
|
90
62
|
extensionPacks: options.extensions ?? []
|
|
91
63
|
});
|
|
92
64
|
const context = createExecutionContext({
|
|
@@ -95,39 +67,56 @@ function postgres(options) {
|
|
|
95
67
|
});
|
|
96
68
|
const schema$1 = schema(context);
|
|
97
69
|
const sql$1 = sql({ context });
|
|
98
|
-
let
|
|
70
|
+
let runtimeInstance;
|
|
71
|
+
const getRuntime = () => {
|
|
72
|
+
if (runtimeInstance) return runtimeInstance;
|
|
73
|
+
const stackInstance = instantiateExecutionStack(stack);
|
|
74
|
+
const driverDescriptor = stack.driver;
|
|
75
|
+
if (!driverDescriptor) throw new Error("Driver descriptor missing from execution stack");
|
|
76
|
+
const connect = binding.kind === "url" ? { pool: new Pool({
|
|
77
|
+
connectionString: binding.url,
|
|
78
|
+
connectionTimeoutMillis: options.poolOptions?.connectionTimeoutMillis ?? 2e4,
|
|
79
|
+
idleTimeoutMillis: options.poolOptions?.idleTimeoutMillis ?? 3e4
|
|
80
|
+
}) } : binding.kind === "pgPool" ? { pool: binding.pool } : { client: binding.client };
|
|
81
|
+
runtimeInstance = createRuntime({
|
|
82
|
+
stackInstance,
|
|
83
|
+
context,
|
|
84
|
+
driver: driverDescriptor.create({
|
|
85
|
+
connect,
|
|
86
|
+
cursor: { disabled: true }
|
|
87
|
+
}),
|
|
88
|
+
verify: options.verify ?? {
|
|
89
|
+
mode: "onFirstUse",
|
|
90
|
+
requireMarker: false
|
|
91
|
+
},
|
|
92
|
+
...options.plugins ? { plugins: options.plugins } : {}
|
|
93
|
+
});
|
|
94
|
+
return runtimeInstance;
|
|
95
|
+
};
|
|
99
96
|
return {
|
|
100
97
|
sql: sql$1,
|
|
98
|
+
kysely(runtime) {
|
|
99
|
+
return new Kysely({ dialect: new KyselyPrismaDialect({
|
|
100
|
+
runtime,
|
|
101
|
+
contract
|
|
102
|
+
}) });
|
|
103
|
+
},
|
|
101
104
|
schema: schema$1,
|
|
105
|
+
orm: orm({
|
|
106
|
+
contract,
|
|
107
|
+
runtime: {
|
|
108
|
+
execute(plan) {
|
|
109
|
+
return getRuntime().execute(plan);
|
|
110
|
+
},
|
|
111
|
+
connection() {
|
|
112
|
+
return getRuntime().connection();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}),
|
|
102
116
|
context,
|
|
103
117
|
stack,
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
runtimePromise = (async () => {
|
|
107
|
-
const stackInstance = instantiateExecutionStack(stack);
|
|
108
|
-
const driver = stackInstance.driver;
|
|
109
|
-
if (driver === void 0) throw new Error("Relational runtime requires a driver descriptor on the execution stack");
|
|
110
|
-
try {
|
|
111
|
-
await driver.connect(binding);
|
|
112
|
-
return createRuntime({
|
|
113
|
-
stackInstance,
|
|
114
|
-
context,
|
|
115
|
-
driver,
|
|
116
|
-
verify: options.verify ?? {
|
|
117
|
-
mode: "onFirstUse",
|
|
118
|
-
requireMarker: false
|
|
119
|
-
},
|
|
120
|
-
...ifDefined("plugins", options.plugins)
|
|
121
|
-
});
|
|
122
|
-
} catch (error) {
|
|
123
|
-
await driver.close().catch(() => void 0);
|
|
124
|
-
throw error;
|
|
125
|
-
}
|
|
126
|
-
})();
|
|
127
|
-
runtimePromise.catch(() => {
|
|
128
|
-
runtimePromise = void 0;
|
|
129
|
-
});
|
|
130
|
-
return runtimePromise;
|
|
118
|
+
runtime() {
|
|
119
|
+
return getRuntime();
|
|
131
120
|
}
|
|
132
121
|
};
|
|
133
122
|
}
|
package/dist/runtime.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.mjs","names":["parsed: URL","PgPool","PgClient","schema: PostgresClient<TContract>['schema']","schemaBuilder","sql","sqlBuilder","runtimePromise: Promise<Runtime> | undefined"],"sources":["../src/runtime/binding.ts","../src/runtime/postgres.ts"],"sourcesContent":["import type { PostgresBinding } from '@prisma-next/driver-postgres/runtime';\nimport type { Client, Pool } from 'pg';\nimport { Client as PgClient, Pool as PgPool } from 'pg';\n\nexport type PostgresBindingInput =\n | {\n readonly binding: PostgresBinding;\n readonly url?: never;\n readonly pg?: never;\n }\n | {\n readonly url: string;\n readonly binding?: never;\n readonly pg?: never;\n }\n | {\n readonly pg: Pool | Client;\n readonly binding?: never;\n readonly url?: never;\n };\n\ninterface PostgresBindingError extends Error {\n readonly code: 'DRIVER.BINDING_INVALID';\n readonly category: 'RUNTIME';\n readonly severity: 'error';\n readonly details?: Record<string, unknown>;\n}\n\nfunction bindingError(message: string, details?: Record<string, unknown>): PostgresBindingError {\n const error = new Error(message) as PostgresBindingError;\n Object.defineProperty(error, 'name', {\n value: 'RuntimeError',\n configurable: true,\n });\n return Object.assign(error, {\n code: 'DRIVER.BINDING_INVALID' as const,\n category: 'RUNTIME' as const,\n severity: 'error' as const,\n message,\n details,\n });\n}\n\nfunction validatePostgresUrl(url: string): string {\n const trimmed = url.trim();\n if (trimmed.length === 0) {\n throw bindingError('Postgres URL must be a non-empty string', {\n field: 'url',\n reason: 'empty',\n });\n }\n\n let parsed: URL;\n try {\n parsed = new URL(trimmed);\n } catch {\n throw bindingError('Postgres URL must be a valid URL', {\n field: 'url',\n reason: 'invalid-url',\n });\n }\n\n if (parsed.protocol !== 'postgres:' && parsed.protocol !== 'postgresql:') {\n throw bindingError('Postgres URL must use postgres:// or postgresql://', {\n field: 'url',\n reason: 'invalid-protocol',\n protocol: parsed.protocol,\n });\n }\n\n return trimmed;\n}\n\nexport function resolvePostgresBinding(options: PostgresBindingInput): PostgresBinding {\n const providedCount =\n Number(options.binding !== undefined) +\n Number(options.url !== undefined) +\n Number(options.pg !== undefined);\n\n if (providedCount !== 1) {\n throw bindingError('Provide one binding input: binding, url, or pg', {\n providedCount,\n });\n }\n\n if (options.binding !== undefined) {\n return options.binding;\n }\n\n if (options.url !== undefined) {\n return { kind: 'url', url: validatePostgresUrl(options.url) };\n }\n\n const pgBinding = options.pg;\n if (pgBinding === undefined) {\n throw bindingError('Invariant violation: expected pg binding after validation', {\n reason: 'missing-pg-binding',\n });\n }\n\n if (pgBinding instanceof PgPool) {\n return { kind: 'pgPool', pool: pgBinding };\n }\n\n if (pgBinding instanceof PgClient) {\n return { kind: 'pgClient', client: pgBinding };\n }\n\n throw bindingError(\n 'Unable to determine pg binding type from pg input; use binding with explicit kind',\n {\n reason: 'unknown-pg-instance',\n },\n );\n}\n","import postgresAdapter from '@prisma-next/adapter-postgres/runtime';\nimport { instantiateExecutionStack } from '@prisma-next/core-execution-plane/stack';\nimport type { PostgresDriverCreateOptions } from '@prisma-next/driver-postgres/runtime';\nimport postgresDriver from '@prisma-next/driver-postgres/runtime';\nimport type {\n ExtractCodecTypes,\n ExtractOperationTypes,\n SqlContract,\n SqlStorage,\n} from '@prisma-next/sql-contract/types';\nimport { validateContract } from '@prisma-next/sql-contract/validate';\nimport type { SelectBuilder } from '@prisma-next/sql-lane';\nimport { sql as sqlBuilder } from '@prisma-next/sql-lane';\nimport type { SchemaHandle } from '@prisma-next/sql-relational-core/schema';\nimport { schema as schemaBuilder } from '@prisma-next/sql-relational-core/schema';\nimport type {\n OperationTypeSignature,\n OperationTypes,\n} from '@prisma-next/sql-relational-core/types';\nimport type {\n ExecutionContext,\n Plugin,\n Runtime,\n RuntimeVerifyOptions,\n SqlExecutionStackWithDriver,\n SqlRuntimeExtensionDescriptor,\n} from '@prisma-next/sql-runtime';\nimport {\n createExecutionContext,\n createRuntime,\n createSqlExecutionStack,\n} from '@prisma-next/sql-runtime';\nimport postgresTarget from '@prisma-next/target-postgres/runtime';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { type PostgresBindingInput, resolvePostgresBinding } from './binding';\n\ntype NormalizeOperationTypes<T> = {\n [TypeId in keyof T]: {\n [Method in keyof T[TypeId]]: T[TypeId][Method] extends OperationTypeSignature\n ? T[TypeId][Method]\n : OperationTypeSignature;\n };\n};\n\ntype ToSchemaOperationTypes<T> = T extends OperationTypes ? T : NormalizeOperationTypes<T>;\n\nexport type PostgresTargetId = 'postgres';\n\nexport interface PostgresClient<TContract extends SqlContract<SqlStorage>> {\n readonly sql: SelectBuilder<\n TContract,\n unknown,\n ExtractCodecTypes<TContract>,\n ExtractOperationTypes<TContract>\n >;\n readonly schema: SchemaHandle<\n TContract,\n ExtractCodecTypes<TContract>,\n ToSchemaOperationTypes<ExtractOperationTypes<TContract>>\n >;\n readonly context: ExecutionContext<TContract>;\n readonly stack: SqlExecutionStackWithDriver<PostgresTargetId>;\n runtime(): Promise<Runtime>;\n}\n\nexport interface PostgresOptionsBase<TContract extends SqlContract<SqlStorage>> {\n readonly extensions?: readonly SqlRuntimeExtensionDescriptor<PostgresTargetId>[];\n readonly plugins?: readonly Plugin<TContract>[];\n readonly verify?: RuntimeVerifyOptions;\n readonly cursor?: PostgresDriverCreateOptions['cursor'];\n}\n\nexport type PostgresOptionsWithContract<TContract extends SqlContract<SqlStorage>> =\n PostgresBindingInput &\n PostgresOptionsBase<TContract> & {\n readonly contract: TContract;\n readonly contractJson?: never;\n };\n\nexport type PostgresOptionsWithContractJson<TContract extends SqlContract<SqlStorage>> =\n PostgresBindingInput &\n PostgresOptionsBase<TContract> & {\n readonly contractJson: unknown;\n readonly contract?: never;\n };\n\nexport type PostgresOptions<TContract extends SqlContract<SqlStorage>> =\n | PostgresOptionsWithContract<TContract>\n | PostgresOptionsWithContractJson<TContract>;\n\nfunction hasContractJson<TContract extends SqlContract<SqlStorage>>(\n options: PostgresOptions<TContract>,\n): options is PostgresOptionsWithContractJson<TContract> {\n return 'contractJson' in options;\n}\n\nfunction resolveContract<TContract extends SqlContract<SqlStorage>>(\n options: PostgresOptions<TContract>,\n): TContract {\n const contractInput = hasContractJson(options) ? options.contractJson : options.contract;\n return validateContract<TContract>(contractInput);\n}\n\n/**\n * Creates a lazy Postgres client from either `contractJson` or a TypeScript-authored `contract`.\n * Static query surfaces are available immediately, while `runtime()` instantiates the driver/pool on first call.\n */\nexport default function postgres<TContract extends SqlContract<SqlStorage>>(\n options: PostgresOptionsWithContract<TContract>,\n): PostgresClient<TContract>;\nexport default function postgres<TContract extends SqlContract<SqlStorage>>(\n options: PostgresOptionsWithContractJson<TContract>,\n): PostgresClient<TContract>;\nexport default function postgres<TContract extends SqlContract<SqlStorage>>(\n options: PostgresOptions<TContract>,\n): PostgresClient<TContract> {\n const contract = resolveContract(options);\n const binding = resolvePostgresBinding(options);\n const stack = createSqlExecutionStack({\n target: postgresTarget,\n adapter: postgresAdapter,\n driver:\n options.cursor === undefined\n ? postgresDriver\n : {\n ...postgresDriver,\n create() {\n return postgresDriver.create({ cursor: options.cursor });\n },\n },\n extensionPacks: options.extensions ?? [],\n });\n\n const context = createExecutionContext({\n contract,\n stack,\n });\n\n const schema: PostgresClient<TContract>['schema'] = schemaBuilder(context);\n const sql = sqlBuilder({ context });\n\n let runtimePromise: Promise<Runtime> | undefined;\n\n return {\n sql,\n schema,\n context,\n stack,\n async runtime() {\n if (runtimePromise) {\n return runtimePromise;\n }\n\n runtimePromise = (async () => {\n const stackInstance = instantiateExecutionStack(stack);\n const driver = stackInstance.driver;\n if (driver === undefined) {\n throw new Error('Relational runtime requires a driver descriptor on the execution stack');\n }\n\n try {\n // `binding` is normalized by resolvePostgresBinding(), so this call site remains\n // type-safe in practice while SqlRuntimeDriverInstance currently uses SqlDriver<unknown>.\n await driver.connect(binding);\n\n return createRuntime({\n stackInstance,\n context,\n driver,\n verify: options.verify ?? { mode: 'onFirstUse', requireMarker: false },\n ...ifDefined('plugins', options.plugins),\n });\n } catch (error) {\n await driver.close().catch(() => undefined);\n throw error;\n }\n })();\n\n runtimePromise.catch(() => {\n runtimePromise = undefined;\n });\n\n return runtimePromise;\n },\n };\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"runtime.mjs","names":["parsed: URL","PgPool","PgClient","schema: PostgresClient<TContract>['schema']","schemaBuilder","sql","sqlBuilder","runtimeInstance: Runtime | undefined","ormBuilder"],"sources":["../src/runtime/binding.ts","../src/runtime/postgres.ts"],"sourcesContent":["import type { Client, Pool } from 'pg';\nimport { Client as PgClient, Pool as PgPool } from 'pg';\n\nexport type PostgresBinding =\n | { readonly kind: 'url'; readonly url: string }\n | { readonly kind: 'pgPool'; readonly pool: Pool }\n | { readonly kind: 'pgClient'; readonly client: Client };\n\nexport type PostgresBindingInput =\n | {\n readonly binding: PostgresBinding;\n readonly url?: never;\n readonly pg?: never;\n }\n | {\n readonly url: string;\n readonly binding?: never;\n readonly pg?: never;\n }\n | {\n readonly pg: Pool | Client;\n readonly binding?: never;\n readonly url?: never;\n };\n\nfunction validatePostgresUrl(url: string): string {\n const trimmed = url.trim();\n if (trimmed.length === 0) {\n throw new Error('Postgres URL must be a non-empty string');\n }\n\n let parsed: URL;\n try {\n parsed = new URL(trimmed);\n } catch {\n throw new Error('Postgres URL must be a valid URL');\n }\n\n if (parsed.protocol !== 'postgres:' && parsed.protocol !== 'postgresql:') {\n throw new Error('Postgres URL must use postgres:// or postgresql://');\n }\n\n return trimmed;\n}\n\nexport function resolvePostgresBinding(options: PostgresBindingInput): PostgresBinding {\n const providedCount =\n Number(options.binding !== undefined) +\n Number(options.url !== undefined) +\n Number(options.pg !== undefined);\n\n if (providedCount !== 1) {\n throw new Error('Provide one binding input: binding, url, or pg');\n }\n\n if (options.binding !== undefined) {\n return options.binding;\n }\n\n if (options.url !== undefined) {\n return { kind: 'url', url: validatePostgresUrl(options.url) };\n }\n\n const pgBinding = options.pg;\n if (pgBinding === undefined) {\n throw new Error('Invariant violation: expected pg binding after validation');\n }\n\n if (pgBinding instanceof PgPool) {\n return { kind: 'pgPool', pool: pgBinding };\n }\n\n if (pgBinding instanceof PgClient) {\n return { kind: 'pgClient', client: pgBinding };\n }\n\n throw new Error(\n 'Unable to determine pg binding type from pg input; use binding with explicit kind',\n );\n}\n","import postgresAdapter from '@prisma-next/adapter-postgres/runtime';\nimport { instantiateExecutionStack } from '@prisma-next/core-execution-plane/stack';\nimport postgresDriver from '@prisma-next/driver-postgres/runtime';\nimport { type KyselifyContract, KyselyPrismaDialect } from '@prisma-next/integration-kysely';\nimport type {\n ExtractCodecTypes,\n ExtractOperationTypes,\n SqlContract,\n SqlStorage,\n} from '@prisma-next/sql-contract/types';\nimport { validateContract } from '@prisma-next/sql-contract/validate';\nimport type { SelectBuilder } from '@prisma-next/sql-lane';\nimport { sql as sqlBuilder } from '@prisma-next/sql-lane';\nimport { orm as ormBuilder } from '@prisma-next/sql-orm-client';\nimport type { SchemaHandle } from '@prisma-next/sql-relational-core/schema';\nimport { schema as schemaBuilder } from '@prisma-next/sql-relational-core/schema';\nimport type {\n OperationTypeSignature,\n OperationTypes,\n} from '@prisma-next/sql-relational-core/types';\nimport type {\n ExecutionContext,\n Plugin,\n Runtime,\n RuntimeVerifyOptions,\n SqlExecutionStackWithDriver,\n SqlRuntimeExtensionDescriptor,\n} from '@prisma-next/sql-runtime';\nimport {\n createExecutionContext,\n createRuntime,\n createSqlExecutionStack,\n} from '@prisma-next/sql-runtime';\nimport postgresTarget from '@prisma-next/target-postgres/runtime';\nimport { Kysely } from 'kysely';\nimport { Pool } from 'pg';\nimport { type PostgresBindingInput, resolvePostgresBinding } from './binding';\n\ntype NormalizeOperationTypes<T> = {\n [TypeId in keyof T]: {\n [Method in keyof T[TypeId]]: T[TypeId][Method] extends OperationTypeSignature\n ? T[TypeId][Method]\n : OperationTypeSignature;\n };\n};\n\ntype ToSchemaOperationTypes<T> = T extends OperationTypes ? T : NormalizeOperationTypes<T>;\n\nexport type PostgresTargetId = 'postgres';\ntype OrmClient<TContract extends SqlContract<SqlStorage>> = ReturnType<\n typeof ormBuilder<TContract>\n>;\n\nexport interface PostgresClient<TContract extends SqlContract<SqlStorage>> {\n readonly sql: SelectBuilder<\n TContract,\n unknown,\n ExtractCodecTypes<TContract>,\n ExtractOperationTypes<TContract>\n >;\n kysely(runtime: Runtime): Kysely<KyselifyContract<TContract>>;\n readonly schema: SchemaHandle<\n TContract,\n ExtractCodecTypes<TContract>,\n ToSchemaOperationTypes<ExtractOperationTypes<TContract>>\n >;\n readonly orm: OrmClient<TContract>;\n readonly context: ExecutionContext<TContract>;\n readonly stack: SqlExecutionStackWithDriver<PostgresTargetId>;\n runtime(): Runtime;\n}\n\nexport interface PostgresOptionsBase<TContract extends SqlContract<SqlStorage>> {\n readonly extensions?: readonly SqlRuntimeExtensionDescriptor<PostgresTargetId>[];\n readonly plugins?: readonly Plugin<TContract>[];\n readonly verify?: RuntimeVerifyOptions;\n readonly poolOptions?: {\n readonly connectionTimeoutMillis?: number;\n readonly idleTimeoutMillis?: number;\n };\n}\n\nexport type PostgresOptionsWithContract<TContract extends SqlContract<SqlStorage>> =\n PostgresBindingInput &\n PostgresOptionsBase<TContract> & {\n readonly contract: TContract;\n readonly contractJson?: never;\n };\n\nexport type PostgresOptionsWithContractJson<TContract extends SqlContract<SqlStorage>> =\n PostgresBindingInput &\n PostgresOptionsBase<TContract> & {\n readonly contractJson: unknown;\n readonly contract?: never;\n };\n\nexport type PostgresOptions<TContract extends SqlContract<SqlStorage>> =\n | PostgresOptionsWithContract<TContract>\n | PostgresOptionsWithContractJson<TContract>;\n\nfunction hasContractJson<TContract extends SqlContract<SqlStorage>>(\n options: PostgresOptions<TContract>,\n): options is PostgresOptionsWithContractJson<TContract> {\n return 'contractJson' in options;\n}\n\nfunction resolveContract<TContract extends SqlContract<SqlStorage>>(\n options: PostgresOptions<TContract>,\n): TContract {\n const contractInput = hasContractJson(options) ? options.contractJson : options.contract;\n return validateContract<TContract>(contractInput);\n}\n\n/**\n * Creates a lazy Postgres client from either `contractJson` or a TypeScript-authored `contract`.\n * Static query surfaces are available immediately, while `runtime()` instantiates the driver/pool on first call.\n */\nexport default function postgres<TContract extends SqlContract<SqlStorage>>(\n options: PostgresOptionsWithContract<TContract>,\n): PostgresClient<TContract>;\nexport default function postgres<TContract extends SqlContract<SqlStorage>>(\n options: PostgresOptionsWithContractJson<TContract>,\n): PostgresClient<TContract>;\nexport default function postgres<TContract extends SqlContract<SqlStorage>>(\n options: PostgresOptions<TContract>,\n): PostgresClient<TContract> {\n const contract = resolveContract(options);\n const binding = resolvePostgresBinding(options);\n const stack = createSqlExecutionStack({\n target: postgresTarget,\n adapter: postgresAdapter,\n driver: postgresDriver,\n extensionPacks: options.extensions ?? [],\n });\n\n const context = createExecutionContext({\n contract,\n stack,\n });\n\n const schema: PostgresClient<TContract>['schema'] = schemaBuilder(context);\n const sql = sqlBuilder({ context });\n let runtimeInstance: Runtime | undefined;\n const getRuntime = (): Runtime => {\n if (runtimeInstance) {\n return runtimeInstance;\n }\n\n const stackInstance = instantiateExecutionStack(stack);\n const driverDescriptor = stack.driver;\n if (!driverDescriptor) {\n throw new Error('Driver descriptor missing from execution stack');\n }\n\n const connect =\n binding.kind === 'url'\n ? {\n pool: new Pool({\n connectionString: binding.url,\n connectionTimeoutMillis: options.poolOptions?.connectionTimeoutMillis ?? 20_000,\n idleTimeoutMillis: options.poolOptions?.idleTimeoutMillis ?? 30_000,\n }),\n }\n : binding.kind === 'pgPool'\n ? { pool: binding.pool }\n : { client: binding.client };\n\n const driver = driverDescriptor.create({\n connect,\n cursor: { disabled: true },\n });\n\n runtimeInstance = createRuntime({\n stackInstance,\n context,\n driver,\n verify: options.verify ?? { mode: 'onFirstUse', requireMarker: false },\n ...(options.plugins ? { plugins: options.plugins } : {}),\n });\n\n return runtimeInstance;\n };\n const orm: OrmClient<TContract> = ormBuilder({\n contract,\n runtime: {\n execute(plan) {\n return getRuntime().execute(plan);\n },\n connection() {\n return getRuntime().connection();\n },\n },\n });\n\n return {\n sql,\n kysely(runtime: Runtime) {\n return new Kysely<KyselifyContract<TContract>>({\n dialect: new KyselyPrismaDialect({ runtime, contract }),\n });\n },\n schema,\n orm,\n context,\n stack,\n runtime() {\n return getRuntime();\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AAyBA,SAAS,oBAAoB,KAAqB;CAChD,MAAM,UAAU,IAAI,MAAM;AAC1B,KAAI,QAAQ,WAAW,EACrB,OAAM,IAAI,MAAM,0CAA0C;CAG5D,IAAIA;AACJ,KAAI;AACF,WAAS,IAAI,IAAI,QAAQ;SACnB;AACN,QAAM,IAAI,MAAM,mCAAmC;;AAGrD,KAAI,OAAO,aAAa,eAAe,OAAO,aAAa,cACzD,OAAM,IAAI,MAAM,qDAAqD;AAGvE,QAAO;;AAGT,SAAgB,uBAAuB,SAAgD;AAMrF,KAJE,OAAO,QAAQ,YAAY,OAAU,GACrC,OAAO,QAAQ,QAAQ,OAAU,GACjC,OAAO,QAAQ,OAAO,OAAU,KAEZ,EACpB,OAAM,IAAI,MAAM,iDAAiD;AAGnE,KAAI,QAAQ,YAAY,OACtB,QAAO,QAAQ;AAGjB,KAAI,QAAQ,QAAQ,OAClB,QAAO;EAAE,MAAM;EAAO,KAAK,oBAAoB,QAAQ,IAAI;EAAE;CAG/D,MAAM,YAAY,QAAQ;AAC1B,KAAI,cAAc,OAChB,OAAM,IAAI,MAAM,4DAA4D;AAG9E,KAAI,qBAAqBC,KACvB,QAAO;EAAE,MAAM;EAAU,MAAM;EAAW;AAG5C,KAAI,qBAAqBC,OACvB,QAAO;EAAE,MAAM;EAAY,QAAQ;EAAW;AAGhD,OAAM,IAAI,MACR,oFACD;;;;;ACsBH,SAAS,gBACP,SACuD;AACvD,QAAO,kBAAkB;;AAG3B,SAAS,gBACP,SACW;AAEX,QAAO,iBADe,gBAAgB,QAAQ,GAAG,QAAQ,eAAe,QAAQ,SAC/B;;AAanD,SAAwB,SACtB,SAC2B;CAC3B,MAAM,WAAW,gBAAgB,QAAQ;CACzC,MAAM,UAAU,uBAAuB,QAAQ;CAC/C,MAAM,QAAQ,wBAAwB;EACpC,QAAQ;EACR,SAAS;EACT,QAAQ;EACR,gBAAgB,QAAQ,cAAc,EAAE;EACzC,CAAC;CAEF,MAAM,UAAU,uBAAuB;EACrC;EACA;EACD,CAAC;CAEF,MAAMC,WAA8CC,OAAc,QAAQ;CAC1E,MAAMC,QAAMC,IAAW,EAAE,SAAS,CAAC;CACnC,IAAIC;CACJ,MAAM,mBAA4B;AAChC,MAAI,gBACF,QAAO;EAGT,MAAM,gBAAgB,0BAA0B,MAAM;EACtD,MAAM,mBAAmB,MAAM;AAC/B,MAAI,CAAC,iBACH,OAAM,IAAI,MAAM,iDAAiD;EAGnE,MAAM,UACJ,QAAQ,SAAS,QACb,EACE,MAAM,IAAI,KAAK;GACb,kBAAkB,QAAQ;GAC1B,yBAAyB,QAAQ,aAAa,2BAA2B;GACzE,mBAAmB,QAAQ,aAAa,qBAAqB;GAC9D,CAAC,EACH,GACD,QAAQ,SAAS,WACf,EAAE,MAAM,QAAQ,MAAM,GACtB,EAAE,QAAQ,QAAQ,QAAQ;AAOlC,oBAAkB,cAAc;GAC9B;GACA;GACA,QARa,iBAAiB,OAAO;IACrC;IACA,QAAQ,EAAE,UAAU,MAAM;IAC3B,CAAC;GAMA,QAAQ,QAAQ,UAAU;IAAE,MAAM;IAAc,eAAe;IAAO;GACtE,GAAI,QAAQ,UAAU,EAAE,SAAS,QAAQ,SAAS,GAAG,EAAE;GACxD,CAAC;AAEF,SAAO;;AAcT,QAAO;EACL;EACA,OAAO,SAAkB;AACvB,UAAO,IAAI,OAAoC,EAC7C,SAAS,IAAI,oBAAoB;IAAE;IAAS;IAAU,CAAC,EACxD,CAAC;;EAEJ;EACA,KApBgCC,IAAW;GAC3C;GACA,SAAS;IACP,QAAQ,MAAM;AACZ,YAAO,YAAY,CAAC,QAAQ,KAAK;;IAEnC,aAAa;AACX,YAAO,YAAY,CAAC,YAAY;;IAEnC;GACF,CAAC;EAWA;EACA;EACA,UAAU;AACR,UAAO,YAAY;;EAEtB"}
|
package/package.json
CHANGED
|
@@ -1,29 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/postgres",
|
|
3
|
-
"version": "0.3.0-dev.
|
|
3
|
+
"version": "0.3.0-dev.44",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "One-liner lazy Postgres client composition for Prisma Next",
|
|
7
7
|
"dependencies": {
|
|
8
|
+
"kysely": "0.28.10",
|
|
8
9
|
"pg": "8.16.3",
|
|
9
|
-
"@prisma-next/core-execution-plane": "0.3.0-dev.
|
|
10
|
-
"@prisma-next/
|
|
11
|
-
"@prisma-next/
|
|
12
|
-
"@prisma-next/sql-contract": "0.3.0-dev.
|
|
13
|
-
"@prisma-next/sql-lane": "0.3.0-dev.
|
|
14
|
-
"@prisma-next/sql-
|
|
15
|
-
"@prisma-next/
|
|
16
|
-
"@prisma-next/
|
|
17
|
-
"@prisma-next/
|
|
10
|
+
"@prisma-next/core-execution-plane": "0.3.0-dev.44",
|
|
11
|
+
"@prisma-next/driver-postgres": "0.3.0-dev.44",
|
|
12
|
+
"@prisma-next/integration-kysely": "0.3.0-dev.44",
|
|
13
|
+
"@prisma-next/sql-contract": "0.3.0-dev.44",
|
|
14
|
+
"@prisma-next/sql-lane": "0.3.0-dev.44",
|
|
15
|
+
"@prisma-next/sql-orm-client": "0.3.0-dev.44",
|
|
16
|
+
"@prisma-next/sql-relational-core": "0.3.0-dev.44",
|
|
17
|
+
"@prisma-next/sql-runtime": "0.3.0-dev.44",
|
|
18
|
+
"@prisma-next/target-postgres": "0.3.0-dev.44",
|
|
19
|
+
"@prisma-next/adapter-postgres": "0.3.0-dev.44"
|
|
18
20
|
},
|
|
19
21
|
"devDependencies": {
|
|
20
22
|
"@types/pg": "8.16.0",
|
|
21
23
|
"tsdown": "0.18.4",
|
|
22
24
|
"typescript": "5.9.3",
|
|
23
25
|
"vitest": "4.0.17",
|
|
26
|
+
"@prisma-next/test-utils": "0.0.1",
|
|
24
27
|
"@prisma-next/tsconfig": "0.0.0",
|
|
25
|
-
"@prisma-next/tsdown": "0.0.0"
|
|
26
|
-
"@prisma-next/test-utils": "0.0.1"
|
|
28
|
+
"@prisma-next/tsdown": "0.0.0"
|
|
27
29
|
},
|
|
28
30
|
"files": [
|
|
29
31
|
"dist",
|
|
@@ -33,20 +35,9 @@
|
|
|
33
35
|
"node": ">=20"
|
|
34
36
|
},
|
|
35
37
|
"exports": {
|
|
36
|
-
"
|
|
37
|
-
"types": "./dist/runtime.d.mts",
|
|
38
|
-
"import": "./dist/runtime.mjs"
|
|
39
|
-
},
|
|
38
|
+
"./runtime": "./dist/runtime.mjs",
|
|
40
39
|
"./package.json": "./package.json"
|
|
41
40
|
},
|
|
42
|
-
"main": "./dist/runtime.mjs",
|
|
43
|
-
"module": "./dist/runtime.mjs",
|
|
44
|
-
"types": "./dist/runtime.d.mts",
|
|
45
|
-
"repository": {
|
|
46
|
-
"type": "git",
|
|
47
|
-
"url": "https://github.com/prisma/prisma-next.git",
|
|
48
|
-
"directory": "packages/3-targets/8-clients/postgres"
|
|
49
|
-
},
|
|
50
41
|
"scripts": {
|
|
51
42
|
"build": "tsdown",
|
|
52
43
|
"test": "vitest run",
|
package/src/exports/runtime.ts
CHANGED
package/src/runtime/binding.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import type { PostgresBinding } from '@prisma-next/driver-postgres/runtime';
|
|
2
1
|
import type { Client, Pool } from 'pg';
|
|
3
2
|
import { Client as PgClient, Pool as PgPool } from 'pg';
|
|
4
3
|
|
|
4
|
+
export type PostgresBinding =
|
|
5
|
+
| { readonly kind: 'url'; readonly url: string }
|
|
6
|
+
| { readonly kind: 'pgPool'; readonly pool: Pool }
|
|
7
|
+
| { readonly kind: 'pgClient'; readonly client: Client };
|
|
8
|
+
|
|
5
9
|
export type PostgresBindingInput =
|
|
6
10
|
| {
|
|
7
11
|
readonly binding: PostgresBinding;
|
|
@@ -19,53 +23,21 @@ export type PostgresBindingInput =
|
|
|
19
23
|
readonly url?: never;
|
|
20
24
|
};
|
|
21
25
|
|
|
22
|
-
interface PostgresBindingError extends Error {
|
|
23
|
-
readonly code: 'DRIVER.BINDING_INVALID';
|
|
24
|
-
readonly category: 'RUNTIME';
|
|
25
|
-
readonly severity: 'error';
|
|
26
|
-
readonly details?: Record<string, unknown>;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function bindingError(message: string, details?: Record<string, unknown>): PostgresBindingError {
|
|
30
|
-
const error = new Error(message) as PostgresBindingError;
|
|
31
|
-
Object.defineProperty(error, 'name', {
|
|
32
|
-
value: 'RuntimeError',
|
|
33
|
-
configurable: true,
|
|
34
|
-
});
|
|
35
|
-
return Object.assign(error, {
|
|
36
|
-
code: 'DRIVER.BINDING_INVALID' as const,
|
|
37
|
-
category: 'RUNTIME' as const,
|
|
38
|
-
severity: 'error' as const,
|
|
39
|
-
message,
|
|
40
|
-
details,
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
|
|
44
26
|
function validatePostgresUrl(url: string): string {
|
|
45
27
|
const trimmed = url.trim();
|
|
46
28
|
if (trimmed.length === 0) {
|
|
47
|
-
throw
|
|
48
|
-
field: 'url',
|
|
49
|
-
reason: 'empty',
|
|
50
|
-
});
|
|
29
|
+
throw new Error('Postgres URL must be a non-empty string');
|
|
51
30
|
}
|
|
52
31
|
|
|
53
32
|
let parsed: URL;
|
|
54
33
|
try {
|
|
55
34
|
parsed = new URL(trimmed);
|
|
56
35
|
} catch {
|
|
57
|
-
throw
|
|
58
|
-
field: 'url',
|
|
59
|
-
reason: 'invalid-url',
|
|
60
|
-
});
|
|
36
|
+
throw new Error('Postgres URL must be a valid URL');
|
|
61
37
|
}
|
|
62
38
|
|
|
63
39
|
if (parsed.protocol !== 'postgres:' && parsed.protocol !== 'postgresql:') {
|
|
64
|
-
throw
|
|
65
|
-
field: 'url',
|
|
66
|
-
reason: 'invalid-protocol',
|
|
67
|
-
protocol: parsed.protocol,
|
|
68
|
-
});
|
|
40
|
+
throw new Error('Postgres URL must use postgres:// or postgresql://');
|
|
69
41
|
}
|
|
70
42
|
|
|
71
43
|
return trimmed;
|
|
@@ -78,9 +50,7 @@ export function resolvePostgresBinding(options: PostgresBindingInput): PostgresB
|
|
|
78
50
|
Number(options.pg !== undefined);
|
|
79
51
|
|
|
80
52
|
if (providedCount !== 1) {
|
|
81
|
-
throw
|
|
82
|
-
providedCount,
|
|
83
|
-
});
|
|
53
|
+
throw new Error('Provide one binding input: binding, url, or pg');
|
|
84
54
|
}
|
|
85
55
|
|
|
86
56
|
if (options.binding !== undefined) {
|
|
@@ -93,9 +63,7 @@ export function resolvePostgresBinding(options: PostgresBindingInput): PostgresB
|
|
|
93
63
|
|
|
94
64
|
const pgBinding = options.pg;
|
|
95
65
|
if (pgBinding === undefined) {
|
|
96
|
-
throw
|
|
97
|
-
reason: 'missing-pg-binding',
|
|
98
|
-
});
|
|
66
|
+
throw new Error('Invariant violation: expected pg binding after validation');
|
|
99
67
|
}
|
|
100
68
|
|
|
101
69
|
if (pgBinding instanceof PgPool) {
|
|
@@ -106,10 +74,7 @@ export function resolvePostgresBinding(options: PostgresBindingInput): PostgresB
|
|
|
106
74
|
return { kind: 'pgClient', client: pgBinding };
|
|
107
75
|
}
|
|
108
76
|
|
|
109
|
-
throw
|
|
77
|
+
throw new Error(
|
|
110
78
|
'Unable to determine pg binding type from pg input; use binding with explicit kind',
|
|
111
|
-
{
|
|
112
|
-
reason: 'unknown-pg-instance',
|
|
113
|
-
},
|
|
114
79
|
);
|
|
115
80
|
}
|
package/src/runtime/postgres.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import postgresAdapter from '@prisma-next/adapter-postgres/runtime';
|
|
2
2
|
import { instantiateExecutionStack } from '@prisma-next/core-execution-plane/stack';
|
|
3
|
-
import type { PostgresDriverCreateOptions } from '@prisma-next/driver-postgres/runtime';
|
|
4
3
|
import postgresDriver from '@prisma-next/driver-postgres/runtime';
|
|
4
|
+
import { type KyselifyContract, KyselyPrismaDialect } from '@prisma-next/integration-kysely';
|
|
5
5
|
import type {
|
|
6
6
|
ExtractCodecTypes,
|
|
7
7
|
ExtractOperationTypes,
|
|
@@ -11,6 +11,7 @@ import type {
|
|
|
11
11
|
import { validateContract } from '@prisma-next/sql-contract/validate';
|
|
12
12
|
import type { SelectBuilder } from '@prisma-next/sql-lane';
|
|
13
13
|
import { sql as sqlBuilder } from '@prisma-next/sql-lane';
|
|
14
|
+
import { orm as ormBuilder } from '@prisma-next/sql-orm-client';
|
|
14
15
|
import type { SchemaHandle } from '@prisma-next/sql-relational-core/schema';
|
|
15
16
|
import { schema as schemaBuilder } from '@prisma-next/sql-relational-core/schema';
|
|
16
17
|
import type {
|
|
@@ -31,7 +32,8 @@ import {
|
|
|
31
32
|
createSqlExecutionStack,
|
|
32
33
|
} from '@prisma-next/sql-runtime';
|
|
33
34
|
import postgresTarget from '@prisma-next/target-postgres/runtime';
|
|
34
|
-
import {
|
|
35
|
+
import { Kysely } from 'kysely';
|
|
36
|
+
import { Pool } from 'pg';
|
|
35
37
|
import { type PostgresBindingInput, resolvePostgresBinding } from './binding';
|
|
36
38
|
|
|
37
39
|
type NormalizeOperationTypes<T> = {
|
|
@@ -45,6 +47,9 @@ type NormalizeOperationTypes<T> = {
|
|
|
45
47
|
type ToSchemaOperationTypes<T> = T extends OperationTypes ? T : NormalizeOperationTypes<T>;
|
|
46
48
|
|
|
47
49
|
export type PostgresTargetId = 'postgres';
|
|
50
|
+
type OrmClient<TContract extends SqlContract<SqlStorage>> = ReturnType<
|
|
51
|
+
typeof ormBuilder<TContract>
|
|
52
|
+
>;
|
|
48
53
|
|
|
49
54
|
export interface PostgresClient<TContract extends SqlContract<SqlStorage>> {
|
|
50
55
|
readonly sql: SelectBuilder<
|
|
@@ -53,21 +58,26 @@ export interface PostgresClient<TContract extends SqlContract<SqlStorage>> {
|
|
|
53
58
|
ExtractCodecTypes<TContract>,
|
|
54
59
|
ExtractOperationTypes<TContract>
|
|
55
60
|
>;
|
|
61
|
+
kysely(runtime: Runtime): Kysely<KyselifyContract<TContract>>;
|
|
56
62
|
readonly schema: SchemaHandle<
|
|
57
63
|
TContract,
|
|
58
64
|
ExtractCodecTypes<TContract>,
|
|
59
65
|
ToSchemaOperationTypes<ExtractOperationTypes<TContract>>
|
|
60
66
|
>;
|
|
67
|
+
readonly orm: OrmClient<TContract>;
|
|
61
68
|
readonly context: ExecutionContext<TContract>;
|
|
62
69
|
readonly stack: SqlExecutionStackWithDriver<PostgresTargetId>;
|
|
63
|
-
runtime():
|
|
70
|
+
runtime(): Runtime;
|
|
64
71
|
}
|
|
65
72
|
|
|
66
73
|
export interface PostgresOptionsBase<TContract extends SqlContract<SqlStorage>> {
|
|
67
74
|
readonly extensions?: readonly SqlRuntimeExtensionDescriptor<PostgresTargetId>[];
|
|
68
75
|
readonly plugins?: readonly Plugin<TContract>[];
|
|
69
76
|
readonly verify?: RuntimeVerifyOptions;
|
|
70
|
-
readonly
|
|
77
|
+
readonly poolOptions?: {
|
|
78
|
+
readonly connectionTimeoutMillis?: number;
|
|
79
|
+
readonly idleTimeoutMillis?: number;
|
|
80
|
+
};
|
|
71
81
|
}
|
|
72
82
|
|
|
73
83
|
export type PostgresOptionsWithContract<TContract extends SqlContract<SqlStorage>> =
|
|
@@ -119,15 +129,7 @@ export default function postgres<TContract extends SqlContract<SqlStorage>>(
|
|
|
119
129
|
const stack = createSqlExecutionStack({
|
|
120
130
|
target: postgresTarget,
|
|
121
131
|
adapter: postgresAdapter,
|
|
122
|
-
driver:
|
|
123
|
-
options.cursor === undefined
|
|
124
|
-
? postgresDriver
|
|
125
|
-
: {
|
|
126
|
-
...postgresDriver,
|
|
127
|
-
create() {
|
|
128
|
-
return postgresDriver.create({ cursor: options.cursor });
|
|
129
|
-
},
|
|
130
|
-
},
|
|
132
|
+
driver: postgresDriver,
|
|
131
133
|
extensionPacks: options.extensions ?? [],
|
|
132
134
|
});
|
|
133
135
|
|
|
@@ -138,49 +140,71 @@ export default function postgres<TContract extends SqlContract<SqlStorage>>(
|
|
|
138
140
|
|
|
139
141
|
const schema: PostgresClient<TContract>['schema'] = schemaBuilder(context);
|
|
140
142
|
const sql = sqlBuilder({ context });
|
|
141
|
-
|
|
142
|
-
|
|
143
|
+
let runtimeInstance: Runtime | undefined;
|
|
144
|
+
const getRuntime = (): Runtime => {
|
|
145
|
+
if (runtimeInstance) {
|
|
146
|
+
return runtimeInstance;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const stackInstance = instantiateExecutionStack(stack);
|
|
150
|
+
const driverDescriptor = stack.driver;
|
|
151
|
+
if (!driverDescriptor) {
|
|
152
|
+
throw new Error('Driver descriptor missing from execution stack');
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const connect =
|
|
156
|
+
binding.kind === 'url'
|
|
157
|
+
? {
|
|
158
|
+
pool: new Pool({
|
|
159
|
+
connectionString: binding.url,
|
|
160
|
+
connectionTimeoutMillis: options.poolOptions?.connectionTimeoutMillis ?? 20_000,
|
|
161
|
+
idleTimeoutMillis: options.poolOptions?.idleTimeoutMillis ?? 30_000,
|
|
162
|
+
}),
|
|
163
|
+
}
|
|
164
|
+
: binding.kind === 'pgPool'
|
|
165
|
+
? { pool: binding.pool }
|
|
166
|
+
: { client: binding.client };
|
|
167
|
+
|
|
168
|
+
const driver = driverDescriptor.create({
|
|
169
|
+
connect,
|
|
170
|
+
cursor: { disabled: true },
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
runtimeInstance = createRuntime({
|
|
174
|
+
stackInstance,
|
|
175
|
+
context,
|
|
176
|
+
driver,
|
|
177
|
+
verify: options.verify ?? { mode: 'onFirstUse', requireMarker: false },
|
|
178
|
+
...(options.plugins ? { plugins: options.plugins } : {}),
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
return runtimeInstance;
|
|
182
|
+
};
|
|
183
|
+
const orm: OrmClient<TContract> = ormBuilder({
|
|
184
|
+
contract,
|
|
185
|
+
runtime: {
|
|
186
|
+
execute(plan) {
|
|
187
|
+
return getRuntime().execute(plan);
|
|
188
|
+
},
|
|
189
|
+
connection() {
|
|
190
|
+
return getRuntime().connection();
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
});
|
|
143
194
|
|
|
144
195
|
return {
|
|
145
196
|
sql,
|
|
197
|
+
kysely(runtime: Runtime) {
|
|
198
|
+
return new Kysely<KyselifyContract<TContract>>({
|
|
199
|
+
dialect: new KyselyPrismaDialect({ runtime, contract }),
|
|
200
|
+
});
|
|
201
|
+
},
|
|
146
202
|
schema,
|
|
203
|
+
orm,
|
|
147
204
|
context,
|
|
148
205
|
stack,
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
return runtimePromise;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
runtimePromise = (async () => {
|
|
155
|
-
const stackInstance = instantiateExecutionStack(stack);
|
|
156
|
-
const driver = stackInstance.driver;
|
|
157
|
-
if (driver === undefined) {
|
|
158
|
-
throw new Error('Relational runtime requires a driver descriptor on the execution stack');
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
try {
|
|
162
|
-
// `binding` is normalized by resolvePostgresBinding(), so this call site remains
|
|
163
|
-
// type-safe in practice while SqlRuntimeDriverInstance currently uses SqlDriver<unknown>.
|
|
164
|
-
await driver.connect(binding);
|
|
165
|
-
|
|
166
|
-
return createRuntime({
|
|
167
|
-
stackInstance,
|
|
168
|
-
context,
|
|
169
|
-
driver,
|
|
170
|
-
verify: options.verify ?? { mode: 'onFirstUse', requireMarker: false },
|
|
171
|
-
...ifDefined('plugins', options.plugins),
|
|
172
|
-
});
|
|
173
|
-
} catch (error) {
|
|
174
|
-
await driver.close().catch(() => undefined);
|
|
175
|
-
throw error;
|
|
176
|
-
}
|
|
177
|
-
})();
|
|
178
|
-
|
|
179
|
-
runtimePromise.catch(() => {
|
|
180
|
-
runtimePromise = undefined;
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
return runtimePromise;
|
|
206
|
+
runtime() {
|
|
207
|
+
return getRuntime();
|
|
184
208
|
},
|
|
185
209
|
};
|
|
186
210
|
}
|