{"version":3,"file":"control.mjs","names":["baselineMetadata","baselineOps"],"sources":["../migrations/20260601T0000_install_postgis_extension/migration.json","../migrations/20260601T0000_install_postgis_extension/ops.json","../migrations/refs/head.json","../src/contract.json","../src/core/contract-space-constants.ts","../src/exports/control.ts"],"sourcesContent":["","","","","/**\n * Static names and identifiers used across postgis's contract space.\n *\n * Centralised here so the contract IR (`./contract`), the baseline\n * migration ops (`./migrations`), the head ref, and the descriptor\n * (`../exports/control`) all reference the same values without typos.\n *\n * The space identifier `'postgis'` is what the framework writes to\n * `migrations/` in the user's repo and what the marker table's\n * `space` column carries for postgis-owned rows.\n *\n * The `postgis:*` invariantId namespace is locked here — once\n * published, an invariantId is immutable so downstream consumers can\n * reference it by literal string match.\n */\n\nexport const POSTGIS_SPACE_ID = 'postgis' as const;\n\nexport const POSTGIS_NATIVE_TYPE = 'geometry' as const;\n\nexport const POSTGIS_BASELINE_MIGRATION_NAME = '20260601T0000_install_postgis_extension' as const;\n\n/**\n * `postgis:*` invariantIds emitted by the baseline migration. Each id,\n * once published, is immutable: downstream consumers (other extensions,\n * the marker table) reference them by literal string match.\n */\nexport const POSTGIS_INVARIANTS = {\n  installPostgis: 'postgis:install-postgis-v1',\n} as const;\n","/**\n * Control-plane descriptor for the postgis extension.\n *\n * **Contract-space package layout.** The extension's contract\n * + migrations are emitted by the same pipeline application authors use:\n *\n *   `prisma-next contract emit` → `<package>/src/contract.{json,d.ts}`\n *   `prisma-next migration plan` → `<package>/migrations/<dir>/...`\n *\n * The descriptor wires those JSON artefacts via JSON-import declarations\n * so they flow through the consuming application's module resolver\n * without filesystem assumptions, and synthesises the canonical\n * `MigrationPackage` shape for the framework's runner / verifier to\n * consume.\n *\n * Wired surfaces:\n *\n *   - `contractSpace.{contractJson,migrations,headRef}` — sourced from\n *     the on-disk artefacts emitted by `build:contract-space`.\n *   - `types.codecTypes.controlPlaneHooks[POSTGIS_GEOMETRY_CODEC_ID]` —\n *     codec control hooks (`expandNativeType`, `resolveIdentityValue`)\n *     the SQL planner extracts via `extractCodecControlHooks` and uses\n *     to render `geometry(Geometry,${srid})` column types.\n *\n * @see docs/architecture docs/adrs/ADR 212 - Contract spaces.md\n *   (contract-space package layout convention).\n */\n\nimport type { Contract } from '@prisma-next/contract/types';\nimport type {\n  CodecControlHooks,\n  SqlControlExtensionDescriptor,\n} from '@prisma-next/family-sql/control';\nimport { contractSpaceFromJson } from '@prisma-next/migration-tools/spaces';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport baselineMetadata from '../../migrations/20260601T0000_install_postgis_extension/migration.json' with {\n  type: 'json',\n};\nimport baselineOps from '../../migrations/20260601T0000_install_postgis_extension/ops.json' with {\n  type: 'json',\n};\nimport headRef from '../../migrations/refs/head.json' with { type: 'json' };\nimport contractJson from '../contract.json' with { type: 'json' };\nimport { POSTGIS_GEOMETRY_CODEC_ID } from '../core/constants';\nimport {\n  POSTGIS_BASELINE_MIGRATION_NAME,\n  POSTGIS_SPACE_ID,\n} from '../core/contract-space-constants';\nimport { postgisPackMeta, postgisQueryOperations } from '../core/descriptor-meta';\n\nconst geometryControlPlaneHooks: CodecControlHooks = {\n  expandNativeType: ({ nativeType, typeParams }) => {\n    const srid = typeParams?.['srid'];\n    if (typeof srid === 'number' && Number.isInteger(srid) && srid >= 0) {\n      // PostGIS prints the type-modifier list without a space — match\n      // it here so the verifier doesn't see `geometry(Geometry, 4326)`\n      // (DDL) mismatch `geometry(Geometry,4326)` (introspected).\n      return `${nativeType}(Geometry,${srid})`;\n    }\n    return nativeType;\n  },\n  // PostGIS has no canonical \"identity\" geometry; backfilling a\n  // non-null column requires the user to supply a valid value, so we\n  // don't synthesise one here.\n  resolveIdentityValue: () => null,\n};\n\nconst postgisContractSpace = contractSpaceFromJson<Contract<SqlStorage>>({\n  contractJson,\n  migrations: [\n    {\n      dirName: POSTGIS_BASELINE_MIGRATION_NAME,\n      metadata: baselineMetadata,\n      ops: baselineOps,\n    },\n  ],\n  headRef,\n});\n\nconst postgisExtensionDescriptor: SqlControlExtensionDescriptor<'postgres'> = {\n  ...postgisPackMeta,\n  id: POSTGIS_SPACE_ID,\n  contractSpace: postgisContractSpace,\n  types: {\n    ...postgisPackMeta.types,\n    codecTypes: {\n      ...postgisPackMeta.types.codecTypes,\n      controlPlaneHooks: {\n        [POSTGIS_GEOMETRY_CODEC_ID]: geometryControlPlaneHooks,\n      },\n    },\n  },\n  queryOperations: () => postgisQueryOperations(),\n  create: () => ({\n    familyId: 'sql' as const,\n    targetId: 'postgres' as const,\n  }),\n};\n\nexport { postgisExtensionDescriptor };\nexport default postgisExtensionDescriptor;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AIgBA,MAAa,mBAAmB;AAIhC,MAAa,kCAAkC;;;AC8B/C,MAAM,4BAA+C;CACnD,mBAAmB,EAAE,YAAY,iBAAiB;EAChD,MAAM,OAAO,aAAa;EAC1B,IAAI,OAAO,SAAS,YAAY,OAAO,UAAU,IAAI,KAAK,QAAQ,GAIhE,OAAO,GAAG,WAAW,YAAY,KAAK;EAExC,OAAO;CACT;CAIA,4BAA4B;AAC9B;AAEA,MAAM,uBAAuB,sBAA4C;CACvE,cAAA;CACA,YAAY,CACV;EACE,SAAS;EACT,UAAUA;EACV,KAAKC;CACP,CACF;CACA,SAAA;AACF,CAAC;AAED,MAAM,6BAAwE;CAC5E,GAAG;CACH,IAAI;CACJ,eAAe;CACf,OAAO;EACL,GAAG,gBAAgB;EACnB,YAAY;GACV,GAAG,gBAAgB,MAAM;GACzB,mBAAmB,GAChB,4BAA4B,0BAC/B;EACF;CACF;CACA,uBAAuB,uBAAuB;CAC9C,eAAe;EACb,UAAU;EACV,UAAU;CACZ;AACF"}