@prisma-next/family-sql 0.3.0-pr.93.5 → 0.3.0-pr.94.2

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 (85) hide show
  1. package/dist/control-adapter.d.mts +47 -0
  2. package/dist/control-adapter.d.mts.map +1 -0
  3. package/dist/control-adapter.mjs +1 -0
  4. package/dist/control.d.mts +65 -0
  5. package/dist/control.d.mts.map +1 -0
  6. package/dist/control.mjs +136 -0
  7. package/dist/control.mjs.map +1 -0
  8. package/dist/instance-B_PdDN4y.mjs +525 -0
  9. package/dist/instance-B_PdDN4y.mjs.map +1 -0
  10. package/dist/instance-wm4TrZN0.d.mts +130 -0
  11. package/dist/instance-wm4TrZN0.d.mts.map +1 -0
  12. package/dist/runtime.d.mts +70 -0
  13. package/dist/runtime.d.mts.map +1 -0
  14. package/dist/runtime.mjs +74 -0
  15. package/dist/runtime.mjs.map +1 -0
  16. package/dist/schema-verify.d.mts +85 -0
  17. package/dist/schema-verify.d.mts.map +1 -0
  18. package/dist/schema-verify.mjs +3 -0
  19. package/dist/test-utils.d.mts +31 -0
  20. package/dist/test-utils.d.mts.map +1 -0
  21. package/dist/test-utils.mjs +5 -0
  22. package/dist/types-D5CPT9N4.d.mts +270 -0
  23. package/dist/types-D5CPT9N4.d.mts.map +1 -0
  24. package/dist/verify-DhFytkFC.mjs +108 -0
  25. package/dist/verify-DhFytkFC.mjs.map +1 -0
  26. package/dist/verify-sql-schema-BnLVoeWI.mjs +686 -0
  27. package/dist/verify-sql-schema-BnLVoeWI.mjs.map +1 -0
  28. package/dist/verify.d.mts +31 -0
  29. package/dist/verify.d.mts.map +1 -0
  30. package/dist/verify.mjs +3 -0
  31. package/package.json +30 -43
  32. package/dist/chunk-F27CR6XZ.js +0 -589
  33. package/dist/chunk-F27CR6XZ.js.map +0 -1
  34. package/dist/chunk-SU7LN2UH.js +0 -96
  35. package/dist/chunk-SU7LN2UH.js.map +0 -1
  36. package/dist/chunk-XH2Y5NTD.js +0 -715
  37. package/dist/chunk-XH2Y5NTD.js.map +0 -1
  38. package/dist/core/assembly.d.ts +0 -25
  39. package/dist/core/assembly.d.ts.map +0 -1
  40. package/dist/core/control-adapter.d.ts +0 -42
  41. package/dist/core/control-adapter.d.ts.map +0 -1
  42. package/dist/core/descriptor.d.ts +0 -24
  43. package/dist/core/descriptor.d.ts.map +0 -1
  44. package/dist/core/instance.d.ts +0 -140
  45. package/dist/core/instance.d.ts.map +0 -1
  46. package/dist/core/migrations/plan-helpers.d.ts +0 -20
  47. package/dist/core/migrations/plan-helpers.d.ts.map +0 -1
  48. package/dist/core/migrations/policies.d.ts +0 -6
  49. package/dist/core/migrations/policies.d.ts.map +0 -1
  50. package/dist/core/migrations/types.d.ts +0 -280
  51. package/dist/core/migrations/types.d.ts.map +0 -1
  52. package/dist/core/runtime-descriptor.d.ts +0 -19
  53. package/dist/core/runtime-descriptor.d.ts.map +0 -1
  54. package/dist/core/runtime-instance.d.ts +0 -54
  55. package/dist/core/runtime-instance.d.ts.map +0 -1
  56. package/dist/core/schema-verify/verify-helpers.d.ts +0 -96
  57. package/dist/core/schema-verify/verify-helpers.d.ts.map +0 -1
  58. package/dist/core/schema-verify/verify-sql-schema.d.ts +0 -45
  59. package/dist/core/schema-verify/verify-sql-schema.d.ts.map +0 -1
  60. package/dist/core/verify.d.ts +0 -39
  61. package/dist/core/verify.d.ts.map +0 -1
  62. package/dist/exports/control-adapter.d.ts +0 -2
  63. package/dist/exports/control-adapter.d.ts.map +0 -1
  64. package/dist/exports/control-adapter.js +0 -1
  65. package/dist/exports/control-adapter.js.map +0 -1
  66. package/dist/exports/control.d.ts +0 -13
  67. package/dist/exports/control.d.ts.map +0 -1
  68. package/dist/exports/control.js +0 -149
  69. package/dist/exports/control.js.map +0 -1
  70. package/dist/exports/runtime.d.ts +0 -8
  71. package/dist/exports/runtime.d.ts.map +0 -1
  72. package/dist/exports/runtime.js +0 -64
  73. package/dist/exports/runtime.js.map +0 -1
  74. package/dist/exports/schema-verify.d.ts +0 -11
  75. package/dist/exports/schema-verify.d.ts.map +0 -1
  76. package/dist/exports/schema-verify.js +0 -15
  77. package/dist/exports/schema-verify.js.map +0 -1
  78. package/dist/exports/test-utils.d.ts +0 -7
  79. package/dist/exports/test-utils.d.ts.map +0 -1
  80. package/dist/exports/test-utils.js +0 -17
  81. package/dist/exports/test-utils.js.map +0 -1
  82. package/dist/exports/verify.d.ts +0 -2
  83. package/dist/exports/verify.d.ts.map +0 -1
  84. package/dist/exports/verify.js +0 -11
  85. package/dist/exports/verify.js.map +0 -1
@@ -0,0 +1,270 @@
1
+ import { n as SqlControlFamilyInstance } from "./instance-wm4TrZN0.mjs";
2
+ import { Result } from "@prisma-next/utils/result";
3
+ import { ControlDriverInstance, ControlExtensionDescriptor, ControlTargetDescriptor, ControlTargetInstance, MigrationOperationPolicy, MigrationPlan, MigrationPlanOperation, MigrationPlannerConflict, MigrationPlannerFailureResult, MigrationPlannerSuccessResult, MigrationRunnerExecutionChecks, MigrationRunnerFailure, MigrationRunnerSuccessValue, OperationContext, SchemaIssue } from "@prisma-next/core-control-plane/types";
4
+ import { SqlSchemaIR } from "@prisma-next/sql-schema-ir/types";
5
+ import { SqlContract, SqlStorage } from "@prisma-next/sql-contract/types";
6
+ import { TargetBoundComponentDescriptor } from "@prisma-next/contract/framework-components";
7
+
8
+ //#region src/core/migrations/types.d.ts
9
+
10
+ type AnyRecord = Readonly<Record<string, unknown>>;
11
+ /**
12
+ * A single database dependency declared by a framework component.
13
+ * Uses SqlMigrationPlanOperation so we inherit the existing precheck/execute/postcheck contract.
14
+ *
15
+ * Database dependencies allow components (extensions, adapters) to declare what database-side
16
+ * persistence structures they require (e.g., Postgres extensions, schemas, functions).
17
+ * The planner emits these as migration operations, and the verifier uses the pure verification
18
+ * hook to check satisfaction against the schema IR.
19
+ */
20
+ interface ComponentDatabaseDependency<TTargetDetails> {
21
+ /** Stable identifier for the dependency (e.g. 'postgres.extension.vector') */
22
+ readonly id: string;
23
+ /** Human label for output (e.g. 'Enable vector extension') */
24
+ readonly label: string;
25
+ /**
26
+ * Operations that install/ensure the dependency.
27
+ * Use SqlMigrationPlanOperation so we inherit the existing precheck/execute/postcheck contract.
28
+ */
29
+ readonly install: readonly SqlMigrationPlanOperation<TTargetDetails>[];
30
+ /**
31
+ * Pure verification hook: checks whether this dependency is already installed
32
+ * based on the in-memory schema IR (no DB I/O).
33
+ *
34
+ * This must return structured issues suitable for CLI and tree output, not just a boolean.
35
+ */
36
+ readonly verifyDatabaseDependencyInstalled: (schema: SqlSchemaIR) => readonly SchemaIssue[];
37
+ }
38
+ /**
39
+ * Database dependencies declared by a framework component.
40
+ */
41
+ interface ComponentDatabaseDependencies<TTargetDetails> {
42
+ /**
43
+ * Dependencies required for db init.
44
+ * Future: update dependencies can be added later (e.g. widening/destructive).
45
+ */
46
+ readonly init?: readonly ComponentDatabaseDependency<TTargetDetails>[];
47
+ }
48
+ /**
49
+ * SQL-specific extension descriptor with optional database dependencies.
50
+ * Extends the core ControlExtensionDescriptor with SQL-specific metadata.
51
+ *
52
+ * Database dependencies are attached to the descriptor (not the instance) because
53
+ * they are declarative metadata that planner/verifier need without constructing instances.
54
+ */
55
+ interface SqlControlExtensionDescriptor<TTargetId extends string> extends ControlExtensionDescriptor<'sql', TTargetId> {
56
+ /** Optional database dependencies this extension requires. */
57
+ readonly databaseDependencies?: ComponentDatabaseDependencies<unknown>;
58
+ }
59
+ /**
60
+ * A single step in a SQL migration operation (precheck, execute, or postcheck).
61
+ */
62
+ interface SqlMigrationPlanOperationStep {
63
+ readonly description: string;
64
+ readonly sql: string;
65
+ readonly meta?: AnyRecord;
66
+ }
67
+ /**
68
+ * Target details for a SQL migration operation (table, column, index, etc.).
69
+ */
70
+ interface SqlMigrationPlanOperationTarget<TTargetDetails> {
71
+ readonly id: string;
72
+ readonly details?: TTargetDetails;
73
+ }
74
+ /**
75
+ * A single SQL migration operation with SQL-specific fields.
76
+ * Extends the core MigrationPlanOperation with SQL execution details.
77
+ */
78
+ interface SqlMigrationPlanOperation<TTargetDetails> extends MigrationPlanOperation {
79
+ /** Optional detailed explanation of what this operation does and why. */
80
+ readonly summary?: string;
81
+ readonly target: SqlMigrationPlanOperationTarget<TTargetDetails>;
82
+ readonly precheck: readonly SqlMigrationPlanOperationStep[];
83
+ readonly execute: readonly SqlMigrationPlanOperationStep[];
84
+ readonly postcheck: readonly SqlMigrationPlanOperationStep[];
85
+ readonly meta?: AnyRecord;
86
+ }
87
+ /**
88
+ * Contract identity information for SQL migrations.
89
+ */
90
+ interface SqlMigrationPlanContractInfo {
91
+ readonly coreHash: string;
92
+ readonly profileHash?: string;
93
+ }
94
+ /**
95
+ * A SQL migration plan with SQL-specific fields.
96
+ * Extends the core MigrationPlan with origin tracking and metadata.
97
+ */
98
+ interface SqlMigrationPlan<TTargetDetails> extends MigrationPlan {
99
+ /**
100
+ * Origin contract identity that the plan expects the database to currently be at.
101
+ * If omitted, the runner treats the origin as "no marker present" (empty database),
102
+ * and will only proceed if no marker exists (or if the marker already matches destination).
103
+ */
104
+ readonly origin?: SqlMigrationPlanContractInfo | null;
105
+ /**
106
+ * Destination contract identity that the plan intends to reach.
107
+ */
108
+ readonly destination: SqlMigrationPlanContractInfo;
109
+ readonly operations: readonly SqlMigrationPlanOperation<TTargetDetails>[];
110
+ readonly meta?: AnyRecord;
111
+ }
112
+ /**
113
+ * Specific conflict kinds for SQL migrations.
114
+ */
115
+ type SqlPlannerConflictKind = 'typeMismatch' | 'nullabilityConflict' | 'indexIncompatible' | 'foreignKeyConflict' | 'missingButNonAdditive' | 'unsupportedExtension' | 'extensionMissing' | 'unsupportedOperation';
116
+ /**
117
+ * Location information for SQL planner conflicts.
118
+ */
119
+ interface SqlPlannerConflictLocation {
120
+ readonly table?: string;
121
+ readonly column?: string;
122
+ readonly index?: string;
123
+ readonly constraint?: string;
124
+ readonly extension?: string;
125
+ }
126
+ /**
127
+ * A SQL-specific planner conflict with additional location information.
128
+ * Extends the core MigrationPlannerConflict.
129
+ */
130
+ interface SqlPlannerConflict extends MigrationPlannerConflict {
131
+ readonly kind: SqlPlannerConflictKind;
132
+ readonly location?: SqlPlannerConflictLocation;
133
+ readonly meta?: AnyRecord;
134
+ }
135
+ /**
136
+ * Successful SQL planner result with the migration plan.
137
+ */
138
+ interface SqlPlannerSuccessResult<TTargetDetails> extends Omit<MigrationPlannerSuccessResult, 'plan'> {
139
+ readonly kind: 'success';
140
+ readonly plan: SqlMigrationPlan<TTargetDetails>;
141
+ }
142
+ /**
143
+ * Failed SQL planner result with the list of conflicts.
144
+ */
145
+ interface SqlPlannerFailureResult extends Omit<MigrationPlannerFailureResult, 'conflicts'> {
146
+ readonly kind: 'failure';
147
+ readonly conflicts: readonly SqlPlannerConflict[];
148
+ }
149
+ /**
150
+ * Union type for SQL planner results.
151
+ */
152
+ type SqlPlannerResult<TTargetDetails> = SqlPlannerSuccessResult<TTargetDetails> | SqlPlannerFailureResult;
153
+ /**
154
+ * Options for SQL migration planner.
155
+ */
156
+ interface SqlMigrationPlannerPlanOptions {
157
+ readonly contract: SqlContract<SqlStorage>;
158
+ readonly schema: SqlSchemaIR;
159
+ readonly policy: MigrationOperationPolicy;
160
+ readonly schemaName?: string;
161
+ /**
162
+ * Active framework components participating in this composition.
163
+ * SQL targets can interpret this list to derive database dependencies.
164
+ * All components must have matching familyId ('sql') and targetId.
165
+ */
166
+ readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;
167
+ }
168
+ /**
169
+ * SQL migration planner interface.
170
+ * Extends the core MigrationPlanner with SQL-specific types.
171
+ */
172
+ interface SqlMigrationPlanner<TTargetDetails> {
173
+ plan(options: SqlMigrationPlannerPlanOptions): SqlPlannerResult<TTargetDetails>;
174
+ }
175
+ /**
176
+ * Callbacks for SQL migration runner execution.
177
+ */
178
+ interface SqlMigrationRunnerExecuteCallbacks<TTargetDetails> {
179
+ onOperationStart?(operation: SqlMigrationPlanOperation<TTargetDetails>): void;
180
+ onOperationComplete?(operation: SqlMigrationPlanOperation<TTargetDetails>): void;
181
+ }
182
+ /**
183
+ * Options for SQL migration runner execution.
184
+ */
185
+ interface SqlMigrationRunnerExecuteOptions<TTargetDetails> {
186
+ readonly plan: SqlMigrationPlan<TTargetDetails>;
187
+ readonly driver: ControlDriverInstance<'sql', string>;
188
+ /**
189
+ * Destination contract IR.
190
+ * Must correspond to `plan.destination` and is used for schema verification and marker/ledger writes.
191
+ */
192
+ readonly destinationContract: SqlContract<SqlStorage>;
193
+ /**
194
+ * Execution-time policy that defines which operation classes are allowed.
195
+ * The runner validates each operation against this policy before execution.
196
+ */
197
+ readonly policy: MigrationOperationPolicy;
198
+ readonly schemaName?: string;
199
+ readonly strictVerification?: boolean;
200
+ readonly callbacks?: SqlMigrationRunnerExecuteCallbacks<TTargetDetails>;
201
+ readonly context?: OperationContext;
202
+ /**
203
+ * Execution-time checks configuration.
204
+ * All checks default to `true` (enabled) when omitted.
205
+ */
206
+ readonly executionChecks?: MigrationRunnerExecutionChecks;
207
+ /**
208
+ * Active framework components participating in this composition.
209
+ * SQL targets can interpret this list to derive database dependencies.
210
+ * All components must have matching familyId ('sql') and targetId.
211
+ */
212
+ readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;
213
+ }
214
+ /**
215
+ * Error codes for SQL migration runner failures.
216
+ */
217
+ type SqlMigrationRunnerErrorCode = 'DESTINATION_CONTRACT_MISMATCH' | 'MARKER_ORIGIN_MISMATCH' | 'POLICY_VIOLATION' | 'PRECHECK_FAILED' | 'POSTCHECK_FAILED' | 'SCHEMA_VERIFY_FAILED' | 'EXECUTION_FAILED';
218
+ /**
219
+ * Detailed information about a SQL migration runner failure.
220
+ * Extends the core MigrationRunnerFailure with SQL-specific error codes.
221
+ */
222
+ interface SqlMigrationRunnerFailure extends MigrationRunnerFailure {
223
+ readonly code: SqlMigrationRunnerErrorCode;
224
+ readonly meta?: AnyRecord;
225
+ }
226
+ /**
227
+ * Success value for SQL migration runner execution.
228
+ * Extends core type for type branding and potential SQL-specific extensions.
229
+ */
230
+ interface SqlMigrationRunnerSuccessValue extends MigrationRunnerSuccessValue {}
231
+ /**
232
+ * Result type for SQL migration runner execution.
233
+ */
234
+ type SqlMigrationRunnerResult = Result<SqlMigrationRunnerSuccessValue, SqlMigrationRunnerFailure>;
235
+ /**
236
+ * SQL migration runner interface.
237
+ * Extends the core MigrationRunner with SQL-specific types.
238
+ */
239
+ interface SqlMigrationRunner<TTargetDetails> {
240
+ execute(options: SqlMigrationRunnerExecuteOptions<TTargetDetails>): Promise<SqlMigrationRunnerResult>;
241
+ }
242
+ /**
243
+ * SQL control target descriptor with migration support.
244
+ * Extends the core ControlTargetDescriptor with SQL-specific migration methods.
245
+ */
246
+ interface SqlControlTargetDescriptor<TTargetId extends string, TTargetDetails> extends ControlTargetDescriptor<'sql', TTargetId, ControlTargetInstance<'sql', TTargetId>, SqlControlFamilyInstance> {
247
+ /**
248
+ * Creates a SQL migration planner for this target.
249
+ * Direct method for SQL-specific usage.
250
+ */
251
+ createPlanner(family: SqlControlFamilyInstance): SqlMigrationPlanner<TTargetDetails>;
252
+ /**
253
+ * Creates a SQL migration runner for this target.
254
+ * Direct method for SQL-specific usage.
255
+ */
256
+ createRunner(family: SqlControlFamilyInstance): SqlMigrationRunner<TTargetDetails>;
257
+ }
258
+ /**
259
+ * Options for creating a SQL migration plan.
260
+ */
261
+ interface CreateSqlMigrationPlanOptions<TTargetDetails> {
262
+ readonly targetId: string;
263
+ readonly origin?: SqlMigrationPlanContractInfo | null;
264
+ readonly destination: SqlMigrationPlanContractInfo;
265
+ readonly operations: readonly SqlMigrationPlanOperation<TTargetDetails>[];
266
+ readonly meta?: AnyRecord;
267
+ }
268
+ //#endregion
269
+ export { SqlPlannerConflictLocation as C, SqlPlannerSuccessResult as E, SqlPlannerConflictKind as S, SqlPlannerResult as T, SqlMigrationRunnerExecuteOptions as _, SqlControlExtensionDescriptor as a, SqlMigrationRunnerSuccessValue as b, SqlMigrationPlanContractInfo as c, SqlMigrationPlanOperationTarget as d, SqlMigrationPlanner as f, SqlMigrationRunnerExecuteCallbacks as g, SqlMigrationRunnerErrorCode as h, CreateSqlMigrationPlanOptions as i, SqlMigrationPlanOperation as l, SqlMigrationRunner as m, ComponentDatabaseDependencies as n, SqlControlTargetDescriptor as o, SqlMigrationPlannerPlanOptions as p, ComponentDatabaseDependency as r, SqlMigrationPlan as s, AnyRecord as t, SqlMigrationPlanOperationStep as u, SqlMigrationRunnerFailure as v, SqlPlannerFailureResult as w, SqlPlannerConflict as x, SqlMigrationRunnerResult as y };
270
+ //# sourceMappingURL=types-D5CPT9N4.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-D5CPT9N4.d.mts","names":[],"sources":["../src/core/migrations/types.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AA6DuD,KA/B3C,SAAA,GAAY,QA+B+B,CA/BtB,MA+BsB,CAAA,MAAA,EAAA,OAAA,CAAA,CAAA;;;AAMvD;AA4BA;;;;;AAaA;AASiB,UAxEA,2BAwE+B,CAAA,cAAA,CAAA,CAAA;EAS/B;EAGkC,SAAA,EAAA,EAAA,MAAA;EAAhC;EACW,SAAA,KAAA,EAAA,MAAA;EACD;;;;EAL4D,SAAA,OAAA,EAAA,SAxE5D,yBAwE4D,CAxElC,cAwEkC,CAAA,EAAA;EAaxE;AASjB;;;;;EAYkB,SAAA,iCAAA,EAAA,CAAA,MAAA,EAnGqC,WAmGrC,EAAA,GAAA,SAnG8D,WAmG9D,EAAA;;;AAUlB;AAaA;AAYiB,UAhIA,6BAgImB,CAAA,cAAA,CAAA,CAAA;EACnB;;;;EADmD,SAAA,IAAA,CAAA,EAAA,SA3HzC,2BA2HyC,CA3Hb,cA2Ha,CAAA,EAAA;AASpE;;;AAiBA;;;;;AAOiB,UArIA,6BAqI8B,CAAA,kBAAA,MAAA,CAAA,SApIrC,0BAoIqC,CAAA,KAAA,EApIH,SAoIG,CAAA,CAAA;EACd;EAAZ,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,sBAAA;;;;AAUpD,UA9LA,0BAAA,CA8L6B;EAE1B,SAAA,KAAA,CAAA,EAAA,MAAA;EACI,SAAA,MAAA,CAAA,EAAA,MAAA;EACkC,SAAA,KAAA,CAAA,EAAA,MAAA;EAA1B,SAAA,UAAA,CAAA,EAAA,MAAA;EACd,SAAA,SAAA,CAAA,EAAA,MAAA;;;;;;UAvLD,kBAAA,SAA2B;iBAC3B;sBACK;kBACJ;;;;;UAMD,gDACP,KAAK;;iBAEE,iBAAiB;;;;;UAMjB,uBAAA,SAAgC,KAAK;;+BAEvB;;;;;KAMnB,mCACR,wBAAwB,kBACxB;;;;UAKa,8BAAA;qBACI,YAAY;mBACd;mBACA;;;;;;;gCAOa,cAAc;;;;;;UAO7B;gBACD,iCAAiC,iBAAiB;;;;;UAUjD;+BACc,0BAA0B;kCACvB,0BAA0B;;;;;UAM3C;iBACA,iBAAiB;mBACf;;;;;gCAKa,YAAY;;;;;mBAKzB;;;uBAGI,mCAAmC;qBACrC;;;;;6BAKQ;;;;;;gCAMG,cAAc;;;;;KAMlC,2BAAA;;;;;UAaK,yBAAA,SAAkC;iBAClC;kBACC;;;;;;UAOD,8BAAA,SAAuC;;;;KAK5C,wBAAA,GAA2B,OACrC,gCACA;;;;;UAOe;mBAEJ,iCAAiC,kBACzC,QAAQ;;;;;;UAWI,6EACP,+BAEN,WACA,6BAA6B,YAC7B;;;;;wBAMoB,2BAA2B,oBAAoB;;;;;uBAKhD,2BAA2B,mBAAmB;;;;;UAUpD;;oBAEG;wBACI;gCACQ,0BAA0B;kBACxC"}
@@ -0,0 +1,108 @@
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
+ });
27
+ /**
28
+ * Parses a contract marker row from database query result.
29
+ * This is SQL-specific parsing logic (handles SQL row structure with snake_case columns).
30
+ */
31
+ function parseContractMarkerRow(row) {
32
+ const result = ContractMarkerRowSchema(row);
33
+ if (result instanceof type.errors) {
34
+ const messages = result.map((p) => p.message).join("; ");
35
+ throw new Error(`Invalid contract marker row: ${messages}`);
36
+ }
37
+ const validatedRow = result;
38
+ const updatedAt = validatedRow.updated_at ? validatedRow.updated_at instanceof Date ? validatedRow.updated_at : new Date(validatedRow.updated_at) : /* @__PURE__ */ new Date();
39
+ return {
40
+ coreHash: validatedRow.core_hash,
41
+ profileHash: validatedRow.profile_hash,
42
+ contractJson: validatedRow.contract_json ?? null,
43
+ canonicalVersion: validatedRow.canonical_version ?? null,
44
+ updatedAt,
45
+ appTag: validatedRow.app_tag ?? null,
46
+ meta: parseMeta(validatedRow.meta)
47
+ };
48
+ }
49
+ /**
50
+ * Returns the SQL statement to read the contract marker.
51
+ * This is a migration-plane helper (no runtime imports).
52
+ * @internal - Used internally by readMarker(). Prefer readMarker() for Control Plane usage.
53
+ */
54
+ function readMarkerSql() {
55
+ return {
56
+ sql: `select
57
+ core_hash,
58
+ profile_hash,
59
+ contract_json,
60
+ canonical_version,
61
+ updated_at,
62
+ app_tag,
63
+ meta
64
+ from prisma_contract.marker
65
+ where id = $1`,
66
+ params: [1]
67
+ };
68
+ }
69
+ /**
70
+ * Reads the contract marker from the database using the provided driver.
71
+ * Returns the parsed marker record or null if no marker is found.
72
+ * This abstracts SQL-specific details from the Control Plane.
73
+ *
74
+ * @param driver - ControlDriverInstance instance for executing queries
75
+ * @returns Promise resolving to ContractMarkerRecord or null if marker not found
76
+ */
77
+ async function readMarker(driver) {
78
+ const markerStatement = readMarkerSql();
79
+ try {
80
+ const queryResult = await driver.query(markerStatement.sql, markerStatement.params);
81
+ if (queryResult.rows.length === 0) return null;
82
+ const markerRow = queryResult.rows[0];
83
+ if (!markerRow) throw new Error("Database query returned unexpected result structure");
84
+ return parseContractMarkerRow(markerRow);
85
+ } catch (error) {
86
+ if (error instanceof Error && (error.message.includes("does not exist") || error.code === "42P01")) return null;
87
+ throw error;
88
+ }
89
+ }
90
+ /**
91
+ * Collects supported codec type IDs from adapter and extension manifests.
92
+ * Returns a sorted, unique array of type IDs that are declared in the manifests.
93
+ * This enables coverage checks by comparing contract column types against supported types.
94
+ *
95
+ * Note: This extracts type IDs from manifest type imports, not from runtime codec registries.
96
+ * The manifests declare which codec types are available, but the actual type IDs
97
+ * are defined in the codec-types TypeScript modules that are imported.
98
+ *
99
+ * For MVP, we return an empty array since extracting type IDs from TypeScript modules
100
+ * would require runtime evaluation or static analysis. This can be enhanced later.
101
+ */
102
+ function collectSupportedCodecTypeIds(descriptors) {
103
+ return [];
104
+ }
105
+
106
+ //#endregion
107
+ export { readMarkerSql as i, parseContractMarkerRow as n, readMarker as r, collectSupportedCodecTypeIds as t };
108
+ //# sourceMappingURL=verify-DhFytkFC.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify-DhFytkFC.mjs","names":["parsed: unknown"],"sources":["../src/core/verify.ts"],"sourcesContent":["import type { ContractMarkerRecord } from '@prisma-next/contract/types';\nimport type {\n ControlAdapterDescriptor,\n ControlDriverInstance,\n ControlExtensionDescriptor,\n ControlTargetDescriptor,\n} from '@prisma-next/core-control-plane/types';\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 coreHash: 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<TFamilyId extends string, TTargetId extends string>(\n descriptors: ReadonlyArray<\n | ControlTargetDescriptor<TFamilyId, TTargetId>\n | ControlAdapterDescriptor<TFamilyId, TTargetId>\n | ControlExtensionDescriptor<TFamilyId, TTargetId>\n >,\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":";;;AASA,MAAM,aAAa,KAAK,EAAE,YAAY,WAAW,CAAC;AAElD,SAAS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