@prisma-next/adapter-postgres 0.4.0-dev.9 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/{adapter-7pXt8ej9.mjs → adapter-Du9Hr9Rl.mjs} +4 -5
  2. package/dist/adapter-Du9Hr9Rl.mjs.map +1 -0
  3. package/dist/adapter.d.mts +1 -1
  4. package/dist/adapter.d.mts.map +1 -1
  5. package/dist/adapter.mjs +1 -1
  6. package/dist/{codec-ids-BwjcIf74.mjs → codec-ids-5g4Gwrgm.mjs} +1 -1
  7. package/dist/{codec-ids-BwjcIf74.mjs.map → codec-ids-5g4Gwrgm.mjs.map} +1 -1
  8. package/dist/codec-types.mjs +1 -1
  9. package/dist/{codecs-C3wlpdV7.mjs → codecs-DiPlMi3-.mjs} +2 -2
  10. package/dist/{codecs-C3wlpdV7.mjs.map → codecs-DiPlMi3-.mjs.map} +1 -1
  11. package/dist/column-types.d.mts.map +1 -1
  12. package/dist/column-types.mjs +1 -1
  13. package/dist/control.mjs +2 -2
  14. package/dist/{descriptor-meta-DemWrTfB.mjs → descriptor-meta-BB9XPAFi.mjs} +30 -6
  15. package/dist/descriptor-meta-BB9XPAFi.mjs.map +1 -0
  16. package/dist/operation-types.d.mts +21 -0
  17. package/dist/operation-types.d.mts.map +1 -0
  18. package/dist/operation-types.mjs +1 -0
  19. package/dist/runtime.d.mts +1 -1
  20. package/dist/runtime.mjs +5 -4
  21. package/dist/runtime.mjs.map +1 -1
  22. package/dist/{sql-utils-CSfAGEwF.mjs → sql-utils-DkUJyZmA.mjs} +1 -1
  23. package/dist/{sql-utils-CSfAGEwF.mjs.map → sql-utils-DkUJyZmA.mjs.map} +1 -1
  24. package/dist/{types-DxaTd7aP.d.mts → types-TyL62f9Y.d.mts} +1 -1
  25. package/dist/{types-DxaTd7aP.d.mts.map → types-TyL62f9Y.d.mts.map} +1 -1
  26. package/dist/types.d.mts +1 -1
  27. package/package.json +15 -14
  28. package/src/core/adapter.ts +0 -1
  29. package/src/core/descriptor-meta.ts +20 -0
  30. package/src/exports/operation-types.ts +1 -0
  31. package/src/exports/runtime.ts +2 -1
  32. package/src/types/operation-types.ts +11 -0
  33. package/dist/adapter-7pXt8ej9.mjs.map +0 -1
  34. package/dist/descriptor-meta-DemWrTfB.mjs.map +0 -1
@@ -1,6 +1,6 @@
1
- import { m as PG_JSON_CODEC_ID, p as PG_JSONB_CODEC_ID } from "./codec-ids-BwjcIf74.mjs";
2
- import { t as codecDefinitions } from "./codecs-C3wlpdV7.mjs";
3
- import { i as quoteIdentifier, n as escapeLiteral } from "./sql-utils-CSfAGEwF.mjs";
1
+ import { m as PG_JSON_CODEC_ID, p as PG_JSONB_CODEC_ID } from "./codec-ids-5g4Gwrgm.mjs";
2
+ import { t as codecDefinitions } from "./codecs-DiPlMi3-.mjs";
3
+ import { i as quoteIdentifier, n as escapeLiteral } from "./sql-utils-DkUJyZmA.mjs";
4
4
  import { LiteralExpr, createCodecRegistry } from "@prisma-next/sql-relational-core/ast";
5
5
  import { ifDefined } from "@prisma-next/utils/defined";
6
6
 
@@ -182,7 +182,6 @@ function renderBinary(expr, contract, pim) {
182
182
  gte: ">=",
183
183
  lte: "<=",
184
184
  like: "LIKE",
185
- ilike: "ILIKE",
186
185
  in: "IN",
187
186
  notIn: "NOT IN"
188
187
  }[expr.op]} ${right}`;
@@ -366,4 +365,4 @@ function createPostgresAdapter(options) {
366
365
 
367
366
  //#endregion
368
367
  export { createPostgresAdapter as t };
369
- //# sourceMappingURL=adapter-7pXt8ej9.mjs.map
368
+ //# sourceMappingURL=adapter-Du9Hr9Rl.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter-Du9Hr9Rl.mjs","names":["parameterizedCodecs: ReadonlyArray<CodecParamsDescriptor>","codec","paramIndexMap: ParamIndexMap","params: unknown[]","sql: string","right: string","orderedColumns: string[]","value: string"],"sources":["../src/core/adapter.ts"],"sourcesContent":["import {\n type Adapter,\n type AdapterProfile,\n type AggregateExpr,\n type AnyExpression,\n type AnyFromSource,\n type AnyQueryAst,\n type BinaryExpr,\n type CodecParamsDescriptor,\n type ColumnRef,\n createCodecRegistry,\n type DeleteAst,\n type InsertAst,\n type InsertValue,\n type JoinAst,\n type JoinOnExpr,\n type JsonArrayAggExpr,\n type JsonObjectExpr,\n type ListExpression,\n LiteralExpr,\n type LowererContext,\n type NullCheckExpr,\n type OperationExpr,\n type OrderByItem,\n type ParamRef,\n type ProjectionItem,\n type SelectAst,\n type SubqueryExpr,\n type UpdateAst,\n} from '@prisma-next/sql-relational-core/ast';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { PG_JSON_CODEC_ID, PG_JSONB_CODEC_ID } from './codec-ids';\nimport { codecDefinitions } from './codecs';\nimport { escapeLiteral, quoteIdentifier } from './sql-utils';\nimport type { PostgresAdapterOptions, PostgresContract, PostgresLoweredStatement } from './types';\n\nconst VECTOR_CODEC_ID = 'pg/vector@1' as const;\n\nfunction getCodecParamCast(codecId: string | undefined): string | undefined {\n if (codecId === VECTOR_CODEC_ID) {\n return 'vector';\n }\n if (codecId === PG_JSON_CODEC_ID) {\n return 'json';\n }\n if (codecId === PG_JSONB_CODEC_ID) {\n return 'jsonb';\n }\n return undefined;\n}\n\nfunction renderTypedParam(index: number, codecId: string | undefined): string {\n const cast = getCodecParamCast(codecId);\n return cast ? `$${index}::${cast}` : `$${index}`;\n}\n\ntype ParamIndexMap = Map<ParamRef, number>;\n\nconst defaultCapabilities = Object.freeze({\n postgres: {\n orderBy: true,\n limit: true,\n lateral: true,\n jsonAgg: true,\n returning: true,\n },\n sql: {\n enums: true,\n returning: true,\n defaultInInsert: true,\n },\n});\n\ntype AdapterCodec = (typeof codecDefinitions)[keyof typeof codecDefinitions]['codec'];\ntype ParameterizedCodec = AdapterCodec & {\n readonly paramsSchema: NonNullable<AdapterCodec['paramsSchema']>;\n};\n\nconst parameterizedCodecs: ReadonlyArray<CodecParamsDescriptor> = Object.values(codecDefinitions)\n .map((definition) => definition.codec)\n .filter((codec): codec is ParameterizedCodec => codec.paramsSchema !== undefined)\n .map((codec) =>\n Object.freeze({\n codecId: codec.id,\n paramsSchema: codec.paramsSchema,\n ...ifDefined('init', codec.init),\n }),\n );\n\nclass PostgresAdapterImpl\n implements Adapter<AnyQueryAst, PostgresContract, PostgresLoweredStatement>\n{\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 readMarkerStatement: () => ({\n sql: 'select core_hash, profile_hash, contract_json, canonical_version, updated_at, app_tag, meta from prisma_contract.marker where id = $1',\n params: [1],\n }),\n });\n }\n\n parameterizedCodecs(): ReadonlyArray<CodecParamsDescriptor> {\n return parameterizedCodecs;\n }\n\n lower(ast: AnyQueryAst, context: LowererContext<PostgresContract>) {\n const collectedParamRefs = ast.collectParamRefs();\n const paramIndexMap: ParamIndexMap = new Map();\n const params: unknown[] = [];\n for (const ref of collectedParamRefs) {\n if (paramIndexMap.has(ref)) {\n continue;\n }\n paramIndexMap.set(ref, params.length + 1);\n params.push(ref.value);\n }\n\n let sql: string;\n\n const node = ast;\n switch (node.kind) {\n case 'select':\n sql = renderSelect(node, context.contract, paramIndexMap);\n break;\n case 'insert':\n sql = renderInsert(node, context.contract, paramIndexMap);\n break;\n case 'update':\n sql = renderUpdate(node, context.contract, paramIndexMap);\n break;\n case 'delete':\n sql = renderDelete(node, context.contract, paramIndexMap);\n break;\n // v8 ignore next 4\n default:\n throw new Error(\n `Unsupported AST node kind: ${(node satisfies never as { kind: string }).kind}`,\n );\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, pim?: ParamIndexMap): string {\n const selectClause = `SELECT ${renderDistinctPrefix(ast.distinct, ast.distinctOn, contract, pim)}${renderProjection(\n ast.projection,\n contract,\n pim,\n )}`;\n const fromClause = `FROM ${renderSource(ast.from, contract, pim)}`;\n\n const joinsClause = ast.joins?.length\n ? ast.joins.map((join) => renderJoin(join, contract, pim)).join(' ')\n : '';\n\n const whereClause = ast.where ? `WHERE ${renderWhere(ast.where, contract, pim)}` : '';\n const groupByClause = ast.groupBy?.length\n ? `GROUP BY ${ast.groupBy.map((expr) => renderExpr(expr, contract, pim)).join(', ')}`\n : '';\n const havingClause = ast.having ? `HAVING ${renderWhere(ast.having, contract, pim)}` : '';\n const orderClause = ast.orderBy?.length\n ? `ORDER BY ${ast.orderBy\n .map((order) => {\n const expr = renderExpr(order.expr, contract, pim);\n return `${expr} ${order.dir.toUpperCase()}`;\n })\n .join(', ')}`\n : '';\n const limitClause = typeof ast.limit === 'number' ? `LIMIT ${ast.limit}` : '';\n const offsetClause = typeof ast.offset === 'number' ? `OFFSET ${ast.offset}` : '';\n\n const clauses = [\n selectClause,\n fromClause,\n joinsClause,\n whereClause,\n groupByClause,\n havingClause,\n orderClause,\n limitClause,\n offsetClause,\n ]\n .filter((part) => part.length > 0)\n .join(' ');\n return clauses.trim();\n}\n\nfunction renderProjection(\n projection: ReadonlyArray<ProjectionItem>,\n contract?: PostgresContract,\n pim?: ParamIndexMap,\n): string {\n return projection\n .map((item) => {\n const alias = quoteIdentifier(item.alias);\n if (item.expr.kind === 'literal') {\n return `${renderLiteral(item.expr)} AS ${alias}`;\n }\n return `${renderExpr(item.expr, contract, pim)} AS ${alias}`;\n })\n .join(', ');\n}\n\nfunction renderDistinctPrefix(\n distinct: true | undefined,\n distinctOn: ReadonlyArray<AnyExpression> | undefined,\n contract?: PostgresContract,\n pim?: ParamIndexMap,\n): string {\n if (distinctOn && distinctOn.length > 0) {\n const rendered = distinctOn.map((expr) => renderExpr(expr, contract, pim)).join(', ');\n return `DISTINCT ON (${rendered}) `;\n }\n if (distinct) {\n return 'DISTINCT ';\n }\n return '';\n}\n\nfunction renderSource(\n source: AnyFromSource,\n contract?: PostgresContract,\n pim?: ParamIndexMap,\n): string {\n const node = source;\n switch (node.kind) {\n case 'table-source': {\n const table = quoteIdentifier(node.name);\n if (!node.alias) {\n return table;\n }\n return `${table} AS ${quoteIdentifier(node.alias)}`;\n }\n case 'derived-table-source':\n return `(${renderSelect(node.query, contract, pim)}) AS ${quoteIdentifier(node.alias)}`;\n // v8 ignore next 4\n default:\n throw new Error(\n `Unsupported source node kind: ${(node satisfies never as { kind: string }).kind}`,\n );\n }\n}\n\nfunction assertScalarSubquery(query: SelectAst): void {\n if (query.projection.length !== 1) {\n throw new Error('Subquery expressions must project exactly one column');\n }\n}\n\nfunction renderSubqueryExpr(\n expr: SubqueryExpr,\n contract?: PostgresContract,\n pim?: ParamIndexMap,\n): string {\n assertScalarSubquery(expr.query);\n return `(${renderSelect(expr.query, contract, pim)})`;\n}\n\nfunction renderWhere(\n expr: AnyExpression,\n contract?: PostgresContract,\n pim?: ParamIndexMap,\n): string {\n return renderExpr(expr, contract, pim);\n}\n\nfunction renderNullCheck(\n expr: NullCheckExpr,\n contract?: PostgresContract,\n pim?: ParamIndexMap,\n): string {\n const rendered = renderExpr(expr.expr, contract, pim);\n const renderedExpr =\n expr.expr.kind === 'operation' || expr.expr.kind === 'subquery' ? `(${rendered})` : rendered;\n return expr.isNull ? `${renderedExpr} IS NULL` : `${renderedExpr} IS NOT NULL`;\n}\n\nfunction renderBinary(expr: BinaryExpr, contract?: PostgresContract, pim?: ParamIndexMap): string {\n if (expr.right.kind === 'list' && expr.right.values.length === 0) {\n if (expr.op === 'in') {\n return 'FALSE';\n }\n if (expr.op === 'notIn') {\n return 'TRUE';\n }\n }\n\n const leftExpr = expr.left;\n const left = renderExpr(leftExpr, contract, pim);\n const leftRendered =\n leftExpr.kind === 'operation' || leftExpr.kind === 'subquery' ? `(${left})` : left;\n\n const rightNode = expr.right;\n let right: string;\n switch (rightNode.kind) {\n case 'list':\n right = renderListLiteral(rightNode, pim);\n break;\n case 'literal':\n right = renderLiteral(rightNode);\n break;\n case 'column-ref':\n right = renderColumn(rightNode);\n break;\n case 'param-ref':\n right = renderParamRef(rightNode, pim);\n break;\n default:\n right = renderExpr(rightNode, contract, pim);\n break;\n }\n\n const operatorMap: Record<BinaryExpr['op'], string> = {\n eq: '=',\n neq: '!=',\n gt: '>',\n lt: '<',\n gte: '>=',\n lte: '<=',\n like: 'LIKE',\n in: 'IN',\n notIn: 'NOT IN',\n };\n\n return `${leftRendered} ${operatorMap[expr.op]} ${right}`;\n}\n\nfunction renderListLiteral(expr: ListExpression, pim?: ParamIndexMap): string {\n if (expr.values.length === 0) {\n return '(NULL)';\n }\n const values = expr.values\n .map((v) => {\n if (v.kind === 'param-ref') return renderParamRef(v, pim);\n if (v.kind === 'literal') return renderLiteral(v);\n return renderExpr(v, undefined, pim);\n })\n .join(', ');\n return `(${values})`;\n}\n\nfunction renderColumn(ref: ColumnRef): string {\n if (ref.table === 'excluded') {\n return `excluded.${quoteIdentifier(ref.column)}`;\n }\n return `${quoteIdentifier(ref.table)}.${quoteIdentifier(ref.column)}`;\n}\n\nfunction renderAggregateExpr(\n expr: AggregateExpr,\n contract?: PostgresContract,\n pim?: ParamIndexMap,\n): string {\n const fn = expr.fn.toUpperCase();\n if (!expr.expr) {\n return `${fn}(*)`;\n }\n return `${fn}(${renderExpr(expr.expr, contract, pim)})`;\n}\n\nfunction renderJsonObjectExpr(\n expr: JsonObjectExpr,\n contract?: PostgresContract,\n pim?: ParamIndexMap,\n): string {\n const args = expr.entries\n .flatMap((entry): [string, string] => {\n const key = `'${escapeLiteral(entry.key)}'`;\n if (entry.value.kind === 'literal') {\n return [key, renderLiteral(entry.value)];\n }\n return [key, renderExpr(entry.value, contract, pim)];\n })\n .join(', ');\n return `json_build_object(${args})`;\n}\n\nfunction renderOrderByItems(\n items: ReadonlyArray<OrderByItem>,\n contract?: PostgresContract,\n pim?: ParamIndexMap,\n): string {\n return items\n .map((item) => `${renderExpr(item.expr, contract, pim)} ${item.dir.toUpperCase()}`)\n .join(', ');\n}\n\nfunction renderJsonArrayAggExpr(\n expr: JsonArrayAggExpr,\n contract?: PostgresContract,\n pim?: ParamIndexMap,\n): string {\n const aggregateOrderBy =\n expr.orderBy && expr.orderBy.length > 0\n ? ` ORDER BY ${renderOrderByItems(expr.orderBy, contract, pim)}`\n : '';\n const aggregated = `json_agg(${renderExpr(expr.expr, contract, pim)}${aggregateOrderBy})`;\n if (expr.onEmpty === 'emptyArray') {\n return `coalesce(${aggregated}, json_build_array())`;\n }\n return aggregated;\n}\n\nfunction renderExpr(expr: AnyExpression, contract?: PostgresContract, pim?: ParamIndexMap): string {\n const node = expr;\n switch (node.kind) {\n case 'column-ref':\n return renderColumn(node);\n case 'identifier-ref':\n return quoteIdentifier(node.name);\n case 'operation':\n return renderOperation(node, contract, pim);\n case 'subquery':\n return renderSubqueryExpr(node, contract, pim);\n case 'aggregate':\n return renderAggregateExpr(node, contract, pim);\n case 'json-object':\n return renderJsonObjectExpr(node, contract, pim);\n case 'json-array-agg':\n return renderJsonArrayAggExpr(node, contract, pim);\n case 'binary':\n return renderBinary(node, contract, pim);\n case 'and':\n if (node.exprs.length === 0) {\n return 'TRUE';\n }\n return `(${node.exprs.map((part) => renderExpr(part, contract, pim)).join(' AND ')})`;\n case 'or':\n if (node.exprs.length === 0) {\n return 'FALSE';\n }\n return `(${node.exprs.map((part) => renderExpr(part, contract, pim)).join(' OR ')})`;\n case 'exists': {\n const notKeyword = node.notExists ? 'NOT ' : '';\n const subquery = renderSelect(node.subquery, contract, pim);\n return `${notKeyword}EXISTS (${subquery})`;\n }\n case 'null-check':\n return renderNullCheck(node, contract, pim);\n case 'not':\n return `NOT (${renderExpr(node.expr, contract, pim)})`;\n case 'param-ref':\n return renderParamRef(node, pim);\n case 'literal':\n return renderLiteral(node);\n case 'list':\n return renderListLiteral(node, pim);\n // v8 ignore next 4\n default:\n throw new Error(\n `Unsupported expression node kind: ${(node satisfies never as { kind: string }).kind}`,\n );\n }\n}\n\nfunction renderParamRef(ref: ParamRef, pim?: ParamIndexMap): string {\n const index = pim?.get(ref);\n if (index === undefined) {\n throw new Error('ParamRef not found in index map');\n }\n return renderTypedParam(index, ref.codecId);\n}\n\nfunction renderLiteral(expr: LiteralExpr): string {\n if (typeof expr.value === 'string') {\n return `'${escapeLiteral(expr.value)}'`;\n }\n if (typeof expr.value === 'number' || typeof expr.value === 'boolean') {\n return String(expr.value);\n }\n if (typeof expr.value === 'bigint') {\n return String(expr.value);\n }\n if (expr.value === null) {\n return 'NULL';\n }\n if (expr.value === undefined) {\n return 'NULL';\n }\n if (expr.value instanceof Date) {\n return `'${escapeLiteral(expr.value.toISOString())}'`;\n }\n if (Array.isArray(expr.value)) {\n return `ARRAY[${expr.value.map((v: unknown) => renderLiteral(new LiteralExpr(v))).join(', ')}]`;\n }\n const json = JSON.stringify(expr.value);\n if (json === undefined) {\n return 'NULL';\n }\n return `'${escapeLiteral(json)}'`;\n}\n\nfunction renderOperation(\n expr: OperationExpr,\n contract?: PostgresContract,\n pim?: ParamIndexMap,\n): string {\n const self = renderExpr(expr.self, contract, pim);\n const args = expr.args.map((arg) => {\n return renderExpr(arg, contract, pim);\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 return result;\n}\n\nfunction renderJoin(join: JoinAst, contract?: PostgresContract, pim?: ParamIndexMap): string {\n const joinType = join.joinType.toUpperCase();\n const lateral = join.lateral ? 'LATERAL ' : '';\n const source = renderSource(join.source, contract, pim);\n const onClause = renderJoinOn(join.on, contract, pim);\n return `${joinType} JOIN ${lateral}${source} ON ${onClause}`;\n}\n\nfunction renderJoinOn(on: JoinOnExpr, contract?: PostgresContract, pim?: ParamIndexMap): string {\n if (on.kind === 'eq-col-join-on') {\n const left = renderColumn(on.left);\n const right = renderColumn(on.right);\n return `${left} = ${right}`;\n }\n return renderWhere(on, contract, pim);\n}\n\nfunction getInsertColumnOrder(\n rows: ReadonlyArray<Record<string, InsertValue>>,\n contract: PostgresContract,\n tableName: string,\n): string[] {\n const orderedColumns: string[] = [];\n const seenColumns = new Set<string>();\n\n for (const row of rows) {\n for (const column of Object.keys(row)) {\n if (seenColumns.has(column)) {\n continue;\n }\n seenColumns.add(column);\n orderedColumns.push(column);\n }\n }\n\n if (orderedColumns.length > 0) {\n return orderedColumns;\n }\n\n return Object.keys(contract.storage.tables[tableName]?.columns ?? {});\n}\n\nfunction renderInsertValue(value: InsertValue | undefined, pim?: ParamIndexMap): string {\n if (!value || value.kind === 'default-value') {\n return 'DEFAULT';\n }\n\n switch (value.kind) {\n case 'param-ref':\n return renderParamRef(value, pim);\n case 'column-ref':\n return renderColumn(value);\n // v8 ignore next 4\n default:\n throw new Error(\n `Unsupported value node in INSERT: ${(value satisfies never as { kind: string }).kind}`,\n );\n }\n}\n\nfunction renderInsert(ast: InsertAst, contract: PostgresContract, pim?: ParamIndexMap): string {\n const table = quoteIdentifier(ast.table.name);\n const rows = ast.rows;\n if (rows.length === 0) {\n throw new Error('INSERT requires at least one row');\n }\n const hasExplicitValues = rows.some((row) => Object.keys(row).length > 0);\n const insertClause = (() => {\n if (!hasExplicitValues) {\n if (rows.length === 1) {\n return `INSERT INTO ${table} DEFAULT VALUES`;\n }\n\n const defaultColumns = getInsertColumnOrder(rows, contract, ast.table.name);\n if (defaultColumns.length === 0) {\n return `INSERT INTO ${table} VALUES ${rows.map(() => '()').join(', ')}`;\n }\n\n const quotedColumns = defaultColumns.map((column) => quoteIdentifier(column));\n const defaultRow = `(${defaultColumns.map(() => 'DEFAULT').join(', ')})`;\n return `INSERT INTO ${table} (${quotedColumns.join(', ')}) VALUES ${rows\n .map(() => defaultRow)\n .join(', ')}`;\n }\n\n const columnOrder = getInsertColumnOrder(rows, contract, ast.table.name);\n const columns = columnOrder.map((column) => quoteIdentifier(column));\n const values = rows\n .map((row) => {\n const renderedRow = columnOrder.map((column) => renderInsertValue(row[column], pim));\n return `(${renderedRow.join(', ')})`;\n })\n .join(', ');\n\n return `INSERT INTO ${table} (${columns.join(', ')}) VALUES ${values}`;\n })();\n const onConflictClause = ast.onConflict\n ? (() => {\n const conflictColumns = ast.onConflict.columns.map((col) => quoteIdentifier(col.column));\n if (conflictColumns.length === 0) {\n throw new Error('INSERT onConflict requires at least one conflict column');\n }\n\n const action = ast.onConflict.action;\n switch (action.kind) {\n case 'do-nothing':\n return ` ON CONFLICT (${conflictColumns.join(', ')}) DO NOTHING`;\n case 'do-update-set': {\n const updates = Object.entries(action.set).map(([colName, value]) => {\n const target = quoteIdentifier(colName);\n if (value.kind === 'param-ref') {\n return `${target} = ${renderParamRef(value, pim)}`;\n }\n return `${target} = ${renderColumn(value)}`;\n });\n return ` ON CONFLICT (${conflictColumns.join(', ')}) DO UPDATE SET ${updates.join(', ')}`;\n }\n // v8 ignore next 4\n default:\n throw new Error(\n `Unsupported onConflict action: ${(action satisfies never as { kind: string }).kind}`,\n );\n }\n })()\n : '';\n const returningClause = ast.returning?.length\n ? ` RETURNING ${ast.returning.map((col) => `${quoteIdentifier(col.table)}.${quoteIdentifier(col.column)}`).join(', ')}`\n : '';\n\n return `${insertClause}${onConflictClause}${returningClause}`;\n}\n\nfunction renderUpdate(ast: UpdateAst, contract: PostgresContract, pim?: ParamIndexMap): string {\n const table = quoteIdentifier(ast.table.name);\n const setClauses = Object.entries(ast.set).map(([col, val]) => {\n const column = quoteIdentifier(col);\n let value: string;\n switch (val.kind) {\n case 'param-ref':\n value = renderParamRef(val, pim);\n break;\n case 'column-ref':\n value = renderColumn(val);\n break;\n // v8 ignore next 4\n default:\n throw new Error(\n `Unsupported value node in UPDATE: ${(val satisfies never as { kind: string }).kind}`,\n );\n }\n return `${column} = ${value}`;\n });\n\n const whereClause = ast.where ? ` WHERE ${renderWhere(ast.where, contract, pim)}` : '';\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, pim?: ParamIndexMap): string {\n const table = quoteIdentifier(ast.table.name);\n const whereClause = ast.where ? ` WHERE ${renderWhere(ast.where, contract, pim)}` : '';\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":";;;;;;;AAoCA,MAAM,kBAAkB;AAExB,SAAS,kBAAkB,SAAiD;AAC1E,KAAI,YAAY,gBACd,QAAO;AAET,KAAI,YAAY,iBACd,QAAO;AAET,KAAI,YAAY,kBACd,QAAO;;AAKX,SAAS,iBAAiB,OAAe,SAAqC;CAC5E,MAAM,OAAO,kBAAkB,QAAQ;AACvC,QAAO,OAAO,IAAI,MAAM,IAAI,SAAS,IAAI;;AAK3C,MAAM,sBAAsB,OAAO,OAAO;CACxC,UAAU;EACR,SAAS;EACT,OAAO;EACP,SAAS;EACT,SAAS;EACT,WAAW;EACZ;CACD,KAAK;EACH,OAAO;EACP,WAAW;EACX,iBAAiB;EAClB;CACF,CAAC;AAOF,MAAMA,sBAA4D,OAAO,OAAO,iBAAiB,CAC9F,KAAK,eAAe,WAAW,MAAM,CACrC,QAAQ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Aa,IAAI;AACzB;GAEF,QACE,OAAM,IAAI,MACR,qCAAsC,IAAyC,OAChF;;AAEL,SAAO,GAAG,OAAO,KAAK;GACtB;CAEF,MAAM,cAAc,IAAI,QAAQ,UAAU,YAAY,IAAI,OAAO,UAAU,IAAI,KAAK;CACpF,MAAM,kBAAkB,IAAI,WAAW,SACnC,cAAc,IAAI,UAAU,KAAK,QAAQ,GAAG,gBAAgB,IAAI,MAAM,CAAC,GAAG,gBAAgB,IAAI,OAAO,GAAG,CAAC,KAAK,KAAK,KACnH;AAEJ,QAAO,UAAU,MAAM,OAAO,WAAW,KAAK,KAAK,GAAG,cAAc;;AAGtE,SAAS,aAAa,KAAgB,UAA6B,KAA6B;AAO9F,QAAO,eANO,gBAAgB,IAAI,MAAM,KAAK,GACzB,IAAI,QAAQ,UAAU,YAAY,IAAI,OAAO,UAAU,IAAI,KAAK,KAC5D,IAAI,WAAW,SACnC,cAAc,IAAI,UAAU,KAAK,QAAQ,GAAG,gBAAgB,IAAI,MAAM,CAAC,GAAG,gBAAgB,IAAI,OAAO,GAAG,CAAC,KAAK,KAAK,KACnH;;AAKN,SAAgB,sBAAsB,SAAkC;AACtE,QAAO,OAAO,OAAO,IAAI,oBAAoB,QAAQ,CAAC"}
@@ -1,4 +1,4 @@
1
- import { c as PostgresContract, l as PostgresLoweredStatement, s as PostgresAdapterOptions } from "./types-DxaTd7aP.mjs";
1
+ import { c as PostgresContract, l as PostgresLoweredStatement, s as PostgresAdapterOptions } from "./types-TyL62f9Y.mjs";
2
2
  import { Adapter, AdapterProfile, AnyQueryAst, CodecParamsDescriptor, LowererContext } from "@prisma-next/sql-relational-core/ast";
3
3
 
4
4
  //#region src/core/adapter.d.ts
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.d.mts","names":[],"sources":["../src/core/adapter.ts"],"sourcesContent":[],"mappings":";;;;cAyFM,mBAAA,YACO,QAAQ,aAAa,kBAAkB;;EAD9C,SAAA,QAAA,EAAA,UACJ;EAAmB,SAAA,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ANGED
@@ -1,3 +1,3 @@
1
- import { t as createPostgresAdapter } from "./adapter-7pXt8ej9.mjs";
1
+ import { t as createPostgresAdapter } from "./adapter-Du9Hr9Rl.mjs";
2
2
 
3
3
  export { createPostgresAdapter };
@@ -26,4 +26,4 @@ const PG_JSONB_CODEC_ID = "pg/jsonb@1";
26
26
 
27
27
  //#endregion
28
28
  export { SQL_CHAR_CODEC_ID as C, SQL_TIMESTAMP_CODEC_ID as D, SQL_TEXT_CODEC_ID as E, SQL_VARCHAR_CODEC_ID as O, PG_VARCHAR_CODEC_ID as S, SQL_INT_CODEC_ID as T, PG_TIMESTAMPTZ_CODEC_ID as _, PG_FLOAT4_CODEC_ID as a, PG_TIME_CODEC_ID as b, PG_INT2_CODEC_ID as c, PG_INTERVAL_CODEC_ID as d, PG_INT_CODEC_ID as f, PG_TEXT_CODEC_ID as g, PG_NUMERIC_CODEC_ID as h, PG_ENUM_CODEC_ID as i, PG_INT4_CODEC_ID as l, PG_JSON_CODEC_ID as m, PG_BOOL_CODEC_ID as n, PG_FLOAT8_CODEC_ID as o, PG_JSONB_CODEC_ID as p, PG_CHAR_CODEC_ID as r, PG_FLOAT_CODEC_ID as s, PG_BIT_CODEC_ID as t, PG_INT8_CODEC_ID as u, PG_TIMESTAMP_CODEC_ID as v, SQL_FLOAT_CODEC_ID as w, PG_VARBIT_CODEC_ID as x, PG_TIMETZ_CODEC_ID as y };
29
- //# sourceMappingURL=codec-ids-BwjcIf74.mjs.map
29
+ //# sourceMappingURL=codec-ids-5g4Gwrgm.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"codec-ids-BwjcIf74.mjs","names":[],"sources":["../src/core/codec-ids.ts"],"sourcesContent":["export {\n SQL_CHAR_CODEC_ID,\n SQL_FLOAT_CODEC_ID,\n SQL_INT_CODEC_ID,\n SQL_TEXT_CODEC_ID,\n SQL_TIMESTAMP_CODEC_ID,\n SQL_VARCHAR_CODEC_ID,\n} from '@prisma-next/sql-relational-core/ast';\nexport const PG_TEXT_CODEC_ID = 'pg/text@1' as const;\nexport const PG_ENUM_CODEC_ID = 'pg/enum@1' as const;\nexport const PG_CHAR_CODEC_ID = 'pg/char@1' as const;\nexport const PG_VARCHAR_CODEC_ID = 'pg/varchar@1' as const;\nexport const PG_INT_CODEC_ID = 'pg/int@1' as const;\nexport const PG_INT2_CODEC_ID = 'pg/int2@1' as const;\nexport const PG_INT4_CODEC_ID = 'pg/int4@1' as const;\nexport const PG_INT8_CODEC_ID = 'pg/int8@1' as const;\nexport const PG_FLOAT_CODEC_ID = 'pg/float@1' as const;\nexport const PG_FLOAT4_CODEC_ID = 'pg/float4@1' as const;\nexport const PG_FLOAT8_CODEC_ID = 'pg/float8@1' as const;\nexport const PG_NUMERIC_CODEC_ID = 'pg/numeric@1' as const;\nexport const PG_BOOL_CODEC_ID = 'pg/bool@1' as const;\nexport const PG_BIT_CODEC_ID = 'pg/bit@1' as const;\nexport const PG_VARBIT_CODEC_ID = 'pg/varbit@1' as const;\nexport const PG_TIMESTAMP_CODEC_ID = 'pg/timestamp@1' as const;\nexport const PG_TIMESTAMPTZ_CODEC_ID = 'pg/timestamptz@1' as const;\nexport const PG_TIME_CODEC_ID = 'pg/time@1' as const;\nexport const PG_TIMETZ_CODEC_ID = 'pg/timetz@1' as const;\nexport const PG_INTERVAL_CODEC_ID = 'pg/interval@1' as const;\nexport const PG_JSON_CODEC_ID = 'pg/json@1' as const;\nexport const PG_JSONB_CODEC_ID = 'pg/jsonb@1' as const;\n"],"mappings":";;;AAQA,MAAa,mBAAmB;AAChC,MAAa,mBAAmB;AAChC,MAAa,mBAAmB;AAChC,MAAa,sBAAsB;AACnC,MAAa,kBAAkB;AAC/B,MAAa,mBAAmB;AAChC,MAAa,mBAAmB;AAChC,MAAa,mBAAmB;AAChC,MAAa,oBAAoB;AACjC,MAAa,qBAAqB;AAClC,MAAa,qBAAqB;AAClC,MAAa,sBAAsB;AACnC,MAAa,mBAAmB;AAChC,MAAa,kBAAkB;AAC/B,MAAa,qBAAqB;AAClC,MAAa,wBAAwB;AACrC,MAAa,0BAA0B;AACvC,MAAa,mBAAmB;AAChC,MAAa,qBAAqB;AAClC,MAAa,uBAAuB;AACpC,MAAa,mBAAmB;AAChC,MAAa,oBAAoB"}
1
+ {"version":3,"file":"codec-ids-5g4Gwrgm.mjs","names":[],"sources":["../src/core/codec-ids.ts"],"sourcesContent":["export {\n SQL_CHAR_CODEC_ID,\n SQL_FLOAT_CODEC_ID,\n SQL_INT_CODEC_ID,\n SQL_TEXT_CODEC_ID,\n SQL_TIMESTAMP_CODEC_ID,\n SQL_VARCHAR_CODEC_ID,\n} from '@prisma-next/sql-relational-core/ast';\nexport const PG_TEXT_CODEC_ID = 'pg/text@1' as const;\nexport const PG_ENUM_CODEC_ID = 'pg/enum@1' as const;\nexport const PG_CHAR_CODEC_ID = 'pg/char@1' as const;\nexport const PG_VARCHAR_CODEC_ID = 'pg/varchar@1' as const;\nexport const PG_INT_CODEC_ID = 'pg/int@1' as const;\nexport const PG_INT2_CODEC_ID = 'pg/int2@1' as const;\nexport const PG_INT4_CODEC_ID = 'pg/int4@1' as const;\nexport const PG_INT8_CODEC_ID = 'pg/int8@1' as const;\nexport const PG_FLOAT_CODEC_ID = 'pg/float@1' as const;\nexport const PG_FLOAT4_CODEC_ID = 'pg/float4@1' as const;\nexport const PG_FLOAT8_CODEC_ID = 'pg/float8@1' as const;\nexport const PG_NUMERIC_CODEC_ID = 'pg/numeric@1' as const;\nexport const PG_BOOL_CODEC_ID = 'pg/bool@1' as const;\nexport const PG_BIT_CODEC_ID = 'pg/bit@1' as const;\nexport const PG_VARBIT_CODEC_ID = 'pg/varbit@1' as const;\nexport const PG_TIMESTAMP_CODEC_ID = 'pg/timestamp@1' as const;\nexport const PG_TIMESTAMPTZ_CODEC_ID = 'pg/timestamptz@1' as const;\nexport const PG_TIME_CODEC_ID = 'pg/time@1' as const;\nexport const PG_TIMETZ_CODEC_ID = 'pg/timetz@1' as const;\nexport const PG_INTERVAL_CODEC_ID = 'pg/interval@1' as const;\nexport const PG_JSON_CODEC_ID = 'pg/json@1' as const;\nexport const PG_JSONB_CODEC_ID = 'pg/jsonb@1' as const;\n"],"mappings":";;;AAQA,MAAa,mBAAmB;AAChC,MAAa,mBAAmB;AAChC,MAAa,mBAAmB;AAChC,MAAa,sBAAsB;AACnC,MAAa,kBAAkB;AAC/B,MAAa,mBAAmB;AAChC,MAAa,mBAAmB;AAChC,MAAa,mBAAmB;AAChC,MAAa,oBAAoB;AACjC,MAAa,qBAAqB;AAClC,MAAa,qBAAqB;AAClC,MAAa,sBAAsB;AACnC,MAAa,mBAAmB;AAChC,MAAa,kBAAkB;AAC/B,MAAa,qBAAqB;AAClC,MAAa,wBAAwB;AACrC,MAAa,0BAA0B;AACvC,MAAa,mBAAmB;AAChC,MAAa,qBAAqB;AAClC,MAAa,uBAAuB;AACpC,MAAa,mBAAmB;AAChC,MAAa,oBAAoB"}
@@ -1,3 +1,3 @@
1
- import { n as dataTypes } from "./codecs-C3wlpdV7.mjs";
1
+ import { n as dataTypes } from "./codecs-DiPlMi3-.mjs";
2
2
 
3
3
  export { dataTypes };
@@ -1,4 +1,4 @@
1
- import { S as PG_VARCHAR_CODEC_ID, _ as PG_TIMESTAMPTZ_CODEC_ID, a as PG_FLOAT4_CODEC_ID, b as PG_TIME_CODEC_ID, c as PG_INT2_CODEC_ID, d as PG_INTERVAL_CODEC_ID, f as PG_INT_CODEC_ID, g as PG_TEXT_CODEC_ID, h as PG_NUMERIC_CODEC_ID, i as PG_ENUM_CODEC_ID, l as PG_INT4_CODEC_ID, m as PG_JSON_CODEC_ID, n as PG_BOOL_CODEC_ID, o as PG_FLOAT8_CODEC_ID, p as PG_JSONB_CODEC_ID, r as PG_CHAR_CODEC_ID, s as PG_FLOAT_CODEC_ID, t as PG_BIT_CODEC_ID, u as PG_INT8_CODEC_ID, v as PG_TIMESTAMP_CODEC_ID, x as PG_VARBIT_CODEC_ID, y as PG_TIMETZ_CODEC_ID } from "./codec-ids-BwjcIf74.mjs";
1
+ import { S as PG_VARCHAR_CODEC_ID, _ as PG_TIMESTAMPTZ_CODEC_ID, a as PG_FLOAT4_CODEC_ID, b as PG_TIME_CODEC_ID, c as PG_INT2_CODEC_ID, d as PG_INTERVAL_CODEC_ID, f as PG_INT_CODEC_ID, g as PG_TEXT_CODEC_ID, h as PG_NUMERIC_CODEC_ID, i as PG_ENUM_CODEC_ID, l as PG_INT4_CODEC_ID, m as PG_JSON_CODEC_ID, n as PG_BOOL_CODEC_ID, o as PG_FLOAT8_CODEC_ID, p as PG_JSONB_CODEC_ID, r as PG_CHAR_CODEC_ID, s as PG_FLOAT_CODEC_ID, t as PG_BIT_CODEC_ID, u as PG_INT8_CODEC_ID, v as PG_TIMESTAMP_CODEC_ID, x as PG_VARBIT_CODEC_ID, y as PG_TIMETZ_CODEC_ID } from "./codec-ids-5g4Gwrgm.mjs";
2
2
  import { codec, defineCodecs, sqlCodecDefinitions } from "@prisma-next/sql-relational-core/ast";
3
3
  import { ifDefined } from "@prisma-next/utils/defined";
4
4
  import { type } from "arktype";
@@ -382,4 +382,4 @@ const dataTypes = codecs.dataTypes;
382
382
 
383
383
  //#endregion
384
384
  export { dataTypes as n, codecDefinitions as t };
385
- //# sourceMappingURL=codecs-C3wlpdV7.mjs.map
385
+ //# sourceMappingURL=codecs-DiPlMi3-.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"codecs-C3wlpdV7.mjs","names":["arktype"],"sources":["../src/core/json-schema-type-expression.ts","../src/core/codecs.ts"],"sourcesContent":["type JsonSchemaRecord = Record<string, unknown>;\n\nconst MAX_DEPTH = 32;\n\nfunction isRecord(value: unknown): value is JsonSchemaRecord {\n return typeof value === 'object' && value !== null;\n}\n\nfunction escapeStringLiteral(str: string): string {\n return str\n .replace(/\\\\/g, '\\\\\\\\')\n .replace(/'/g, \"\\\\'\")\n .replace(/\\n/g, '\\\\n')\n .replace(/\\r/g, '\\\\r');\n}\n\nfunction quotePropertyKey(key: string): string {\n return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key) ? key : `'${escapeStringLiteral(key)}'`;\n}\n\nfunction renderLiteral(value: unknown): string {\n if (typeof value === 'string') {\n return `'${escapeStringLiteral(value)}'`;\n }\n if (typeof value === 'number' || typeof value === 'boolean') {\n return String(value);\n }\n if (value === null) {\n return 'null';\n }\n return 'unknown';\n}\n\nfunction renderUnion(items: readonly unknown[], depth: number): string {\n const rendered = items.map((item) => render(item, depth));\n return rendered.join(' | ');\n}\n\nfunction renderObjectType(schema: JsonSchemaRecord, depth: number): string {\n const properties = isRecord(schema['properties']) ? schema['properties'] : {};\n const required = Array.isArray(schema['required'])\n ? new Set(schema['required'].filter((key): key is string => typeof key === 'string'))\n : new Set<string>();\n const keys = Object.keys(properties).sort((left, right) => left.localeCompare(right));\n\n if (keys.length === 0) {\n const additionalProperties = schema['additionalProperties'];\n if (additionalProperties === true || additionalProperties === undefined) {\n return 'Record<string, unknown>';\n }\n return `Record<string, ${render(additionalProperties, depth)}>`;\n }\n\n const renderedProperties = keys.map((key) => {\n const valueSchema = (properties as JsonSchemaRecord)[key];\n const optionalMarker = required.has(key) ? '' : '?';\n return `${quotePropertyKey(key)}${optionalMarker}: ${render(valueSchema, depth)}`;\n });\n\n return `{ ${renderedProperties.join('; ')} }`;\n}\n\nfunction renderArrayType(schema: JsonSchemaRecord, depth: number): string {\n if (Array.isArray(schema['items'])) {\n return `readonly [${schema['items'].map((item) => render(item, depth)).join(', ')}]`;\n }\n\n if (schema['items'] !== undefined) {\n const itemType = render(schema['items'], depth);\n const needsParens = itemType.includes(' | ') || itemType.includes(' & ');\n return needsParens ? `(${itemType})[]` : `${itemType}[]`;\n }\n\n return 'unknown[]';\n}\n\nfunction render(schema: unknown, depth: number): string {\n if (depth > MAX_DEPTH || !isRecord(schema)) {\n return 'JsonValue';\n }\n\n const nextDepth = depth + 1;\n\n if ('const' in schema) {\n return renderLiteral(schema['const']);\n }\n\n if (Array.isArray(schema['enum'])) {\n return schema['enum'].map((value) => renderLiteral(value)).join(' | ');\n }\n\n if (Array.isArray(schema['oneOf'])) {\n return renderUnion(schema['oneOf'], nextDepth);\n }\n\n if (Array.isArray(schema['anyOf'])) {\n return renderUnion(schema['anyOf'], nextDepth);\n }\n\n if (Array.isArray(schema['allOf'])) {\n return schema['allOf'].map((item) => render(item, nextDepth)).join(' & ');\n }\n\n if (Array.isArray(schema['type'])) {\n return schema['type'].map((item) => render({ ...schema, type: item }, nextDepth)).join(' | ');\n }\n\n switch (schema['type']) {\n case 'string':\n return 'string';\n case 'number':\n case 'integer':\n return 'number';\n case 'boolean':\n return 'boolean';\n case 'null':\n return 'null';\n case 'array':\n return renderArrayType(schema, nextDepth);\n case 'object':\n return renderObjectType(schema, nextDepth);\n default:\n break;\n }\n\n return 'JsonValue';\n}\n\nexport function renderTypeScriptTypeFromJsonSchema(schema: unknown): string {\n return render(schema, 0);\n}\n","/**\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 type { JsonValue } from '@prisma-next/contract/types';\nimport type { Codec, CodecMeta, CodecTrait } from '@prisma-next/sql-relational-core/ast';\nimport { codec, defineCodecs, sqlCodecDefinitions } from '@prisma-next/sql-relational-core/ast';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { type as arktype } from 'arktype';\nimport {\n PG_BIT_CODEC_ID,\n PG_BOOL_CODEC_ID,\n PG_CHAR_CODEC_ID,\n PG_ENUM_CODEC_ID,\n PG_FLOAT_CODEC_ID,\n PG_FLOAT4_CODEC_ID,\n PG_FLOAT8_CODEC_ID,\n PG_INT_CODEC_ID,\n PG_INT2_CODEC_ID,\n PG_INT4_CODEC_ID,\n PG_INT8_CODEC_ID,\n PG_INTERVAL_CODEC_ID,\n PG_JSON_CODEC_ID,\n PG_JSONB_CODEC_ID,\n PG_NUMERIC_CODEC_ID,\n PG_TEXT_CODEC_ID,\n PG_TIME_CODEC_ID,\n PG_TIMESTAMP_CODEC_ID,\n PG_TIMESTAMPTZ_CODEC_ID,\n PG_TIMETZ_CODEC_ID,\n PG_VARBIT_CODEC_ID,\n PG_VARCHAR_CODEC_ID,\n} from './codec-ids';\nimport { renderTypeScriptTypeFromJsonSchema } from './json-schema-type-expression';\n\nconst lengthParamsSchema = arktype({\n length: 'number.integer > 0',\n});\n\nconst numericParamsSchema = arktype({\n precision: 'number.integer > 0 & number.integer <= 1000',\n 'scale?': 'number.integer >= 0',\n});\n\nconst precisionParamsSchema = arktype({\n 'precision?': 'number.integer >= 0 & number.integer <= 6',\n});\n\nfunction renderLength(typeName: string, typeParams: Record<string, unknown>): string | undefined {\n const length = typeParams['length'];\n if (length === undefined) {\n return undefined;\n }\n if (typeof length !== 'number' || !Number.isFinite(length) || !Number.isInteger(length)) {\n throw new Error(\n `renderOutputType: expected integer \"length\" in typeParams for ${typeName}, got ${String(length)}`,\n );\n }\n return `${typeName}<${length}>`;\n}\n\nfunction renderPrecision(typeName: string, typeParams: Record<string, unknown>): string {\n const precision = typeParams['precision'];\n if (precision === undefined) {\n return typeName;\n }\n if (\n typeof precision !== 'number' ||\n !Number.isFinite(precision) ||\n !Number.isInteger(precision)\n ) {\n throw new Error(\n `renderOutputType: expected integer \"precision\" in typeParams for ${typeName}, got ${String(precision)}`,\n );\n }\n return `${typeName}<${precision}>`;\n}\n\nfunction renderJsonOutputType(typeParams: Record<string, unknown>): string {\n const typeName = typeParams['type'];\n if (typeof typeName === 'string' && typeName.trim().length > 0) {\n return typeName.trim();\n }\n const schema = typeParams['schemaJson'];\n if (schema && typeof schema === 'object') {\n return renderTypeScriptTypeFromJsonSchema(schema);\n }\n throw new Error(\n `renderOutputType: JSON codec typeParams must contain \"type\" (string) or \"schemaJson\" (object), got keys: ${Object.keys(typeParams).join(', ')}`,\n );\n}\n\nfunction aliasCodec<\n Id extends string,\n TTraits extends readonly CodecTrait[],\n TWire,\n TJs,\n TParams,\n THelper,\n>(\n base: Codec<string, TTraits, TWire, TJs, TParams, THelper>,\n options: {\n readonly typeId: Id;\n readonly targetTypes: readonly string[];\n readonly meta?: CodecMeta;\n },\n): Codec<Id, TTraits, TWire, TJs, TParams, THelper> {\n return {\n id: options.typeId,\n targetTypes: options.targetTypes,\n ...ifDefined('meta', options.meta),\n ...ifDefined('paramsSchema', base.paramsSchema),\n ...ifDefined('init', base.init),\n ...ifDefined('encode', base.encode),\n ...ifDefined('traits', base.traits),\n ...ifDefined('renderOutputType', base.renderOutputType),\n decode: base.decode,\n encodeJson: base.encodeJson,\n decodeJson: base.decodeJson,\n } as Codec<Id, TTraits, TWire, TJs, TParams, THelper>;\n}\n\nconst sqlCharCodec = sqlCodecDefinitions.char.codec;\nconst sqlVarcharCodec = sqlCodecDefinitions.varchar.codec;\nconst sqlIntCodec = sqlCodecDefinitions.int.codec;\nconst sqlFloatCodec = sqlCodecDefinitions.float.codec;\nconst sqlTextCodec = sqlCodecDefinitions.text.codec;\nconst sqlTimestampCodec = sqlCodecDefinitions.timestamp.codec;\n\n// Create individual codec instances\nconst pgTextCodec = codec({\n typeId: PG_TEXT_CODEC_ID,\n targetTypes: ['text'],\n traits: ['equality', 'order', 'textual'],\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 pgCharCodec = aliasCodec(sqlCharCodec, {\n typeId: PG_CHAR_CODEC_ID,\n targetTypes: ['character'],\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'character',\n },\n },\n },\n },\n});\n\nconst pgVarcharCodec = aliasCodec(sqlVarcharCodec, {\n typeId: PG_VARCHAR_CODEC_ID,\n targetTypes: ['character varying'],\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'character varying',\n },\n },\n },\n },\n});\n\nconst pgIntCodec = aliasCodec(sqlIntCodec, {\n typeId: PG_INT_CODEC_ID,\n targetTypes: ['int4'],\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'integer',\n },\n },\n },\n },\n});\n\nconst pgFloatCodec = aliasCodec(sqlFloatCodec, {\n typeId: PG_FLOAT_CODEC_ID,\n targetTypes: ['float8'],\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'double precision',\n },\n },\n },\n },\n});\n\nconst pgInt4Codec = codec({\n typeId: PG_INT4_CODEC_ID,\n targetTypes: ['int4'],\n traits: ['equality', 'order', 'numeric'],\n encode: (value: number): number => value,\n decode: (wire: number): number => wire,\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'integer',\n },\n },\n },\n },\n});\n\nconst pgNumericCodec = codec<\n typeof PG_NUMERIC_CODEC_ID,\n readonly ['equality', 'order', 'numeric'],\n string,\n string\n>({\n typeId: PG_NUMERIC_CODEC_ID,\n targetTypes: ['numeric', 'decimal'],\n traits: ['equality', 'order', 'numeric'],\n encode: (value: string): string => value,\n decode: (wire: string | number): string => {\n if (typeof wire === 'number') return String(wire);\n return wire;\n },\n paramsSchema: numericParamsSchema,\n renderOutputType: (typeParams) => {\n const precision = typeParams['precision'];\n if (precision === undefined) return undefined;\n if (\n typeof precision !== 'number' ||\n !Number.isFinite(precision) ||\n !Number.isInteger(precision)\n ) {\n throw new Error(\n `renderOutputType: expected integer \"precision\" in typeParams for Numeric, got ${String(precision)}`,\n );\n }\n const scale = typeParams['scale'];\n return typeof scale === 'number' ? `Numeric<${precision}, ${scale}>` : `Numeric<${precision}>`;\n },\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'numeric',\n },\n },\n },\n },\n});\n\nconst pgInt2Codec = codec({\n typeId: PG_INT2_CODEC_ID,\n targetTypes: ['int2'],\n traits: ['equality', 'order', 'numeric'],\n encode: (value: number): number => value,\n decode: (wire: number): number => wire,\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'smallint',\n },\n },\n },\n },\n});\n\nconst pgInt8Codec = codec({\n typeId: PG_INT8_CODEC_ID,\n targetTypes: ['int8'],\n traits: ['equality', 'order', 'numeric'],\n encode: (value: number): number => value,\n decode: (wire: number): number => wire,\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'bigint',\n },\n },\n },\n },\n});\n\nconst pgFloat4Codec = codec({\n typeId: PG_FLOAT4_CODEC_ID,\n targetTypes: ['float4'],\n traits: ['equality', 'order', 'numeric'],\n encode: (value: number): number => value,\n decode: (wire: number): number => wire,\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'real',\n },\n },\n },\n },\n});\n\nconst pgFloat8Codec = codec({\n typeId: PG_FLOAT8_CODEC_ID,\n targetTypes: ['float8'],\n traits: ['equality', 'order', 'numeric'],\n encode: (value: number): number => value,\n decode: (wire: number): number => wire,\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'double precision',\n },\n },\n },\n },\n});\n\nconst pgTimestampCodec = codec<\n typeof PG_TIMESTAMP_CODEC_ID,\n readonly ['equality', 'order'],\n string | Date,\n string | Date\n>({\n typeId: PG_TIMESTAMP_CODEC_ID,\n targetTypes: ['timestamp'],\n traits: ['equality', 'order'],\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 (wire instanceof Date) return wire.toISOString();\n return wire;\n },\n encodeJson: (value: string | Date) => (value instanceof Date ? value.toISOString() : value),\n decodeJson: (json) => {\n if (typeof json !== 'string') {\n throw new Error(`Expected ISO date string for pg/timestamp@1, got ${typeof json}`);\n }\n const date = new Date(json);\n if (Number.isNaN(date.getTime())) {\n throw new Error(`Invalid ISO date string for pg/timestamp@1: ${json}`);\n }\n return date;\n },\n paramsSchema: precisionParamsSchema,\n renderOutputType: (typeParams) => renderPrecision('Timestamp', typeParams),\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'timestamp without time zone',\n },\n },\n },\n },\n});\n\nconst pgTimestamptzCodec = codec<\n typeof PG_TIMESTAMPTZ_CODEC_ID,\n readonly ['equality', 'order'],\n string | Date,\n string | Date\n>({\n typeId: PG_TIMESTAMPTZ_CODEC_ID,\n targetTypes: ['timestamptz'],\n traits: ['equality', 'order'],\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 (wire instanceof Date) return wire.toISOString();\n return wire;\n },\n encodeJson: (value: string | Date) => (value instanceof Date ? value.toISOString() : value),\n decodeJson: (json) => {\n if (typeof json !== 'string') {\n throw new Error(`Expected ISO date string for pg/timestamptz@1, got ${typeof json}`);\n }\n const date = new Date(json);\n if (Number.isNaN(date.getTime())) {\n throw new Error(`Invalid ISO date string for pg/timestamptz@1: ${json}`);\n }\n return date;\n },\n paramsSchema: precisionParamsSchema,\n renderOutputType: (typeParams) => renderPrecision('Timestamptz', typeParams),\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'timestamp with time zone',\n },\n },\n },\n },\n});\n\nconst pgTimeCodec = codec<typeof PG_TIME_CODEC_ID, readonly ['equality', 'order'], string, string>({\n typeId: PG_TIME_CODEC_ID,\n targetTypes: ['time'],\n traits: ['equality', 'order'],\n encode: (value: string): string => value,\n decode: (wire: string): string => wire,\n paramsSchema: precisionParamsSchema,\n renderOutputType: (typeParams) => renderPrecision('Time', typeParams),\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'time',\n },\n },\n },\n },\n});\n\nconst pgTimetzCodec = codec<\n typeof PG_TIMETZ_CODEC_ID,\n readonly ['equality', 'order'],\n string,\n string\n>({\n typeId: PG_TIMETZ_CODEC_ID,\n targetTypes: ['timetz'],\n traits: ['equality', 'order'],\n encode: (value: string): string => value,\n decode: (wire: string): string => wire,\n paramsSchema: precisionParamsSchema,\n renderOutputType: (typeParams) => renderPrecision('Timetz', typeParams),\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'timetz',\n },\n },\n },\n },\n});\n\nconst pgBoolCodec = codec({\n typeId: PG_BOOL_CODEC_ID,\n targetTypes: ['bool'],\n traits: ['equality', 'boolean'],\n encode: (value: boolean): boolean => value,\n decode: (wire: boolean): boolean => wire,\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'boolean',\n },\n },\n },\n },\n});\n\nconst pgBitCodec = codec<typeof PG_BIT_CODEC_ID, readonly ['equality', 'order'], string, string>({\n typeId: PG_BIT_CODEC_ID,\n targetTypes: ['bit'],\n traits: ['equality', 'order'],\n encode: (value: string): string => value,\n decode: (wire: string): string => wire,\n paramsSchema: lengthParamsSchema,\n renderOutputType: (typeParams) => renderLength('Bit', typeParams),\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'bit',\n },\n },\n },\n },\n});\n\nconst pgVarbitCodec = codec<\n typeof PG_VARBIT_CODEC_ID,\n readonly ['equality', 'order'],\n string,\n string\n>({\n typeId: PG_VARBIT_CODEC_ID,\n targetTypes: ['bit varying'],\n traits: ['equality', 'order'],\n encode: (value: string): string => value,\n decode: (wire: string): string => wire,\n paramsSchema: lengthParamsSchema,\n renderOutputType: (typeParams) => renderLength('VarBit', typeParams),\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'bit varying',\n },\n },\n },\n },\n});\n\nconst pgEnumCodec = codec({\n typeId: PG_ENUM_CODEC_ID,\n targetTypes: ['enum'],\n traits: ['equality', 'order'],\n encode: (value: string): string => value,\n decode: (wire: string): string => wire,\n renderOutputType: (typeParams) => {\n const values = typeParams['values'];\n if (!Array.isArray(values)) {\n throw new Error(\n `renderOutputType: expected array \"values\" in typeParams for enum, got ${typeof values}`,\n );\n }\n return values\n .map((value) => `'${String(value).replace(/\\\\/g, '\\\\\\\\').replace(/'/g, \"\\\\'\")}'`)\n .join(' | ');\n },\n});\n\nconst pgIntervalCodec = codec<\n typeof PG_INTERVAL_CODEC_ID,\n readonly ['equality', 'order'],\n string | Record<string, unknown>,\n string\n>({\n typeId: PG_INTERVAL_CODEC_ID,\n targetTypes: ['interval'],\n traits: ['equality', 'order'],\n encode: (value: string): string => value,\n decode: (wire: string | Record<string, unknown>): string => {\n if (typeof wire === 'string') return wire;\n return JSON.stringify(wire);\n },\n paramsSchema: precisionParamsSchema,\n renderOutputType: (typeParams) => renderPrecision('Interval', typeParams),\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'interval',\n },\n },\n },\n },\n});\n\nconst pgJsonCodec = codec({\n typeId: PG_JSON_CODEC_ID,\n targetTypes: ['json'],\n traits: [],\n encode: (value: string | JsonValue): string => JSON.stringify(value),\n decode: (wire: string | JsonValue): JsonValue =>\n typeof wire === 'string' ? JSON.parse(wire) : wire,\n renderOutputType: renderJsonOutputType,\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'json',\n },\n },\n },\n },\n});\n\nconst pgJsonbCodec = codec({\n typeId: PG_JSONB_CODEC_ID,\n targetTypes: ['jsonb'],\n traits: ['equality'],\n encode: (value: string | JsonValue): string => JSON.stringify(value),\n decode: (wire: string | JsonValue): JsonValue =>\n typeof wire === 'string' ? JSON.parse(wire) : wire,\n renderOutputType: renderJsonOutputType,\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'jsonb',\n },\n },\n },\n },\n});\n\n// Build codec definitions using the builder DSL\nconst codecs = defineCodecs()\n .add('char', sqlCharCodec)\n .add('varchar', sqlVarcharCodec)\n .add('int', sqlIntCodec)\n .add('float', sqlFloatCodec)\n .add('sql-text', sqlTextCodec)\n .add('sql-timestamp', sqlTimestampCodec)\n .add('text', pgTextCodec)\n .add('character', pgCharCodec)\n .add('character varying', pgVarcharCodec)\n .add('integer', pgIntCodec)\n .add('double precision', pgFloatCodec)\n .add('int4', pgInt4Codec)\n .add('int2', pgInt2Codec)\n .add('int8', pgInt8Codec)\n .add('float4', pgFloat4Codec)\n .add('float8', pgFloat8Codec)\n .add('numeric', pgNumericCodec)\n .add('timestamp', pgTimestampCodec)\n .add('timestamptz', pgTimestamptzCodec)\n .add('time', pgTimeCodec)\n .add('timetz', pgTimetzCodec)\n .add('bool', pgBoolCodec)\n .add('bit', pgBitCodec)\n .add('bit varying', pgVarbitCodec)\n .add('interval', pgIntervalCodec)\n .add('enum', pgEnumCodec)\n .add('json', pgJsonCodec)\n .add('jsonb', pgJsonbCodec);\n\n// Export derived structures directly from codecs builder\nexport const codecDefinitions = codecs.codecDefinitions;\nexport const dataTypes = codecs.dataTypes;\n\nexport type CodecTypes = typeof codecs.CodecTypes;\n"],"mappings":";;;;;;AAEA,MAAM,YAAY;AAElB,SAAS,SAAS,OAA2C;AAC3D,QAAO,OAAO,UAAU,YAAY,UAAU;;AAGhD,SAAS,oBAAoB,KAAqB;AAChD,QAAO,IACJ,QAAQ,OAAO,OAAO,CACtB,QAAQ,MAAM,MAAM,CACpB,QAAQ,OAAO,MAAM,CACrB,QAAQ,OAAO,MAAM;;AAG1B,SAAS,iBAAiB,KAAqB;AAC7C,QAAO,6BAA6B,KAAK,IAAI,GAAG,MAAM,IAAI,oBAAoB,IAAI,CAAC;;AAGrF,SAAS,cAAc,OAAwB;AAC7C,KAAI,OAAO,UAAU,SACnB,QAAO,IAAI,oBAAoB,MAAM,CAAC;AAExC,KAAI,OAAO,UAAU,YAAY,OAAO,UAAU,UAChD,QAAO,OAAO,MAAM;AAEtB,KAAI,UAAU,KACZ,QAAO;AAET,QAAO;;AAGT,SAAS,YAAY,OAA2B,OAAuB;AAErE,QADiB,MAAM,KAAK,SAAS,OAAO,MAAM,MAAM,CAAC,CACzC,KAAK,MAAM;;AAG7B,SAAS,iBAAiB,QAA0B,OAAuB;CACzE,MAAM,aAAa,SAAS,OAAO,cAAc,GAAG,OAAO,gBAAgB,EAAE;CAC7E,MAAM,WAAW,MAAM,QAAQ,OAAO,YAAY,GAC9C,IAAI,IAAI,OAAO,YAAY,QAAQ,QAAuB,OAAO,QAAQ,SAAS,CAAC,mBACnF,IAAI,KAAa;CACrB,MAAM,OAAO,OAAO,KAAK,WAAW,CAAC,MAAM,MAAM,UAAU,KAAK,cAAc,MAAM,CAAC;AAErF,KAAI,KA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AU,EACR,YAAY,SACb,EACF,EACF,EACF;CACF,CAAC;AAGF,MAAM,SAAS,cAAc,CAC1B,IAAI,QAAQ,aAAa,CACzB,IAAI,WAAW,gBAAgB,CAC/B,IAAI,OAAO,YAAY,CACvB,IAAI,SAAS,cAAc,CAC3B,IAAI,YAAY,aAAa,CAC7B,IAAI,iBAAiB,kBAAkB,CACvC,IAAI,QAAQ,YAAY,CACxB,IAAI,aAAa,YAAY,CAC7B,IAAI,qBAAqB,eAAe,CACxC,IAAI,WAAW,WAAW,CAC1B,IAAI,oBAAoB,aAAa,CACrC,IAAI,QAAQ,YAAY,CACxB,IAAI,QAAQ,YAAY,CACxB,IAAI,QAAQ,YAAY,CACxB,IAAI,UAAU,cAAc,CAC5B,IAAI,UAAU,cAAc,CAC5B,IAAI,WAAW,eAAe,CAC9B,IAAI,aAAa,iBAAiB,CAClC,IAAI,eAAe,mBAAmB,CACtC,IAAI,QAAQ,YAAY,CACxB,IAAI,UAAU,cAAc,CAC5B,IAAI,QAAQ,YAAY,CACxB,IAAI,OAAO,WAAW,CACtB,IAAI,eAAe,cAAc,CACjC,IAAI,YAAY,gBAAgB,CAChC,IAAI,QAAQ,YAAY,CACxB,IAAI,QAAQ,YAAY,CACxB,IAAI,SAAS,aAAa;AAG7B,MAAa,mBAAmB,OAAO;AACvC,MAAa,YAAY,OAAO"}
1
+ {"version":3,"file":"codecs-DiPlMi3-.mjs","names":["arktype"],"sources":["../src/core/json-schema-type-expression.ts","../src/core/codecs.ts"],"sourcesContent":["type JsonSchemaRecord = Record<string, unknown>;\n\nconst MAX_DEPTH = 32;\n\nfunction isRecord(value: unknown): value is JsonSchemaRecord {\n return typeof value === 'object' && value !== null;\n}\n\nfunction escapeStringLiteral(str: string): string {\n return str\n .replace(/\\\\/g, '\\\\\\\\')\n .replace(/'/g, \"\\\\'\")\n .replace(/\\n/g, '\\\\n')\n .replace(/\\r/g, '\\\\r');\n}\n\nfunction quotePropertyKey(key: string): string {\n return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key) ? key : `'${escapeStringLiteral(key)}'`;\n}\n\nfunction renderLiteral(value: unknown): string {\n if (typeof value === 'string') {\n return `'${escapeStringLiteral(value)}'`;\n }\n if (typeof value === 'number' || typeof value === 'boolean') {\n return String(value);\n }\n if (value === null) {\n return 'null';\n }\n return 'unknown';\n}\n\nfunction renderUnion(items: readonly unknown[], depth: number): string {\n const rendered = items.map((item) => render(item, depth));\n return rendered.join(' | ');\n}\n\nfunction renderObjectType(schema: JsonSchemaRecord, depth: number): string {\n const properties = isRecord(schema['properties']) ? schema['properties'] : {};\n const required = Array.isArray(schema['required'])\n ? new Set(schema['required'].filter((key): key is string => typeof key === 'string'))\n : new Set<string>();\n const keys = Object.keys(properties).sort((left, right) => left.localeCompare(right));\n\n if (keys.length === 0) {\n const additionalProperties = schema['additionalProperties'];\n if (additionalProperties === true || additionalProperties === undefined) {\n return 'Record<string, unknown>';\n }\n return `Record<string, ${render(additionalProperties, depth)}>`;\n }\n\n const renderedProperties = keys.map((key) => {\n const valueSchema = (properties as JsonSchemaRecord)[key];\n const optionalMarker = required.has(key) ? '' : '?';\n return `${quotePropertyKey(key)}${optionalMarker}: ${render(valueSchema, depth)}`;\n });\n\n return `{ ${renderedProperties.join('; ')} }`;\n}\n\nfunction renderArrayType(schema: JsonSchemaRecord, depth: number): string {\n if (Array.isArray(schema['items'])) {\n return `readonly [${schema['items'].map((item) => render(item, depth)).join(', ')}]`;\n }\n\n if (schema['items'] !== undefined) {\n const itemType = render(schema['items'], depth);\n const needsParens = itemType.includes(' | ') || itemType.includes(' & ');\n return needsParens ? `(${itemType})[]` : `${itemType}[]`;\n }\n\n return 'unknown[]';\n}\n\nfunction render(schema: unknown, depth: number): string {\n if (depth > MAX_DEPTH || !isRecord(schema)) {\n return 'JsonValue';\n }\n\n const nextDepth = depth + 1;\n\n if ('const' in schema) {\n return renderLiteral(schema['const']);\n }\n\n if (Array.isArray(schema['enum'])) {\n return schema['enum'].map((value) => renderLiteral(value)).join(' | ');\n }\n\n if (Array.isArray(schema['oneOf'])) {\n return renderUnion(schema['oneOf'], nextDepth);\n }\n\n if (Array.isArray(schema['anyOf'])) {\n return renderUnion(schema['anyOf'], nextDepth);\n }\n\n if (Array.isArray(schema['allOf'])) {\n return schema['allOf'].map((item) => render(item, nextDepth)).join(' & ');\n }\n\n if (Array.isArray(schema['type'])) {\n return schema['type'].map((item) => render({ ...schema, type: item }, nextDepth)).join(' | ');\n }\n\n switch (schema['type']) {\n case 'string':\n return 'string';\n case 'number':\n case 'integer':\n return 'number';\n case 'boolean':\n return 'boolean';\n case 'null':\n return 'null';\n case 'array':\n return renderArrayType(schema, nextDepth);\n case 'object':\n return renderObjectType(schema, nextDepth);\n default:\n break;\n }\n\n return 'JsonValue';\n}\n\nexport function renderTypeScriptTypeFromJsonSchema(schema: unknown): string {\n return render(schema, 0);\n}\n","/**\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 type { JsonValue } from '@prisma-next/contract/types';\nimport type { Codec, CodecMeta, CodecTrait } from '@prisma-next/sql-relational-core/ast';\nimport { codec, defineCodecs, sqlCodecDefinitions } from '@prisma-next/sql-relational-core/ast';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { type as arktype } from 'arktype';\nimport {\n PG_BIT_CODEC_ID,\n PG_BOOL_CODEC_ID,\n PG_CHAR_CODEC_ID,\n PG_ENUM_CODEC_ID,\n PG_FLOAT_CODEC_ID,\n PG_FLOAT4_CODEC_ID,\n PG_FLOAT8_CODEC_ID,\n PG_INT_CODEC_ID,\n PG_INT2_CODEC_ID,\n PG_INT4_CODEC_ID,\n PG_INT8_CODEC_ID,\n PG_INTERVAL_CODEC_ID,\n PG_JSON_CODEC_ID,\n PG_JSONB_CODEC_ID,\n PG_NUMERIC_CODEC_ID,\n PG_TEXT_CODEC_ID,\n PG_TIME_CODEC_ID,\n PG_TIMESTAMP_CODEC_ID,\n PG_TIMESTAMPTZ_CODEC_ID,\n PG_TIMETZ_CODEC_ID,\n PG_VARBIT_CODEC_ID,\n PG_VARCHAR_CODEC_ID,\n} from './codec-ids';\nimport { renderTypeScriptTypeFromJsonSchema } from './json-schema-type-expression';\n\nconst lengthParamsSchema = arktype({\n length: 'number.integer > 0',\n});\n\nconst numericParamsSchema = arktype({\n precision: 'number.integer > 0 & number.integer <= 1000',\n 'scale?': 'number.integer >= 0',\n});\n\nconst precisionParamsSchema = arktype({\n 'precision?': 'number.integer >= 0 & number.integer <= 6',\n});\n\nfunction renderLength(typeName: string, typeParams: Record<string, unknown>): string | undefined {\n const length = typeParams['length'];\n if (length === undefined) {\n return undefined;\n }\n if (typeof length !== 'number' || !Number.isFinite(length) || !Number.isInteger(length)) {\n throw new Error(\n `renderOutputType: expected integer \"length\" in typeParams for ${typeName}, got ${String(length)}`,\n );\n }\n return `${typeName}<${length}>`;\n}\n\nfunction renderPrecision(typeName: string, typeParams: Record<string, unknown>): string {\n const precision = typeParams['precision'];\n if (precision === undefined) {\n return typeName;\n }\n if (\n typeof precision !== 'number' ||\n !Number.isFinite(precision) ||\n !Number.isInteger(precision)\n ) {\n throw new Error(\n `renderOutputType: expected integer \"precision\" in typeParams for ${typeName}, got ${String(precision)}`,\n );\n }\n return `${typeName}<${precision}>`;\n}\n\nfunction renderJsonOutputType(typeParams: Record<string, unknown>): string {\n const typeName = typeParams['type'];\n if (typeof typeName === 'string' && typeName.trim().length > 0) {\n return typeName.trim();\n }\n const schema = typeParams['schemaJson'];\n if (schema && typeof schema === 'object') {\n return renderTypeScriptTypeFromJsonSchema(schema);\n }\n throw new Error(\n `renderOutputType: JSON codec typeParams must contain \"type\" (string) or \"schemaJson\" (object), got keys: ${Object.keys(typeParams).join(', ')}`,\n );\n}\n\nfunction aliasCodec<\n Id extends string,\n TTraits extends readonly CodecTrait[],\n TWire,\n TJs,\n TParams,\n THelper,\n>(\n base: Codec<string, TTraits, TWire, TJs, TParams, THelper>,\n options: {\n readonly typeId: Id;\n readonly targetTypes: readonly string[];\n readonly meta?: CodecMeta;\n },\n): Codec<Id, TTraits, TWire, TJs, TParams, THelper> {\n return {\n id: options.typeId,\n targetTypes: options.targetTypes,\n ...ifDefined('meta', options.meta),\n ...ifDefined('paramsSchema', base.paramsSchema),\n ...ifDefined('init', base.init),\n ...ifDefined('encode', base.encode),\n ...ifDefined('traits', base.traits),\n ...ifDefined('renderOutputType', base.renderOutputType),\n decode: base.decode,\n encodeJson: base.encodeJson,\n decodeJson: base.decodeJson,\n } as Codec<Id, TTraits, TWire, TJs, TParams, THelper>;\n}\n\nconst sqlCharCodec = sqlCodecDefinitions.char.codec;\nconst sqlVarcharCodec = sqlCodecDefinitions.varchar.codec;\nconst sqlIntCodec = sqlCodecDefinitions.int.codec;\nconst sqlFloatCodec = sqlCodecDefinitions.float.codec;\nconst sqlTextCodec = sqlCodecDefinitions.text.codec;\nconst sqlTimestampCodec = sqlCodecDefinitions.timestamp.codec;\n\n// Create individual codec instances\nconst pgTextCodec = codec({\n typeId: PG_TEXT_CODEC_ID,\n targetTypes: ['text'],\n traits: ['equality', 'order', 'textual'],\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 pgCharCodec = aliasCodec(sqlCharCodec, {\n typeId: PG_CHAR_CODEC_ID,\n targetTypes: ['character'],\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'character',\n },\n },\n },\n },\n});\n\nconst pgVarcharCodec = aliasCodec(sqlVarcharCodec, {\n typeId: PG_VARCHAR_CODEC_ID,\n targetTypes: ['character varying'],\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'character varying',\n },\n },\n },\n },\n});\n\nconst pgIntCodec = aliasCodec(sqlIntCodec, {\n typeId: PG_INT_CODEC_ID,\n targetTypes: ['int4'],\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'integer',\n },\n },\n },\n },\n});\n\nconst pgFloatCodec = aliasCodec(sqlFloatCodec, {\n typeId: PG_FLOAT_CODEC_ID,\n targetTypes: ['float8'],\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'double precision',\n },\n },\n },\n },\n});\n\nconst pgInt4Codec = codec({\n typeId: PG_INT4_CODEC_ID,\n targetTypes: ['int4'],\n traits: ['equality', 'order', 'numeric'],\n encode: (value: number): number => value,\n decode: (wire: number): number => wire,\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'integer',\n },\n },\n },\n },\n});\n\nconst pgNumericCodec = codec<\n typeof PG_NUMERIC_CODEC_ID,\n readonly ['equality', 'order', 'numeric'],\n string,\n string\n>({\n typeId: PG_NUMERIC_CODEC_ID,\n targetTypes: ['numeric', 'decimal'],\n traits: ['equality', 'order', 'numeric'],\n encode: (value: string): string => value,\n decode: (wire: string | number): string => {\n if (typeof wire === 'number') return String(wire);\n return wire;\n },\n paramsSchema: numericParamsSchema,\n renderOutputType: (typeParams) => {\n const precision = typeParams['precision'];\n if (precision === undefined) return undefined;\n if (\n typeof precision !== 'number' ||\n !Number.isFinite(precision) ||\n !Number.isInteger(precision)\n ) {\n throw new Error(\n `renderOutputType: expected integer \"precision\" in typeParams for Numeric, got ${String(precision)}`,\n );\n }\n const scale = typeParams['scale'];\n return typeof scale === 'number' ? `Numeric<${precision}, ${scale}>` : `Numeric<${precision}>`;\n },\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'numeric',\n },\n },\n },\n },\n});\n\nconst pgInt2Codec = codec({\n typeId: PG_INT2_CODEC_ID,\n targetTypes: ['int2'],\n traits: ['equality', 'order', 'numeric'],\n encode: (value: number): number => value,\n decode: (wire: number): number => wire,\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'smallint',\n },\n },\n },\n },\n});\n\nconst pgInt8Codec = codec({\n typeId: PG_INT8_CODEC_ID,\n targetTypes: ['int8'],\n traits: ['equality', 'order', 'numeric'],\n encode: (value: number): number => value,\n decode: (wire: number): number => wire,\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'bigint',\n },\n },\n },\n },\n});\n\nconst pgFloat4Codec = codec({\n typeId: PG_FLOAT4_CODEC_ID,\n targetTypes: ['float4'],\n traits: ['equality', 'order', 'numeric'],\n encode: (value: number): number => value,\n decode: (wire: number): number => wire,\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'real',\n },\n },\n },\n },\n});\n\nconst pgFloat8Codec = codec({\n typeId: PG_FLOAT8_CODEC_ID,\n targetTypes: ['float8'],\n traits: ['equality', 'order', 'numeric'],\n encode: (value: number): number => value,\n decode: (wire: number): number => wire,\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'double precision',\n },\n },\n },\n },\n});\n\nconst pgTimestampCodec = codec<\n typeof PG_TIMESTAMP_CODEC_ID,\n readonly ['equality', 'order'],\n string | Date,\n string | Date\n>({\n typeId: PG_TIMESTAMP_CODEC_ID,\n targetTypes: ['timestamp'],\n traits: ['equality', 'order'],\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 (wire instanceof Date) return wire.toISOString();\n return wire;\n },\n encodeJson: (value: string | Date) => (value instanceof Date ? value.toISOString() : value),\n decodeJson: (json) => {\n if (typeof json !== 'string') {\n throw new Error(`Expected ISO date string for pg/timestamp@1, got ${typeof json}`);\n }\n const date = new Date(json);\n if (Number.isNaN(date.getTime())) {\n throw new Error(`Invalid ISO date string for pg/timestamp@1: ${json}`);\n }\n return date;\n },\n paramsSchema: precisionParamsSchema,\n renderOutputType: (typeParams) => renderPrecision('Timestamp', typeParams),\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'timestamp without time zone',\n },\n },\n },\n },\n});\n\nconst pgTimestamptzCodec = codec<\n typeof PG_TIMESTAMPTZ_CODEC_ID,\n readonly ['equality', 'order'],\n string | Date,\n string | Date\n>({\n typeId: PG_TIMESTAMPTZ_CODEC_ID,\n targetTypes: ['timestamptz'],\n traits: ['equality', 'order'],\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 (wire instanceof Date) return wire.toISOString();\n return wire;\n },\n encodeJson: (value: string | Date) => (value instanceof Date ? value.toISOString() : value),\n decodeJson: (json) => {\n if (typeof json !== 'string') {\n throw new Error(`Expected ISO date string for pg/timestamptz@1, got ${typeof json}`);\n }\n const date = new Date(json);\n if (Number.isNaN(date.getTime())) {\n throw new Error(`Invalid ISO date string for pg/timestamptz@1: ${json}`);\n }\n return date;\n },\n paramsSchema: precisionParamsSchema,\n renderOutputType: (typeParams) => renderPrecision('Timestamptz', typeParams),\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'timestamp with time zone',\n },\n },\n },\n },\n});\n\nconst pgTimeCodec = codec<typeof PG_TIME_CODEC_ID, readonly ['equality', 'order'], string, string>({\n typeId: PG_TIME_CODEC_ID,\n targetTypes: ['time'],\n traits: ['equality', 'order'],\n encode: (value: string): string => value,\n decode: (wire: string): string => wire,\n paramsSchema: precisionParamsSchema,\n renderOutputType: (typeParams) => renderPrecision('Time', typeParams),\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'time',\n },\n },\n },\n },\n});\n\nconst pgTimetzCodec = codec<\n typeof PG_TIMETZ_CODEC_ID,\n readonly ['equality', 'order'],\n string,\n string\n>({\n typeId: PG_TIMETZ_CODEC_ID,\n targetTypes: ['timetz'],\n traits: ['equality', 'order'],\n encode: (value: string): string => value,\n decode: (wire: string): string => wire,\n paramsSchema: precisionParamsSchema,\n renderOutputType: (typeParams) => renderPrecision('Timetz', typeParams),\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'timetz',\n },\n },\n },\n },\n});\n\nconst pgBoolCodec = codec({\n typeId: PG_BOOL_CODEC_ID,\n targetTypes: ['bool'],\n traits: ['equality', 'boolean'],\n encode: (value: boolean): boolean => value,\n decode: (wire: boolean): boolean => wire,\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'boolean',\n },\n },\n },\n },\n});\n\nconst pgBitCodec = codec<typeof PG_BIT_CODEC_ID, readonly ['equality', 'order'], string, string>({\n typeId: PG_BIT_CODEC_ID,\n targetTypes: ['bit'],\n traits: ['equality', 'order'],\n encode: (value: string): string => value,\n decode: (wire: string): string => wire,\n paramsSchema: lengthParamsSchema,\n renderOutputType: (typeParams) => renderLength('Bit', typeParams),\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'bit',\n },\n },\n },\n },\n});\n\nconst pgVarbitCodec = codec<\n typeof PG_VARBIT_CODEC_ID,\n readonly ['equality', 'order'],\n string,\n string\n>({\n typeId: PG_VARBIT_CODEC_ID,\n targetTypes: ['bit varying'],\n traits: ['equality', 'order'],\n encode: (value: string): string => value,\n decode: (wire: string): string => wire,\n paramsSchema: lengthParamsSchema,\n renderOutputType: (typeParams) => renderLength('VarBit', typeParams),\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'bit varying',\n },\n },\n },\n },\n});\n\nconst pgEnumCodec = codec({\n typeId: PG_ENUM_CODEC_ID,\n targetTypes: ['enum'],\n traits: ['equality', 'order'],\n encode: (value: string): string => value,\n decode: (wire: string): string => wire,\n renderOutputType: (typeParams) => {\n const values = typeParams['values'];\n if (!Array.isArray(values)) {\n throw new Error(\n `renderOutputType: expected array \"values\" in typeParams for enum, got ${typeof values}`,\n );\n }\n return values\n .map((value) => `'${String(value).replace(/\\\\/g, '\\\\\\\\').replace(/'/g, \"\\\\'\")}'`)\n .join(' | ');\n },\n});\n\nconst pgIntervalCodec = codec<\n typeof PG_INTERVAL_CODEC_ID,\n readonly ['equality', 'order'],\n string | Record<string, unknown>,\n string\n>({\n typeId: PG_INTERVAL_CODEC_ID,\n targetTypes: ['interval'],\n traits: ['equality', 'order'],\n encode: (value: string): string => value,\n decode: (wire: string | Record<string, unknown>): string => {\n if (typeof wire === 'string') return wire;\n return JSON.stringify(wire);\n },\n paramsSchema: precisionParamsSchema,\n renderOutputType: (typeParams) => renderPrecision('Interval', typeParams),\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'interval',\n },\n },\n },\n },\n});\n\nconst pgJsonCodec = codec({\n typeId: PG_JSON_CODEC_ID,\n targetTypes: ['json'],\n traits: [],\n encode: (value: string | JsonValue): string => JSON.stringify(value),\n decode: (wire: string | JsonValue): JsonValue =>\n typeof wire === 'string' ? JSON.parse(wire) : wire,\n renderOutputType: renderJsonOutputType,\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'json',\n },\n },\n },\n },\n});\n\nconst pgJsonbCodec = codec({\n typeId: PG_JSONB_CODEC_ID,\n targetTypes: ['jsonb'],\n traits: ['equality'],\n encode: (value: string | JsonValue): string => JSON.stringify(value),\n decode: (wire: string | JsonValue): JsonValue =>\n typeof wire === 'string' ? JSON.parse(wire) : wire,\n renderOutputType: renderJsonOutputType,\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'jsonb',\n },\n },\n },\n },\n});\n\n// Build codec definitions using the builder DSL\nconst codecs = defineCodecs()\n .add('char', sqlCharCodec)\n .add('varchar', sqlVarcharCodec)\n .add('int', sqlIntCodec)\n .add('float', sqlFloatCodec)\n .add('sql-text', sqlTextCodec)\n .add('sql-timestamp', sqlTimestampCodec)\n .add('text', pgTextCodec)\n .add('character', pgCharCodec)\n .add('character varying', pgVarcharCodec)\n .add('integer', pgIntCodec)\n .add('double precision', pgFloatCodec)\n .add('int4', pgInt4Codec)\n .add('int2', pgInt2Codec)\n .add('int8', pgInt8Codec)\n .add('float4', pgFloat4Codec)\n .add('float8', pgFloat8Codec)\n .add('numeric', pgNumericCodec)\n .add('timestamp', pgTimestampCodec)\n .add('timestamptz', pgTimestamptzCodec)\n .add('time', pgTimeCodec)\n .add('timetz', pgTimetzCodec)\n .add('bool', pgBoolCodec)\n .add('bit', pgBitCodec)\n .add('bit varying', pgVarbitCodec)\n .add('interval', pgIntervalCodec)\n .add('enum', pgEnumCodec)\n .add('json', pgJsonCodec)\n .add('jsonb', pgJsonbCodec);\n\n// Export derived structures directly from codecs builder\nexport const codecDefinitions = codecs.codecDefinitions;\nexport const dataTypes = codecs.dataTypes;\n\nexport type CodecTypes = typeof codecs.CodecTypes;\n"],"mappings":";;;;;;AAEA,MAAM,YAAY;AAElB,SAAS,SAAS,OAA2C;AAC3D,QAAO,OAAO,UAAU,YAAY,UAAU;;AAGhD,SAAS,oBAAoB,KAAqB;AAChD,QAAO,IACJ,QAAQ,OAAO,OAAO,CACtB,QAAQ,MAAM,MAAM,CACpB,QAAQ,OAAO,MAAM,CACrB,QAAQ,OAAO,MAAM;;AAG1B,SAAS,iBAAiB,KAAqB;AAC7C,QAAO,6BAA6B,KAAK,IAAI,GAAG,MAAM,IAAI,oBAAoB,IAAI,CAAC;;AAGrF,SAAS,cAAc,OAAwB;AAC7C,KAAI,OAAO,UAAU,SACnB,QAAO,IAAI,oBAAoB,MAAM,CAAC;AAExC,KAAI,OAAO,UAAU,YAAY,OAAO,UAAU,UAChD,QAAO,OAAO,MAAM;AAEtB,KAAI,UAAU,KACZ,QAAO;AAET,QAAO;;AAGT,SAAS,YAAY,OAA2B,OAAuB;AAErE,QADiB,MAAM,KAAK,SAAS,OAAO,MAAM,MAAM,CAAC,CACzC,KAAK,MAAM;;AAG7B,SAAS,iBAAiB,QAA0B,OAAuB;CACzE,MAAM,aAAa,SAAS,OAAO,cAAc,GAAG,OAAO,gBAAgB,EAAE;CAC7E,MAAM,WAAW,MAAM,QAAQ,OAAO,YAAY,GAC9C,IAAI,IAAI,OAAO,YAAY,QAAQ,QAAuB,OAAO,QAAQ,SAAS,CAAC,mBACnF,IAAI,KAAa;CACrB,MAAM,OAAO,OAAO,KAAK,WAAW,CAAC,MAAM,MAAM,UAAU,KAAK,cAAc,MAAM,CAAC;AAErF,KAAI,KAAK,WAAW,GA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Y,SACb,EACF,EACF,EACF;CACF,CAAC;AAGF,MAAM,SAAS,cAAc,CAC1B,IAAI,QAAQ,aAAa,CACzB,IAAI,WAAW,gBAAgB,CAC/B,IAAI,OAAO,YAAY,CACvB,IAAI,SAAS,cAAc,CAC3B,IAAI,YAAY,aAAa,CAC7B,IAAI,iBAAiB,kBAAkB,CACvC,IAAI,QAAQ,YAAY,CACxB,IAAI,aAAa,YAAY,CAC7B,IAAI,qBAAqB,eAAe,CACxC,IAAI,WAAW,WAAW,CAC1B,IAAI,oBAAoB,aAAa,CACrC,IAAI,QAAQ,YAAY,CACxB,IAAI,QAAQ,YAAY,CACxB,IAAI,QAAQ,YAAY,CACxB,IAAI,UAAU,cAAc,CAC5B,IAAI,UAAU,cAAc,CAC5B,IAAI,WAAW,eAAe,CAC9B,IAAI,aAAa,iBAAiB,CAClC,IAAI,eAAe,mBAAmB,CACtC,IAAI,QAAQ,YAAY,CACxB,IAAI,UAAU,cAAc,CAC5B,IAAI,QAAQ,YAAY,CACxB,IAAI,OAAO,WAAW,CACtB,IAAI,eAAe,cAAc,CACjC,IAAI,YAAY,gBAAgB,CAChC,IAAI,QAAQ,YAAY,CACxB,IAAI,QAAQ,YAAY,CACxB,IAAI,SAAS,aAAa;AAG7B,MAAa,mBAAmB,OAAO;AACvC,MAAa,YAAY,OAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"column-types.d.mts","names":[],"sources":["../src/core/standard-schema.ts","../src/exports/column-types.ts"],"sourcesContent":[],"mappings":";;;;KAEK,6BAAA;;;AAFsB;AAc3B;;;;ACwBA;AAKA;AAUA;AAUa,KDjDD,kBAAA,GCoD6B;EAE5B,SAAA,WAG4B,CAAA,EAAA;IAE5B,SAG4B,OAAA,CAAA,EAAA,MAAA;IAE5B,SAAA,UAG4B,CAAA,EDhEf,6BCgEe;EAE5B,CAAA;EAKG,SAAA,UAAa,CAAA,EAAA,OAG1B;AAUH,CAAA;;;AA/Da,cAAA,UAG4B,EAAA;EAEzB,SAA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;;;iBAKG,SAAA,kBAA2B;;;;;iBAU3B,YAAA,kBAA8B;;;;;iBAU9B,cAAA,sBAAoC;;;;;cAUvC;;;;cAKA;;;;iBAiDG,IAAA,UAAc,qBAAqB;iBAInC,KAAA,UAAe,qBAAqB;iBAIpC,uEAEN,SACP;;qBAAgE;;;iBAQnD,8CACJ,+BAET;oBAA2C"}
@@ -1,4 +1,4 @@
1
- import { C as SQL_CHAR_CODEC_ID, O as SQL_VARCHAR_CODEC_ID, _ as PG_TIMESTAMPTZ_CODEC_ID, a as PG_FLOAT4_CODEC_ID, b as PG_TIME_CODEC_ID, c as PG_INT2_CODEC_ID, d as PG_INTERVAL_CODEC_ID, g as PG_TEXT_CODEC_ID, h as PG_NUMERIC_CODEC_ID, i as PG_ENUM_CODEC_ID, l as PG_INT4_CODEC_ID, m as PG_JSON_CODEC_ID, n as PG_BOOL_CODEC_ID, o as PG_FLOAT8_CODEC_ID, p as PG_JSONB_CODEC_ID, t as PG_BIT_CODEC_ID, u as PG_INT8_CODEC_ID, v as PG_TIMESTAMP_CODEC_ID, x as PG_VARBIT_CODEC_ID, y as PG_TIMETZ_CODEC_ID } from "./codec-ids-BwjcIf74.mjs";
1
+ import { C as SQL_CHAR_CODEC_ID, O as SQL_VARCHAR_CODEC_ID, _ as PG_TIMESTAMPTZ_CODEC_ID, a as PG_FLOAT4_CODEC_ID, b as PG_TIME_CODEC_ID, c as PG_INT2_CODEC_ID, d as PG_INTERVAL_CODEC_ID, g as PG_TEXT_CODEC_ID, h as PG_NUMERIC_CODEC_ID, i as PG_ENUM_CODEC_ID, l as PG_INT4_CODEC_ID, m as PG_JSON_CODEC_ID, n as PG_BOOL_CODEC_ID, o as PG_FLOAT8_CODEC_ID, p as PG_JSONB_CODEC_ID, t as PG_BIT_CODEC_ID, u as PG_INT8_CODEC_ID, v as PG_TIMESTAMP_CODEC_ID, x as PG_VARBIT_CODEC_ID, y as PG_TIMETZ_CODEC_ID } from "./codec-ids-5g4Gwrgm.mjs";
2
2
 
3
3
  //#region src/core/standard-schema.ts
4
4
  function isObjectLike(value) {
package/dist/control.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { i as quoteIdentifier, n as escapeLiteral, r as qualifyName, t as SqlEscapeError } from "./sql-utils-CSfAGEwF.mjs";
2
- import { n as pgEnumControlHooks, t as postgresAdapterDescriptorMeta } from "./descriptor-meta-DemWrTfB.mjs";
1
+ import { i as quoteIdentifier, n as escapeLiteral, r as qualifyName, t as SqlEscapeError } from "./sql-utils-DkUJyZmA.mjs";
2
+ import { r as pgEnumControlHooks, t as postgresAdapterDescriptorMeta } from "./descriptor-meta-BB9XPAFi.mjs";
3
3
  import { ifDefined } from "@prisma-next/utils/defined";
4
4
  import { builtinGeneratorRegistryMetadata, resolveBuiltinGeneratedColumnDescriptor } from "@prisma-next/ids";
5
5
 
@@ -1,6 +1,6 @@
1
- import { C as SQL_CHAR_CODEC_ID, D as SQL_TIMESTAMP_CODEC_ID, E as SQL_TEXT_CODEC_ID, O as SQL_VARCHAR_CODEC_ID, S as PG_VARCHAR_CODEC_ID, T as SQL_INT_CODEC_ID, _ as PG_TIMESTAMPTZ_CODEC_ID, a as PG_FLOAT4_CODEC_ID, b as PG_TIME_CODEC_ID, c as PG_INT2_CODEC_ID, d as PG_INTERVAL_CODEC_ID, f as PG_INT_CODEC_ID, g as PG_TEXT_CODEC_ID, h as PG_NUMERIC_CODEC_ID, i as PG_ENUM_CODEC_ID, l as PG_INT4_CODEC_ID, m as PG_JSON_CODEC_ID, n as PG_BOOL_CODEC_ID, o as PG_FLOAT8_CODEC_ID, p as PG_JSONB_CODEC_ID, r as PG_CHAR_CODEC_ID, s as PG_FLOAT_CODEC_ID, t as PG_BIT_CODEC_ID, u as PG_INT8_CODEC_ID, v as PG_TIMESTAMP_CODEC_ID, w as SQL_FLOAT_CODEC_ID, x as PG_VARBIT_CODEC_ID, y as PG_TIMETZ_CODEC_ID } from "./codec-ids-BwjcIf74.mjs";
2
- import { t as codecDefinitions } from "./codecs-C3wlpdV7.mjs";
3
- import { a as validateEnumValueLength, i as quoteIdentifier, n as escapeLiteral, r as qualifyName } from "./sql-utils-CSfAGEwF.mjs";
1
+ import { C as SQL_CHAR_CODEC_ID, D as SQL_TIMESTAMP_CODEC_ID, E as SQL_TEXT_CODEC_ID, O as SQL_VARCHAR_CODEC_ID, S as PG_VARCHAR_CODEC_ID, T as SQL_INT_CODEC_ID, _ as PG_TIMESTAMPTZ_CODEC_ID, a as PG_FLOAT4_CODEC_ID, b as PG_TIME_CODEC_ID, c as PG_INT2_CODEC_ID, d as PG_INTERVAL_CODEC_ID, f as PG_INT_CODEC_ID, g as PG_TEXT_CODEC_ID, h as PG_NUMERIC_CODEC_ID, i as PG_ENUM_CODEC_ID, l as PG_INT4_CODEC_ID, m as PG_JSON_CODEC_ID, n as PG_BOOL_CODEC_ID, o as PG_FLOAT8_CODEC_ID, p as PG_JSONB_CODEC_ID, r as PG_CHAR_CODEC_ID, s as PG_FLOAT_CODEC_ID, t as PG_BIT_CODEC_ID, u as PG_INT8_CODEC_ID, v as PG_TIMESTAMP_CODEC_ID, w as SQL_FLOAT_CODEC_ID, x as PG_VARBIT_CODEC_ID, y as PG_TIMETZ_CODEC_ID } from "./codec-ids-5g4Gwrgm.mjs";
2
+ import { t as codecDefinitions } from "./codecs-DiPlMi3-.mjs";
3
+ import { a as validateEnumValueLength, i as quoteIdentifier, n as escapeLiteral, r as qualifyName } from "./sql-utils-DkUJyZmA.mjs";
4
4
  import { arraysEqual } from "@prisma-next/family-sql/schema-verify";
5
5
 
6
6
  //#region src/core/enum-control-hooks.ts
@@ -532,6 +532,25 @@ const lengthHooks = { expandNativeType: expandLength };
532
532
  const precisionHooks = { expandNativeType: expandPrecision };
533
533
  const numericHooks = { expandNativeType: expandNumeric };
534
534
  const identityHooks = { expandNativeType: ({ nativeType }) => nativeType };
535
+ const postgresQueryOperations = [{
536
+ method: "ilike",
537
+ args: [{
538
+ traits: ["textual"],
539
+ nullable: false
540
+ }, {
541
+ codecId: PG_TEXT_CODEC_ID,
542
+ nullable: false
543
+ }],
544
+ returns: {
545
+ codecId: PG_BOOL_CODEC_ID,
546
+ nullable: false
547
+ },
548
+ lowering: {
549
+ targetFamily: "sql",
550
+ strategy: "infix",
551
+ template: "{{self}} ILIKE {{arg0}}"
552
+ }
553
+ }];
535
554
  const postgresAdapterDescriptorMeta = {
536
555
  kind: "adapter",
537
556
  familyId: "sql",
@@ -759,10 +778,15 @@ const postgresAdapterDescriptorMeta = {
759
778
  targetId: "postgres",
760
779
  nativeType: "jsonb"
761
780
  }
762
- ]
781
+ ],
782
+ queryOperationTypes: { import: {
783
+ package: "@prisma-next/adapter-postgres/operation-types",
784
+ named: "QueryOperationTypes",
785
+ alias: "PgAdapterQueryOps"
786
+ } }
763
787
  }
764
788
  };
765
789
 
766
790
  //#endregion
767
- export { pgEnumControlHooks as n, postgresAdapterDescriptorMeta as t };
768
- //# sourceMappingURL=descriptor-meta-DemWrTfB.mjs.map
791
+ export { postgresQueryOperations as n, pgEnumControlHooks as r, postgresAdapterDescriptorMeta as t };
792
+ //# sourceMappingURL=descriptor-meta-BB9XPAFi.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"descriptor-meta-BB9XPAFi.mjs","names":["result: string[]","operations: SqlMigrationPlanOperation<unknown>[]","columns: Array<{ table: string; column: string }>","result: Array<{ table: string; column: string }>","pgEnumControlHooks: CodecControlHooks","types: Record<string, StorageTypeInstance>","lengthHooks: CodecControlHooks","precisionHooks: CodecControlHooks","numericHooks: CodecControlHooks","identityHooks: CodecControlHooks","postgresQueryOperations: readonly SqlOperationDescriptor[]"],"sources":["../src/core/enum-control-hooks.ts","../src/core/descriptor-meta.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\nimport type { CodecControlHooks, SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport { arraysEqual } from '@prisma-next/family-sql/schema-verify';\nimport type { SqlStorage, StorageTypeInstance } from '@prisma-next/sql-contract/types';\nimport type { SqlSchemaIR } from '@prisma-next/sql-schema-ir/types';\nimport { PG_ENUM_CODEC_ID } from './codec-ids';\nimport { escapeLiteral, qualifyName, quoteIdentifier, validateEnumValueLength } from './sql-utils';\n\n/**\n * Postgres enum control hooks.\n *\n * - Plans enum type operations for migrations\n * - Verifies enum types in schema IR\n * - Introspects enum types from the database\n */\ntype EnumRow = {\n schema_name: string;\n type_name: string;\n values: string[];\n};\n\ntype EnumDiff =\n | { kind: 'unchanged' }\n | { kind: 'add_values'; values: readonly string[] }\n | { kind: 'rebuild'; removedValues: readonly string[] };\n\n// ============================================================================\n// Introspection SQL\n// ============================================================================\n\nconst ENUM_INTROSPECT_QUERY = `\n SELECT\n n.nspname AS schema_name,\n t.typname AS type_name,\n array_agg(e.enumlabel ORDER BY e.enumsortorder) AS values\n FROM pg_type t\n JOIN pg_namespace n ON t.typnamespace = n.oid\n JOIN pg_enum e ON t.oid = e.enumtypid\n WHERE n.nspname = $1\n GROUP BY n.nspname, t.typname\n ORDER BY n.nspname, t.typname\n`;\n\n// ============================================================================\n// Schema Helpers (Simplified)\n// ============================================================================\n\n/**\n * Type guard for string arrays. Used for runtime validation of introspected data.\n */\nfunction isStringArray(value: unknown): value is string[] {\n return Array.isArray(value) && value.every((entry) => typeof entry === 'string');\n}\n\n/**\n * Parses a PostgreSQL array value into a JavaScript string array.\n *\n * PostgreSQL's `pg` library may return `array_agg` results either as:\n * - A JavaScript array (when type parsers are configured)\n * - A string in PostgreSQL array literal format: `{value1,value2,...}`\n *\n * Handles PostgreSQL's quoting rules for array elements:\n * - Elements containing commas, double quotes, backslashes, or whitespace are double-quoted\n * - Inside quoted elements, `\\\"` represents `\"` and `\\\\` represents `\\`\n *\n * @param value - The value to parse (array or PostgreSQL array string)\n * @returns A string array, or null if the value cannot be parsed\n */\nexport function parsePostgresArray(value: unknown): string[] | null {\n if (isStringArray(value)) {\n return value;\n }\n if (typeof value === 'string' && value.startsWith('{') && value.endsWith('}')) {\n const inner = value.slice(1, -1);\n if (inner === '') {\n return [];\n }\n return parseArrayElements(inner);\n }\n return null;\n}\n\nfunction parseArrayElements(input: string): string[] {\n const result: string[] = [];\n let i = 0;\n while (i < input.length) {\n if (input[i] === ',') {\n i++;\n continue;\n }\n if (input[i] === '\"') {\n i++;\n let element = '';\n while (i < input.length && input[i] !== '\"') {\n if (input[i] === '\\\\' && i + 1 < input.length) {\n i++;\n element += input[i];\n } else {\n element += input[i];\n }\n i++;\n }\n i++;\n result.push(element);\n } else {\n const nextComma = input.indexOf(',', i);\n if (nextComma === -1) {\n result.push(input.slice(i).trim());\n i = input.length;\n } else {\n result.push(input.slice(i, nextComma).trim());\n i = nextComma;\n }\n }\n }\n return result;\n}\n\n/**\n * Extracts enum values from a StorageTypeInstance.\n * Returns null if values are missing or invalid.\n */\nfunction getEnumValues(typeInstance: StorageTypeInstance): readonly string[] | null {\n const values = typeInstance.typeParams?.['values'];\n return isStringArray(values) ? values : null;\n}\n\n/**\n * Reads existing enum values from the schema IR for a given native type.\n * Uses optional chaining to simplify navigation through the annotations structure.\n */\nfunction readExistingEnumValues(schema: SqlSchemaIR, nativeType: string): readonly string[] | null {\n const storageTypes = (schema.annotations?.['pg'] as Record<string, unknown> | undefined)?.[\n 'storageTypes'\n ] as Record<string, StorageTypeInstance> | undefined;\n\n const existing = storageTypes?.[nativeType];\n if (!existing || existing.codecId !== PG_ENUM_CODEC_ID) {\n return null;\n }\n return getEnumValues(existing);\n}\n\n/**\n * Determines what changes are needed to transform existing enum values to desired values.\n *\n * Returns one of:\n * - `unchanged`: No changes needed, values match exactly\n * - `add_values`: New values can be safely appended (PostgreSQL supports this)\n * - `rebuild`: Full enum rebuild required (value removal, reordering, or both)\n *\n * Note: PostgreSQL enums can only have values added (not removed or reordered) without\n * a full type rebuild involving temp type creation and column migration.\n *\n * @param existing - Current enum values in the database\n * @param desired - Target enum values from the contract\n * @returns The type of change required\n */\nfunction determineEnumDiff(existing: readonly string[], desired: readonly string[]): EnumDiff {\n if (arraysEqual(existing, desired)) {\n return { kind: 'unchanged' };\n }\n\n // Use Sets for O(1) lookups instead of O(n) array.includes()\n const existingSet = new Set(existing);\n const desiredSet = new Set(desired);\n\n const missingValues = desired.filter((value) => !existingSet.has(value));\n const removedValues = existing.filter((value) => !desiredSet.has(value));\n const orderMismatch =\n missingValues.length === 0 && removedValues.length === 0 && !arraysEqual(existing, desired);\n\n if (removedValues.length > 0 || orderMismatch) {\n return { kind: 'rebuild', removedValues };\n }\n\n return { kind: 'add_values', values: missingValues };\n}\n\n// ============================================================================\n// SQL Helpers\n// ============================================================================\n\nfunction enumTypeExistsCheck(schemaName: string, typeName: string, exists = true): string {\n const existsClause = exists ? 'EXISTS' : 'NOT EXISTS';\n return `SELECT ${existsClause} (\n SELECT 1\n FROM pg_type t\n JOIN pg_namespace n ON t.typnamespace = n.oid\n WHERE n.nspname = '${escapeLiteral(schemaName)}'\n AND t.typname = '${escapeLiteral(typeName)}'\n)`;\n}\n\n// ============================================================================\n// Operation Builders\n// ============================================================================\n\nfunction buildCreateEnumOperation(\n typeName: string,\n nativeType: string,\n schemaName: string,\n values: readonly string[],\n): SqlMigrationPlanOperation<unknown> {\n // Validate all enum values don't exceed PostgreSQL's label length limit\n for (const value of values) {\n validateEnumValueLength(value, typeName);\n }\n const literalValues = values.map((value) => `'${escapeLiteral(value)}'`).join(', ');\n const qualifiedType = qualifyName(schemaName, nativeType);\n return {\n id: `type.${typeName}`,\n label: `Create type ${typeName}`,\n summary: `Creates enum type ${typeName}`,\n operationClass: 'additive',\n target: { id: 'postgres' },\n precheck: [\n {\n description: `ensure type \"${nativeType}\" does not exist`,\n sql: enumTypeExistsCheck(schemaName, nativeType, false),\n },\n ],\n execute: [\n {\n description: `create type \"${nativeType}\"`,\n sql: `CREATE TYPE ${qualifiedType} AS ENUM (${literalValues})`,\n },\n ],\n postcheck: [\n {\n description: `verify type \"${nativeType}\" exists`,\n sql: enumTypeExistsCheck(schemaName, nativeType),\n },\n ],\n };\n}\n\n/**\n * Computes the optimal position for inserting a new enum value to maintain\n * the desired order relative to existing values.\n *\n * PostgreSQL's `ALTER TYPE ADD VALUE` supports BEFORE/AFTER positioning.\n * This function finds the best reference value by:\n * 1. Looking for the nearest preceding value that already exists\n * 2. Falling back to the nearest following value if no preceding exists\n * 3. Defaulting to end-of-list if no reference is found\n *\n * @param options.desired - The target ordered list of all enum values\n * @param options.desiredIndex - Index of the value being inserted in the desired list\n * @param options.current - Current list of enum values (being built up incrementally)\n * @returns SQL clause (e.g., \" AFTER 'x'\") and insert position for tracking\n */\nfunction computeInsertPosition(options: {\n desired: readonly string[];\n desiredIndex: number;\n current: readonly string[];\n}): { clause: string; insertAt: number } {\n const { desired, desiredIndex, current } = options;\n const currentSet = new Set(current);\n const previous = desired\n .slice(0, desiredIndex)\n .reverse()\n .find((candidate) => currentSet.has(candidate));\n const next = desired.slice(desiredIndex + 1).find((candidate) => currentSet.has(candidate));\n const clause = previous\n ? ` AFTER '${escapeLiteral(previous)}'`\n : next\n ? ` BEFORE '${escapeLiteral(next)}'`\n : '';\n const insertAt = previous\n ? current.indexOf(previous) + 1\n : next\n ? current.indexOf(next)\n : current.length;\n\n return { clause, insertAt };\n}\n\n/**\n * Builds operations to add new enum values to an existing PostgreSQL enum type.\n *\n * Each new value is added with `ALTER TYPE ... ADD VALUE IF NOT EXISTS` for idempotency.\n * Values are inserted in the correct order using BEFORE/AFTER positioning to match\n * the desired final order.\n *\n * This is a safe, non-destructive operation - existing data is not affected.\n *\n * @param options.typeName - Contract-level type name (e.g., 'Role')\n * @param options.nativeType - PostgreSQL type name (e.g., 'role')\n * @param options.schemaName - PostgreSQL schema (e.g., 'public')\n * @param options.desired - Target ordered list of all enum values\n * @param options.existing - Current enum values in the database\n * @returns Array of migration operations to add each missing value\n */\nfunction buildAddValueOperations(options: {\n typeName: string;\n nativeType: string;\n schemaName: string;\n desired: readonly string[];\n existing: readonly string[];\n}): SqlMigrationPlanOperation<unknown>[] {\n const { typeName, nativeType, schemaName } = options;\n const current = [...options.existing];\n const currentSet = new Set(current);\n const operations: SqlMigrationPlanOperation<unknown>[] = [];\n for (let index = 0; index < options.desired.length; index += 1) {\n const value = options.desired[index];\n if (value === undefined) {\n continue;\n }\n if (currentSet.has(value)) {\n continue;\n }\n // Validate the new value doesn't exceed PostgreSQL's label length limit\n validateEnumValueLength(value, typeName);\n const { clause, insertAt } = computeInsertPosition({\n desired: options.desired,\n desiredIndex: index,\n current,\n });\n // Use IF NOT EXISTS for idempotency - safe to re-run after partial failures.\n // Supported in PostgreSQL 9.3+, and we require PostgreSQL 12+.\n operations.push({\n id: `type.${typeName}.value.${value}`,\n label: `Add value ${value} to ${typeName}`,\n summary: `Adds enum value ${value} to ${typeName}`,\n operationClass: 'widening',\n target: { id: 'postgres' },\n precheck: [],\n execute: [\n {\n description: `add value \"${value}\" if not exists`,\n sql: `ALTER TYPE ${qualifyName(schemaName, nativeType)} ADD VALUE IF NOT EXISTS '${escapeLiteral(\n value,\n )}'${clause}`,\n },\n ],\n postcheck: [],\n });\n current.splice(insertAt, 0, value);\n currentSet.add(value);\n }\n return operations;\n}\n\n/**\n * Collects columns using the enum type from the contract (desired state).\n * Used for type-safe reference tracking.\n */\nfunction collectEnumColumnsFromContract(\n contract: Contract<SqlStorage>,\n typeName: string,\n nativeType: string,\n): ReadonlyArray<{ table: string; column: string }> {\n const columns: Array<{ table: string; column: string }> = [];\n for (const [tableName, table] of Object.entries(contract.storage.tables)) {\n for (const [columnName, column] of Object.entries(table.columns)) {\n if (\n column.typeRef === typeName ||\n (column.nativeType === nativeType && column.codecId === PG_ENUM_CODEC_ID)\n ) {\n columns.push({ table: tableName, column: columnName });\n }\n }\n }\n return columns;\n}\n\n/**\n * Collects columns using the enum type from the schema IR (live database state).\n * This ensures we find ALL dependent columns, including those added outside the contract\n * (e.g., manual DDL), which is critical for safe enum rebuild operations.\n */\nfunction collectEnumColumnsFromSchema(\n schema: SqlSchemaIR,\n nativeType: string,\n): ReadonlyArray<{ table: string; column: string }> {\n const columns: Array<{ table: string; column: string }> = [];\n for (const [tableName, table] of Object.entries(schema.tables)) {\n for (const [columnName, column] of Object.entries(table.columns)) {\n // Match by nativeType since schema IR doesn't have codecId/typeRef\n if (column.nativeType === nativeType) {\n columns.push({ table: tableName, column: columnName });\n }\n }\n }\n return columns;\n}\n\n/**\n * Collects all columns using the enum type from both contract AND live database.\n * Merges and deduplicates to ensure we migrate ALL dependent columns during rebuild.\n *\n * This is critical for data integrity: if a column exists in the database using\n * this enum but is not in the contract (e.g., added via manual DDL), we must\n * still migrate it to avoid DROP TYPE failures.\n */\nfunction collectAllEnumColumns(\n contract: Contract<SqlStorage>,\n schema: SqlSchemaIR,\n typeName: string,\n nativeType: string,\n): ReadonlyArray<{ table: string; column: string }> {\n const contractColumns = collectEnumColumnsFromContract(contract, typeName, nativeType);\n const schemaColumns = collectEnumColumnsFromSchema(schema, nativeType);\n\n // Merge and deduplicate using a Set of \"table.column\" keys\n const seen = new Set<string>();\n const result: Array<{ table: string; column: string }> = [];\n\n for (const col of [...contractColumns, ...schemaColumns]) {\n const key = `${col.table}.${col.column}`;\n if (!seen.has(key)) {\n seen.add(key);\n result.push(col);\n }\n }\n\n // Sort for deterministic operation order\n return result.sort((a, b) => {\n const tableCompare = a.table.localeCompare(b.table);\n return tableCompare !== 0 ? tableCompare : a.column.localeCompare(b.column);\n });\n}\n\n/**\n * Builds a SQL check to verify a column's type matches an expected type.\n */\nfunction columnTypeCheck(options: {\n schemaName: string;\n tableName: string;\n columnName: string;\n expectedType: string;\n}): string {\n return `SELECT EXISTS (\n SELECT 1\n FROM information_schema.columns\n WHERE table_schema = '${escapeLiteral(options.schemaName)}'\n AND table_name = '${escapeLiteral(options.tableName)}'\n AND column_name = '${escapeLiteral(options.columnName)}'\n AND udt_name = '${escapeLiteral(options.expectedType)}'\n)`;\n}\n\n/** PostgreSQL maximum identifier length (NAMEDATALEN - 1) */\nconst MAX_IDENTIFIER_LENGTH = 63;\n\n/** Suffix added to enum type names during rebuild operations */\nconst REBUILD_SUFFIX = '__pn_rebuild';\n\n/**\n * Builds an SQL check to verify no rows contain any of the removed enum values.\n * This prevents data loss during enum rebuild operations.\n *\n * @param schemaName - PostgreSQL schema name\n * @param tableName - Table containing the enum column\n * @param columnName - Column using the enum type\n * @param removedValues - Array of enum values being removed\n * @returns SQL query that returns true if no rows contain removed values\n */\nfunction noRemovedValuesExistCheck(\n schemaName: string,\n tableName: string,\n columnName: string,\n removedValues: readonly string[],\n): string {\n if (removedValues.length === 0) {\n // No values being removed, always passes\n return 'SELECT true';\n }\n const valuesList = removedValues.map((v) => `'${escapeLiteral(v)}'`).join(', ');\n return `SELECT NOT EXISTS (\n SELECT 1 FROM ${qualifyName(schemaName, tableName)}\n WHERE ${quoteIdentifier(columnName)}::text IN (${valuesList})\n LIMIT 1\n)`;\n}\n\n/**\n * Builds a migration operation to recreate a PostgreSQL enum type with updated values.\n *\n * This is required when:\n * - Enum values are removed (PostgreSQL doesn't support direct removal)\n * - Enum values are reordered (PostgreSQL doesn't support reordering)\n *\n * The operation:\n * 1. Creates a new enum type with the desired values (temp name)\n * 2. Migrates all columns to use the new type via text cast\n * 3. Drops the original type\n * 4. Renames the temp type to the original name\n *\n * IMPORTANT: If values are being removed and data exists using those values,\n * the operation will fail at the precheck stage with a clear error message.\n * This prevents silent data loss.\n *\n * @param options.typeName - Contract-level type name\n * @param options.nativeType - PostgreSQL type name\n * @param options.schemaName - PostgreSQL schema\n * @param options.values - Desired final enum values\n * @param options.removedValues - Values being removed (for data loss checks)\n * @param options.contract - Full contract for column discovery\n * @param options.schema - Current schema IR for column discovery\n * @returns Migration operation for full enum rebuild\n */\nfunction buildRecreateEnumOperation(options: {\n typeName: string;\n nativeType: string;\n schemaName: string;\n values: readonly string[];\n removedValues: readonly string[];\n contract: Contract<SqlStorage>;\n schema: SqlSchemaIR;\n}): SqlMigrationPlanOperation<unknown> {\n const tempTypeName = `${options.nativeType}${REBUILD_SUFFIX}`;\n\n // Validate temp type name length won't exceed PostgreSQL's 63-character limit.\n // If it would, PostgreSQL silently truncates which could cause conflicts.\n if (tempTypeName.length > MAX_IDENTIFIER_LENGTH) {\n const maxBaseLength = MAX_IDENTIFIER_LENGTH - REBUILD_SUFFIX.length;\n throw new Error(\n `Enum type name \"${options.nativeType}\" is too long for rebuild operation. ` +\n `Maximum length is ${maxBaseLength} characters (type name + \"${REBUILD_SUFFIX}\" suffix ` +\n `must fit within PostgreSQL's ${MAX_IDENTIFIER_LENGTH}-character identifier limit).`,\n );\n }\n\n const qualifiedOriginal = qualifyName(options.schemaName, options.nativeType);\n const qualifiedTemp = qualifyName(options.schemaName, tempTypeName);\n const literalValues = options.values.map((value) => `'${escapeLiteral(value)}'`).join(', ');\n\n // CRITICAL: Collect columns from BOTH contract AND live database.\n // This ensures we migrate ALL dependent columns, including those added\n // outside of Prisma Next (e.g., manual DDL). Without this, DROP TYPE\n // would fail if the database has columns not tracked in the contract.\n const columnRefs = collectAllEnumColumns(\n options.contract,\n options.schema,\n options.typeName,\n options.nativeType,\n );\n\n const alterColumns = columnRefs.map((ref) => ({\n description: `alter ${ref.table}.${ref.column} to ${tempTypeName}`,\n sql: `ALTER TABLE ${qualifyName(options.schemaName, ref.table)}\nALTER COLUMN ${quoteIdentifier(ref.column)}\nTYPE ${qualifiedTemp}\nUSING ${quoteIdentifier(ref.column)}::text::${qualifiedTemp}`,\n }));\n\n // Build postchecks to verify:\n // 1. The final type exists with the correct name\n // 2. The temp type was cleaned up (renamed away)\n // 3. All migrated columns now reference the final type\n const postchecks = [\n {\n description: `verify type \"${options.nativeType}\" exists`,\n sql: enumTypeExistsCheck(options.schemaName, options.nativeType),\n },\n {\n description: `verify temp type \"${tempTypeName}\" was removed`,\n sql: enumTypeExistsCheck(options.schemaName, tempTypeName, false),\n },\n // Verify each column was successfully migrated to the final type\n ...columnRefs.map((ref) => ({\n description: `verify ${ref.table}.${ref.column} uses type \"${options.nativeType}\"`,\n sql: columnTypeCheck({\n schemaName: options.schemaName,\n tableName: ref.table,\n columnName: ref.column,\n expectedType: options.nativeType,\n }),\n })),\n ];\n\n return {\n id: `type.${options.typeName}.rebuild`,\n label: `Rebuild type ${options.typeName}`,\n summary: `Recreates enum type ${options.typeName} with updated values`,\n operationClass: 'destructive',\n target: { id: 'postgres' },\n precheck: [\n {\n description: `ensure type \"${options.nativeType}\" exists`,\n sql: enumTypeExistsCheck(options.schemaName, options.nativeType),\n },\n // Note: We don't precheck that temp type doesn't exist because we handle\n // orphaned temp types in the execute step below.\n\n // CRITICAL: If values are being removed, verify no data exists using those values.\n // This prevents silent data loss during the rebuild - the USING cast would fail\n // at runtime if rows contain values that don't exist in the new enum.\n ...(options.removedValues.length > 0\n ? columnRefs.map((ref) => ({\n description: `ensure no rows in ${ref.table}.${ref.column} contain removed values (${options.removedValues.join(', ')})`,\n sql: noRemovedValuesExistCheck(\n options.schemaName,\n ref.table,\n ref.column,\n options.removedValues,\n ),\n }))\n : []),\n ],\n execute: [\n // Clean up any orphaned temp type from a previous failed migration.\n // This makes the operation recoverable without manual intervention.\n // DROP TYPE IF EXISTS is safe - it's a no-op if the type doesn't exist.\n {\n description: `drop orphaned temp type \"${tempTypeName}\" if exists`,\n sql: `DROP TYPE IF EXISTS ${qualifiedTemp}`,\n },\n {\n description: `create temp type \"${tempTypeName}\"`,\n sql: `CREATE TYPE ${qualifiedTemp} AS ENUM (${literalValues})`,\n },\n ...alterColumns,\n {\n description: `drop type \"${options.nativeType}\"`,\n sql: `DROP TYPE ${qualifiedOriginal}`,\n },\n {\n description: `rename type \"${tempTypeName}\" to \"${options.nativeType}\"`,\n sql: `ALTER TYPE ${qualifiedTemp} RENAME TO ${quoteIdentifier(options.nativeType)}`,\n },\n ],\n postcheck: postchecks,\n };\n}\n\n// ============================================================================\n// Codec Control Hooks\n// ============================================================================\n\n/**\n * Postgres enum hooks for planning, verifying, and introspecting `storage.types`.\n */\nexport const pgEnumControlHooks: CodecControlHooks = {\n planTypeOperations: ({ typeName, typeInstance, contract, schema, schemaName }) => {\n const desired = getEnumValues(typeInstance);\n if (!desired || desired.length === 0) {\n return { operations: [] };\n }\n\n const schemaNamespace = schemaName ?? 'public';\n const existing = readExistingEnumValues(schema, typeInstance.nativeType);\n if (!existing) {\n return {\n operations: [\n buildCreateEnumOperation(typeName, typeInstance.nativeType, schemaNamespace, desired),\n ],\n };\n }\n\n const diff = determineEnumDiff(existing, desired);\n if (diff.kind === 'unchanged') {\n return { operations: [] };\n }\n\n if (diff.kind === 'rebuild') {\n return {\n operations: [\n buildRecreateEnumOperation({\n typeName,\n nativeType: typeInstance.nativeType,\n schemaName: schemaNamespace,\n values: desired,\n removedValues: diff.removedValues,\n contract,\n schema,\n }),\n ],\n };\n }\n\n return {\n operations: buildAddValueOperations({\n typeName,\n nativeType: typeInstance.nativeType,\n schemaName: schemaNamespace,\n desired,\n existing,\n }),\n };\n },\n verifyType: ({ typeName, typeInstance, schema }) => {\n const desired = getEnumValues(typeInstance);\n if (!desired) {\n return [];\n }\n const existing = readExistingEnumValues(schema, typeInstance.nativeType);\n if (!existing) {\n return [\n {\n kind: 'type_missing',\n typeName,\n message: `Type \"${typeName}\" is missing from database`,\n },\n ];\n }\n const diff = determineEnumDiff(existing, desired);\n if (diff.kind === 'unchanged') return [];\n const existingSet = new Set(existing);\n const desiredSet = new Set(desired);\n const addedValues = desired.filter((v) => !existingSet.has(v));\n const removedValues = existing.filter((v) => !desiredSet.has(v));\n return [\n {\n kind: 'enum_values_changed' as const,\n typeName,\n addedValues,\n removedValues,\n message:\n diff.kind === 'add_values'\n ? `Enum type \"${typeName}\" needs new values: ${addedValues.join(', ')}`\n : `Enum type \"${typeName}\" values changed (requires rebuild): +[${addedValues.join(', ')}] -[${removedValues.join(', ')}]`,\n },\n ];\n },\n introspectTypes: async ({ driver, schemaName }) => {\n const namespace = schemaName ?? 'public';\n const result = await driver.query<EnumRow>(ENUM_INTROSPECT_QUERY, [namespace]);\n const types: Record<string, StorageTypeInstance> = {};\n for (const row of result.rows) {\n const values = parsePostgresArray(row.values);\n if (!values) {\n throw new Error(\n `Failed to parse enum values for type \"${row.type_name}\": ` +\n `unexpected format: ${JSON.stringify(row.values)}`,\n );\n }\n types[row.type_name] = {\n codecId: PG_ENUM_CODEC_ID,\n nativeType: row.type_name,\n typeParams: { values },\n };\n }\n return types;\n },\n};\n","import type { CodecControlHooks, ExpandNativeTypeInput } from '@prisma-next/family-sql/control';\nimport type { SqlOperationDescriptor } from '@prisma-next/sql-operations';\nimport {\n PG_BIT_CODEC_ID,\n PG_BOOL_CODEC_ID,\n PG_CHAR_CODEC_ID,\n PG_ENUM_CODEC_ID,\n PG_FLOAT_CODEC_ID,\n PG_FLOAT4_CODEC_ID,\n PG_FLOAT8_CODEC_ID,\n PG_INT_CODEC_ID,\n PG_INT2_CODEC_ID,\n PG_INT4_CODEC_ID,\n PG_INT8_CODEC_ID,\n PG_INTERVAL_CODEC_ID,\n PG_JSON_CODEC_ID,\n PG_JSONB_CODEC_ID,\n PG_NUMERIC_CODEC_ID,\n PG_TEXT_CODEC_ID,\n PG_TIME_CODEC_ID,\n PG_TIMESTAMP_CODEC_ID,\n PG_TIMESTAMPTZ_CODEC_ID,\n PG_TIMETZ_CODEC_ID,\n PG_VARBIT_CODEC_ID,\n PG_VARCHAR_CODEC_ID,\n SQL_CHAR_CODEC_ID,\n SQL_FLOAT_CODEC_ID,\n SQL_INT_CODEC_ID,\n SQL_TEXT_CODEC_ID,\n SQL_TIMESTAMP_CODEC_ID,\n SQL_VARCHAR_CODEC_ID,\n} from './codec-ids';\nimport { codecDefinitions } from './codecs';\nimport { pgEnumControlHooks } from './enum-control-hooks';\n\n// ============================================================================\n// Helper functions for reducing boilerplate\n// ============================================================================\n\n/** Creates a type import spec for codec types */\nconst codecTypeImport = (named: string) =>\n ({\n package: '@prisma-next/adapter-postgres/codec-types',\n named,\n alias: named,\n }) as const;\n\nfunction isPositiveInteger(value: unknown): value is number {\n return (\n typeof value === 'number' && Number.isFinite(value) && Number.isInteger(value) && value > 0\n );\n}\n\nfunction isNonNegativeInteger(value: unknown): value is number {\n return (\n typeof value === 'number' && Number.isFinite(value) && Number.isInteger(value) && value >= 0\n );\n}\n\nfunction expandLength({ nativeType, typeParams }: ExpandNativeTypeInput): string {\n if (!typeParams || !('length' in typeParams)) {\n return nativeType;\n }\n const length = typeParams['length'];\n if (!isPositiveInteger(length)) {\n throw new Error(\n `Invalid \"length\" type parameter for \"${nativeType}\": expected a positive integer, got ${JSON.stringify(length)}`,\n );\n }\n return `${nativeType}(${length})`;\n}\n\nfunction expandPrecision({ nativeType, typeParams }: ExpandNativeTypeInput): string {\n if (!typeParams || !('precision' in typeParams)) {\n return nativeType;\n }\n const precision = typeParams['precision'];\n if (!isPositiveInteger(precision)) {\n throw new Error(\n `Invalid \"precision\" type parameter for \"${nativeType}\": expected a positive integer, got ${JSON.stringify(precision)}`,\n );\n }\n return `${nativeType}(${precision})`;\n}\n\nfunction expandNumeric({ nativeType, typeParams }: ExpandNativeTypeInput): string {\n const hasPrecision = typeParams && 'precision' in typeParams;\n const hasScale = typeParams && 'scale' in typeParams;\n\n if (!hasPrecision && !hasScale) {\n return nativeType;\n }\n\n if (!hasPrecision && hasScale) {\n throw new Error(\n `Invalid type parameters for \"${nativeType}\": \"scale\" requires \"precision\" to be specified`,\n );\n }\n\n if (hasPrecision) {\n const precision = typeParams['precision'];\n if (!isPositiveInteger(precision)) {\n throw new Error(\n `Invalid \"precision\" type parameter for \"${nativeType}\": expected a positive integer, got ${JSON.stringify(precision)}`,\n );\n }\n if (hasScale) {\n const scale = typeParams['scale'];\n if (!isNonNegativeInteger(scale)) {\n throw new Error(\n `Invalid \"scale\" type parameter for \"${nativeType}\": expected a non-negative integer, got ${JSON.stringify(scale)}`,\n );\n }\n return `${nativeType}(${precision},${scale})`;\n }\n return `${nativeType}(${precision})`;\n }\n\n return nativeType;\n}\n\nconst lengthHooks: CodecControlHooks = { expandNativeType: expandLength };\nconst precisionHooks: CodecControlHooks = { expandNativeType: expandPrecision };\nconst numericHooks: CodecControlHooks = { expandNativeType: expandNumeric };\nconst identityHooks: CodecControlHooks = { expandNativeType: ({ nativeType }) => nativeType };\n\n// ============================================================================\n// Descriptor metadata\n// ============================================================================\n\nexport const postgresQueryOperations: readonly SqlOperationDescriptor[] = [\n {\n method: 'ilike',\n args: [\n { traits: ['textual'], nullable: false },\n { codecId: PG_TEXT_CODEC_ID, nullable: false },\n ],\n returns: { codecId: PG_BOOL_CODEC_ID, nullable: false },\n lowering: { targetFamily: 'sql', strategy: 'infix', template: '{{self}} ILIKE {{arg0}}' },\n },\n];\n\nexport 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 sql: {\n enums: true,\n returning: true,\n defaultInInsert: true,\n },\n },\n types: {\n codecTypes: {\n codecInstances: Object.values(codecDefinitions).map((def) => def.codec),\n import: {\n package: '@prisma-next/adapter-postgres/codec-types',\n named: 'CodecTypes',\n alias: 'PgTypes',\n },\n typeImports: [\n {\n package: '@prisma-next/adapter-postgres/codec-types',\n named: 'JsonValue',\n alias: 'JsonValue',\n },\n codecTypeImport('Char'),\n codecTypeImport('Varchar'),\n codecTypeImport('Numeric'),\n codecTypeImport('Bit'),\n codecTypeImport('VarBit'),\n codecTypeImport('Timestamp'),\n codecTypeImport('Timestamptz'),\n codecTypeImport('Time'),\n codecTypeImport('Timetz'),\n codecTypeImport('Interval'),\n ],\n controlPlaneHooks: {\n [SQL_CHAR_CODEC_ID]: lengthHooks,\n [SQL_VARCHAR_CODEC_ID]: lengthHooks,\n [SQL_TIMESTAMP_CODEC_ID]: precisionHooks,\n [PG_CHAR_CODEC_ID]: lengthHooks,\n [PG_VARCHAR_CODEC_ID]: lengthHooks,\n [PG_NUMERIC_CODEC_ID]: numericHooks,\n [PG_BIT_CODEC_ID]: lengthHooks,\n [PG_VARBIT_CODEC_ID]: lengthHooks,\n [PG_TIMESTAMP_CODEC_ID]: precisionHooks,\n [PG_TIMESTAMPTZ_CODEC_ID]: precisionHooks,\n [PG_TIME_CODEC_ID]: precisionHooks,\n [PG_TIMETZ_CODEC_ID]: precisionHooks,\n [PG_INTERVAL_CODEC_ID]: precisionHooks,\n [PG_ENUM_CODEC_ID]: pgEnumControlHooks,\n [PG_JSON_CODEC_ID]: identityHooks,\n [PG_JSONB_CODEC_ID]: identityHooks,\n },\n },\n storage: [\n { typeId: PG_TEXT_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'text' },\n { typeId: SQL_TEXT_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'text' },\n { typeId: SQL_CHAR_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'character' },\n {\n typeId: SQL_VARCHAR_CODEC_ID,\n familyId: 'sql',\n targetId: 'postgres',\n nativeType: 'character varying',\n },\n { typeId: SQL_INT_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'int4' },\n { typeId: SQL_FLOAT_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'float8' },\n {\n typeId: SQL_TIMESTAMP_CODEC_ID,\n familyId: 'sql',\n targetId: 'postgres',\n nativeType: 'timestamp',\n },\n { typeId: PG_CHAR_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'character' },\n {\n typeId: PG_VARCHAR_CODEC_ID,\n familyId: 'sql',\n targetId: 'postgres',\n nativeType: 'character varying',\n },\n { typeId: PG_INT_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'int4' },\n { typeId: PG_FLOAT_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'float8' },\n { typeId: PG_INT4_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'int4' },\n { typeId: PG_INT2_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'int2' },\n { typeId: PG_INT8_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'int8' },\n { typeId: PG_FLOAT4_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'float4' },\n { typeId: PG_FLOAT8_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'float8' },\n { typeId: PG_NUMERIC_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'numeric' },\n {\n typeId: PG_TIMESTAMP_CODEC_ID,\n familyId: 'sql',\n targetId: 'postgres',\n nativeType: 'timestamp',\n },\n {\n typeId: PG_TIMESTAMPTZ_CODEC_ID,\n familyId: 'sql',\n targetId: 'postgres',\n nativeType: 'timestamptz',\n },\n { typeId: PG_TIME_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'time' },\n { typeId: PG_TIMETZ_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'timetz' },\n { typeId: PG_BOOL_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'bool' },\n { typeId: PG_BIT_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'bit' },\n {\n typeId: PG_VARBIT_CODEC_ID,\n familyId: 'sql',\n targetId: 'postgres',\n nativeType: 'bit varying',\n },\n {\n typeId: PG_INTERVAL_CODEC_ID,\n familyId: 'sql',\n targetId: 'postgres',\n nativeType: 'interval',\n },\n { typeId: PG_JSON_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'json' },\n { typeId: PG_JSONB_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'jsonb' },\n ],\n queryOperationTypes: {\n import: {\n package: '@prisma-next/adapter-postgres/operation-types',\n named: 'QueryOperationTypes',\n alias: 'PgAdapterQueryOps',\n },\n },\n },\n} as const;\n"],"mappings":";;;;;;AA8BA,MAAM,wBAAwB;;;;;;;;;;;;;;;AAoB9B,SAAS,cAAc,OAAmC;AACxD,QAAO,MAAM,QAAQ,MAAM,IAAI,MAAM,OAAO,UAAU,OAAO,UAAU,SAAS;;;;;;;;;;;;;;;;AAiBlF,SAAg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Q;IACR,UAAU;IACV,UAAU;IACV,YAAY;IACb;GACD;IAAE,QAAQ;IAAkB,UAAU;IAAO,UAAU;IAAY,YAAY;IAAQ;GACvF;IAAE,QAAQ;IAAmB,UAAU;IAAO,UAAU;IAAY,YAAY;IAAS;GAC1F;EACD,qBAAqB,EACnB,QAAQ;GACN,SAAS;GACT,OAAO;GACP,OAAO;GACR,EACF;EACF;CACF"}
@@ -0,0 +1,21 @@
1
+ import { SqlQueryOperationTypes } from "@prisma-next/sql-contract/types";
2
+
3
+ //#region src/types/operation-types.d.ts
4
+ type QueryOperationTypes = SqlQueryOperationTypes<{
5
+ readonly ilike: {
6
+ readonly args: readonly [{
7
+ readonly traits: readonly ['textual'];
8
+ readonly nullable: false;
9
+ }, {
10
+ readonly codecId: 'pg/text@1';
11
+ readonly nullable: false;
12
+ }];
13
+ readonly returns: {
14
+ readonly codecId: 'pg/bool@1';
15
+ readonly nullable: false;
16
+ };
17
+ };
18
+ }>;
19
+ //#endregion
20
+ export { type QueryOperationTypes };
21
+ //# sourceMappingURL=operation-types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operation-types.d.mts","names":[],"sources":["../src/types/operation-types.ts"],"sourcesContent":[],"mappings":";;;KAEY,mBAAA,GAAsB;;IAAtB,SAAA,IAAA,EAAA,SAAmB"}
@@ -0,0 +1 @@
1
+ export { };
@@ -1,4 +1,4 @@
1
- import { c as PostgresContract, l as PostgresLoweredStatement } from "./types-DxaTd7aP.mjs";
1
+ import { c as PostgresContract, l as PostgresLoweredStatement } from "./types-TyL62f9Y.mjs";
2
2
  import { Adapter, AnyQueryAst } from "@prisma-next/sql-relational-core/ast";
3
3
  import { RuntimeAdapterInstance } from "@prisma-next/framework-components/execution";
4
4
  import { SqlRuntimeAdapterDescriptor } from "@prisma-next/sql-runtime";
package/dist/runtime.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { m as PG_JSON_CODEC_ID, p as PG_JSONB_CODEC_ID } from "./codec-ids-BwjcIf74.mjs";
2
- import { t as codecDefinitions } from "./codecs-C3wlpdV7.mjs";
3
- import { t as createPostgresAdapter } from "./adapter-7pXt8ej9.mjs";
4
- import { t as postgresAdapterDescriptorMeta } from "./descriptor-meta-DemWrTfB.mjs";
1
+ import { m as PG_JSON_CODEC_ID, p as PG_JSONB_CODEC_ID } from "./codec-ids-5g4Gwrgm.mjs";
2
+ import { t as codecDefinitions } from "./codecs-DiPlMi3-.mjs";
3
+ import { t as createPostgresAdapter } from "./adapter-Du9Hr9Rl.mjs";
4
+ import { n as postgresQueryOperations, t as postgresAdapterDescriptorMeta } from "./descriptor-meta-BB9XPAFi.mjs";
5
5
  import { createCodecRegistry } from "@prisma-next/sql-relational-core/ast";
6
6
  import { type } from "arktype";
7
7
  import { builtinGeneratorIds } from "@prisma-next/ids";
@@ -86,6 +86,7 @@ const postgresRuntimeAdapterDescriptor = {
86
86
  ...postgresAdapterDescriptorMeta,
87
87
  codecs: createPostgresCodecRegistry,
88
88
  parameterizedCodecs: () => parameterizedCodecDescriptors,
89
+ queryOperations: () => postgresQueryOperations,
89
90
  mutationDefaultGenerators: createPostgresMutationDefaultGenerators,
90
91
  create() {
91
92
  return createPostgresAdapter();
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.mjs","names":["sharedAjv: Ajv | undefined","arktype","postgresRuntimeAdapterDescriptor: SqlRuntimeAdapterDescriptor<'postgres', SqlRuntimeAdapter>"],"sources":["../src/core/json-schema-validator.ts","../src/exports/runtime.ts"],"sourcesContent":["import type {\n JsonSchemaValidateFn,\n JsonSchemaValidationError,\n JsonSchemaValidationResult,\n} from '@prisma-next/sql-relational-core/query-lane-context';\nimport Ajv from 'ajv';\n\nexport type { JsonSchemaValidateFn, JsonSchemaValidationError, JsonSchemaValidationResult };\n\n/**\n * Shared Ajv instance for all JSON Schema validators.\n * Reusing a single instance avoids ~50-100KB memory overhead per compiled schema.\n */\nlet sharedAjv: Ajv | undefined;\n\nfunction getSharedAjv(): Ajv {\n if (!sharedAjv) {\n sharedAjv = new Ajv({ allErrors: false, strict: false });\n }\n return sharedAjv;\n}\n\n/**\n * Compiles a JSON Schema object into a reusable validate function using Ajv.\n *\n * The returned function validates a value against the schema and returns\n * a structured result with error details on failure.\n *\n * Uses a shared Ajv instance and fail-fast mode (`allErrors: false`)\n * to minimize memory and CPU overhead.\n *\n * @param schema - A JSON Schema object (draft-07 compatible)\n * @returns A validate function\n */\nexport function compileJsonSchemaValidator(schema: Record<string, unknown>): JsonSchemaValidateFn {\n const ajv = getSharedAjv();\n const validate = ajv.compile(schema);\n\n return (value: unknown): JsonSchemaValidationResult => {\n const valid = validate(value);\n if (valid) {\n return { valid: true };\n }\n\n const errors: JsonSchemaValidationError[] = (validate.errors ?? []).map((err) => ({\n path: err.instancePath || '/',\n message: err.message ?? 'unknown validation error',\n keyword: err.keyword,\n }));\n\n return { valid: false, errors };\n };\n}\n","import type { GeneratedValueSpec } from '@prisma-next/contract/types';\nimport type { RuntimeAdapterInstance } from '@prisma-next/framework-components/execution';\nimport { builtinGeneratorIds } from '@prisma-next/ids';\nimport { generateId } from '@prisma-next/ids/runtime';\nimport type { Adapter, AnyQueryAst, CodecRegistry } from '@prisma-next/sql-relational-core/ast';\nimport { createCodecRegistry } from '@prisma-next/sql-relational-core/ast';\nimport type {\n RuntimeParameterizedCodecDescriptor,\n SqlRuntimeAdapterDescriptor,\n} from '@prisma-next/sql-runtime';\nimport { type as arktype } from 'arktype';\nimport { createPostgresAdapter } from '../core/adapter';\nimport { PG_JSON_CODEC_ID, PG_JSONB_CODEC_ID } from '../core/codec-ids';\nimport { codecDefinitions } from '../core/codecs';\nimport { postgresAdapterDescriptorMeta } from '../core/descriptor-meta';\nimport {\n compileJsonSchemaValidator,\n type JsonSchemaValidateFn,\n} from '../core/json-schema-validator';\nimport type { PostgresContract, PostgresLoweredStatement } from '../core/types';\n\nexport interface SqlRuntimeAdapter\n extends RuntimeAdapterInstance<'sql', 'postgres'>,\n Adapter<AnyQueryAst, PostgresContract, PostgresLoweredStatement> {}\n\nfunction createPostgresCodecRegistry(): CodecRegistry {\n const registry = createCodecRegistry();\n for (const definition of Object.values(codecDefinitions)) {\n registry.register(definition.codec);\n }\n return registry;\n}\n\nconst jsonTypeParamsSchema = arktype({\n schemaJson: 'object',\n 'type?': 'string',\n});\n\n/** The inferred type params shape from the arktype schema. */\ntype JsonTypeParams = typeof jsonTypeParamsSchema.infer;\n\n/**\n * Helper returned by the JSON/JSONB `init` hook.\n * Contains a compiled JSON Schema validate function for runtime conformance checks.\n */\nexport type JsonCodecHelper = { readonly validate: JsonSchemaValidateFn };\n\nfunction createPostgresMutationDefaultGenerators() {\n return builtinGeneratorIds.map((id) => ({\n id,\n generate: (params?: Record<string, unknown>) => {\n const spec: GeneratedValueSpec = params ? { id, params } : { id };\n return generateId(spec);\n },\n }));\n}\n\nfunction initJsonCodecHelper(params: JsonTypeParams): JsonCodecHelper {\n return { validate: compileJsonSchemaValidator(params.schemaJson as Record<string, unknown>) };\n}\n\nconst parameterizedCodecDescriptors = [\n {\n codecId: PG_JSON_CODEC_ID,\n paramsSchema: jsonTypeParamsSchema,\n init: initJsonCodecHelper,\n },\n {\n codecId: PG_JSONB_CODEC_ID,\n paramsSchema: jsonTypeParamsSchema,\n init: initJsonCodecHelper,\n },\n] as const satisfies ReadonlyArray<\n RuntimeParameterizedCodecDescriptor<JsonTypeParams, JsonCodecHelper>\n>;\n\nconst postgresRuntimeAdapterDescriptor: SqlRuntimeAdapterDescriptor<'postgres', SqlRuntimeAdapter> =\n {\n ...postgresAdapterDescriptorMeta,\n codecs: createPostgresCodecRegistry,\n parameterizedCodecs: () => parameterizedCodecDescriptors,\n mutationDefaultGenerators: createPostgresMutationDefaultGenerators,\n create(): SqlRuntimeAdapter {\n return createPostgresAdapter();\n },\n };\n\nexport default postgresRuntimeAdapterDescriptor;\n"],"mappings":";;;;;;;;;;;;;;;AAaA,IAAIA;AAEJ,SAAS,eAAoB;AAC3B,KAAI,CAAC,UACH,aAAY,IAAI,IAAI;EAAE,WAAW;EAAO,QAAQ;EAAO,CAAC;AAE1D,QAAO;;;;;;;;;;;;;;AAeT,SAAgB,2BAA2B,QAAuD;CAEhG,MAAM,WADM,cAAc,CACL,QAAQ,OAAO;AAEpC,SAAQ,UAA+C;AAErD,MADc,SAAS,MAAM,CAE3B,QAAO,EAAE,OAAO,MAAM;AASxB,SAAO;GAAE,OAAO;GAAO,SANsB,SAAS,UAAU,EAAE,EAAE,KAAK,SAAS;IAChF,MAAM,IAAI,gBAAgB;IAC1B,SAAS,IAAI,WAAW;IACxB,SAAS,IAAI;IACd,EAAE;GAE4B;;;;;;ACzBnC,SAAS,8BAA6C;CACpD,MAAM,WAAW,qBAAqB;AACtC,MAAK,MAAM,cAAc,OAAO,OAAO,iBAAiB,CACtD,UAAS,SAAS,WAAW,MAAM;AAErC,QAAO;;AAGT,MAAM,uBAAuBC,KAAQ;CACnC,YAAY;CACZ,SAAS;CACV,CAAC;AAWF,SAAS,0CAA0C;AACjD,QAAO,oBAAoB,KAAK,QAAQ;EACtC;EACA,WAAW,WAAqC;AAE9C,UAAO,WAD0B,SAAS;IAAE;IAAI;IAAQ,GAAG,EAAE,IAAI,CAC1C;;EAE1B,EAAE;;AAGL,SAAS,oBAAoB,QAAyC;AACpE,QAAO,EAAE,UAAU,2BAA2B,OAAO,WAAsC,EAAE;;AAG/F,MAAM,gCAAgC,CACpC;CACE,SAAS;CACT,cAAc;CACd,MAAM;CACP,EACD;CACE,SAAS;CACT,cAAc;CACd,MAAM;CACP,CACF;AAID,MAAMC,mCACJ;CACE,GAAG;CACH,QAAQ;CACR,2BAA2B;CAC3B,2BAA2B;CAC3B,SAA4B;AAC1B,SAAO,uBAAuB;;CAEjC;AAEH,sBAAe"}
1
+ {"version":3,"file":"runtime.mjs","names":["sharedAjv: Ajv | undefined","arktype","postgresRuntimeAdapterDescriptor: SqlRuntimeAdapterDescriptor<'postgres', SqlRuntimeAdapter>"],"sources":["../src/core/json-schema-validator.ts","../src/exports/runtime.ts"],"sourcesContent":["import type {\n JsonSchemaValidateFn,\n JsonSchemaValidationError,\n JsonSchemaValidationResult,\n} from '@prisma-next/sql-relational-core/query-lane-context';\nimport Ajv from 'ajv';\n\nexport type { JsonSchemaValidateFn, JsonSchemaValidationError, JsonSchemaValidationResult };\n\n/**\n * Shared Ajv instance for all JSON Schema validators.\n * Reusing a single instance avoids ~50-100KB memory overhead per compiled schema.\n */\nlet sharedAjv: Ajv | undefined;\n\nfunction getSharedAjv(): Ajv {\n if (!sharedAjv) {\n sharedAjv = new Ajv({ allErrors: false, strict: false });\n }\n return sharedAjv;\n}\n\n/**\n * Compiles a JSON Schema object into a reusable validate function using Ajv.\n *\n * The returned function validates a value against the schema and returns\n * a structured result with error details on failure.\n *\n * Uses a shared Ajv instance and fail-fast mode (`allErrors: false`)\n * to minimize memory and CPU overhead.\n *\n * @param schema - A JSON Schema object (draft-07 compatible)\n * @returns A validate function\n */\nexport function compileJsonSchemaValidator(schema: Record<string, unknown>): JsonSchemaValidateFn {\n const ajv = getSharedAjv();\n const validate = ajv.compile(schema);\n\n return (value: unknown): JsonSchemaValidationResult => {\n const valid = validate(value);\n if (valid) {\n return { valid: true };\n }\n\n const errors: JsonSchemaValidationError[] = (validate.errors ?? []).map((err) => ({\n path: err.instancePath || '/',\n message: err.message ?? 'unknown validation error',\n keyword: err.keyword,\n }));\n\n return { valid: false, errors };\n };\n}\n","import type { GeneratedValueSpec } from '@prisma-next/contract/types';\nimport type { RuntimeAdapterInstance } from '@prisma-next/framework-components/execution';\nimport { builtinGeneratorIds } from '@prisma-next/ids';\nimport { generateId } from '@prisma-next/ids/runtime';\nimport type { Adapter, AnyQueryAst, CodecRegistry } from '@prisma-next/sql-relational-core/ast';\nimport { createCodecRegistry } from '@prisma-next/sql-relational-core/ast';\nimport type {\n RuntimeParameterizedCodecDescriptor,\n SqlRuntimeAdapterDescriptor,\n} from '@prisma-next/sql-runtime';\nimport { type as arktype } from 'arktype';\nimport { createPostgresAdapter } from '../core/adapter';\nimport { PG_JSON_CODEC_ID, PG_JSONB_CODEC_ID } from '../core/codec-ids';\nimport { codecDefinitions } from '../core/codecs';\nimport { postgresAdapterDescriptorMeta, postgresQueryOperations } from '../core/descriptor-meta';\nimport {\n compileJsonSchemaValidator,\n type JsonSchemaValidateFn,\n} from '../core/json-schema-validator';\nimport type { PostgresContract, PostgresLoweredStatement } from '../core/types';\n\nexport interface SqlRuntimeAdapter\n extends RuntimeAdapterInstance<'sql', 'postgres'>,\n Adapter<AnyQueryAst, PostgresContract, PostgresLoweredStatement> {}\n\nfunction createPostgresCodecRegistry(): CodecRegistry {\n const registry = createCodecRegistry();\n for (const definition of Object.values(codecDefinitions)) {\n registry.register(definition.codec);\n }\n return registry;\n}\n\nconst jsonTypeParamsSchema = arktype({\n schemaJson: 'object',\n 'type?': 'string',\n});\n\n/** The inferred type params shape from the arktype schema. */\ntype JsonTypeParams = typeof jsonTypeParamsSchema.infer;\n\n/**\n * Helper returned by the JSON/JSONB `init` hook.\n * Contains a compiled JSON Schema validate function for runtime conformance checks.\n */\nexport type JsonCodecHelper = { readonly validate: JsonSchemaValidateFn };\n\nfunction createPostgresMutationDefaultGenerators() {\n return builtinGeneratorIds.map((id) => ({\n id,\n generate: (params?: Record<string, unknown>) => {\n const spec: GeneratedValueSpec = params ? { id, params } : { id };\n return generateId(spec);\n },\n }));\n}\n\nfunction initJsonCodecHelper(params: JsonTypeParams): JsonCodecHelper {\n return { validate: compileJsonSchemaValidator(params.schemaJson as Record<string, unknown>) };\n}\n\nconst parameterizedCodecDescriptors = [\n {\n codecId: PG_JSON_CODEC_ID,\n paramsSchema: jsonTypeParamsSchema,\n init: initJsonCodecHelper,\n },\n {\n codecId: PG_JSONB_CODEC_ID,\n paramsSchema: jsonTypeParamsSchema,\n init: initJsonCodecHelper,\n },\n] as const satisfies ReadonlyArray<\n RuntimeParameterizedCodecDescriptor<JsonTypeParams, JsonCodecHelper>\n>;\n\nconst postgresRuntimeAdapterDescriptor: SqlRuntimeAdapterDescriptor<'postgres', SqlRuntimeAdapter> =\n {\n ...postgresAdapterDescriptorMeta,\n codecs: createPostgresCodecRegistry,\n parameterizedCodecs: () => parameterizedCodecDescriptors,\n queryOperations: () => postgresQueryOperations,\n mutationDefaultGenerators: createPostgresMutationDefaultGenerators,\n create(): SqlRuntimeAdapter {\n return createPostgresAdapter();\n },\n };\n\nexport default postgresRuntimeAdapterDescriptor;\n"],"mappings":";;;;;;;;;;;;;;;AAaA,IAAIA;AAEJ,SAAS,eAAoB;AAC3B,KAAI,CAAC,UACH,aAAY,IAAI,IAAI;EAAE,WAAW;EAAO,QAAQ;EAAO,CAAC;AAE1D,QAAO;;;;;;;;;;;;;;AAeT,SAAgB,2BAA2B,QAAuD;CAEhG,MAAM,WADM,cAAc,CACL,QAAQ,OAAO;AAEpC,SAAQ,UAA+C;AAErD,MADc,SAAS,MAAM,CAE3B,QAAO,EAAE,OAAO,MAAM;AASxB,SAAO;GAAE,OAAO;GAAO,SANsB,SAAS,UAAU,EAAE,EAAE,KAAK,SAAS;IAChF,MAAM,IAAI,gBAAgB;IAC1B,SAAS,IAAI,WAAW;IACxB,SAAS,IAAI;IACd,EAAE;GAE4B;;;;;;ACzBnC,SAAS,8BAA6C;CACpD,MAAM,WAAW,qBAAqB;AACtC,MAAK,MAAM,cAAc,OAAO,OAAO,iBAAiB,CACtD,UAAS,SAAS,WAAW,MAAM;AAErC,QAAO;;AAGT,MAAM,uBAAuBC,KAAQ;CACnC,YAAY;CACZ,SAAS;CACV,CAAC;AAWF,SAAS,0CAA0C;AACjD,QAAO,oBAAoB,KAAK,QAAQ;EACtC;EACA,WAAW,WAAqC;AAE9C,UAAO,WAD0B,SAAS;IAAE;IAAI;IAAQ,GAAG,EAAE,IAAI,CAC1C;;EAE1B,EAAE;;AAGL,SAAS,oBAAoB,QAAyC;AACpE,QAAO,EAAE,UAAU,2BAA2B,OAAO,WAAsC,EAAE;;AAG/F,MAAM,gCAAgC,CACpC;CACE,SAAS;CACT,cAAc;CACd,MAAM;CACP,EACD;CACE,SAAS;CACT,cAAc;CACd,MAAM;CACP,CACF;AAID,MAAMC,mCACJ;CACE,GAAG;CACH,QAAQ;CACR,2BAA2B;CAC3B,uBAAuB;CACvB,2BAA2B;CAC3B,SAA4B;AAC1B,SAAO,uBAAuB;;CAEjC;AAEH,sBAAe"}
@@ -75,4 +75,4 @@ function validateEnumValueLength(value, enumTypeName) {
75
75
 
76
76
  //#endregion
77
77
  export { validateEnumValueLength as a, quoteIdentifier as i, escapeLiteral as n, qualifyName as r, SqlEscapeError as t };
78
- //# sourceMappingURL=sql-utils-CSfAGEwF.mjs.map
78
+ //# sourceMappingURL=sql-utils-DkUJyZmA.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"sql-utils-CSfAGEwF.mjs","names":["value: string","kind: 'identifier' | 'literal'"],"sources":["../src/core/sql-utils.ts"],"sourcesContent":["/**\n * Shared SQL utility functions for the Postgres adapter.\n *\n * These functions handle safe SQL identifier and literal escaping\n * with security validations to prevent injection and encoding issues.\n */\n\n/**\n * Error thrown when an invalid SQL identifier or literal is detected.\n * Boundary layers map this to structured envelopes.\n */\nexport class SqlEscapeError extends Error {\n constructor(\n message: string,\n public readonly value: string,\n public readonly kind: 'identifier' | 'literal',\n ) {\n super(message);\n this.name = 'SqlEscapeError';\n }\n}\n\n/**\n * Maximum length for PostgreSQL identifiers (NAMEDATALEN - 1).\n */\nconst MAX_IDENTIFIER_LENGTH = 63;\n\n/**\n * Validates and quotes a PostgreSQL identifier (table, column, type, schema names).\n *\n * Security validations:\n * - Rejects null bytes which could cause truncation or unexpected behavior\n * - Rejects empty identifiers\n * - Warns on identifiers exceeding PostgreSQL's 63-character limit\n *\n * @throws {SqlEscapeError} If the identifier contains null bytes or is empty\n */\nexport function quoteIdentifier(identifier: string): string {\n if (identifier.length === 0) {\n throw new SqlEscapeError('Identifier cannot be empty', identifier, 'identifier');\n }\n if (identifier.includes('\\0')) {\n throw new SqlEscapeError(\n 'Identifier cannot contain null bytes',\n identifier.replace(/\\0/g, '\\\\0'),\n 'identifier',\n );\n }\n // PostgreSQL will truncate identifiers longer than 63 characters.\n // We don't throw here because it's not a security issue, but callers should be aware.\n if (identifier.length > MAX_IDENTIFIER_LENGTH) {\n // Log warning in development, but don't fail - PostgreSQL handles truncation\n console.warn(\n `Identifier \"${identifier.slice(0, 20)}...\" exceeds PostgreSQL's ${MAX_IDENTIFIER_LENGTH}-character limit and will be truncated`,\n );\n }\n return `\"${identifier.replace(/\"/g, '\"\"')}\"`;\n}\n\n/**\n * Escapes a string literal for safe use in SQL statements.\n *\n * Security validations:\n * - Rejects null bytes which could cause truncation or unexpected behavior\n *\n * Note: This assumes PostgreSQL's `standard_conforming_strings` is ON (default since PG 9.1).\n * Backslashes are treated as literal characters, not escape sequences.\n *\n * @throws {SqlEscapeError} If the value contains null bytes\n */\nexport function escapeLiteral(value: string): string {\n if (value.includes('\\0')) {\n throw new SqlEscapeError(\n 'Literal value cannot contain null bytes',\n value.replace(/\\0/g, '\\\\0'),\n 'literal',\n );\n }\n return value.replace(/'/g, \"''\");\n}\n\n/**\n * Builds a qualified name (schema.object) with proper quoting.\n */\nexport function qualifyName(schemaName: string, objectName: string): string {\n return `${quoteIdentifier(schemaName)}.${quoteIdentifier(objectName)}`;\n}\n\n/**\n * Validates that an enum value doesn't exceed PostgreSQL's label length limit.\n *\n * PostgreSQL enum labels have a maximum length of NAMEDATALEN-1 (63 bytes by default).\n * Unlike identifiers, enum labels that exceed this limit cause an error rather than\n * silent truncation.\n *\n * @param value - The enum value to validate\n * @param enumTypeName - Name of the enum type (for error messages)\n * @throws {SqlEscapeError} If the value exceeds the maximum length\n */\nexport function validateEnumValueLength(value: string, enumTypeName: string): void {\n // PostgreSQL uses byte length, not character length. For simplicity, we use\n // character length as a conservative approximation (multi-byte chars would fail earlier).\n if (value.length > MAX_IDENTIFIER_LENGTH) {\n throw new SqlEscapeError(\n `Enum value \"${value.slice(0, 20)}...\" for type \"${enumTypeName}\" exceeds PostgreSQL's ` +\n `${MAX_IDENTIFIER_LENGTH}-character label limit`,\n value,\n 'literal',\n );\n }\n}\n"],"mappings":";;;;;;;;;;;AAWA,IAAa,iBAAb,cAAoC,MAAM;CACxC,YACE,SACA,AAAgBA,OAChB,AAAgBC,MAChB;AACA,QAAM,QAAQ;EAHE;EACA;AAGhB,OAAK,OAAO;;;;;;AAOhB,MAAM,wBAAwB;;;;;;;;;;;AAY9B,SAAgB,gBAAgB,YAA4B;AAC1D,KAAI,WAAW,WAAW,EACxB,OAAM,IAAI,eAAe,8BAA8B,YAAY,aAAa;AAElF,KAAI,WAAW,SAAS,KAAK,CAC3B,OAAM,IAAI,eACR,wCACA,WAAW,QAAQ,OAAO,MAAM,EAChC,aACD;AAIH,KAAI,WAAW,SAAS,sBAEtB,SAAQ,KACN,eAAe,WAAW,MAAM,GAAG,GAAG,CAAC,4BAA4B,sBAAsB,wCAC1F;AAEH,QAAO,IAAI,WAAW,QAAQ,MAAM,OAAK,CAAC;;;;;;;;;;;;;AAc5C,SAAgB,cAAc,OAAuB;AACnD,KAAI,MAAM,SAAS,KAAK,CACtB,OAAM,IAAI,eACR,2CACA,MAAM,QAAQ,OAAO,MAAM,EAC3B,UACD;AAEH,QAAO,MAAM,QAAQ,MAAM,KAAK;;;;;AAMlC,SAAgB,YAAY,YAAoB,YAA4B;AAC1E,QAAO,GAAG,gBAAgB,WAAW,CAAC,GAAG,gBAAgB,WAAW;;;;;;;;;;;;;AActE,SAAgB,wBAAwB,OAAe,cAA4B;AAGjF,KAAI,MAAM,SAAS,sBACjB,OAAM,IAAI,eACR,eAAe,MAAM,MAAM,GAAG,GAAG,CAAC,iBAAiB,aAAa,yBAC3D,sBAAsB,yBAC3B,OACA,UACD"}
1
+ {"version":3,"file":"sql-utils-DkUJyZmA.mjs","names":["value: string","kind: 'identifier' | 'literal'"],"sources":["../src/core/sql-utils.ts"],"sourcesContent":["/**\n * Shared SQL utility functions for the Postgres adapter.\n *\n * These functions handle safe SQL identifier and literal escaping\n * with security validations to prevent injection and encoding issues.\n */\n\n/**\n * Error thrown when an invalid SQL identifier or literal is detected.\n * Boundary layers map this to structured envelopes.\n */\nexport class SqlEscapeError extends Error {\n constructor(\n message: string,\n public readonly value: string,\n public readonly kind: 'identifier' | 'literal',\n ) {\n super(message);\n this.name = 'SqlEscapeError';\n }\n}\n\n/**\n * Maximum length for PostgreSQL identifiers (NAMEDATALEN - 1).\n */\nconst MAX_IDENTIFIER_LENGTH = 63;\n\n/**\n * Validates and quotes a PostgreSQL identifier (table, column, type, schema names).\n *\n * Security validations:\n * - Rejects null bytes which could cause truncation or unexpected behavior\n * - Rejects empty identifiers\n * - Warns on identifiers exceeding PostgreSQL's 63-character limit\n *\n * @throws {SqlEscapeError} If the identifier contains null bytes or is empty\n */\nexport function quoteIdentifier(identifier: string): string {\n if (identifier.length === 0) {\n throw new SqlEscapeError('Identifier cannot be empty', identifier, 'identifier');\n }\n if (identifier.includes('\\0')) {\n throw new SqlEscapeError(\n 'Identifier cannot contain null bytes',\n identifier.replace(/\\0/g, '\\\\0'),\n 'identifier',\n );\n }\n // PostgreSQL will truncate identifiers longer than 63 characters.\n // We don't throw here because it's not a security issue, but callers should be aware.\n if (identifier.length > MAX_IDENTIFIER_LENGTH) {\n // Log warning in development, but don't fail - PostgreSQL handles truncation\n console.warn(\n `Identifier \"${identifier.slice(0, 20)}...\" exceeds PostgreSQL's ${MAX_IDENTIFIER_LENGTH}-character limit and will be truncated`,\n );\n }\n return `\"${identifier.replace(/\"/g, '\"\"')}\"`;\n}\n\n/**\n * Escapes a string literal for safe use in SQL statements.\n *\n * Security validations:\n * - Rejects null bytes which could cause truncation or unexpected behavior\n *\n * Note: This assumes PostgreSQL's `standard_conforming_strings` is ON (default since PG 9.1).\n * Backslashes are treated as literal characters, not escape sequences.\n *\n * @throws {SqlEscapeError} If the value contains null bytes\n */\nexport function escapeLiteral(value: string): string {\n if (value.includes('\\0')) {\n throw new SqlEscapeError(\n 'Literal value cannot contain null bytes',\n value.replace(/\\0/g, '\\\\0'),\n 'literal',\n );\n }\n return value.replace(/'/g, \"''\");\n}\n\n/**\n * Builds a qualified name (schema.object) with proper quoting.\n */\nexport function qualifyName(schemaName: string, objectName: string): string {\n return `${quoteIdentifier(schemaName)}.${quoteIdentifier(objectName)}`;\n}\n\n/**\n * Validates that an enum value doesn't exceed PostgreSQL's label length limit.\n *\n * PostgreSQL enum labels have a maximum length of NAMEDATALEN-1 (63 bytes by default).\n * Unlike identifiers, enum labels that exceed this limit cause an error rather than\n * silent truncation.\n *\n * @param value - The enum value to validate\n * @param enumTypeName - Name of the enum type (for error messages)\n * @throws {SqlEscapeError} If the value exceeds the maximum length\n */\nexport function validateEnumValueLength(value: string, enumTypeName: string): void {\n // PostgreSQL uses byte length, not character length. For simplicity, we use\n // character length as a conservative approximation (multi-byte chars would fail earlier).\n if (value.length > MAX_IDENTIFIER_LENGTH) {\n throw new SqlEscapeError(\n `Enum value \"${value.slice(0, 20)}...\" for type \"${enumTypeName}\" exceeds PostgreSQL's ` +\n `${MAX_IDENTIFIER_LENGTH}-character label limit`,\n value,\n 'literal',\n );\n }\n}\n"],"mappings":";;;;;;;;;;;AAWA,IAAa,iBAAb,cAAoC,MAAM;CACxC,YACE,SACA,AAAgBA,OAChB,AAAgBC,MAChB;AACA,QAAM,QAAQ;EAHE;EACA;AAGhB,OAAK,OAAO;;;;;;AAOhB,MAAM,wBAAwB;;;;;;;;;;;AAY9B,SAAgB,gBAAgB,YAA4B;AAC1D,KAAI,WAAW,WAAW,EACxB,OAAM,IAAI,eAAe,8BAA8B,YAAY,aAAa;AAElF,KAAI,WAAW,SAAS,KAAK,CAC3B,OAAM,IAAI,eACR,wCACA,WAAW,QAAQ,OAAO,MAAM,EAChC,aACD;AAIH,KAAI,WAAW,SAAS,sBAEtB,SAAQ,KACN,eAAe,WAAW,MAAM,GAAG,GAAG,CAAC,4BAA4B,sBAAsB,wCAC1F;AAEH,QAAO,IAAI,WAAW,QAAQ,MAAM,OAAK,CAAC;;;;;;;;;;;;;AAc5C,SAAgB,cAAc,OAAuB;AACnD,KAAI,MAAM,SAAS,KAAK,CACtB,OAAM,IAAI,eACR,2CACA,MAAM,QAAQ,OAAO,MAAM,EAC3B,UACD;AAEH,QAAO,MAAM,QAAQ,MAAM,KAAK;;;;;AAMlC,SAAgB,YAAY,YAAoB,YAA4B;AAC1E,QAAO,GAAG,gBAAgB,WAAW,CAAC,GAAG,gBAAgB,WAAW;;;;;;;;;;;;;AActE,SAAgB,wBAAwB,OAAe,cAA4B;AAGjF,KAAI,MAAM,SAAS,sBACjB,OAAM,IAAI,eACR,eAAe,MAAM,MAAM,GAAG,GAAG,CAAC,iBAAiB,aAAa,yBAC3D,sBAAsB,yBAC3B,OACA,UACD"}
@@ -17,4 +17,4 @@ interface OrderClause {
17
17
  type PostgresLoweredStatement = LoweredStatement;
18
18
  //#endregion
19
19
  export { OrderClause as a, PostgresContract as c, StorageColumn as d, StorageTable as f, Expr as i, PostgresLoweredStatement as l, ColumnRef as n, ParamRef as o, Direction as r, PostgresAdapterOptions as s, BinaryExpr as t, SelectAst as u };
20
- //# sourceMappingURL=types-DxaTd7aP.d.mts.map
20
+ //# sourceMappingURL=types-TyL62f9Y.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types-DxaTd7aP.d.mts","names":[],"sources":["../src/core/types.ts"],"sourcesContent":[],"mappings":";;;;;UAmBiB,sBAAA;;AAAjB;AAIY,KAAA,gBAAA,GAAmB,QAAS,CAAA,UAAT,CAAA,GAAA;EAEnB,SAAI,MAAA,EAAA,UAAA;CAAG;AAAY,KAAnB,IAAA,GAAO,SAAY,GAAA,QAAA,GAAW,gBAAX;AAAW,UAEzB,WAAA,CAFyB;EAAgB,SAAA,IAAA,EAGzC,SAHyC;EAEzC,SAAA,GAAA,EAED,SAFY;AAK5B;KAAY,wBAAA,GAA2B"}
1
+ {"version":3,"file":"types-TyL62f9Y.d.mts","names":[],"sources":["../src/core/types.ts"],"sourcesContent":[],"mappings":";;;;;UAmBiB,sBAAA;;AAAjB;AAIY,KAAA,gBAAA,GAAmB,QAAS,CAAA,UAAT,CAAA,GAAA;EAEnB,SAAI,MAAA,EAAA,UAAA;CAAG;AAAY,KAAnB,IAAA,GAAO,SAAY,GAAA,QAAA,GAAW,gBAAX;AAAW,UAEzB,WAAA,CAFyB;EAAgB,SAAA,IAAA,EAGzC,SAHyC;EAEzC,SAAA,GAAA,EAED,SAFY;AAK5B;KAAY,wBAAA,GAA2B"}
package/dist/types.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as OrderClause, c as PostgresContract, d as StorageColumn, f as StorageTable, i as Expr, l as PostgresLoweredStatement, n as ColumnRef, o as ParamRef, r as Direction, s as PostgresAdapterOptions, t as BinaryExpr, u as SelectAst } from "./types-DxaTd7aP.mjs";
1
+ import { a as OrderClause, c as PostgresContract, d as StorageColumn, f as StorageTable, i as Expr, l as PostgresLoweredStatement, n as ColumnRef, o as ParamRef, r as Direction, s as PostgresAdapterOptions, t as BinaryExpr, u as SelectAst } from "./types-TyL62f9Y.mjs";
2
2
  export { type BinaryExpr, type ColumnRef, type Direction, type Expr, type OrderClause, type ParamRef, type PostgresAdapterOptions, type PostgresContract, type PostgresLoweredStatement, type SelectAst, type StorageColumn, type StorageTable };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma-next/adapter-postgres",
3
- "version": "0.4.0-dev.9",
3
+ "version": "0.4.1",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "files": [
@@ -10,19 +10,19 @@
10
10
  "dependencies": {
11
11
  "ajv": "^8.18.0",
12
12
  "arktype": "^2.0.0",
13
- "@prisma-next/contract": "0.4.0-dev.9",
14
- "@prisma-next/contract-authoring": "0.4.0-dev.9",
15
- "@prisma-next/family-sql": "0.4.0-dev.9",
16
- "@prisma-next/framework-components": "0.4.0-dev.9",
17
- "@prisma-next/ids": "0.4.0-dev.9",
18
- "@prisma-next/sql-contract": "0.4.0-dev.9",
19
- "@prisma-next/sql-contract-psl": "0.4.0-dev.9",
20
- "@prisma-next/sql-operations": "0.4.0-dev.9",
21
- "@prisma-next/sql-schema-ir": "0.4.0-dev.9",
22
- "@prisma-next/sql-contract-ts": "0.4.0-dev.9",
23
- "@prisma-next/sql-relational-core": "0.4.0-dev.9",
24
- "@prisma-next/utils": "0.4.0-dev.9",
25
- "@prisma-next/sql-runtime": "0.4.0-dev.9"
13
+ "@prisma-next/contract": "0.4.1",
14
+ "@prisma-next/contract-authoring": "0.4.1",
15
+ "@prisma-next/sql-contract": "0.4.1",
16
+ "@prisma-next/family-sql": "0.4.1",
17
+ "@prisma-next/framework-components": "0.4.1",
18
+ "@prisma-next/sql-contract-psl": "0.4.1",
19
+ "@prisma-next/sql-operations": "0.4.1",
20
+ "@prisma-next/sql-contract-ts": "0.4.1",
21
+ "@prisma-next/sql-relational-core": "0.4.1",
22
+ "@prisma-next/ids": "0.4.1",
23
+ "@prisma-next/sql-runtime": "0.4.1",
24
+ "@prisma-next/sql-schema-ir": "0.4.1",
25
+ "@prisma-next/utils": "0.4.1"
26
26
  },
27
27
  "devDependencies": {
28
28
  "tsdown": "0.18.4",
@@ -37,6 +37,7 @@
37
37
  "./codec-types": "./dist/codec-types.mjs",
38
38
  "./column-types": "./dist/column-types.mjs",
39
39
  "./control": "./dist/control.mjs",
40
+ "./operation-types": "./dist/operation-types.mjs",
40
41
  "./runtime": "./dist/runtime.mjs",
41
42
  "./types": "./dist/types.mjs",
42
43
  "./package.json": "./package.json"
@@ -340,7 +340,6 @@ function renderBinary(expr: BinaryExpr, contract?: PostgresContract, pim?: Param
340
340
  gte: '>=',
341
341
  lte: '<=',
342
342
  like: 'LIKE',
343
- ilike: 'ILIKE',
344
343
  in: 'IN',
345
344
  notIn: 'NOT IN',
346
345
  };
@@ -1,4 +1,5 @@
1
1
  import type { CodecControlHooks, ExpandNativeTypeInput } from '@prisma-next/family-sql/control';
2
+ import type { SqlOperationDescriptor } from '@prisma-next/sql-operations';
2
3
  import {
3
4
  PG_BIT_CODEC_ID,
4
5
  PG_BOOL_CODEC_ID,
@@ -127,6 +128,18 @@ const identityHooks: CodecControlHooks = { expandNativeType: ({ nativeType }) =>
127
128
  // Descriptor metadata
128
129
  // ============================================================================
129
130
 
131
+ export const postgresQueryOperations: readonly SqlOperationDescriptor[] = [
132
+ {
133
+ method: 'ilike',
134
+ args: [
135
+ { traits: ['textual'], nullable: false },
136
+ { codecId: PG_TEXT_CODEC_ID, nullable: false },
137
+ ],
138
+ returns: { codecId: PG_BOOL_CODEC_ID, nullable: false },
139
+ lowering: { targetFamily: 'sql', strategy: 'infix', template: '{{self}} ILIKE {{arg0}}' },
140
+ },
141
+ ];
142
+
130
143
  export const postgresAdapterDescriptorMeta = {
131
144
  kind: 'adapter',
132
145
  familyId: 'sql',
@@ -255,5 +268,12 @@ export const postgresAdapterDescriptorMeta = {
255
268
  { typeId: PG_JSON_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'json' },
256
269
  { typeId: PG_JSONB_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'jsonb' },
257
270
  ],
271
+ queryOperationTypes: {
272
+ import: {
273
+ package: '@prisma-next/adapter-postgres/operation-types',
274
+ named: 'QueryOperationTypes',
275
+ alias: 'PgAdapterQueryOps',
276
+ },
277
+ },
258
278
  },
259
279
  } as const;
@@ -0,0 +1 @@
1
+ export type { QueryOperationTypes } from '../types/operation-types';
@@ -12,7 +12,7 @@ import { type as arktype } from 'arktype';
12
12
  import { createPostgresAdapter } from '../core/adapter';
13
13
  import { PG_JSON_CODEC_ID, PG_JSONB_CODEC_ID } from '../core/codec-ids';
14
14
  import { codecDefinitions } from '../core/codecs';
15
- import { postgresAdapterDescriptorMeta } from '../core/descriptor-meta';
15
+ import { postgresAdapterDescriptorMeta, postgresQueryOperations } from '../core/descriptor-meta';
16
16
  import {
17
17
  compileJsonSchemaValidator,
18
18
  type JsonSchemaValidateFn,
@@ -79,6 +79,7 @@ const postgresRuntimeAdapterDescriptor: SqlRuntimeAdapterDescriptor<'postgres',
79
79
  ...postgresAdapterDescriptorMeta,
80
80
  codecs: createPostgresCodecRegistry,
81
81
  parameterizedCodecs: () => parameterizedCodecDescriptors,
82
+ queryOperations: () => postgresQueryOperations,
82
83
  mutationDefaultGenerators: createPostgresMutationDefaultGenerators,
83
84
  create(): SqlRuntimeAdapter {
84
85
  return createPostgresAdapter();
@@ -0,0 +1,11 @@
1
+ import type { SqlQueryOperationTypes } from '@prisma-next/sql-contract/types';
2
+
3
+ export type QueryOperationTypes = SqlQueryOperationTypes<{
4
+ readonly ilike: {
5
+ readonly args: readonly [
6
+ { readonly traits: readonly ['textual']; readonly nullable: false },
7
+ { readonly codecId: 'pg/text@1'; readonly nullable: false },
8
+ ];
9
+ readonly returns: { readonly codecId: 'pg/bool@1'; readonly nullable: false };
10
+ };
11
+ }>;
@@ -1 +0,0 @@
1
- {"version":3,"file":"adapter-7pXt8ej9.mjs","names":["parameterizedCodecs: ReadonlyArray<CodecParamsDescriptor>","codec","paramIndexMap: ParamIndexMap","params: unknown[]","sql: string","right: string","orderedColumns: string[]","value: string"],"sources":["../src/core/adapter.ts"],"sourcesContent":["import {\n type Adapter,\n type AdapterProfile,\n type AggregateExpr,\n type AnyExpression,\n type AnyFromSource,\n type AnyQueryAst,\n type BinaryExpr,\n type CodecParamsDescriptor,\n type ColumnRef,\n createCodecRegistry,\n type DeleteAst,\n type InsertAst,\n type InsertValue,\n type JoinAst,\n type JoinOnExpr,\n type JsonArrayAggExpr,\n type JsonObjectExpr,\n type ListExpression,\n LiteralExpr,\n type LowererContext,\n type NullCheckExpr,\n type OperationExpr,\n type OrderByItem,\n type ParamRef,\n type ProjectionItem,\n type SelectAst,\n type SubqueryExpr,\n type UpdateAst,\n} from '@prisma-next/sql-relational-core/ast';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { PG_JSON_CODEC_ID, PG_JSONB_CODEC_ID } from './codec-ids';\nimport { codecDefinitions } from './codecs';\nimport { escapeLiteral, quoteIdentifier } from './sql-utils';\nimport type { PostgresAdapterOptions, PostgresContract, PostgresLoweredStatement } from './types';\n\nconst VECTOR_CODEC_ID = 'pg/vector@1' as const;\n\nfunction getCodecParamCast(codecId: string | undefined): string | undefined {\n if (codecId === VECTOR_CODEC_ID) {\n return 'vector';\n }\n if (codecId === PG_JSON_CODEC_ID) {\n return 'json';\n }\n if (codecId === PG_JSONB_CODEC_ID) {\n return 'jsonb';\n }\n return undefined;\n}\n\nfunction renderTypedParam(index: number, codecId: string | undefined): string {\n const cast = getCodecParamCast(codecId);\n return cast ? `$${index}::${cast}` : `$${index}`;\n}\n\ntype ParamIndexMap = Map<ParamRef, number>;\n\nconst defaultCapabilities = Object.freeze({\n postgres: {\n orderBy: true,\n limit: true,\n lateral: true,\n jsonAgg: true,\n returning: true,\n },\n sql: {\n enums: true,\n returning: true,\n defaultInInsert: true,\n },\n});\n\ntype AdapterCodec = (typeof codecDefinitions)[keyof typeof codecDefinitions]['codec'];\ntype ParameterizedCodec = AdapterCodec & {\n readonly paramsSchema: NonNullable<AdapterCodec['paramsSchema']>;\n};\n\nconst parameterizedCodecs: ReadonlyArray<CodecParamsDescriptor> = Object.values(codecDefinitions)\n .map((definition) => definition.codec)\n .filter((codec): codec is ParameterizedCodec => codec.paramsSchema !== undefined)\n .map((codec) =>\n Object.freeze({\n codecId: codec.id,\n paramsSchema: codec.paramsSchema,\n ...ifDefined('init', codec.init),\n }),\n );\n\nclass PostgresAdapterImpl\n implements Adapter<AnyQueryAst, PostgresContract, PostgresLoweredStatement>\n{\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 readMarkerStatement: () => ({\n sql: 'select core_hash, profile_hash, contract_json, canonical_version, updated_at, app_tag, meta from prisma_contract.marker where id = $1',\n params: [1],\n }),\n });\n }\n\n parameterizedCodecs(): ReadonlyArray<CodecParamsDescriptor> {\n return parameterizedCodecs;\n }\n\n lower(ast: AnyQueryAst, context: LowererContext<PostgresContract>) {\n const collectedParamRefs = ast.collectParamRefs();\n const paramIndexMap: ParamIndexMap = new Map();\n const params: unknown[] = [];\n for (const ref of collectedParamRefs) {\n if (paramIndexMap.has(ref)) {\n continue;\n }\n paramIndexMap.set(ref, params.length + 1);\n params.push(ref.value);\n }\n\n let sql: string;\n\n const node = ast;\n switch (node.kind) {\n case 'select':\n sql = renderSelect(node, context.contract, paramIndexMap);\n break;\n case 'insert':\n sql = renderInsert(node, context.contract, paramIndexMap);\n break;\n case 'update':\n sql = renderUpdate(node, context.contract, paramIndexMap);\n break;\n case 'delete':\n sql = renderDelete(node, context.contract, paramIndexMap);\n break;\n // v8 ignore next 4\n default:\n throw new Error(\n `Unsupported AST node kind: ${(node satisfies never as { kind: string }).kind}`,\n );\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, pim?: ParamIndexMap): string {\n const selectClause = `SELECT ${renderDistinctPrefix(ast.distinct, ast.distinctOn, contract, pim)}${renderProjection(\n ast.projection,\n contract,\n pim,\n )}`;\n const fromClause = `FROM ${renderSource(ast.from, contract, pim)}`;\n\n const joinsClause = ast.joins?.length\n ? ast.joins.map((join) => renderJoin(join, contract, pim)).join(' ')\n : '';\n\n const whereClause = ast.where ? `WHERE ${renderWhere(ast.where, contract, pim)}` : '';\n const groupByClause = ast.groupBy?.length\n ? `GROUP BY ${ast.groupBy.map((expr) => renderExpr(expr, contract, pim)).join(', ')}`\n : '';\n const havingClause = ast.having ? `HAVING ${renderWhere(ast.having, contract, pim)}` : '';\n const orderClause = ast.orderBy?.length\n ? `ORDER BY ${ast.orderBy\n .map((order) => {\n const expr = renderExpr(order.expr, contract, pim);\n return `${expr} ${order.dir.toUpperCase()}`;\n })\n .join(', ')}`\n : '';\n const limitClause = typeof ast.limit === 'number' ? `LIMIT ${ast.limit}` : '';\n const offsetClause = typeof ast.offset === 'number' ? `OFFSET ${ast.offset}` : '';\n\n const clauses = [\n selectClause,\n fromClause,\n joinsClause,\n whereClause,\n groupByClause,\n havingClause,\n orderClause,\n limitClause,\n offsetClause,\n ]\n .filter((part) => part.length > 0)\n .join(' ');\n return clauses.trim();\n}\n\nfunction renderProjection(\n projection: ReadonlyArray<ProjectionItem>,\n contract?: PostgresContract,\n pim?: ParamIndexMap,\n): string {\n return projection\n .map((item) => {\n const alias = quoteIdentifier(item.alias);\n if (item.expr.kind === 'literal') {\n return `${renderLiteral(item.expr)} AS ${alias}`;\n }\n return `${renderExpr(item.expr, contract, pim)} AS ${alias}`;\n })\n .join(', ');\n}\n\nfunction renderDistinctPrefix(\n distinct: true | undefined,\n distinctOn: ReadonlyArray<AnyExpression> | undefined,\n contract?: PostgresContract,\n pim?: ParamIndexMap,\n): string {\n if (distinctOn && distinctOn.length > 0) {\n const rendered = distinctOn.map((expr) => renderExpr(expr, contract, pim)).join(', ');\n return `DISTINCT ON (${rendered}) `;\n }\n if (distinct) {\n return 'DISTINCT ';\n }\n return '';\n}\n\nfunction renderSource(\n source: AnyFromSource,\n contract?: PostgresContract,\n pim?: ParamIndexMap,\n): string {\n const node = source;\n switch (node.kind) {\n case 'table-source': {\n const table = quoteIdentifier(node.name);\n if (!node.alias) {\n return table;\n }\n return `${table} AS ${quoteIdentifier(node.alias)}`;\n }\n case 'derived-table-source':\n return `(${renderSelect(node.query, contract, pim)}) AS ${quoteIdentifier(node.alias)}`;\n // v8 ignore next 4\n default:\n throw new Error(\n `Unsupported source node kind: ${(node satisfies never as { kind: string }).kind}`,\n );\n }\n}\n\nfunction assertScalarSubquery(query: SelectAst): void {\n if (query.projection.length !== 1) {\n throw new Error('Subquery expressions must project exactly one column');\n }\n}\n\nfunction renderSubqueryExpr(\n expr: SubqueryExpr,\n contract?: PostgresContract,\n pim?: ParamIndexMap,\n): string {\n assertScalarSubquery(expr.query);\n return `(${renderSelect(expr.query, contract, pim)})`;\n}\n\nfunction renderWhere(\n expr: AnyExpression,\n contract?: PostgresContract,\n pim?: ParamIndexMap,\n): string {\n return renderExpr(expr, contract, pim);\n}\n\nfunction renderNullCheck(\n expr: NullCheckExpr,\n contract?: PostgresContract,\n pim?: ParamIndexMap,\n): string {\n const rendered = renderExpr(expr.expr, contract, pim);\n const renderedExpr =\n expr.expr.kind === 'operation' || expr.expr.kind === 'subquery' ? `(${rendered})` : rendered;\n return expr.isNull ? `${renderedExpr} IS NULL` : `${renderedExpr} IS NOT NULL`;\n}\n\nfunction renderBinary(expr: BinaryExpr, contract?: PostgresContract, pim?: ParamIndexMap): string {\n if (expr.right.kind === 'list' && expr.right.values.length === 0) {\n if (expr.op === 'in') {\n return 'FALSE';\n }\n if (expr.op === 'notIn') {\n return 'TRUE';\n }\n }\n\n const leftExpr = expr.left;\n const left = renderExpr(leftExpr, contract, pim);\n const leftRendered =\n leftExpr.kind === 'operation' || leftExpr.kind === 'subquery' ? `(${left})` : left;\n\n const rightNode = expr.right;\n let right: string;\n switch (rightNode.kind) {\n case 'list':\n right = renderListLiteral(rightNode, pim);\n break;\n case 'literal':\n right = renderLiteral(rightNode);\n break;\n case 'column-ref':\n right = renderColumn(rightNode);\n break;\n case 'param-ref':\n right = renderParamRef(rightNode, pim);\n break;\n default:\n right = renderExpr(rightNode, contract, pim);\n break;\n }\n\n const operatorMap: Record<BinaryExpr['op'], string> = {\n eq: '=',\n neq: '!=',\n gt: '>',\n lt: '<',\n gte: '>=',\n lte: '<=',\n like: 'LIKE',\n ilike: 'ILIKE',\n in: 'IN',\n notIn: 'NOT IN',\n };\n\n return `${leftRendered} ${operatorMap[expr.op]} ${right}`;\n}\n\nfunction renderListLiteral(expr: ListExpression, pim?: ParamIndexMap): string {\n if (expr.values.length === 0) {\n return '(NULL)';\n }\n const values = expr.values\n .map((v) => {\n if (v.kind === 'param-ref') return renderParamRef(v, pim);\n if (v.kind === 'literal') return renderLiteral(v);\n return renderExpr(v, undefined, pim);\n })\n .join(', ');\n return `(${values})`;\n}\n\nfunction renderColumn(ref: ColumnRef): string {\n if (ref.table === 'excluded') {\n return `excluded.${quoteIdentifier(ref.column)}`;\n }\n return `${quoteIdentifier(ref.table)}.${quoteIdentifier(ref.column)}`;\n}\n\nfunction renderAggregateExpr(\n expr: AggregateExpr,\n contract?: PostgresContract,\n pim?: ParamIndexMap,\n): string {\n const fn = expr.fn.toUpperCase();\n if (!expr.expr) {\n return `${fn}(*)`;\n }\n return `${fn}(${renderExpr(expr.expr, contract, pim)})`;\n}\n\nfunction renderJsonObjectExpr(\n expr: JsonObjectExpr,\n contract?: PostgresContract,\n pim?: ParamIndexMap,\n): string {\n const args = expr.entries\n .flatMap((entry): [string, string] => {\n const key = `'${escapeLiteral(entry.key)}'`;\n if (entry.value.kind === 'literal') {\n return [key, renderLiteral(entry.value)];\n }\n return [key, renderExpr(entry.value, contract, pim)];\n })\n .join(', ');\n return `json_build_object(${args})`;\n}\n\nfunction renderOrderByItems(\n items: ReadonlyArray<OrderByItem>,\n contract?: PostgresContract,\n pim?: ParamIndexMap,\n): string {\n return items\n .map((item) => `${renderExpr(item.expr, contract, pim)} ${item.dir.toUpperCase()}`)\n .join(', ');\n}\n\nfunction renderJsonArrayAggExpr(\n expr: JsonArrayAggExpr,\n contract?: PostgresContract,\n pim?: ParamIndexMap,\n): string {\n const aggregateOrderBy =\n expr.orderBy && expr.orderBy.length > 0\n ? ` ORDER BY ${renderOrderByItems(expr.orderBy, contract, pim)}`\n : '';\n const aggregated = `json_agg(${renderExpr(expr.expr, contract, pim)}${aggregateOrderBy})`;\n if (expr.onEmpty === 'emptyArray') {\n return `coalesce(${aggregated}, json_build_array())`;\n }\n return aggregated;\n}\n\nfunction renderExpr(expr: AnyExpression, contract?: PostgresContract, pim?: ParamIndexMap): string {\n const node = expr;\n switch (node.kind) {\n case 'column-ref':\n return renderColumn(node);\n case 'identifier-ref':\n return quoteIdentifier(node.name);\n case 'operation':\n return renderOperation(node, contract, pim);\n case 'subquery':\n return renderSubqueryExpr(node, contract, pim);\n case 'aggregate':\n return renderAggregateExpr(node, contract, pim);\n case 'json-object':\n return renderJsonObjectExpr(node, contract, pim);\n case 'json-array-agg':\n return renderJsonArrayAggExpr(node, contract, pim);\n case 'binary':\n return renderBinary(node, contract, pim);\n case 'and':\n if (node.exprs.length === 0) {\n return 'TRUE';\n }\n return `(${node.exprs.map((part) => renderExpr(part, contract, pim)).join(' AND ')})`;\n case 'or':\n if (node.exprs.length === 0) {\n return 'FALSE';\n }\n return `(${node.exprs.map((part) => renderExpr(part, contract, pim)).join(' OR ')})`;\n case 'exists': {\n const notKeyword = node.notExists ? 'NOT ' : '';\n const subquery = renderSelect(node.subquery, contract, pim);\n return `${notKeyword}EXISTS (${subquery})`;\n }\n case 'null-check':\n return renderNullCheck(node, contract, pim);\n case 'not':\n return `NOT (${renderExpr(node.expr, contract, pim)})`;\n case 'param-ref':\n return renderParamRef(node, pim);\n case 'literal':\n return renderLiteral(node);\n case 'list':\n return renderListLiteral(node, pim);\n // v8 ignore next 4\n default:\n throw new Error(\n `Unsupported expression node kind: ${(node satisfies never as { kind: string }).kind}`,\n );\n }\n}\n\nfunction renderParamRef(ref: ParamRef, pim?: ParamIndexMap): string {\n const index = pim?.get(ref);\n if (index === undefined) {\n throw new Error('ParamRef not found in index map');\n }\n return renderTypedParam(index, ref.codecId);\n}\n\nfunction renderLiteral(expr: LiteralExpr): string {\n if (typeof expr.value === 'string') {\n return `'${escapeLiteral(expr.value)}'`;\n }\n if (typeof expr.value === 'number' || typeof expr.value === 'boolean') {\n return String(expr.value);\n }\n if (typeof expr.value === 'bigint') {\n return String(expr.value);\n }\n if (expr.value === null) {\n return 'NULL';\n }\n if (expr.value === undefined) {\n return 'NULL';\n }\n if (expr.value instanceof Date) {\n return `'${escapeLiteral(expr.value.toISOString())}'`;\n }\n if (Array.isArray(expr.value)) {\n return `ARRAY[${expr.value.map((v: unknown) => renderLiteral(new LiteralExpr(v))).join(', ')}]`;\n }\n const json = JSON.stringify(expr.value);\n if (json === undefined) {\n return 'NULL';\n }\n return `'${escapeLiteral(json)}'`;\n}\n\nfunction renderOperation(\n expr: OperationExpr,\n contract?: PostgresContract,\n pim?: ParamIndexMap,\n): string {\n const self = renderExpr(expr.self, contract, pim);\n const args = expr.args.map((arg) => {\n return renderExpr(arg, contract, pim);\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 return result;\n}\n\nfunction renderJoin(join: JoinAst, contract?: PostgresContract, pim?: ParamIndexMap): string {\n const joinType = join.joinType.toUpperCase();\n const lateral = join.lateral ? 'LATERAL ' : '';\n const source = renderSource(join.source, contract, pim);\n const onClause = renderJoinOn(join.on, contract, pim);\n return `${joinType} JOIN ${lateral}${source} ON ${onClause}`;\n}\n\nfunction renderJoinOn(on: JoinOnExpr, contract?: PostgresContract, pim?: ParamIndexMap): string {\n if (on.kind === 'eq-col-join-on') {\n const left = renderColumn(on.left);\n const right = renderColumn(on.right);\n return `${left} = ${right}`;\n }\n return renderWhere(on, contract, pim);\n}\n\nfunction getInsertColumnOrder(\n rows: ReadonlyArray<Record<string, InsertValue>>,\n contract: PostgresContract,\n tableName: string,\n): string[] {\n const orderedColumns: string[] = [];\n const seenColumns = new Set<string>();\n\n for (const row of rows) {\n for (const column of Object.keys(row)) {\n if (seenColumns.has(column)) {\n continue;\n }\n seenColumns.add(column);\n orderedColumns.push(column);\n }\n }\n\n if (orderedColumns.length > 0) {\n return orderedColumns;\n }\n\n return Object.keys(contract.storage.tables[tableName]?.columns ?? {});\n}\n\nfunction renderInsertValue(value: InsertValue | undefined, pim?: ParamIndexMap): string {\n if (!value || value.kind === 'default-value') {\n return 'DEFAULT';\n }\n\n switch (value.kind) {\n case 'param-ref':\n return renderParamRef(value, pim);\n case 'column-ref':\n return renderColumn(value);\n // v8 ignore next 4\n default:\n throw new Error(\n `Unsupported value node in INSERT: ${(value satisfies never as { kind: string }).kind}`,\n );\n }\n}\n\nfunction renderInsert(ast: InsertAst, contract: PostgresContract, pim?: ParamIndexMap): string {\n const table = quoteIdentifier(ast.table.name);\n const rows = ast.rows;\n if (rows.length === 0) {\n throw new Error('INSERT requires at least one row');\n }\n const hasExplicitValues = rows.some((row) => Object.keys(row).length > 0);\n const insertClause = (() => {\n if (!hasExplicitValues) {\n if (rows.length === 1) {\n return `INSERT INTO ${table} DEFAULT VALUES`;\n }\n\n const defaultColumns = getInsertColumnOrder(rows, contract, ast.table.name);\n if (defaultColumns.length === 0) {\n return `INSERT INTO ${table} VALUES ${rows.map(() => '()').join(', ')}`;\n }\n\n const quotedColumns = defaultColumns.map((column) => quoteIdentifier(column));\n const defaultRow = `(${defaultColumns.map(() => 'DEFAULT').join(', ')})`;\n return `INSERT INTO ${table} (${quotedColumns.join(', ')}) VALUES ${rows\n .map(() => defaultRow)\n .join(', ')}`;\n }\n\n const columnOrder = getInsertColumnOrder(rows, contract, ast.table.name);\n const columns = columnOrder.map((column) => quoteIdentifier(column));\n const values = rows\n .map((row) => {\n const renderedRow = columnOrder.map((column) => renderInsertValue(row[column], pim));\n return `(${renderedRow.join(', ')})`;\n })\n .join(', ');\n\n return `INSERT INTO ${table} (${columns.join(', ')}) VALUES ${values}`;\n })();\n const onConflictClause = ast.onConflict\n ? (() => {\n const conflictColumns = ast.onConflict.columns.map((col) => quoteIdentifier(col.column));\n if (conflictColumns.length === 0) {\n throw new Error('INSERT onConflict requires at least one conflict column');\n }\n\n const action = ast.onConflict.action;\n switch (action.kind) {\n case 'do-nothing':\n return ` ON CONFLICT (${conflictColumns.join(', ')}) DO NOTHING`;\n case 'do-update-set': {\n const updates = Object.entries(action.set).map(([colName, value]) => {\n const target = quoteIdentifier(colName);\n if (value.kind === 'param-ref') {\n return `${target} = ${renderParamRef(value, pim)}`;\n }\n return `${target} = ${renderColumn(value)}`;\n });\n return ` ON CONFLICT (${conflictColumns.join(', ')}) DO UPDATE SET ${updates.join(', ')}`;\n }\n // v8 ignore next 4\n default:\n throw new Error(\n `Unsupported onConflict action: ${(action satisfies never as { kind: string }).kind}`,\n );\n }\n })()\n : '';\n const returningClause = ast.returning?.length\n ? ` RETURNING ${ast.returning.map((col) => `${quoteIdentifier(col.table)}.${quoteIdentifier(col.column)}`).join(', ')}`\n : '';\n\n return `${insertClause}${onConflictClause}${returningClause}`;\n}\n\nfunction renderUpdate(ast: UpdateAst, contract: PostgresContract, pim?: ParamIndexMap): string {\n const table = quoteIdentifier(ast.table.name);\n const setClauses = Object.entries(ast.set).map(([col, val]) => {\n const column = quoteIdentifier(col);\n let value: string;\n switch (val.kind) {\n case 'param-ref':\n value = renderParamRef(val, pim);\n break;\n case 'column-ref':\n value = renderColumn(val);\n break;\n // v8 ignore next 4\n default:\n throw new Error(\n `Unsupported value node in UPDATE: ${(val satisfies never as { kind: string }).kind}`,\n );\n }\n return `${column} = ${value}`;\n });\n\n const whereClause = ast.where ? ` WHERE ${renderWhere(ast.where, contract, pim)}` : '';\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, pim?: ParamIndexMap): string {\n const table = quoteIdentifier(ast.table.name);\n const whereClause = ast.where ? ` WHERE ${renderWhere(ast.where, contract, pim)}` : '';\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":";;;;;;;AAoCA,MAAM,kBAAkB;AAExB,SAAS,kBAAkB,SAAiD;AAC1E,KAAI,YAAY,gBACd,QAAO;AAET,KAAI,YAAY,iBACd,QAAO;AAET,KAAI,YAAY,kBACd,QAAO;;AAKX,SAAS,iBAAiB,OAAe,SAAqC;CAC5E,MAAM,OAAO,kBAAkB,QAAQ;AACvC,QAAO,OAAO,IAAI,MAAM,IAAI,SAAS,IAAI;;AAK3C,MAAM,sBAAsB,OAAO,OAAO;CACxC,UAAU;EACR,SAAS;EACT,OAAO;EACP,SAAS;EACT,SAAS;EACT,WAAW;EACZ;CACD,KAAK;EACH,OAAO;EACP,WAAW;EACX,iBAAiB;EAClB;CACF,CAAC;AAOF,MAAMA,sBAA4D,OAAO,OAAO,iBAAiB,CAC9F,KAAK,eAAe,WAAW,MAAM,CACrC,QAAQ,YAAuCC,QAAM,iBAAiB,OAAU,CAChF,KAAK,YACJ,OAAO,OAAO;CACZ,SAASA,QAAM;CACf,cAAcA,QAAM;CACpB,GAAG,UAAU,QAAQA,QAAM,KAAK;CACjC,CAAC,CACH;AAEH,IAAM,sBAAN,MAEA;CAGE,AAAS,WAAW;CACpB,AAAS,WAAW;CAEpB,AAAS;CACT,AAAiB,uBAAuB;EACtC,MAAM,WAAW,qBAAqB;AACtC,OAAK,MAAM,cAAc,OAAO,OAAO,iBAAiB,CACtD,UAAS,SAAS,WAAW,MAAM;AAErC,SAAO;KACL;CAEJ,YAAY,SAAkC;AAC5C,OAAK,UAAU,OAAO,OAAO;GAC3B,IAAI,SAAS,aAAa;GAC1B,QAAQ;GACR,cAAc;GACd,cAAc,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AI,MAAM,KAAK,GACzB,IAAI,QAAQ,UAAU,YAAY,IAAI,OAAO,UAAU,IAAI,KAAK,KAC5D,IAAI,WAAW,SACnC,cAAc,IAAI,UAAU,KAAK,QAAQ,GAAG,gBAAgB,IAAI,MAAM,CAAC,GAAG,gBAAgB,IAAI,OAAO,GAAG,CAAC,KAAK,KAAK,KACnH;;AAKN,SAAgB,sBAAsB,SAAkC;AACtE,QAAO,OAAO,OAAO,IAAI,oBAAoB,QAAQ,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"descriptor-meta-DemWrTfB.mjs","names":["result: string[]","operations: SqlMigrationPlanOperation<unknown>[]","columns: Array<{ table: string; column: string }>","result: Array<{ table: string; column: string }>","pgEnumControlHooks: CodecControlHooks","types: Record<string, StorageTypeInstance>","lengthHooks: CodecControlHooks","precisionHooks: CodecControlHooks","numericHooks: CodecControlHooks","identityHooks: CodecControlHooks"],"sources":["../src/core/enum-control-hooks.ts","../src/core/descriptor-meta.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\nimport type { CodecControlHooks, SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport { arraysEqual } from '@prisma-next/family-sql/schema-verify';\nimport type { SqlStorage, StorageTypeInstance } from '@prisma-next/sql-contract/types';\nimport type { SqlSchemaIR } from '@prisma-next/sql-schema-ir/types';\nimport { PG_ENUM_CODEC_ID } from './codec-ids';\nimport { escapeLiteral, qualifyName, quoteIdentifier, validateEnumValueLength } from './sql-utils';\n\n/**\n * Postgres enum control hooks.\n *\n * - Plans enum type operations for migrations\n * - Verifies enum types in schema IR\n * - Introspects enum types from the database\n */\ntype EnumRow = {\n schema_name: string;\n type_name: string;\n values: string[];\n};\n\ntype EnumDiff =\n | { kind: 'unchanged' }\n | { kind: 'add_values'; values: readonly string[] }\n | { kind: 'rebuild'; removedValues: readonly string[] };\n\n// ============================================================================\n// Introspection SQL\n// ============================================================================\n\nconst ENUM_INTROSPECT_QUERY = `\n SELECT\n n.nspname AS schema_name,\n t.typname AS type_name,\n array_agg(e.enumlabel ORDER BY e.enumsortorder) AS values\n FROM pg_type t\n JOIN pg_namespace n ON t.typnamespace = n.oid\n JOIN pg_enum e ON t.oid = e.enumtypid\n WHERE n.nspname = $1\n GROUP BY n.nspname, t.typname\n ORDER BY n.nspname, t.typname\n`;\n\n// ============================================================================\n// Schema Helpers (Simplified)\n// ============================================================================\n\n/**\n * Type guard for string arrays. Used for runtime validation of introspected data.\n */\nfunction isStringArray(value: unknown): value is string[] {\n return Array.isArray(value) && value.every((entry) => typeof entry === 'string');\n}\n\n/**\n * Parses a PostgreSQL array value into a JavaScript string array.\n *\n * PostgreSQL's `pg` library may return `array_agg` results either as:\n * - A JavaScript array (when type parsers are configured)\n * - A string in PostgreSQL array literal format: `{value1,value2,...}`\n *\n * Handles PostgreSQL's quoting rules for array elements:\n * - Elements containing commas, double quotes, backslashes, or whitespace are double-quoted\n * - Inside quoted elements, `\\\"` represents `\"` and `\\\\` represents `\\`\n *\n * @param value - The value to parse (array or PostgreSQL array string)\n * @returns A string array, or null if the value cannot be parsed\n */\nexport function parsePostgresArray(value: unknown): string[] | null {\n if (isStringArray(value)) {\n return value;\n }\n if (typeof value === 'string' && value.startsWith('{') && value.endsWith('}')) {\n const inner = value.slice(1, -1);\n if (inner === '') {\n return [];\n }\n return parseArrayElements(inner);\n }\n return null;\n}\n\nfunction parseArrayElements(input: string): string[] {\n const result: string[] = [];\n let i = 0;\n while (i < input.length) {\n if (input[i] === ',') {\n i++;\n continue;\n }\n if (input[i] === '\"') {\n i++;\n let element = '';\n while (i < input.length && input[i] !== '\"') {\n if (input[i] === '\\\\' && i + 1 < input.length) {\n i++;\n element += input[i];\n } else {\n element += input[i];\n }\n i++;\n }\n i++;\n result.push(element);\n } else {\n const nextComma = input.indexOf(',', i);\n if (nextComma === -1) {\n result.push(input.slice(i).trim());\n i = input.length;\n } else {\n result.push(input.slice(i, nextComma).trim());\n i = nextComma;\n }\n }\n }\n return result;\n}\n\n/**\n * Extracts enum values from a StorageTypeInstance.\n * Returns null if values are missing or invalid.\n */\nfunction getEnumValues(typeInstance: StorageTypeInstance): readonly string[] | null {\n const values = typeInstance.typeParams?.['values'];\n return isStringArray(values) ? values : null;\n}\n\n/**\n * Reads existing enum values from the schema IR for a given native type.\n * Uses optional chaining to simplify navigation through the annotations structure.\n */\nfunction readExistingEnumValues(schema: SqlSchemaIR, nativeType: string): readonly string[] | null {\n const storageTypes = (schema.annotations?.['pg'] as Record<string, unknown> | undefined)?.[\n 'storageTypes'\n ] as Record<string, StorageTypeInstance> | undefined;\n\n const existing = storageTypes?.[nativeType];\n if (!existing || existing.codecId !== PG_ENUM_CODEC_ID) {\n return null;\n }\n return getEnumValues(existing);\n}\n\n/**\n * Determines what changes are needed to transform existing enum values to desired values.\n *\n * Returns one of:\n * - `unchanged`: No changes needed, values match exactly\n * - `add_values`: New values can be safely appended (PostgreSQL supports this)\n * - `rebuild`: Full enum rebuild required (value removal, reordering, or both)\n *\n * Note: PostgreSQL enums can only have values added (not removed or reordered) without\n * a full type rebuild involving temp type creation and column migration.\n *\n * @param existing - Current enum values in the database\n * @param desired - Target enum values from the contract\n * @returns The type of change required\n */\nfunction determineEnumDiff(existing: readonly string[], desired: readonly string[]): EnumDiff {\n if (arraysEqual(existing, desired)) {\n return { kind: 'unchanged' };\n }\n\n // Use Sets for O(1) lookups instead of O(n) array.includes()\n const existingSet = new Set(existing);\n const desiredSet = new Set(desired);\n\n const missingValues = desired.filter((value) => !existingSet.has(value));\n const removedValues = existing.filter((value) => !desiredSet.has(value));\n const orderMismatch =\n missingValues.length === 0 && removedValues.length === 0 && !arraysEqual(existing, desired);\n\n if (removedValues.length > 0 || orderMismatch) {\n return { kind: 'rebuild', removedValues };\n }\n\n return { kind: 'add_values', values: missingValues };\n}\n\n// ============================================================================\n// SQL Helpers\n// ============================================================================\n\nfunction enumTypeExistsCheck(schemaName: string, typeName: string, exists = true): string {\n const existsClause = exists ? 'EXISTS' : 'NOT EXISTS';\n return `SELECT ${existsClause} (\n SELECT 1\n FROM pg_type t\n JOIN pg_namespace n ON t.typnamespace = n.oid\n WHERE n.nspname = '${escapeLiteral(schemaName)}'\n AND t.typname = '${escapeLiteral(typeName)}'\n)`;\n}\n\n// ============================================================================\n// Operation Builders\n// ============================================================================\n\nfunction buildCreateEnumOperation(\n typeName: string,\n nativeType: string,\n schemaName: string,\n values: readonly string[],\n): SqlMigrationPlanOperation<unknown> {\n // Validate all enum values don't exceed PostgreSQL's label length limit\n for (const value of values) {\n validateEnumValueLength(value, typeName);\n }\n const literalValues = values.map((value) => `'${escapeLiteral(value)}'`).join(', ');\n const qualifiedType = qualifyName(schemaName, nativeType);\n return {\n id: `type.${typeName}`,\n label: `Create type ${typeName}`,\n summary: `Creates enum type ${typeName}`,\n operationClass: 'additive',\n target: { id: 'postgres' },\n precheck: [\n {\n description: `ensure type \"${nativeType}\" does not exist`,\n sql: enumTypeExistsCheck(schemaName, nativeType, false),\n },\n ],\n execute: [\n {\n description: `create type \"${nativeType}\"`,\n sql: `CREATE TYPE ${qualifiedType} AS ENUM (${literalValues})`,\n },\n ],\n postcheck: [\n {\n description: `verify type \"${nativeType}\" exists`,\n sql: enumTypeExistsCheck(schemaName, nativeType),\n },\n ],\n };\n}\n\n/**\n * Computes the optimal position for inserting a new enum value to maintain\n * the desired order relative to existing values.\n *\n * PostgreSQL's `ALTER TYPE ADD VALUE` supports BEFORE/AFTER positioning.\n * This function finds the best reference value by:\n * 1. Looking for the nearest preceding value that already exists\n * 2. Falling back to the nearest following value if no preceding exists\n * 3. Defaulting to end-of-list if no reference is found\n *\n * @param options.desired - The target ordered list of all enum values\n * @param options.desiredIndex - Index of the value being inserted in the desired list\n * @param options.current - Current list of enum values (being built up incrementally)\n * @returns SQL clause (e.g., \" AFTER 'x'\") and insert position for tracking\n */\nfunction computeInsertPosition(options: {\n desired: readonly string[];\n desiredIndex: number;\n current: readonly string[];\n}): { clause: string; insertAt: number } {\n const { desired, desiredIndex, current } = options;\n const currentSet = new Set(current);\n const previous = desired\n .slice(0, desiredIndex)\n .reverse()\n .find((candidate) => currentSet.has(candidate));\n const next = desired.slice(desiredIndex + 1).find((candidate) => currentSet.has(candidate));\n const clause = previous\n ? ` AFTER '${escapeLiteral(previous)}'`\n : next\n ? ` BEFORE '${escapeLiteral(next)}'`\n : '';\n const insertAt = previous\n ? current.indexOf(previous) + 1\n : next\n ? current.indexOf(next)\n : current.length;\n\n return { clause, insertAt };\n}\n\n/**\n * Builds operations to add new enum values to an existing PostgreSQL enum type.\n *\n * Each new value is added with `ALTER TYPE ... ADD VALUE IF NOT EXISTS` for idempotency.\n * Values are inserted in the correct order using BEFORE/AFTER positioning to match\n * the desired final order.\n *\n * This is a safe, non-destructive operation - existing data is not affected.\n *\n * @param options.typeName - Contract-level type name (e.g., 'Role')\n * @param options.nativeType - PostgreSQL type name (e.g., 'role')\n * @param options.schemaName - PostgreSQL schema (e.g., 'public')\n * @param options.desired - Target ordered list of all enum values\n * @param options.existing - Current enum values in the database\n * @returns Array of migration operations to add each missing value\n */\nfunction buildAddValueOperations(options: {\n typeName: string;\n nativeType: string;\n schemaName: string;\n desired: readonly string[];\n existing: readonly string[];\n}): SqlMigrationPlanOperation<unknown>[] {\n const { typeName, nativeType, schemaName } = options;\n const current = [...options.existing];\n const currentSet = new Set(current);\n const operations: SqlMigrationPlanOperation<unknown>[] = [];\n for (let index = 0; index < options.desired.length; index += 1) {\n const value = options.desired[index];\n if (value === undefined) {\n continue;\n }\n if (currentSet.has(value)) {\n continue;\n }\n // Validate the new value doesn't exceed PostgreSQL's label length limit\n validateEnumValueLength(value, typeName);\n const { clause, insertAt } = computeInsertPosition({\n desired: options.desired,\n desiredIndex: index,\n current,\n });\n // Use IF NOT EXISTS for idempotency - safe to re-run after partial failures.\n // Supported in PostgreSQL 9.3+, and we require PostgreSQL 12+.\n operations.push({\n id: `type.${typeName}.value.${value}`,\n label: `Add value ${value} to ${typeName}`,\n summary: `Adds enum value ${value} to ${typeName}`,\n operationClass: 'widening',\n target: { id: 'postgres' },\n precheck: [],\n execute: [\n {\n description: `add value \"${value}\" if not exists`,\n sql: `ALTER TYPE ${qualifyName(schemaName, nativeType)} ADD VALUE IF NOT EXISTS '${escapeLiteral(\n value,\n )}'${clause}`,\n },\n ],\n postcheck: [],\n });\n current.splice(insertAt, 0, value);\n currentSet.add(value);\n }\n return operations;\n}\n\n/**\n * Collects columns using the enum type from the contract (desired state).\n * Used for type-safe reference tracking.\n */\nfunction collectEnumColumnsFromContract(\n contract: Contract<SqlStorage>,\n typeName: string,\n nativeType: string,\n): ReadonlyArray<{ table: string; column: string }> {\n const columns: Array<{ table: string; column: string }> = [];\n for (const [tableName, table] of Object.entries(contract.storage.tables)) {\n for (const [columnName, column] of Object.entries(table.columns)) {\n if (\n column.typeRef === typeName ||\n (column.nativeType === nativeType && column.codecId === PG_ENUM_CODEC_ID)\n ) {\n columns.push({ table: tableName, column: columnName });\n }\n }\n }\n return columns;\n}\n\n/**\n * Collects columns using the enum type from the schema IR (live database state).\n * This ensures we find ALL dependent columns, including those added outside the contract\n * (e.g., manual DDL), which is critical for safe enum rebuild operations.\n */\nfunction collectEnumColumnsFromSchema(\n schema: SqlSchemaIR,\n nativeType: string,\n): ReadonlyArray<{ table: string; column: string }> {\n const columns: Array<{ table: string; column: string }> = [];\n for (const [tableName, table] of Object.entries(schema.tables)) {\n for (const [columnName, column] of Object.entries(table.columns)) {\n // Match by nativeType since schema IR doesn't have codecId/typeRef\n if (column.nativeType === nativeType) {\n columns.push({ table: tableName, column: columnName });\n }\n }\n }\n return columns;\n}\n\n/**\n * Collects all columns using the enum type from both contract AND live database.\n * Merges and deduplicates to ensure we migrate ALL dependent columns during rebuild.\n *\n * This is critical for data integrity: if a column exists in the database using\n * this enum but is not in the contract (e.g., added via manual DDL), we must\n * still migrate it to avoid DROP TYPE failures.\n */\nfunction collectAllEnumColumns(\n contract: Contract<SqlStorage>,\n schema: SqlSchemaIR,\n typeName: string,\n nativeType: string,\n): ReadonlyArray<{ table: string; column: string }> {\n const contractColumns = collectEnumColumnsFromContract(contract, typeName, nativeType);\n const schemaColumns = collectEnumColumnsFromSchema(schema, nativeType);\n\n // Merge and deduplicate using a Set of \"table.column\" keys\n const seen = new Set<string>();\n const result: Array<{ table: string; column: string }> = [];\n\n for (const col of [...contractColumns, ...schemaColumns]) {\n const key = `${col.table}.${col.column}`;\n if (!seen.has(key)) {\n seen.add(key);\n result.push(col);\n }\n }\n\n // Sort for deterministic operation order\n return result.sort((a, b) => {\n const tableCompare = a.table.localeCompare(b.table);\n return tableCompare !== 0 ? tableCompare : a.column.localeCompare(b.column);\n });\n}\n\n/**\n * Builds a SQL check to verify a column's type matches an expected type.\n */\nfunction columnTypeCheck(options: {\n schemaName: string;\n tableName: string;\n columnName: string;\n expectedType: string;\n}): string {\n return `SELECT EXISTS (\n SELECT 1\n FROM information_schema.columns\n WHERE table_schema = '${escapeLiteral(options.schemaName)}'\n AND table_name = '${escapeLiteral(options.tableName)}'\n AND column_name = '${escapeLiteral(options.columnName)}'\n AND udt_name = '${escapeLiteral(options.expectedType)}'\n)`;\n}\n\n/** PostgreSQL maximum identifier length (NAMEDATALEN - 1) */\nconst MAX_IDENTIFIER_LENGTH = 63;\n\n/** Suffix added to enum type names during rebuild operations */\nconst REBUILD_SUFFIX = '__pn_rebuild';\n\n/**\n * Builds an SQL check to verify no rows contain any of the removed enum values.\n * This prevents data loss during enum rebuild operations.\n *\n * @param schemaName - PostgreSQL schema name\n * @param tableName - Table containing the enum column\n * @param columnName - Column using the enum type\n * @param removedValues - Array of enum values being removed\n * @returns SQL query that returns true if no rows contain removed values\n */\nfunction noRemovedValuesExistCheck(\n schemaName: string,\n tableName: string,\n columnName: string,\n removedValues: readonly string[],\n): string {\n if (removedValues.length === 0) {\n // No values being removed, always passes\n return 'SELECT true';\n }\n const valuesList = removedValues.map((v) => `'${escapeLiteral(v)}'`).join(', ');\n return `SELECT NOT EXISTS (\n SELECT 1 FROM ${qualifyName(schemaName, tableName)}\n WHERE ${quoteIdentifier(columnName)}::text IN (${valuesList})\n LIMIT 1\n)`;\n}\n\n/**\n * Builds a migration operation to recreate a PostgreSQL enum type with updated values.\n *\n * This is required when:\n * - Enum values are removed (PostgreSQL doesn't support direct removal)\n * - Enum values are reordered (PostgreSQL doesn't support reordering)\n *\n * The operation:\n * 1. Creates a new enum type with the desired values (temp name)\n * 2. Migrates all columns to use the new type via text cast\n * 3. Drops the original type\n * 4. Renames the temp type to the original name\n *\n * IMPORTANT: If values are being removed and data exists using those values,\n * the operation will fail at the precheck stage with a clear error message.\n * This prevents silent data loss.\n *\n * @param options.typeName - Contract-level type name\n * @param options.nativeType - PostgreSQL type name\n * @param options.schemaName - PostgreSQL schema\n * @param options.values - Desired final enum values\n * @param options.removedValues - Values being removed (for data loss checks)\n * @param options.contract - Full contract for column discovery\n * @param options.schema - Current schema IR for column discovery\n * @returns Migration operation for full enum rebuild\n */\nfunction buildRecreateEnumOperation(options: {\n typeName: string;\n nativeType: string;\n schemaName: string;\n values: readonly string[];\n removedValues: readonly string[];\n contract: Contract<SqlStorage>;\n schema: SqlSchemaIR;\n}): SqlMigrationPlanOperation<unknown> {\n const tempTypeName = `${options.nativeType}${REBUILD_SUFFIX}`;\n\n // Validate temp type name length won't exceed PostgreSQL's 63-character limit.\n // If it would, PostgreSQL silently truncates which could cause conflicts.\n if (tempTypeName.length > MAX_IDENTIFIER_LENGTH) {\n const maxBaseLength = MAX_IDENTIFIER_LENGTH - REBUILD_SUFFIX.length;\n throw new Error(\n `Enum type name \"${options.nativeType}\" is too long for rebuild operation. ` +\n `Maximum length is ${maxBaseLength} characters (type name + \"${REBUILD_SUFFIX}\" suffix ` +\n `must fit within PostgreSQL's ${MAX_IDENTIFIER_LENGTH}-character identifier limit).`,\n );\n }\n\n const qualifiedOriginal = qualifyName(options.schemaName, options.nativeType);\n const qualifiedTemp = qualifyName(options.schemaName, tempTypeName);\n const literalValues = options.values.map((value) => `'${escapeLiteral(value)}'`).join(', ');\n\n // CRITICAL: Collect columns from BOTH contract AND live database.\n // This ensures we migrate ALL dependent columns, including those added\n // outside of Prisma Next (e.g., manual DDL). Without this, DROP TYPE\n // would fail if the database has columns not tracked in the contract.\n const columnRefs = collectAllEnumColumns(\n options.contract,\n options.schema,\n options.typeName,\n options.nativeType,\n );\n\n const alterColumns = columnRefs.map((ref) => ({\n description: `alter ${ref.table}.${ref.column} to ${tempTypeName}`,\n sql: `ALTER TABLE ${qualifyName(options.schemaName, ref.table)}\nALTER COLUMN ${quoteIdentifier(ref.column)}\nTYPE ${qualifiedTemp}\nUSING ${quoteIdentifier(ref.column)}::text::${qualifiedTemp}`,\n }));\n\n // Build postchecks to verify:\n // 1. The final type exists with the correct name\n // 2. The temp type was cleaned up (renamed away)\n // 3. All migrated columns now reference the final type\n const postchecks = [\n {\n description: `verify type \"${options.nativeType}\" exists`,\n sql: enumTypeExistsCheck(options.schemaName, options.nativeType),\n },\n {\n description: `verify temp type \"${tempTypeName}\" was removed`,\n sql: enumTypeExistsCheck(options.schemaName, tempTypeName, false),\n },\n // Verify each column was successfully migrated to the final type\n ...columnRefs.map((ref) => ({\n description: `verify ${ref.table}.${ref.column} uses type \"${options.nativeType}\"`,\n sql: columnTypeCheck({\n schemaName: options.schemaName,\n tableName: ref.table,\n columnName: ref.column,\n expectedType: options.nativeType,\n }),\n })),\n ];\n\n return {\n id: `type.${options.typeName}.rebuild`,\n label: `Rebuild type ${options.typeName}`,\n summary: `Recreates enum type ${options.typeName} with updated values`,\n operationClass: 'destructive',\n target: { id: 'postgres' },\n precheck: [\n {\n description: `ensure type \"${options.nativeType}\" exists`,\n sql: enumTypeExistsCheck(options.schemaName, options.nativeType),\n },\n // Note: We don't precheck that temp type doesn't exist because we handle\n // orphaned temp types in the execute step below.\n\n // CRITICAL: If values are being removed, verify no data exists using those values.\n // This prevents silent data loss during the rebuild - the USING cast would fail\n // at runtime if rows contain values that don't exist in the new enum.\n ...(options.removedValues.length > 0\n ? columnRefs.map((ref) => ({\n description: `ensure no rows in ${ref.table}.${ref.column} contain removed values (${options.removedValues.join(', ')})`,\n sql: noRemovedValuesExistCheck(\n options.schemaName,\n ref.table,\n ref.column,\n options.removedValues,\n ),\n }))\n : []),\n ],\n execute: [\n // Clean up any orphaned temp type from a previous failed migration.\n // This makes the operation recoverable without manual intervention.\n // DROP TYPE IF EXISTS is safe - it's a no-op if the type doesn't exist.\n {\n description: `drop orphaned temp type \"${tempTypeName}\" if exists`,\n sql: `DROP TYPE IF EXISTS ${qualifiedTemp}`,\n },\n {\n description: `create temp type \"${tempTypeName}\"`,\n sql: `CREATE TYPE ${qualifiedTemp} AS ENUM (${literalValues})`,\n },\n ...alterColumns,\n {\n description: `drop type \"${options.nativeType}\"`,\n sql: `DROP TYPE ${qualifiedOriginal}`,\n },\n {\n description: `rename type \"${tempTypeName}\" to \"${options.nativeType}\"`,\n sql: `ALTER TYPE ${qualifiedTemp} RENAME TO ${quoteIdentifier(options.nativeType)}`,\n },\n ],\n postcheck: postchecks,\n };\n}\n\n// ============================================================================\n// Codec Control Hooks\n// ============================================================================\n\n/**\n * Postgres enum hooks for planning, verifying, and introspecting `storage.types`.\n */\nexport const pgEnumControlHooks: CodecControlHooks = {\n planTypeOperations: ({ typeName, typeInstance, contract, schema, schemaName }) => {\n const desired = getEnumValues(typeInstance);\n if (!desired || desired.length === 0) {\n return { operations: [] };\n }\n\n const schemaNamespace = schemaName ?? 'public';\n const existing = readExistingEnumValues(schema, typeInstance.nativeType);\n if (!existing) {\n return {\n operations: [\n buildCreateEnumOperation(typeName, typeInstance.nativeType, schemaNamespace, desired),\n ],\n };\n }\n\n const diff = determineEnumDiff(existing, desired);\n if (diff.kind === 'unchanged') {\n return { operations: [] };\n }\n\n if (diff.kind === 'rebuild') {\n return {\n operations: [\n buildRecreateEnumOperation({\n typeName,\n nativeType: typeInstance.nativeType,\n schemaName: schemaNamespace,\n values: desired,\n removedValues: diff.removedValues,\n contract,\n schema,\n }),\n ],\n };\n }\n\n return {\n operations: buildAddValueOperations({\n typeName,\n nativeType: typeInstance.nativeType,\n schemaName: schemaNamespace,\n desired,\n existing,\n }),\n };\n },\n verifyType: ({ typeName, typeInstance, schema }) => {\n const desired = getEnumValues(typeInstance);\n if (!desired) {\n return [];\n }\n const existing = readExistingEnumValues(schema, typeInstance.nativeType);\n if (!existing) {\n return [\n {\n kind: 'type_missing',\n typeName,\n message: `Type \"${typeName}\" is missing from database`,\n },\n ];\n }\n const diff = determineEnumDiff(existing, desired);\n if (diff.kind === 'unchanged') return [];\n const existingSet = new Set(existing);\n const desiredSet = new Set(desired);\n const addedValues = desired.filter((v) => !existingSet.has(v));\n const removedValues = existing.filter((v) => !desiredSet.has(v));\n return [\n {\n kind: 'enum_values_changed' as const,\n typeName,\n addedValues,\n removedValues,\n message:\n diff.kind === 'add_values'\n ? `Enum type \"${typeName}\" needs new values: ${addedValues.join(', ')}`\n : `Enum type \"${typeName}\" values changed (requires rebuild): +[${addedValues.join(', ')}] -[${removedValues.join(', ')}]`,\n },\n ];\n },\n introspectTypes: async ({ driver, schemaName }) => {\n const namespace = schemaName ?? 'public';\n const result = await driver.query<EnumRow>(ENUM_INTROSPECT_QUERY, [namespace]);\n const types: Record<string, StorageTypeInstance> = {};\n for (const row of result.rows) {\n const values = parsePostgresArray(row.values);\n if (!values) {\n throw new Error(\n `Failed to parse enum values for type \"${row.type_name}\": ` +\n `unexpected format: ${JSON.stringify(row.values)}`,\n );\n }\n types[row.type_name] = {\n codecId: PG_ENUM_CODEC_ID,\n nativeType: row.type_name,\n typeParams: { values },\n };\n }\n return types;\n },\n};\n","import type { CodecControlHooks, ExpandNativeTypeInput } from '@prisma-next/family-sql/control';\nimport {\n PG_BIT_CODEC_ID,\n PG_BOOL_CODEC_ID,\n PG_CHAR_CODEC_ID,\n PG_ENUM_CODEC_ID,\n PG_FLOAT_CODEC_ID,\n PG_FLOAT4_CODEC_ID,\n PG_FLOAT8_CODEC_ID,\n PG_INT_CODEC_ID,\n PG_INT2_CODEC_ID,\n PG_INT4_CODEC_ID,\n PG_INT8_CODEC_ID,\n PG_INTERVAL_CODEC_ID,\n PG_JSON_CODEC_ID,\n PG_JSONB_CODEC_ID,\n PG_NUMERIC_CODEC_ID,\n PG_TEXT_CODEC_ID,\n PG_TIME_CODEC_ID,\n PG_TIMESTAMP_CODEC_ID,\n PG_TIMESTAMPTZ_CODEC_ID,\n PG_TIMETZ_CODEC_ID,\n PG_VARBIT_CODEC_ID,\n PG_VARCHAR_CODEC_ID,\n SQL_CHAR_CODEC_ID,\n SQL_FLOAT_CODEC_ID,\n SQL_INT_CODEC_ID,\n SQL_TEXT_CODEC_ID,\n SQL_TIMESTAMP_CODEC_ID,\n SQL_VARCHAR_CODEC_ID,\n} from './codec-ids';\nimport { codecDefinitions } from './codecs';\nimport { pgEnumControlHooks } from './enum-control-hooks';\n\n// ============================================================================\n// Helper functions for reducing boilerplate\n// ============================================================================\n\n/** Creates a type import spec for codec types */\nconst codecTypeImport = (named: string) =>\n ({\n package: '@prisma-next/adapter-postgres/codec-types',\n named,\n alias: named,\n }) as const;\n\nfunction isPositiveInteger(value: unknown): value is number {\n return (\n typeof value === 'number' && Number.isFinite(value) && Number.isInteger(value) && value > 0\n );\n}\n\nfunction isNonNegativeInteger(value: unknown): value is number {\n return (\n typeof value === 'number' && Number.isFinite(value) && Number.isInteger(value) && value >= 0\n );\n}\n\nfunction expandLength({ nativeType, typeParams }: ExpandNativeTypeInput): string {\n if (!typeParams || !('length' in typeParams)) {\n return nativeType;\n }\n const length = typeParams['length'];\n if (!isPositiveInteger(length)) {\n throw new Error(\n `Invalid \"length\" type parameter for \"${nativeType}\": expected a positive integer, got ${JSON.stringify(length)}`,\n );\n }\n return `${nativeType}(${length})`;\n}\n\nfunction expandPrecision({ nativeType, typeParams }: ExpandNativeTypeInput): string {\n if (!typeParams || !('precision' in typeParams)) {\n return nativeType;\n }\n const precision = typeParams['precision'];\n if (!isPositiveInteger(precision)) {\n throw new Error(\n `Invalid \"precision\" type parameter for \"${nativeType}\": expected a positive integer, got ${JSON.stringify(precision)}`,\n );\n }\n return `${nativeType}(${precision})`;\n}\n\nfunction expandNumeric({ nativeType, typeParams }: ExpandNativeTypeInput): string {\n const hasPrecision = typeParams && 'precision' in typeParams;\n const hasScale = typeParams && 'scale' in typeParams;\n\n if (!hasPrecision && !hasScale) {\n return nativeType;\n }\n\n if (!hasPrecision && hasScale) {\n throw new Error(\n `Invalid type parameters for \"${nativeType}\": \"scale\" requires \"precision\" to be specified`,\n );\n }\n\n if (hasPrecision) {\n const precision = typeParams['precision'];\n if (!isPositiveInteger(precision)) {\n throw new Error(\n `Invalid \"precision\" type parameter for \"${nativeType}\": expected a positive integer, got ${JSON.stringify(precision)}`,\n );\n }\n if (hasScale) {\n const scale = typeParams['scale'];\n if (!isNonNegativeInteger(scale)) {\n throw new Error(\n `Invalid \"scale\" type parameter for \"${nativeType}\": expected a non-negative integer, got ${JSON.stringify(scale)}`,\n );\n }\n return `${nativeType}(${precision},${scale})`;\n }\n return `${nativeType}(${precision})`;\n }\n\n return nativeType;\n}\n\nconst lengthHooks: CodecControlHooks = { expandNativeType: expandLength };\nconst precisionHooks: CodecControlHooks = { expandNativeType: expandPrecision };\nconst numericHooks: CodecControlHooks = { expandNativeType: expandNumeric };\nconst identityHooks: CodecControlHooks = { expandNativeType: ({ nativeType }) => nativeType };\n\n// ============================================================================\n// Descriptor metadata\n// ============================================================================\n\nexport 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 sql: {\n enums: true,\n returning: true,\n defaultInInsert: true,\n },\n },\n types: {\n codecTypes: {\n codecInstances: Object.values(codecDefinitions).map((def) => def.codec),\n import: {\n package: '@prisma-next/adapter-postgres/codec-types',\n named: 'CodecTypes',\n alias: 'PgTypes',\n },\n typeImports: [\n {\n package: '@prisma-next/adapter-postgres/codec-types',\n named: 'JsonValue',\n alias: 'JsonValue',\n },\n codecTypeImport('Char'),\n codecTypeImport('Varchar'),\n codecTypeImport('Numeric'),\n codecTypeImport('Bit'),\n codecTypeImport('VarBit'),\n codecTypeImport('Timestamp'),\n codecTypeImport('Timestamptz'),\n codecTypeImport('Time'),\n codecTypeImport('Timetz'),\n codecTypeImport('Interval'),\n ],\n controlPlaneHooks: {\n [SQL_CHAR_CODEC_ID]: lengthHooks,\n [SQL_VARCHAR_CODEC_ID]: lengthHooks,\n [SQL_TIMESTAMP_CODEC_ID]: precisionHooks,\n [PG_CHAR_CODEC_ID]: lengthHooks,\n [PG_VARCHAR_CODEC_ID]: lengthHooks,\n [PG_NUMERIC_CODEC_ID]: numericHooks,\n [PG_BIT_CODEC_ID]: lengthHooks,\n [PG_VARBIT_CODEC_ID]: lengthHooks,\n [PG_TIMESTAMP_CODEC_ID]: precisionHooks,\n [PG_TIMESTAMPTZ_CODEC_ID]: precisionHooks,\n [PG_TIME_CODEC_ID]: precisionHooks,\n [PG_TIMETZ_CODEC_ID]: precisionHooks,\n [PG_INTERVAL_CODEC_ID]: precisionHooks,\n [PG_ENUM_CODEC_ID]: pgEnumControlHooks,\n [PG_JSON_CODEC_ID]: identityHooks,\n [PG_JSONB_CODEC_ID]: identityHooks,\n },\n },\n storage: [\n { typeId: PG_TEXT_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'text' },\n { typeId: SQL_TEXT_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'text' },\n { typeId: SQL_CHAR_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'character' },\n {\n typeId: SQL_VARCHAR_CODEC_ID,\n familyId: 'sql',\n targetId: 'postgres',\n nativeType: 'character varying',\n },\n { typeId: SQL_INT_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'int4' },\n { typeId: SQL_FLOAT_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'float8' },\n {\n typeId: SQL_TIMESTAMP_CODEC_ID,\n familyId: 'sql',\n targetId: 'postgres',\n nativeType: 'timestamp',\n },\n { typeId: PG_CHAR_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'character' },\n {\n typeId: PG_VARCHAR_CODEC_ID,\n familyId: 'sql',\n targetId: 'postgres',\n nativeType: 'character varying',\n },\n { typeId: PG_INT_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'int4' },\n { typeId: PG_FLOAT_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'float8' },\n { typeId: PG_INT4_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'int4' },\n { typeId: PG_INT2_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'int2' },\n { typeId: PG_INT8_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'int8' },\n { typeId: PG_FLOAT4_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'float4' },\n { typeId: PG_FLOAT8_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'float8' },\n { typeId: PG_NUMERIC_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'numeric' },\n {\n typeId: PG_TIMESTAMP_CODEC_ID,\n familyId: 'sql',\n targetId: 'postgres',\n nativeType: 'timestamp',\n },\n {\n typeId: PG_TIMESTAMPTZ_CODEC_ID,\n familyId: 'sql',\n targetId: 'postgres',\n nativeType: 'timestamptz',\n },\n { typeId: PG_TIME_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'time' },\n { typeId: PG_TIMETZ_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'timetz' },\n { typeId: PG_BOOL_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'bool' },\n { typeId: PG_BIT_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'bit' },\n {\n typeId: PG_VARBIT_CODEC_ID,\n familyId: 'sql',\n targetId: 'postgres',\n nativeType: 'bit varying',\n },\n {\n typeId: PG_INTERVAL_CODEC_ID,\n familyId: 'sql',\n targetId: 'postgres',\n nativeType: 'interval',\n },\n { typeId: PG_JSON_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'json' },\n { typeId: PG_JSONB_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'jsonb' },\n ],\n },\n} as const;\n"],"mappings":";;;;;;AA8BA,MAAM,wBAAwB;;;;;;;;;;;;;;;AAoB9B,SAAS,cAAc,OAAmC;AACxD,QAAO,MAAM,QAAQ,MAAM,IAAI,MAAM,OAAO,UAAU,OAAO,UAAU,SAAS;;;;;;;;;;;;;;;;AAiBlF,SAAgB,mBAAmB,OAAiC;AAClE,KAAI,cAAc,MAAM,CACtB,QAAO;AAET,KAAI,OAAO,UAAU,YAAY,MAAM,WAAW,IAAI,IAAI,MAAM,SAAS,IAAI,EAAE;EAC7E,MAAM,QAAQ,MAAM,MAAM,GAAG,GAAG;AAChC,MAAI,UAAU,GACZ,QAAO,EAAE;AAEX,SAAO,mBAAmB,MAAM;;AAElC,QAAO;;AAGT,SAAS,mBAAmB,OAAyB;CACnD,MAAMA,SAAmB,EAAE;CAC3B,IAAI,IAAI;AACR,QAAO,IAAI,MAAM,QAAQ;AACvB,MAAI,MAAM,OAAO,KAAK;AACpB;AACA;;AAEF,MAAI,MAAM,OAAO,MAAK;AACpB;GACA,IAAI,UAAU;AACd,UAAO,IAAI,MAAM,UAAU,MAAM,OAAO,MAAK;AAC3C,QAAI,MAAM,OAAO,QAAQ,IAAI,IAAI,MAAM,QAAQ;AAC7C;AACA,gBAAW,MAAM;UAEjB,YAAW,MAAM;AAEnB;;AAEF;AACA,UAAO,KAAK,QAAQ;SACf;GACL,MAAM,YAAY,MAAM,QAAQ,KAAK,EAAE;AACvC,OAAI,cAAc,IAAI;AACpB,WAAO,KAAK,MAAM,MAAM,EAAE,CAAC,MAAM,CAAC;AAClC,QAAI,MAAM;UACL;AACL,WAAO,KAAK,MAAM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