qubu 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/dist/{canonical-BbnqavJm.mjs → canonical-BXUguqfo.mjs} +23 -23
  2. package/dist/codegen.d.mts +25 -33
  3. package/dist/codegen.mjs +38 -45
  4. package/dist/column-hqKr7-1I.mjs +620 -0
  5. package/dist/{complete-D5Djh-zo.mjs → complete-WYyVozgK.mjs} +50 -50
  6. package/dist/{complete-types-BavBtv8J.d.mts → complete-types-IjEn5VPN.d.mts} +56 -56
  7. package/dist/core.d.mts +2 -2
  8. package/dist/core.mjs +4 -4
  9. package/dist/ddl.d.mts +12 -12
  10. package/dist/ddl.mjs +13 -14
  11. package/dist/{dialect-b2-Z6uBF.mjs → dialect-wUKrnPMB.mjs} +2 -2
  12. package/dist/diff.d.mts +1 -1
  13. package/dist/diff.mjs +6 -7
  14. package/dist/{index-DH0qV6aS.d.mts → index-1DpA3mUh.d.mts} +20 -20
  15. package/dist/{index-D3ZOwPT-.d.mts → index-CPvfEheG.d.mts} +13 -15
  16. package/dist/index.d.mts +1 -1
  17. package/dist/index.mjs +94 -95
  18. package/dist/introspection.d.mts +8 -8
  19. package/dist/introspection.mjs +29 -30
  20. package/dist/{json-CUZlv4HT.mjs → json-Db7XRD91.mjs} +2 -2
  21. package/dist/migration.d.mts +20 -21
  22. package/dist/migration.mjs +5 -6
  23. package/dist/{mysql-CKEKGnj4.mjs → mysql-B_cYzzX2.mjs} +237 -7
  24. package/dist/mysql.d.mts +1 -1
  25. package/dist/mysql.mjs +3 -3
  26. package/dist/{on-conflict-4MOBl51J.mjs → on-conflict-hfPW0KmQ.mjs} +3 -4
  27. package/dist/postgres.d.mts +5 -5
  28. package/dist/postgres.mjs +6 -6
  29. package/dist/{registry-CXV8u7Pt.mjs → registry-BRMLYwDp.mjs} +26 -29
  30. package/dist/{relational-DuQ9IHSb.mjs → relational-BZ3WDPzC.mjs} +2 -2
  31. package/dist/schema.d.mts +1 -1
  32. package/dist/schema.mjs +5 -6
  33. package/dist/{snapshot-DJpfmxhQ.mjs → snapshot-C-W65HEd.mjs} +5 -5
  34. package/dist/snapshot.d.mts +3 -3
  35. package/dist/snapshot.mjs +5 -7
  36. package/dist/{source-DGO3DRgg.mjs → source-BcS2AsIg.mjs} +6 -8
  37. package/dist/{serialize-CFtYYAdk.mjs → sqlite-Cg0nwYEH.mjs} +326 -12
  38. package/dist/sqlite.d.mts +2 -2
  39. package/dist/sqlite.mjs +2 -2
  40. package/dist/{standard-BTVYKh_F.mjs → standard-DfcZEVOj.mjs} +1 -1
  41. package/dist/{table-D6rcs8SB.mjs → table-Bp5irMSj.mjs} +2 -3
  42. package/dist/{types-Deo_q43Y.d.mts → types-BK1COGZe.d.mts} +1113 -1128
  43. package/dist/{types-g-vVvj1B.mjs → types-JM3FcAnX.mjs} +7 -8
  44. package/dist/{types-CSNJTYaM.d.mts → types-JSZHpUEj.d.mts} +83 -84
  45. package/dist/{value-b6OFZXVS.mjs → value-Bi71Agyf.mjs} +1 -1
  46. package/dist/vite/ambient.d.ts +309 -340
  47. package/dist/vite.d.mts +5 -6
  48. package/dist/vite.mjs +3 -4
  49. package/docs/dialects-and-execution.md +45 -55
  50. package/docs/getting-started.md +4 -4
  51. package/docs/guides/better-auth.md +57 -0
  52. package/docs/guides/compose-queries.md +24 -67
  53. package/docs/guides/drizzle.md +23 -23
  54. package/docs/guides/extensions/dialects.md +4 -4
  55. package/docs/guides/extensions/sources-and-clauses.md +15 -15
  56. package/docs/guides/extensions/typed-expressions.md +13 -17
  57. package/docs/guides/extensions/unsafe-syntax.md +3 -3
  58. package/docs/guides/json.md +7 -7
  59. package/docs/guides/mutations.md +14 -21
  60. package/docs/guides/select/conditions.md +6 -8
  61. package/docs/guides/select/grouping-and-windows.md +4 -15
  62. package/docs/guides/select/ordering-and-pagination.md +6 -19
  63. package/docs/guides/select/overview.md +12 -26
  64. package/docs/guides/sql-templates.md +20 -24
  65. package/docs/guides/vite-plugin.md +9 -13
  66. package/docs/index.md +5 -7
  67. package/docs/query-model/fragments.md +4 -15
  68. package/docs/query-model/result-shapes.md +11 -14
  69. package/docs/query-model/source-scope.md +31 -49
  70. package/docs/reference/mysql-snapshot.md +2 -5
  71. package/docs/reference/postgres-snapshot.md +3 -3
  72. package/docs/reference/sqlite-snapshot.md +2 -5
  73. package/docs/reference/supported-surface.md +26 -26
  74. package/docs/schema/catalog-model.md +2 -5
  75. package/docs/schema/code-generation.md +18 -18
  76. package/docs/schema/columns-and-writes.md +17 -25
  77. package/docs/schema/constraints-and-indexes.md +36 -52
  78. package/docs/schema/ddl-emission.md +6 -6
  79. package/docs/schema/diff.md +5 -5
  80. package/docs/schema/introspection.md +7 -7
  81. package/docs/schema/migration-plans.md +9 -9
  82. package/docs/schema/snapshots.md +3 -3
  83. package/docs/schema/storage-and-schema-sql.md +11 -11
  84. package/docs/schema/tables-and-names.md +11 -14
  85. package/docs/sql-semantic-types.md +10 -10
  86. package/docs/troubleshooting.md +10 -10
  87. package/package.json +21 -33
  88. package/skills/qubu/agents/openai.yaml +3 -3
  89. package/dist/column-D-8OqGuV.mjs +0 -328
  90. package/dist/column-LV7oGQde.mjs +0 -296
  91. package/dist/drizzle-mysql.d.mts +0 -24
  92. package/dist/drizzle-mysql.mjs +0 -72
  93. package/dist/drizzle-postgres.d.mts +0 -24
  94. package/dist/drizzle-postgres.mjs +0 -73
  95. package/dist/drizzle-sqlite.d.mts +0 -57
  96. package/dist/drizzle-sqlite.mjs +0 -108
  97. package/dist/drizzle.d.mts +0 -13
  98. package/dist/drizzle.mjs +0 -2
  99. package/dist/errors-BGCoLe_r.mjs +0 -14
  100. package/dist/postgres-BK2APkKP.mjs +0 -236
  101. package/dist/runtime-Cn_Xgzta.mjs +0 -193
  102. package/dist/sqlite-CrsK0Fza.mjs +0 -320
  103. package/dist/types-DZsueVoI.d.mts +0 -45
@@ -93,7 +93,7 @@ function validateSnapshot(value, diagnostics) {
93
93
  if (validated !== void 0) tables.push(validated);
94
94
  }
95
95
  }
96
- if (dialect === void 0 || namingPolicy === void 0) return void 0;
96
+ if (dialect === void 0 || namingPolicy === void 0) return;
97
97
  validateCrossReferences(tables, diagnostics);
98
98
  return {
99
99
  format: schemaSnapshotFormat,
@@ -113,7 +113,7 @@ function validateDialect(value, path, diagnostics) {
113
113
  if (typeof value.name !== "string" || value.name.length === 0) diagnostics.push(diagnostic("invalid-snapshot", "Dialect name must be non-empty", [...path, "name"]));
114
114
  if (typeof value.version !== "number" || !Number.isSafeInteger(value.version) || value.version < 1) diagnostics.push(diagnostic("invalid-snapshot", "Dialect version must be a positive integer", [...path, "version"]));
115
115
  else if (value.version > 1) diagnostics.push(diagnostic("future-version", `Unsupported dialect extension version: ${value.version}`, [...path, "version"]));
116
- if (typeof value.name !== "string" || typeof value.version !== "number") return void 0;
116
+ if (typeof value.name !== "string" || typeof value.version !== "number") return;
117
117
  return {
118
118
  name: value.name,
119
119
  version: value.version
@@ -127,7 +127,7 @@ function validateNamingPolicy(value, path, diagnostics) {
127
127
  requireKeys(value, ["name", "version"], path, diagnostics);
128
128
  if (typeof value.name !== "string" || value.name.length === 0) diagnostics.push(diagnostic("invalid-snapshot", "Naming-policy name must be non-empty", [...path, "name"]));
129
129
  if (value.version !== 1) diagnostics.push(diagnostic(typeof value.version === "number" && value.version > 1 ? "future-version" : "invalid-snapshot", `Unsupported naming-policy version: ${String(value.version)}`, [...path, "version"]));
130
- if (typeof value.name !== "string" || typeof value.version !== "number") return void 0;
130
+ if (typeof value.name !== "string" || typeof value.version !== "number") return;
131
131
  return {
132
132
  name: value.name,
133
133
  version: value.version
@@ -153,7 +153,7 @@ function validateTable(value, path, dialect, diagnostics) {
153
153
  validateSortedIds(value.columns, [...path, "columns"], diagnostics);
154
154
  validateSortedIds(value.constraints, [...path, "constraints"], diagnostics);
155
155
  validateSortedIds(value.indexes, [...path, "indexes"], diagnostics);
156
- if (id === void 0 || physicalName === void 0 || columns === void 0 || constraints === void 0 || indexes === void 0) return void 0;
156
+ if (id === void 0 || physicalName === void 0 || columns === void 0 || constraints === void 0 || indexes === void 0) return;
157
157
  return {
158
158
  id,
159
159
  physicalName,
@@ -196,7 +196,7 @@ function validateColumn(value, path, dialect, diagnostics) {
196
196
  const identity = value.identity === void 0 ? void 0 : validateIdentity(value.identity, [...path, "identity"], dialect, diagnostics);
197
197
  const onUpdate = value.onUpdate === void 0 ? void 0 : validateExpression(value.onUpdate, [...path, "onUpdate"], "default", dialect, diagnostics);
198
198
  if (onUpdate !== void 0 && dialect !== "mysql") diagnostics.push(diagnostic("dialect-mismatch", "Column onUpdate metadata is only valid for MySQL snapshots", [...path, "onUpdate"]));
199
- if (id === void 0 || physicalName === void 0 || nullable === void 0 || hasDefault === void 0 || generated === void 0) return void 0;
199
+ if (id === void 0 || physicalName === void 0 || nullable === void 0 || hasDefault === void 0 || generated === void 0) return;
200
200
  return {
201
201
  id,
202
202
  physicalName,
@@ -311,7 +311,7 @@ function validateIdentity(value, path, dialect, diagnostics) {
311
311
  ], path, diagnostics, ["dialect"]);
312
312
  if (value.kind !== "identity") diagnostics.push(diagnostic("invalid-snapshot", "Identity kind must be identity", [...path, "kind"]));
313
313
  if (value.generation !== "always" && value.generation !== "by-default") diagnostics.push(diagnostic("invalid-snapshot", "Identity generation is invalid", [...path, "generation"]));
314
- if (value.kind !== "identity" || value.generation !== "always" && value.generation !== "by-default") return void 0;
314
+ if (value.kind !== "identity" || value.generation !== "always" && value.generation !== "by-default") return;
315
315
  const extension = validateExtension(value.dialect, [...path, "dialect"], dialect, diagnostics);
316
316
  return {
317
317
  kind: "identity",
@@ -325,7 +325,7 @@ function validateConstraint(value, path, dialect, diagnostics) {
325
325
  return;
326
326
  }
327
327
  const common = validateConstraintCommon(value, path, diagnostics);
328
- if (common === void 0) return void 0;
328
+ if (common === void 0) return;
329
329
  if (value.kind === "primary-key" || value.kind === "unique") {
330
330
  requireKeys(value, [
331
331
  "id",
@@ -343,7 +343,7 @@ function validateConstraint(value, path, dialect, diagnostics) {
343
343
  const columns = validateColumnIds(value.columns, [...path, "columns"], diagnostics);
344
344
  const extra = validateConstraintTiming(value, path, diagnostics);
345
345
  const extension = validateExtension(value.dialect, [...path, "dialect"], dialect, diagnostics);
346
- if (columns === void 0 || extra === void 0) return void 0;
346
+ if (columns === void 0 || extra === void 0) return;
347
347
  return {
348
348
  ...common,
349
349
  kind: value.kind,
@@ -371,7 +371,7 @@ function validateConstraint(value, path, dialect, diagnostics) {
371
371
  const extra = validateConstraintTiming(value, path, diagnostics);
372
372
  const extension = validateExtension(value.dialect, [...path, "dialect"], dialect, diagnostics);
373
373
  if (value.nulls !== "distinct" && value.nulls !== "not-distinct") diagnostics.push(diagnostic("invalid-snapshot", "Unique-constraint null semantics are invalid", [...path, "nulls"]));
374
- if (columns === void 0 || extra === void 0 || value.nulls !== "distinct" && value.nulls !== "not-distinct") return void 0;
374
+ if (columns === void 0 || extra === void 0 || value.nulls !== "distinct" && value.nulls !== "not-distinct") return;
375
375
  return {
376
376
  ...common,
377
377
  kind: "unique-constraint",
@@ -406,7 +406,7 @@ function validateConstraint(value, path, dialect, diagnostics) {
406
406
  const target = validateForeignKeyTarget(value.target, [...path, "target"], diagnostics);
407
407
  const extra = validateForeignKeyOptions(value, path, diagnostics);
408
408
  const extension = validateExtension(value.dialect, [...path, "dialect"], dialect, diagnostics);
409
- if (columns === void 0 || target === void 0 || extra === void 0) return void 0;
409
+ if (columns === void 0 || target === void 0 || extra === void 0) return;
410
410
  return {
411
411
  ...common,
412
412
  kind: "foreign-key",
@@ -433,7 +433,7 @@ function validateConstraint(value, path, dialect, diagnostics) {
433
433
  const expression = validateExpression(value.expression, [...path, "expression"], "check", dialect, diagnostics);
434
434
  const extra = validateConstraintTiming(value, path, diagnostics);
435
435
  const extension = validateExtension(value.dialect, [...path, "dialect"], dialect, diagnostics);
436
- if (expression === void 0 || extra === void 0) return void 0;
436
+ if (expression === void 0 || extra === void 0) return;
437
437
  return {
438
438
  ...common,
439
439
  kind: "check",
@@ -447,7 +447,7 @@ function validateConstraint(value, path, dialect, diagnostics) {
447
447
  function validateConstraintCommon(value, path, diagnostics) {
448
448
  const id = validateId(value.id, [...path, "id"], diagnostics);
449
449
  const physicalName = validateName(value.physicalName, [...path, "physicalName"], diagnostics);
450
- if (id === void 0 || physicalName === void 0) return void 0;
450
+ if (id === void 0 || physicalName === void 0) return;
451
451
  return {
452
452
  id,
453
453
  kind: value.kind,
@@ -458,8 +458,8 @@ function validateConstraintTiming(value, path, diagnostics) {
458
458
  const deferrable = validateOptionalBoolean(value.deferrable, [...path, "deferrable"], diagnostics);
459
459
  const initially = value.initially === void 0 ? void 0 : value.initially === "immediate" || value.initially === "deferred" ? value.initially : void 0;
460
460
  if (value.initially !== void 0 && initially === void 0) diagnostics.push(diagnostic("invalid-snapshot", "Constraint timing is invalid", [...path, "initially"]));
461
- if (deferrable === void 0 && value.deferrable !== void 0) return void 0;
462
- if (value.initially !== void 0 && initially === void 0) return void 0;
461
+ if (deferrable === void 0 && value.deferrable !== void 0) return;
462
+ if (value.initially !== void 0 && initially === void 0) return;
463
463
  return {
464
464
  ...deferrable === void 0 ? {} : { deferrable },
465
465
  ...initially === void 0 ? {} : { initially }
@@ -468,7 +468,7 @@ function validateConstraintTiming(value, path, diagnostics) {
468
468
  function validateForeignKeyOptions(value, path, diagnostics) {
469
469
  const action = (key) => {
470
470
  const candidate = value[key];
471
- if (candidate === void 0) return void 0;
471
+ if (candidate === void 0) return;
472
472
  if (candidate === "no-action" || candidate === "restrict" || candidate === "cascade" || candidate === "set-null" || candidate === "set-default") return candidate;
473
473
  diagnostics.push(diagnostic("invalid-snapshot", `Foreign-key ${key} action is invalid`, [...path, key]));
474
474
  };
@@ -477,7 +477,7 @@ function validateForeignKeyOptions(value, path, diagnostics) {
477
477
  const match = value.match === void 0 ? void 0 : value.match === "simple" || value.match === "full" || value.match === "partial" ? value.match : void 0;
478
478
  if (value.match !== void 0 && match === void 0) diagnostics.push(diagnostic("invalid-snapshot", "Foreign-key match mode is invalid", [...path, "match"]));
479
479
  const timing = validateConstraintTiming(value, path, diagnostics);
480
- if (timing === void 0 || value.onUpdate !== void 0 && onUpdate === void 0 || value.onDelete !== void 0 && onDelete === void 0 || value.match !== void 0 && match === void 0) return void 0;
480
+ if (timing === void 0 || value.onUpdate !== void 0 && onUpdate === void 0 || value.onDelete !== void 0 && onDelete === void 0 || value.match !== void 0 && match === void 0) return;
481
481
  return {
482
482
  ...onUpdate === void 0 ? {} : { onUpdate },
483
483
  ...onDelete === void 0 ? {} : { onDelete },
@@ -527,7 +527,7 @@ function validateIndex(value, path, dialect, diagnostics) {
527
527
  const predicate = value.predicate === void 0 ? void 0 : validateExpression(value.predicate, [...path, "predicate"], "index", dialect, diagnostics);
528
528
  const includedColumns = value.includedColumns === void 0 ? void 0 : validateColumnIds(value.includedColumns, [...path, "includedColumns"], diagnostics);
529
529
  const extension = validateExtension(value.dialect, [...path, "dialect"], dialect, diagnostics);
530
- if (id === void 0 || physicalName === void 0 || unique === void 0 || candidateKey === void 0 || terms === void 0 || value.kind !== "index" || terms.length === 0) return void 0;
530
+ if (id === void 0 || physicalName === void 0 || unique === void 0 || candidateKey === void 0 || terms === void 0 || value.kind !== "index" || terms.length === 0) return;
531
531
  return {
532
532
  id,
533
533
  kind: "index",
@@ -573,7 +573,7 @@ function validateIndexTerm(value, path, dialect, diagnostics) {
573
573
  const nulls = value.nulls === void 0 ? void 0 : value.nulls === "FIRST" || value.nulls === "LAST" ? value.nulls : void 0;
574
574
  if (value.direction !== void 0 && direction === void 0) diagnostics.push(diagnostic("invalid-snapshot", "Index order direction is invalid", [...path, "direction"]));
575
575
  if (value.nulls !== void 0 && nulls === void 0) diagnostics.push(diagnostic("invalid-snapshot", "Index NULL ordering is invalid", [...path, "nulls"]));
576
- if (expression === void 0 || value.direction !== void 0 && direction === void 0 || value.nulls !== void 0 && nulls === void 0) return void 0;
576
+ if (expression === void 0 || value.direction !== void 0 && direction === void 0 || value.nulls !== void 0 && nulls === void 0) return;
577
577
  return {
578
578
  kind: "order",
579
579
  expression,
@@ -626,7 +626,7 @@ function validateExpression(value, path, _mode, dialect, diagnostics) {
626
626
  if (expressionDialect !== void 0 && value.expressionKind !== "unsafe") diagnostics.push(diagnostic("invalid-snapshot", "Only unsafe expressions may carry a dialect tag", [...path, "dialect"]));
627
627
  if (expressionDialect === void 0 && value.expressionKind === "unsafe") diagnostics.push(diagnostic("invalid-snapshot", "Unsafe expressions must carry a dialect tag", [...path, "dialect"]));
628
628
  if (sql !== void 0 && sql !== sql.replace(/\r\n?/g, "\n")) diagnostics.push(diagnostic("non-canonical", "Expression SQL must use LF line endings", [...path, "sql"]));
629
- if (expressionKind === void 0 || sql === void 0 || value.kind !== "expression") return void 0;
629
+ if (expressionKind === void 0 || sql === void 0 || value.kind !== "expression") return;
630
630
  return {
631
631
  kind: "expression",
632
632
  expressionKind,
@@ -670,7 +670,7 @@ function validateLiteral(value, path, diagnostics) {
670
670
  diagnostics.push(diagnostic("invalid-snapshot", "Literal kind is invalid", [...path, "kind"]));
671
671
  }
672
672
  function validateExtension(value, path, dialect, diagnostics) {
673
- if (value === void 0) return void 0;
673
+ if (value === void 0) return;
674
674
  if (!isRecord(value)) {
675
675
  diagnostics.push(diagnostic("invalid-snapshot", "Dialect extension must be an object", path));
676
676
  return;
@@ -686,7 +686,7 @@ function validateExtension(value, path, dialect, diagnostics) {
686
686
  else if (version > 1) diagnostics.push(diagnostic("future-version", `Unsupported dialect extension version: ${version}`, [...path, "version"]));
687
687
  if (extensionDialect !== void 0 && dialect !== void 0 && extensionDialect !== dialect) diagnostics.push(diagnostic("dialect-mismatch", `Dialect extension belongs to "${extensionDialect}" but snapshot dialect is "${dialect}"`, [...path, "dialect"]));
688
688
  const data = validateJsonValue(value.data, [...path, "data"], diagnostics);
689
- if (extensionDialect === void 0 || typeof version !== "number" || data === void 0) return void 0;
689
+ if (extensionDialect === void 0 || typeof version !== "number" || data === void 0) return;
690
690
  return {
691
691
  dialect: extensionDialect,
692
692
  version,
@@ -943,8 +943,8 @@ function encodeCanonicalSnapshot(snapshot) {
943
943
  return canonicalJson(snapshot);
944
944
  }
945
945
  /**
946
- * Compute a small deterministic content digest for cache keys and diagnostics.
947
- * It is deliberately not an entity identity, signature, or migration lineage.
946
+ * Compute a small deterministic content digest for cache keys and diagnostics. It is deliberately
947
+ * not an entity identity, signature, or migration lineage.
948
948
  */
949
949
  function schemaSnapshotDigest(snapshot) {
950
950
  const source = encodeCanonicalSnapshot(assertSchemaSnapshot(snapshot));
@@ -1,12 +1,12 @@
1
- import { St as IntrospectionDiagnostic, dt as IntrospectionResult, i as CatalogClassificationConfidence, p as CatalogDialect, z as CatalogPortableStorageType } from "./types-CSNJTYaM.mjs";
1
+ import { St as IntrospectionDiagnostic, dt as IntrospectionResult, i as CatalogClassificationConfidence, p as CatalogDialect, z as CatalogPortableStorageType } from "./types-JSZHpUEj.mjs";
2
2
  //#region src/codegen/types.d.ts
3
3
  /** TypeScript value types that the controlled source printer can emit. */
4
- type CodegenApplicationType = 'unknown' | 'string' | 'number' | 'boolean' | 'bigint' | 'Date' | 'Uint8Array';
4
+ type CodegenApplicationType = "unknown" | "string" | "number" | "boolean" | "bigint" | "Date" | "Uint8Array";
5
5
  /** Qubu SQL semantic domains that generated columns can carry. */
6
- type CodegenSqlDomain = 'unknown' | 'integer' | 'decimal' | 'text' | 'boolean' | 'date' | 'timestamp' | 'uuid' | 'json' | 'bigint' | 'binary';
6
+ type CodegenSqlDomain = "unknown" | "integer" | "decimal" | "text" | "boolean" | "date" | "timestamp" | "uuid" | "json" | "bigint" | "binary";
7
7
  /** One logical-name decision exposed to a generator naming callback. */
8
8
  interface CodegenNameContext {
9
- readonly kind: 'schema' | 'table' | 'column' | 'constraint' | 'index';
9
+ readonly kind: "schema" | "table" | "column" | "constraint" | "index";
10
10
  readonly physicalName: string;
11
11
  readonly suggestedName: string;
12
12
  readonly tablePhysicalName?: string;
@@ -39,21 +39,20 @@ interface CodegenColumnMapping {
39
39
  /** Controlled customization points for generated logical names and types. */
40
40
  interface SchemaCodegenOptions {
41
41
  /**
42
- * Override one suggested camelCase name. The returned value must still be a
43
- * safe camelCase logical ID, and table and schema names must be valid export
44
- * bindings.
42
+ * Override one suggested camelCase name. The returned value must still be a safe camelCase
43
+ * logical ID, and table and schema names must be valid export bindings.
45
44
  */
46
45
  readonly naming?: (context: CodegenNameContext) => string | undefined;
47
46
  /**
48
- * Override trusted application types or a Qubu SQL domain for one column.
49
- * The callback selects from fixed tokens and cannot inject source text.
47
+ * Override trusted application types or a Qubu SQL domain for one column. The callback selects
48
+ * from fixed tokens and cannot inject source text.
50
49
  */
51
50
  readonly mapColumn?: (context: CodegenColumnContext) => CodegenColumnMapping | undefined;
52
51
  }
53
52
  /** Stable generator findings added beside retained introspection diagnostics. */
54
- type CodegenDiagnosticCode = IntrospectionDiagnostic['code'] | 'invalid-input' | 'lossy-input' | 'unsupported-snapshot' | 'omitted-fact' | 'unsafe-name' | 'name-collision' | 'invalid-option' | 'unrepresentable-fact' | 'excluded-object-family' | 'unsafe-source';
53
+ type CodegenDiagnosticCode = IntrospectionDiagnostic["code"] | "invalid-input" | "lossy-input" | "unsupported-snapshot" | "omitted-fact" | "unsafe-name" | "name-collision" | "invalid-option" | "unrepresentable-fact" | "excluded-object-family" | "unsafe-source";
55
54
  /** A path-addressed finding returned by schema source generation. */
56
- interface CodegenDiagnostic extends Omit<IntrospectionDiagnostic, 'code'> {
55
+ interface CodegenDiagnostic extends Omit<IntrospectionDiagnostic, "code"> {
57
56
  readonly code: CodegenDiagnosticCode;
58
57
  readonly relatedPaths?: readonly (readonly (string | number)[])[];
59
58
  }
@@ -77,28 +76,21 @@ type SchemaCodegenResult = SchemaCodegenSuccess | SchemaCodegenFailure;
77
76
  * Generate a deterministic TypeScript module from one introspection result.
78
77
  *
79
78
  * @remarks
80
- * Generation accepts only a successful, non-lossy Snapshot v1 result for one
81
- * PostgreSQL, SQLite, or MySQL namespace. It is pure: it opens no connection,
82
- * performs no filesystem writes, and never evaluates catalog SQL. Existing
83
- * introspection diagnostics are copied into the result. Any error returns no
84
- * source.
85
- *
86
- * The generated module exports every ordinary table plus one schema registry.
87
- * Physical names and native declarations remain escaped string literals.
88
- * Catalog expressions use dialect-tagged schema data, checks use
89
- * `catalogCheck()`, and foreign keys use lazy `catalogForeignKey()` targets.
90
- * Foreign keys must have equal local and target arity and target an exact
91
- * primary key, strict unique key, or candidate index. Nullable database UNIQUE
92
- * constraints do not provide that candidate-key proof and fail generation.
93
- *
94
- * Application output, insert, and update types default independently to
95
- * `unknown`. The generator may attach a conservative SQL semantic domain, and
96
- * {@link SchemaCodegenOptions.mapColumn} can override either type axis with a
97
- * fixed token. Naming callbacks can replace suggested camelCase IDs, but they
98
- * cannot supply source syntax.
99
- *
100
- * @param input A completed introspection operation. Failed and lossy results
101
- * are reported as diagnostics rather than thrown errors.
79
+ * Generation accepts only a successful, non-lossy Snapshot v1 result for one PostgreSQL, SQLite,
80
+ * or MySQL namespace. It is pure: it opens no connection, performs no filesystem writes, and
81
+ * never evaluates catalog SQL. Existing introspection diagnostics are copied into the result. Any
82
+ * error returns no source. The generated module exports every ordinary table plus one schema
83
+ * registry. Physical names and native declarations remain escaped string literals. Catalog
84
+ * expressions use dialect-tagged schema data, checks use `catalogCheck()`, and foreign keys use
85
+ * lazy `catalogForeignKey()` targets. Foreign keys must have equal local and target arity and
86
+ * target an exact primary key, strict unique key, or candidate index. Nullable database UNIQUE
87
+ * constraints do not provide that candidate-key proof and fail generation. Application output,
88
+ * insert, and update types default independently to `unknown`. The generator may attach a
89
+ * conservative SQL semantic domain, and {@link SchemaCodegenOptions.mapColumn} can override either
90
+ * type axis with a fixed token. Naming callbacks can replace suggested camelCase IDs, but they
91
+ * cannot supply source syntax.
92
+ * @param input A completed introspection operation. Failed and lossy results are reported as
93
+ * diagnostics rather than thrown errors.
102
94
  * @param options Controlled logical-name and column-type mappings.
103
95
  * @returns Generated source and diagnostics, or diagnostics without source.
104
96
  */
package/dist/codegen.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { l as decodeSchemaSnapshot } from "./canonical-BbnqavJm.mjs";
2
- import { t as mapCatalogToSnapshot } from "./snapshot-DJpfmxhQ.mjs";
1
+ import { l as decodeSchemaSnapshot } from "./canonical-BXUguqfo.mjs";
2
+ import { t as mapCatalogToSnapshot } from "./snapshot-C-W65HEd.mjs";
3
3
  //#region src/codegen/source.ts
4
4
  const header = `/* Generated by Qubu. Do not edit this machine-owned file. */
5
5
  import * as _qubu from 'qubu'
@@ -40,7 +40,7 @@ const catalogPredicateHelper = `const _catalogPredicate = <
40
40
  `;
41
41
  function printSchemaSource(schema, diagnostics) {
42
42
  const tables = schema.tables.map((table) => printTable(schema, table, diagnostics));
43
- if (tables.some((table) => table === void 0)) return void 0;
43
+ if (tables.some((table) => table === void 0)) return;
44
44
  const registry = schema.tables.map((table) => ` ${literal(table.name)}: ${table.name},`).join("\n");
45
45
  const predicateHelper = schema.tables.some((table) => table.indexes.some((index) => index.snapshot.predicate !== void 0)) ? `\n${catalogPredicateHelper}` : "";
46
46
  const columnHelper = schema.tables.some((table) => table.columns.length > 0) ? `\n${catalogColumnHelper}` : "";
@@ -110,7 +110,7 @@ function printConstraintType(table, constraint, columnsName, diagnostics) {
110
110
  ];
111
111
  if (snapshot.kind === "check") return `readonly ${literal(constraint.name)}: _qubu.CheckConstraint`;
112
112
  const columns = printColumnTypeTuple(table, snapshot.columns, columnsName, path, diagnostics);
113
- if (columns === void 0) return void 0;
113
+ if (columns === void 0) return;
114
114
  if (snapshot.kind === "foreign-key") return `readonly ${literal(constraint.name)}: _qubu.ForeignKeyConstraint<${columns}>`;
115
115
  if (snapshot.kind === "unique-constraint") return `readonly ${literal(constraint.name)}: _qubu.UniqueConstraint<
116
116
  ${columns},
@@ -134,7 +134,7 @@ function printIndexType(table, index, columnsName, diagnostics) {
134
134
  "terms",
135
135
  position
136
136
  ], diagnostics));
137
- if (terms.some((term) => term === void 0)) return void 0;
137
+ if (terms.some((term) => term === void 0)) return;
138
138
  const properties = [
139
139
  `readonly terms: readonly [${terms.join(", ")}]`,
140
140
  `readonly unique: ${index.snapshot.unique ? "true" : "false"}`,
@@ -143,7 +143,7 @@ function printIndexType(table, index, columnsName, diagnostics) {
143
143
  ];
144
144
  if (index.snapshot.includedColumns !== void 0) {
145
145
  const included = printColumnTypeTuple(table, index.snapshot.includedColumns, columnsName, [...path, "includedColumns"], diagnostics);
146
- if (included === void 0) return void 0;
146
+ if (included === void 0) return;
147
147
  properties.push(`readonly includedColumns?: ${included}`);
148
148
  } else properties.push("readonly includedColumns?: undefined");
149
149
  return `readonly ${literal(index.name)}: {
@@ -199,7 +199,7 @@ function printColumn(schema, table, column, diagnostics) {
199
199
  if (snapshot.default.kind === "external") options.push("default: _qubu.externalDefault()");
200
200
  else if (snapshot.default.kind === "literal") {
201
201
  const value = printSnapshotLiteral(snapshot.default.value, path, diagnostics);
202
- if (value === void 0) return void 0;
202
+ if (value === void 0) return;
203
203
  options.push(`default: ${value}`);
204
204
  } else {
205
205
  const value = printExpression(snapshot.default.expression, schema, [
@@ -207,7 +207,7 @@ function printColumn(schema, table, column, diagnostics) {
207
207
  "default",
208
208
  "expression"
209
209
  ], diagnostics);
210
- if (value === void 0) return void 0;
210
+ if (value === void 0) return;
211
211
  options.push(`default: ${value}`);
212
212
  }
213
213
  }
@@ -219,7 +219,7 @@ function printColumn(schema, table, column, diagnostics) {
219
219
  "generatedColumn",
220
220
  "expression"
221
221
  ], diagnostics);
222
- if (expression === void 0) return void 0;
222
+ if (expression === void 0) return;
223
223
  options.push(`generatedColumn: _qubu.generatedColumn(${expression}, ${literal(snapshot.generatedColumn.mode)})`);
224
224
  }
225
225
  }
@@ -234,7 +234,7 @@ function printColumn(schema, table, column, diagnostics) {
234
234
  }
235
235
  if (snapshot.onUpdate !== void 0) {
236
236
  const expression = printExpression(snapshot.onUpdate, schema, [...path, "onUpdate"], diagnostics);
237
- if (expression === void 0) return void 0;
237
+ if (expression === void 0) return;
238
238
  options.push(`onUpdate: ${expression}`);
239
239
  }
240
240
  const types = [
@@ -262,11 +262,11 @@ function printConstraint(schema, table, constraint, diagnostics) {
262
262
  snapshot.id
263
263
  ];
264
264
  const options = printConstraintOptions(snapshot, schema, path, diagnostics);
265
- if (options === void 0) return void 0;
265
+ if (options === void 0) return;
266
266
  let expression;
267
267
  if (snapshot.kind === "check") {
268
268
  const sql = catalogExpressionData(snapshot.expression, schema, [...path, "expression"], diagnostics);
269
- if (sql === void 0) return void 0;
269
+ if (sql === void 0) return;
270
270
  expression = `_qubu.catalogCheck(${sql}, ${options})`;
271
271
  } else if (snapshot.kind === "foreign-key") {
272
272
  const local = printColumns(table, snapshot.columns, path, diagnostics);
@@ -280,7 +280,7 @@ function printConstraint(schema, table, constraint, diagnostics) {
280
280
  return;
281
281
  }
282
282
  const target = printColumns(targetTable, snapshot.target.columns, [...path, "target"], diagnostics, targetTable.name);
283
- if (local === void 0 || target === void 0) return void 0;
283
+ if (local === void 0 || target === void 0) return;
284
284
  expression = `_qubu.catalogForeignKey(
285
285
  [${local.join(", ")}],
286
286
  () => _qubu.references(${targetTable.name}, ${target.join(", ")}),
@@ -288,7 +288,7 @@ function printConstraint(schema, table, constraint, diagnostics) {
288
288
  )`;
289
289
  } else {
290
290
  const columns = printColumns(table, snapshot.columns, path, diagnostics);
291
- if (columns === void 0) return void 0;
291
+ if (columns === void 0) return;
292
292
  expression = `_qubu.${snapshot.kind === "primary-key" ? "primaryKey" : snapshot.kind === "unique" ? "unique" : "uniqueConstraint"}(${columns.join(", ")}, ${options})`;
293
293
  }
294
294
  return `${literal(constraint.name)}: ${expression},`;
@@ -305,7 +305,7 @@ function printConstraintOptions(constraint, schema, path, diagnostics) {
305
305
  if (constraint.initially !== void 0) properties.push(`initially: ${literal(constraint.initially)}`);
306
306
  if (constraint.dialect !== void 0) {
307
307
  const extension = printExtension(constraint.dialect, schema, [...path, "dialect"], diagnostics);
308
- if (extension === void 0) return void 0;
308
+ if (extension === void 0) return;
309
309
  properties.push(`dialect: ${extension}`);
310
310
  }
311
311
  return `{ ${properties.join(", ")} }`;
@@ -323,21 +323,21 @@ function printIndex(schema, table, index, diagnostics) {
323
323
  "terms",
324
324
  termIndex
325
325
  ], diagnostics));
326
- if (terms.some((term) => term === void 0)) return void 0;
326
+ if (terms.some((term) => term === void 0)) return;
327
327
  const options = [`physicalName: ${literal(index.snapshot.physicalName)}`, `unique: ${index.snapshot.unique ? "true" : "false"}`];
328
328
  if (index.snapshot.predicate !== void 0) {
329
329
  const predicate = catalogExpressionData(index.snapshot.predicate, schema, [...path, "predicate"], diagnostics);
330
- if (predicate === void 0) return void 0;
330
+ if (predicate === void 0) return;
331
331
  options.push(`where: _catalogPredicate(${predicate})`);
332
332
  }
333
333
  if (index.snapshot.includedColumns !== void 0) {
334
334
  const included = printColumns(table, index.snapshot.includedColumns, [...path, "includedColumns"], diagnostics);
335
- if (included === void 0) return void 0;
335
+ if (included === void 0) return;
336
336
  options.push(`include: [${included.join(", ")}]`);
337
337
  }
338
338
  if (index.snapshot.dialect !== void 0) {
339
339
  const extension = printExtension(index.snapshot.dialect, schema, [...path, "dialect"], diagnostics);
340
- if (extension === void 0) return void 0;
340
+ if (extension === void 0) return;
341
341
  options.push(`dialect: ${extension}`);
342
342
  }
343
343
  return `${literal(index.name)}: _qubu.index(
@@ -348,7 +348,7 @@ function printIndex(schema, table, index, diagnostics) {
348
348
  function printIndexTerm(schema, table, term, path, diagnostics) {
349
349
  if (term.kind !== "order") return printIndexTermExpression(schema, table, term, path, diagnostics);
350
350
  const expression = printIndexTermExpression(schema, table, term.expression, [...path, "expression"], diagnostics);
351
- if (expression === void 0) return void 0;
351
+ if (expression === void 0) return;
352
352
  return `_qubu.order(${expression}, ${term.direction === void 0 ? "undefined" : literal(term.direction)}, ${term.nulls === void 0 ? "undefined" : literal(term.nulls)})`;
353
353
  }
354
354
  function printIndexTermExpression(schema, table, expression, path, diagnostics) {
@@ -567,28 +567,21 @@ const excludedFamilies = [
567
567
  * Generate a deterministic TypeScript module from one introspection result.
568
568
  *
569
569
  * @remarks
570
- * Generation accepts only a successful, non-lossy Snapshot v1 result for one
571
- * PostgreSQL, SQLite, or MySQL namespace. It is pure: it opens no connection,
572
- * performs no filesystem writes, and never evaluates catalog SQL. Existing
573
- * introspection diagnostics are copied into the result. Any error returns no
574
- * source.
575
- *
576
- * The generated module exports every ordinary table plus one schema registry.
577
- * Physical names and native declarations remain escaped string literals.
578
- * Catalog expressions use dialect-tagged schema data, checks use
579
- * `catalogCheck()`, and foreign keys use lazy `catalogForeignKey()` targets.
580
- * Foreign keys must have equal local and target arity and target an exact
581
- * primary key, strict unique key, or candidate index. Nullable database UNIQUE
582
- * constraints do not provide that candidate-key proof and fail generation.
583
- *
584
- * Application output, insert, and update types default independently to
585
- * `unknown`. The generator may attach a conservative SQL semantic domain, and
586
- * {@link SchemaCodegenOptions.mapColumn} can override either type axis with a
587
- * fixed token. Naming callbacks can replace suggested camelCase IDs, but they
588
- * cannot supply source syntax.
589
- *
590
- * @param input A completed introspection operation. Failed and lossy results
591
- * are reported as diagnostics rather than thrown errors.
570
+ * Generation accepts only a successful, non-lossy Snapshot v1 result for one PostgreSQL, SQLite,
571
+ * or MySQL namespace. It is pure: it opens no connection, performs no filesystem writes, and
572
+ * never evaluates catalog SQL. Existing introspection diagnostics are copied into the result. Any
573
+ * error returns no source. The generated module exports every ordinary table plus one schema
574
+ * registry. Physical names and native declarations remain escaped string literals. Catalog
575
+ * expressions use dialect-tagged schema data, checks use `catalogCheck()`, and foreign keys use
576
+ * lazy `catalogForeignKey()` targets. Foreign keys must have equal local and target arity and
577
+ * target an exact primary key, strict unique key, or candidate index. Nullable database UNIQUE
578
+ * constraints do not provide that candidate-key proof and fail generation. Application output,
579
+ * insert, and update types default independently to `unknown`. The generator may attach a
580
+ * conservative SQL semantic domain, and {@link SchemaCodegenOptions.mapColumn} can override either
581
+ * type axis with a fixed token. Naming callbacks can replace suggested camelCase IDs, but they
582
+ * cannot supply source syntax.
583
+ * @param input A completed introspection operation. Failed and lossy results are reported as
584
+ * diagnostics rather than thrown errors.
592
585
  * @param options Controlled logical-name and column-type mappings.
593
586
  * @returns Generated source and diagnostics, or diagnostics without source.
594
587
  */
@@ -730,7 +723,7 @@ function candidateIndexColumns(index) {
730
723
  const columns = [];
731
724
  for (const term of index.terms) {
732
725
  const expression = term.kind === "order" ? term.expression : term;
733
- if (expression.kind !== "column") return void 0;
726
+ if (expression.kind !== "column") return;
734
727
  columns.push(expression.column);
735
728
  }
736
729
  return columns.length > 0 ? columns : void 0;
@@ -777,7 +770,7 @@ function resolveSchema(catalog, snapshot, options, diagnostics) {
777
770
  const tableCollision = tableNames.get(schemaName);
778
771
  if (tableCollision !== void 0) diagnostics.push(errorDiagnostic("name-collision", `Schema export and table export both resolve to "${schemaName}"`, ["schema"], void 0, [tableCollision]));
779
772
  }
780
- if (schemaName === void 0 || hasErrors(diagnostics)) return void 0;
773
+ if (schemaName === void 0 || hasErrors(diagnostics)) return;
781
774
  const orderedTables = tables.sort(compareName);
782
775
  return {
783
776
  name: schemaName,
@@ -858,7 +851,7 @@ function resolveTable(snapshot, catalogTable, tableName, catalog, options, diagn
858
851
  }
859
852
  const constraints = resolveObjects(snapshot.constraints, "constraint", snapshot, tableName, options, diagnostics);
860
853
  const indexes = resolveObjects(snapshot.indexes, "index", snapshot, tableName, options, diagnostics);
861
- if (hasErrors(diagnostics)) return void 0;
854
+ if (hasErrors(diagnostics)) return;
862
855
  const orderedColumns = columns.sort(compareName);
863
856
  return {
864
857
  name: tableName,