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,24 @@
1
+ import { Pt as AnyTable, Xr as Schema, ni as SchemaTableRecord } from "./types-4Q076HKo.mjs";
2
+ import { r as DrizzleSchemaValidation, t as DrizzleColumnConfig } from "./types-CO1KaRNc.mjs";
3
+ import { MySqlColumn, MySqlTableWithColumns } from "drizzle-orm/mysql-core";
4
+ //#region src/drizzle/mysql.d.ts
5
+ type MysqlDrizzleColumn<TTableName extends string, TDefinition> = MySqlColumn<DrizzleColumnConfig<TTableName, TDefinition, 'MySqlCustomColumn'>>;
6
+ type MysqlDrizzleColumns<TTable extends AnyTable> = { [TKey in keyof TTable['definitions']]: MysqlDrizzleColumn<TTable['tableName'], TTable['definitions'][TKey]>; };
7
+ /** The Drizzle MySQL table produced for one Qubu table. */
8
+ type MysqlDrizzleTable<TTable extends AnyTable> = MySqlTableWithColumns<{
9
+ name: TTable['tableName'];
10
+ schema: string | undefined;
11
+ columns: MysqlDrizzleColumns<TTable>;
12
+ dialect: 'mysql';
13
+ }>;
14
+ /** A MySQL Drizzle table record retaining Qubu's logical table keys. */
15
+ type MysqlDrizzleSchema<TSchema extends Schema<any>> = { readonly [TKey in keyof TSchema['tables']]: MysqlDrizzleTable<TSchema['tables'][TKey]>; };
16
+ /**
17
+ * Convert a live Qubu schema registry into MySQL Drizzle table objects.
18
+ *
19
+ * @throws A snapshot validation error for invalid MySQL metadata, or a
20
+ * DrizzleSchemaConversionError when Drizzle cannot represent required metadata.
21
+ */
22
+ declare function toMysqlDrizzleSchema<const TTables extends SchemaTableRecord>(schema: Schema<TTables> & DrizzleSchemaValidation<TTables, 'mysql'>): MysqlDrizzleSchema<Schema<TTables>>;
23
+ //#endregion
24
+ export { MysqlDrizzleSchema, MysqlDrizzleTable, toMysqlDrizzleSchema };
@@ -0,0 +1,72 @@
1
+ import { t as createMysqlSchemaSnapshot } from "./mysql-DqkqXB6A.mjs";
2
+ import { i as stringExtension, n as extensionData, t as convertDrizzleSchema } from "./runtime-BTr-MTlo.mjs";
3
+ import { bigint, boolean, char, check, customType, date, datetime, decimal, foreignKey, index, int, json, mysqlSchema, mysqlTable, primaryKey, text, unique, uniqueIndex } from "drizzle-orm/mysql-core";
4
+ //#region src/drizzle/mysql.ts
5
+ const mysqlAdapter = {
6
+ dialect: "mysql",
7
+ createSnapshot: createMysqlSchemaSnapshot,
8
+ createTableFactory(namespace) {
9
+ return namespace === void 0 ? mysqlTable : mysqlSchema(namespace).table;
10
+ },
11
+ createStorageBuilder: createMysqlStorageBuilder,
12
+ applyIdentity(builder, definition) {
13
+ const extension = definition.identity?.dialect;
14
+ return extension?.dialect === "mysql" && "autoIncrement" in extension && extension.autoIncrement === true && builder.autoincrement ? builder.autoincrement() : builder;
15
+ },
16
+ createPrimaryKey(name, columns) {
17
+ return primaryKey({
18
+ name,
19
+ columns
20
+ });
21
+ },
22
+ createUniqueConstraint(name, columns) {
23
+ return unique(name).on(...columns);
24
+ },
25
+ createCheck: check,
26
+ createForeignKey(name, columns, foreignColumns) {
27
+ return foreignKey({
28
+ name,
29
+ columns,
30
+ foreignColumns
31
+ });
32
+ },
33
+ createIndex(indexDefinition, terms) {
34
+ const data = extensionData(indexDefinition.dialect);
35
+ let builder = (indexDefinition.unique ? uniqueIndex(indexDefinition.physicalName) : index(indexDefinition.physicalName)).on(...terms);
36
+ const using = stringExtension(data, "using");
37
+ const algorithm = stringExtension(data, "algorithm");
38
+ const lock = stringExtension(data, "lock");
39
+ if (using) builder = builder.using(using);
40
+ if (algorithm) builder = builder.algorithm(algorithm);
41
+ if (lock) builder = builder.lock(lock);
42
+ return builder;
43
+ }
44
+ };
45
+ /**
46
+ * Convert a live Qubu schema registry into MySQL Drizzle table objects.
47
+ *
48
+ * @throws A snapshot validation error for invalid MySQL metadata, or a
49
+ * DrizzleSchemaConversionError when Drizzle cannot represent required metadata.
50
+ */
51
+ function toMysqlDrizzleSchema(schema) {
52
+ return convertDrizzleSchema(schema, mysqlAdapter);
53
+ }
54
+ function createMysqlStorageBuilder(type, name, declaration) {
55
+ return (() => {
56
+ switch (type) {
57
+ case "integer": return int(name);
58
+ case "numeric": return decimal(name, { mode: "number" });
59
+ case "text": return text(name);
60
+ case "boolean": return boolean(name);
61
+ case "date": return date(name, { mode: "date" });
62
+ case "timestamp": return datetime(name, { mode: "date" });
63
+ case "uuid": return char(name, { length: 36 });
64
+ case "json": return json(name);
65
+ case "bigint": return bigint(name, { mode: "bigint" });
66
+ case "binary": return customType({ dataType: () => declaration })(name);
67
+ default: return customType({ dataType: () => declaration })(name);
68
+ }
69
+ })();
70
+ }
71
+ //#endregion
72
+ export { toMysqlDrizzleSchema };
@@ -0,0 +1,24 @@
1
+ import { Pt as AnyTable, Xr as Schema, ni as SchemaTableRecord } from "./types-4Q076HKo.mjs";
2
+ import { r as DrizzleSchemaValidation, t as DrizzleColumnConfig } from "./types-CO1KaRNc.mjs";
3
+ import { PgColumn, PgTableWithColumns } from "drizzle-orm/pg-core";
4
+ //#region src/drizzle/postgres.d.ts
5
+ type PostgresDrizzleColumn<TTableName extends string, TDefinition> = PgColumn<DrizzleColumnConfig<TTableName, TDefinition, 'PgCustomColumn'>>;
6
+ type PostgresDrizzleColumns<TTable extends AnyTable> = { [TKey in keyof TTable['definitions']]: PostgresDrizzleColumn<TTable['tableName'], TTable['definitions'][TKey]>; };
7
+ /** The Drizzle PostgreSQL table produced for one Qubu table. */
8
+ type PostgresDrizzleTable<TTable extends AnyTable> = PgTableWithColumns<{
9
+ name: TTable['tableName'];
10
+ schema: string | undefined;
11
+ columns: PostgresDrizzleColumns<TTable>;
12
+ dialect: 'pg';
13
+ }>;
14
+ /** A PostgreSQL Drizzle table record retaining Qubu's logical table keys. */
15
+ type PostgresDrizzleSchema<TSchema extends Schema<any>> = { readonly [TKey in keyof TSchema['tables']]: PostgresDrizzleTable<TSchema['tables'][TKey]>; };
16
+ /**
17
+ * Convert a live Qubu schema registry into PostgreSQL Drizzle table objects.
18
+ *
19
+ * @throws A snapshot validation error for invalid PostgreSQL metadata, or a
20
+ * DrizzleSchemaConversionError when Drizzle cannot represent required metadata.
21
+ */
22
+ declare function toPostgresDrizzleSchema<const TTables extends SchemaTableRecord>(schema: Schema<TTables> & DrizzleSchemaValidation<TTables, 'postgresql'>): PostgresDrizzleSchema<Schema<TTables>>;
23
+ //#endregion
24
+ export { PostgresDrizzleSchema, PostgresDrizzleTable, toPostgresDrizzleSchema };
@@ -0,0 +1,73 @@
1
+ import { t as createPostgresSchemaSnapshot } from "./postgres-DEBBeh52.mjs";
2
+ import { i as stringExtension, n as extensionData, r as recordExtension, t as convertDrizzleSchema } from "./runtime-BTr-MTlo.mjs";
3
+ import { bigint, boolean, check, customType, date, foreignKey, index, integer, jsonb, numeric, pgSchema, pgTable, primaryKey, text, timestamp, unique, uniqueIndex, uuid } from "drizzle-orm/pg-core";
4
+ //#region src/drizzle/postgres.ts
5
+ const postgresAdapter = {
6
+ dialect: "postgresql",
7
+ createSnapshot: createPostgresSchemaSnapshot,
8
+ createTableFactory(namespace) {
9
+ return namespace === void 0 ? pgTable : pgSchema(namespace).table;
10
+ },
11
+ createStorageBuilder: createPostgresStorageBuilder,
12
+ applyIdentity(builder, _definition, column) {
13
+ const method = column.identity?.generation === "always" ? builder.generatedAlwaysAsIdentity : builder.generatedByDefaultAsIdentity;
14
+ return method === void 0 ? builder : method.call(builder);
15
+ },
16
+ createPrimaryKey(name, columns) {
17
+ return primaryKey({
18
+ name,
19
+ columns
20
+ });
21
+ },
22
+ createUniqueConstraint(name, columns, nullsNotDistinct) {
23
+ const builder = unique(name).on(...columns);
24
+ return nullsNotDistinct ? builder.nullsNotDistinct() : builder;
25
+ },
26
+ createCheck: check,
27
+ createForeignKey(name, columns, foreignColumns) {
28
+ return foreignKey({
29
+ name,
30
+ columns,
31
+ foreignColumns
32
+ });
33
+ },
34
+ createIndex(indexDefinition, terms, predicate) {
35
+ const data = extensionData(indexDefinition.dialect);
36
+ const start = indexDefinition.unique ? uniqueIndex(indexDefinition.physicalName) : index(indexDefinition.physicalName);
37
+ const method = stringExtension(data, "method");
38
+ let builder = method ? start.using(method, ...terms) : start.on(...terms);
39
+ if (data.concurrently === true) builder = builder.concurrently();
40
+ const storageParameters = recordExtension(data, "storageParameters");
41
+ if (storageParameters) builder = builder.with(storageParameters);
42
+ if (predicate) builder = builder.where(predicate);
43
+ return builder;
44
+ }
45
+ };
46
+ /**
47
+ * Convert a live Qubu schema registry into PostgreSQL Drizzle table objects.
48
+ *
49
+ * @throws A snapshot validation error for invalid PostgreSQL metadata, or a
50
+ * DrizzleSchemaConversionError when Drizzle cannot represent required metadata.
51
+ */
52
+ function toPostgresDrizzleSchema(schema) {
53
+ return convertDrizzleSchema(schema, postgresAdapter);
54
+ }
55
+ function createPostgresStorageBuilder(type, name, declaration) {
56
+ return (() => {
57
+ switch (type) {
58
+ case "integer": return integer(name);
59
+ case "numeric": return numeric(name, { mode: "number" });
60
+ case "text": return text(name);
61
+ case "boolean": return boolean(name);
62
+ case "date": return date(name, { mode: "date" });
63
+ case "timestamp": return timestamp(name, { mode: "date" });
64
+ case "uuid": return uuid(name);
65
+ case "json": return jsonb(name);
66
+ case "bigint": return bigint(name, { mode: "bigint" });
67
+ case "binary": return customType({ dataType: () => declaration })(name);
68
+ default: return customType({ dataType: () => declaration })(name);
69
+ }
70
+ })();
71
+ }
72
+ //#endregion
73
+ export { toPostgresDrizzleSchema };
@@ -0,0 +1,24 @@
1
+ import { Pt as AnyTable, Xr as Schema, ni as SchemaTableRecord } from "./types-4Q076HKo.mjs";
2
+ import { r as DrizzleSchemaValidation, t as DrizzleColumnConfig } from "./types-CO1KaRNc.mjs";
3
+ import { SQLiteColumn, SQLiteTableWithColumns } from "drizzle-orm/sqlite-core";
4
+ //#region src/drizzle/sqlite.d.ts
5
+ type SqliteDrizzleColumn<TTableName extends string, TDefinition> = SQLiteColumn<DrizzleColumnConfig<TTableName, TDefinition, 'SQLiteCustomColumn'>>;
6
+ type SqliteDrizzleColumns<TTable extends AnyTable> = { [TKey in keyof TTable['definitions']]: SqliteDrizzleColumn<TTable['tableName'], TTable['definitions'][TKey]>; };
7
+ /** The Drizzle SQLite table produced for one Qubu table. */
8
+ type SqliteDrizzleTable<TTable extends AnyTable> = SQLiteTableWithColumns<{
9
+ name: TTable['tableName'];
10
+ schema: undefined;
11
+ columns: SqliteDrizzleColumns<TTable>;
12
+ dialect: 'sqlite';
13
+ }>;
14
+ /** A SQLite Drizzle table record retaining Qubu's logical table keys. */
15
+ type SqliteDrizzleSchema<TSchema extends Schema<any>> = { readonly [TKey in keyof TSchema['tables']]: SqliteDrizzleTable<TSchema['tables'][TKey]>; };
16
+ /**
17
+ * Convert a live Qubu schema registry into SQLite Drizzle table objects.
18
+ *
19
+ * @throws A snapshot validation error for invalid SQLite metadata, or a
20
+ * DrizzleSchemaConversionError when Drizzle cannot represent required metadata.
21
+ */
22
+ declare function toSqliteDrizzleSchema<const TTables extends SchemaTableRecord>(schema: Schema<TTables> & DrizzleSchemaValidation<TTables, 'sqlite'>): SqliteDrizzleSchema<Schema<TTables>>;
23
+ //#endregion
24
+ export { SqliteDrizzleSchema, SqliteDrizzleTable, toSqliteDrizzleSchema };
@@ -0,0 +1,82 @@
1
+ import { t as createSqliteSchemaSnapshot } from "./sqlite-BU6DBxef.mjs";
2
+ import { t as convertDrizzleSchema } from "./runtime-BTr-MTlo.mjs";
3
+ import { blob, check, customType, foreignKey, index, integer, primaryKey, sqliteTable, text, unique, uniqueIndex } from "drizzle-orm/sqlite-core";
4
+ //#region src/drizzle/sqlite.ts
5
+ const sqliteAdapter = {
6
+ dialect: "sqlite",
7
+ createSnapshot: createSqliteSchemaSnapshot,
8
+ createTableFactory() {
9
+ return sqliteTable;
10
+ },
11
+ createStorageBuilder: createSqliteStorageBuilder,
12
+ applyIdentity(builder, definition, column, table) {
13
+ const extension = definition.identity?.dialect;
14
+ const autoIncrement = extension?.dialect === "sqlite" && "autoIncrement" in extension && extension.autoIncrement === true;
15
+ const isSingleColumnPrimaryKey = table.constraints.some((constraint) => constraint.kind === "primary-key" && constraint.columns.length === 1 && constraint.columns[0] === column.id);
16
+ return autoIncrement && isSingleColumnPrimaryKey && builder.primaryKey ? builder.primaryKey({ autoIncrement: true }) : builder;
17
+ },
18
+ createPrimaryKey(name, columns) {
19
+ return primaryKey({
20
+ name,
21
+ columns
22
+ });
23
+ },
24
+ createUniqueConstraint(name, columns) {
25
+ return unique(name).on(...columns);
26
+ },
27
+ createCheck: check,
28
+ createForeignKey(name, columns, foreignColumns) {
29
+ return foreignKey({
30
+ name,
31
+ columns,
32
+ foreignColumns
33
+ });
34
+ },
35
+ createIndex(indexDefinition, terms, predicate) {
36
+ let builder = (indexDefinition.unique ? uniqueIndex(indexDefinition.physicalName) : index(indexDefinition.physicalName)).on(...terms);
37
+ if (predicate) builder = builder.where(predicate);
38
+ return builder;
39
+ }
40
+ };
41
+ /**
42
+ * Convert a live Qubu schema registry into SQLite Drizzle table objects.
43
+ *
44
+ * @throws A snapshot validation error for invalid SQLite metadata, or a
45
+ * DrizzleSchemaConversionError when Drizzle cannot represent required metadata.
46
+ */
47
+ function toSqliteDrizzleSchema(schema) {
48
+ return convertDrizzleSchema(schema, sqliteAdapter);
49
+ }
50
+ function createSqliteStorageBuilder(type, name, declaration) {
51
+ return (() => {
52
+ switch (type) {
53
+ case "integer": return integer(name);
54
+ case "numeric": return customType({
55
+ dataType: () => declaration,
56
+ fromDriver: (value) => Number(value)
57
+ })(name);
58
+ case "text": return text(name);
59
+ case "boolean": return integer(name, { mode: "boolean" });
60
+ case "date": return customType({
61
+ dataType: () => declaration,
62
+ fromDriver: (value) => new Date(value),
63
+ toDriver: (value) => value.toISOString().slice(0, 10)
64
+ })(name);
65
+ case "timestamp": return customType({
66
+ dataType: () => declaration,
67
+ fromDriver: (value) => new Date(value),
68
+ toDriver: (value) => value.toISOString()
69
+ })(name);
70
+ case "uuid": return text(name);
71
+ case "json": return text(name, { mode: "json" });
72
+ case "bigint": return customType({
73
+ dataType: () => declaration,
74
+ fromDriver: (value) => BigInt(value)
75
+ })(name);
76
+ case "binary": return blob(name, { mode: "buffer" });
77
+ default: return customType({ dataType: () => declaration })(name);
78
+ }
79
+ })();
80
+ }
81
+ //#endregion
82
+ export { toSqliteDrizzleSchema };
@@ -0,0 +1,13 @@
1
+ import { n as DrizzleDialect } from "./types-CO1KaRNc.mjs";
2
+ //#region src/drizzle/errors.d.ts
3
+ /** Stable failure categories raised while building a Drizzle schema. */
4
+ type DrizzleSchemaConversionErrorCode = 'missing-storage' | 'unsupported-metadata';
5
+ /** A path-addressed failure raised when Drizzle cannot represent Qubu metadata. */
6
+ declare class DrizzleSchemaConversionError extends TypeError {
7
+ readonly name = "DrizzleSchemaConversionError";
8
+ readonly code: DrizzleSchemaConversionErrorCode;
9
+ readonly path: readonly (string | number)[];
10
+ constructor(code: DrizzleSchemaConversionErrorCode, message: string, path: readonly (string | number)[]);
11
+ }
12
+ //#endregion
13
+ export { type DrizzleDialect, DrizzleSchemaConversionError, type DrizzleSchemaConversionErrorCode };
@@ -0,0 +1,2 @@
1
+ import { t as DrizzleSchemaConversionError } from "./errors-BGCoLe_r.mjs";
2
+ export { DrizzleSchemaConversionError };
@@ -0,0 +1,14 @@
1
+ //#region src/drizzle/errors.ts
2
+ /** A path-addressed failure raised when Drizzle cannot represent Qubu metadata. */
3
+ var DrizzleSchemaConversionError = class extends TypeError {
4
+ name = "DrizzleSchemaConversionError";
5
+ code;
6
+ path;
7
+ constructor(code, message, path) {
8
+ super(message);
9
+ this.code = code;
10
+ this.path = Object.freeze([...path]);
11
+ }
12
+ };
13
+ //#endregion
14
+ export { DrizzleSchemaConversionError as t };
@@ -0,0 +1,26 @@
1
+ //#region src/query/errors.ts
2
+ /** Raised when a query cannot satisfy Qubu's runtime authoring rules. */
3
+ var QueryValidationError = class extends TypeError {
4
+ name = "QueryValidationError";
5
+ code;
6
+ context;
7
+ path;
8
+ hint;
9
+ issue;
10
+ constructor(issue) {
11
+ super(issue.message);
12
+ this.code = issue.code;
13
+ this.context = issue.context;
14
+ this.path = Object.freeze([...issue.path]);
15
+ this.hint = issue.hint;
16
+ this.issue = Object.freeze({
17
+ ...issue,
18
+ path: this.path
19
+ });
20
+ }
21
+ };
22
+ function queryValidationError(issue) {
23
+ return new QueryValidationError(issue);
24
+ }
25
+ //#endregion
26
+ export { queryValidationError as n, QueryValidationError as t };
@@ -0,0 +1,98 @@
1
+ import { n as queryValidationError } from "./errors-Dxv73YJu.mjs";
2
+ //#region src/dialects/explain.ts
3
+ const readQueryKinds = /* @__PURE__ */ new Set(["select", "set"]);
4
+ function assertExplainAnalysisAllowed(dialect, queryKind, options) {
5
+ if (options.analyze !== true || readQueryKinds.has(queryKind)) return;
6
+ throwExplainError("invalid-explain-query", dialect, ["analyze"], `EXPLAIN ANALYZE is only available for read queries; received ${queryKind}`, "Remove analyze for a plan-only mutation EXPLAIN.");
7
+ }
8
+ function assertSupportedExplainOptions(dialect, options, supported) {
9
+ for (const option of explainOptionNames) {
10
+ if (options[option] === void 0 || supported.includes(option)) continue;
11
+ throwExplainError("unsupported-explain-option", dialect, [option], `The ${dialect} EXPLAIN policy does not support the "${option}" option`, `Remove ${option} or use a dialect that supports it.`);
12
+ }
13
+ }
14
+ function assertBooleanExplainOption(dialect, option, value) {
15
+ if (value === void 0 || typeof value === "boolean") return;
16
+ throwExplainError("invalid-explain-options", dialect, [option], `The ${dialect} EXPLAIN option "${option}" must be boolean`, `Set ${option} to true or false.`);
17
+ }
18
+ function unsupportedExplainFormat(dialect, format, supported) {
19
+ throwExplainError("unsupported-explain-option", dialect, ["format"], `The ${dialect} EXPLAIN policy does not support the "${String(format)}" format`, `Use one of: ${supported.join(", ")}.`);
20
+ }
21
+ function invalidExplainCombination(dialect, path, message, hint) {
22
+ throwExplainError("invalid-explain-options", dialect, path, message, hint);
23
+ }
24
+ const postgresExplain = { render(statement, queryKind, options) {
25
+ assertExplainAnalysisAllowed("PostgreSQL", queryKind, options);
26
+ assertSupportedExplainOptions("PostgreSQL", options, [
27
+ "analyze",
28
+ "verbose",
29
+ "buffers",
30
+ "format"
31
+ ]);
32
+ assertBooleanExplainOption("PostgreSQL", "analyze", options.analyze);
33
+ assertBooleanExplainOption("PostgreSQL", "verbose", options.verbose);
34
+ assertBooleanExplainOption("PostgreSQL", "buffers", options.buffers);
35
+ const format = options.format;
36
+ if (format !== void 0 && !postgresExplainFormats.includes(format)) unsupportedExplainFormat("PostgreSQL", format, postgresExplainFormats);
37
+ if (options.buffers === true && options.analyze !== true) invalidExplainCombination("PostgreSQL", ["buffers"], "PostgreSQL EXPLAIN BUFFERS requires ANALYZE", "Set analyze: true for a read query, or remove buffers.");
38
+ const clauses = [
39
+ options.analyze === true ? "ANALYZE" : void 0,
40
+ options.verbose === true ? "VERBOSE" : void 0,
41
+ options.buffers === true ? "BUFFERS" : void 0,
42
+ format === void 0 ? void 0 : `FORMAT ${String(format).toUpperCase()}`
43
+ ].filter((value) => value !== void 0);
44
+ return `EXPLAIN${clauses.length === 0 ? "" : ` (${clauses.join(", ")})`} ${statement}`;
45
+ } };
46
+ const sqliteExplain = { render(statement, queryKind, options) {
47
+ assertExplainAnalysisAllowed("SQLite", queryKind, options);
48
+ assertSupportedExplainOptions("SQLite", options, ["format", "queryPlan"]);
49
+ assertBooleanExplainOption("SQLite", "queryPlan", options.queryPlan);
50
+ const format = options.format;
51
+ if (format !== void 0 && !sqliteExplainFormats.includes(format)) unsupportedExplainFormat("SQLite", format, sqliteExplainFormats);
52
+ const formatIsQueryPlan = format === "query-plan";
53
+ const formatIsBytecode = format === "bytecode";
54
+ if (formatIsQueryPlan && options.queryPlan === false) invalidExplainCombination("SQLite", ["format", "queryPlan"], "SQLite EXPLAIN format \"query-plan\" conflicts with queryPlan: false", "Choose query-plan or bytecode mode, not both.");
55
+ if (formatIsBytecode && options.queryPlan === true) invalidExplainCombination("SQLite", ["format", "queryPlan"], "SQLite EXPLAIN format \"bytecode\" conflicts with queryPlan: true", "Choose query-plan or bytecode mode, not both.");
56
+ return `${formatIsQueryPlan || !formatIsBytecode && options.queryPlan !== false ? "EXPLAIN QUERY PLAN" : "EXPLAIN"} ${statement}`;
57
+ } };
58
+ const mysqlExplain = { render(statement, queryKind, options) {
59
+ assertExplainAnalysisAllowed("MySQL", queryKind, options);
60
+ assertSupportedExplainOptions("MySQL", options, ["analyze", "format"]);
61
+ assertBooleanExplainOption("MySQL", "analyze", options.analyze);
62
+ const format = options.format;
63
+ if (format !== void 0 && !mysqlExplainFormats.includes(format)) unsupportedExplainFormat("MySQL", format, mysqlExplainFormats);
64
+ if (options.analyze === true && format !== void 0) invalidExplainCombination("MySQL", ["analyze", "format"], "MySQL EXPLAIN ANALYZE cannot be combined with FORMAT", "Use analyze for the tree analyzer output, or choose a FORMAT without analyze.");
65
+ if (options.analyze === true) return `EXPLAIN ANALYZE ${statement}`;
66
+ if (format === void 0) return `EXPLAIN ${statement}`;
67
+ return `EXPLAIN FORMAT=${String(format).toUpperCase()} ${statement}`;
68
+ } };
69
+ const explainOptionNames = [
70
+ "analyze",
71
+ "verbose",
72
+ "buffers",
73
+ "format",
74
+ "queryPlan"
75
+ ];
76
+ const postgresExplainFormats = [
77
+ "text",
78
+ "xml",
79
+ "json",
80
+ "yaml"
81
+ ];
82
+ const sqliteExplainFormats = ["query-plan", "bytecode"];
83
+ const mysqlExplainFormats = [
84
+ "traditional",
85
+ "json",
86
+ "tree"
87
+ ];
88
+ function throwExplainError(code, dialect, path, message, hint) {
89
+ throw queryValidationError({
90
+ code,
91
+ context: `dialect.${dialect.toLowerCase()}.explain`,
92
+ path,
93
+ message,
94
+ hint
95
+ });
96
+ }
97
+ //#endregion
98
+ export { postgresExplain as n, sqliteExplain as r, mysqlExplain as t };
@@ -0,0 +1,146 @@
1
+ import { Mr as SchemaDialect, T as SnapshotJsonValue, Xr as Schema, f as SnapshotDiagnostic, i as SchemaSnapshotInput, l as SnapshotCreateResult, m as SnapshotDialect, n as SchemaSnapshot, r as SchemaSnapshotAdapter, u as SnapshotDecodeResult } from "./types-4Q076HKo.mjs";
2
+ import { n as CompleteSchemaSnapshotInput, t as CompleteSchemaSnapshot, u as CompleteSnapshotDecodeResult } from "./complete-types-BdFqUfbb.mjs";
3
+ //#region src/snapshot/canonical.d.ts
4
+ /** Error raised when a value cannot cross the canonical JSON boundary. */
5
+ declare class SnapshotCanonicalError extends TypeError {
6
+ readonly path: readonly (string | number)[];
7
+ constructor(message: string, path?: readonly (string | number)[]);
8
+ }
9
+ /** Convert a JavaScript value to the explicit JSON-safe snapshot domain. */
10
+ declare function toSnapshotJsonValue(value: unknown, path?: readonly (string | number)[], seen?: WeakSet<object>): SnapshotJsonValue;
11
+ /** Render a JSON-safe value with deterministic scalar and object handling. */
12
+ declare function canonicalJson(value: SnapshotJsonValue): string;
13
+ /** Canonical JSON for a schema snapshot after fixed-order reconstruction. */
14
+ declare function encodeCanonicalSnapshot(snapshot: SchemaSnapshot): string;
15
+ /**
16
+ * Compute a small deterministic content digest for cache keys and diagnostics.
17
+ * It is deliberately not an entity identity, signature, or migration lineage.
18
+ */
19
+ declare function schemaSnapshotDigest(snapshot: SchemaSnapshotInput | string): string;
20
+ //#endregion
21
+ //#region src/snapshot/complete.d.ts
22
+ /** Error raised by throwing APIs after collecting strict v2 diagnostics. */
23
+ declare class CompleteSnapshotValidationError extends TypeError {
24
+ readonly name = "CompleteSnapshotValidationError";
25
+ readonly diagnostics: readonly SnapshotDiagnostic[];
26
+ readonly issues: readonly SnapshotDiagnostic[];
27
+ constructor(diagnostics: readonly SnapshotDiagnostic[]);
28
+ }
29
+ /** Decode and strictly validate a complete Snapshot v2 JSON value. */
30
+ declare function decodeCompleteSchemaSnapshot(input: string | unknown): CompleteSnapshotDecodeResult;
31
+ /** Validate a complete snapshot and throw one structured error on failure. */
32
+ declare function assertCompleteSchemaSnapshot(input: CompleteSchemaSnapshotInput | string): CompleteSchemaSnapshot;
33
+ /** Return a fixed-order, deeply immutable complete snapshot. */
34
+ declare function canonicalizeCompleteSchemaSnapshot(input: CompleteSchemaSnapshotInput): CompleteSchemaSnapshot;
35
+ /** Encode a complete snapshot with deterministic property and array order. */
36
+ declare function encodeCompleteSchemaSnapshot(snapshot: CompleteSchemaSnapshot): string;
37
+ /** Compute the deterministic content digest for a complete Snapshot v2. */
38
+ declare function completeSchemaSnapshotDigest(snapshot: CompleteSchemaSnapshotInput | string): string;
39
+ /** Numbered aliases for tooling that keeps v1 and v2 side by side. */
40
+ declare const decodeSchemaSnapshotV2: typeof decodeCompleteSchemaSnapshot;
41
+ declare const assertSchemaSnapshotV2: typeof assertCompleteSchemaSnapshot;
42
+ declare const encodeSchemaSnapshotV2: typeof encodeCompleteSchemaSnapshot;
43
+ declare const canonicalizeSchemaSnapshotV2: typeof canonicalizeCompleteSchemaSnapshot;
44
+ declare const schemaSnapshotV2Digest: typeof completeSchemaSnapshotDigest;
45
+ declare const decodeCompleteSnapshot: typeof decodeCompleteSchemaSnapshot;
46
+ declare const assertCompleteSnapshot: typeof assertCompleteSchemaSnapshot;
47
+ declare const encodeCompleteSnapshot: typeof encodeCompleteSchemaSnapshot;
48
+ declare const digestCompleteSchemaSnapshot: typeof completeSchemaSnapshotDigest;
49
+ //#endregion
50
+ //#region src/snapshot/decode.d.ts
51
+ /** Error raised by throwing snapshot APIs after collecting diagnostics. */
52
+ declare class SnapshotValidationError extends TypeError {
53
+ readonly name: string;
54
+ readonly diagnostics: readonly SnapshotDiagnostic[];
55
+ readonly issues: readonly SnapshotDiagnostic[];
56
+ constructor(diagnostics: readonly SnapshotDiagnostic[]);
57
+ }
58
+ /** Decode and strictly validate a JSON string or parsed snapshot value. */
59
+ declare function decodeSchemaSnapshot(input: string | unknown): SnapshotDecodeResult;
60
+ /** Validate a snapshot and throw one structured error if it is malformed. */
61
+ declare function assertSchemaSnapshot(input: SchemaSnapshotInput | string): SchemaSnapshot;
62
+ /** Return a fixed-order, deeply immutable copy of a valid snapshot. */
63
+ declare function canonicalizeSchemaSnapshot(input: SchemaSnapshotInput): SchemaSnapshot;
64
+ //#endregion
65
+ //#region src/snapshot/serialize.d.ts
66
+ /** Error raised when a live Qubu schema cannot be represented as a snapshot. */
67
+ declare class SnapshotSerializationError extends SnapshotValidationError {
68
+ readonly name = "SnapshotSerializationError";
69
+ }
70
+ /** Options for the neutral traversal and a future dialect adapter. */
71
+ interface SchemaSnapshotOptions {
72
+ readonly adapter?: SchemaSnapshotAdapter;
73
+ readonly dialect?: SchemaDialect;
74
+ /** Explicit hook overrides retained for custom tooling integrations. */
75
+ readonly expressionEncoder?: SchemaDialect['schema']['encodeExpression'];
76
+ readonly storageEncoder?: SchemaDialect['schema']['encodeStorage'];
77
+ readonly extensionEncoder?: SchemaDialect['schema']['encodeDialectExtension'];
78
+ readonly namingPolicy?: {
79
+ readonly name: string;
80
+ readonly version?: number;
81
+ };
82
+ }
83
+ /** Create a neutral or adapter-owned immutable snapshot from a live schema. */
84
+ declare function createSchemaSnapshot<TSchema extends Schema<any>>(schema: TSchema, options?: SchemaSnapshotOptions): SchemaSnapshot;
85
+ /** Non-throwing form of {@link createSchemaSnapshot}. */
86
+ declare function tryCreateSchemaSnapshot<TSchema extends Schema<any>>(schema: TSchema, options?: SchemaSnapshotOptions): SnapshotCreateResult;
87
+ /** Encode a valid snapshot using fixed property order and canonical JSON. */
88
+ declare function encodeSchemaSnapshot(snapshot: SchemaSnapshot): string;
89
+ /** Alias used by tooling packages that call the operation serialization. */
90
+ declare const serializeSchema: typeof createSchemaSnapshot;
91
+ /** Alias for the canonical snapshot encoder. */
92
+ declare const encodeSnapshot: typeof encodeSchemaSnapshot;
93
+ /** Alias for the canonical snapshot digest helper. */
94
+ declare const digestSchemaSnapshot: typeof schemaSnapshotDigest;
95
+ //#endregion
96
+ //#region src/snapshot/postgres.d.ts
97
+ /** PostgreSQL's v1 snapshot extension identity. */
98
+ declare const postgresSnapshotDialect: SnapshotDialect;
99
+ /** PostgreSQL's query dialect plus its schema metadata behavior. */
100
+ declare const postgresSchemaDialect: SchemaDialect<'ilike' | 'json' | 'on-conflict' | 'row-locking'>;
101
+ /** Snapshot adapter retaining the historical adapter-shaped entry point. */
102
+ declare const postgresSnapshotAdapter: SchemaSnapshotAdapter<'ilike' | 'json' | 'on-conflict' | 'row-locking'>;
103
+ /** Create a canonical PostgreSQL schema snapshot. */
104
+ declare function createPostgresSchemaSnapshot<TSchema extends Schema<any>>(schema: TSchema, options?: PostgresSnapshotOptions): SchemaSnapshot;
105
+ /** Return PostgreSQL capability diagnostics without throwing. */
106
+ declare function tryCreatePostgresSchemaSnapshot<TSchema extends Schema<any>>(schema: TSchema, options?: PostgresSnapshotOptions): SnapshotCreateResult;
107
+ /** Options accepted by the PostgreSQL snapshot convenience functions. */
108
+ type PostgresSnapshotOptions = Omit<SchemaSnapshotOptions, 'adapter' | 'dialect'>;
109
+ //#endregion
110
+ //#region src/snapshot/sqlite.d.ts
111
+ /** SQLite's v1 snapshot extension identity. */
112
+ declare const sqliteSnapshotDialect: SnapshotDialect;
113
+ /** SQLite's five declared-type affinity categories. */
114
+ type SqliteStorageAffinity = 'blob' | 'integer' | 'numeric' | 'real' | 'text';
115
+ /**
116
+ * Resolve SQLite's declared-type affinity without changing the declaration.
117
+ * SQLite applies these ordered substring rules at table creation time; the
118
+ * returned affinity is useful metadata, not a replacement for the exact type.
119
+ */
120
+ declare function sqliteStorageAffinity(declaration: string): SqliteStorageAffinity;
121
+ /** SQLite's query dialect plus its schema metadata behavior. */
122
+ declare const sqliteSchemaDialect: SchemaDialect<'json' | 'on-conflict'>;
123
+ /** Snapshot adapter retaining the historical adapter-shaped entry point. */
124
+ declare const sqliteSnapshotAdapter: SchemaSnapshotAdapter<'json' | 'on-conflict'>;
125
+ /** Create a canonical SQLite schema snapshot. */
126
+ declare function createSqliteSchemaSnapshot<TSchema extends Schema<any>>(schema: TSchema, options?: SqliteSnapshotOptions): SchemaSnapshot;
127
+ /** Return SQLite capability diagnostics without throwing. */
128
+ declare function tryCreateSqliteSchemaSnapshot<TSchema extends Schema<any>>(schema: TSchema, options?: SqliteSnapshotOptions): SnapshotCreateResult;
129
+ /** Options accepted by the SQLite snapshot convenience functions. */
130
+ type SqliteSnapshotOptions = Omit<SchemaSnapshotOptions, 'adapter' | 'dialect'>;
131
+ //#endregion
132
+ //#region src/snapshot/mysql.d.ts
133
+ /** MySQL's v1 snapshot extension identity. */
134
+ declare const mysqlSnapshotDialect: SnapshotDialect;
135
+ /** MySQL's query dialect plus its schema metadata behavior. */
136
+ declare const mysqlSchemaDialect: SchemaDialect<'json' | 'row-locking'>;
137
+ /** Snapshot adapter retaining the historical adapter-shaped entry point. */
138
+ declare const mysqlSnapshotAdapter: SchemaSnapshotAdapter<'json' | 'row-locking'>;
139
+ /** Create a canonical MySQL schema snapshot. */
140
+ declare function createMysqlSchemaSnapshot<TSchema extends Schema<any>>(schema: TSchema, options?: MysqlSnapshotOptions): SchemaSnapshot;
141
+ /** Return MySQL capability diagnostics without throwing. */
142
+ declare function tryCreateMysqlSchemaSnapshot<TSchema extends Schema<any>>(schema: TSchema, options?: MysqlSnapshotOptions): SnapshotCreateResult;
143
+ /** Options accepted by the MySQL snapshot convenience functions. */
144
+ type MysqlSnapshotOptions = Omit<SchemaSnapshotOptions, 'adapter' | 'dialect'>;
145
+ //#endregion
146
+ export { assertSchemaSnapshot as A, decodeCompleteSchemaSnapshot as B, createSchemaSnapshot as C, serializeSchema as D, encodeSnapshot as E, assertCompleteSnapshot as F, encodeCompleteSnapshot as G, decodeSchemaSnapshotV2 as H, assertSchemaSnapshotV2 as I, SnapshotCanonicalError as J, encodeSchemaSnapshotV2 as K, canonicalizeCompleteSchemaSnapshot as L, decodeSchemaSnapshot as M, CompleteSnapshotValidationError as N, tryCreateSchemaSnapshot as O, assertCompleteSchemaSnapshot as P, toSnapshotJsonValue as Q, canonicalizeSchemaSnapshotV2 as R, SnapshotSerializationError as S, encodeSchemaSnapshot as T, digestCompleteSchemaSnapshot as U, decodeCompleteSnapshot as V, encodeCompleteSchemaSnapshot as W, encodeCanonicalSnapshot as X, canonicalJson as Y, schemaSnapshotDigest as Z, postgresSchemaDialect as _, mysqlSnapshotDialect as a, tryCreatePostgresSchemaSnapshot as b, SqliteStorageAffinity as c, sqliteSnapshotAdapter as d, sqliteSnapshotDialect as f, createPostgresSchemaSnapshot as g, PostgresSnapshotOptions as h, mysqlSnapshotAdapter as i, canonicalizeSchemaSnapshot as j, SnapshotValidationError as k, createSqliteSchemaSnapshot as l, tryCreateSqliteSchemaSnapshot as m, createMysqlSchemaSnapshot as n, tryCreateMysqlSchemaSnapshot as o, sqliteStorageAffinity as p, schemaSnapshotV2Digest as q, mysqlSchemaDialect as r, SqliteSnapshotOptions as s, MysqlSnapshotOptions as t, sqliteSchemaDialect as u, postgresSnapshotAdapter as v, digestSchemaSnapshot as w, SchemaSnapshotOptions as x, postgresSnapshotDialect as y, completeSchemaSnapshotDigest as z };