@prisma-next/family-sql 0.4.0-dev.9 → 0.5.0-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/control-adapter.d.mts +16 -2
  2. package/dist/control-adapter.d.mts.map +1 -1
  3. package/dist/control.d.mts +2 -2
  4. package/dist/control.d.mts.map +1 -1
  5. package/dist/control.mjs +23 -11
  6. package/dist/control.mjs.map +1 -1
  7. package/dist/migration.d.mts +36 -0
  8. package/dist/migration.d.mts.map +1 -0
  9. package/dist/migration.mjs +35 -0
  10. package/dist/migration.mjs.map +1 -0
  11. package/dist/schema-verify.d.mts +1 -1
  12. package/dist/{types-CH9zsNrU.d.mts → types-C6K4mxDM.d.mts} +33 -3
  13. package/dist/types-C6K4mxDM.d.mts.map +1 -0
  14. package/dist/{verify-DZHtfcmj.mjs → verify-4GshvY4p.mjs} +25 -11
  15. package/dist/verify-4GshvY4p.mjs.map +1 -0
  16. package/dist/verify-sql-schema-Ovz7RXR5.mjs.map +1 -1
  17. package/dist/verify.d.mts.map +1 -1
  18. package/dist/verify.mjs +1 -1
  19. package/package.json +19 -18
  20. package/src/core/control-adapter.ts +21 -1
  21. package/src/core/control-instance.ts +2 -2
  22. package/src/core/migrations/contract-to-schema-ir.ts +45 -5
  23. package/src/core/migrations/types.ts +35 -0
  24. package/src/core/sql-migration.ts +34 -0
  25. package/src/core/verify.ts +50 -32
  26. package/src/exports/control.ts +2 -0
  27. package/src/exports/migration.ts +1 -0
  28. package/dist/operation-descriptors.d.mts +0 -380
  29. package/dist/operation-descriptors.d.mts.map +0 -1
  30. package/dist/operation-descriptors.mjs +0 -294
  31. package/dist/operation-descriptors.mjs.map +0 -1
  32. package/dist/types-CH9zsNrU.d.mts.map +0 -1
  33. package/dist/verify-DZHtfcmj.mjs.map +0 -1
  34. package/src/core/migrations/descriptor-schemas.ts +0 -172
  35. package/src/core/migrations/operation-descriptors.ts +0 -213
  36. package/src/exports/operation-descriptors.ts +0 -52
@@ -1 +0,0 @@
1
- {"version":3,"file":"operation-descriptors.mjs","names":[],"sources":["../src/core/migrations/descriptor-schemas.ts","../src/core/migrations/operation-descriptors.ts"],"sourcesContent":["/**\n * Arktype schemas for SQL migration operation descriptors.\n *\n * These schemas are the source of truth for descriptor shapes.\n * TypeScript types are derived via `typeof schema.infer`.\n */\n\nimport { type } from 'arktype';\n\n// ============================================================================\n// Table descriptors\n// ============================================================================\n\nexport const CreateTableSchema = type({ kind: \"'createTable'\", table: 'string' });\nexport const DropTableSchema = type({ kind: \"'dropTable'\", table: 'string' });\n\n// ============================================================================\n// Column descriptors\n// ============================================================================\n\nexport const AddColumnSchema = type({\n kind: \"'addColumn'\",\n table: 'string',\n column: 'string',\n 'overrides?': { 'nullable?': 'boolean' },\n});\n\nexport const DropColumnSchema = type({ kind: \"'dropColumn'\", table: 'string', column: 'string' });\n\nexport const AlterColumnTypeSchema = type({\n kind: \"'alterColumnType'\",\n table: 'string',\n column: 'string',\n 'using?': 'string',\n 'toType?': 'string',\n});\n\nexport const SetNotNullSchema = type({ kind: \"'setNotNull'\", table: 'string', column: 'string' });\nexport const DropNotNullSchema = type({ kind: \"'dropNotNull'\", table: 'string', column: 'string' });\nexport const SetDefaultSchema = type({ kind: \"'setDefault'\", table: 'string', column: 'string' });\nexport const DropDefaultSchema = type({ kind: \"'dropDefault'\", table: 'string', column: 'string' });\n\n// ============================================================================\n// Constraint descriptors\n// ============================================================================\n\nexport const AddPrimaryKeySchema = type({ kind: \"'addPrimaryKey'\", table: 'string' });\nexport const AddUniqueSchema = type({ kind: \"'addUnique'\", table: 'string', columns: 'string[]' });\nexport const AddForeignKeySchema = type({\n kind: \"'addForeignKey'\",\n table: 'string',\n columns: 'string[]',\n});\nexport const DropConstraintSchema = type({\n kind: \"'dropConstraint'\",\n table: 'string',\n constraintName: 'string',\n});\n\n// ============================================================================\n// Index descriptors\n// ============================================================================\n\nexport const CreateIndexSchema = type({\n kind: \"'createIndex'\",\n table: 'string',\n columns: 'string[]',\n});\nexport const DropIndexSchema = type({\n kind: \"'dropIndex'\",\n table: 'string',\n indexName: 'string',\n});\n\n// ============================================================================\n// Type descriptors\n// ============================================================================\n\nexport const CreateEnumTypeSchema = type({\n kind: \"'createEnumType'\",\n typeName: 'string',\n 'values?': 'string[]',\n});\nexport const AddEnumValuesSchema = type({\n kind: \"'addEnumValues'\",\n typeName: 'string',\n values: 'string[]',\n});\nexport const DropEnumTypeSchema = type({ kind: \"'dropEnumType'\", typeName: 'string' });\nexport const RenameTypeSchema = type({\n kind: \"'renameType'\",\n fromName: 'string',\n toName: 'string',\n});\n\n// ============================================================================\n// Dependency descriptors\n// ============================================================================\n\nexport const CreateDependencySchema = type({\n kind: \"'createDependency'\",\n dependencyId: 'string',\n});\n\n// ============================================================================\n// Data transform descriptor\n// ============================================================================\n\nexport const DataTransformSchema = type({\n kind: \"'dataTransform'\",\n name: 'string',\n source: 'string',\n check: 'boolean | Function | symbol | object',\n run: '(Function | symbol | object)[]',\n});\n\n// ============================================================================\n// Union schema\n// ============================================================================\n\nexport const SqlMigrationOpDescriptorSchema = type.or(\n CreateTableSchema,\n DropTableSchema,\n AddColumnSchema,\n DropColumnSchema,\n AlterColumnTypeSchema,\n SetNotNullSchema,\n DropNotNullSchema,\n SetDefaultSchema,\n DropDefaultSchema,\n AddPrimaryKeySchema,\n AddUniqueSchema,\n AddForeignKeySchema,\n DropConstraintSchema,\n CreateIndexSchema,\n DropIndexSchema,\n CreateEnumTypeSchema,\n AddEnumValuesSchema,\n DropEnumTypeSchema,\n RenameTypeSchema,\n CreateDependencySchema,\n DataTransformSchema,\n);\n\nexport const MigrationDescriptorArraySchema = SqlMigrationOpDescriptorSchema.array();\n\n// ============================================================================\n// Derived types\n// ============================================================================\n\nexport type CreateTableDescriptor = typeof CreateTableSchema.infer;\nexport type DropTableDescriptor = typeof DropTableSchema.infer;\nexport type AddColumnDescriptor = typeof AddColumnSchema.infer;\nexport type DropColumnDescriptor = typeof DropColumnSchema.infer;\nexport type AlterColumnTypeDescriptor = typeof AlterColumnTypeSchema.infer;\nexport type SetNotNullDescriptor = typeof SetNotNullSchema.infer;\nexport type DropNotNullDescriptor = typeof DropNotNullSchema.infer;\nexport type SetDefaultDescriptor = typeof SetDefaultSchema.infer;\nexport type DropDefaultDescriptor = typeof DropDefaultSchema.infer;\nexport type AddPrimaryKeyDescriptor = typeof AddPrimaryKeySchema.infer;\nexport type AddUniqueDescriptor = typeof AddUniqueSchema.infer;\nexport type AddForeignKeyDescriptor = typeof AddForeignKeySchema.infer;\nexport type DropConstraintDescriptor = typeof DropConstraintSchema.infer;\nexport type CreateIndexDescriptor = typeof CreateIndexSchema.infer;\nexport type DropIndexDescriptor = typeof DropIndexSchema.infer;\nexport type CreateEnumTypeDescriptor = typeof CreateEnumTypeSchema.infer;\nexport type AddEnumValuesDescriptor = typeof AddEnumValuesSchema.infer;\nexport type DropEnumTypeDescriptor = typeof DropEnumTypeSchema.infer;\nexport type RenameTypeDescriptor = typeof RenameTypeSchema.infer;\nexport type CreateDependencyDescriptor = typeof CreateDependencySchema.infer;\nexport type DataTransformDescriptor = typeof DataTransformSchema.infer;\nexport type SqlMigrationOpDescriptor = typeof SqlMigrationOpDescriptorSchema.infer;\n","/**\n * SQL migration operation descriptors — builder functions and re-exports.\n *\n * Types are defined by arktype schemas in descriptor-schemas.ts and derived\n * via `typeof schema.infer`. This file provides the builder functions that\n * construct descriptors, plus re-exports the types and schemas.\n */\n\nimport type { SqlQueryPlan } from '@prisma-next/sql-relational-core/plan';\nimport { ifDefined } from '@prisma-next/utils/defined';\n\n// Re-export types and schemas from the schema source of truth\nexport type {\n AddColumnDescriptor,\n AddEnumValuesDescriptor,\n AddForeignKeyDescriptor,\n AddPrimaryKeyDescriptor,\n AddUniqueDescriptor,\n AlterColumnTypeDescriptor,\n CreateDependencyDescriptor,\n CreateEnumTypeDescriptor,\n CreateIndexDescriptor,\n CreateTableDescriptor,\n DataTransformDescriptor,\n DropColumnDescriptor,\n DropConstraintDescriptor,\n DropDefaultDescriptor,\n DropEnumTypeDescriptor,\n DropIndexDescriptor,\n DropNotNullDescriptor,\n DropTableDescriptor,\n RenameTypeDescriptor,\n SetDefaultDescriptor,\n SetNotNullDescriptor,\n SqlMigrationOpDescriptor,\n} from './descriptor-schemas';\n\nexport { MigrationDescriptorArraySchema } from './descriptor-schemas';\n\nimport type {\n AddColumnDescriptor,\n AddEnumValuesDescriptor,\n AddForeignKeyDescriptor,\n AddPrimaryKeyDescriptor,\n AddUniqueDescriptor,\n AlterColumnTypeDescriptor,\n CreateDependencyDescriptor,\n CreateEnumTypeDescriptor,\n CreateIndexDescriptor,\n CreateTableDescriptor,\n DropColumnDescriptor,\n DropConstraintDescriptor,\n DropDefaultDescriptor,\n DropEnumTypeDescriptor,\n DropIndexDescriptor,\n DropNotNullDescriptor,\n DropTableDescriptor,\n RenameTypeDescriptor,\n SetDefaultDescriptor,\n SetNotNullDescriptor,\n} from './descriptor-schemas';\n\n// ============================================================================\n// Data transform support types (not validated by arktype — runtime values)\n// ============================================================================\n\n/** Something that can produce a SqlQueryPlan via .build(). */\nexport interface Buildable {\n build(): SqlQueryPlan;\n}\n\n/**\n * Sentinel value for unimplemented data transform queries.\n * The scaffold renders this as a TODO comment. The resolver throws if it encounters one.\n */\nexport const TODO = Symbol.for('prisma-next.migration.todo');\nexport type TodoMarker = typeof TODO;\n\n// ============================================================================\n// Builder functions\n// ============================================================================\n\nexport function createTable(table: string): CreateTableDescriptor {\n return { kind: 'createTable', table };\n}\n\nexport function dropTable(table: string): DropTableDescriptor {\n return { kind: 'dropTable', table };\n}\n\nexport function addColumn(\n table: string,\n column: string,\n overrides?: { nullable?: boolean },\n): AddColumnDescriptor {\n return { kind: 'addColumn', table, column, ...ifDefined('overrides', overrides) };\n}\n\nexport function dropColumn(table: string, column: string): DropColumnDescriptor {\n return { kind: 'dropColumn', table, column };\n}\n\nexport function alterColumnType(\n table: string,\n column: string,\n opts?: string | { using?: string; toType?: string },\n): AlterColumnTypeDescriptor {\n const using = typeof opts === 'string' ? opts : opts?.using;\n const toType = typeof opts === 'string' ? undefined : opts?.toType;\n return {\n kind: 'alterColumnType',\n table,\n column,\n ...ifDefined('using', using),\n ...ifDefined('toType', toType),\n };\n}\n\nexport function setNotNull(table: string, column: string): SetNotNullDescriptor {\n return { kind: 'setNotNull', table, column };\n}\n\nexport function dropNotNull(table: string, column: string): DropNotNullDescriptor {\n return { kind: 'dropNotNull', table, column };\n}\n\nexport function setDefault(table: string, column: string): SetDefaultDescriptor {\n return { kind: 'setDefault', table, column };\n}\n\nexport function dropDefault(table: string, column: string): DropDefaultDescriptor {\n return { kind: 'dropDefault', table, column };\n}\n\nexport function addPrimaryKey(table: string): AddPrimaryKeyDescriptor {\n return { kind: 'addPrimaryKey', table };\n}\n\nexport function addUnique(table: string, columns: readonly string[]): AddUniqueDescriptor {\n return { kind: 'addUnique', table, columns: [...columns] };\n}\n\nexport function addForeignKey(table: string, columns: readonly string[]): AddForeignKeyDescriptor {\n return { kind: 'addForeignKey', table, columns: [...columns] };\n}\n\nexport function dropConstraint(table: string, constraintName: string): DropConstraintDescriptor {\n return { kind: 'dropConstraint', table, constraintName };\n}\n\nexport function createIndex(table: string, columns: readonly string[]): CreateIndexDescriptor {\n return { kind: 'createIndex', table, columns: [...columns] };\n}\n\nexport function dropIndex(table: string, indexName: string): DropIndexDescriptor {\n return { kind: 'dropIndex', table, indexName };\n}\n\nexport function createEnumType(\n typeName: string,\n values?: readonly string[],\n): CreateEnumTypeDescriptor {\n return {\n kind: 'createEnumType',\n typeName,\n ...ifDefined('values', values ? [...values] : undefined),\n };\n}\n\nexport function addEnumValues(\n typeName: string,\n values: readonly string[],\n): AddEnumValuesDescriptor {\n return { kind: 'addEnumValues', typeName, values: [...values] };\n}\n\nexport function dropEnumType(typeName: string): DropEnumTypeDescriptor {\n return { kind: 'dropEnumType', typeName };\n}\n\nexport function renameType(fromName: string, toName: string): RenameTypeDescriptor {\n return { kind: 'renameType', fromName, toName };\n}\n\nexport function createDependency(dependencyId: string): CreateDependencyDescriptor {\n return { kind: 'createDependency', dependencyId };\n}\n\n/**\n * All structural builder functions keyed by descriptor kind.\n */\nexport const builders = {\n createTable,\n dropTable,\n addColumn,\n dropColumn,\n alterColumnType,\n setNotNull,\n dropNotNull,\n setDefault,\n dropDefault,\n addPrimaryKey,\n addUnique,\n addForeignKey,\n dropConstraint,\n createIndex,\n dropIndex,\n createEnumType,\n addEnumValues,\n dropEnumType,\n renameType,\n createDependency,\n} as const;\n"],"mappings":";;;;;;;;;;AAaA,MAAa,oBAAoB,KAAK;CAAE,MAAM;CAAiB,OAAO;CAAU,CAAC;AACjF,MAAa,kBAAkB,KAAK;CAAE,MAAM;CAAe,OAAO;CAAU,CAAC;AAM7E,MAAa,kBAAkB,KAAK;CAClC,MAAM;CACN,OAAO;CACP,QAAQ;CACR,cAAc,EAAE,aAAa,WAAW;CACzC,CAAC;AAEF,MAAa,mBAAmB,KAAK;CAAE,MAAM;CAAgB,OAAO;CAAU,QAAQ;CAAU,CAAC;AAEjG,MAAa,wBAAwB,KAAK;CACxC,MAAM;CACN,OAAO;CACP,QAAQ;CACR,UAAU;CACV,WAAW;CACZ,CAAC;AAEF,MAAa,mBAAmB,KAAK;CAAE,MAAM;CAAgB,OAAO;CAAU,QAAQ;CAAU,CAAC;AACjG,MAAa,oBAAoB,KAAK;CAAE,MAAM;CAAiB,OAAO;CAAU,QAAQ;CAAU,CAAC;AACnG,MAAa,mBAAmB,KAAK;CAAE,MAAM;CAAgB,OAAO;CAAU,QAAQ;CAAU,CAAC;AACjG,MAAa,oBAAoB,KAAK;CAAE,MAAM;CAAiB,OAAO;CAAU,QAAQ;CAAU,CAAC;AAMnG,MAAa,sBAAsB,KAAK;CAAE,MAAM;CAAmB,OAAO;CAAU,CAAC;AACrF,MAAa,kBAAkB,KAAK;CAAE,MAAM;CAAe,OAAO;CAAU,SAAS;CAAY,CAAC;AAClG,MAAa,sBAAsB,KA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EACzD;;AAGH,SAAgB,cACd,UACA,QACyB;AACzB,QAAO;EAAE,MAAM;EAAiB;EAAU,QAAQ,CAAC,GAAG,OAAO;EAAE;;AAGjE,SAAgB,aAAa,UAA0C;AACrE,QAAO;EAAE,MAAM;EAAgB;EAAU;;AAG3C,SAAgB,WAAW,UAAkB,QAAsC;AACjF,QAAO;EAAE,MAAM;EAAc;EAAU;EAAQ;;AAGjD,SAAgB,iBAAiB,cAAkD;AACjF,QAAO;EAAE,MAAM;EAAoB;EAAc;;;;;AAMnD,MAAa,WAAW;CACtB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types-CH9zsNrU.d.mts","names":[],"sources":["../src/core/control-instance.ts","../src/core/migrations/types.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;UAyJU,eAAA;;;;;AAzHsE;AAyHvD,KAOpB,uBAAA,GAA0B,GAAH,CAAA,MAAA,EAAe,eAAA,CAAA;AAAT,UAExB,sBAAA,CAAsB;EACW,SAAA,gBAAA,EAAd,aAAc,CAAA,eAAA,CAAA;EAAd,SAAA,oBAAA,EACI,aADJ,CACkB,eADlB,CAAA;EACkB,SAAA,YAAA,EACtB,aADsB,CAAA,MAAA,CAAA;EAAd,SAAA,oBAAA,EAEA,uBAFA;;AAEA,UAGhB,mBAAA,CAHgB;EAAuB,SAAA,MAAA,EAIrC,qBAJqC,CAAA,KAAA,EAAA,MAAA,CAAA;EAGvC,SAAA,QAAA,EAAA,OAAmB;EACjB,SAAA,MAAA,EAAA,OAAA;EAGE,SAAA,OAAA,CAAA,EAAA,gBAAA;EAKyB;;;AAG9C;EACuC,SAAA,mBAAA,EAJP,aAIO,CAJO,8BAIP,CAAA,KAAA,EAAA,MAAA,CAAA,CAAA;;AAGI,UAJ1B,wBAAA,SACP,qBAGiC,CAAA,KAAA,EAHJ,WAGI,CAAA,EAF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A,CAAA,EAvCK,8BAuCL;EAA+C;;;;;EAF7D,SAAA,mBAAA,EA/BsB,aA+BtB,CA/BoC,8BA+BpC,CAAA,KAAA,EAAA,MAAA,CAAA,CAAA;;AAMO,KAlCL,2BAAA,GAkCkC,+BAAA,GAAA,wBAAA,GAAA,kBAAA,GAAA,iBAAA,GAAA,kBAAA,GAAA,sBAAA,GAAA,kBAAA;AAE1B,UA3BH,yBAAA,SAAkC,sBA2B/B,CAAA;EACI,SAAA,IAAA,EA3BP,2BA2BO;EACkC,SAAA,IAAA,CAAA,EA3BxC,SA2BwC;;AACxC,UAzBD,8BAAA,SAAuC,2BAyBtC,CAAA;KAvBN,wBAAA,GAA2B,OACrC,gCACA;UAGe;mBAEJ,iCAAiC,kBACzC,QAAQ;;UAGI,6EACP,kCAAkC,WAAW;mCACpB,cAAc;wBACzB,2BAA2B,oBAAoB;uBAChD,2BAA2B,mBAAmB;;UAGpD;;oBAEG;wBACI;gCACQ,0BAA0B;kBACxC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"verify-DZHtfcmj.mjs","names":["parsed: unknown"],"sources":["../src/core/verify.ts"],"sourcesContent":["import type { ContractMarkerRecord } from '@prisma-next/contract/types';\nimport type { ControlDriverInstance } from '@prisma-next/framework-components/control';\nimport { type } from 'arktype';\n\nconst MetaSchema = type({ '[string]': 'unknown' });\n\nfunction parseMeta(meta: unknown): Record<string, unknown> {\n if (meta === null || meta === undefined) {\n return {};\n }\n\n let parsed: unknown;\n if (typeof meta === 'string') {\n try {\n parsed = JSON.parse(meta);\n } catch {\n return {};\n }\n } else {\n parsed = meta;\n }\n\n const result = MetaSchema(parsed);\n if (result instanceof type.errors) {\n return {};\n }\n\n return result as Record<string, unknown>;\n}\n\nconst ContractMarkerRowSchema = type({\n core_hash: 'string',\n profile_hash: 'string',\n 'contract_json?': 'unknown | null',\n 'canonical_version?': 'number | null',\n 'updated_at?': 'Date | string',\n 'app_tag?': 'string | null',\n 'meta?': 'unknown | null',\n});\n\n/**\n * Parses a contract marker row from database query result.\n * This is SQL-specific parsing logic (handles SQL row structure with snake_case columns).\n */\nexport function parseContractMarkerRow(row: unknown): ContractMarkerRecord {\n const result = ContractMarkerRowSchema(row);\n if (result instanceof type.errors) {\n const messages = result.map((p: { message: string }) => p.message).join('; ');\n throw new Error(`Invalid contract marker row: ${messages}`);\n }\n\n const validatedRow = result as {\n core_hash: string;\n profile_hash: string;\n contract_json?: unknown | null;\n canonical_version?: number | null;\n updated_at?: Date | string;\n app_tag?: string | null;\n meta?: unknown | null;\n };\n\n const updatedAt = validatedRow.updated_at\n ? validatedRow.updated_at instanceof Date\n ? validatedRow.updated_at\n : new Date(validatedRow.updated_at)\n : new Date();\n\n return {\n storageHash: validatedRow.core_hash,\n profileHash: validatedRow.profile_hash,\n contractJson: validatedRow.contract_json ?? null,\n canonicalVersion: validatedRow.canonical_version ?? null,\n updatedAt,\n appTag: validatedRow.app_tag ?? null,\n meta: parseMeta(validatedRow.meta),\n };\n}\n\n/**\n * Returns the SQL statement to read the contract marker.\n * This is a migration-plane helper (no runtime imports).\n * @internal - Used internally by readMarker(). Prefer readMarker() for Control Plane usage.\n */\nexport function readMarkerSql(): { readonly sql: string; readonly params: readonly unknown[] } {\n return {\n sql: `select\n core_hash,\n profile_hash,\n contract_json,\n canonical_version,\n updated_at,\n app_tag,\n meta\n from prisma_contract.marker\n where id = $1`,\n params: [1],\n };\n}\n\n/**\n * Reads the contract marker from the database using the provided driver.\n * Returns the parsed marker record or null if no marker is found.\n * This abstracts SQL-specific details from the Control Plane.\n *\n * @param driver - ControlDriverInstance instance for executing queries\n * @returns Promise resolving to ContractMarkerRecord or null if marker not found\n */\nexport async function readMarker(\n driver: ControlDriverInstance<'sql', string>,\n): Promise<ContractMarkerRecord | null> {\n const markerStatement = readMarkerSql();\n\n try {\n const queryResult = await driver.query<{\n core_hash: string;\n profile_hash: string;\n contract_json: unknown | null;\n canonical_version: number | null;\n updated_at: Date | string;\n app_tag: string | null;\n meta: unknown | null;\n }>(markerStatement.sql, markerStatement.params);\n\n if (queryResult.rows.length === 0) {\n return null;\n }\n\n const markerRow = queryResult.rows[0];\n if (!markerRow) {\n // If rows array has length > 0 but first element is undefined, this is an unexpected result structure\n throw new Error('Database query returned unexpected result structure');\n }\n\n return parseContractMarkerRow(markerRow);\n } catch (error) {\n // Handle case where marker table doesn't exist yet (empty database)\n // PostgreSQL error code 42P01 = undefined_table\n if (\n error instanceof Error &&\n (error.message.includes('does not exist') || (error as { code?: string }).code === '42P01')\n ) {\n return null;\n }\n throw error;\n }\n}\n\n/**\n * Collects supported codec type IDs from adapter and extension manifests.\n * Returns a sorted, unique array of type IDs that are declared in the manifests.\n * This enables coverage checks by comparing contract column types against supported types.\n *\n * Note: This extracts type IDs from manifest type imports, not from runtime codec registries.\n * The manifests declare which codec types are available, but the actual type IDs\n * are defined in the codec-types TypeScript modules that are imported.\n *\n * For MVP, we return an empty array since extracting type IDs from TypeScript modules\n * would require runtime evaluation or static analysis. This can be enhanced later.\n */\nexport function collectSupportedCodecTypeIds(\n descriptors: ReadonlyArray<{ readonly id: string }>,\n): readonly string[] {\n // For MVP, return empty array\n // Future enhancement: Extract type IDs from codec-types modules via static analysis\n // or require manifests to explicitly list supported type IDs\n void descriptors;\n return [];\n}\n"],"mappings":";;;AAIA,MAAM,aAAa,KAAK,EAAE,YAAY,WAAW,CAAC;AAElD,SAAS,UAAU,MAAwC;AACzD,KAAI,SAAS,QAAQ,SAAS,OAC5B,QAAO,EAAE;CAGX,IAAIA;AACJ,KAAI,OAAO,SAAS,SAClB,KAAI;AACF,WAAS,KAAK,MAAM,KAAK;SACnB;AACN,SAAO,EAAE;;KAGX,UAAS;CAGX,MAAM,SAAS,WAAW,OAAO;AACjC,KAAI,kBAAkB,KAAK,OACzB,QAAO,EAAE;AAGX,QAAO;;AAGT,MAAM,0BAA0B,KAAK;CACnC,WAAW;CACX,cAAc;CACd,kBAAkB;CAClB,sBAAsB;CACtB,eAAe;CACf,YAAY;CACZ,SAAS;CACV,CAAC;;;;;AAMF,SAAgB,uBAAuB,KAAoC;CACzE,MAAM,SAAS,wBAAwB,IAAI;AAC3C,KAAI,kBAAkB,KAAK,QAAQ;EACjC,MAAM,WAAW,OAAO,KAAK,MAA2B,EAAE,QAAQ,CAAC,KAAK,KAAK;AAC7E,QAAM,IAAI,MAAM,gCAAgC,WAAW;;CAG7D,MAAM,eAAe;CAUrB,MAAM,YAAY,aAAa,aAC3B,aAAa,sBAAsB,OACjC,aAAa,aACb,IAAI,KAAK,aAAa,WAAW,mBACnC,IAAI,MAAM;AAEd,QAAO;EACL,aAAa,aAAa;EAC1B,aAAa,aAAa;EAC1B,cAAc,aAAa,iBAAiB;EAC5C,kBAAkB,aAAa,qBAAqB;EACpD;EACA,QAAQ,aAAa,WAAW;EAChC,MAAM,UAAU,aAAa,KAAK;EACnC;;;;;;;AAQH,SAAgB,gBAA+E;AAC7F,QAAO;EACL,KAAK;;;;;;;;;;EAUL,QAAQ,CAAC,EAAE;EACZ;;;;;;;;;;AAWH,eAAsB,WACpB,QACsC;CACtC,MAAM,kBAAkB,eAAe;AAEvC,KAAI;EACF,MAAM,cAAc,MAAM,OAAO,MAQ9B,gBAAgB,KAAK,gBAAgB,OAAO;AAE/C,MAAI,YAAY,KAAK,WAAW,EAC9B,QAAO;EAGT,MAAM,YAAY,YAAY,KAAK;AACnC,MAAI,CAAC,UAEH,OAAM,IAAI,MAAM,sDAAsD;AAGxE,SAAO,uBAAuB,UAAU;UACjC,OAAO;AAGd,MACE,iBAAiB,UAChB,MAAM,QAAQ,SAAS,iBAAiB,IAAK,MAA4B,SAAS,SAEnF,QAAO;AAET,QAAM;;;;;;;;;;;;;;;AAgBV,SAAgB,6BACd,aACmB;AAKnB,QAAO,EAAE"}
@@ -1,172 +0,0 @@
1
- /**
2
- * Arktype schemas for SQL migration operation descriptors.
3
- *
4
- * These schemas are the source of truth for descriptor shapes.
5
- * TypeScript types are derived via `typeof schema.infer`.
6
- */
7
-
8
- import { type } from 'arktype';
9
-
10
- // ============================================================================
11
- // Table descriptors
12
- // ============================================================================
13
-
14
- export const CreateTableSchema = type({ kind: "'createTable'", table: 'string' });
15
- export const DropTableSchema = type({ kind: "'dropTable'", table: 'string' });
16
-
17
- // ============================================================================
18
- // Column descriptors
19
- // ============================================================================
20
-
21
- export const AddColumnSchema = type({
22
- kind: "'addColumn'",
23
- table: 'string',
24
- column: 'string',
25
- 'overrides?': { 'nullable?': 'boolean' },
26
- });
27
-
28
- export const DropColumnSchema = type({ kind: "'dropColumn'", table: 'string', column: 'string' });
29
-
30
- export const AlterColumnTypeSchema = type({
31
- kind: "'alterColumnType'",
32
- table: 'string',
33
- column: 'string',
34
- 'using?': 'string',
35
- 'toType?': 'string',
36
- });
37
-
38
- export const SetNotNullSchema = type({ kind: "'setNotNull'", table: 'string', column: 'string' });
39
- export const DropNotNullSchema = type({ kind: "'dropNotNull'", table: 'string', column: 'string' });
40
- export const SetDefaultSchema = type({ kind: "'setDefault'", table: 'string', column: 'string' });
41
- export const DropDefaultSchema = type({ kind: "'dropDefault'", table: 'string', column: 'string' });
42
-
43
- // ============================================================================
44
- // Constraint descriptors
45
- // ============================================================================
46
-
47
- export const AddPrimaryKeySchema = type({ kind: "'addPrimaryKey'", table: 'string' });
48
- export const AddUniqueSchema = type({ kind: "'addUnique'", table: 'string', columns: 'string[]' });
49
- export const AddForeignKeySchema = type({
50
- kind: "'addForeignKey'",
51
- table: 'string',
52
- columns: 'string[]',
53
- });
54
- export const DropConstraintSchema = type({
55
- kind: "'dropConstraint'",
56
- table: 'string',
57
- constraintName: 'string',
58
- });
59
-
60
- // ============================================================================
61
- // Index descriptors
62
- // ============================================================================
63
-
64
- export const CreateIndexSchema = type({
65
- kind: "'createIndex'",
66
- table: 'string',
67
- columns: 'string[]',
68
- });
69
- export const DropIndexSchema = type({
70
- kind: "'dropIndex'",
71
- table: 'string',
72
- indexName: 'string',
73
- });
74
-
75
- // ============================================================================
76
- // Type descriptors
77
- // ============================================================================
78
-
79
- export const CreateEnumTypeSchema = type({
80
- kind: "'createEnumType'",
81
- typeName: 'string',
82
- 'values?': 'string[]',
83
- });
84
- export const AddEnumValuesSchema = type({
85
- kind: "'addEnumValues'",
86
- typeName: 'string',
87
- values: 'string[]',
88
- });
89
- export const DropEnumTypeSchema = type({ kind: "'dropEnumType'", typeName: 'string' });
90
- export const RenameTypeSchema = type({
91
- kind: "'renameType'",
92
- fromName: 'string',
93
- toName: 'string',
94
- });
95
-
96
- // ============================================================================
97
- // Dependency descriptors
98
- // ============================================================================
99
-
100
- export const CreateDependencySchema = type({
101
- kind: "'createDependency'",
102
- dependencyId: 'string',
103
- });
104
-
105
- // ============================================================================
106
- // Data transform descriptor
107
- // ============================================================================
108
-
109
- export const DataTransformSchema = type({
110
- kind: "'dataTransform'",
111
- name: 'string',
112
- source: 'string',
113
- check: 'boolean | Function | symbol | object',
114
- run: '(Function | symbol | object)[]',
115
- });
116
-
117
- // ============================================================================
118
- // Union schema
119
- // ============================================================================
120
-
121
- export const SqlMigrationOpDescriptorSchema = type.or(
122
- CreateTableSchema,
123
- DropTableSchema,
124
- AddColumnSchema,
125
- DropColumnSchema,
126
- AlterColumnTypeSchema,
127
- SetNotNullSchema,
128
- DropNotNullSchema,
129
- SetDefaultSchema,
130
- DropDefaultSchema,
131
- AddPrimaryKeySchema,
132
- AddUniqueSchema,
133
- AddForeignKeySchema,
134
- DropConstraintSchema,
135
- CreateIndexSchema,
136
- DropIndexSchema,
137
- CreateEnumTypeSchema,
138
- AddEnumValuesSchema,
139
- DropEnumTypeSchema,
140
- RenameTypeSchema,
141
- CreateDependencySchema,
142
- DataTransformSchema,
143
- );
144
-
145
- export const MigrationDescriptorArraySchema = SqlMigrationOpDescriptorSchema.array();
146
-
147
- // ============================================================================
148
- // Derived types
149
- // ============================================================================
150
-
151
- export type CreateTableDescriptor = typeof CreateTableSchema.infer;
152
- export type DropTableDescriptor = typeof DropTableSchema.infer;
153
- export type AddColumnDescriptor = typeof AddColumnSchema.infer;
154
- export type DropColumnDescriptor = typeof DropColumnSchema.infer;
155
- export type AlterColumnTypeDescriptor = typeof AlterColumnTypeSchema.infer;
156
- export type SetNotNullDescriptor = typeof SetNotNullSchema.infer;
157
- export type DropNotNullDescriptor = typeof DropNotNullSchema.infer;
158
- export type SetDefaultDescriptor = typeof SetDefaultSchema.infer;
159
- export type DropDefaultDescriptor = typeof DropDefaultSchema.infer;
160
- export type AddPrimaryKeyDescriptor = typeof AddPrimaryKeySchema.infer;
161
- export type AddUniqueDescriptor = typeof AddUniqueSchema.infer;
162
- export type AddForeignKeyDescriptor = typeof AddForeignKeySchema.infer;
163
- export type DropConstraintDescriptor = typeof DropConstraintSchema.infer;
164
- export type CreateIndexDescriptor = typeof CreateIndexSchema.infer;
165
- export type DropIndexDescriptor = typeof DropIndexSchema.infer;
166
- export type CreateEnumTypeDescriptor = typeof CreateEnumTypeSchema.infer;
167
- export type AddEnumValuesDescriptor = typeof AddEnumValuesSchema.infer;
168
- export type DropEnumTypeDescriptor = typeof DropEnumTypeSchema.infer;
169
- export type RenameTypeDescriptor = typeof RenameTypeSchema.infer;
170
- export type CreateDependencyDescriptor = typeof CreateDependencySchema.infer;
171
- export type DataTransformDescriptor = typeof DataTransformSchema.infer;
172
- export type SqlMigrationOpDescriptor = typeof SqlMigrationOpDescriptorSchema.infer;
@@ -1,213 +0,0 @@
1
- /**
2
- * SQL migration operation descriptors — builder functions and re-exports.
3
- *
4
- * Types are defined by arktype schemas in descriptor-schemas.ts and derived
5
- * via `typeof schema.infer`. This file provides the builder functions that
6
- * construct descriptors, plus re-exports the types and schemas.
7
- */
8
-
9
- import type { SqlQueryPlan } from '@prisma-next/sql-relational-core/plan';
10
- import { ifDefined } from '@prisma-next/utils/defined';
11
-
12
- // Re-export types and schemas from the schema source of truth
13
- export type {
14
- AddColumnDescriptor,
15
- AddEnumValuesDescriptor,
16
- AddForeignKeyDescriptor,
17
- AddPrimaryKeyDescriptor,
18
- AddUniqueDescriptor,
19
- AlterColumnTypeDescriptor,
20
- CreateDependencyDescriptor,
21
- CreateEnumTypeDescriptor,
22
- CreateIndexDescriptor,
23
- CreateTableDescriptor,
24
- DataTransformDescriptor,
25
- DropColumnDescriptor,
26
- DropConstraintDescriptor,
27
- DropDefaultDescriptor,
28
- DropEnumTypeDescriptor,
29
- DropIndexDescriptor,
30
- DropNotNullDescriptor,
31
- DropTableDescriptor,
32
- RenameTypeDescriptor,
33
- SetDefaultDescriptor,
34
- SetNotNullDescriptor,
35
- SqlMigrationOpDescriptor,
36
- } from './descriptor-schemas';
37
-
38
- export { MigrationDescriptorArraySchema } from './descriptor-schemas';
39
-
40
- import type {
41
- AddColumnDescriptor,
42
- AddEnumValuesDescriptor,
43
- AddForeignKeyDescriptor,
44
- AddPrimaryKeyDescriptor,
45
- AddUniqueDescriptor,
46
- AlterColumnTypeDescriptor,
47
- CreateDependencyDescriptor,
48
- CreateEnumTypeDescriptor,
49
- CreateIndexDescriptor,
50
- CreateTableDescriptor,
51
- DropColumnDescriptor,
52
- DropConstraintDescriptor,
53
- DropDefaultDescriptor,
54
- DropEnumTypeDescriptor,
55
- DropIndexDescriptor,
56
- DropNotNullDescriptor,
57
- DropTableDescriptor,
58
- RenameTypeDescriptor,
59
- SetDefaultDescriptor,
60
- SetNotNullDescriptor,
61
- } from './descriptor-schemas';
62
-
63
- // ============================================================================
64
- // Data transform support types (not validated by arktype — runtime values)
65
- // ============================================================================
66
-
67
- /** Something that can produce a SqlQueryPlan via .build(). */
68
- export interface Buildable {
69
- build(): SqlQueryPlan;
70
- }
71
-
72
- /**
73
- * Sentinel value for unimplemented data transform queries.
74
- * The scaffold renders this as a TODO comment. The resolver throws if it encounters one.
75
- */
76
- export const TODO = Symbol.for('prisma-next.migration.todo');
77
- export type TodoMarker = typeof TODO;
78
-
79
- // ============================================================================
80
- // Builder functions
81
- // ============================================================================
82
-
83
- export function createTable(table: string): CreateTableDescriptor {
84
- return { kind: 'createTable', table };
85
- }
86
-
87
- export function dropTable(table: string): DropTableDescriptor {
88
- return { kind: 'dropTable', table };
89
- }
90
-
91
- export function addColumn(
92
- table: string,
93
- column: string,
94
- overrides?: { nullable?: boolean },
95
- ): AddColumnDescriptor {
96
- return { kind: 'addColumn', table, column, ...ifDefined('overrides', overrides) };
97
- }
98
-
99
- export function dropColumn(table: string, column: string): DropColumnDescriptor {
100
- return { kind: 'dropColumn', table, column };
101
- }
102
-
103
- export function alterColumnType(
104
- table: string,
105
- column: string,
106
- opts?: string | { using?: string; toType?: string },
107
- ): AlterColumnTypeDescriptor {
108
- const using = typeof opts === 'string' ? opts : opts?.using;
109
- const toType = typeof opts === 'string' ? undefined : opts?.toType;
110
- return {
111
- kind: 'alterColumnType',
112
- table,
113
- column,
114
- ...ifDefined('using', using),
115
- ...ifDefined('toType', toType),
116
- };
117
- }
118
-
119
- export function setNotNull(table: string, column: string): SetNotNullDescriptor {
120
- return { kind: 'setNotNull', table, column };
121
- }
122
-
123
- export function dropNotNull(table: string, column: string): DropNotNullDescriptor {
124
- return { kind: 'dropNotNull', table, column };
125
- }
126
-
127
- export function setDefault(table: string, column: string): SetDefaultDescriptor {
128
- return { kind: 'setDefault', table, column };
129
- }
130
-
131
- export function dropDefault(table: string, column: string): DropDefaultDescriptor {
132
- return { kind: 'dropDefault', table, column };
133
- }
134
-
135
- export function addPrimaryKey(table: string): AddPrimaryKeyDescriptor {
136
- return { kind: 'addPrimaryKey', table };
137
- }
138
-
139
- export function addUnique(table: string, columns: readonly string[]): AddUniqueDescriptor {
140
- return { kind: 'addUnique', table, columns: [...columns] };
141
- }
142
-
143
- export function addForeignKey(table: string, columns: readonly string[]): AddForeignKeyDescriptor {
144
- return { kind: 'addForeignKey', table, columns: [...columns] };
145
- }
146
-
147
- export function dropConstraint(table: string, constraintName: string): DropConstraintDescriptor {
148
- return { kind: 'dropConstraint', table, constraintName };
149
- }
150
-
151
- export function createIndex(table: string, columns: readonly string[]): CreateIndexDescriptor {
152
- return { kind: 'createIndex', table, columns: [...columns] };
153
- }
154
-
155
- export function dropIndex(table: string, indexName: string): DropIndexDescriptor {
156
- return { kind: 'dropIndex', table, indexName };
157
- }
158
-
159
- export function createEnumType(
160
- typeName: string,
161
- values?: readonly string[],
162
- ): CreateEnumTypeDescriptor {
163
- return {
164
- kind: 'createEnumType',
165
- typeName,
166
- ...ifDefined('values', values ? [...values] : undefined),
167
- };
168
- }
169
-
170
- export function addEnumValues(
171
- typeName: string,
172
- values: readonly string[],
173
- ): AddEnumValuesDescriptor {
174
- return { kind: 'addEnumValues', typeName, values: [...values] };
175
- }
176
-
177
- export function dropEnumType(typeName: string): DropEnumTypeDescriptor {
178
- return { kind: 'dropEnumType', typeName };
179
- }
180
-
181
- export function renameType(fromName: string, toName: string): RenameTypeDescriptor {
182
- return { kind: 'renameType', fromName, toName };
183
- }
184
-
185
- export function createDependency(dependencyId: string): CreateDependencyDescriptor {
186
- return { kind: 'createDependency', dependencyId };
187
- }
188
-
189
- /**
190
- * All structural builder functions keyed by descriptor kind.
191
- */
192
- export const builders = {
193
- createTable,
194
- dropTable,
195
- addColumn,
196
- dropColumn,
197
- alterColumnType,
198
- setNotNull,
199
- dropNotNull,
200
- setDefault,
201
- dropDefault,
202
- addPrimaryKey,
203
- addUnique,
204
- addForeignKey,
205
- dropConstraint,
206
- createIndex,
207
- dropIndex,
208
- createEnumType,
209
- addEnumValues,
210
- dropEnumType,
211
- renameType,
212
- createDependency,
213
- } as const;
@@ -1,52 +0,0 @@
1
- export type {
2
- AddColumnDescriptor,
3
- AddEnumValuesDescriptor,
4
- AddForeignKeyDescriptor,
5
- AddPrimaryKeyDescriptor,
6
- AddUniqueDescriptor,
7
- AlterColumnTypeDescriptor,
8
- CreateDependencyDescriptor,
9
- CreateEnumTypeDescriptor,
10
- CreateIndexDescriptor,
11
- CreateTableDescriptor,
12
- DataTransformDescriptor,
13
- DropColumnDescriptor,
14
- DropConstraintDescriptor,
15
- DropDefaultDescriptor,
16
- DropEnumTypeDescriptor,
17
- DropIndexDescriptor,
18
- DropNotNullDescriptor,
19
- DropTableDescriptor,
20
- RenameTypeDescriptor,
21
- SetDefaultDescriptor,
22
- SetNotNullDescriptor,
23
- SqlMigrationOpDescriptor,
24
- } from '../core/migrations/descriptor-schemas';
25
-
26
- export {
27
- addColumn,
28
- addEnumValues,
29
- addForeignKey,
30
- addPrimaryKey,
31
- addUnique,
32
- alterColumnType,
33
- type Buildable,
34
- builders,
35
- createDependency,
36
- createEnumType,
37
- createIndex,
38
- createTable,
39
- dropColumn,
40
- dropConstraint,
41
- dropDefault,
42
- dropEnumType,
43
- dropIndex,
44
- dropNotNull,
45
- dropTable,
46
- MigrationDescriptorArraySchema,
47
- renameType,
48
- setDefault,
49
- setNotNull,
50
- TODO,
51
- type TodoMarker,
52
- } from '../core/migrations/operation-descriptors';