qubu 0.0.0 → 0.3.3

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 (109) hide show
  1. package/dist/canonical-BbnqavJm.mjs +972 -0
  2. package/dist/codegen.d.mts +107 -0
  3. package/dist/codegen.mjs +1199 -0
  4. package/dist/column-CXMxx8Hq.mjs +118 -0
  5. package/dist/complete-D5Djh-zo.mjs +1788 -0
  6. package/dist/complete-types-BdFqUfbb.d.mts +371 -0
  7. package/dist/core.d.mts +33 -0
  8. package/dist/core.mjs +36 -0
  9. package/dist/ddl.d.mts +118 -0
  10. package/dist/ddl.mjs +1120 -0
  11. package/dist/dialect-b2-Z6uBF.mjs +13 -0
  12. package/dist/diff.d.mts +2 -0
  13. package/dist/diff.mjs +883 -0
  14. package/dist/drizzle-mysql.d.mts +24 -0
  15. package/dist/drizzle-mysql.mjs +72 -0
  16. package/dist/drizzle-postgres.d.mts +24 -0
  17. package/dist/drizzle-postgres.mjs +73 -0
  18. package/dist/drizzle-sqlite.d.mts +24 -0
  19. package/dist/drizzle-sqlite.mjs +82 -0
  20. package/dist/drizzle.d.mts +13 -0
  21. package/dist/drizzle.mjs +2 -0
  22. package/dist/errors-BGCoLe_r.mjs +14 -0
  23. package/dist/errors-Dxv73YJu.mjs +26 -0
  24. package/dist/explain-CkIK13L_.mjs +98 -0
  25. package/dist/index-Ds7-mhJi.d.mts +146 -0
  26. package/dist/index-Dug5HnLB.d.mts +204 -0
  27. package/dist/index.d.mts +2 -0
  28. package/dist/index.mjs +1276 -0
  29. package/dist/introspection.d.mts +117 -0
  30. package/dist/introspection.mjs +4341 -0
  31. package/dist/json-CUZlv4HT.mjs +169 -0
  32. package/dist/migration.d.mts +215 -0
  33. package/dist/migration.mjs +1161 -0
  34. package/dist/mysql-DqkqXB6A.mjs +355 -0
  35. package/dist/mysql.d.mts +5 -0
  36. package/dist/mysql.mjs +50 -0
  37. package/dist/naming-QVCOnSj2.mjs +20 -0
  38. package/dist/omit-OxV58AwX.mjs +5 -0
  39. package/dist/on-conflict-BxnxubMb.mjs +143 -0
  40. package/dist/postgres-DEBBeh52.mjs +235 -0
  41. package/dist/postgres.d.mts +123 -0
  42. package/dist/postgres.mjs +52 -0
  43. package/dist/registry-BufIskVN.mjs +569 -0
  44. package/dist/relational-DCZrrNia.mjs +77 -0
  45. package/dist/runtime-BTr-MTlo.mjs +193 -0
  46. package/dist/schema.d.mts +2 -0
  47. package/dist/schema.mjs +5 -0
  48. package/dist/serialize-PF1cfH2P.mjs +556 -0
  49. package/dist/snapshot-CWPgzxNx.mjs +392 -0
  50. package/dist/snapshot.d.mts +4 -0
  51. package/dist/snapshot.mjs +8 -0
  52. package/dist/source-DUoJVXmL.mjs +68 -0
  53. package/dist/sqlite-BU6DBxef.mjs +320 -0
  54. package/dist/sqlite.d.mts +5 -0
  55. package/dist/sqlite.mjs +48 -0
  56. package/dist/standard-BTVYKh_F.mjs +12 -0
  57. package/dist/table-llv9tsZ8.mjs +384 -0
  58. package/dist/types-4Q076HKo.d.mts +3636 -0
  59. package/dist/types-BX0mckiU.d.mts +644 -0
  60. package/dist/types-CO1KaRNc.d.mts +46 -0
  61. package/dist/types-Cec0xzo4.mjs +116 -0
  62. package/dist/value-BvilP0oz.mjs +29 -0
  63. package/dist/vite/ambient.d.ts +449 -0
  64. package/dist/vite.d.mts +35 -0
  65. package/dist/vite.mjs +498 -0
  66. package/docs/config.json +21 -0
  67. package/docs/dialects-and-execution.md +427 -0
  68. package/docs/getting-started.md +96 -0
  69. package/docs/guides/compose-queries.md +225 -0
  70. package/docs/guides/drizzle.md +129 -0
  71. package/docs/guides/extensions/dialects.md +40 -0
  72. package/docs/guides/extensions/overview.md +36 -0
  73. package/docs/guides/extensions/sources-and-clauses.md +82 -0
  74. package/docs/guides/extensions/typed-expressions.md +94 -0
  75. package/docs/guides/extensions/unsafe-syntax.md +27 -0
  76. package/docs/guides/json.md +65 -0
  77. package/docs/guides/mutations.md +138 -0
  78. package/docs/guides/select/conditions.md +110 -0
  79. package/docs/guides/select/grouping-and-windows.md +82 -0
  80. package/docs/guides/select/ordering-and-pagination.md +78 -0
  81. package/docs/guides/select/overview.md +139 -0
  82. package/docs/guides/sql-templates.md +157 -0
  83. package/docs/guides/vite-plugin.md +92 -0
  84. package/docs/index.md +111 -0
  85. package/docs/query-model/fragments.md +109 -0
  86. package/docs/query-model/result-shapes.md +125 -0
  87. package/docs/query-model/source-scope.md +182 -0
  88. package/docs/reference/introspection-support.md +196 -0
  89. package/docs/reference/mysql-snapshot.md +55 -0
  90. package/docs/reference/postgres-snapshot.md +61 -0
  91. package/docs/reference/sqlite-snapshot.md +53 -0
  92. package/docs/reference/supported-surface.md +104 -0
  93. package/docs/schema/catalog-model.md +58 -0
  94. package/docs/schema/code-generation.md +139 -0
  95. package/docs/schema/columns-and-writes.md +130 -0
  96. package/docs/schema/constraints-and-indexes.md +180 -0
  97. package/docs/schema/ddl-emission.md +75 -0
  98. package/docs/schema/diff.md +75 -0
  99. package/docs/schema/introspection.md +214 -0
  100. package/docs/schema/migration-plans.md +76 -0
  101. package/docs/schema/snapshots.md +93 -0
  102. package/docs/schema/storage-and-schema-sql.md +104 -0
  103. package/docs/schema/tables-and-names.md +106 -0
  104. package/docs/sql-semantic-types.md +141 -0
  105. package/docs/troubleshooting.md +151 -0
  106. package/package.json +132 -10
  107. package/skills/qubu/SKILL.md +42 -0
  108. package/skills/qubu/agents/openai.yaml +6 -0
  109. package/readme.md +0 -1
@@ -0,0 +1,644 @@
1
+ import { n as SchemaSnapshot } from "./types-4Q076HKo.mjs";
2
+ //#region src/introspection/connection.d.ts
3
+ /** A parameterized statement owned by a catalog adapter. */
4
+ interface CatalogQuery {
5
+ /** Fixed catalog SQL selected by Qubu's dialect adapter. */
6
+ readonly text: string;
7
+ /** Values bound by the user-owned connection or driver adapter. */
8
+ readonly parameters: readonly unknown[];
9
+ }
10
+ /** Optional execution controls passed through to a catalog connection. */
11
+ interface CatalogQueryOptions {
12
+ /** Abort propagation is optional because drivers expose it inconsistently. */
13
+ readonly signal?: AbortSignal;
14
+ }
15
+ /**
16
+ * User-owned catalog query boundary.
17
+ *
18
+ * Qubu does not select a driver, open or close a connection, manage a pool,
19
+ * authenticate, retry, start a transaction, or impose a timeout. The
20
+ * connection only executes fixed, parameterized catalog statements and
21
+ * returns already-decoded row records.
22
+ */
23
+ interface CatalogConnection {
24
+ readonly dialect: CatalogDialect;
25
+ query<TRow extends CatalogQueryRow = CatalogQueryRow>(statement: CatalogQuery, options?: CatalogQueryOptions): Promise<readonly TRow[]>;
26
+ }
27
+ //#endregion
28
+ //#region src/introspection/diagnostics.d.ts
29
+ /** Stable severity levels for discovery and normalization findings. */
30
+ type IntrospectionDiagnosticSeverity = 'error' | 'warning' | 'info';
31
+ /** Stable codes emitted by catalog discovery and normalization. */
32
+ type IntrospectionDiagnosticCode = 'connection-failed' | 'query-failed' | 'permission-denied' | 'unsupported-product' | 'unsupported-server' | 'unsupported-feature' | 'invalid-catalog-row' | 'missing-catalog-row' | 'expression-parse-failed' | 'unresolved-reference' | 'ambiguous-identity' | 'unmodeled-object' | 'lossy-mapping' | 'dialect-mismatch' | 'partial-result';
33
+ /** A path-addressed diagnostic from catalog discovery or normalization. */
34
+ interface IntrospectionDiagnostic {
35
+ readonly severity: IntrospectionDiagnosticSeverity;
36
+ readonly code: IntrospectionDiagnosticCode;
37
+ readonly message: string;
38
+ /** Location in the normalized catalog or adapter input being described. */
39
+ readonly path: readonly (string | number)[];
40
+ /** Physical object and current-run catalog identity involved in the issue. */
41
+ readonly physicalReference?: CatalogReference;
42
+ /** Other physical objects or current-run references related to the issue. */
43
+ readonly relatedReferences?: readonly CatalogReference[];
44
+ /** Optional action that can resolve or explain the finding. */
45
+ readonly remediation?: string;
46
+ }
47
+ /** Input accepted by {@link createIntrospectionDiagnostic}. */
48
+ type IntrospectionDiagnosticInput = IntrospectionDiagnostic;
49
+ /**
50
+ * Create one immutable diagnostic without interpreting catalog text or
51
+ * copying driver error details into the structured fields.
52
+ */
53
+ declare function createIntrospectionDiagnostic(diagnostic: IntrospectionDiagnosticInput): IntrospectionDiagnostic;
54
+ /** Return whether a diagnostic list prevents strict introspection output. */
55
+ declare function hasIntrospectionErrors(diagnostics: readonly IntrospectionDiagnostic[]): boolean;
56
+ /** Error raised by a throwing introspection operation after collecting findings. */
57
+ declare class IntrospectionError extends Error {
58
+ readonly name = "IntrospectionError";
59
+ readonly diagnostics: readonly IntrospectionDiagnostic[];
60
+ readonly issues: readonly IntrospectionDiagnostic[];
61
+ constructor(diagnostics: readonly IntrospectionDiagnostic[]);
62
+ }
63
+ //#endregion
64
+ //#region src/introspection/identity.d.ts
65
+ /** The source selected by the stable introspection identity precedence. */
66
+ type CatalogIdentitySource = 'explicit-hint' | 'previous-snapshot' | 'physical-name' | 'deterministic-fallback';
67
+ /** Entity kinds for which a caller may provide a logical identity hint. */
68
+ type CatalogIdentityEntityKind = Exclude<CatalogEntityKind, 'namespace' | 'deferred-object'>;
69
+ /** A physical selector for one table-scoped or namespace-scoped entity. */
70
+ interface CatalogIdentityHint {
71
+ readonly kind: CatalogIdentityEntityKind;
72
+ /** Logical ID to retain in the normalized catalog and later snapshot. */
73
+ readonly logicalId: string;
74
+ /** Current physical name of the selected object. */
75
+ readonly physicalName: string;
76
+ /** Physical table name for columns, constraints, and indexes. */
77
+ readonly tablePhysicalName?: string;
78
+ }
79
+ /** The caller-provided identity hints accepted by an introspection run. */
80
+ type CatalogIdentityHints = readonly CatalogIdentityHint[];
81
+ /** How invalid physical names become deterministic logical IDs. */
82
+ type CatalogIdentityFallback = 'escaped' | 'hashed';
83
+ /** Versioned metadata for the identity policy used by one introspection run. */
84
+ interface CatalogIdentityPolicy {
85
+ readonly name: string;
86
+ readonly version: number;
87
+ readonly fallback: CatalogIdentityFallback;
88
+ readonly precedence: readonly CatalogIdentitySource[];
89
+ }
90
+ /** The naming policy used by the first introspection snapshot mapper. */
91
+ declare const introspectedPhysicalIdentityPolicy: CatalogIdentityPolicy;
92
+ /** A resolved logical ID together with the rule that selected it. */
93
+ interface CatalogResolvedIdentity {
94
+ readonly logicalId: string;
95
+ readonly source: CatalogIdentitySource;
96
+ }
97
+ /**
98
+ * Inputs used when carrying a prior snapshot's table and column IDs forward.
99
+ * The resolver must match physical names inside the selected namespace only.
100
+ */
101
+ interface CatalogPreviousSnapshotIdentitySource {
102
+ readonly snapshot: SchemaSnapshot;
103
+ }
104
+ //#endregion
105
+ //#region src/introspection/types.d.ts
106
+ /** SQL engines supported by the common catalog contract. */
107
+ type CatalogDialect = 'postgresql' | 'sqlite' | 'mysql';
108
+ /** A decoded row returned by a user-owned catalog connection. */
109
+ type CatalogQueryRow = Readonly<Record<string, unknown>>;
110
+ /** Physical objects that can receive stable logical IDs. */
111
+ type CatalogEntityKind = 'namespace' | 'table' | 'column' | 'constraint' | 'index' | 'view' | 'materialized-view' | 'sequence' | 'enum' | 'domain' | 'collation' | 'trigger' | 'routine' | 'partition' | 'policy' | 'extension' | 'comment' | 'ownership' | 'opaque-object' | 'deferred-object';
112
+ /** A scalar value retained as catalog data rather than executable SQL. */
113
+ type CatalogScalar = null | boolean | string | number | bigint;
114
+ /** Plain catalog data used for dialect extensions and unknown fields. */
115
+ type CatalogData = CatalogScalar | readonly CatalogData[] | {
116
+ readonly [key: string]: CatalogData;
117
+ };
118
+ /** A current-run catalog key. It is never a persisted logical identity. */
119
+ interface CatalogCatalogReference {
120
+ readonly relation: string;
121
+ readonly key: string;
122
+ readonly value: string | number;
123
+ }
124
+ /**
125
+ * A physical object reference with an optional current-run catalog key.
126
+ * PostgreSQL OIDs and similar values belong in `catalog`, not in logical IDs.
127
+ */
128
+ interface CatalogReference {
129
+ readonly kind: CatalogEntityKind;
130
+ readonly namespace?: string;
131
+ readonly table?: string;
132
+ readonly name: string;
133
+ readonly catalog?: CatalogCatalogReference;
134
+ }
135
+ /** Where an opaque catalog SQL expression came from. */
136
+ type CatalogProvenanceKind = 'catalog' | 'decompiler' | 'create-sql';
137
+ /** Source location retained with catalog-derived SQL text. */
138
+ interface CatalogProvenance {
139
+ readonly kind: CatalogProvenanceKind;
140
+ readonly dialect: CatalogDialect;
141
+ readonly reference?: CatalogReference;
142
+ readonly path?: readonly (string | number)[];
143
+ }
144
+ /**
145
+ * Opaque SQL text recovered from catalog metadata. It has no evaluator or
146
+ * Qubu expression implementation and must not be executed by introspection.
147
+ */
148
+ interface CatalogSqlExpression {
149
+ readonly kind: 'sql';
150
+ readonly dialect: CatalogDialect;
151
+ readonly text: string;
152
+ readonly provenance: CatalogProvenance;
153
+ }
154
+ /** A literal catalog fact with optional source provenance. */
155
+ interface CatalogLiteralFact {
156
+ readonly kind: 'literal';
157
+ readonly value: CatalogScalar;
158
+ readonly provenance?: CatalogProvenance;
159
+ }
160
+ /** A catalog fact whose value remains opaque dialect SQL. */
161
+ interface CatalogExpressionFact {
162
+ readonly kind: 'expression';
163
+ readonly expression: CatalogSqlExpression;
164
+ }
165
+ /** Tagged data used by defaults, identity options, and dialect metadata. */
166
+ type CatalogValueFact = CatalogLiteralFact | CatalogExpressionFact;
167
+ /** An unmodeled field retained for later adapter and mapper support. */
168
+ interface CatalogUnknownField {
169
+ readonly name: string;
170
+ readonly value: CatalogData | CatalogSqlExpression;
171
+ readonly provenance?: CatalogProvenance;
172
+ }
173
+ /** A reference to an object in the normalized catalog. */
174
+ interface CatalogObjectReference {
175
+ readonly kind: Exclude<CatalogEntityKind, 'namespace'>;
176
+ readonly id: string;
177
+ }
178
+ /** A comment observed for a physical catalog object. */
179
+ interface CatalogComment {
180
+ readonly kind: 'comment';
181
+ readonly id: string;
182
+ readonly object: CatalogObjectReference;
183
+ readonly text: string;
184
+ readonly reference?: CatalogReference;
185
+ readonly provenance?: CatalogProvenance;
186
+ readonly dialect?: CatalogDialectExtension;
187
+ readonly unknownFields?: readonly CatalogUnknownField[];
188
+ }
189
+ /** Ownership metadata observed for a physical catalog object. */
190
+ interface CatalogOwnership {
191
+ readonly kind: 'ownership';
192
+ readonly id: string;
193
+ readonly object: CatalogObjectReference;
194
+ readonly owner: string;
195
+ readonly reference?: CatalogReference;
196
+ readonly provenance?: CatalogProvenance;
197
+ readonly dialect?: CatalogDialectExtension;
198
+ readonly unknownFields?: readonly CatalogUnknownField[];
199
+ }
200
+ /** Optional metadata shared by complete normalized catalog objects. */
201
+ interface CatalogObjectMetadata {
202
+ readonly provenance?: CatalogProvenance;
203
+ readonly comment?: CatalogComment;
204
+ readonly ownership?: CatalogOwnership;
205
+ }
206
+ /** Common identity and physical-name fields for complete catalog objects. */
207
+ interface CatalogObjectBase extends CatalogObjectMetadata {
208
+ readonly kind: Exclude<CatalogEntityKind, 'namespace'>;
209
+ readonly id: string;
210
+ readonly identitySource: CatalogIdentitySource;
211
+ readonly physicalName: string;
212
+ readonly reference?: CatalogReference;
213
+ readonly dialect?: CatalogDialectExtension;
214
+ readonly unknownFields?: readonly CatalogUnknownField[];
215
+ }
216
+ /** Portable classification retained beside an exact native declaration. */
217
+ type CatalogPortableStorageType = 'integer' | 'numeric' | 'text' | 'boolean' | 'date' | 'timestamp' | 'uuid' | 'json' | 'bigint' | 'binary';
218
+ /** Confidence for a portable classification, never a replacement for native type text. */
219
+ type CatalogClassificationConfidence = 'exact' | 'inferred' | 'unknown';
220
+ /** Exact native storage plus an optional portable classification. */
221
+ interface CatalogStorageType {
222
+ readonly nativeType: string;
223
+ readonly portable?: {
224
+ readonly type: CatalogPortableStorageType;
225
+ readonly confidence: CatalogClassificationConfidence;
226
+ };
227
+ }
228
+ /** A generated-column expression and its recovered storage mode. */
229
+ interface CatalogGeneratedColumn {
230
+ readonly kind: 'generated';
231
+ readonly expression: CatalogSqlExpression;
232
+ readonly mode: 'stored' | 'virtual' | 'unknown';
233
+ }
234
+ /** Identity behavior kept separate from defaults and generated expressions. */
235
+ interface CatalogIdentity {
236
+ readonly kind: 'identity';
237
+ readonly generation: 'always' | 'by-default';
238
+ readonly options: Readonly<Record<string, CatalogValueFact>>;
239
+ readonly dialect?: CatalogDialectExtension;
240
+ }
241
+ /** Version parts parsed from a server's raw version string. */
242
+ interface CatalogVersion {
243
+ readonly major: number;
244
+ readonly minor?: number;
245
+ readonly patch?: number;
246
+ readonly suffix?: string;
247
+ }
248
+ /** Calculated feature and visibility facts reported by a catalog adapter. */
249
+ interface CatalogCapabilities {
250
+ readonly generatedColumns: boolean;
251
+ readonly identityMetadata: boolean;
252
+ readonly checkConstraints: boolean;
253
+ readonly checkConstraintEnforcement: 'enforced' | 'metadata-only' | 'unknown';
254
+ readonly expressionDecompilation: boolean;
255
+ readonly indexExpressions: boolean;
256
+ readonly indexPredicates: boolean;
257
+ readonly indexIncludedColumns: boolean;
258
+ readonly namespaces: boolean;
259
+ readonly visibility: 'complete' | 'limited' | 'unknown';
260
+ readonly [capability: string]: boolean | string;
261
+ }
262
+ /** Server product, raw version text, parsed version, and adapter capabilities. */
263
+ interface CatalogServerInfo {
264
+ readonly product: string;
265
+ readonly rawVersion: string;
266
+ readonly parsedVersion?: CatalogVersion;
267
+ readonly capabilities: CatalogCapabilities;
268
+ }
269
+ /** The one physical namespace selected for a catalog run. */
270
+ interface CatalogNamespace {
271
+ readonly kind: 'postgres-schema' | 'sqlite-database' | 'mysql-database';
272
+ readonly name: string;
273
+ readonly reference?: CatalogReference;
274
+ readonly provenance?: CatalogProvenance;
275
+ readonly comment?: CatalogComment;
276
+ readonly ownership?: CatalogOwnership;
277
+ readonly dialect?: CatalogDialectExtension;
278
+ readonly unknownFields?: readonly CatalogUnknownField[];
279
+ }
280
+ /** A logical reference used for normalized cross-object relationships. */
281
+ interface CatalogEntityReference {
282
+ readonly kind: Exclude<CatalogEntityKind, 'namespace' | 'deferred-object'>;
283
+ readonly id: string;
284
+ readonly tableId?: string;
285
+ }
286
+ /** A primary key constraint in the normalized catalog. */
287
+ interface CatalogPrimaryKeyConstraint extends CatalogObjectMetadata {
288
+ readonly kind: 'primary-key';
289
+ readonly id: string;
290
+ readonly identitySource: CatalogIdentitySource;
291
+ readonly physicalName?: string;
292
+ readonly columns: readonly string[];
293
+ readonly backingIndex?: CatalogEntityReference;
294
+ readonly deferrable?: boolean;
295
+ readonly initially?: 'immediate' | 'deferred';
296
+ readonly validated?: boolean;
297
+ readonly reference?: CatalogReference;
298
+ readonly dialect?: CatalogDialectExtension;
299
+ readonly unknownFields?: readonly CatalogUnknownField[];
300
+ }
301
+ /** A unique constraint, including nullable uniqueness semantics. */
302
+ interface CatalogUniqueConstraint extends CatalogObjectMetadata {
303
+ readonly kind: 'unique';
304
+ readonly id: string;
305
+ readonly identitySource: CatalogIdentitySource;
306
+ readonly physicalName?: string;
307
+ readonly columns: readonly string[];
308
+ readonly nulls: 'distinct' | 'not-distinct';
309
+ readonly backingIndex?: CatalogEntityReference;
310
+ readonly deferrable?: boolean;
311
+ readonly initially?: 'immediate' | 'deferred';
312
+ readonly validated?: boolean;
313
+ readonly reference?: CatalogReference;
314
+ readonly dialect?: CatalogDialectExtension;
315
+ readonly unknownFields?: readonly CatalogUnknownField[];
316
+ }
317
+ /** Ordered target columns and table IDs for a normalized foreign key. */
318
+ interface CatalogForeignKeyTarget {
319
+ readonly table: string;
320
+ readonly columns: readonly string[];
321
+ }
322
+ /** A foreign key with ordered columns and referential actions. */
323
+ interface CatalogForeignKeyConstraint extends CatalogObjectMetadata {
324
+ readonly kind: 'foreign-key';
325
+ readonly id: string;
326
+ readonly identitySource: CatalogIdentitySource;
327
+ readonly physicalName?: string;
328
+ readonly columns: readonly string[];
329
+ readonly target: CatalogForeignKeyTarget;
330
+ readonly onUpdate?: 'no-action' | 'restrict' | 'cascade' | 'set-null' | 'set-default';
331
+ readonly onDelete?: 'no-action' | 'restrict' | 'cascade' | 'set-null' | 'set-default';
332
+ readonly match?: 'simple' | 'full' | 'partial';
333
+ readonly deferrable?: boolean;
334
+ readonly initially?: 'immediate' | 'deferred';
335
+ readonly validated?: boolean;
336
+ readonly reference?: CatalogReference;
337
+ readonly dialect?: CatalogDialectExtension;
338
+ readonly unknownFields?: readonly CatalogUnknownField[];
339
+ }
340
+ /** A check constraint whose expression remains tagged catalog SQL. */
341
+ interface CatalogCheckConstraint extends CatalogObjectMetadata {
342
+ readonly kind: 'check';
343
+ readonly id: string;
344
+ readonly identitySource: CatalogIdentitySource;
345
+ readonly physicalName?: string;
346
+ readonly expression: CatalogSqlExpression;
347
+ readonly deferrable?: boolean;
348
+ readonly initially?: 'immediate' | 'deferred';
349
+ readonly validated?: boolean;
350
+ readonly reference?: CatalogReference;
351
+ readonly dialect?: CatalogDialectExtension;
352
+ readonly unknownFields?: readonly CatalogUnknownField[];
353
+ }
354
+ /** Every constraint represented by the normalized catalog contract. */
355
+ type CatalogConstraint = CatalogPrimaryKeyConstraint | CatalogUniqueConstraint | CatalogForeignKeyConstraint | CatalogCheckConstraint;
356
+ /** One ordered column or expression term in a normalized index. */
357
+ type CatalogIndexTerm = {
358
+ readonly kind: 'column';
359
+ readonly column: string;
360
+ readonly position: number;
361
+ readonly direction?: 'ASC' | 'DESC';
362
+ readonly nulls?: 'FIRST' | 'LAST';
363
+ readonly prefixLength?: CatalogValueFact;
364
+ readonly operatorClass?: string;
365
+ } | {
366
+ readonly kind: 'expression';
367
+ readonly expression: CatalogSqlExpression;
368
+ readonly position: number;
369
+ readonly direction?: 'ASC' | 'DESC';
370
+ readonly nulls?: 'FIRST' | 'LAST';
371
+ readonly operatorClass?: string;
372
+ };
373
+ /** A normalized index with ordered terms and backing relationships. */
374
+ interface CatalogIndex extends CatalogObjectMetadata {
375
+ readonly kind: 'index';
376
+ readonly id: string;
377
+ readonly identitySource: CatalogIdentitySource;
378
+ readonly physicalName?: string;
379
+ readonly unique: boolean;
380
+ readonly terms: readonly CatalogIndexTerm[];
381
+ readonly predicate?: CatalogSqlExpression;
382
+ readonly includedColumns?: readonly string[];
383
+ readonly backingConstraint?: CatalogEntityReference;
384
+ readonly method?: string;
385
+ readonly reference?: CatalogReference;
386
+ readonly dialect?: CatalogDialectExtension;
387
+ readonly unknownFields?: readonly CatalogUnknownField[];
388
+ }
389
+ /** A normalized table containing only ordinary included table metadata. */
390
+ interface CatalogTable extends CatalogObjectMetadata {
391
+ readonly kind: 'table';
392
+ readonly id: string;
393
+ readonly identitySource: CatalogIdentitySource;
394
+ readonly physicalName: string;
395
+ readonly ordinalPosition?: number;
396
+ readonly reference?: CatalogReference;
397
+ readonly columns: readonly CatalogColumn[];
398
+ readonly constraints: readonly CatalogConstraint[];
399
+ readonly indexes: readonly CatalogIndex[];
400
+ readonly dialect?: CatalogDialectExtension;
401
+ readonly unknownFields?: readonly CatalogUnknownField[];
402
+ }
403
+ /** A normalized visible column within an ordinary table. */
404
+ interface CatalogColumn extends CatalogObjectMetadata {
405
+ readonly kind: 'column';
406
+ readonly id: string;
407
+ readonly identitySource: CatalogIdentitySource;
408
+ readonly physicalName: string;
409
+ readonly ordinalPosition: number;
410
+ readonly nullable: boolean;
411
+ readonly storage: CatalogStorageType;
412
+ readonly default?: CatalogValueFact;
413
+ readonly generated?: CatalogGeneratedColumn;
414
+ readonly identity?: CatalogIdentity;
415
+ readonly onUpdate?: CatalogSqlExpression;
416
+ readonly reference?: CatalogReference;
417
+ readonly dialect?: CatalogDialectExtension;
418
+ readonly unknownFields?: readonly CatalogUnknownField[];
419
+ }
420
+ /** Object categories intentionally retained outside Snapshot v1 tables. */
421
+ type CatalogDeferredObjectKind = 'view' | 'materialized-view' | 'sequence' | 'enum' | 'domain' | 'collation' | 'routine' | 'trigger' | 'policy' | 'extension' | 'partition' | 'virtual-table' | 'shadow-table' | 'temporary-object' | 'foreign-table' | 'other';
422
+ /** A deferred or unmodeled object retained for diagnostics and future support. */
423
+ interface CatalogDeferredObject extends CatalogObjectMetadata {
424
+ readonly kind: 'deferred-object';
425
+ readonly objectKind: CatalogDeferredObjectKind;
426
+ /** Optional in the legacy reader contract; complete readers should set it. */
427
+ readonly id?: string;
428
+ readonly identitySource?: CatalogIdentitySource;
429
+ readonly physicalName: string;
430
+ readonly reference?: CatalogReference;
431
+ readonly dialect?: CatalogDialectExtension;
432
+ readonly unknownFields?: readonly CatalogUnknownField[];
433
+ }
434
+ /** A versioned dialect-owned catalog payload. */
435
+ interface CatalogDialectExtension {
436
+ readonly dialect: CatalogDialect;
437
+ readonly version: number;
438
+ readonly data: CatalogData;
439
+ }
440
+ /** A view or materialized view definition and its exposed columns. */
441
+ interface CatalogView extends CatalogObjectBase {
442
+ readonly kind: 'view' | 'materialized-view';
443
+ readonly columns: readonly CatalogColumn[];
444
+ readonly definition: CatalogSqlExpression;
445
+ readonly dependencies?: readonly CatalogObjectReference[];
446
+ readonly checkOption?: 'none' | 'local' | 'cascaded';
447
+ readonly securityBarrier?: boolean;
448
+ readonly securityInvoker?: boolean;
449
+ }
450
+ /** Sequence metadata, including options needed to describe an identity. */
451
+ interface CatalogSequence extends CatalogObjectBase {
452
+ readonly kind: 'sequence';
453
+ readonly storage?: CatalogStorageType;
454
+ readonly start?: CatalogValueFact;
455
+ readonly increment?: CatalogValueFact;
456
+ readonly minimum?: CatalogValueFact;
457
+ readonly maximum?: CatalogValueFact;
458
+ readonly cache?: CatalogValueFact;
459
+ readonly cycle?: boolean;
460
+ readonly ownedBy?: CatalogObjectReference;
461
+ readonly identity?: CatalogIdentity;
462
+ }
463
+ /** One ordered enum label retained exactly as returned by the database. */
464
+ interface CatalogEnumValue {
465
+ readonly value: string;
466
+ readonly ordinalPosition: number;
467
+ readonly provenance?: CatalogProvenance;
468
+ }
469
+ /** A database enum type with stable label ordering. */
470
+ interface CatalogEnum extends CatalogObjectBase {
471
+ readonly kind: 'enum';
472
+ readonly values: readonly CatalogEnumValue[];
473
+ }
474
+ /** A domain type layered over a native storage declaration. */
475
+ interface CatalogDomain extends CatalogObjectBase {
476
+ readonly kind: 'domain';
477
+ readonly storage: CatalogStorageType;
478
+ readonly nullable?: boolean;
479
+ readonly default?: CatalogValueFact;
480
+ readonly constraints?: readonly CatalogCheckConstraint[];
481
+ }
482
+ /** Collation properties that affect comparison and ordering semantics. */
483
+ interface CatalogCollation extends CatalogObjectBase {
484
+ readonly kind: 'collation';
485
+ readonly provider?: string;
486
+ readonly locale?: string;
487
+ readonly deterministic?: boolean;
488
+ readonly version?: string;
489
+ }
490
+ /** A trigger attached to a table or view, retaining its body as opaque SQL. */
491
+ interface CatalogTrigger extends CatalogObjectBase {
492
+ readonly kind: 'trigger';
493
+ readonly table: CatalogObjectReference;
494
+ readonly timing: 'before' | 'after' | 'instead-of' | 'unknown';
495
+ readonly events: readonly ('insert' | 'update' | 'delete' | 'truncate')[];
496
+ readonly orientation?: 'row' | 'statement';
497
+ readonly condition?: CatalogSqlExpression;
498
+ readonly body: CatalogSqlExpression;
499
+ readonly enabled?: boolean;
500
+ }
501
+ /** A routine parameter as observed in a function or procedure signature. */
502
+ interface CatalogRoutineParameter {
503
+ readonly name?: string;
504
+ readonly mode?: 'in' | 'out' | 'inout' | 'variadic' | 'table';
505
+ readonly storage: CatalogStorageType;
506
+ readonly default?: CatalogValueFact;
507
+ readonly ordinalPosition: number;
508
+ readonly provenance?: CatalogProvenance;
509
+ }
510
+ /** A function, procedure, aggregate, or other routine declaration. */
511
+ interface CatalogRoutine extends CatalogObjectBase {
512
+ readonly kind: 'routine';
513
+ readonly routineKind: 'function' | 'procedure' | 'aggregate' | 'window' | 'unknown';
514
+ readonly parameters: readonly CatalogRoutineParameter[];
515
+ readonly returnType?: CatalogStorageType;
516
+ readonly language?: string;
517
+ readonly body?: CatalogSqlExpression;
518
+ readonly volatility?: 'immutable' | 'stable' | 'volatile' | 'unknown';
519
+ readonly parallel?: 'safe' | 'restricted' | 'unsafe' | 'unknown';
520
+ readonly security?: 'invoker' | 'definer' | 'unknown';
521
+ readonly dependencies?: readonly CatalogObjectReference[];
522
+ }
523
+ /** A partition child and its normalized bound expression. */
524
+ interface CatalogPartition extends CatalogObjectBase {
525
+ readonly kind: 'partition';
526
+ readonly parent: CatalogObjectReference;
527
+ readonly strategy: 'range' | 'list' | 'hash' | 'reference' | 'unknown';
528
+ readonly keyColumns?: readonly string[];
529
+ readonly bound?: CatalogSqlExpression;
530
+ readonly default?: boolean;
531
+ }
532
+ /** A row-level security policy attached to a table. */
533
+ interface CatalogPolicy extends CatalogObjectBase {
534
+ readonly kind: 'policy';
535
+ readonly table: CatalogObjectReference;
536
+ readonly command: 'all' | 'select' | 'insert' | 'update' | 'delete' | 'unknown';
537
+ readonly roles?: readonly string[];
538
+ readonly permissive?: boolean;
539
+ readonly using?: CatalogSqlExpression;
540
+ readonly check?: CatalogSqlExpression;
541
+ }
542
+ /** An engine extension object and its typed, versioned payload. */
543
+ interface CatalogExtensionObject extends CatalogObjectBase {
544
+ readonly kind: 'extension';
545
+ readonly extensionName: string;
546
+ readonly extensionVersion?: string;
547
+ readonly schema?: string;
548
+ readonly data: CatalogData;
549
+ readonly configuration?: CatalogData;
550
+ }
551
+ /** An observed object whose family is not yet modeled by a first-party type. */
552
+ interface CatalogOpaqueObject extends CatalogObjectBase {
553
+ readonly kind: 'opaque-object';
554
+ readonly objectKind: string;
555
+ readonly data: CatalogData;
556
+ readonly sql?: CatalogSqlExpression;
557
+ }
558
+ /** Naming alias for adapters that call retained objects "unknown" records. */
559
+ type CatalogUnknownObject = CatalogOpaqueObject;
560
+ /** Every complete object family retained by the normalized catalog. */
561
+ type CatalogCompleteObject = CatalogTable | CatalogView | CatalogSequence | CatalogEnum | CatalogDomain | CatalogCollation | CatalogTrigger | CatalogRoutine | CatalogPartition | CatalogPolicy | CatalogExtensionObject | CatalogOpaqueObject | CatalogDeferredObject | CatalogComment | CatalogOwnership;
562
+ /** Short alias for the complete normalized object union. */
563
+ type CatalogObject = CatalogCompleteObject;
564
+ /** The complete normalized catalog shape used by the v2 snapshot mapper. */
565
+ interface CompleteIntrospectionCatalog {
566
+ readonly dialect: CatalogDialect;
567
+ readonly server: CatalogServerInfo;
568
+ readonly capabilities: CatalogCapabilities;
569
+ readonly namespace: CatalogNamespace;
570
+ readonly tables: readonly CatalogTable[];
571
+ readonly views: readonly CatalogView[];
572
+ readonly sequences: readonly CatalogSequence[];
573
+ readonly enums: readonly CatalogEnum[];
574
+ readonly domains: readonly CatalogDomain[];
575
+ readonly collations: readonly CatalogCollation[];
576
+ readonly triggers: readonly CatalogTrigger[];
577
+ readonly routines: readonly CatalogRoutine[];
578
+ readonly partitions: readonly CatalogPartition[];
579
+ readonly policies: readonly CatalogPolicy[];
580
+ readonly extensionObjects: readonly CatalogExtensionObject[];
581
+ readonly deferredObjects: readonly CatalogDeferredObject[];
582
+ readonly opaqueObjects: readonly CatalogOpaqueObject[];
583
+ readonly comments: readonly CatalogComment[];
584
+ readonly ownership: readonly CatalogOwnership[];
585
+ readonly diagnostics: readonly IntrospectionDiagnostic[];
586
+ }
587
+ /** The complete normalized catalog for one selected physical namespace. */
588
+ interface IntrospectionCatalog {
589
+ readonly dialect: CatalogDialect;
590
+ readonly server: CatalogServerInfo;
591
+ readonly namespace: CatalogNamespace;
592
+ readonly tables: readonly CatalogTable[];
593
+ /** Complete object families are optional until a dialect reader populates them. */
594
+ readonly views?: readonly CatalogView[];
595
+ readonly sequences?: readonly CatalogSequence[];
596
+ readonly enums?: readonly CatalogEnum[];
597
+ readonly domains?: readonly CatalogDomain[];
598
+ readonly collations?: readonly CatalogCollation[];
599
+ readonly triggers?: readonly CatalogTrigger[];
600
+ readonly routines?: readonly CatalogRoutine[];
601
+ readonly partitions?: readonly CatalogPartition[];
602
+ readonly policies?: readonly CatalogPolicy[];
603
+ readonly extensionObjects?: readonly CatalogExtensionObject[];
604
+ readonly deferredObjects: readonly CatalogDeferredObject[];
605
+ readonly opaqueObjects?: readonly CatalogOpaqueObject[];
606
+ readonly comments?: readonly CatalogComment[];
607
+ readonly ownership?: readonly CatalogOwnership[];
608
+ readonly capabilities?: CatalogCapabilities;
609
+ readonly diagnostics: readonly IntrospectionDiagnostic[];
610
+ }
611
+ /** Strictness of the optional normalized-catalog-to-snapshot step. */
612
+ type IntrospectionMode = 'strict' | 'lossy';
613
+ /** Inputs shared by dialect adapters and the later snapshot mapper. */
614
+ interface IntrospectionOptions {
615
+ /** PostgreSQL schema, MySQL database, or SQLite database name. */
616
+ readonly namespace: string;
617
+ readonly previousSnapshot?: SchemaSnapshot;
618
+ readonly identityHints?: CatalogIdentityHints;
619
+ readonly identityPolicy?: CatalogIdentityPolicy;
620
+ /** Strict is the default. Lossy output must be requested explicitly. */
621
+ readonly mode?: IntrospectionMode;
622
+ readonly signal?: AbortSignal;
623
+ }
624
+ /** A successful introspection result with a canonical snapshot. */
625
+ interface IntrospectionSuccess {
626
+ readonly ok: true;
627
+ readonly catalog: IntrospectionCatalog;
628
+ readonly snapshot: SchemaSnapshot;
629
+ readonly diagnostics: readonly IntrospectionDiagnostic[];
630
+ readonly lossy: boolean;
631
+ }
632
+ /** A failed introspection result, optionally retaining a partial catalog. */
633
+ interface IntrospectionFailure {
634
+ readonly ok: false;
635
+ readonly catalog?: IntrospectionCatalog;
636
+ readonly diagnostics: readonly IntrospectionDiagnostic[];
637
+ readonly lossy: false;
638
+ }
639
+ /** Result returned by a non-throwing introspection operation. */
640
+ type IntrospectionResult = IntrospectionSuccess | IntrospectionFailure;
641
+ /** Function shape for a later dialect-specific catalog reader. */
642
+ type CatalogIntrospector = (connection: CatalogConnection, options: IntrospectionOptions) => Promise<IntrospectionResult>;
643
+ //#endregion
644
+ export { CatalogTrigger as $, CatalogNamespace as A, CatalogQuery as At, CatalogPrimaryKeyConstraint as B, CatalogForeignKeyTarget as C, IntrospectionDiagnosticCode as Ct, CatalogIndexTerm as D, createIntrospectionDiagnostic as Dt, CatalogIndex as E, IntrospectionError as Et, CatalogOpaqueObject as F, CatalogRoutine as G, CatalogProvenanceKind as H, CatalogOwnership as I, CatalogSequence as J, CatalogRoutineParameter as K, CatalogPartition as L, CatalogObjectBase as M, CatalogObjectMetadata as N, CatalogIntrospector as O, hasIntrospectionErrors as Ot, CatalogObjectReference as P, CatalogTable as Q, CatalogPolicy as R, CatalogForeignKeyConstraint as S, IntrospectionDiagnostic as St, CatalogIdentity as T, IntrospectionDiagnosticSeverity as Tt, CatalogQueryRow as U, CatalogProvenance as V, CatalogReference as W, CatalogSqlExpression as X, CatalogServerInfo as Y, CatalogStorageType as Z, CatalogEntityReference as _, CatalogIdentityPolicy as _t, CatalogCollation as a, CatalogView as at, CatalogExpressionFact as b, CatalogResolvedIdentity as bt, CatalogCompleteObject as c, IntrospectionFailure as ct, CatalogDeferredObject as d, IntrospectionResult as dt, CatalogUniqueConstraint as et, CatalogDeferredObjectKind as f, IntrospectionSuccess as ft, CatalogEntityKind as g, CatalogIdentityHints as gt, CatalogDomain as h, CatalogIdentityHint as ht, CatalogClassificationConfidence as i, CatalogVersion as it, CatalogObject as j, CatalogQueryOptions as jt, CatalogLiteralFact as k, CatalogConnection as kt, CatalogConstraint as l, IntrospectionMode as lt, CatalogDialectExtension as m, CatalogIdentityFallback as mt, CatalogCatalogReference as n, CatalogUnknownObject as nt, CatalogColumn as o, CompleteIntrospectionCatalog as ot, CatalogDialect as p, CatalogIdentityEntityKind as pt, CatalogScalar as q, CatalogCheckConstraint as r, CatalogValueFact as rt, CatalogComment as s, IntrospectionCatalog as st, CatalogCapabilities as t, CatalogUnknownField as tt, CatalogData as u, IntrospectionOptions as ut, CatalogEnum as v, CatalogIdentitySource as vt, CatalogGeneratedColumn as w, IntrospectionDiagnosticInput as wt, CatalogExtensionObject as x, introspectedPhysicalIdentityPolicy as xt, CatalogEnumValue as y, CatalogPreviousSnapshotIdentitySource as yt, CatalogPortableStorageType as z };