@prisma-next/family-sql 0.5.0-dev.19 → 0.5.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.
package/package.json CHANGED
@@ -1,35 +1,35 @@
1
1
  {
2
2
  "name": "@prisma-next/family-sql",
3
- "version": "0.5.0-dev.19",
3
+ "version": "0.5.0-dev.20",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "description": "SQL family descriptor for Prisma Next",
7
7
  "dependencies": {
8
8
  "arktype": "^2.0.0",
9
- "@prisma-next/contract": "0.5.0-dev.19",
10
- "@prisma-next/emitter": "0.5.0-dev.19",
11
- "@prisma-next/framework-components": "0.5.0-dev.19",
12
- "@prisma-next/operations": "0.5.0-dev.19",
13
- "@prisma-next/sql-contract": "0.5.0-dev.19",
14
- "@prisma-next/sql-contract-emitter": "0.5.0-dev.19",
15
- "@prisma-next/migration-tools": "0.5.0-dev.19",
16
- "@prisma-next/sql-contract-ts": "0.5.0-dev.19",
17
- "@prisma-next/sql-operations": "0.5.0-dev.19",
18
- "@prisma-next/sql-relational-core": "0.5.0-dev.19",
19
- "@prisma-next/sql-runtime": "0.5.0-dev.19",
20
- "@prisma-next/sql-schema-ir": "0.5.0-dev.19",
21
- "@prisma-next/utils": "0.5.0-dev.19"
9
+ "@prisma-next/contract": "0.5.0-dev.20",
10
+ "@prisma-next/emitter": "0.5.0-dev.20",
11
+ "@prisma-next/framework-components": "0.5.0-dev.20",
12
+ "@prisma-next/migration-tools": "0.5.0-dev.20",
13
+ "@prisma-next/sql-contract": "0.5.0-dev.20",
14
+ "@prisma-next/operations": "0.5.0-dev.20",
15
+ "@prisma-next/sql-contract-emitter": "0.5.0-dev.20",
16
+ "@prisma-next/sql-contract-ts": "0.5.0-dev.20",
17
+ "@prisma-next/sql-relational-core": "0.5.0-dev.20",
18
+ "@prisma-next/sql-runtime": "0.5.0-dev.20",
19
+ "@prisma-next/utils": "0.5.0-dev.20",
20
+ "@prisma-next/sql-schema-ir": "0.5.0-dev.20",
21
+ "@prisma-next/sql-operations": "0.5.0-dev.20"
22
22
  },
23
23
  "devDependencies": {
24
24
  "tsdown": "0.18.4",
25
25
  "typescript": "5.9.3",
26
26
  "vitest": "4.0.17",
27
- "@prisma-next/psl-parser": "0.5.0-dev.19",
28
- "@prisma-next/sql-contract-psl": "0.5.0-dev.19",
27
+ "@prisma-next/driver-postgres": "0.5.0-dev.20",
28
+ "@prisma-next/psl-parser": "0.5.0-dev.20",
29
+ "@prisma-next/tsconfig": "0.0.0",
29
30
  "@prisma-next/test-utils": "0.0.1",
30
- "@prisma-next/driver-postgres": "0.5.0-dev.19",
31
31
  "@prisma-next/tsdown": "0.0.0",
32
- "@prisma-next/tsconfig": "0.0.0"
32
+ "@prisma-next/sql-contract-psl": "0.5.0-dev.20"
33
33
  },
34
34
  "files": [
35
35
  "dist",
@@ -1,3 +1,4 @@
1
+ import type { ContractMarkerRecord } from '@prisma-next/contract/types';
1
2
  import type {
2
3
  ControlAdapterInstance,
3
4
  ControlDriverInstance,
@@ -19,6 +20,17 @@ import type { DefaultNormalizer, NativeTypeNormalizer } from './schema-verify/ve
19
20
  */
20
21
  export interface SqlControlAdapter<TTarget extends string = string>
21
22
  extends ControlAdapterInstance<'sql', TTarget> {
23
+ /**
24
+ * Reads the contract marker from the database, returning `null` if the marker
25
+ * table or its row is missing. Implementations are responsible for the
26
+ * dialect-specific existence probe (e.g. Postgres `information_schema.tables`
27
+ * vs SQLite `sqlite_master`) and parameter placeholders.
28
+ *
29
+ * @param driver - ControlDriverInstance for executing queries (target-specific)
30
+ * @returns Resolved marker record, or `null` if not yet stamped.
31
+ */
32
+ readMarker(driver: ControlDriverInstance<'sql', TTarget>): Promise<ContractMarkerRecord | null>;
33
+
22
34
  /**
23
35
  * Introspects a database schema and returns a raw SqlSchemaIR.
24
36
  *
@@ -38,7 +38,7 @@ import type {
38
38
  SqlControlExtensionDescriptor,
39
39
  } from './migrations/types';
40
40
  import { verifySqlSchema } from './schema-verify/verify-sql-schema';
41
- import { collectSupportedCodecTypeIds, readMarker } from './verify';
41
+ import { collectSupportedCodecTypeIds } from './verify';
42
42
 
43
43
  function extractCodecTypeIdsFromContract(contract: unknown): readonly string[] {
44
44
  const typeIds = new Set<string>();
@@ -217,7 +217,9 @@ function isSqlControlAdapter<TTargetId extends string>(
217
217
  typeof value === 'object' &&
218
218
  value !== null &&
219
219
  'introspect' in value &&
220
- typeof (value as { introspect: unknown }).introspect === 'function'
220
+ typeof (value as { introspect: unknown }).introspect === 'function' &&
221
+ 'readMarker' in value &&
222
+ typeof (value as { readMarker: unknown }).readMarker === 'function'
221
223
  );
222
224
  }
223
225
 
@@ -293,6 +295,20 @@ export function createSqlFamilyInstance<TTargetId extends string>(
293
295
  extensionPacks: extensions,
294
296
  });
295
297
 
298
+ // Family-instance methods accept `ControlDriverInstance<'sql', string>` —
299
+ // the family API isn't generic on the target id. Letting `isSqlControlAdapter`
300
+ // default its type parameter narrows the adapter to `SqlControlAdapter<string>`,
301
+ // which matches the family-level driver type without any cast at call sites.
302
+ const getControlAdapter = () => {
303
+ const controlAdapter = adapter.create(stack);
304
+ if (!isSqlControlAdapter(controlAdapter)) {
305
+ throw new Error(
306
+ 'Adapter does not implement SqlControlAdapter (missing introspect or readMarker)',
307
+ );
308
+ }
309
+ return controlAdapter;
310
+ };
311
+
296
312
  return {
297
313
  familyId: 'sql',
298
314
  codecTypeImports,
@@ -326,7 +342,7 @@ export function createSqlFamilyInstance<TTargetId extends string>(
326
342
  const contractProfileHash = contract.profileHash;
327
343
  const contractTarget = contract.target;
328
344
 
329
- const marker = await readMarker(driver);
345
+ const marker = await getControlAdapter().readMarker(driver);
330
346
 
331
347
  let missingCodecs: readonly string[] | undefined;
332
348
  let codecCoverageSkipped = false;
@@ -435,10 +451,7 @@ export function createSqlFamilyInstance<TTargetId extends string>(
435
451
 
436
452
  const contract = sqlValidateContract<Contract<SqlStorage>>(contractInput, emptyCodecLookup);
437
453
 
438
- const controlAdapter = adapter.create(stack);
439
- if (!isSqlControlAdapter(controlAdapter)) {
440
- throw new Error('Adapter does not implement SqlControlAdapter.introspect()');
441
- }
454
+ const controlAdapter = getControlAdapter();
442
455
  const schemaIR = await controlAdapter.introspect(driver, contractInput);
443
456
 
444
457
  return verifySqlSchema({
@@ -474,7 +487,7 @@ export function createSqlFamilyInstance<TTargetId extends string>(
474
487
  await driver.query(ensureSchemaStatement.sql, ensureSchemaStatement.params);
475
488
  await driver.query(ensureTableStatement.sql, ensureTableStatement.params);
476
489
 
477
- const existingMarker = await readMarker(driver);
490
+ const existingMarker = await getControlAdapter().readMarker(driver);
478
491
 
479
492
  let markerCreated = false;
480
493
  let markerUpdated = false;
@@ -551,19 +564,13 @@ export function createSqlFamilyInstance<TTargetId extends string>(
551
564
  async readMarker(options: {
552
565
  readonly driver: ControlDriverInstance<'sql', string>;
553
566
  }): Promise<ContractMarkerRecord | null> {
554
- return readMarker(options.driver);
567
+ return getControlAdapter().readMarker(options.driver);
555
568
  },
556
569
  async introspect(options: {
557
570
  readonly driver: ControlDriverInstance<'sql', string>;
558
571
  readonly contract?: unknown;
559
572
  }): Promise<SqlSchemaIR> {
560
- const { driver, contract } = options;
561
-
562
- const controlAdapter = adapter.create(stack);
563
- if (!isSqlControlAdapter(controlAdapter)) {
564
- throw new Error('Adapter does not implement SqlControlAdapter.introspect()');
565
- }
566
- return controlAdapter.introspect(driver, contract);
573
+ return getControlAdapter().introspect(options.driver, options.contract);
567
574
  },
568
575
 
569
576
  toSchemaView(schema: SqlSchemaIR): CoreSchemaView {
@@ -311,6 +311,7 @@ export type SqlMigrationRunnerErrorCode =
311
311
  | 'PRECHECK_FAILED'
312
312
  | 'POSTCHECK_FAILED'
313
313
  | 'SCHEMA_VERIFY_FAILED'
314
+ | 'FOREIGN_KEY_VIOLATION'
314
315
  | 'EXECUTION_FAILED';
315
316
 
316
317
  export interface SqlMigrationRunnerFailure extends MigrationRunnerFailure {
@@ -1,5 +1,4 @@
1
1
  import type { ContractMarkerRecord } from '@prisma-next/contract/types';
2
- import type { ControlDriverInstance } from '@prisma-next/framework-components/control';
3
2
  import { type } from 'arktype';
4
3
 
5
4
  const MetaSchema = type({ '[string]': 'unknown' });
@@ -28,6 +27,40 @@ function parseMeta(meta: unknown): Record<string, unknown> {
28
27
  return result as Record<string, unknown>;
29
28
  }
30
29
 
30
+ /**
31
+ * SQLite stores `contract_json` as TEXT, so the wire shape is a JSON string;
32
+ * Postgres uses `jsonb` and returns an already-parsed value. Normalize both
33
+ * here so `ContractMarkerRecord.contractJson` is always the structured form.
34
+ */
35
+ function parseContractJson(value: unknown): unknown {
36
+ if (value === null || value === undefined) return null;
37
+ if (typeof value !== 'string') return value;
38
+ try {
39
+ return JSON.parse(value);
40
+ } catch {
41
+ return null;
42
+ }
43
+ }
44
+
45
+ /**
46
+ * Wire shape of a `prisma_contract.marker` row as it comes out of a SQL
47
+ * driver. Snake-cased to match the on-disk column names. Shared by every
48
+ * SQL target's `readMarker` so each runner doesn't redeclare it inline.
49
+ */
50
+ export type ContractMarkerRow = {
51
+ core_hash: string;
52
+ profile_hash: string;
53
+ contract_json: unknown | null;
54
+ canonical_version: number | null;
55
+ updated_at: Date | string;
56
+ app_tag: string | null;
57
+ meta: unknown | null;
58
+ // SQLite stores arrays as JSON-TEXT, so this is `string` on the wire from
59
+ // a SQLite driver and `string[]` from a Postgres driver. Targets normalize
60
+ // before passing to `parseContractMarkerRow`.
61
+ invariants: unknown;
62
+ };
63
+
31
64
  const ContractMarkerRowSchema = type({
32
65
  core_hash: 'string',
33
66
  profile_hash: 'string',
@@ -59,7 +92,7 @@ export function parseContractMarkerRow(row: unknown): ContractMarkerRecord {
59
92
  return {
60
93
  storageHash: result.core_hash,
61
94
  profileHash: result.profile_hash,
62
- contractJson: result.contract_json ?? null,
95
+ contractJson: parseContractJson(result.contract_json),
63
96
  canonicalVersion: result.canonical_version ?? null,
64
97
  updatedAt,
65
98
  appTag: result.app_tag ?? null,
@@ -68,95 +101,6 @@ export function parseContractMarkerRow(row: unknown): ContractMarkerRecord {
68
101
  };
69
102
  }
70
103
 
71
- /**
72
- * Returns the SQL statement to read the contract marker.
73
- * This is a migration-plane helper (no runtime imports).
74
- * @internal - Used internally by readMarker(). Prefer readMarker() for Control Plane usage.
75
- */
76
- export function readMarkerSql(): { readonly sql: string; readonly params: readonly unknown[] } {
77
- return {
78
- sql: `select
79
- core_hash,
80
- profile_hash,
81
- contract_json,
82
- canonical_version,
83
- updated_at,
84
- app_tag,
85
- meta,
86
- invariants
87
- from prisma_contract.marker
88
- where id = $1`,
89
- params: [1],
90
- };
91
- }
92
-
93
- /**
94
- * Returns the SQL statement that probes for the existence of the marker table.
95
- * Uses the SQL-standard `information_schema.tables` view so the query succeeds
96
- * (returning zero rows) when the table has not been created yet — avoiding a
97
- * `relation does not exist` error. Some Postgres wire-protocol implementations
98
- * (e.g. PGlite's TCP proxy) do not fully recover from an extended-protocol
99
- * parse error, so we probe first instead of relying on an error signal.
100
- * @internal - Used internally by readMarker().
101
- */
102
- export function markerTableExistsSql(): {
103
- readonly sql: string;
104
- readonly params: readonly unknown[];
105
- } {
106
- return {
107
- sql: `select 1
108
- from information_schema.tables
109
- where table_schema = $1 and table_name = $2`,
110
- params: ['prisma_contract', 'marker'],
111
- };
112
- }
113
-
114
- /**
115
- * Reads the contract marker from the database using the provided driver.
116
- * Returns the parsed marker record or null if no marker is found.
117
- * This abstracts SQL-specific details from the Control Plane.
118
- *
119
- * @param driver - ControlDriverInstance instance for executing queries
120
- * @returns Promise resolving to ContractMarkerRecord or null if marker not found
121
- */
122
- export async function readMarker(
123
- driver: ControlDriverInstance<'sql', string>,
124
- ): Promise<ContractMarkerRecord | null> {
125
- // Probe for the marker table first so that a fresh database (no
126
- // `prisma_contract` schema) returns null cleanly instead of surfacing a
127
- // `relation does not exist` error. This keeps the control connection in a
128
- // predictable state for driver implementations that are sensitive to
129
- // extended-protocol parse errors.
130
- const existsStatement = markerTableExistsSql();
131
- const existsResult = await driver.query(existsStatement.sql, existsStatement.params);
132
- if (existsResult.rows.length === 0) {
133
- return null;
134
- }
135
-
136
- const markerStatement = readMarkerSql();
137
- const queryResult = await driver.query<{
138
- core_hash: string;
139
- profile_hash: string;
140
- contract_json: unknown | null;
141
- canonical_version: number | null;
142
- updated_at: Date | string;
143
- app_tag: string | null;
144
- meta: unknown | null;
145
- invariants: readonly string[];
146
- }>(markerStatement.sql, markerStatement.params);
147
-
148
- if (queryResult.rows.length === 0) {
149
- return null;
150
- }
151
-
152
- const markerRow = queryResult.rows[0];
153
- if (!markerRow) {
154
- throw new Error('Database query returned unexpected result structure');
155
- }
156
-
157
- return parseContractMarkerRow(markerRow);
158
- }
159
-
160
104
  /**
161
105
  * Collects supported codec type IDs from adapter and extension manifests.
162
106
  * Returns a sorted, unique array of type IDs that are declared in the manifests.
@@ -1 +1 @@
1
- export { parseContractMarkerRow, readMarker, readMarkerSql } from '../core/verify';
1
+ export { type ContractMarkerRow, parseContractMarkerRow } from '../core/verify';
@@ -1,124 +0,0 @@
1
- import { type } from "arktype";
2
-
3
- //#region src/core/verify.ts
4
- const MetaSchema = type({ "[string]": "unknown" });
5
- function parseMeta(meta) {
6
- if (meta === null || meta === void 0) return {};
7
- let parsed;
8
- if (typeof meta === "string") try {
9
- parsed = JSON.parse(meta);
10
- } catch {
11
- return {};
12
- }
13
- else parsed = meta;
14
- const result = MetaSchema(parsed);
15
- if (result instanceof type.errors) return {};
16
- return result;
17
- }
18
- const ContractMarkerRowSchema = type({
19
- core_hash: "string",
20
- profile_hash: "string",
21
- "contract_json?": "unknown | null",
22
- "canonical_version?": "number | null",
23
- "updated_at?": "Date | string",
24
- "app_tag?": "string | null",
25
- "meta?": "unknown | null",
26
- invariants: type("string").array()
27
- });
28
- /**
29
- * Parses a contract marker row from database query result.
30
- * This is SQL-specific parsing logic (handles SQL row structure with snake_case columns).
31
- */
32
- function parseContractMarkerRow(row) {
33
- const result = ContractMarkerRowSchema(row);
34
- if (result instanceof type.errors) {
35
- const messages = result.map((p) => p.message).join("; ");
36
- throw new Error(`Invalid contract marker row: ${messages}`);
37
- }
38
- const updatedAt = result.updated_at ? result.updated_at instanceof Date ? result.updated_at : new Date(result.updated_at) : /* @__PURE__ */ new Date();
39
- return {
40
- storageHash: result.core_hash,
41
- profileHash: result.profile_hash,
42
- contractJson: result.contract_json ?? null,
43
- canonicalVersion: result.canonical_version ?? null,
44
- updatedAt,
45
- appTag: result.app_tag ?? null,
46
- meta: parseMeta(result.meta),
47
- invariants: result.invariants
48
- };
49
- }
50
- /**
51
- * Returns the SQL statement to read the contract marker.
52
- * This is a migration-plane helper (no runtime imports).
53
- * @internal - Used internally by readMarker(). Prefer readMarker() for Control Plane usage.
54
- */
55
- function readMarkerSql() {
56
- return {
57
- sql: `select
58
- core_hash,
59
- profile_hash,
60
- contract_json,
61
- canonical_version,
62
- updated_at,
63
- app_tag,
64
- meta,
65
- invariants
66
- from prisma_contract.marker
67
- where id = $1`,
68
- params: [1]
69
- };
70
- }
71
- /**
72
- * Returns the SQL statement that probes for the existence of the marker table.
73
- * Uses the SQL-standard `information_schema.tables` view so the query succeeds
74
- * (returning zero rows) when the table has not been created yet — avoiding a
75
- * `relation does not exist` error. Some Postgres wire-protocol implementations
76
- * (e.g. PGlite's TCP proxy) do not fully recover from an extended-protocol
77
- * parse error, so we probe first instead of relying on an error signal.
78
- * @internal - Used internally by readMarker().
79
- */
80
- function markerTableExistsSql() {
81
- return {
82
- sql: `select 1
83
- from information_schema.tables
84
- where table_schema = $1 and table_name = $2`,
85
- params: ["prisma_contract", "marker"]
86
- };
87
- }
88
- /**
89
- * Reads the contract marker from the database using the provided driver.
90
- * Returns the parsed marker record or null if no marker is found.
91
- * This abstracts SQL-specific details from the Control Plane.
92
- *
93
- * @param driver - ControlDriverInstance instance for executing queries
94
- * @returns Promise resolving to ContractMarkerRecord or null if marker not found
95
- */
96
- async function readMarker(driver) {
97
- const existsStatement = markerTableExistsSql();
98
- if ((await driver.query(existsStatement.sql, existsStatement.params)).rows.length === 0) return null;
99
- const markerStatement = readMarkerSql();
100
- const queryResult = await driver.query(markerStatement.sql, markerStatement.params);
101
- if (queryResult.rows.length === 0) return null;
102
- const markerRow = queryResult.rows[0];
103
- if (!markerRow) throw new Error("Database query returned unexpected result structure");
104
- return parseContractMarkerRow(markerRow);
105
- }
106
- /**
107
- * Collects supported codec type IDs from adapter and extension manifests.
108
- * Returns a sorted, unique array of type IDs that are declared in the manifests.
109
- * This enables coverage checks by comparing contract column types against supported types.
110
- *
111
- * Note: This extracts type IDs from manifest type imports, not from runtime codec registries.
112
- * The manifests declare which codec types are available, but the actual type IDs
113
- * are defined in the codec-types TypeScript modules that are imported.
114
- *
115
- * For MVP, we return an empty array since extracting type IDs from TypeScript modules
116
- * would require runtime evaluation or static analysis. This can be enhanced later.
117
- */
118
- function collectSupportedCodecTypeIds(descriptors) {
119
- return [];
120
- }
121
-
122
- //#endregion
123
- export { readMarkerSql as i, parseContractMarkerRow as n, readMarker as r, collectSupportedCodecTypeIds as t };
124
- //# sourceMappingURL=verify-xsruyH5V.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"verify-xsruyH5V.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 invariants: type('string').array(),\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 updatedAt = result.updated_at\n ? result.updated_at instanceof Date\n ? result.updated_at\n : new Date(result.updated_at)\n : new Date();\n\n return {\n storageHash: result.core_hash,\n profileHash: result.profile_hash,\n contractJson: result.contract_json ?? null,\n canonicalVersion: result.canonical_version ?? null,\n updatedAt,\n appTag: result.app_tag ?? null,\n meta: parseMeta(result.meta),\n invariants: result.invariants,\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 invariants\n from prisma_contract.marker\n where id = $1`,\n params: [1],\n };\n}\n\n/**\n * Returns the SQL statement that probes for the existence of the marker table.\n * Uses the SQL-standard `information_schema.tables` view so the query succeeds\n * (returning zero rows) when the table has not been created yet — avoiding a\n * `relation does not exist` error. Some Postgres wire-protocol implementations\n * (e.g. PGlite's TCP proxy) do not fully recover from an extended-protocol\n * parse error, so we probe first instead of relying on an error signal.\n * @internal - Used internally by readMarker().\n */\nexport function markerTableExistsSql(): {\n readonly sql: string;\n readonly params: readonly unknown[];\n} {\n return {\n sql: `select 1\n from information_schema.tables\n where table_schema = $1 and table_name = $2`,\n params: ['prisma_contract', 'marker'],\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 // Probe for the marker table first so that a fresh database (no\n // `prisma_contract` schema) returns null cleanly instead of surfacing a\n // `relation does not exist` error. This keeps the control connection in a\n // predictable state for driver implementations that are sensitive to\n // extended-protocol parse errors.\n const existsStatement = markerTableExistsSql();\n const existsResult = await driver.query(existsStatement.sql, existsStatement.params);\n if (existsResult.rows.length === 0) {\n return null;\n }\n\n const markerStatement = readMarkerSql();\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 invariants: readonly string[];\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 throw new Error('Database query returned unexpected result structure');\n }\n\n return parseContractMarkerRow(markerRow);\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,SAA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