@prisma-next/adapter-postgres 0.3.0-dev.4 → 0.3.0-dev.6

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.
Files changed (47) hide show
  1. package/dist/{exports/chunk-B5SU5BVC.js → chunk-HD5YISNQ.js} +1 -1
  2. package/dist/chunk-HD5YISNQ.js.map +1 -0
  3. package/dist/{exports/chunk-CPAKRHXM.js → chunk-J3XSOAM2.js} +1 -1
  4. package/dist/chunk-J3XSOAM2.js.map +1 -0
  5. package/dist/{exports/chunk-ZHJOVBWT.js → chunk-T6S3A6VT.js} +2 -2
  6. package/dist/chunk-T6S3A6VT.js.map +1 -0
  7. package/dist/core/adapter.d.ts +19 -0
  8. package/dist/core/adapter.d.ts.map +1 -0
  9. package/dist/core/codecs.d.ts +110 -0
  10. package/dist/core/codecs.d.ts.map +1 -0
  11. package/dist/core/control-adapter.d.ts +33 -0
  12. package/dist/core/control-adapter.d.ts.map +1 -0
  13. package/dist/core/descriptor-meta.d.ts +72 -0
  14. package/dist/core/descriptor-meta.d.ts.map +1 -0
  15. package/dist/core/types.d.ts +16 -0
  16. package/dist/core/types.d.ts.map +1 -0
  17. package/dist/exports/adapter.d.ts +2 -21
  18. package/dist/exports/adapter.d.ts.map +1 -0
  19. package/dist/exports/adapter.js +2 -2
  20. package/dist/exports/codec-types.d.ts +7 -34
  21. package/dist/exports/codec-types.d.ts.map +1 -0
  22. package/dist/exports/codec-types.js +1 -1
  23. package/dist/exports/column-types.d.ts +11 -14
  24. package/dist/exports/column-types.d.ts.map +1 -0
  25. package/dist/exports/control.d.ts +4 -5
  26. package/dist/exports/control.d.ts.map +1 -0
  27. package/dist/exports/control.js +1 -1
  28. package/dist/exports/runtime.d.ts +6 -8
  29. package/dist/exports/runtime.d.ts.map +1 -0
  30. package/dist/exports/runtime.js +3 -3
  31. package/dist/exports/types.d.ts +2 -19
  32. package/dist/exports/types.d.ts.map +1 -0
  33. package/package.json +15 -14
  34. package/src/core/adapter.ts +429 -0
  35. package/src/core/codecs.ts +194 -0
  36. package/src/core/control-adapter.ts +375 -0
  37. package/src/core/descriptor-meta.ts +41 -0
  38. package/src/core/types.ts +53 -0
  39. package/src/exports/adapter.ts +1 -0
  40. package/src/exports/codec-types.ts +11 -0
  41. package/src/exports/column-types.ts +53 -0
  42. package/src/exports/control.ts +20 -0
  43. package/src/exports/runtime.ts +32 -0
  44. package/src/exports/types.ts +14 -0
  45. package/dist/exports/chunk-B5SU5BVC.js.map +0 -1
  46. package/dist/exports/chunk-CPAKRHXM.js.map +0 -1
  47. package/dist/exports/chunk-ZHJOVBWT.js.map +0 -1
@@ -44,4 +44,4 @@ var postgresAdapterDescriptorMeta = {
44
44
  export {
45
45
  postgresAdapterDescriptorMeta
46
46
  };
47
- //# sourceMappingURL=chunk-B5SU5BVC.js.map
47
+ //# sourceMappingURL=chunk-HD5YISNQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/descriptor-meta.ts"],"sourcesContent":["export const postgresAdapterDescriptorMeta = {\n kind: 'adapter',\n familyId: 'sql',\n targetId: 'postgres',\n id: 'postgres',\n version: '0.0.1',\n capabilities: {\n postgres: {\n orderBy: true,\n limit: true,\n lateral: true,\n jsonAgg: true,\n returning: true,\n },\n },\n types: {\n codecTypes: {\n import: {\n package: '@prisma-next/adapter-postgres/codec-types',\n named: 'CodecTypes',\n alias: 'PgTypes',\n },\n },\n storage: [\n { typeId: 'pg/text@1', familyId: 'sql', targetId: 'postgres', nativeType: 'text' },\n { typeId: 'pg/int4@1', familyId: 'sql', targetId: 'postgres', nativeType: 'int4' },\n { typeId: 'pg/int2@1', familyId: 'sql', targetId: 'postgres', nativeType: 'int2' },\n { typeId: 'pg/int8@1', familyId: 'sql', targetId: 'postgres', nativeType: 'int8' },\n { typeId: 'pg/float4@1', familyId: 'sql', targetId: 'postgres', nativeType: 'float4' },\n { typeId: 'pg/float8@1', familyId: 'sql', targetId: 'postgres', nativeType: 'float8' },\n { typeId: 'pg/timestamp@1', familyId: 'sql', targetId: 'postgres', nativeType: 'timestamp' },\n {\n typeId: 'pg/timestamptz@1',\n familyId: 'sql',\n targetId: 'postgres',\n nativeType: 'timestamptz',\n },\n { typeId: 'pg/bool@1', familyId: 'sql', targetId: 'postgres', nativeType: 'bool' },\n ],\n },\n} as const;\n"],"mappings":";AAAO,IAAM,gCAAgC;AAAA,EAC3C,MAAM;AAAA,EACN,UAAU;AAAA,EACV,UAAU;AAAA,EACV,IAAI;AAAA,EACJ,SAAS;AAAA,EACT,cAAc;AAAA,IACZ,UAAU;AAAA,MACR,SAAS;AAAA,MACT,OAAO;AAAA,MACP,SAAS;AAAA,MACT,SAAS;AAAA,MACT,WAAW;AAAA,IACb;AAAA,EACF;AAAA,EACA,OAAO;AAAA,IACL,YAAY;AAAA,MACV,QAAQ;AAAA,QACN,SAAS;AAAA,QACT,OAAO;AAAA,QACP,OAAO;AAAA,MACT;AAAA,IACF;AAAA,IACA,SAAS;AAAA,MACP,EAAE,QAAQ,aAAa,UAAU,OAAO,UAAU,YAAY,YAAY,OAAO;AAAA,MACjF,EAAE,QAAQ,aAAa,UAAU,OAAO,UAAU,YAAY,YAAY,OAAO;AAAA,MACjF,EAAE,QAAQ,aAAa,UAAU,OAAO,UAAU,YAAY,YAAY,OAAO;AAAA,MACjF,EAAE,QAAQ,aAAa,UAAU,OAAO,UAAU,YAAY,YAAY,OAAO;AAAA,MACjF,EAAE,QAAQ,eAAe,UAAU,OAAO,UAAU,YAAY,YAAY,SAAS;AAAA,MACrF,EAAE,QAAQ,eAAe,UAAU,OAAO,UAAU,YAAY,YAAY,SAAS;AAAA,MACrF,EAAE,QAAQ,kBAAkB,UAAU,OAAO,UAAU,YAAY,YAAY,YAAY;AAAA,MAC3F;AAAA,QACE,QAAQ;AAAA,QACR,UAAU;AAAA,QACV,UAAU;AAAA,QACV,YAAY;AAAA,MACd;AAAA,MACA,EAAE,QAAQ,aAAa,UAAU,OAAO,UAAU,YAAY,YAAY,OAAO;AAAA,IACnF;AAAA,EACF;AACF;","names":[]}
@@ -159,4 +159,4 @@ export {
159
159
  codecDefinitions,
160
160
  dataTypes
161
161
  };
162
- //# sourceMappingURL=chunk-CPAKRHXM.js.map
162
+ //# sourceMappingURL=chunk-J3XSOAM2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/codecs.ts"],"sourcesContent":["/**\n * Unified codec definitions for Postgres adapter.\n *\n * This file contains a single source of truth for all codec information:\n * - Scalar names\n * - Type IDs\n * - Codec implementations (runtime)\n * - Type information (compile-time)\n *\n * This structure is used both at runtime (to populate the registry) and\n * at compile time (to derive CodecTypes).\n */\n\nimport { codec, defineCodecs } from '@prisma-next/sql-relational-core/ast';\n\n// Create individual codec instances\nconst pgTextCodec = codec({\n typeId: 'pg/text@1',\n targetTypes: ['text'],\n encode: (value: string): string => value,\n decode: (wire: string): string => wire,\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'text',\n },\n },\n },\n },\n});\n\nconst pgInt4Codec = codec<'pg/int4@1', number, number>({\n typeId: 'pg/int4@1',\n targetTypes: ['int4'],\n encode: (value) => value,\n decode: (wire) => wire,\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'integer',\n },\n },\n },\n },\n});\n\nconst pgInt2Codec = codec<'pg/int2@1', number, number>({\n typeId: 'pg/int2@1',\n targetTypes: ['int2'],\n encode: (value) => value,\n decode: (wire) => wire,\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'smallint',\n },\n },\n },\n },\n});\n\nconst pgInt8Codec = codec<'pg/int8@1', number, number>({\n typeId: 'pg/int8@1',\n targetTypes: ['int8'],\n encode: (value) => value,\n decode: (wire) => wire,\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'bigint',\n },\n },\n },\n },\n});\n\nconst pgFloat4Codec = codec<'pg/float4@1', number, number>({\n typeId: 'pg/float4@1',\n targetTypes: ['float4'],\n encode: (value) => value,\n decode: (wire) => wire,\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'real',\n },\n },\n },\n },\n});\n\nconst pgFloat8Codec = codec<'pg/float8@1', number, number>({\n typeId: 'pg/float8@1',\n targetTypes: ['float8'],\n encode: (value) => value,\n decode: (wire) => wire,\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'double precision',\n },\n },\n },\n },\n});\n\nconst pgTimestampCodec = codec<'pg/timestamp@1', string | Date, string>({\n typeId: 'pg/timestamp@1',\n targetTypes: ['timestamp'],\n encode: (value: string | Date): string => {\n if (value instanceof Date) return value.toISOString();\n if (typeof value === 'string') return value;\n return String(value);\n },\n decode: (wire: string | Date): string => {\n if (typeof wire === 'string') return wire;\n if (wire instanceof Date) return wire.toISOString();\n return String(wire);\n },\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'timestamp without time zone',\n },\n },\n },\n },\n});\n\nconst pgTimestamptzCodec = codec<'pg/timestamptz@1', string | Date, string>({\n typeId: 'pg/timestamptz@1',\n targetTypes: ['timestamptz'],\n encode: (value: string | Date): string => {\n if (value instanceof Date) return value.toISOString();\n if (typeof value === 'string') return value;\n return String(value);\n },\n decode: (wire: string | Date): string => {\n if (typeof wire === 'string') return wire;\n if (wire instanceof Date) return wire.toISOString();\n return String(wire);\n },\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'timestamp with time zone',\n },\n },\n },\n },\n});\n\nconst pgBoolCodec = codec<'pg/bool@1', boolean, boolean>({\n typeId: 'pg/bool@1',\n targetTypes: ['bool'],\n encode: (value) => value,\n decode: (wire) => wire,\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'boolean',\n },\n },\n },\n },\n});\n\n// Build codec definitions using the builder DSL\nconst codecs = defineCodecs()\n .add('text', pgTextCodec)\n .add('int4', pgInt4Codec)\n .add('int2', pgInt2Codec)\n .add('int8', pgInt8Codec)\n .add('float4', pgFloat4Codec)\n .add('float8', pgFloat8Codec)\n .add('timestamp', pgTimestampCodec)\n .add('timestamptz', pgTimestamptzCodec)\n .add('bool', pgBoolCodec);\n\n// Export derived structures directly from codecs builder\nexport const codecDefinitions = codecs.codecDefinitions;\nexport const dataTypes = codecs.dataTypes;\n\n// Export types derived from codecs builder\nexport type CodecTypes = typeof codecs.CodecTypes;\n"],"mappings":";AAaA,SAAS,OAAO,oBAAoB;AAGpC,IAAM,cAAc,MAAM;AAAA,EACxB,QAAQ;AAAA,EACR,aAAa,CAAC,MAAM;AAAA,EACpB,QAAQ,CAAC,UAA0B;AAAA,EACnC,QAAQ,CAAC,SAAyB;AAAA,EAClC,MAAM;AAAA,IACJ,IAAI;AAAA,MACF,KAAK;AAAA,QACH,UAAU;AAAA,UACR,YAAY;AAAA,QACd;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF,CAAC;AAED,IAAM,cAAc,MAAmC;AAAA,EACrD,QAAQ;AAAA,EACR,aAAa,CAAC,MAAM;AAAA,EACpB,QAAQ,CAAC,UAAU;AAAA,EACnB,QAAQ,CAAC,SAAS;AAAA,EAClB,MAAM;AAAA,IACJ,IAAI;AAAA,MACF,KAAK;AAAA,QACH,UAAU;AAAA,UACR,YAAY;AAAA,QACd;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF,CAAC;AAED,IAAM,cAAc,MAAmC;AAAA,EACrD,QAAQ;AAAA,EACR,aAAa,CAAC,MAAM;AAAA,EACpB,QAAQ,CAAC,UAAU;AAAA,EACnB,QAAQ,CAAC,SAAS;AAAA,EAClB,MAAM;AAAA,IACJ,IAAI;AAAA,MACF,KAAK;AAAA,QACH,UAAU;AAAA,UACR,YAAY;AAAA,QACd;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF,CAAC;AAED,IAAM,cAAc,MAAmC;AAAA,EACrD,QAAQ;AAAA,EACR,aAAa,CAAC,MAAM;AAAA,EACpB,QAAQ,CAAC,UAAU;AAAA,EACnB,QAAQ,CAAC,SAAS;AAAA,EAClB,MAAM;AAAA,IACJ,IAAI;AAAA,MACF,KAAK;AAAA,QACH,UAAU;AAAA,UACR,YAAY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C;AACxC,QAAI,iBAAiB,KAAM,QAAO,MAAM,YAAY;AACpD,QAAI,OAAO,UAAU,SAAU,QAAO;AACtC,WAAO,OAAO,KAAK;AAAA,EACrB;AAAA,EACA,QAAQ,CAAC,SAAgC;AACvC,QAAI,OAAO,SAAS,SAAU,QAAO;AACrC,QAAI,gBAAgB,KAAM,QAAO,KAAK,YAAY;AAClD,WAAO,OAAO,IAAI;AAAA,EACpB;AAAA,EACA,MAAM;AAAA,IACJ,IAAI;AAAA,MACF,KAAK;AAAA,QACH,UAAU;AAAA,UACR,YAAY;AAAA,QACd;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF,CAAC;AAED,IAAM,cAAc,MAAqC;AAAA,EACvD,QAAQ;AAAA,EACR,aAAa,CAAC,MAAM;AAAA,EACpB,QAAQ,CAAC,UAAU;AAAA,EACnB,QAAQ,CAAC,SAAS;AAAA,EAClB,MAAM;AAAA,IACJ,IAAI;AAAA,MACF,KAAK;AAAA,QACH,UAAU;AAAA,UACR,YAAY;AAAA,QACd;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF,CAAC;AAGD,IAAM,SAAS,aAAa,EACzB,IAAI,QAAQ,WAAW,EACvB,IAAI,QAAQ,WAAW,EACvB,IAAI,QAAQ,WAAW,EACvB,IAAI,QAAQ,WAAW,EACvB,IAAI,UAAU,aAAa,EAC3B,IAAI,UAAU,aAAa,EAC3B,IAAI,aAAa,gBAAgB,EACjC,IAAI,eAAe,kBAAkB,EACrC,IAAI,QAAQ,WAAW;AAGnB,IAAM,mBAAmB,OAAO;AAChC,IAAM,YAAY,OAAO;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  codecDefinitions
3
- } from "./chunk-CPAKRHXM.js";
3
+ } from "./chunk-J3XSOAM2.js";
4
4
 
5
5
  // src/core/adapter.ts
6
6
  import { createCodecRegistry, isOperationExpr } from "@prisma-next/sql-relational-core/ast";
@@ -298,4 +298,4 @@ function createPostgresAdapter(options) {
298
298
  export {
299
299
  createPostgresAdapter
300
300
  };
301
- //# sourceMappingURL=chunk-ZHJOVBWT.js.map
301
+ //# sourceMappingURL=chunk-T6S3A6VT.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/adapter.ts"],"sourcesContent":["import type {\n Adapter,\n AdapterProfile,\n BinaryExpr,\n ColumnRef,\n DeleteAst,\n ExistsExpr,\n IncludeRef,\n InsertAst,\n JoinAst,\n LiteralExpr,\n LowererContext,\n OperationExpr,\n ParamRef,\n QueryAst,\n SelectAst,\n UpdateAst,\n} from '@prisma-next/sql-relational-core/ast';\nimport { createCodecRegistry, isOperationExpr } from '@prisma-next/sql-relational-core/ast';\nimport { codecDefinitions } from './codecs';\nimport type { PostgresAdapterOptions, PostgresContract, PostgresLoweredStatement } from './types';\n\nconst VECTOR_CODEC_ID = 'pg/vector@1' as const;\n\nconst defaultCapabilities = Object.freeze({\n postgres: {\n orderBy: true,\n limit: true,\n lateral: true,\n jsonAgg: true,\n returning: true,\n },\n});\n\nclass PostgresAdapterImpl implements Adapter<QueryAst, PostgresContract, PostgresLoweredStatement> {\n // These fields make the adapter instance structurally compatible with\n // RuntimeAdapterInstance<'sql', 'postgres'> without introducing a runtime-plane dependency.\n readonly familyId = 'sql' as const;\n readonly targetId = 'postgres' as const;\n\n readonly profile: AdapterProfile<'postgres'>;\n private readonly codecRegistry = (() => {\n const registry = createCodecRegistry();\n for (const definition of Object.values(codecDefinitions)) {\n registry.register(definition.codec);\n }\n return registry;\n })();\n\n constructor(options?: PostgresAdapterOptions) {\n this.profile = Object.freeze({\n id: options?.profileId ?? 'postgres/default@1',\n target: 'postgres',\n capabilities: defaultCapabilities,\n codecs: () => this.codecRegistry,\n });\n }\n\n lower(ast: QueryAst, context: LowererContext<PostgresContract>) {\n let sql: string;\n const params = context.params ? [...context.params] : [];\n\n if (ast.kind === 'select') {\n sql = renderSelect(ast, context.contract);\n } else if (ast.kind === 'insert') {\n sql = renderInsert(ast, context.contract);\n } else if (ast.kind === 'update') {\n sql = renderUpdate(ast, context.contract);\n } else if (ast.kind === 'delete') {\n sql = renderDelete(ast, context.contract);\n } else {\n throw new Error(`Unsupported AST kind: ${(ast as { kind: string }).kind}`);\n }\n\n return Object.freeze({\n profileId: this.profile.id,\n body: Object.freeze({ sql, params }),\n });\n }\n}\n\nfunction renderSelect(ast: SelectAst, contract?: PostgresContract): string {\n const selectClause = `SELECT ${renderProjection(ast, contract)}`;\n const fromClause = `FROM ${quoteIdentifier(ast.from.name)}`;\n\n const joinsClause = ast.joins?.length\n ? ast.joins.map((join) => renderJoin(join, contract)).join(' ')\n : '';\n const includesClause = ast.includes?.length\n ? ast.includes.map((include) => renderInclude(include, contract)).join(' ')\n : '';\n\n const whereClause = ast.where ? ` WHERE ${renderWhere(ast.where, contract)}` : '';\n const orderClause = ast.orderBy?.length\n ? ` ORDER BY ${ast.orderBy\n .map((order) => {\n const expr = renderExpr(order.expr as ColumnRef | OperationExpr, contract);\n return `${expr} ${order.dir.toUpperCase()}`;\n })\n .join(', ')}`\n : '';\n const limitClause = typeof ast.limit === 'number' ? ` LIMIT ${ast.limit}` : '';\n\n const clauses = [joinsClause, includesClause].filter(Boolean).join(' ');\n return `${selectClause} ${fromClause}${clauses ? ` ${clauses}` : ''}${whereClause}${orderClause}${limitClause}`.trim();\n}\n\nfunction renderProjection(ast: SelectAst, contract?: PostgresContract): string {\n return ast.project\n .map((item) => {\n const expr = item.expr as ColumnRef | IncludeRef | OperationExpr | LiteralExpr;\n if (expr.kind === 'includeRef') {\n // For include references, select the column from the LATERAL join alias\n // The LATERAL subquery returns a single column (the JSON array) with the alias\n // The table is aliased as {alias}_lateral, and the column inside is aliased as the include alias\n // We select it using table_alias.column_alias\n const tableAlias = `${expr.alias}_lateral`;\n return `${quoteIdentifier(tableAlias)}.${quoteIdentifier(expr.alias)} AS ${quoteIdentifier(item.alias)}`;\n }\n if (expr.kind === 'operation') {\n const operation = renderOperation(expr, contract);\n const alias = quoteIdentifier(item.alias);\n return `${operation} AS ${alias}`;\n }\n if (expr.kind === 'literal') {\n const literal = renderLiteral(expr);\n const alias = quoteIdentifier(item.alias);\n return `${literal} AS ${alias}`;\n }\n const column = renderColumn(expr as ColumnRef);\n const alias = quoteIdentifier(item.alias);\n return `${column} AS ${alias}`;\n })\n .join(', ');\n}\n\nfunction renderWhere(expr: BinaryExpr | ExistsExpr, contract?: PostgresContract): string {\n if (expr.kind === 'exists') {\n const notKeyword = expr.not ? 'NOT ' : '';\n const subquery = renderSelect(expr.subquery, contract);\n return `${notKeyword}EXISTS (${subquery})`;\n }\n return renderBinary(expr, contract);\n}\n\nfunction renderBinary(expr: BinaryExpr, contract?: PostgresContract): string {\n const leftExpr = expr.left as ColumnRef | OperationExpr;\n const left = renderExpr(leftExpr, contract);\n // Handle both ParamRef and ColumnRef on the right side\n // (ColumnRef can appear in EXISTS subqueries for correlation)\n const rightExpr = expr.right as ParamRef | ColumnRef;\n const right =\n rightExpr.kind === 'col'\n ? renderColumn(rightExpr)\n : renderParam(rightExpr as ParamRef, contract);\n // Only wrap in parentheses if it's an operation expression\n const leftRendered = isOperationExpr(leftExpr) ? `(${left})` : left;\n\n // Map operators to SQL symbols\n const operatorMap: Record<BinaryExpr['op'], string> = {\n eq: '=',\n neq: '!=',\n gt: '>',\n lt: '<',\n gte: '>=',\n lte: '<=',\n };\n\n return `${leftRendered} ${operatorMap[expr.op]} ${right}`;\n}\n\nfunction renderColumn(ref: ColumnRef): string {\n return `${quoteIdentifier(ref.table)}.${quoteIdentifier(ref.column)}`;\n}\n\nfunction renderExpr(expr: ColumnRef | OperationExpr, contract?: PostgresContract): string {\n if (isOperationExpr(expr)) {\n return renderOperation(expr, contract);\n }\n return renderColumn(expr);\n}\n\nfunction renderParam(\n ref: ParamRef,\n contract?: PostgresContract,\n tableName?: string,\n columnName?: string,\n): string {\n // Cast vector parameters to vector type for PostgreSQL\n if (contract && tableName && columnName) {\n const tableMeta = contract.storage.tables[tableName];\n const columnMeta = tableMeta?.columns[columnName];\n if (columnMeta?.codecId === VECTOR_CODEC_ID) {\n return `$${ref.index}::vector`;\n }\n }\n return `$${ref.index}`;\n}\n\nfunction renderLiteral(expr: LiteralExpr): string {\n if (typeof expr.value === 'string') {\n return `'${expr.value.replace(/'/g, \"''\")}'`;\n }\n if (typeof expr.value === 'number' || typeof expr.value === 'boolean') {\n return String(expr.value);\n }\n if (expr.value === null) {\n return 'NULL';\n }\n if (Array.isArray(expr.value)) {\n return `ARRAY[${expr.value.map((v: unknown) => renderLiteral({ kind: 'literal', value: v })).join(', ')}]`;\n }\n return JSON.stringify(expr.value);\n}\n\nfunction renderOperation(expr: OperationExpr, contract?: PostgresContract): string {\n const self = renderExpr(expr.self, contract);\n // For vector operations, cast param arguments to vector type\n const isVectorOperation = expr.forTypeId === VECTOR_CODEC_ID;\n const args = expr.args.map((arg: ColumnRef | ParamRef | LiteralExpr | OperationExpr) => {\n if (arg.kind === 'col') {\n return renderColumn(arg);\n }\n if (arg.kind === 'param') {\n // Cast vector operation parameters to vector type\n return isVectorOperation ? `$${arg.index}::vector` : renderParam(arg, contract);\n }\n if (arg.kind === 'literal') {\n return renderLiteral(arg);\n }\n if (arg.kind === 'operation') {\n return renderOperation(arg, contract);\n }\n const _exhaustive: never = arg;\n throw new Error(`Unsupported argument kind: ${(_exhaustive as { kind: string }).kind}`);\n });\n\n let result = expr.lowering.template;\n result = result.replace(/\\$\\{self\\}/g, self);\n for (let i = 0; i < args.length; i++) {\n result = result.replace(new RegExp(`\\\\$\\\\{arg${i}\\\\}`, 'g'), args[i] ?? '');\n }\n\n if (expr.lowering.strategy === 'function') {\n return result;\n }\n\n return result;\n}\n\nfunction renderJoin(join: JoinAst, _contract?: PostgresContract): string {\n const joinType = join.joinType.toUpperCase();\n const table = quoteIdentifier(join.table.name);\n const onClause = renderJoinOn(join.on);\n return `${joinType} JOIN ${table} ON ${onClause}`;\n}\n\nfunction renderJoinOn(on: JoinAst['on']): string {\n if (on.kind === 'eqCol') {\n const left = renderColumn(on.left);\n const right = renderColumn(on.right);\n return `${left} = ${right}`;\n }\n throw new Error(`Unsupported join ON expression kind: ${on.kind}`);\n}\n\nfunction renderInclude(\n include: NonNullable<SelectAst['includes']>[number],\n contract?: PostgresContract,\n): string {\n const alias = include.alias;\n\n // Build the lateral subquery\n const childProjection = include.child.project\n .map((item: { alias: string; expr: ColumnRef | OperationExpr }) => {\n const expr = renderExpr(item.expr, contract);\n return `'${item.alias}', ${expr}`;\n })\n .join(', ');\n\n const jsonBuildObject = `json_build_object(${childProjection})`;\n\n // Build the ON condition from the include's ON clause - this goes in the WHERE clause\n const onCondition = renderJoinOn(include.child.on);\n\n // Build WHERE clause: combine ON condition with any additional WHERE clauses\n let whereClause = ` WHERE ${onCondition}`;\n if (include.child.where) {\n whereClause += ` AND ${renderWhere(include.child.where, contract)}`;\n }\n\n // Add ORDER BY if present - it goes inside json_agg() call\n const childOrderBy = include.child.orderBy?.length\n ? ` ORDER BY ${include.child.orderBy\n .map(\n (order: { expr: ColumnRef | OperationExpr; dir: string }) =>\n `${renderExpr(order.expr, contract)} ${order.dir.toUpperCase()}`,\n )\n .join(', ')}`\n : '';\n\n // Add LIMIT if present\n const childLimit = typeof include.child.limit === 'number' ? ` LIMIT ${include.child.limit}` : '';\n\n // Build the lateral subquery\n // When ORDER BY is present without LIMIT, it goes inside json_agg() call: json_agg(expr ORDER BY ...)\n // When LIMIT is present (with or without ORDER BY), we need to wrap in a subquery\n const childTable = quoteIdentifier(include.child.table.name);\n let subquery: string;\n if (typeof include.child.limit === 'number') {\n // With LIMIT, we need to wrap in a subquery\n // Select individual columns in inner query, then aggregate\n // Create a map of column references to their aliases for ORDER BY\n // Only ColumnRef can be mapped (OperationExpr doesn't have table/column properties)\n const columnAliasMap = new Map<string, string>();\n for (const item of include.child.project) {\n if (item.expr.kind === 'col') {\n const columnKey = `${item.expr.table}.${item.expr.column}`;\n columnAliasMap.set(columnKey, item.alias);\n }\n }\n\n const innerColumns = include.child.project\n .map((item: { alias: string; expr: ColumnRef | OperationExpr }) => {\n const expr = renderExpr(item.expr, contract);\n return `${expr} AS ${quoteIdentifier(item.alias)}`;\n })\n .join(', ');\n\n // For ORDER BY, use column aliases if the column is in the SELECT list\n const childOrderByWithAliases = include.child.orderBy?.length\n ? ` ORDER BY ${include.child.orderBy\n .map((order: { expr: ColumnRef | OperationExpr; dir: string }) => {\n if (order.expr.kind === 'col') {\n const columnKey = `${order.expr.table}.${order.expr.column}`;\n const alias = columnAliasMap.get(columnKey);\n if (alias) {\n return `${quoteIdentifier(alias)} ${order.dir.toUpperCase()}`;\n }\n }\n return `${renderExpr(order.expr, contract)} ${order.dir.toUpperCase()}`;\n })\n .join(', ')}`\n : '';\n\n const innerSelect = `SELECT ${innerColumns} FROM ${childTable}${whereClause}${childOrderByWithAliases}${childLimit}`;\n subquery = `(SELECT json_agg(row_to_json(sub.*)) AS ${quoteIdentifier(alias)} FROM (${innerSelect}) sub)`;\n } else if (childOrderBy) {\n // With ORDER BY but no LIMIT, ORDER BY goes inside json_agg()\n subquery = `(SELECT json_agg(${jsonBuildObject}${childOrderBy}) AS ${quoteIdentifier(alias)} FROM ${childTable}${whereClause})`;\n } else {\n // No ORDER BY or LIMIT\n subquery = `(SELECT json_agg(${jsonBuildObject}) AS ${quoteIdentifier(alias)} FROM ${childTable}${whereClause})`;\n }\n\n // Return the LATERAL join with ON true (the condition is in the WHERE clause)\n // The subquery returns a single column (the JSON array) with the alias\n // We use a different alias for the table to avoid ambiguity when selecting the column\n const tableAlias = `${alias}_lateral`;\n return `LEFT JOIN LATERAL ${subquery} AS ${quoteIdentifier(tableAlias)} ON true`;\n}\n\nfunction quoteIdentifier(identifier: string): string {\n return `\"${identifier.replace(/\"/g, '\"\"')}\"`;\n}\n\nfunction renderInsert(ast: InsertAst, contract: PostgresContract): string {\n const table = quoteIdentifier(ast.table.name);\n const columns = Object.keys(ast.values).map((col) => quoteIdentifier(col));\n const tableMeta = contract.storage.tables[ast.table.name];\n const values = Object.entries(ast.values).map(([colName, val]) => {\n if (val.kind === 'param') {\n const columnMeta = tableMeta?.columns[colName];\n const isVector = columnMeta?.codecId === VECTOR_CODEC_ID;\n return isVector ? `$${val.index}::vector` : `$${val.index}`;\n }\n if (val.kind === 'col') {\n return `${quoteIdentifier(val.table)}.${quoteIdentifier(val.column)}`;\n }\n throw new Error(`Unsupported value kind in INSERT: ${(val as { kind: string }).kind}`);\n });\n\n const insertClause = `INSERT INTO ${table} (${columns.join(', ')}) VALUES (${values.join(', ')})`;\n const returningClause = ast.returning?.length\n ? ` RETURNING ${ast.returning.map((col) => `${quoteIdentifier(col.table)}.${quoteIdentifier(col.column)}`).join(', ')}`\n : '';\n\n return `${insertClause}${returningClause}`;\n}\n\nfunction renderUpdate(ast: UpdateAst, contract: PostgresContract): string {\n const table = quoteIdentifier(ast.table.name);\n const tableMeta = contract.storage.tables[ast.table.name];\n const setClauses = Object.entries(ast.set).map(([col, val]) => {\n const column = quoteIdentifier(col);\n let value: string;\n if (val.kind === 'param') {\n const columnMeta = tableMeta?.columns[col];\n const isVector = columnMeta?.codecId === VECTOR_CODEC_ID;\n value = isVector ? `$${val.index}::vector` : `$${val.index}`;\n } else if (val.kind === 'col') {\n value = `${quoteIdentifier(val.table)}.${quoteIdentifier(val.column)}`;\n } else {\n throw new Error(`Unsupported value kind in UPDATE: ${(val as { kind: string }).kind}`);\n }\n return `${column} = ${value}`;\n });\n\n const whereClause = ` WHERE ${renderBinary(ast.where, contract)}`;\n const returningClause = ast.returning?.length\n ? ` RETURNING ${ast.returning.map((col) => `${quoteIdentifier(col.table)}.${quoteIdentifier(col.column)}`).join(', ')}`\n : '';\n\n return `UPDATE ${table} SET ${setClauses.join(', ')}${whereClause}${returningClause}`;\n}\n\nfunction renderDelete(ast: DeleteAst, contract?: PostgresContract): string {\n const table = quoteIdentifier(ast.table.name);\n const whereClause = ` WHERE ${renderBinary(ast.where, contract)}`;\n const returningClause = ast.returning?.length\n ? ` RETURNING ${ast.returning.map((col) => `${quoteIdentifier(col.table)}.${quoteIdentifier(col.column)}`).join(', ')}`\n : '';\n\n return `DELETE FROM ${table}${whereClause}${returningClause}`;\n}\n\nexport function createPostgresAdapter(options?: PostgresAdapterOptions) {\n return Object.freeze(new PostgresAdapterImpl(options));\n}\n"],"mappings":";;;;;AAkBA,SAAS,qBAAqB,uBAAuB;AAIrD,IAAM,kBAAkB;AAExB,IAAM,sBAAsB,OAAO,OAAO;AAAA,EACxC,UAAU;AAAA,IACR,SAAS;AAAA,IACT,OAAO;AAAA,IACP,SAAS;AAAA,IACT,SAAS;AAAA,IACT,WAAW;AAAA,EACb;AACF,CAAC;AAED,IAAM,sBAAN,MAAmG;AAAA;AAAA;AAAA,EAGxF,WAAW;AAAA,EACX,WAAW;AAAA,EAEX;AAAA,EACQ,iBAAiB,MAAM;AACtC,UAAM,WAAW,oBAAoB;AACrC,eAAW,cAAc,OAAO,OAAO,gBAAgB,GAAG;AACxD,eAAS,SAAS,WAAW,KAAK;AAAA,IACpC;AACA,WAAO;AAAA,EACT,GAAG;AAAA,EAEH,YAAY,SAAkC;AAC5C,SAAK,UAAU,OAAO,OAAO;AAAA,MAC3B,IAAI,SAAS,aAAa;AAAA,MAC1B,QAAQ;AAAA,MACR,cAAc;AAAA,MACd,QAAQ,MAAM,KAAK;AAAA,IACrB,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,KAAe,SAA2C;AAC9D,QAAI;AACJ,UAAM,SAAS,QAAQ,SAAS,CAAC,GAAG,QAAQ,MAAM,IAAI,CAAC;AAEvD,QAAI,IAAI,SAAS,UAAU;AACzB,YAAM,aAAa,KAAK,QAAQ,QAAQ;AAAA,IAC1C,WAAW,IAAI,SAAS,UAAU;AAChC,YAAM,aAAa,KAAK,QAAQ,QAAQ;AAAA,IAC1C,WAAW,IAAI,SAAS,UAAU;AAChC,YAAM,aAAa,KAAK,QAAQ,QAAQ;AAAA,IAC1C,WAAW,IAAI,SAAS,UAAU;AAChC,YAAM,aAAa,KAAK,QAAQ,QAAQ;AAAA,IAC1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AAS,OAAO;AAC7B,cAAQ,GAAG,gBAAgB,IAAI,KAAK,CAAC,IAAI,gBAAgB,IAAI,MAAM,CAAC;AAAA,IACtE,OAAO;AACL,YAAM,IAAI,MAAM,qCAAsC,IAAyB,IAAI,EAAE;AAAA,IACvF;AACA,WAAO,GAAG,MAAM,MAAM,KAAK;AAAA,EAC7B,CAAC;AAED,QAAM,cAAc,UAAU,aAAa,IAAI,OAAO,QAAQ,CAAC;AAC/D,QAAM,kBAAkB,IAAI,WAAW,SACnC,cAAc,IAAI,UAAU,IAAI,CAAC,QAAQ,GAAG,gBAAgB,IAAI,KAAK,CAAC,IAAI,gBAAgB,IAAI,MAAM,CAAC,EAAE,EAAE,KAAK,IAAI,CAAC,KACnH;AAEJ,SAAO,UAAU,KAAK,QAAQ,WAAW,KAAK,IAAI,CAAC,GAAG,WAAW,GAAG,eAAe;AACrF;AAEA,SAAS,aAAa,KAAgB,UAAqC;AACzE,QAAM,QAAQ,gBAAgB,IAAI,MAAM,IAAI;AAC5C,QAAM,cAAc,UAAU,aAAa,IAAI,OAAO,QAAQ,CAAC;AAC/D,QAAM,kBAAkB,IAAI,WAAW,SACnC,cAAc,IAAI,UAAU,IAAI,CAAC,QAAQ,GAAG,gBAAgB,IAAI,KAAK,CAAC,IAAI,gBAAgB,IAAI,MAAM,CAAC,EAAE,EAAE,KAAK,IAAI,CAAC,KACnH;AAEJ,SAAO,eAAe,KAAK,GAAG,WAAW,GAAG,eAAe;AAC7D;AAEO,SAAS,sBAAsB,SAAkC;AACtE,SAAO,OAAO,OAAO,IAAI,oBAAoB,OAAO,CAAC;AACvD;","names":["alias"]}
@@ -0,0 +1,19 @@
1
+ import type { Adapter, AdapterProfile, LowererContext, QueryAst } from '@prisma-next/sql-relational-core/ast';
2
+ import type { PostgresAdapterOptions, PostgresContract, PostgresLoweredStatement } from './types';
3
+ declare class PostgresAdapterImpl implements Adapter<QueryAst, PostgresContract, PostgresLoweredStatement> {
4
+ readonly familyId: "sql";
5
+ readonly targetId: "postgres";
6
+ readonly profile: AdapterProfile<'postgres'>;
7
+ private readonly codecRegistry;
8
+ constructor(options?: PostgresAdapterOptions);
9
+ lower(ast: QueryAst, context: LowererContext<PostgresContract>): Readonly<{
10
+ profileId: string;
11
+ body: Readonly<{
12
+ sql: string;
13
+ params: unknown[];
14
+ }>;
15
+ }>;
16
+ }
17
+ export declare function createPostgresAdapter(options?: PostgresAdapterOptions): Readonly<PostgresAdapterImpl>;
18
+ export {};
19
+ //# sourceMappingURL=adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/core/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,cAAc,EASd,cAAc,EAGd,QAAQ,EAGT,MAAM,sCAAsC,CAAC;AAG9C,OAAO,KAAK,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAclG,cAAM,mBAAoB,YAAW,OAAO,CAAC,QAAQ,EAAE,gBAAgB,EAAE,wBAAwB,CAAC;IAGhG,QAAQ,CAAC,QAAQ,EAAG,KAAK,CAAU;IACnC,QAAQ,CAAC,QAAQ,EAAG,UAAU,CAAU;IAExC,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;IAC7C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAMzB;gBAEO,OAAO,CAAC,EAAE,sBAAsB;IAS5C,KAAK,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,cAAc,CAAC,gBAAgB,CAAC;;;;;;;CAqB/D;AA2VD,wBAAgB,qBAAqB,CAAC,OAAO,CAAC,EAAE,sBAAsB,iCAErE"}
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Unified codec definitions for Postgres adapter.
3
+ *
4
+ * This file contains a single source of truth for all codec information:
5
+ * - Scalar names
6
+ * - Type IDs
7
+ * - Codec implementations (runtime)
8
+ * - Type information (compile-time)
9
+ *
10
+ * This structure is used both at runtime (to populate the registry) and
11
+ * at compile time (to derive CodecTypes).
12
+ */
13
+ declare const codecs: import("@prisma-next/sql-relational-core/ast").CodecDefBuilder<{
14
+ text: import("@prisma-next/sql-relational-core/ast").Codec<"pg/text@1", string, string>;
15
+ int4: import("@prisma-next/sql-relational-core/ast").Codec<"pg/int4@1", number, number>;
16
+ int2: import("@prisma-next/sql-relational-core/ast").Codec<"pg/int2@1", number, number>;
17
+ int8: import("@prisma-next/sql-relational-core/ast").Codec<"pg/int8@1", number, number>;
18
+ float4: import("@prisma-next/sql-relational-core/ast").Codec<"pg/float4@1", number, number>;
19
+ float8: import("@prisma-next/sql-relational-core/ast").Codec<"pg/float8@1", number, number>;
20
+ timestamp: import("@prisma-next/sql-relational-core/ast").Codec<"pg/timestamp@1", string | Date, string>;
21
+ timestamptz: import("@prisma-next/sql-relational-core/ast").Codec<"pg/timestamptz@1", string | Date, string>;
22
+ } & Record<"bool", import("@prisma-next/sql-relational-core/ast").Codec<"pg/bool@1", boolean, boolean>>>;
23
+ export declare const codecDefinitions: {
24
+ readonly text: {
25
+ readonly typeId: "pg/text@1";
26
+ readonly scalar: "text";
27
+ readonly codec: import("@prisma-next/sql-relational-core/ast").Codec<"pg/text@1", string, string>;
28
+ readonly input: string;
29
+ readonly output: string;
30
+ readonly jsType: string;
31
+ };
32
+ readonly int4: {
33
+ readonly typeId: "pg/int4@1";
34
+ readonly scalar: "int4";
35
+ readonly codec: import("@prisma-next/sql-relational-core/ast").Codec<"pg/int4@1", number, number>;
36
+ readonly input: number;
37
+ readonly output: number;
38
+ readonly jsType: number;
39
+ };
40
+ readonly int2: {
41
+ readonly typeId: "pg/int2@1";
42
+ readonly scalar: "int2";
43
+ readonly codec: import("@prisma-next/sql-relational-core/ast").Codec<"pg/int2@1", number, number>;
44
+ readonly input: number;
45
+ readonly output: number;
46
+ readonly jsType: number;
47
+ };
48
+ readonly int8: {
49
+ readonly typeId: "pg/int8@1";
50
+ readonly scalar: "int8";
51
+ readonly codec: import("@prisma-next/sql-relational-core/ast").Codec<"pg/int8@1", number, number>;
52
+ readonly input: number;
53
+ readonly output: number;
54
+ readonly jsType: number;
55
+ };
56
+ readonly float4: {
57
+ readonly typeId: "pg/float4@1";
58
+ readonly scalar: "float4";
59
+ readonly codec: import("@prisma-next/sql-relational-core/ast").Codec<"pg/float4@1", number, number>;
60
+ readonly input: number;
61
+ readonly output: number;
62
+ readonly jsType: number;
63
+ };
64
+ readonly float8: {
65
+ readonly typeId: "pg/float8@1";
66
+ readonly scalar: "float8";
67
+ readonly codec: import("@prisma-next/sql-relational-core/ast").Codec<"pg/float8@1", number, number>;
68
+ readonly input: number;
69
+ readonly output: number;
70
+ readonly jsType: number;
71
+ };
72
+ readonly timestamp: {
73
+ readonly typeId: "pg/timestamp@1";
74
+ readonly scalar: "timestamp";
75
+ readonly codec: import("@prisma-next/sql-relational-core/ast").Codec<"pg/timestamp@1", string | Date, string>;
76
+ readonly input: string;
77
+ readonly output: string;
78
+ readonly jsType: string;
79
+ };
80
+ readonly timestamptz: {
81
+ readonly typeId: "pg/timestamptz@1";
82
+ readonly scalar: "timestamptz";
83
+ readonly codec: import("@prisma-next/sql-relational-core/ast").Codec<"pg/timestamptz@1", string | Date, string>;
84
+ readonly input: string;
85
+ readonly output: string;
86
+ readonly jsType: string;
87
+ };
88
+ readonly bool: {
89
+ readonly typeId: "pg/bool@1";
90
+ readonly scalar: "bool";
91
+ readonly codec: import("@prisma-next/sql-relational-core/ast").Codec<"pg/bool@1", boolean, boolean>;
92
+ readonly input: boolean;
93
+ readonly output: boolean;
94
+ readonly jsType: boolean;
95
+ };
96
+ };
97
+ export declare const dataTypes: {
98
+ readonly text: "pg/text@1";
99
+ readonly int4: "pg/int4@1";
100
+ readonly int2: "pg/int2@1";
101
+ readonly int8: "pg/int8@1";
102
+ readonly float4: "pg/float4@1";
103
+ readonly float8: "pg/float8@1";
104
+ readonly timestamp: "pg/timestamp@1";
105
+ readonly timestamptz: "pg/timestamptz@1";
106
+ readonly bool: "pg/bool@1";
107
+ };
108
+ export type CodecTypes = typeof codecs.CodecTypes;
109
+ export {};
110
+ //# sourceMappingURL=codecs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codecs.d.ts","sourceRoot":"","sources":["../../src/core/codecs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAsKH,QAAA,MAAM,MAAM;;;;;;;;;wGASe,CAAC;AAG5B,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAA0B,CAAC;AACxD,eAAO,MAAM,SAAS;;;;;;;;;;CAAmB,CAAC;AAG1C,MAAM,MAAM,UAAU,GAAG,OAAO,MAAM,CAAC,UAAU,CAAC"}
@@ -0,0 +1,33 @@
1
+ import type { ControlDriverInstance } from '@prisma-next/core-control-plane/types';
2
+ import type { SqlControlAdapter } from '@prisma-next/family-sql/control-adapter';
3
+ import type { SqlSchemaIR } from '@prisma-next/sql-schema-ir/types';
4
+ /**
5
+ * Postgres control plane adapter for control-plane operations like introspection.
6
+ * Provides target-specific implementations for control-plane domain actions.
7
+ */
8
+ export declare class PostgresControlAdapter implements SqlControlAdapter<'postgres'> {
9
+ readonly familyId: "sql";
10
+ readonly targetId: "postgres";
11
+ /**
12
+ * @deprecated Use targetId instead
13
+ */
14
+ readonly target: "postgres";
15
+ /**
16
+ * Introspects a Postgres database schema and returns a raw SqlSchemaIR.
17
+ *
18
+ * This is a pure schema discovery operation that queries the Postgres catalog
19
+ * and returns the schema structure without type mapping or contract enrichment.
20
+ * Type mapping and enrichment are handled separately by enrichment helpers.
21
+ *
22
+ * @param driver - ControlDriverInstance<'sql', 'postgres'> instance for executing queries
23
+ * @param contractIR - Optional contract IR for contract-guided introspection (filtering, optimization)
24
+ * @param schema - Schema name to introspect (defaults to 'public')
25
+ * @returns Promise resolving to SqlSchemaIR representing the live database schema
26
+ */
27
+ introspect(driver: ControlDriverInstance<'sql', 'postgres'>, _contractIR?: unknown, schema?: string): Promise<SqlSchemaIR>;
28
+ /**
29
+ * Gets the Postgres version from the database.
30
+ */
31
+ private getPostgresVersion;
32
+ }
33
+ //# sourceMappingURL=control-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"control-adapter.d.ts","sourceRoot":"","sources":["../../src/core/control-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AACnF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AACjF,OAAO,KAAK,EAKV,WAAW,EAGZ,MAAM,kCAAkC,CAAC;AAE1C;;;GAGG;AACH,qBAAa,sBAAuB,YAAW,iBAAiB,CAAC,UAAU,CAAC;IAC1E,QAAQ,CAAC,QAAQ,EAAG,KAAK,CAAU;IACnC,QAAQ,CAAC,QAAQ,EAAG,UAAU,CAAU;IACxC;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAG,UAAU,CAAU;IAEtC;;;;;;;;;;;OAWG;IACG,UAAU,CACd,MAAM,EAAE,qBAAqB,CAAC,KAAK,EAAE,UAAU,CAAC,EAChD,WAAW,CAAC,EAAE,OAAO,EACrB,MAAM,SAAW,GAChB,OAAO,CAAC,WAAW,CAAC;IAkUvB;;OAEG;YACW,kBAAkB;CASjC"}
@@ -0,0 +1,72 @@
1
+ export declare const postgresAdapterDescriptorMeta: {
2
+ readonly kind: "adapter";
3
+ readonly familyId: "sql";
4
+ readonly targetId: "postgres";
5
+ readonly id: "postgres";
6
+ readonly version: "0.0.1";
7
+ readonly capabilities: {
8
+ readonly postgres: {
9
+ readonly orderBy: true;
10
+ readonly limit: true;
11
+ readonly lateral: true;
12
+ readonly jsonAgg: true;
13
+ readonly returning: true;
14
+ };
15
+ };
16
+ readonly types: {
17
+ readonly codecTypes: {
18
+ readonly import: {
19
+ readonly package: "@prisma-next/adapter-postgres/codec-types";
20
+ readonly named: "CodecTypes";
21
+ readonly alias: "PgTypes";
22
+ };
23
+ };
24
+ readonly storage: readonly [{
25
+ readonly typeId: "pg/text@1";
26
+ readonly familyId: "sql";
27
+ readonly targetId: "postgres";
28
+ readonly nativeType: "text";
29
+ }, {
30
+ readonly typeId: "pg/int4@1";
31
+ readonly familyId: "sql";
32
+ readonly targetId: "postgres";
33
+ readonly nativeType: "int4";
34
+ }, {
35
+ readonly typeId: "pg/int2@1";
36
+ readonly familyId: "sql";
37
+ readonly targetId: "postgres";
38
+ readonly nativeType: "int2";
39
+ }, {
40
+ readonly typeId: "pg/int8@1";
41
+ readonly familyId: "sql";
42
+ readonly targetId: "postgres";
43
+ readonly nativeType: "int8";
44
+ }, {
45
+ readonly typeId: "pg/float4@1";
46
+ readonly familyId: "sql";
47
+ readonly targetId: "postgres";
48
+ readonly nativeType: "float4";
49
+ }, {
50
+ readonly typeId: "pg/float8@1";
51
+ readonly familyId: "sql";
52
+ readonly targetId: "postgres";
53
+ readonly nativeType: "float8";
54
+ }, {
55
+ readonly typeId: "pg/timestamp@1";
56
+ readonly familyId: "sql";
57
+ readonly targetId: "postgres";
58
+ readonly nativeType: "timestamp";
59
+ }, {
60
+ readonly typeId: "pg/timestamptz@1";
61
+ readonly familyId: "sql";
62
+ readonly targetId: "postgres";
63
+ readonly nativeType: "timestamptz";
64
+ }, {
65
+ readonly typeId: "pg/bool@1";
66
+ readonly familyId: "sql";
67
+ readonly targetId: "postgres";
68
+ readonly nativeType: "bool";
69
+ }];
70
+ };
71
+ };
72
+ //# sourceMappingURL=descriptor-meta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"descriptor-meta.d.ts","sourceRoot":"","sources":["../../src/core/descriptor-meta.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwChC,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { SqlContract, SqlStorage, StorageColumn, StorageTable } from '@prisma-next/sql-contract/types';
2
+ import type { BinaryExpr, ColumnRef, DeleteAst, Direction, InsertAst, JoinAst, LiteralExpr, LoweredStatement, OperationExpr, ParamRef, QueryAst, SelectAst, UpdateAst } from '@prisma-next/sql-relational-core/ast';
3
+ export interface PostgresAdapterOptions {
4
+ readonly profileId?: string;
5
+ }
6
+ export type PostgresContract = SqlContract<SqlStorage> & {
7
+ readonly target: 'postgres';
8
+ };
9
+ export type Expr = ColumnRef | ParamRef;
10
+ export interface OrderClause {
11
+ readonly expr: ColumnRef;
12
+ readonly dir: Direction;
13
+ }
14
+ export type PostgresLoweredStatement = LoweredStatement;
15
+ export type { BinaryExpr, ColumnRef, DeleteAst, Direction, InsertAst, JoinAst, LiteralExpr, OperationExpr, ParamRef, QueryAst, SelectAst, StorageColumn, StorageTable, UpdateAst, };
16
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,aAAa,EACb,YAAY,EACb,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,OAAO,EACP,WAAW,EACX,gBAAgB,EAChB,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,SAAS,EACV,MAAM,sCAAsC,CAAC;AAE9C,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,MAAM,gBAAgB,GAAG,WAAW,CAAC,UAAU,CAAC,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAA;CAAE,CAAC;AAEzF,MAAM,MAAM,IAAI,GAAG,SAAS,GAAG,QAAQ,CAAC;AAExC,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;CACzB;AAED,MAAM,MAAM,wBAAwB,GAAG,gBAAgB,CAAC;AAExD,YAAY,EACV,UAAU,EACV,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,OAAO,EACP,WAAW,EACX,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,aAAa,EACb,YAAY,EACZ,SAAS,GACV,CAAC"}
@@ -1,21 +1,2 @@
1
- import { Adapter, QueryAst, AdapterProfile, LowererContext } from '@prisma-next/sql-relational-core/ast';
2
- import { PostgresAdapterOptions, PostgresContract, PostgresLoweredStatement } from './types.js';
3
- import '@prisma-next/sql-contract/types';
4
-
5
- declare class PostgresAdapterImpl implements Adapter<QueryAst, PostgresContract, PostgresLoweredStatement> {
6
- readonly familyId: "sql";
7
- readonly targetId: "postgres";
8
- readonly profile: AdapterProfile<'postgres'>;
9
- private readonly codecRegistry;
10
- constructor(options?: PostgresAdapterOptions);
11
- lower(ast: QueryAst, context: LowererContext<PostgresContract>): Readonly<{
12
- profileId: string;
13
- body: Readonly<{
14
- sql: string;
15
- params: unknown[];
16
- }>;
17
- }>;
18
- }
19
- declare function createPostgresAdapter(options?: PostgresAdapterOptions): Readonly<PostgresAdapterImpl>;
20
-
21
- export { createPostgresAdapter };
1
+ export { createPostgresAdapter } from '../core/adapter';
2
+ //# sourceMappingURL=adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/exports/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createPostgresAdapter
3
- } from "./chunk-ZHJOVBWT.js";
4
- import "./chunk-CPAKRHXM.js";
3
+ } from "../chunk-T6S3A6VT.js";
4
+ import "../chunk-J3XSOAM2.js";
5
5
  export {
6
6
  createPostgresAdapter
7
7
  };
@@ -1,38 +1,11 @@
1
- import * as _prisma_next_sql_relational_core_ast from '@prisma-next/sql-relational-core/ast';
2
-
3
1
  /**
4
- * Unified codec definitions for Postgres adapter.
2
+ * Codec type definitions for Postgres adapter.
5
3
  *
6
- * This file contains a single source of truth for all codec information:
7
- * - Scalar names
8
- * - Type IDs
9
- * - Codec implementations (runtime)
10
- * - Type information (compile-time)
4
+ * This file exports type-only definitions for codec input/output types.
5
+ * These types are imported by contract.d.ts files for compile-time type inference.
11
6
  *
12
- * This structure is used both at runtime (to populate the registry) and
13
- * at compile time (to derive CodecTypes).
7
+ * Runtime codec implementations are provided by the adapter's codec registry.
14
8
  */
15
- declare const codecs: _prisma_next_sql_relational_core_ast.CodecDefBuilder<{
16
- text: _prisma_next_sql_relational_core_ast.Codec<"pg/text@1", string, string>;
17
- int4: _prisma_next_sql_relational_core_ast.Codec<"pg/int4@1", number, number>;
18
- int2: _prisma_next_sql_relational_core_ast.Codec<"pg/int2@1", number, number>;
19
- int8: _prisma_next_sql_relational_core_ast.Codec<"pg/int8@1", number, number>;
20
- float4: _prisma_next_sql_relational_core_ast.Codec<"pg/float4@1", number, number>;
21
- float8: _prisma_next_sql_relational_core_ast.Codec<"pg/float8@1", number, number>;
22
- timestamp: _prisma_next_sql_relational_core_ast.Codec<"pg/timestamp@1", string | Date, string>;
23
- timestamptz: _prisma_next_sql_relational_core_ast.Codec<"pg/timestamptz@1", string | Date, string>;
24
- } & Record<"bool", _prisma_next_sql_relational_core_ast.Codec<"pg/bool@1", boolean, boolean>>>;
25
- declare const dataTypes: {
26
- readonly text: "pg/text@1";
27
- readonly int4: "pg/int4@1";
28
- readonly int2: "pg/int2@1";
29
- readonly int8: "pg/int8@1";
30
- readonly float4: "pg/float4@1";
31
- readonly float8: "pg/float8@1";
32
- readonly timestamp: "pg/timestamp@1";
33
- readonly timestamptz: "pg/timestamptz@1";
34
- readonly bool: "pg/bool@1";
35
- };
36
- type CodecTypes = typeof codecs.CodecTypes;
37
-
38
- export { type CodecTypes, dataTypes };
9
+ export type { CodecTypes } from '../core/codecs';
10
+ export { dataTypes } from '../core/codecs';
11
+ //# sourceMappingURL=codec-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codec-types.d.ts","sourceRoot":"","sources":["../../src/exports/codec-types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  dataTypes
3
- } from "./chunk-CPAKRHXM.js";
3
+ } from "../chunk-J3XSOAM2.js";
4
4
  export {
5
5
  dataTypes
6
6
  };
@@ -1,20 +1,17 @@
1
- import { ColumnTypeDescriptor } from '@prisma-next/contract-authoring';
2
-
3
1
  /**
4
2
  * Column type descriptors for Postgres adapter.
5
3
  *
6
4
  * These descriptors provide both codecId and nativeType for use in contract authoring.
7
5
  * They are derived from the same source of truth as codec definitions and manifests.
8
6
  */
9
-
10
- declare const textColumn: ColumnTypeDescriptor;
11
- declare const int4Column: ColumnTypeDescriptor;
12
- declare const int2Column: ColumnTypeDescriptor;
13
- declare const int8Column: ColumnTypeDescriptor;
14
- declare const float4Column: ColumnTypeDescriptor;
15
- declare const float8Column: ColumnTypeDescriptor;
16
- declare const timestampColumn: ColumnTypeDescriptor;
17
- declare const timestamptzColumn: ColumnTypeDescriptor;
18
- declare const boolColumn: ColumnTypeDescriptor;
19
-
20
- export { boolColumn, float4Column, float8Column, int2Column, int4Column, int8Column, textColumn, timestampColumn, timestamptzColumn };
7
+ import type { ColumnTypeDescriptor } from '@prisma-next/contract-authoring';
8
+ export declare const textColumn: ColumnTypeDescriptor;
9
+ export declare const int4Column: ColumnTypeDescriptor;
10
+ export declare const int2Column: ColumnTypeDescriptor;
11
+ export declare const int8Column: ColumnTypeDescriptor;
12
+ export declare const float4Column: ColumnTypeDescriptor;
13
+ export declare const float8Column: ColumnTypeDescriptor;
14
+ export declare const timestampColumn: ColumnTypeDescriptor;
15
+ export declare const timestamptzColumn: ColumnTypeDescriptor;
16
+ export declare const boolColumn: ColumnTypeDescriptor;
17
+ //# sourceMappingURL=column-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"column-types.d.ts","sourceRoot":"","sources":["../../src/exports/column-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAE5E,eAAO,MAAM,UAAU,EAAE,oBAGf,CAAC;AAEX,eAAO,MAAM,UAAU,EAAE,oBAGf,CAAC;AAEX,eAAO,MAAM,UAAU,EAAE,oBAGf,CAAC;AAEX,eAAO,MAAM,UAAU,EAAE,oBAGf,CAAC;AAEX,eAAO,MAAM,YAAY,EAAE,oBAGjB,CAAC;AAEX,eAAO,MAAM,YAAY,EAAE,oBAGjB,CAAC;AAEX,eAAO,MAAM,eAAe,EAAE,oBAGpB,CAAC;AAEX,eAAO,MAAM,iBAAiB,EAAE,oBAGtB,CAAC;AAEX,eAAO,MAAM,UAAU,EAAE,oBAGf,CAAC"}
@@ -1,9 +1,8 @@
1
- import { ControlAdapterDescriptor } from '@prisma-next/core-control-plane/types';
2
- import { SqlControlAdapter } from '@prisma-next/family-sql/control-adapter';
3
-
1
+ import type { ControlAdapterDescriptor } from '@prisma-next/core-control-plane/types';
2
+ import type { SqlControlAdapter } from '@prisma-next/family-sql/control-adapter';
4
3
  /**
5
4
  * Postgres adapter descriptor for CLI config.
6
5
  */
7
6
  declare const postgresAdapterDescriptor: ControlAdapterDescriptor<'sql', 'postgres', SqlControlAdapter<'postgres'>>;
8
-
9
- export { postgresAdapterDescriptor as default };
7
+ export default postgresAdapterDescriptor;
8
+ //# sourceMappingURL=control.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"control.d.ts","sourceRoot":"","sources":["../../src/exports/control.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AACtF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAIjF;;GAEG;AACH,QAAA,MAAM,yBAAyB,EAAE,wBAAwB,CACvD,KAAK,EACL,UAAU,EACV,iBAAiB,CAAC,UAAU,CAAC,CAM9B,CAAC;AAEF,eAAe,yBAAyB,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  postgresAdapterDescriptorMeta
3
- } from "./chunk-B5SU5BVC.js";
3
+ } from "../chunk-HD5YISNQ.js";
4
4
 
5
5
  // src/core/control-adapter.ts
6
6
  var PostgresControlAdapter = class {
@@ -1,17 +1,15 @@
1
- import { RuntimeAdapterDescriptor, RuntimeAdapterInstance } from '@prisma-next/core-execution-plane/types';
2
- import { Adapter, QueryAst } from '@prisma-next/sql-relational-core/ast';
3
- import { PostgresContract, PostgresLoweredStatement } from './types.js';
4
- import '@prisma-next/sql-contract/types';
5
-
1
+ import type { RuntimeAdapterDescriptor, RuntimeAdapterInstance } from '@prisma-next/core-execution-plane/types';
2
+ import type { Adapter, QueryAst } from '@prisma-next/sql-relational-core/ast';
3
+ import type { PostgresContract, PostgresLoweredStatement } from '../core/types';
6
4
  /**
7
5
  * SQL runtime adapter interface for Postgres.
8
6
  * Extends RuntimeAdapterInstance with SQL-specific adapter methods.
9
7
  */
10
- interface SqlRuntimeAdapter extends RuntimeAdapterInstance<'sql', 'postgres'>, Adapter<QueryAst, PostgresContract, PostgresLoweredStatement> {
8
+ export interface SqlRuntimeAdapter extends RuntimeAdapterInstance<'sql', 'postgres'>, Adapter<QueryAst, PostgresContract, PostgresLoweredStatement> {
11
9
  }
12
10
  /**
13
11
  * Postgres adapter descriptor for runtime plane.
14
12
  */
15
13
  declare const postgresRuntimeAdapterDescriptor: RuntimeAdapterDescriptor<'sql', 'postgres', SqlRuntimeAdapter>;
16
-
17
- export { type SqlRuntimeAdapter, postgresRuntimeAdapterDescriptor as default };
14
+ export default postgresRuntimeAdapterDescriptor;
15
+ //# sourceMappingURL=runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/exports/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,sBAAsB,EACvB,MAAM,yCAAyC,CAAC;AACjD,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAG9E,OAAO,KAAK,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAEhF;;;GAGG;AACH,MAAM,WAAW,iBACf,SAAQ,sBAAsB,CAAC,KAAK,EAAE,UAAU,CAAC,EAC/C,OAAO,CAAC,QAAQ,EAAE,gBAAgB,EAAE,wBAAwB,CAAC;CAAG;AAEpE;;GAEG;AACH,QAAA,MAAM,gCAAgC,EAAE,wBAAwB,CAC9D,KAAK,EACL,UAAU,EACV,iBAAiB,CAMlB,CAAC;AAEF,eAAe,gCAAgC,CAAC"}
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  createPostgresAdapter
3
- } from "./chunk-ZHJOVBWT.js";
4
- import "./chunk-CPAKRHXM.js";
3
+ } from "../chunk-T6S3A6VT.js";
4
+ import "../chunk-J3XSOAM2.js";
5
5
  import {
6
6
  postgresAdapterDescriptorMeta
7
- } from "./chunk-B5SU5BVC.js";
7
+ } from "../chunk-HD5YISNQ.js";
8
8
 
9
9
  // src/exports/runtime.ts
10
10
  var postgresRuntimeAdapterDescriptor = {