@prisma-next/target-postgres 0.13.0-dev.2 → 0.13.0-dev.20

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 (115) hide show
  1. package/dist/{codec-ids-B1vOchLE.d.mts → codec-ids-BzrFF-I4.d.mts} +3 -2
  2. package/dist/{codec-ids-B1vOchLE.d.mts.map → codec-ids-BzrFF-I4.d.mts.map} +1 -1
  3. package/dist/{codec-ids-CTikp1if.mjs → codec-ids-C_-Hj6bL.mjs} +3 -2
  4. package/dist/{codec-ids-CTikp1if.mjs.map → codec-ids-C_-Hj6bL.mjs.map} +1 -1
  5. package/dist/codec-ids.d.mts +2 -2
  6. package/dist/codec-ids.mjs +2 -2
  7. package/dist/{codec-types-CnFiNML4.d.mts → codec-types-B0WT0obB.d.mts} +3 -2
  8. package/dist/codec-types-B0WT0obB.d.mts.map +1 -0
  9. package/dist/codec-types.d.mts +1 -1
  10. package/dist/{codecs-CBpEv4s5.d.mts → codecs-CX56Smsj.d.mts} +26 -3
  11. package/dist/{codecs-CBpEv4s5.d.mts.map → codecs-CX56Smsj.d.mts.map} +1 -1
  12. package/dist/codecs.d.mts +2 -2
  13. package/dist/codecs.mjs +31 -2
  14. package/dist/codecs.mjs.map +1 -1
  15. package/dist/contract-free.mjs +1 -1
  16. package/dist/control.d.mts.map +1 -1
  17. package/dist/control.mjs +19 -22
  18. package/dist/control.mjs.map +1 -1
  19. package/dist/{data-transform-D25tLeYU.mjs → data-transform-BOWpliq8.mjs} +9 -17
  20. package/dist/data-transform-BOWpliq8.mjs.map +1 -0
  21. package/dist/{data-transform-DGOqcLrf.d.mts → data-transform-DDgWdB5o.d.mts} +2 -2
  22. package/dist/data-transform-DDgWdB5o.d.mts.map +1 -0
  23. package/dist/data-transform.d.mts +1 -1
  24. package/dist/data-transform.mjs +1 -1
  25. package/dist/{descriptor-meta-DKmj-IMN.mjs → descriptor-meta-26XbSdrs.mjs} +2 -2
  26. package/dist/{descriptor-meta-DKmj-IMN.mjs.map → descriptor-meta-26XbSdrs.mjs.map} +1 -1
  27. package/dist/{descriptor-meta-runtime-My8_s4cs.mjs → descriptor-meta-runtime-B5ZtrgVF.mjs} +40 -2
  28. package/dist/descriptor-meta-runtime-B5ZtrgVF.mjs.map +1 -0
  29. package/dist/{enum-planning-BCyvlFHk.mjs → enum-planning-eI1gxdKF.mjs} +0 -0
  30. package/dist/enum-planning-eI1gxdKF.mjs.map +1 -0
  31. package/dist/enum-planning.d.mts +13 -7
  32. package/dist/enum-planning.d.mts.map +1 -1
  33. package/dist/enum-planning.mjs +2 -2
  34. package/dist/{issue-planner-Br0pt1Ea.mjs → issue-planner-DsCMvGja.mjs} +14 -7
  35. package/dist/issue-planner-DsCMvGja.mjs.map +1 -0
  36. package/dist/issue-planner.d.mts +1 -1
  37. package/dist/issue-planner.d.mts.map +1 -1
  38. package/dist/issue-planner.mjs +1 -1
  39. package/dist/migration.d.mts +2 -2
  40. package/dist/migration.mjs +3 -3
  41. package/dist/{op-factory-call-D2aAUhmS.mjs → op-factory-call-BZ3xDgCY.mjs} +18 -10
  42. package/dist/op-factory-call-BZ3xDgCY.mjs.map +1 -0
  43. package/dist/{op-factory-call-DMA86_2D.d.mts → op-factory-call-DEvD9sbB.d.mts} +5 -5
  44. package/dist/op-factory-call-DEvD9sbB.d.mts.map +1 -0
  45. package/dist/op-factory-call.d.mts +1 -1
  46. package/dist/op-factory-call.mjs +1 -1
  47. package/dist/pack.d.mts +38 -1
  48. package/dist/pack.d.mts.map +1 -1
  49. package/dist/pack.mjs +1 -1
  50. package/dist/{planner-CAYPJObw.mjs → planner-QWZaVIrn.mjs} +6 -6
  51. package/dist/planner-QWZaVIrn.mjs.map +1 -0
  52. package/dist/{planner-produced-postgres-migration-NSEhWL0L.mjs → planner-produced-postgres-migration-BHH6-2-1.mjs} +6 -4
  53. package/dist/planner-produced-postgres-migration-BHH6-2-1.mjs.map +1 -0
  54. package/dist/{planner-produced-postgres-migration-B4EDvLdz.d.mts → planner-produced-postgres-migration-CIX9peJN.d.mts} +5 -6
  55. package/dist/planner-produced-postgres-migration-CIX9peJN.d.mts.map +1 -0
  56. package/dist/planner-produced-postgres-migration.d.mts +1 -1
  57. package/dist/planner-produced-postgres-migration.mjs +1 -1
  58. package/dist/{planner-sql-checks-DAdhnI2c.mjs → planner-sql-checks-CrAbk7gX.mjs} +2 -2
  59. package/dist/{planner-sql-checks-DAdhnI2c.mjs.map → planner-sql-checks-CrAbk7gX.mjs.map} +1 -1
  60. package/dist/planner-sql-checks.mjs +1 -1
  61. package/dist/planner.d.mts +4 -4
  62. package/dist/planner.d.mts.map +1 -1
  63. package/dist/planner.mjs +1 -1
  64. package/dist/{postgres-contract-serializer-DYTyXjPf.mjs → postgres-contract-serializer-BDbqgeFb.mjs} +14 -7
  65. package/dist/postgres-contract-serializer-BDbqgeFb.mjs.map +1 -0
  66. package/dist/{postgres-migration-COore9Mz.mjs → postgres-migration-BN6TNJNf.mjs} +3 -3
  67. package/dist/{postgres-migration-COore9Mz.mjs.map → postgres-migration-BN6TNJNf.mjs.map} +1 -1
  68. package/dist/{postgres-migration-DZ_gLUOW.d.mts → postgres-migration-h_DA3LRq.d.mts} +5 -5
  69. package/dist/postgres-migration-h_DA3LRq.d.mts.map +1 -0
  70. package/dist/{postgres-schema-BuxCxbvB.mjs → postgres-schema-BAgkIU9u.mjs} +17 -6
  71. package/dist/postgres-schema-BAgkIU9u.mjs.map +1 -0
  72. package/dist/{render-ops-BpjstrKQ.mjs → render-ops-BREh1kHe.mjs} +10 -5
  73. package/dist/render-ops-BREh1kHe.mjs.map +1 -0
  74. package/dist/render-ops.d.mts +2 -2
  75. package/dist/render-ops.d.mts.map +1 -1
  76. package/dist/render-ops.mjs +1 -1
  77. package/dist/runtime.d.mts.map +1 -1
  78. package/dist/runtime.mjs +2 -2
  79. package/dist/types.d.mts +3 -1
  80. package/dist/types.d.mts.map +1 -1
  81. package/dist/types.mjs +1 -1
  82. package/package.json +17 -17
  83. package/src/core/authoring.ts +42 -0
  84. package/src/core/codec-ids.ts +1 -0
  85. package/src/core/codec-type-map.ts +2 -0
  86. package/src/core/codecs.ts +44 -0
  87. package/src/core/migrations/enum-planning.ts +33 -29
  88. package/src/core/migrations/issue-planner.ts +24 -3
  89. package/src/core/migrations/op-factory-call.ts +22 -9
  90. package/src/core/migrations/operations/data-transform.ts +15 -18
  91. package/src/core/migrations/planner-produced-postgres-migration.ts +15 -7
  92. package/src/core/migrations/planner.ts +6 -4
  93. package/src/core/migrations/postgres-migration.ts +3 -3
  94. package/src/core/migrations/render-ops.ts +26 -13
  95. package/src/core/migrations/runner.ts +26 -16
  96. package/src/core/postgres-contract-serializer.ts +15 -1
  97. package/src/core/postgres-schema.ts +35 -16
  98. package/src/exports/codecs.ts +2 -0
  99. package/src/exports/control.ts +9 -16
  100. package/src/exports/enum-planning.ts +0 -1
  101. package/dist/codec-types-CnFiNML4.d.mts.map +0 -1
  102. package/dist/data-transform-D25tLeYU.mjs.map +0 -1
  103. package/dist/data-transform-DGOqcLrf.d.mts.map +0 -1
  104. package/dist/descriptor-meta-runtime-My8_s4cs.mjs.map +0 -1
  105. package/dist/enum-planning-BCyvlFHk.mjs.map +0 -1
  106. package/dist/issue-planner-Br0pt1Ea.mjs.map +0 -1
  107. package/dist/op-factory-call-D2aAUhmS.mjs.map +0 -1
  108. package/dist/op-factory-call-DMA86_2D.d.mts.map +0 -1
  109. package/dist/planner-CAYPJObw.mjs.map +0 -1
  110. package/dist/planner-produced-postgres-migration-B4EDvLdz.d.mts.map +0 -1
  111. package/dist/planner-produced-postgres-migration-NSEhWL0L.mjs.map +0 -1
  112. package/dist/postgres-contract-serializer-DYTyXjPf.mjs.map +0 -1
  113. package/dist/postgres-migration-DZ_gLUOW.d.mts.map +0 -1
  114. package/dist/postgres-schema-BuxCxbvB.mjs.map +0 -1
  115. package/dist/render-ops-BpjstrKQ.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"planner-sql-checks-DAdhnI2c.mjs","names":[],"sources":["../src/core/migrations/planner-sql-checks.ts"],"sourcesContent":["import type { CodecControlHooks } from '@prisma-next/family-sql/control';\nimport type {\n PostgresEnumStorageEntry,\n StorageColumn,\n StorageTypeInstance,\n} from '@prisma-next/sql-contract/types';\nimport { postgresCreateNamespace } from '../postgres-schema';\nimport { escapeLiteral, quoteIdentifier } from '../sql-utils';\nimport { resolveColumnTypeMetadata } from './planner-type-resolution';\n\n/**\n * String-keyed entry points the migration ops use to render\n * schema-qualified DDL and catalog checks. The `schema` argument is\n * interpreted as a namespace coordinate: the framework `__unbound__`\n * sentinel resolves to the late-bound `PostgresUnboundSchema` singleton\n * (which elides the qualifier so `search_path` decides at runtime); any\n * other id materialises a `PostgresSchema(id)` whose qualifier is the\n * named schema. Helpers route through these `Namespace` concretions so\n * the unbound branch lives in the polymorphic override, not the call\n * site.\n */\nexport function qualifyTableName(schema: string, table: string): string {\n return postgresCreateNamespace({ id: schema, entries: { table: {} } }).qualifyTable(table);\n}\n\nexport function toRegclassLiteral(schema: string, name: string): string {\n return postgresCreateNamespace({ id: schema, entries: { table: {} } }).regclassLiteral(name);\n}\n\n/**\n * When `table` is omitted the check matches by name + schema across all tables.\n * Pass `table` to scope the check to a single table (prevents false matches on\n * identically-named constraints in different tables).\n */\nexport function constraintExistsCheck({\n constraintName,\n schema,\n table,\n exists = true,\n}: {\n constraintName: string;\n schema: string;\n table?: string;\n exists?: boolean;\n}): string {\n const namespace = postgresCreateNamespace({ id: schema, entries: { table: {} } });\n const existsClause = exists ? 'EXISTS' : 'NOT EXISTS';\n const tableFilter = table\n ? `AND c.conrelid = to_regclass(${namespace.regclassLiteral(table)})`\n : '';\n return `SELECT ${existsClause} (\n SELECT 1 FROM pg_constraint c\n JOIN pg_namespace n ON c.connamespace = n.oid\n WHERE c.conname = '${escapeLiteral(constraintName)}'\n AND n.nspname = ${namespace.schemaSqlExpression()}\n ${tableFilter}\n)`;\n}\n\nexport function columnExistsCheck({\n schema,\n table,\n column,\n exists = true,\n}: {\n schema: string;\n table: string;\n column: string;\n exists?: boolean;\n}): string {\n const namespace = postgresCreateNamespace({ id: schema, entries: { table: {} } });\n const existsClause = exists ? '' : 'NOT ';\n return `SELECT ${existsClause}EXISTS (\n SELECT 1\n FROM information_schema.columns\n WHERE table_schema = ${namespace.schemaSqlExpression()}\n AND table_name = '${escapeLiteral(table)}'\n AND column_name = '${escapeLiteral(column)}'\n)`;\n}\n\nexport function columnNullabilityCheck({\n schema,\n table,\n column,\n nullable,\n}: {\n schema: string;\n table: string;\n column: string;\n nullable: boolean;\n}): string {\n const namespace = postgresCreateNamespace({ id: schema, entries: { table: {} } });\n const expected = nullable ? 'YES' : 'NO';\n return `SELECT EXISTS (\n SELECT 1\n FROM information_schema.columns\n WHERE table_schema = ${namespace.schemaSqlExpression()}\n AND table_name = '${escapeLiteral(table)}'\n AND column_name = '${escapeLiteral(column)}'\n AND is_nullable = '${expected}'\n)`;\n}\n\nexport function tableIsEmptyCheck(qualifiedTableName: string): string {\n return `SELECT NOT EXISTS (SELECT 1 FROM ${qualifiedTableName} LIMIT 1)`;\n}\n\nexport function columnHasNoDefaultCheck(opts: {\n schema: string;\n table: string;\n column: string;\n}): string {\n const namespace = postgresCreateNamespace({ id: opts.schema, entries: { table: {} } });\n return `SELECT NOT EXISTS (\n SELECT 1\n FROM information_schema.columns\n WHERE table_schema = ${namespace.schemaSqlExpression()}\n AND table_name = '${escapeLiteral(opts.table)}'\n AND column_name = '${escapeLiteral(opts.column)}'\n AND column_default IS NOT NULL\n)`;\n}\n\nconst FORMAT_TYPE_DISPLAY: ReadonlyMap<string, string> = new Map([\n ['int2', 'smallint'],\n ['int4', 'integer'],\n ['int8', 'bigint'],\n ['float4', 'real'],\n ['float8', 'double precision'],\n ['bool', 'boolean'],\n ['timestamp', 'timestamp without time zone'],\n ['timestamptz', 'timestamp with time zone'],\n ['time', 'time without time zone'],\n ['timetz', 'time with time zone'],\n]);\n\nconst UNQUOTED_POSTGRES_IDENTIFIER_PATTERN = /^[a-z_][a-z0-9_$]*$/;\n\nconst POSTGRES_RESERVED_IDENTIFIER_WORDS = new Set([\n 'all',\n 'analyse',\n 'analyze',\n 'and',\n 'any',\n 'array',\n 'as',\n 'asc',\n 'asymmetric',\n 'authorization',\n 'between',\n 'binary',\n 'both',\n 'case',\n 'cast',\n 'check',\n 'collate',\n 'column',\n 'constraint',\n 'create',\n 'current_catalog',\n 'current_date',\n 'current_role',\n 'current_time',\n 'current_timestamp',\n 'current_user',\n 'default',\n 'deferrable',\n 'desc',\n 'distinct',\n 'do',\n 'else',\n 'end',\n 'except',\n 'false',\n 'fetch',\n 'for',\n 'foreign',\n 'freeze',\n 'from',\n 'full',\n 'grant',\n 'group',\n 'having',\n 'ilike',\n 'in',\n 'initially',\n 'inner',\n 'intersect',\n 'into',\n 'is',\n 'isnull',\n 'join',\n 'lateral',\n 'leading',\n 'left',\n 'like',\n 'limit',\n 'localtime',\n 'localtimestamp',\n 'natural',\n 'not',\n 'notnull',\n 'null',\n 'offset',\n 'on',\n 'only',\n 'or',\n 'order',\n 'outer',\n 'overlaps',\n 'placing',\n 'primary',\n 'references',\n 'right',\n 'select',\n 'session_user',\n 'similar',\n 'some',\n 'symmetric',\n 'table',\n 'then',\n 'to',\n 'trailing',\n 'true',\n 'union',\n 'unique',\n 'user',\n 'using',\n 'variadic',\n 'verbose',\n 'when',\n 'where',\n 'window',\n 'with',\n]);\n\nfunction formatUserDefinedTypeName(identifier: string): string {\n if (\n UNQUOTED_POSTGRES_IDENTIFIER_PATTERN.test(identifier) &&\n !POSTGRES_RESERVED_IDENTIFIER_WORDS.has(identifier)\n ) {\n return identifier;\n }\n\n return quoteIdentifier(identifier);\n}\n\nexport function buildExpectedFormatType(\n column: StorageColumn,\n codecHooks: Map<string, CodecControlHooks>,\n storageTypes: Record<string, StorageTypeInstance | PostgresEnumStorageEntry> = {},\n): string {\n const resolved = resolveColumnTypeMetadata(column, storageTypes);\n\n if (resolved.typeParams && resolved.codecId) {\n const hooks = codecHooks.get(resolved.codecId);\n if (hooks?.expandNativeType) {\n return hooks.expandNativeType({\n nativeType: resolved.nativeType,\n codecId: resolved.codecId,\n typeParams: resolved.typeParams,\n });\n }\n }\n\n if (column.typeRef) {\n return formatUserDefinedTypeName(resolved.nativeType);\n }\n\n return FORMAT_TYPE_DISPLAY.get(resolved.nativeType) ?? resolved.nativeType;\n}\n\nexport function columnTypeCheck({\n schema,\n table,\n column,\n expectedType,\n}: {\n schema: string;\n table: string;\n column: string;\n expectedType: string;\n}): string {\n const namespace = postgresCreateNamespace({ id: schema, entries: { table: {} } });\n return `SELECT EXISTS (\n SELECT 1\n FROM pg_attribute a\n JOIN pg_class c ON c.oid = a.attrelid\n JOIN pg_namespace n ON n.oid = c.relnamespace\n WHERE n.nspname = ${namespace.schemaSqlExpression()}\n AND c.relname = '${escapeLiteral(table)}'\n AND a.attname = '${escapeLiteral(column)}'\n AND format_type(a.atttypid, a.atttypmod) = '${escapeLiteral(expectedType)}'\n AND NOT a.attisdropped\n)`;\n}\n\nexport function columnDefaultExistsCheck({\n schema,\n table,\n column,\n exists = true,\n}: {\n schema: string;\n table: string;\n column: string;\n exists?: boolean;\n}): string {\n const namespace = postgresCreateNamespace({ id: schema, entries: { table: {} } });\n const nullCheck = exists ? 'IS NOT NULL' : 'IS NULL';\n return `SELECT EXISTS (\n SELECT 1\n FROM information_schema.columns\n WHERE table_schema = ${namespace.schemaSqlExpression()}\n AND table_name = '${escapeLiteral(table)}'\n AND column_name = '${escapeLiteral(column)}'\n AND column_default ${nullCheck}\n)`;\n}\n\nexport function tableHasPrimaryKeyCheck(\n schema: string,\n table: string,\n exists: boolean,\n constraintName?: string,\n): string {\n const namespace = postgresCreateNamespace({ id: schema, entries: { table: {} } });\n const comparison = exists ? '' : 'NOT ';\n const constraintFilter = constraintName\n ? `AND c2.relname = '${escapeLiteral(constraintName)}'`\n : '';\n return `SELECT ${comparison}EXISTS (\n SELECT 1\n FROM pg_index i\n JOIN pg_class c ON c.oid = i.indrelid\n JOIN pg_namespace n ON n.oid = c.relnamespace\n LEFT JOIN pg_class c2 ON c2.oid = i.indexrelid\n WHERE n.nspname = ${namespace.schemaSqlExpression()}\n AND c.relname = '${escapeLiteral(table)}'\n AND i.indisprimary\n ${constraintFilter}\n)`;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAqBA,SAAgB,iBAAiB,QAAgB,OAAuB;CACtE,OAAO,wBAAwB;EAAE,IAAI;EAAQ,SAAS,EAAE,OAAO,CAAC,EAAE;CAAE,CAAC,CAAC,CAAC,aAAa,KAAK;AAC3F;AAEA,SAAgB,kBAAkB,QAAgB,MAAsB;CACtE,OAAO,wBAAwB;EAAE,IAAI;EAAQ,SAAS,EAAE,OAAO,CAAC,EAAE;CAAE,CAAC,CAAC,CAAC,gBAAgB,IAAI;AAC7F;;;;;;AAOA,SAAgB,sBAAsB,EACpC,gBACA,QACA,OACA,SAAS,QAMA;CACT,MAAM,YAAY,wBAAwB;EAAE,IAAI;EAAQ,SAAS,EAAE,OAAO,CAAC,EAAE;CAAE,CAAC;CAChF,MAAM,eAAe,SAAS,WAAW;CACzC,MAAM,cAAc,QAChB,gCAAgC,UAAU,gBAAgB,KAAK,EAAE,KACjE;CACJ,OAAO,UAAU,aAAa;;;uBAGT,cAAc,cAAc,EAAE;oBACjC,UAAU,oBAAoB,EAAE;IAChD,YAAY;;AAEhB;AAEA,SAAgB,kBAAkB,EAChC,QACA,OACA,QACA,SAAS,QAMA;CACT,MAAM,YAAY,wBAAwB;EAAE,IAAI;EAAQ,SAAS,EAAE,OAAO,CAAC,EAAE;CAAE,CAAC;CAEhF,OAAO,UADc,SAAS,KAAK,OACL;;;yBAGP,UAAU,oBAAoB,EAAE;wBACjC,cAAc,KAAK,EAAE;yBACpB,cAAc,MAAM,EAAE;;AAE/C;AAEA,SAAgB,uBAAuB,EACrC,QACA,OACA,QACA,YAMS;CACT,MAAM,YAAY,wBAAwB;EAAE,IAAI;EAAQ,SAAS,EAAE,OAA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,OAAO,CAAC,EAAE;CAAE,CAAC;CAChF,MAAM,aAAa,SAAS,KAAK;CACjC,MAAM,mBAAmB,iBACrB,qBAAqB,cAAc,cAAc,EAAE,KACnD;CACJ,OAAO,UAAU,WAAW;;;;;;sBAMR,UAAU,oBAAoB,EAAE;uBAC/B,cAAc,KAAK,EAAE;;MAEtC,iBAAiB;;AAEvB"}
1
+ {"version":3,"file":"planner-sql-checks-CrAbk7gX.mjs","names":[],"sources":["../src/core/migrations/planner-sql-checks.ts"],"sourcesContent":["import type { CodecControlHooks } from '@prisma-next/family-sql/control';\nimport type {\n PostgresEnumStorageEntry,\n StorageColumn,\n StorageTypeInstance,\n} from '@prisma-next/sql-contract/types';\nimport { postgresCreateNamespace } from '../postgres-schema';\nimport { escapeLiteral, quoteIdentifier } from '../sql-utils';\nimport { resolveColumnTypeMetadata } from './planner-type-resolution';\n\n/**\n * String-keyed entry points the migration ops use to render\n * schema-qualified DDL and catalog checks. The `schema` argument is\n * interpreted as a namespace coordinate: the framework `__unbound__`\n * sentinel resolves to the late-bound `PostgresUnboundSchema` singleton\n * (which elides the qualifier so `search_path` decides at runtime); any\n * other id materialises a `PostgresSchema(id)` whose qualifier is the\n * named schema. Helpers route through these `Namespace` concretions so\n * the unbound branch lives in the polymorphic override, not the call\n * site.\n */\nexport function qualifyTableName(schema: string, table: string): string {\n return postgresCreateNamespace({ id: schema, entries: { table: {} } }).qualifyTable(table);\n}\n\nexport function toRegclassLiteral(schema: string, name: string): string {\n return postgresCreateNamespace({ id: schema, entries: { table: {} } }).regclassLiteral(name);\n}\n\n/**\n * When `table` is omitted the check matches by name + schema across all tables.\n * Pass `table` to scope the check to a single table (prevents false matches on\n * identically-named constraints in different tables).\n */\nexport function constraintExistsCheck({\n constraintName,\n schema,\n table,\n exists = true,\n}: {\n constraintName: string;\n schema: string;\n table?: string;\n exists?: boolean;\n}): string {\n const namespace = postgresCreateNamespace({ id: schema, entries: { table: {} } });\n const existsClause = exists ? 'EXISTS' : 'NOT EXISTS';\n const tableFilter = table\n ? `AND c.conrelid = to_regclass(${namespace.regclassLiteral(table)})`\n : '';\n return `SELECT ${existsClause} (\n SELECT 1 FROM pg_constraint c\n JOIN pg_namespace n ON c.connamespace = n.oid\n WHERE c.conname = '${escapeLiteral(constraintName)}'\n AND n.nspname = ${namespace.schemaSqlExpression()}\n ${tableFilter}\n)`;\n}\n\nexport function columnExistsCheck({\n schema,\n table,\n column,\n exists = true,\n}: {\n schema: string;\n table: string;\n column: string;\n exists?: boolean;\n}): string {\n const namespace = postgresCreateNamespace({ id: schema, entries: { table: {} } });\n const existsClause = exists ? '' : 'NOT ';\n return `SELECT ${existsClause}EXISTS (\n SELECT 1\n FROM information_schema.columns\n WHERE table_schema = ${namespace.schemaSqlExpression()}\n AND table_name = '${escapeLiteral(table)}'\n AND column_name = '${escapeLiteral(column)}'\n)`;\n}\n\nexport function columnNullabilityCheck({\n schema,\n table,\n column,\n nullable,\n}: {\n schema: string;\n table: string;\n column: string;\n nullable: boolean;\n}): string {\n const namespace = postgresCreateNamespace({ id: schema, entries: { table: {} } });\n const expected = nullable ? 'YES' : 'NO';\n return `SELECT EXISTS (\n SELECT 1\n FROM information_schema.columns\n WHERE table_schema = ${namespace.schemaSqlExpression()}\n AND table_name = '${escapeLiteral(table)}'\n AND column_name = '${escapeLiteral(column)}'\n AND is_nullable = '${expected}'\n)`;\n}\n\nexport function tableIsEmptyCheck(qualifiedTableName: string): string {\n return `SELECT NOT EXISTS (SELECT 1 FROM ${qualifiedTableName} LIMIT 1)`;\n}\n\nexport function columnHasNoDefaultCheck(opts: {\n schema: string;\n table: string;\n column: string;\n}): string {\n const namespace = postgresCreateNamespace({ id: opts.schema, entries: { table: {} } });\n return `SELECT NOT EXISTS (\n SELECT 1\n FROM information_schema.columns\n WHERE table_schema = ${namespace.schemaSqlExpression()}\n AND table_name = '${escapeLiteral(opts.table)}'\n AND column_name = '${escapeLiteral(opts.column)}'\n AND column_default IS NOT NULL\n)`;\n}\n\nconst FORMAT_TYPE_DISPLAY: ReadonlyMap<string, string> = new Map([\n ['int2', 'smallint'],\n ['int4', 'integer'],\n ['int8', 'bigint'],\n ['float4', 'real'],\n ['float8', 'double precision'],\n ['bool', 'boolean'],\n ['timestamp', 'timestamp without time zone'],\n ['timestamptz', 'timestamp with time zone'],\n ['time', 'time without time zone'],\n ['timetz', 'time with time zone'],\n]);\n\nconst UNQUOTED_POSTGRES_IDENTIFIER_PATTERN = /^[a-z_][a-z0-9_$]*$/;\n\nconst POSTGRES_RESERVED_IDENTIFIER_WORDS = new Set([\n 'all',\n 'analyse',\n 'analyze',\n 'and',\n 'any',\n 'array',\n 'as',\n 'asc',\n 'asymmetric',\n 'authorization',\n 'between',\n 'binary',\n 'both',\n 'case',\n 'cast',\n 'check',\n 'collate',\n 'column',\n 'constraint',\n 'create',\n 'current_catalog',\n 'current_date',\n 'current_role',\n 'current_time',\n 'current_timestamp',\n 'current_user',\n 'default',\n 'deferrable',\n 'desc',\n 'distinct',\n 'do',\n 'else',\n 'end',\n 'except',\n 'false',\n 'fetch',\n 'for',\n 'foreign',\n 'freeze',\n 'from',\n 'full',\n 'grant',\n 'group',\n 'having',\n 'ilike',\n 'in',\n 'initially',\n 'inner',\n 'intersect',\n 'into',\n 'is',\n 'isnull',\n 'join',\n 'lateral',\n 'leading',\n 'left',\n 'like',\n 'limit',\n 'localtime',\n 'localtimestamp',\n 'natural',\n 'not',\n 'notnull',\n 'null',\n 'offset',\n 'on',\n 'only',\n 'or',\n 'order',\n 'outer',\n 'overlaps',\n 'placing',\n 'primary',\n 'references',\n 'right',\n 'select',\n 'session_user',\n 'similar',\n 'some',\n 'symmetric',\n 'table',\n 'then',\n 'to',\n 'trailing',\n 'true',\n 'union',\n 'unique',\n 'user',\n 'using',\n 'variadic',\n 'verbose',\n 'when',\n 'where',\n 'window',\n 'with',\n]);\n\nfunction formatUserDefinedTypeName(identifier: string): string {\n if (\n UNQUOTED_POSTGRES_IDENTIFIER_PATTERN.test(identifier) &&\n !POSTGRES_RESERVED_IDENTIFIER_WORDS.has(identifier)\n ) {\n return identifier;\n }\n\n return quoteIdentifier(identifier);\n}\n\nexport function buildExpectedFormatType(\n column: StorageColumn,\n codecHooks: Map<string, CodecControlHooks>,\n storageTypes: Record<string, StorageTypeInstance | PostgresEnumStorageEntry> = {},\n): string {\n const resolved = resolveColumnTypeMetadata(column, storageTypes);\n\n if (resolved.typeParams && resolved.codecId) {\n const hooks = codecHooks.get(resolved.codecId);\n if (hooks?.expandNativeType) {\n return hooks.expandNativeType({\n nativeType: resolved.nativeType,\n codecId: resolved.codecId,\n typeParams: resolved.typeParams,\n });\n }\n }\n\n if (column.typeRef) {\n return formatUserDefinedTypeName(resolved.nativeType);\n }\n\n return FORMAT_TYPE_DISPLAY.get(resolved.nativeType) ?? resolved.nativeType;\n}\n\nexport function columnTypeCheck({\n schema,\n table,\n column,\n expectedType,\n}: {\n schema: string;\n table: string;\n column: string;\n expectedType: string;\n}): string {\n const namespace = postgresCreateNamespace({ id: schema, entries: { table: {} } });\n return `SELECT EXISTS (\n SELECT 1\n FROM pg_attribute a\n JOIN pg_class c ON c.oid = a.attrelid\n JOIN pg_namespace n ON n.oid = c.relnamespace\n WHERE n.nspname = ${namespace.schemaSqlExpression()}\n AND c.relname = '${escapeLiteral(table)}'\n AND a.attname = '${escapeLiteral(column)}'\n AND format_type(a.atttypid, a.atttypmod) = '${escapeLiteral(expectedType)}'\n AND NOT a.attisdropped\n)`;\n}\n\nexport function columnDefaultExistsCheck({\n schema,\n table,\n column,\n exists = true,\n}: {\n schema: string;\n table: string;\n column: string;\n exists?: boolean;\n}): string {\n const namespace = postgresCreateNamespace({ id: schema, entries: { table: {} } });\n const nullCheck = exists ? 'IS NOT NULL' : 'IS NULL';\n return `SELECT EXISTS (\n SELECT 1\n FROM information_schema.columns\n WHERE table_schema = ${namespace.schemaSqlExpression()}\n AND table_name = '${escapeLiteral(table)}'\n AND column_name = '${escapeLiteral(column)}'\n AND column_default ${nullCheck}\n)`;\n}\n\nexport function tableHasPrimaryKeyCheck(\n schema: string,\n table: string,\n exists: boolean,\n constraintName?: string,\n): string {\n const namespace = postgresCreateNamespace({ id: schema, entries: { table: {} } });\n const comparison = exists ? '' : 'NOT ';\n const constraintFilter = constraintName\n ? `AND c2.relname = '${escapeLiteral(constraintName)}'`\n : '';\n return `SELECT ${comparison}EXISTS (\n SELECT 1\n FROM pg_index i\n JOIN pg_class c ON c.oid = i.indrelid\n JOIN pg_namespace n ON n.oid = c.relnamespace\n LEFT JOIN pg_class c2 ON c2.oid = i.indexrelid\n WHERE n.nspname = ${namespace.schemaSqlExpression()}\n AND c.relname = '${escapeLiteral(table)}'\n AND i.indisprimary\n ${constraintFilter}\n)`;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAqBA,SAAgB,iBAAiB,QAAgB,OAAuB;CACtE,OAAO,wBAAwB;EAAE,IAAI;EAAQ,SAAS,EAAE,OAAO,CAAC,EAAE;CAAE,CAAC,CAAC,CAAC,aAAa,KAAK;AAC3F;AAEA,SAAgB,kBAAkB,QAAgB,MAAsB;CACtE,OAAO,wBAAwB;EAAE,IAAI;EAAQ,SAAS,EAAE,OAAO,CAAC,EAAE;CAAE,CAAC,CAAC,CAAC,gBAAgB,IAAI;AAC7F;;;;;;AAOA,SAAgB,sBAAsB,EACpC,gBACA,QACA,OACA,SAAS,QAMA;CACT,MAAM,YAAY,wBAAwB;EAAE,IAAI;EAAQ,SAAS,EAAE,OAAO,CAAC,EAAE;CAAE,CAAC;CAChF,MAAM,eAAe,SAAS,WAAW;CACzC,MAAM,cAAc,QAChB,gCAAgC,UAAU,gBAAgB,KAAK,EAAE,KACjE;CACJ,OAAO,UAAU,aAAa;;;uBAGT,cAAc,cAAc,EAAE;oBACjC,UAAU,oBAAoB,EAAE;IAChD,YAAY;;AAEhB;AAEA,SAAgB,kBAAkB,EAChC,QACA,OACA,QACA,SAAS,QAMA;CACT,MAAM,YAAY,wBAAwB;EAAE,IAAI;EAAQ,SAAS,EAAE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EAAE;CAAE,CAAC;CAChF,MAAM,YAAY,SAAS,gBAAgB;CAC3C,OAAO;;;yBAGgB,UAAU,oBAAoB,EAAE;wBACjC,cAAc,KAAK,EAAE;yBACpB,cAAc,MAAM,EAAE;yBACtB,UAAU;;AAEnC;AAEA,SAAgB,wBACd,QACA,OACA,QACA,gBACQ;CACR,MAAM,YAAY,wBAAwB;EAAE,IAAI;EAAQ,SAAS,EAAE,OAAO,CAAC,EAAE;CAAE,CAAC;CAChF,MAAM,aAAa,SAAS,KAAK;CACjC,MAAM,mBAAmB,iBACrB,qBAAqB,cAAc,cAAc,EAAE,KACnD;CACJ,OAAO,UAAU,WAAW;;;;;;sBAMR,UAAU,oBAAoB,EAAE;uBAC/B,cAAc,KAAK,EAAE;;MAEtC,iBAAiB;;AAEvB"}
@@ -1,2 +1,2 @@
1
- import { a as columnNullabilityCheck, c as qualifyTableName, d as toRegclassLiteral, i as columnHasNoDefaultCheck, l as tableHasPrimaryKeyCheck, r as columnExistsCheck, s as constraintExistsCheck, t as buildExpectedFormatType, u as tableIsEmptyCheck } from "./planner-sql-checks-DAdhnI2c.mjs";
1
+ import { a as columnNullabilityCheck, c as qualifyTableName, d as toRegclassLiteral, i as columnHasNoDefaultCheck, l as tableHasPrimaryKeyCheck, r as columnExistsCheck, s as constraintExistsCheck, t as buildExpectedFormatType, u as tableIsEmptyCheck } from "./planner-sql-checks-CrAbk7gX.mjs";
2
2
  export { buildExpectedFormatType, columnExistsCheck, columnHasNoDefaultCheck, columnNullabilityCheck, constraintExistsCheck, qualifyTableName, tableHasPrimaryKeyCheck, tableIsEmptyCheck, toRegclassLiteral };
@@ -1,12 +1,12 @@
1
- import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-B4EDvLdz.mjs";
1
+ import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-CIX9peJN.mjs";
2
2
  import { MigrationOperationPolicy, SqlPlannerConflict, SqlPlannerFailureResult } from "@prisma-next/family-sql/control";
3
3
  import { MigrationPlanWithAuthoringSurface, MigrationPlanner, MigrationScaffoldContext } from "@prisma-next/framework-components/control";
4
4
  import { Contract } from "@prisma-next/contract/types";
5
- import { Lowerer } from "@prisma-next/family-sql/control-adapter";
5
+ import { ExecuteRequestLowerer } from "@prisma-next/family-sql/control-adapter";
6
6
  import { TargetBoundComponentDescriptor } from "@prisma-next/framework-components/components";
7
7
 
8
8
  //#region src/core/migrations/planner.d.ts
9
- declare function createPostgresMigrationPlanner(lowerer: Lowerer): PostgresMigrationPlanner;
9
+ declare function createPostgresMigrationPlanner(lowerer: ExecuteRequestLowerer): PostgresMigrationPlanner;
10
10
  /**
11
11
  * Result of `PostgresMigrationPlanner.plan()`. A discriminated union whose
12
12
  * success variant carries a `TypeScriptRenderablePostgresMigration` — a
@@ -37,7 +37,7 @@ type PostgresPlanResult = {
37
37
  */
38
38
  declare class PostgresMigrationPlanner implements MigrationPlanner<'sql', 'postgres'> {
39
39
  #private;
40
- constructor(lowerer?: Lowerer);
40
+ constructor(lowerer?: ExecuteRequestLowerer);
41
41
  plan(options: {
42
42
  readonly contract: unknown;
43
43
  readonly schema: unknown;
@@ -1 +1 @@
1
- {"version":3,"file":"planner.d.mts","names":[],"sources":["../src/core/migrations/planner.ts"],"mappings":";;;;;;;;iBAsDgB,8BAAA,CAA+B,OAAA,EAAS,OAAA,GAAU,wBAAwB;;AAA1F;;;;;;KAWY,kBAAA;EAAA,SAEG,IAAA;EAAA,SACA,IAAA,EAAM,qCAAA;EAAA,SACN,QAAA,YAAoB,kBAAA;AAAA,IAE/B,uBAAA;;;;;;;;;;;;;;AAAuB;AAkB3B;;cAAa,wBAAA,YAAoC,gBAAA;EAAA;cAGnC,OAAA,GAAU,OAAA;EAItB,IAAA,CAAK,OAAA;IAAA,SACM,QAAA;IAAA,SACA,MAAA;IAAA,SACA,MAAA,EAAQ,wBAAA;IA6BR;;;;;;;;;;;;;;IAAA,SAdA,YAAA,EAAc,QAAA;IAAA,SACd,UAAA;IAAA,SACA,mBAAA,EAAqB,aAAA,CAAc,8BAAA;IADnC;;;;;IAAA,SAOA,OAAA;EAAA,IACP,kBAAA;EAIJ,cAAA,CACE,OAAA,EAAS,wBAAA,EACT,OAAA,WACC,iCAAA;EAAA,QAYK,OAAA;EAAA,QAmGA,oBAAA;EAAA,QAaA,mBAAA;AAAA"}
1
+ {"version":3,"file":"planner.d.mts","names":[],"sources":["../src/core/migrations/planner.ts"],"mappings":";;;;;;;;iBAsDgB,8BAAA,CACd,OAAA,EAAS,qBAAA,GACR,wBAAwB;;AAF3B;;;;;;KAaY,kBAAA;EAAA,SAEG,IAAA;EAAA,SACA,IAAA,EAAM,qCAAA;EAAA,SACN,QAAA,YAAoB,kBAAA;AAAA,IAE/B,uBAAA;;;;;;;;;;;;;;AAAuB;AAkB3B;;cAAa,wBAAA,YAAoC,gBAAA;EAAA;cAGnC,OAAA,GAAU,qBAAA;EAItB,IAAA,CAAK,OAAA;IAAA,SACM,QAAA;IAAA,SACA,MAAA;IAAA,SACA,MAAA,EAAQ,wBAAA;IA6BR;;;;;;;;;;;;;;IAAA,SAdA,YAAA,EAAc,QAAA;IAAA,SACd,UAAA;IAAA,SACA,mBAAA,EAAqB,aAAA,CAAc,8BAAA;IADnC;;;;;IAAA,SAOA,OAAA;EAAA,IACP,kBAAA;EAIJ,cAAA,CACE,OAAA,EAAS,wBAAA,EACT,OAAA,WACC,iCAAA;EAAA,QAYK,OAAA;EAAA,QAmGA,oBAAA;EAAA,QAaA,mBAAA;AAAA"}
package/dist/planner.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { t as createPostgresMigrationPlanner } from "./planner-CAYPJObw.mjs";
1
+ import { t as createPostgresMigrationPlanner } from "./planner-QWZaVIrn.mjs";
2
2
  export { createPostgresMigrationPlanner };
@@ -1,7 +1,7 @@
1
- import { n as postgresAuthoringEntityTypes } from "./descriptor-meta-runtime-My8_s4cs.mjs";
2
- import { r as isPostgresSchema, t as PostgresSchema } from "./postgres-schema-BuxCxbvB.mjs";
3
- import { NamespaceBase, UNBOUND_NAMESPACE_ID } from "@prisma-next/framework-components/ir";
1
+ import { n as postgresAuthoringEntityTypes } from "./descriptor-meta-runtime-B5ZtrgVF.mjs";
2
+ import { r as isPostgresSchema, t as PostgresSchema } from "./postgres-schema-BAgkIU9u.mjs";
4
3
  import { blindCast } from "@prisma-next/utils/casts";
4
+ import { NamespaceBase, UNBOUND_NAMESPACE_ID } from "@prisma-next/framework-components/ir";
5
5
  import { SqlContractSerializerBase } from "@prisma-next/family-sql/ir";
6
6
  import { isAuthoringEntityTypeDescriptor } from "@prisma-next/framework-components/authoring";
7
7
  //#region src/core/postgres-contract-serializer.ts
@@ -56,14 +56,17 @@ var PostgresContractSerializer = class extends SqlContractSerializerBase {
56
56
  typeSlot = Object.fromEntries(Object.entries(rawTypeSlot).map(([name, entry]) => [name, blindCast(enumFactory !== void 0 ? enumFactory(entry) : entry)]));
57
57
  }
58
58
  }
59
+ const valueSetSlot = entries.valueSet;
60
+ const hasValueSets = valueSetSlot !== void 0 && Object.keys(valueSetSlot).length > 0;
59
61
  const emptyTables = Object.keys(entries.table).length === 0;
60
62
  const emptyTypes = !typeSlot || Object.keys(typeSlot).length === 0;
61
- if (id === UNBOUND_NAMESPACE_ID && emptyTables && emptyTypes) return PostgresSchema.unbound;
63
+ if (id === UNBOUND_NAMESPACE_ID && emptyTables && emptyTypes && !hasValueSets) return PostgresSchema.unbound;
62
64
  return new PostgresSchema({
63
65
  id,
64
66
  entries: {
65
67
  table: entries.table,
66
- type: typeSlot ?? {}
68
+ type: typeSlot ?? {},
69
+ ...hasValueSets ? { valueSet: valueSetSlot } : {}
67
70
  }
68
71
  });
69
72
  }
@@ -95,12 +98,16 @@ var PostgresContractSerializer = class extends SqlContractSerializerBase {
95
98
  for (const [tableName, table] of Object.entries(ns.entries.table)) tablesOut[tableName] = this.serializeJsonValue(table);
96
99
  const typeOut = {};
97
100
  for (const [typeName, ty] of Object.entries(ns.entries.type)) typeOut[typeName] = this.serializeJsonValue(ty);
101
+ const valueSetEntries = ns.entries.valueSet;
102
+ const valueSetOut = {};
103
+ if (valueSetEntries !== void 0) for (const [valueSetName, valueSet] of Object.entries(valueSetEntries)) valueSetOut[valueSetName] = blindCast(this.serializeJsonValue(valueSet));
98
104
  return {
99
105
  id: ns.id,
100
106
  kind: isUnboundSlot ? "postgres-unbound-schema" : "postgres-schema",
101
107
  entries: {
102
108
  table: tablesOut,
103
- type: typeOut
109
+ type: typeOut,
110
+ ...Object.keys(valueSetOut).length > 0 ? { valueSet: valueSetOut } : {}
104
111
  }
105
112
  };
106
113
  }
@@ -111,4 +118,4 @@ var PostgresContractSerializer = class extends SqlContractSerializerBase {
111
118
  //#endregion
112
119
  export { PostgresContractSerializer as t };
113
120
 
114
- //# sourceMappingURL=postgres-contract-serializer-DYTyXjPf.mjs.map
121
+ //# sourceMappingURL=postgres-contract-serializer-BDbqgeFb.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-contract-serializer-BDbqgeFb.mjs","names":["rawRecord"],"sources":["../src/core/postgres-contract-serializer.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\nimport {\n SqlContractSerializerBase,\n type SqlEntityHydrationFactory,\n} from '@prisma-next/family-sql/ir';\nimport {\n type AuthoringEntityContext,\n type AuthoringEntityTypeFactoryOutput,\n type AuthoringEntityTypeNamespace,\n isAuthoringEntityTypeDescriptor,\n} from '@prisma-next/framework-components/authoring';\nimport {\n type Namespace,\n NamespaceBase,\n UNBOUND_NAMESPACE_ID,\n} from '@prisma-next/framework-components/ir';\nimport type { SqlNamespaceTablesInput, SqlStorage } from '@prisma-next/sql-contract/types';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport type { JsonObject } from '@prisma-next/utils/json';\nimport type { Type } from 'arktype';\nimport { postgresAuthoringEntityTypes } from './authoring';\nimport type { PostgresEnumType } from './postgres-enum-type';\nimport { isPostgresSchema, PostgresSchema } from './postgres-schema';\n\nconst POSTGRES_AUTHORING_CTX: AuthoringEntityContext = {\n family: 'sql',\n target: 'postgres',\n};\n\nfunction isAuthoringEntityTypeFactoryOutput(\n output: unknown,\n): output is AuthoringEntityTypeFactoryOutput<unknown, unknown> {\n return (\n typeof output === 'object' &&\n output !== null &&\n typeof (output as AuthoringEntityTypeFactoryOutput).factory === 'function'\n );\n}\n\n/**\n * Walks a pack's entity-type namespace tree and emits the maps the\n * family base consumes — hydrators and validator-schema fragments, both\n * keyed by the descriptor's `discriminator`.\n */\nfunction collectEntityRegistryContributions(namespace: AuthoringEntityTypeNamespace): {\n readonly entityTypeRegistry: ReadonlyMap<string, SqlEntityHydrationFactory>;\n readonly validatorFragments: ReadonlyMap<string, Type<unknown>>;\n} {\n const entityTypeRegistry = new Map<string, SqlEntityHydrationFactory>();\n const validatorFragments = new Map<string, Type<unknown>>();\n const walk = (node: AuthoringEntityTypeNamespace): void => {\n for (const value of Object.values(node)) {\n if (isAuthoringEntityTypeDescriptor(value)) {\n if (isAuthoringEntityTypeFactoryOutput(value.output)) {\n const { factory } = value.output;\n entityTypeRegistry.set(value.discriminator, (raw) =>\n factory(raw, POSTGRES_AUTHORING_CTX),\n );\n }\n if (value.validatorSchema !== undefined) {\n validatorFragments.set(value.discriminator, value.validatorSchema);\n }\n continue;\n }\n if (typeof value === 'object' && value !== null) {\n walk(value);\n }\n }\n };\n walk(namespace);\n return { entityTypeRegistry, validatorFragments };\n}\n\nexport class PostgresContractSerializer extends SqlContractSerializerBase<Contract<SqlStorage>> {\n constructor() {\n const { entityTypeRegistry, validatorFragments } = collectEntityRegistryContributions(\n postgresAuthoringEntityTypes,\n );\n super(entityTypeRegistry, validatorFragments);\n }\n\n protected override hydrateSqlNamespaceEntry(\n nsId: string,\n raw: Namespace | Record<string, unknown>,\n ): Namespace | SqlNamespaceTablesInput {\n if (raw instanceof NamespaceBase) {\n return raw;\n }\n const hydrated = blindCast<\n SqlNamespaceTablesInput,\n 'super.hydrateSqlNamespaceEntry returns the tables form when raw is not a NamespaceBase'\n >(super.hydrateSqlNamespaceEntry(nsId, raw));\n const { id, entries } = hydrated;\n\n // Extract the postgres-specific `type` slot directly from raw input.\n // The family base handles the `table` slot; the postgres target owns `type`.\n const rawRecord = raw as Record<string, unknown>;\n const rawEntries = rawRecord['entries'];\n let typeSlot: Record<string, PostgresEnumType> | undefined;\n if (rawEntries !== null && typeof rawEntries === 'object' && !Array.isArray(rawEntries)) {\n const rawTypeSlot = (rawEntries as Record<string, unknown>)['type'];\n if (rawTypeSlot !== null && typeof rawTypeSlot === 'object' && !Array.isArray(rawTypeSlot)) {\n const enumFactory = this.entityTypeRegistry.get('postgres-enum');\n typeSlot = Object.fromEntries(\n Object.entries(rawTypeSlot as Record<string, unknown>).map(([name, entry]) => [\n name,\n blindCast<PostgresEnumType, 'postgres-enum factory returns PostgresEnumType'>(\n enumFactory !== undefined ? enumFactory(entry) : entry,\n ),\n ]),\n );\n }\n }\n\n const valueSetSlot = entries.valueSet;\n const hasValueSets = valueSetSlot !== undefined && Object.keys(valueSetSlot).length > 0;\n const emptyTables = Object.keys(entries.table).length === 0;\n const emptyTypes = !typeSlot || Object.keys(typeSlot).length === 0;\n if (id === UNBOUND_NAMESPACE_ID && emptyTables && emptyTypes && !hasValueSets) {\n return PostgresSchema.unbound;\n }\n return new PostgresSchema({\n id,\n entries: {\n table: entries.table,\n type: typeSlot ?? {},\n ...(hasValueSets ? { valueSet: valueSetSlot } : {}),\n },\n });\n }\n\n override serializeContract(contract: Contract<SqlStorage>): JsonObject {\n const { storage, ...rest } = contract;\n const namespacesJson: Record<string, JsonObject> = {};\n for (const [nsId, ns] of Object.entries(storage.namespaces)) {\n if (isPostgresSchema(ns)) {\n namespacesJson[nsId] = this.serializePostgresNamespace(ns, ns.id === UNBOUND_NAMESPACE_ID);\n } else {\n const isUnboundSlot = nsId === UNBOUND_NAMESPACE_ID;\n namespacesJson[nsId] = {\n id: nsId,\n kind: isUnboundSlot ? 'postgres-unbound-schema' : 'postgres-schema',\n entries: {\n table: Object.fromEntries(\n Object.entries(ns.entries.table).map(([tableName, table]) => [\n tableName,\n this.serializeJsonValue(table) as JsonObject,\n ]),\n ),\n },\n };\n }\n }\n const storageOut: Record<string, unknown> = {\n storageHash: String(storage.storageHash),\n namespaces: namespacesJson,\n };\n if (storage.types !== undefined) {\n const typesOut: Record<string, JsonObject> = {};\n for (const [name, entry] of Object.entries(storage.types)) {\n typesOut[name] = this.serializeJsonValue(entry) as JsonObject;\n }\n storageOut['types'] = typesOut;\n }\n return {\n ...rest,\n storage: storageOut,\n } as unknown as JsonObject;\n }\n\n private serializePostgresNamespace(ns: PostgresSchema, isUnboundSlot: boolean): JsonObject {\n const tablesOut: Record<string, JsonObject> = {};\n for (const [tableName, table] of Object.entries(ns.entries.table)) {\n tablesOut[tableName] = this.serializeJsonValue(table) as JsonObject;\n }\n const typeOut: Record<string, JsonObject> = {};\n for (const [typeName, ty] of Object.entries(ns.entries.type)) {\n typeOut[typeName] = this.serializeJsonValue(ty) as JsonObject;\n }\n const valueSetEntries = ns.entries.valueSet;\n const valueSetOut: Record<string, JsonObject> = {};\n if (valueSetEntries !== undefined) {\n for (const [valueSetName, valueSet] of Object.entries(valueSetEntries)) {\n valueSetOut[valueSetName] = blindCast<\n JsonObject,\n 'serializeJsonValue round-trips the value-set node through JSON, yielding a JsonObject'\n >(this.serializeJsonValue(valueSet));\n }\n }\n return {\n id: ns.id,\n kind: isUnboundSlot ? 'postgres-unbound-schema' : 'postgres-schema',\n entries: {\n table: tablesOut,\n type: typeOut,\n ...(Object.keys(valueSetOut).length > 0 ? { valueSet: valueSetOut } : {}),\n },\n };\n }\n\n private serializeJsonValue(value: unknown): unknown {\n return JSON.parse(JSON.stringify(value)) as unknown;\n }\n}\n"],"mappings":";;;;;;;AAwBA,MAAM,yBAAiD;CACrD,QAAQ;CACR,QAAQ;AACV;AAEA,SAAS,mCACP,QAC8D;CAC9D,OACE,OAAO,WAAW,YAClB,WAAW,QACX,OAAQ,OAA4C,YAAY;AAEpE;;;;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2BAAmC,IAAoB,eAAoC;EACzF,MAAM,YAAwC,CAAC;EAC/C,KAAK,MAAM,CAAC,WAAW,UAAU,OAAO,QAAQ,GAAG,QAAQ,KAAK,GAC9D,UAAU,aAAa,KAAK,mBAAmB,KAAK;EAEtD,MAAM,UAAsC,CAAC;EAC7C,KAAK,MAAM,CAAC,UAAU,OAAO,OAAO,QAAQ,GAAG,QAAQ,IAAI,GACzD,QAAQ,YAAY,KAAK,mBAAmB,EAAE;EAEhD,MAAM,kBAAkB,GAAG,QAAQ;EACnC,MAAM,cAA0C,CAAC;EACjD,IAAI,oBAAoB,KAAA,GACtB,KAAK,MAAM,CAAC,cAAc,aAAa,OAAO,QAAQ,eAAe,GACnE,YAAY,gBAAgB,UAG1B,KAAK,mBAAmB,QAAQ,CAAC;EAGvC,OAAO;GACL,IAAI,GAAG;GACP,MAAM,gBAAgB,4BAA4B;GAClD,SAAS;IACP,OAAO;IACP,MAAM;IACN,GAAI,OAAO,KAAK,WAAW,CAAC,CAAC,SAAS,IAAI,EAAE,UAAU,YAAY,IAAI,CAAC;GACzE;EACF;CACF;CAEA,mBAA2B,OAAyB;EAClD,OAAO,KAAK,MAAM,KAAK,UAAU,KAAK,CAAC;CACzC;AACF"}
@@ -1,6 +1,6 @@
1
- import { d as CreateSchemaCall, f as CreateTableCall } from "./op-factory-call-D2aAUhmS.mjs";
1
+ import { d as CreateSchemaCall, f as CreateTableCall } from "./op-factory-call-BZ3xDgCY.mjs";
2
2
  import { t as errorPostgresMigrationStackMissing } from "./errors-CUk87ByX.mjs";
3
- import { t as dataTransform } from "./data-transform-D25tLeYU.mjs";
3
+ import { t as dataTransform } from "./data-transform-BOWpliq8.mjs";
4
4
  import { UNBOUND_NAMESPACE_ID } from "@prisma-next/framework-components/ir";
5
5
  import { Migration } from "@prisma-next/family-sql/migration";
6
6
  //#region src/core/migrations/postgres-migration.ts
@@ -68,4 +68,4 @@ var PostgresMigration = class extends Migration {
68
68
  //#endregion
69
69
  export { PostgresMigration as t };
70
70
 
71
- //# sourceMappingURL=postgres-migration-COore9Mz.mjs.map
71
+ //# sourceMappingURL=postgres-migration-BN6TNJNf.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"postgres-migration-COore9Mz.mjs","names":["SqlMigration"],"sources":["../src/core/migrations/postgres-migration.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\nimport type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type { SqlControlAdapter } from '@prisma-next/family-sql/control-adapter';\nimport { Migration as SqlMigration } from '@prisma-next/family-sql/migration';\nimport type { ControlStack } from '@prisma-next/framework-components/control';\nimport { UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport type { DdlColumn, DdlTableConstraint } from '@prisma-next/sql-relational-core/ast';\nimport { errorPostgresMigrationStackMissing } from '../errors';\nimport { CreateSchemaCall, CreateTableCall } from './op-factory-call';\nimport { type DataTransformOptions, dataTransform } from './operations/data-transform';\nimport type { PostgresPlanTargetDetails } from './planner-target-details';\n\n/**\n * Target-owned base class for Postgres migrations.\n *\n * Fixes the `SqlMigration` generic to `PostgresPlanTargetDetails` and the\n * abstract `targetId` to the Postgres target-id string literal, so both\n * user-authored migrations and renderer-generated scaffolds (the output of\n * `renderCallsToTypeScript`) can extend `PostgresMigration` directly without\n * redeclaring target-local identity.\n *\n * Mirrors `MongoMigration` in `@prisma-next/family-mongo`: the renderer\n * emits `extends Migration` against a facade re-export of this class\n * from `@prisma-next/postgres/migration`, keeping the authoring surface\n * target-scoped rather than family-scoped.\n *\n * The constructor materializes a single Postgres `SqlControlAdapter` from\n * `stack.adapter.create(stack)` and stores it; the protected `dataTransform`\n * instance method forwards to the free `dataTransform` factory with that\n * stored adapter, so user migrations can write `this.dataTransform(...)`\n * without threading the adapter through every call.\n */\nexport abstract class PostgresMigration extends SqlMigration<\n PostgresPlanTargetDetails,\n 'postgres'\n> {\n readonly targetId = 'postgres' as const;\n\n /**\n * Materialized Postgres control adapter, created once per migration\n * instance from the injected stack. `undefined` only when the migration\n * was instantiated without a stack (test fixtures); `dataTransform`\n * throws in that case to surface the misuse.\n */\n protected readonly controlAdapter: SqlControlAdapter<'postgres'> | undefined;\n\n constructor(stack?: ControlStack<'sql', 'postgres'>) {\n super(stack);\n // The descriptor `create()` is typed as the wider `ControlAdapterInstance`;\n // the Postgres descriptor concretely returns a `SqlControlAdapter<'postgres'>`,\n // so the cast holds for any Postgres-target stack assembled at runtime.\n this.controlAdapter = stack?.adapter\n ? (stack.adapter.create(stack) as SqlControlAdapter<'postgres'>)\n : undefined;\n }\n\n /**\n * Instance-method wrapper around the free `dataTransform` factory that\n * supplies the stored control adapter. Authors call this from inside\n * `get operations()`; the adapter argument is hidden from the call site.\n */\n protected dataTransform<TContract extends Contract<SqlStorage>>(\n contract: TContract,\n name: string,\n options: DataTransformOptions,\n ): SqlMigrationPlanOperation<PostgresPlanTargetDetails> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return dataTransform(contract, name, options, this.controlAdapter);\n }\n\n /**\n * Emit a `CREATE TABLE` migration operation. Builds a typed DDL node from\n * the supplied options and lowers it through the stored control adapter.\n * Throws if no adapter is present (i.e. migration instantiated without a stack).\n */\n protected createTable(options: {\n readonly schema?: string;\n readonly table: string;\n readonly ifNotExists?: boolean;\n readonly columns: readonly DdlColumn[];\n readonly constraints?: readonly DdlTableConstraint[];\n }): SqlMigrationPlanOperation<PostgresPlanTargetDetails> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new CreateTableCall(\n options.schema ?? UNBOUND_NAMESPACE_ID,\n options.table,\n options.columns,\n options.constraints,\n ).toOp(this.controlAdapter);\n }\n\n /**\n * Emit a `CREATE SCHEMA` migration operation. Builds a typed DDL node from\n * the supplied options and lowers it through the stored control adapter.\n * Throws if no adapter is present (i.e. migration instantiated without a stack).\n */\n protected createSchema(options: {\n readonly schema: string;\n readonly ifNotExists?: boolean;\n }): SqlMigrationPlanOperation<PostgresPlanTargetDetails> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new CreateSchemaCall(options.schema).toOp(this.controlAdapter);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,IAAsB,oBAAtB,cAAgDA,UAG9C;CACA,WAAoB;;;;;;;CAQpB;CAEA,YAAY,OAAyC;EACnD,MAAM,KAAK;EAIX,KAAK,iBAAiB,OAAO,UACxB,MAAM,QAAQ,OAAO,KAAK,IAC3B,KAAA;CACN;;;;;;CAOA,cACE,UACA,MACA,SACsD;EACtD,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,cAAc,UAAU,MAAM,SAAS,KAAK,cAAc;CACnE;;;;;;CAOA,YAAsB,SAMmC;EACvD,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,IAAI,gBACT,QAAQ,UAAU,sBAClB,QAAQ,OACR,QAAQ,SACR,QAAQ,WACV,CAAC,CAAC,KAAK,KAAK,cAAc;CAC5B;;;;;;CAOA,aAAuB,SAGkC;EACvD,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,IAAI,iBAAiB,QAAQ,MAAM,CAAC,CAAC,KAAK,KAAK,cAAc;CACtE;AACF"}
1
+ {"version":3,"file":"postgres-migration-BN6TNJNf.mjs","names":["SqlMigration"],"sources":["../src/core/migrations/postgres-migration.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\nimport type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type { SqlControlAdapter } from '@prisma-next/family-sql/control-adapter';\nimport { Migration as SqlMigration } from '@prisma-next/family-sql/migration';\nimport type { ControlStack } from '@prisma-next/framework-components/control';\nimport { UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport type { DdlColumn, DdlTableConstraint } from '@prisma-next/sql-relational-core/ast';\nimport { errorPostgresMigrationStackMissing } from '../errors';\nimport { CreateSchemaCall, CreateTableCall } from './op-factory-call';\nimport { type DataTransformOptions, dataTransform } from './operations/data-transform';\nimport type { PostgresPlanTargetDetails } from './planner-target-details';\n\n/**\n * Target-owned base class for Postgres migrations.\n *\n * Fixes the `SqlMigration` generic to `PostgresPlanTargetDetails` and the\n * abstract `targetId` to the Postgres target-id string literal, so both\n * user-authored migrations and renderer-generated scaffolds (the output of\n * `renderCallsToTypeScript`) can extend `PostgresMigration` directly without\n * redeclaring target-local identity.\n *\n * Mirrors `MongoMigration` in `@prisma-next/family-mongo`: the renderer\n * emits `extends Migration` against a facade re-export of this class\n * from `@prisma-next/postgres/migration`, keeping the authoring surface\n * target-scoped rather than family-scoped.\n *\n * The constructor materializes a single Postgres `SqlControlAdapter` from\n * `stack.adapter.create(stack)` and stores it; the protected `dataTransform`\n * instance method forwards to the free `dataTransform` factory with that\n * stored adapter, so user migrations can write `this.dataTransform(...)`\n * without threading the adapter through every call.\n */\nexport abstract class PostgresMigration extends SqlMigration<\n PostgresPlanTargetDetails,\n 'postgres'\n> {\n readonly targetId = 'postgres' as const;\n\n /**\n * Materialized Postgres control adapter, created once per migration\n * instance from the injected stack. `undefined` only when the migration\n * was instantiated without a stack (test fixtures); `dataTransform`\n * throws in that case to surface the misuse.\n */\n protected readonly controlAdapter: SqlControlAdapter<'postgres'> | undefined;\n\n constructor(stack?: ControlStack<'sql', 'postgres'>) {\n super(stack);\n // The descriptor `create()` is typed as the wider `ControlAdapterInstance`;\n // the Postgres descriptor concretely returns a `SqlControlAdapter<'postgres'>`,\n // so the cast holds for any Postgres-target stack assembled at runtime.\n this.controlAdapter = stack?.adapter\n ? (stack.adapter.create(stack) as SqlControlAdapter<'postgres'>)\n : undefined;\n }\n\n /**\n * Instance-method wrapper around the free `dataTransform` factory that\n * supplies the stored control adapter. Authors call this from inside\n * `get operations()`; the adapter argument is hidden from the call site.\n */\n protected dataTransform<TContract extends Contract<SqlStorage>>(\n contract: TContract,\n name: string,\n options: DataTransformOptions,\n ): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return dataTransform(contract, name, options, this.controlAdapter);\n }\n\n /**\n * Emit a `CREATE TABLE` migration operation. Builds a typed DDL node from\n * the supplied options and lowers it through the stored control adapter.\n * Throws if no adapter is present (i.e. migration instantiated without a stack).\n */\n protected createTable(options: {\n readonly schema?: string;\n readonly table: string;\n readonly ifNotExists?: boolean;\n readonly columns: readonly DdlColumn[];\n readonly constraints?: readonly DdlTableConstraint[];\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new CreateTableCall(\n options.schema ?? UNBOUND_NAMESPACE_ID,\n options.table,\n options.columns,\n options.constraints,\n ).toOp(this.controlAdapter);\n }\n\n /**\n * Emit a `CREATE SCHEMA` migration operation. Builds a typed DDL node from\n * the supplied options and lowers it through the stored control adapter.\n * Throws if no adapter is present (i.e. migration instantiated without a stack).\n */\n protected createSchema(options: {\n readonly schema: string;\n readonly ifNotExists?: boolean;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new CreateSchemaCall(options.schema).toOp(this.controlAdapter);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,IAAsB,oBAAtB,cAAgDA,UAG9C;CACA,WAAoB;;;;;;;CAQpB;CAEA,YAAY,OAAyC;EACnD,MAAM,KAAK;EAIX,KAAK,iBAAiB,OAAO,UACxB,MAAM,QAAQ,OAAO,KAAK,IAC3B,KAAA;CACN;;;;;;CAOA,cACE,UACA,MACA,SAC+D;EAC/D,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,cAAc,UAAU,MAAM,SAAS,KAAK,cAAc;CACnE;;;;;;CAOA,YAAsB,SAM4C;EAChE,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,IAAI,gBACT,QAAQ,UAAU,sBAClB,QAAQ,OACR,QAAQ,SACR,QAAQ,WACV,CAAC,CAAC,KAAK,KAAK,cAAc;CAC5B;;;;;;CAOA,aAAuB,SAG2C;EAChE,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,IAAI,iBAAiB,QAAQ,MAAM,CAAC,CAAC,KAAK,KAAK,cAAc;CACtE;AACF"}
@@ -1,5 +1,5 @@
1
1
  import { t as PostgresPlanTargetDetails } from "./planner-target-details-CIY6tLeo.mjs";
2
- import { n as DataTransformOptions } from "./data-transform-DGOqcLrf.mjs";
2
+ import { n as DataTransformOptions } from "./data-transform-DDgWdB5o.mjs";
3
3
  import { DdlColumn, DdlTableConstraint } from "@prisma-next/sql-relational-core/ast";
4
4
  import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
5
5
  import { SqlStorage } from "@prisma-next/sql-contract/types";
@@ -44,7 +44,7 @@ declare abstract class PostgresMigration extends Migration<PostgresPlanTargetDet
44
44
  * supplies the stored control adapter. Authors call this from inside
45
45
  * `get operations()`; the adapter argument is hidden from the call site.
46
46
  */
47
- protected dataTransform<TContract extends Contract<SqlStorage>>(contract: TContract, name: string, options: DataTransformOptions): SqlMigrationPlanOperation<PostgresPlanTargetDetails>;
47
+ protected dataTransform<TContract extends Contract<SqlStorage>>(contract: TContract, name: string, options: DataTransformOptions): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>;
48
48
  /**
49
49
  * Emit a `CREATE TABLE` migration operation. Builds a typed DDL node from
50
50
  * the supplied options and lowers it through the stored control adapter.
@@ -56,7 +56,7 @@ declare abstract class PostgresMigration extends Migration<PostgresPlanTargetDet
56
56
  readonly ifNotExists?: boolean;
57
57
  readonly columns: readonly DdlColumn[];
58
58
  readonly constraints?: readonly DdlTableConstraint[];
59
- }): SqlMigrationPlanOperation<PostgresPlanTargetDetails>;
59
+ }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>;
60
60
  /**
61
61
  * Emit a `CREATE SCHEMA` migration operation. Builds a typed DDL node from
62
62
  * the supplied options and lowers it through the stored control adapter.
@@ -65,8 +65,8 @@ declare abstract class PostgresMigration extends Migration<PostgresPlanTargetDet
65
65
  protected createSchema(options: {
66
66
  readonly schema: string;
67
67
  readonly ifNotExists?: boolean;
68
- }): SqlMigrationPlanOperation<PostgresPlanTargetDetails>;
68
+ }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>;
69
69
  }
70
70
  //#endregion
71
71
  export { PostgresMigration as t };
72
- //# sourceMappingURL=postgres-migration-DZ_gLUOW.d.mts.map
72
+ //# sourceMappingURL=postgres-migration-h_DA3LRq.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-migration-h_DA3LRq.d.mts","names":[],"sources":["../src/core/migrations/postgres-migration.ts"],"mappings":";;;;;;;;;;;;;AAiCA;;;;;;;;;;;;;;;;;;uBAAsB,iBAAA,SAA0B,SAAA,CAC9C,yBAAA;EAAA,SAGS,QAAA;EAmEL;;;;;;EAAA,mBA3De,cAAA,EAAgB,iBAAA;cAEvB,KAAA,GAAQ,YAAA;EAFe;;;;;EAAA,UAiBzB,aAAA,mBAAgC,QAAA,CAAS,UAAA,GACjD,QAAA,EAAU,SAAA,EACV,IAAA,UACA,OAAA,EAAS,oBAAA,GACR,OAAA,CAAQ,yBAAA,CAA0B,yBAAA;EAJK;;;;;EAAA,UAgBhC,WAAA,CAAY,OAAA;IAAA,SACX,MAAA;IAAA,SACA,KAAA;IAAA,SACA,WAAA;IAAA,SACA,OAAA,WAAkB,SAAA;IAAA,SAClB,WAAA,YAAuB,kBAAA;EAAA,IAC9B,OAAA,CAAQ,yBAAA,CAA0B,yBAAA;EAJ3B;;;;;EAAA,UAqBD,YAAA,CAAa,OAAA;IAAA,SACZ,MAAA;IAAA,SACA,WAAA;EAAA,IACP,OAAA,CAAQ,yBAAA,CAA0B,yBAAA;AAAA"}
@@ -1,7 +1,7 @@
1
1
  import { t as PostgresEnumType } from "./postgres-enum-type-DPKqCBem.mjs";
2
2
  import { n as escapeLiteral } from "./sql-utils-DcfMz4MQ.mjs";
3
3
  import { NamespaceBase, UNBOUND_NAMESPACE_ID, freezeNode } from "@prisma-next/framework-components/ir";
4
- import { StorageTable } from "@prisma-next/sql-contract/types";
4
+ import { StorageTable, StorageValueSet } from "@prisma-next/sql-contract/types";
5
5
  //#region src/core/postgres-schema.ts
6
6
  /**
7
7
  * Postgres target `Namespace` concretion — a Postgres schema (`CREATE
@@ -31,9 +31,19 @@ var PostgresSchema = class extends NamespaceBase {
31
31
  constructor(input) {
32
32
  super();
33
33
  this.id = input.id;
34
- this.entries = Object.freeze({
35
- table: Object.freeze(Object.fromEntries(Object.entries(input.entries.table).map(([k, v]) => [k, v instanceof StorageTable ? v : new StorageTable(v)]))),
36
- type: Object.freeze(Object.fromEntries(Object.entries(input.entries.type).map(([k, v]) => [k, v instanceof PostgresEnumType ? v : new PostgresEnumType(v)])))
34
+ const table = Object.freeze(Object.fromEntries(Object.entries(input.entries.table).map(([k, v]) => [k, v instanceof StorageTable ? v : new StorageTable(v)])));
35
+ const type = Object.freeze(Object.fromEntries(Object.entries(input.entries.type).map(([k, v]) => [k, v instanceof PostgresEnumType ? v : new PostgresEnumType(v)])));
36
+ const valueSetInput = input.entries.valueSet;
37
+ this.entries = valueSetInput !== void 0 && Object.keys(valueSetInput).length > 0 ? Object.freeze({
38
+ table,
39
+ type,
40
+ valueSet: Object.freeze(Object.fromEntries(Object.entries(valueSetInput).map(([k, v]) => [k, new StorageValueSet({
41
+ kind: "valueSet",
42
+ values: v.values
43
+ })])))
44
+ }) : Object.freeze({
45
+ table,
46
+ type
37
47
  });
38
48
  Object.defineProperty(this, "kind", {
39
49
  value: "schema",
@@ -164,7 +174,8 @@ function postgresCreateNamespace(input, enumTypes) {
164
174
  id: input.id,
165
175
  entries: {
166
176
  table: input.entries.table,
167
- type: enumTypes ?? {}
177
+ type: enumTypes ?? {},
178
+ ...input.entries.valueSet !== void 0 ? { valueSet: input.entries.valueSet } : {}
168
179
  }
169
180
  };
170
181
  if (input.id === UNBOUND_NAMESPACE_ID) return new PostgresUnboundSchema(schemaInput);
@@ -173,4 +184,4 @@ function postgresCreateNamespace(input, enumTypes) {
173
184
  //#endregion
174
185
  export { postgresCreateNamespace as i, PostgresUnboundSchema as n, isPostgresSchema as r, PostgresSchema as t };
175
186
 
176
- //# sourceMappingURL=postgres-schema-BuxCxbvB.mjs.map
187
+ //# sourceMappingURL=postgres-schema-BAgkIU9u.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-schema-BAgkIU9u.mjs","names":[],"sources":["../src/core/postgres-schema.ts"],"sourcesContent":["import {\n freezeNode,\n NamespaceBase,\n UNBOUND_NAMESPACE_ID,\n} from '@prisma-next/framework-components/ir';\nimport {\n type PostgresEnumStorageEntry,\n type SqlNamespaceTablesInput,\n type SqlStorage,\n StorageTable,\n type StorageTableInput,\n StorageValueSet,\n type StorageValueSetInput,\n} from '@prisma-next/sql-contract/types';\nimport { PostgresEnumType, type PostgresEnumTypeInput } from './postgres-enum-type';\nimport { escapeLiteral } from './sql-utils';\n\nexport interface PostgresSchemaInput {\n readonly id: string;\n readonly entries: {\n readonly table: Record<string, StorageTable | StorageTableInput>;\n readonly type: Record<string, PostgresEnumType | PostgresEnumTypeInput>;\n readonly valueSet?: Record<string, StorageValueSet | StorageValueSetInput>;\n };\n}\n\n/**\n * Postgres target `Namespace` concretion — a Postgres schema (`CREATE\n * SCHEMA …`). Each Postgres `SqlStorage` carries a\n * `namespaces: Record<NamespaceId, PostgresSchema>` map populated by\n * the Postgres PSL interpreter from `namespace { … }` AST buckets.\n *\n * `entries` holds entity-kind slot maps (`table`, `type`). Qualifier\n * emission is the rendering seam: DDL / SQL emission asks the namespace\n * for its qualifier (`\"<schema>\"`) or for a qualified table name\n * (`\"<schema>\".\"<table>\"`) and consumes the result polymorphically.\n * The unbound singleton below overrides these methods to elide the\n * prefix entirely — call sites stay polymorphic and never branch on\n * `id === UNBOUND_NAMESPACE_ID`.\n */\nexport class PostgresSchema extends NamespaceBase {\n /**\n * Stable singleton reference for the late-bound slot. Materialised\n * lazily below the singleton subclass declaration so the static\n * initialiser sees the subclass before assigning. Consumers always\n * reach for `PostgresSchema.unbound` (or `PostgresUnboundSchema.instance`\n * — same identity).\n */\n static unbound: PostgresUnboundSchema;\n\n declare readonly kind: 'schema';\n readonly id: string;\n readonly entries: Readonly<{\n readonly table: Readonly<Record<string, StorageTable>>;\n readonly type: Readonly<Record<string, PostgresEnumType>>;\n readonly valueSet?: Readonly<Record<string, StorageValueSet>>;\n }>;\n\n constructor(input: PostgresSchemaInput) {\n super();\n this.id = input.id;\n const table = Object.freeze(\n Object.fromEntries(\n Object.entries(input.entries.table).map(([k, v]) => [\n k,\n v instanceof StorageTable ? v : new StorageTable(v as StorageTableInput),\n ]),\n ),\n );\n const type = Object.freeze(\n Object.fromEntries(\n Object.entries(input.entries.type).map(([k, v]) => [\n k,\n v instanceof PostgresEnumType ? v : new PostgresEnumType(v as PostgresEnumTypeInput),\n ]),\n ),\n );\n const valueSetInput = input.entries.valueSet;\n this.entries =\n valueSetInput !== undefined && Object.keys(valueSetInput).length > 0\n ? Object.freeze({\n table,\n type,\n valueSet: Object.freeze(\n Object.fromEntries(\n Object.entries(valueSetInput).map(([k, v]) => [\n k,\n new StorageValueSet({ kind: 'valueSet', values: v.values }),\n ]),\n ),\n ),\n })\n : Object.freeze({ table, type });\n Object.defineProperty(this, 'kind', {\n value: 'schema',\n writable: false,\n enumerable: false,\n configurable: true,\n });\n freezeNode(this);\n }\n\n /**\n * The bare schema qualifier as it would appear in a rendered SQL\n * fragment (already quoted). The unbound-schema singleton overrides\n * this to return `''`.\n */\n qualifier(): string {\n return `\"${this.id}\"`;\n }\n\n /**\n * Qualify a table name with the schema prefix\n * (`\"<schema>\".\"<table>\"`). The unbound-schema singleton overrides\n * this to emit just `\"<table>\"` so the resolved DDL is unqualified\n * and `search_path` decides where the object lands at runtime.\n */\n qualifyTable(tableName: string): string {\n return `\"${this.id}\".\"${tableName}\"`;\n }\n\n /**\n * Render a SQL string-literal containing the qualified-name form\n * suitable for `to_regclass(...)` arguments (e.g. `'\"public\".\"user\"'`).\n * The unbound singleton overrides this to elide the schema prefix\n * (`'\"user\"'`) so `search_path` resolves the object at runtime.\n */\n regclassLiteral(name: string): string {\n return `'${escapeLiteral(this.qualifyTable(name))}'`;\n }\n\n /**\n * Render a SQL expression that evaluates to this namespace's schema\n * name at runtime, ready to drop into a `WHERE table_schema = …` /\n * `WHERE n.nspname = …` clause. Named schemas emit a quoted SQL\n * literal (`'public'`); the unbound singleton overrides this to emit\n * `current_schema()` so catalog queries match whichever schema the\n * connection's `search_path` resolved at runtime.\n */\n schemaSqlExpression(): string {\n return `'${escapeLiteral(this.id)}'`;\n }\n\n /**\n * The bare schema name a DDL planner should target when emitting\n * statements that need to identify this namespace in the live\n * database (e.g. `CREATE TABLE \"<ddlSchemaName>\".\"<table>\" …`,\n * catalog filters, planner conflict lookups). Named schemas resolve\n * to their own id. The `PostgresUnboundSchema` singleton inherits\n * this and returns `UNBOUND_NAMESPACE_ID` — callers that dispatch\n * through `qualifyTableName` / `toRegclassLiteral` route through the\n * polymorphic `PostgresUnboundSchema` overrides and produce\n * unqualified (search-path-resolved) output automatically.\n */\n ddlSchemaName(_storage: SqlStorage): string {\n return this.id;\n }\n}\n\n/**\n * Singleton subclass for the reserved sentinel namespace id\n * (`UNBOUND_NAMESPACE_ID`) — the late-bound Postgres slot whose binding\n * the connection's `search_path` resolves at runtime. Overrides\n * qualifier emission to elide the schema prefix; call sites that consume\n * `qualifier()` / `qualifyTable()` get unqualified output without\n * branching on the namespace id.\n *\n * This is the target-side materialization of \"the framework provides\n * affordances; targets implement specifics\": the framework names the\n * sentinel; Postgres decides what late-bound means here (the table\n * name, naked — the schema is supplied by the live connection's\n * `search_path`).\n *\n * `ddlSchemaName` is inherited from `PostgresSchema` and returns\n * `UNBOUND_NAMESPACE_ID`. Downstream helpers (`qualifyTableName`,\n * `toRegclassLiteral`) route through the polymorphic factory and\n * produce unqualified output automatically.\n */\nexport class PostgresUnboundSchema extends PostgresSchema {\n static readonly instance: PostgresUnboundSchema = new PostgresUnboundSchema();\n\n constructor(input?: PostgresSchemaInput) {\n super(input ?? { id: UNBOUND_NAMESPACE_ID, entries: { table: {}, type: {} } });\n }\n\n override qualifier(): string {\n return '';\n }\n\n override qualifyTable(tableName: string): string {\n return `\"${tableName}\"`;\n }\n\n override schemaSqlExpression(): string {\n return 'current_schema()';\n }\n}\n\nPostgresSchema.unbound = PostgresUnboundSchema.instance;\n\n/**\n * Narrow an arbitrary namespace (or `undefined`) to `PostgresSchema`\n * so callers can dispatch to the polymorphic emission methods without\n * branching at the call site. Uses the structural `kind` discriminator\n * (`'schema'`) rather than `instanceof` so the check survives realm /\n * bundle / hot-reload boundaries — matching the rest of the IR's\n * narrowing convention. `PostgresUnboundSchema` passes through because\n * it inherits the same `kind: 'schema'` from `PostgresSchema`.\n */\nexport function isPostgresSchema(ns: unknown): ns is PostgresSchema {\n return (ns as { kind?: unknown } | null | undefined)?.kind === 'schema';\n}\n\n/**\n * Target-supplied `Namespace` factory the Postgres target plumbs\n * through `defineContract({ createNamespace })` and the SQL PSL\n * interpreter. Returns the unbound singleton for the framework\n * sentinel and a fresh `PostgresSchema` for any other coordinate.\n *\n * The factory has no per-call state — every named id deterministically\n * maps to a distinct schema instance — so callers can pass it through\n * by reference and trust the resulting `SqlStorage.namespaces` map to\n * be value-stable for a given input set.\n */\nexport function postgresCreateNamespace(\n input: SqlNamespaceTablesInput,\n enumTypes?: Readonly<Record<string, PostgresEnumStorageEntry>>,\n): PostgresSchema {\n const schemaInput: PostgresSchemaInput = {\n id: input.id,\n entries: {\n table: input.entries.table,\n type: (enumTypes ?? {}) as Record<string, PostgresEnumTypeInput>,\n ...(input.entries.valueSet !== undefined ? { valueSet: input.entries.valueSet } : {}),\n },\n };\n if (input.id === UNBOUND_NAMESPACE_ID) {\n return new PostgresUnboundSchema(schemaInput);\n }\n return new PostgresSchema(schemaInput);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAwCA,IAAa,iBAAb,cAAoC,cAAc;;;;;;;;CAQhD,OAAO;CAGP;CACA;CAMA,YAAY,OAA4B;EACtC,MAAM;EACN,KAAK,KAAK,MAAM;EAChB,MAAM,QAAQ,OAAO,OACnB,OAAO,YACL,OAAO,QAAQ,MAAM,QAAQ,KAAK,CAAC,CAAC,KAAK,CAAC,GAAG,OAAO,CAClD,GACA,aAAa,eAAe,IAAI,IAAI,aAAa,CAAsB,CACzE,CAAC,CACH,CACF;EACA,MAAM,OAAO,OAAO,OAClB,OAAO,YACL,OAAO,QAAQ,MAAM,QAAQ,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,OAAO,CACjD,GACA,aAAa,mBAAmB,IAAI,IAAI,iBAAiB,CAA0B,CACrF,CAAC,CACH,CACF;EACA,MAAM,gBAAgB,MAAM,QAAQ;EACpC,KAAK,UACH,kBAAkB,KAAA,KAAa,OAAO,KAAK,aAAa,CAAC,CAAC,SAAS,IAC/D,OAAO,OAAO;GACZ;GACA;GACA,UAAU,OAAO,OACf,OAAO,YACL,OAAO,QAAQ,aAAa,CAAC,CAAC,KAAK,CAAC,GAAG,OAAO,CAC5C,GACA,IAAI,gBAAgB;IAAE,MAAM;IAAY,QAAQ,EAAE;GAAO,CAAC,CAC5D,CAAC,CACH,CACF;EACF,CAAC,IACD,OAAO,OAAO;GAAE;GAAO;EAAK,CAAC;EACnC,OAAO,eAAe,MAAM,QAAQ;GAClC,OAAO;GACP,UAAU;GACV,YAAY;GACZ,cAAc;EAChB,CAAC;EACD,WAAW,IAAI;CACjB;;;;;;CAOA,YAAoB;EAClB,OAAO,IAAI,KAAK,GAAG;CACrB;;;;;;;CAQA,aAAa,WAA2B;EACtC,OAAO,IAAI,KAAK,GAAG,KAAK,UAAU;CACpC;;;;;;;CAQA,gBAAgB,MAAsB;EACpC,OAAO,IAAI,cAAc,KAAK,aAAa,IAAI,CAAC,EAAE;CACpD;;;;;;;;;CAUA,sBAA8B;EAC5B,OAAO,IAAI,cAAc,KAAK,EAAE,EAAE;CACpC;;;;;;;;;;;;CAaA,cAAc,UAA8B;EAC1C,OAAO,KAAK;CACd;AACF;;;;;;;;;;;;;;;;;;;;AAqBA,IAAa,wBAAb,MAAa,8BAA8B,eAAe;CACxD,OAAgB,WAAkC,IAAI,sBAAsB;CAE5E,YAAY,OAA6B;EACvC,MAAM,SAAS;GAAE,IAAI;GAAsB,SAAS;IAAE,OAAO,CAAC;IAAG,MAAM,CAAC;GAAE;EAAE,CAAC;CAC/E;CAEA,YAA6B;EAC3B,OAAO;CACT;CAEA,aAAsB,WAA2B;EAC/C,OAAO,IAAI,UAAU;CACvB;CAEA,sBAAuC;EACrC,OAAO;CACT;AACF;AAEA,eAAe,UAAU,sBAAsB;;;;;;;;;;AAW/C,SAAgB,iBAAiB,IAAmC;CAClE,OAAQ,IAA8C,SAAS;AACjE;;;;;;;;;;;;AAaA,SAAgB,wBACd,OACA,WACgB;CAChB,MAAM,cAAmC;EACvC,IAAI,MAAM;EACV,SAAS;GACP,OAAO,MAAM,QAAQ;GACrB,MAAO,aAAa,CAAC;GACrB,GAAI,MAAM,QAAQ,aAAa,KAAA,IAAY,EAAE,UAAU,MAAM,QAAQ,SAAS,IAAI,CAAC;EACrF;CACF;CACA,IAAI,MAAM,OAAO,sBACf,OAAO,IAAI,sBAAsB,WAAW;CAE9C,OAAO,IAAI,eAAe,WAAW;AACvC"}
@@ -1,4 +1,5 @@
1
1
  import { blindCast } from "@prisma-next/utils/casts";
2
+ import { isThenable } from "@prisma-next/utils/promise";
2
3
  //#region src/core/migrations/render-ops.ts
3
4
  /**
4
5
  * Asserts an op materialised by an `OpFactoryCall` targets postgres. The
@@ -8,17 +9,21 @@ import { blindCast } from "@prisma-next/utils/casts";
8
9
  * place to fail loudly with op metadata (`id` + `target.id`).
9
10
  */
10
11
  function assertPostgresOp(op, callFactoryName) {
11
- const targetId = op.target?.id;
12
+ const targetId = blindCast(op).target?.id;
12
13
  if (targetId !== "postgres") throw new Error(`renderOps: expected postgres op but got target.id="${String(targetId)}" for op.id="${op.id}" (factoryName="${callFactoryName}"). An OpFactoryCall produced an op for a different target on the postgres planner path; check the call's target binding.`);
13
14
  }
14
15
  function renderOps(calls, lowerer) {
15
16
  return calls.map((c) => {
16
- const op = blindCast(c).toOp(lowerer);
17
- assertPostgresOp(op, c.factoryName);
18
- return op;
17
+ const opOrPromise = blindCast(c).toOp(lowerer);
18
+ if (isThenable(opOrPromise)) return opOrPromise.then((op) => {
19
+ assertPostgresOp(op, c.factoryName);
20
+ return op;
21
+ });
22
+ assertPostgresOp(opOrPromise, c.factoryName);
23
+ return opOrPromise;
19
24
  });
20
25
  }
21
26
  //#endregion
22
27
  export { renderOps as t };
23
28
 
24
- //# sourceMappingURL=render-ops-BpjstrKQ.mjs.map
29
+ //# sourceMappingURL=render-ops-BREh1kHe.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-ops-BREh1kHe.mjs","names":[],"sources":["../src/core/migrations/render-ops.ts"],"sourcesContent":["import type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type { ExecuteRequestLowerer } from '@prisma-next/family-sql/control-adapter';\nimport type {\n MigrationPlanOperation,\n OpFactoryCall,\n} from '@prisma-next/framework-components/control';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { isThenable } from '@prisma-next/utils/promise';\nimport type { PostgresPlanTargetDetails } from './planner-target-details';\n\ntype Op = SqlMigrationPlanOperation<PostgresPlanTargetDetails>;\n\n/**\n * Asserts an op materialised by an `OpFactoryCall` targets postgres. The\n * extension surface lets any contributor emit calls, so this is the\n * integration boundary where a stray non-postgres op would otherwise\n * silently flow through to postgres-shaped renderers — exactly the\n * place to fail loudly with op metadata (`id` + `target.id`).\n */\nfunction assertPostgresOp(op: MigrationPlanOperation, callFactoryName: string): asserts op is Op {\n const targetId = blindCast<\n { target?: { id?: string } },\n 'op.target is present on concrete SqlMigrationPlanOperation but absent on the framework MigrationPlanOperation base'\n >(op).target?.id;\n if (targetId !== 'postgres') {\n throw new Error(\n `renderOps: expected postgres op but got target.id=\"${String(targetId)}\" for op.id=\"${op.id}\" (factoryName=\"${callFactoryName}\"). An OpFactoryCall produced an op for a different target on the postgres planner path; check the call's target binding.`,\n );\n }\n}\n\nexport function renderOps(\n calls: readonly OpFactoryCall[],\n lowerer?: ExecuteRequestLowerer,\n): (Op | Promise<Op>)[] {\n return calls.map((c) => {\n const opOrPromise = blindCast<\n { toOp(lowerer?: ExecuteRequestLowerer): Op | Promise<Op> },\n 'PG OpFactoryCall.toOp accepts an optional ExecuteRequestLowerer; the framework interface omits it because not all targets need a lowerer — the PG target overrides with this extended signature'\n >(c).toOp(lowerer);\n if (isThenable(opOrPromise)) {\n return opOrPromise.then((op) => {\n assertPostgresOp(op, c.factoryName);\n return op;\n });\n }\n assertPostgresOp(opOrPromise, c.factoryName);\n return opOrPromise;\n });\n}\n"],"mappings":";;;;;;;;;;AAmBA,SAAS,iBAAiB,IAA4B,iBAA2C;CAC/F,MAAM,WAAW,UAGf,EAAE,CAAC,CAAC,QAAQ;CACd,IAAI,aAAa,YACf,MAAM,IAAI,MACR,sDAAsD,OAAO,QAAQ,EAAE,eAAe,GAAG,GAAG,kBAAkB,gBAAgB,0HAChI;AAEJ;AAEA,SAAgB,UACd,OACA,SACsB;CACtB,OAAO,MAAM,KAAK,MAAM;EACtB,MAAM,cAAc,UAGlB,CAAC,CAAC,CAAC,KAAK,OAAO;EACjB,IAAI,WAAW,WAAW,GACxB,OAAO,YAAY,MAAM,OAAO;GAC9B,iBAAiB,IAAI,EAAE,WAAW;GAClC,OAAO;EACT,CAAC;EAEH,iBAAiB,aAAa,EAAE,WAAW;EAC3C,OAAO;CACT,CAAC;AACH"}
@@ -1,11 +1,11 @@
1
1
  import { t as PostgresPlanTargetDetails } from "./planner-target-details-CIY6tLeo.mjs";
2
2
  import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
3
3
  import { OpFactoryCall } from "@prisma-next/framework-components/control";
4
- import { Lowerer } from "@prisma-next/family-sql/control-adapter";
4
+ import { ExecuteRequestLowerer } from "@prisma-next/family-sql/control-adapter";
5
5
 
6
6
  //#region src/core/migrations/render-ops.d.ts
7
7
  type Op = SqlMigrationPlanOperation<PostgresPlanTargetDetails>;
8
- declare function renderOps(calls: readonly OpFactoryCall[], lowerer?: Lowerer): Op[];
8
+ declare function renderOps(calls: readonly OpFactoryCall[], lowerer?: ExecuteRequestLowerer): (Op | Promise<Op>)[];
9
9
  //#endregion
10
10
  export { renderOps };
11
11
  //# sourceMappingURL=render-ops.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"render-ops.d.mts","names":[],"sources":["../src/core/migrations/render-ops.ts"],"mappings":";;;;;;KAMK,EAAA,GAAK,yBAAyB,CAAC,yBAAA;AAAA,iBAqBpB,SAAA,CAAU,KAAA,WAAgB,aAAA,IAAiB,OAAA,GAAU,OAAA,GAAU,EAAA"}
1
+ {"version":3,"file":"render-ops.d.mts","names":[],"sources":["../src/core/migrations/render-ops.ts"],"mappings":";;;;;;KAUK,EAAA,GAAK,yBAAyB,CAAC,yBAAA;AAAA,iBAqBpB,SAAA,CACd,KAAA,WAAgB,aAAA,IAChB,OAAA,GAAU,qBAAA,IACR,EAAA,GAAK,OAAA,CAAQ,EAAA"}
@@ -1,2 +1,2 @@
1
- import { t as renderOps } from "./render-ops-BpjstrKQ.mjs";
1
+ import { t as renderOps } from "./render-ops-BREh1kHe.mjs";
2
2
  export { renderOps };
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/core/postgres-contract-serializer.ts","../src/exports/runtime.ts"],"mappings":";;;;;;;;;cAyEa,0BAAA,SAAmC,yBAAA,CAA0B,QAAA,CAAS,UAAA;;YAQ9D,wBAAA,CACjB,IAAA,UACA,GAAA,EAAK,SAAA,GAAY,MAAA,oBAChB,SAAA,GAAY,uBAAA;EA4CN,iBAAA,CAAkB,QAAA,EAAU,QAAA,CAAS,UAAA,IAAc,UAAA;EAAA,QAuCpD,0BAAA;EAAA,QAmBA,kBAAA;AAAA;;;UCjLO,6BAAA,SAAsC,qBAAqB;;;;;ADgE5E;;cCxDM,+BAAA,EAAiC,uBAAA,oBAGrC,6BAAA;EAAA,SAES,MAAA,iBAAuB,kBAAA;AAAA"}
1
+ {"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/core/postgres-contract-serializer.ts","../src/exports/runtime.ts"],"mappings":";;;;;;;;;cAyEa,0BAAA,SAAmC,yBAAA,CAA0B,QAAA,CAAS,UAAA;;YAQ9D,wBAAA,CACjB,IAAA,UACA,GAAA,EAAK,SAAA,GAAY,MAAA,oBAChB,SAAA,GAAY,uBAAA;EA+CN,iBAAA,CAAkB,QAAA,EAAU,QAAA,CAAS,UAAA,IAAc,UAAA;EAAA,QAuCpD,0BAAA;EAAA,QA8BA,kBAAA;AAAA;;;UC/LO,6BAAA,SAAsC,qBAAqB;;;;;ADgE5E;;cCxDM,+BAAA,EAAiC,uBAAA,oBAGrC,6BAAA;EAAA,SAES,MAAA,iBAAuB,kBAAA;AAAA"}
package/dist/runtime.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { t as postgresTargetDescriptorMetaRuntime } from "./descriptor-meta-runtime-My8_s4cs.mjs";
2
- import { t as PostgresContractSerializer } from "./postgres-contract-serializer-DYTyXjPf.mjs";
1
+ import { t as postgresTargetDescriptorMetaRuntime } from "./descriptor-meta-runtime-B5ZtrgVF.mjs";
2
+ import { t as PostgresContractSerializer } from "./postgres-contract-serializer-BDbqgeFb.mjs";
3
3
  //#region src/exports/runtime.ts
4
4
  /**
5
5
  * Target-postgres deliberately does NOT import `SqlRuntimeTargetDescriptor` from `@prisma-next/sql-runtime`. The target package is a control-plane residence and must not pull the SQL execution-plane package into its dependency closure. The runtime descriptor here is shaped to satisfy the framework's `RuntimeTargetDescriptor` plus the structural `SqlStaticContributions` (`codecs:` returning a descriptor list) that
package/dist/types.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { n as PostgresEnumTypeInput, t as PostgresEnumType } from "./postgres-enum-type-BVn63a89.mjs";
2
2
  import { t as PostgresColumnDefault } from "./types-BDKkx8MA.mjs";
3
3
  import { NamespaceBase } from "@prisma-next/framework-components/ir";
4
- import { PostgresEnumStorageEntry, SqlNamespaceTablesInput, SqlStorage, StorageTable, StorageTableInput } from "@prisma-next/sql-contract/types";
4
+ import { PostgresEnumStorageEntry, SqlNamespaceTablesInput, SqlStorage, StorageTable, StorageTableInput, StorageValueSet, StorageValueSetInput } from "@prisma-next/sql-contract/types";
5
5
 
6
6
  //#region src/core/postgres-schema.d.ts
7
7
  interface PostgresSchemaInput {
@@ -9,6 +9,7 @@ interface PostgresSchemaInput {
9
9
  readonly entries: {
10
10
  readonly table: Record<string, StorageTable | StorageTableInput>;
11
11
  readonly type: Record<string, PostgresEnumType | PostgresEnumTypeInput>;
12
+ readonly valueSet?: Record<string, StorageValueSet | StorageValueSetInput>;
12
13
  };
13
14
  }
14
15
  /**
@@ -39,6 +40,7 @@ declare class PostgresSchema extends NamespaceBase {
39
40
  readonly entries: Readonly<{
40
41
  readonly table: Readonly<Record<string, StorageTable>>;
41
42
  readonly type: Readonly<Record<string, PostgresEnumType>>;
43
+ readonly valueSet?: Readonly<Record<string, StorageValueSet>>;
42
44
  }>;
43
45
  constructor(input: PostgresSchemaInput);
44
46
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.mts","names":[],"sources":["../src/core/postgres-schema.ts"],"mappings":";;;;;;UAeiB,mBAAA;EAAA,SACN,EAAA;EAAA,SACA,OAAA;IAAA,SACE,KAAA,EAAO,MAAA,SAAe,YAAA,GAAe,iBAAA;IAAA,SACrC,IAAA,EAAM,MAAA,SAAe,gBAAA,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AAA,SAEC,IAAA;EAAA,SACR,EAAA;EAAA,SACA,OAAA,EAAS,QAAA;IAAA,SACP,KAAA,EAAO,QAAA,CAAS,MAAA,SAAe,YAAA;IAAA,SAC/B,IAAA,EAAM,QAAA,CAAS,MAAA,SAAe,gBAAA;IAAA,SAC9B,QAAA,GAAW,QAAA,CAAS,MAAA,SAAe,eAAA;EAAA;cAGlC,KAAA,EAAO,mBAAA;EALD;;;;;EAsDlB,SAAA;EApDsB;;;;;;EA8DtB,YAAA,CAAa,SAAA;EA7EqB;;;;;;EAuFlC,eAAA,CAAgB,IAAA;EA1EL;;;;;;;;EAsFX,mBAAA;EApFsB;;;;;;;;;;;EAmGtB,aAAA,CAAc,QAAA,EAAU,UAAA;AAAA;;;;AAAU;AAwBpC;;;;;;;;;;;;;;;cAAa,qBAAA,SAA8B,cAAA;EAAA,gBACzB,QAAA,EAAU,qBAAA;cAEd,KAAA,GAAQ,mBAAA;EAIX,SAAA;EAIA,YAAA,CAAa,SAAA;EAIb,mBAAA;AAAA;;;;;;;AAkCM;;;;;iBAHD,uBAAA,CACd,KAAA,EAAO,uBAAA,EACP,SAAA,GAAY,QAAA,CAAS,MAAA,SAAe,wBAAA,KACnC,cAAA"}
package/dist/types.mjs CHANGED
@@ -1,3 +1,3 @@
1
1
  import { t as PostgresEnumType } from "./postgres-enum-type-DPKqCBem.mjs";
2
- import { i as postgresCreateNamespace, n as PostgresUnboundSchema, t as PostgresSchema } from "./postgres-schema-BuxCxbvB.mjs";
2
+ import { i as postgresCreateNamespace, n as PostgresUnboundSchema, t as PostgresSchema } from "./postgres-schema-BAgkIU9u.mjs";
3
3
  export { PostgresEnumType, PostgresSchema, PostgresUnboundSchema, postgresCreateNamespace };
package/package.json CHANGED
@@ -1,32 +1,32 @@
1
1
  {
2
2
  "name": "@prisma-next/target-postgres",
3
- "version": "0.13.0-dev.2",
3
+ "version": "0.13.0-dev.20",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "description": "Postgres target pack for Prisma Next",
8
8
  "dependencies": {
9
- "@prisma-next/cli": "0.13.0-dev.2",
10
- "@prisma-next/contract": "0.13.0-dev.2",
11
- "@prisma-next/errors": "0.13.0-dev.2",
12
- "@prisma-next/family-sql": "0.13.0-dev.2",
13
- "@prisma-next/framework-components": "0.13.0-dev.2",
14
- "@prisma-next/migration-tools": "0.13.0-dev.2",
15
- "@prisma-next/ts-render": "0.13.0-dev.2",
16
- "@prisma-next/sql-contract": "0.13.0-dev.2",
17
- "@prisma-next/sql-errors": "0.13.0-dev.2",
18
- "@prisma-next/sql-operations": "0.13.0-dev.2",
19
- "@prisma-next/sql-relational-core": "0.13.0-dev.2",
20
- "@prisma-next/sql-schema-ir": "0.13.0-dev.2",
21
- "@prisma-next/utils": "0.13.0-dev.2",
9
+ "@prisma-next/cli": "0.13.0-dev.20",
10
+ "@prisma-next/contract": "0.13.0-dev.20",
11
+ "@prisma-next/errors": "0.13.0-dev.20",
12
+ "@prisma-next/family-sql": "0.13.0-dev.20",
13
+ "@prisma-next/framework-components": "0.13.0-dev.20",
14
+ "@prisma-next/migration-tools": "0.13.0-dev.20",
15
+ "@prisma-next/ts-render": "0.13.0-dev.20",
16
+ "@prisma-next/sql-contract": "0.13.0-dev.20",
17
+ "@prisma-next/sql-errors": "0.13.0-dev.20",
18
+ "@prisma-next/sql-operations": "0.13.0-dev.20",
19
+ "@prisma-next/sql-relational-core": "0.13.0-dev.20",
20
+ "@prisma-next/sql-schema-ir": "0.13.0-dev.20",
21
+ "@prisma-next/utils": "0.13.0-dev.20",
22
22
  "@standard-schema/spec": "^1.1.0",
23
23
  "arktype": "^2.2.0",
24
24
  "pathe": "^2.0.3"
25
25
  },
26
26
  "devDependencies": {
27
- "@prisma-next/test-utils": "0.13.0-dev.2",
28
- "@prisma-next/tsconfig": "0.13.0-dev.2",
29
- "@prisma-next/tsdown": "0.13.0-dev.2",
27
+ "@prisma-next/test-utils": "0.13.0-dev.20",
28
+ "@prisma-next/tsconfig": "0.13.0-dev.20",
29
+ "@prisma-next/tsdown": "0.13.0-dev.20",
30
30
  "tsdown": "0.22.1",
31
31
  "typescript": "5.9.3",
32
32
  "vitest": "4.1.8"
@@ -59,6 +59,11 @@ export const postgresAuthoringEntityTypes = {
59
59
  * (see `createPostgresPslScalarTypeDescriptors`), so that authoring a field
60
60
  * via the TS callback surface (e.g. `field.int()`) and via the PSL scalar
61
61
  * surface (e.g. `Int`) lowers to byte-identical contracts.
62
+ *
63
+ * The `uuidNative` / `id.uuidv4Native` / `id.uuidv7Native` presets use the
64
+ * native Postgres `uuid` type (codecId `pg/uuid@1`). For cross-target
65
+ * portability use `uuidString` / `id.uuidv4String` / `id.uuidv7String` from
66
+ * the family pack instead.
62
67
  */
63
68
  export const postgresAuthoringFieldPresets = {
64
69
  text: {
@@ -128,4 +133,41 @@ export const postgresAuthoringFieldPresets = {
128
133
  codecId: 'pg/timestamptz@1',
129
134
  nativeType: 'timestamptz',
130
135
  }),
136
+ uuidNative: {
137
+ kind: 'fieldPreset',
138
+ output: {
139
+ codecId: 'pg/uuid@1',
140
+ nativeType: 'uuid',
141
+ },
142
+ },
143
+ id: {
144
+ uuidv4Native: {
145
+ kind: 'fieldPreset',
146
+ output: {
147
+ codecId: 'pg/uuid@1',
148
+ nativeType: 'uuid',
149
+ executionDefaults: {
150
+ onCreate: {
151
+ kind: 'generator',
152
+ id: 'uuidv4',
153
+ },
154
+ },
155
+ id: true,
156
+ },
157
+ },
158
+ uuidv7Native: {
159
+ kind: 'fieldPreset',
160
+ output: {
161
+ codecId: 'pg/uuid@1',
162
+ nativeType: 'uuid',
163
+ executionDefaults: {
164
+ onCreate: {
165
+ kind: 'generator',
166
+ id: 'uuidv7',
167
+ },
168
+ },
169
+ id: true,
170
+ },
171
+ },
172
+ },
131
173
  } as const satisfies AuthoringFieldNamespace;
@@ -30,3 +30,4 @@ export const PG_INTERVAL_CODEC_ID = 'pg/interval@1' as const;
30
30
  export const PG_JSON_CODEC_ID = 'pg/json@1' as const;
31
31
  export const PG_JSONB_CODEC_ID = 'pg/jsonb@1' as const;
32
32
  export const PG_BYTEA_CODEC_ID = 'pg/bytea@1' as const;
33
+ export const PG_UUID_CODEC_ID = 'pg/uuid@1' as const;