qubu 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/codegen.mjs +1 -1
- package/dist/column-Da37jYSD.mjs +309 -0
- package/dist/column-r1Y4ivwt.mjs +327 -0
- package/dist/constraints-YGyNPQ_z.mjs +208 -0
- package/dist/core.mjs +3 -3
- package/dist/index-B2rZf3-2.d.mts +32 -0
- package/dist/index.mjs +9 -7
- package/dist/introspection.mjs +1 -1
- package/dist/{on-conflict-jPsl9l0K.mjs → on-conflict-DZQ85f1t.mjs} +3 -2
- package/dist/postgres.mjs +3 -3
- package/dist/registry-BRcUuazJ.mjs +256 -0
- package/dist/{relational-x3BDVX9e.mjs → relational-CxnLCqZQ.mjs} +2 -2
- package/dist/schema.mjs +6 -4
- package/dist/{sqlite-CsIUtZ2Q.mjs → serialize-BN07IK0v.mjs} +3 -317
- package/dist/serialize-CEIIlWhC.d.mts +66 -0
- package/dist/snapshot/mysql.d.mts +17 -0
- package/dist/snapshot/mysql.mjs +356 -0
- package/dist/snapshot/postgres.d.mts +17 -0
- package/dist/snapshot/postgres.mjs +237 -0
- package/dist/snapshot/sqlite.d.mts +25 -0
- package/dist/snapshot/sqlite.mjs +321 -0
- package/dist/{snapshot-BSraiLtH.mjs → snapshot-Xam8-q0j.mjs} +1 -1
- package/dist/snapshot.d.mts +3 -2
- package/dist/snapshot.mjs +2 -583
- package/dist/{source-C4Vmu5bb.mjs → source-SqrKWjFJ.mjs} +2 -1
- package/dist/sqlite.mjs +2 -2
- package/dist/{table-DLQ7YWth.mjs → table-BwflqeAj.mjs} +3 -2
- package/dist/{types-CTENnDh9.mjs → types-BIJsj2fJ.mjs} +3 -2
- package/dist/{value-BEEj_Ayd.mjs → value-D14I_XgL.mjs} +1 -1
- package/docs/dialects-and-execution.md +34 -0
- package/docs/migrations/index.md +7 -7
- package/docs/reference/mysql-snapshot.md +5 -5
- package/docs/reference/postgres-snapshot.md +7 -7
- package/docs/reference/sqlite-snapshot.md +5 -5
- package/docs/reference/supported-surface.md +40 -32
- package/docs/schema/code-generation.md +2 -2
- package/docs/schema/ddl-emission.md +1 -1
- package/docs/schema/snapshots.md +12 -0
- package/package.json +13 -1
- package/dist/column-DmazTL67.mjs +0 -633
- package/dist/index-C-480HmV.d.mts +0 -146
- package/dist/registry-BGqa05et.mjs +0 -461
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { t as standardDialect } from "./standard-DfcZEVOj.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { r as isColumnReference, u as generatedSchemaObjectName } from "./column-r1Y4ivwt.mjs";
|
|
3
|
+
import { c as isUnsafeSchemaSql, n as defaultSchemaNamingPolicy, u as renderSchemaExpression } from "./registry-BRcUuazJ.mjs";
|
|
4
4
|
import { t as createSchemaDialect } from "./dialect-wUKrnPMB.mjs";
|
|
5
5
|
import { a as toSnapshotJsonValue, f as schemaSnapshotFormat, i as schemaSnapshotFingerprint, o as SnapshotValidationError, r as encodeCanonicalSnapshot, s as assertSchemaSnapshot, u as neutralSnapshotDialect } from "./canonical-DMvR9yBe.mjs";
|
|
6
|
-
import { sqliteDialect } from "./sqlite.mjs";
|
|
7
6
|
//#region src/snapshot/serialize.ts
|
|
8
7
|
const neutralSchemaDialect = createSchemaDialect(Object.freeze({
|
|
9
8
|
...standardDialect(),
|
|
@@ -554,317 +553,4 @@ function compareId(left, right) {
|
|
|
554
553
|
return left.id < right.id ? -1 : left.id > right.id ? 1 : 0;
|
|
555
554
|
}
|
|
556
555
|
//#endregion
|
|
557
|
-
|
|
558
|
-
/** SQLite's v1 snapshot extension identity. */
|
|
559
|
-
const sqliteSnapshotDialect = Object.freeze({
|
|
560
|
-
name: "sqlite",
|
|
561
|
-
version: 1
|
|
562
|
-
});
|
|
563
|
-
var SqliteSnapshotDialectError = class extends TypeError {
|
|
564
|
-
code = "dialect-mismatch";
|
|
565
|
-
};
|
|
566
|
-
const sqliteStorageTypes = Object.freeze({
|
|
567
|
-
integer: "INTEGER",
|
|
568
|
-
numeric: "NUMERIC",
|
|
569
|
-
text: "TEXT",
|
|
570
|
-
boolean: "INTEGER",
|
|
571
|
-
date: "TEXT",
|
|
572
|
-
timestamp: "TEXT",
|
|
573
|
-
uuid: "TEXT",
|
|
574
|
-
json: "TEXT",
|
|
575
|
-
bigint: "INTEGER",
|
|
576
|
-
binary: "BLOB"
|
|
577
|
-
});
|
|
578
|
-
/**
|
|
579
|
-
* Resolve SQLite's declared-type affinity without changing the declaration. SQLite applies these
|
|
580
|
-
* ordered substring rules at table creation time; the returned affinity is useful metadata, not a
|
|
581
|
-
* replacement for the exact type.
|
|
582
|
-
*/
|
|
583
|
-
function sqliteStorageAffinity(declaration) {
|
|
584
|
-
const upper = declaration.toUpperCase();
|
|
585
|
-
if (upper.includes("INT")) return "integer";
|
|
586
|
-
if (upper.includes("CHAR") || upper.includes("CLOB") || upper.includes("TEXT")) return "text";
|
|
587
|
-
if (upper.includes("BLOB") || upper.trim().length === 0) return "blob";
|
|
588
|
-
if (upper.includes("REAL") || upper.includes("FLOA") || upper.includes("DOUB")) return "real";
|
|
589
|
-
return "numeric";
|
|
590
|
-
}
|
|
591
|
-
/** SQLite's query dialect plus its schema metadata behavior. */
|
|
592
|
-
const sqliteSchemaDialect = createSchemaDialect(sqliteDialect(), {
|
|
593
|
-
version: 1,
|
|
594
|
-
validate: validateSqliteSchema,
|
|
595
|
-
encodeStorage(storage, context) {
|
|
596
|
-
return encodeSqliteStorage(storage, context.dialect);
|
|
597
|
-
},
|
|
598
|
-
encodeExpression(expression, context) {
|
|
599
|
-
return encodeSqliteExpression(expression, context.mode, context.dialect);
|
|
600
|
-
},
|
|
601
|
-
encodeDialectExtension(extension, context) {
|
|
602
|
-
return encodeSqliteExtension(extension, context.dialect);
|
|
603
|
-
}
|
|
604
|
-
});
|
|
605
|
-
/** Snapshot adapter retaining the historical adapter-shaped entry point. */
|
|
606
|
-
const sqliteSnapshotAdapter = Object.freeze({ dialect: sqliteSchemaDialect });
|
|
607
|
-
/** Create a canonical SQLite schema snapshot. */
|
|
608
|
-
function createSqliteSchemaSnapshot(schema, options = {}) {
|
|
609
|
-
return createSchemaSnapshot(schema, {
|
|
610
|
-
...options,
|
|
611
|
-
adapter: sqliteSnapshotAdapter
|
|
612
|
-
});
|
|
613
|
-
}
|
|
614
|
-
/** Return SQLite capability diagnostics without throwing. */
|
|
615
|
-
function tryCreateSqliteSchemaSnapshot(schema, options = {}) {
|
|
616
|
-
return tryCreateSchemaSnapshot(schema, {
|
|
617
|
-
...options,
|
|
618
|
-
adapter: sqliteSnapshotAdapter
|
|
619
|
-
});
|
|
620
|
-
}
|
|
621
|
-
function encodeSqliteStorage(storage, dialect) {
|
|
622
|
-
if (storage.kind === "native") {
|
|
623
|
-
if (storage.dialect !== dialect.name) throw new SqliteSnapshotDialectError(`SQLite storage cannot encode a native declaration owned by "${storage.dialect}"`);
|
|
624
|
-
if (storage.type.trim().length === 0) throw new TypeError("SQLite native storage declarations cannot be empty");
|
|
625
|
-
return {
|
|
626
|
-
kind: "native",
|
|
627
|
-
dialect: dialect.name,
|
|
628
|
-
type: storage.type,
|
|
629
|
-
affinity: sqliteStorageAffinity(storage.type)
|
|
630
|
-
};
|
|
631
|
-
}
|
|
632
|
-
const type = sqliteStorageTypes[storage.type];
|
|
633
|
-
if (type === void 0) throw new TypeError(`Unsupported portable storage type for SQLite: ${String(storage.type)}`);
|
|
634
|
-
return {
|
|
635
|
-
kind: "native",
|
|
636
|
-
dialect: dialect.name,
|
|
637
|
-
type,
|
|
638
|
-
affinity: sqliteStorageAffinity(type)
|
|
639
|
-
};
|
|
640
|
-
}
|
|
641
|
-
function encodeSqliteExpression(expression, mode, dialect) {
|
|
642
|
-
if (isUnsafeSchemaSql(expression) && expression.schemaSqlDialect !== dialect.name) throw new SqliteSnapshotDialectError(`Schema SQL is tagged for "${expression.schemaSqlDialect}" but the SQLite schema dialect is "${dialect.name}"`);
|
|
643
|
-
const rendered = renderSchemaExpression(expression, {
|
|
644
|
-
mode,
|
|
645
|
-
dialect
|
|
646
|
-
});
|
|
647
|
-
if (rendered.parameters.length !== 0) throw new TypeError("SQLite schema expressions must be parameter-free");
|
|
648
|
-
return {
|
|
649
|
-
kind: "expression",
|
|
650
|
-
expressionKind: expression.expressionKind,
|
|
651
|
-
sql: rendered.text,
|
|
652
|
-
...isUnsafeSchemaSql(expression) ? { dialect: dialect.name } : {}
|
|
653
|
-
};
|
|
654
|
-
}
|
|
655
|
-
function encodeSqliteExtension(extension, dialect) {
|
|
656
|
-
if (extension.dialect !== dialect.name) throw new TypeError(`SQLite schema extensions require dialect "${dialect.name}"`);
|
|
657
|
-
const data = Object.fromEntries(Object.entries(extension).filter(([key]) => key !== "dialect").sort(([left], [right]) => left.localeCompare(right)));
|
|
658
|
-
return {
|
|
659
|
-
dialect: dialect.name,
|
|
660
|
-
version: dialect.schema.version,
|
|
661
|
-
data: sortSnapshotJson(toSnapshotJsonValue(data))
|
|
662
|
-
};
|
|
663
|
-
}
|
|
664
|
-
function sortSnapshotJson(value) {
|
|
665
|
-
if (Array.isArray(value)) return value.map(sortSnapshotJson);
|
|
666
|
-
if (typeof value !== "object" || value === null) return value;
|
|
667
|
-
return Object.fromEntries(Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, child]) => [key, sortSnapshotJson(child)]));
|
|
668
|
-
}
|
|
669
|
-
function validateSqliteSchema(schema, context) {
|
|
670
|
-
const diagnostics = [];
|
|
671
|
-
const tableEntries = Object.entries(schema.registry).sort(([left], [right]) => compareIds(left, right));
|
|
672
|
-
const relationNames = /* @__PURE__ */ new Map();
|
|
673
|
-
if (schema.namespace !== void 0) validateSqliteName(schema.namespace, ["namespace"], "SQLite namespace", diagnostics);
|
|
674
|
-
for (const [id, entry] of tableEntries) {
|
|
675
|
-
const tablePath = ["tables", id];
|
|
676
|
-
validateSqliteName(entry.physicalName, [...tablePath, "physicalName"], "SQLite table", diagnostics);
|
|
677
|
-
addRelationName(relationNames, entry.physicalName, [...tablePath, "physicalName"], "table", diagnostics);
|
|
678
|
-
}
|
|
679
|
-
for (const [id, entry] of tableEntries) validateSqliteTable(id, entry, context, relationNames, diagnostics);
|
|
680
|
-
return Object.freeze(diagnostics);
|
|
681
|
-
}
|
|
682
|
-
function validateSqliteTable(tableId, entry, context, relationNames, diagnostics) {
|
|
683
|
-
const table = entry.table;
|
|
684
|
-
const tablePath = ["tables", tableId];
|
|
685
|
-
const definitions = table.definitions;
|
|
686
|
-
const metadata = table;
|
|
687
|
-
for (const [columnId, definition] of Object.entries(definitions).sort(([left], [right]) => compareIds(left, right))) {
|
|
688
|
-
validateSqliteName(table.sqlNames[columnId] ?? columnId, [
|
|
689
|
-
...tablePath,
|
|
690
|
-
"columns",
|
|
691
|
-
columnId,
|
|
692
|
-
"physicalName"
|
|
693
|
-
], "SQLite column", diagnostics);
|
|
694
|
-
if (definition.onUpdate !== void 0) diagnostics.push({
|
|
695
|
-
code: "unsupported-dialect-option",
|
|
696
|
-
message: "MySQL ON UPDATE expressions are not supported by SQLite",
|
|
697
|
-
path: [
|
|
698
|
-
...tablePath,
|
|
699
|
-
"columns",
|
|
700
|
-
columnId,
|
|
701
|
-
"onUpdate"
|
|
702
|
-
]
|
|
703
|
-
});
|
|
704
|
-
const storage = definition.storage;
|
|
705
|
-
const identity = definition.identity;
|
|
706
|
-
if (identity !== void 0) {
|
|
707
|
-
const identityPath = [
|
|
708
|
-
...tablePath,
|
|
709
|
-
"columns",
|
|
710
|
-
columnId,
|
|
711
|
-
"identity"
|
|
712
|
-
];
|
|
713
|
-
const extension = identity.dialect;
|
|
714
|
-
if (extension !== void 0 && extension.dialect === "sqlite" && extension.autoIncrement !== void 0 && typeof extension.autoIncrement !== "boolean") diagnostics.push({
|
|
715
|
-
code: "unsupported-dialect-option",
|
|
716
|
-
message: "SQLite identity autoIncrement must be boolean",
|
|
717
|
-
path: [
|
|
718
|
-
...identityPath,
|
|
719
|
-
"dialect",
|
|
720
|
-
"autoIncrement"
|
|
721
|
-
]
|
|
722
|
-
});
|
|
723
|
-
const primary = primaryKeyForColumn(metadata.constraints, columnId);
|
|
724
|
-
const declaration = sqliteDeclaration(storage);
|
|
725
|
-
if ((declaration === void 0 ? void 0 : sqliteStorageAffinity(declaration)) !== "integer") diagnostics.push({
|
|
726
|
-
code: "unsupported-dialect-option",
|
|
727
|
-
message: "SQLite identity columns must use INTEGER affinity so they can be rowid aliases",
|
|
728
|
-
path: [...identityPath, "generation"]
|
|
729
|
-
});
|
|
730
|
-
if (primary === void 0 || primary.length !== 1) diagnostics.push({
|
|
731
|
-
code: "unsupported-dialect-option",
|
|
732
|
-
message: "SQLite identity columns must be the sole column of a PRIMARY KEY constraint",
|
|
733
|
-
path: [...identityPath, "generation"]
|
|
734
|
-
});
|
|
735
|
-
if (extension?.dialect === "sqlite" && extension.autoIncrement === true && declaration?.trim().toUpperCase() !== "INTEGER") diagnostics.push({
|
|
736
|
-
code: "unsupported-dialect-option",
|
|
737
|
-
message: "SQLite AUTOINCREMENT requires an exact INTEGER PRIMARY KEY declaration",
|
|
738
|
-
path: [
|
|
739
|
-
...identityPath,
|
|
740
|
-
"dialect",
|
|
741
|
-
"autoIncrement"
|
|
742
|
-
]
|
|
743
|
-
});
|
|
744
|
-
}
|
|
745
|
-
if (definition.generatedColumn?.kind === "expression" && primaryKeyForColumn(metadata.constraints, columnId) !== void 0) diagnostics.push({
|
|
746
|
-
code: "unsupported-dialect-option",
|
|
747
|
-
message: "SQLite generated columns cannot be part of a PRIMARY KEY",
|
|
748
|
-
path: [
|
|
749
|
-
...tablePath,
|
|
750
|
-
"columns",
|
|
751
|
-
columnId,
|
|
752
|
-
"generatedColumn"
|
|
753
|
-
]
|
|
754
|
-
});
|
|
755
|
-
}
|
|
756
|
-
const constraintNames = /* @__PURE__ */ new Map();
|
|
757
|
-
const constraints = Object.entries(metadata.constraints);
|
|
758
|
-
for (const [constraintId, constraint] of constraints.sort(([left], [right]) => compareIds(left, right))) {
|
|
759
|
-
const constraintPath = [
|
|
760
|
-
...tablePath,
|
|
761
|
-
"constraints",
|
|
762
|
-
constraintId
|
|
763
|
-
];
|
|
764
|
-
const physicalName = constraint.physicalName ?? constraintId;
|
|
765
|
-
validateSqliteName(physicalName, [...constraintPath, "physicalName"], "SQLite constraint", diagnostics);
|
|
766
|
-
addScopedName(constraintNames, physicalName, [...constraintPath, "physicalName"], "constraint", diagnostics);
|
|
767
|
-
appendMetadataDiagnostics(diagnostics, validateConstraintDialect(constraint, context.dialect.name, constraintPath));
|
|
768
|
-
if ((constraint.kind === "primary-key" || constraint.kind === "unique" || constraint.kind === "unique-constraint" || constraint.kind === "check") && (constraint.deferrable === true || constraint.initially !== void 0)) diagnostics.push({
|
|
769
|
-
code: "unsupported-dialect-option",
|
|
770
|
-
message: "SQLite only supports DEFERRABLE timing on foreign-key constraints",
|
|
771
|
-
path: [...constraintPath, constraint.deferrable ? "deferrable" : "initially"]
|
|
772
|
-
});
|
|
773
|
-
if (constraint.kind === "foreign-key" && constraint.match !== void 0 && constraint.match !== "simple") diagnostics.push({
|
|
774
|
-
code: "unsupported-dialect-option",
|
|
775
|
-
message: "SQLite supports MATCH SIMPLE foreign keys only",
|
|
776
|
-
path: [...constraintPath, "match"]
|
|
777
|
-
});
|
|
778
|
-
if (constraint.kind === "unique-constraint" && constraint.nulls === "not-distinct") diagnostics.push({
|
|
779
|
-
code: "unsupported-dialect-option",
|
|
780
|
-
message: "SQLite UNIQUE constraints always use distinct NULL semantics in v1",
|
|
781
|
-
path: [...constraintPath, "nulls"]
|
|
782
|
-
});
|
|
783
|
-
if (constraint.dialect?.dialect === "sqlite" && "onConflict" in constraint.dialect && constraint.dialect.onConflict !== void 0 && ![
|
|
784
|
-
"rollback",
|
|
785
|
-
"abort",
|
|
786
|
-
"fail",
|
|
787
|
-
"ignore",
|
|
788
|
-
"replace"
|
|
789
|
-
].includes(String(constraint.dialect.onConflict))) diagnostics.push({
|
|
790
|
-
code: "unsupported-dialect-option",
|
|
791
|
-
message: "SQLite constraint onConflict has an unsupported value",
|
|
792
|
-
path: [
|
|
793
|
-
...constraintPath,
|
|
794
|
-
"dialect",
|
|
795
|
-
"onConflict"
|
|
796
|
-
]
|
|
797
|
-
});
|
|
798
|
-
}
|
|
799
|
-
const indexes = Object.entries(metadata.indexes);
|
|
800
|
-
for (const [indexId, index] of indexes.sort(([left], [right]) => compareIds(left, right))) {
|
|
801
|
-
const indexPath = [
|
|
802
|
-
...tablePath,
|
|
803
|
-
"indexes",
|
|
804
|
-
indexId
|
|
805
|
-
];
|
|
806
|
-
const physicalName = index.physicalName ?? indexId;
|
|
807
|
-
validateSqliteName(physicalName, [...indexPath, "physicalName"], "SQLite index", diagnostics);
|
|
808
|
-
addRelationName(relationNames, physicalName, [...indexPath, "physicalName"], "index", diagnostics);
|
|
809
|
-
appendMetadataDiagnostics(diagnostics, validateIndexDialect(index, context.dialect.name, indexPath));
|
|
810
|
-
if (index.dialect?.dialect === "sqlite" && "auto" in index.dialect && index.dialect.auto !== void 0 && typeof index.dialect.auto !== "boolean") diagnostics.push({
|
|
811
|
-
code: "unsupported-dialect-option",
|
|
812
|
-
message: "SQLite index auto must be boolean",
|
|
813
|
-
path: [
|
|
814
|
-
...indexPath,
|
|
815
|
-
"dialect",
|
|
816
|
-
"auto"
|
|
817
|
-
]
|
|
818
|
-
});
|
|
819
|
-
}
|
|
820
|
-
}
|
|
821
|
-
function sqliteDeclaration(storage) {
|
|
822
|
-
if (storage === void 0) return;
|
|
823
|
-
if (storage.kind === "native") return storage.type;
|
|
824
|
-
return sqliteStorageTypes[storage.type];
|
|
825
|
-
}
|
|
826
|
-
function primaryKeyForColumn(constraints, columnId) {
|
|
827
|
-
for (const constraint of Object.values(constraints)) {
|
|
828
|
-
if (constraint.kind !== "primary-key") continue;
|
|
829
|
-
if (constraint.columns.some((column) => isColumnReference(column) && column.fieldName === columnId)) return constraint.columns;
|
|
830
|
-
}
|
|
831
|
-
}
|
|
832
|
-
function validateSqliteName(name, path, kind, diagnostics) {
|
|
833
|
-
if (!isValidSchemaObjectName(name) || name.length === 0) diagnostics.push({
|
|
834
|
-
code: "invalid-schema",
|
|
835
|
-
message: `${kind} name "${name}" is not a valid unqualified identifier`,
|
|
836
|
-
path
|
|
837
|
-
});
|
|
838
|
-
}
|
|
839
|
-
function addRelationName(names, name, path, kind, diagnostics) {
|
|
840
|
-
addScopedName(names, name, path, kind, diagnostics);
|
|
841
|
-
}
|
|
842
|
-
function addScopedName(names, name, path, kind, diagnostics) {
|
|
843
|
-
const previousPath = names.get(name);
|
|
844
|
-
if (previousPath !== void 0) {
|
|
845
|
-
diagnostics.push({
|
|
846
|
-
code: "invalid-schema",
|
|
847
|
-
message: `SQLite ${kind} name "${name}" collides with another table or index`,
|
|
848
|
-
path,
|
|
849
|
-
relatedPaths: [previousPath]
|
|
850
|
-
});
|
|
851
|
-
return;
|
|
852
|
-
}
|
|
853
|
-
names.set(name, path);
|
|
854
|
-
}
|
|
855
|
-
function appendMetadataDiagnostics(diagnostics, issues) {
|
|
856
|
-
for (const issue of issues) {
|
|
857
|
-
if (issue.code === "dialect-mismatch") continue;
|
|
858
|
-
diagnostics.push({
|
|
859
|
-
code: issue.code === "unsupported-dialect-option" ? "unsupported-dialect-option" : "invalid-schema",
|
|
860
|
-
message: issue.message,
|
|
861
|
-
path: issue.path,
|
|
862
|
-
...issue.relatedPaths === void 0 ? {} : { relatedPaths: issue.relatedPaths }
|
|
863
|
-
});
|
|
864
|
-
}
|
|
865
|
-
}
|
|
866
|
-
function compareIds(left, right) {
|
|
867
|
-
return left < right ? -1 : left > right ? 1 : 0;
|
|
868
|
-
}
|
|
869
|
-
//#endregion
|
|
870
|
-
export { sqliteStorageAffinity as a, createSchemaSnapshot as c, fingerprintSchemaSnapshot as d, serializeSchema as f, sqliteSnapshotDialect as i, encodeSchemaSnapshot as l, sqliteSchemaDialect as n, tryCreateSqliteSchemaSnapshot as o, tryCreateSchemaSnapshot as p, sqliteSnapshotAdapter as r, SnapshotSerializationError as s, createSqliteSchemaSnapshot as t, encodeSnapshot as u };
|
|
556
|
+
export { fingerprintSchemaSnapshot as a, encodeSnapshot as i, createSchemaSnapshot as n, serializeSchema as o, encodeSchemaSnapshot as r, tryCreateSchemaSnapshot as s, SnapshotSerializationError as t };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { T as SnapshotJsonValue, Tr as SchemaDialect, Ur as Schema, f as SnapshotDiagnostic, i as SchemaSnapshotInput, l as SnapshotCreateResult, n as SchemaSnapshot, r as SchemaSnapshotAdapter, u as SnapshotDecodeResult } from "./types-C0VkiwpR.mjs";
|
|
2
|
+
//#region src/snapshot/canonical.d.ts
|
|
3
|
+
/** Error raised when a value cannot cross the canonical JSON boundary. */
|
|
4
|
+
declare class SnapshotCanonicalError extends TypeError {
|
|
5
|
+
readonly path: readonly (string | number)[];
|
|
6
|
+
constructor(message: string, path?: readonly (string | number)[]);
|
|
7
|
+
}
|
|
8
|
+
/** Convert a JavaScript value to the explicit JSON-safe snapshot domain. */
|
|
9
|
+
declare function toSnapshotJsonValue(value: unknown, path?: readonly (string | number)[], seen?: WeakSet<object>): SnapshotJsonValue;
|
|
10
|
+
/** Render a JSON-safe value with deterministic scalar and object handling. */
|
|
11
|
+
declare function canonicalJson(value: SnapshotJsonValue): string;
|
|
12
|
+
/** Canonical JSON for a schema snapshot after fixed-order reconstruction. */
|
|
13
|
+
declare function encodeCanonicalSnapshot(snapshot: SchemaSnapshot): string;
|
|
14
|
+
/**
|
|
15
|
+
* Compute a small deterministic content fingerprint for cache keys and diagnostics. It is
|
|
16
|
+
* deliberately not an entity identity, signature, or migration lineage.
|
|
17
|
+
*/
|
|
18
|
+
declare function schemaSnapshotFingerprint(snapshot: SchemaSnapshotInput | string): string;
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/snapshot/decode.d.ts
|
|
21
|
+
/** Error raised by throwing snapshot APIs after collecting diagnostics. */
|
|
22
|
+
declare class SnapshotValidationError extends TypeError {
|
|
23
|
+
readonly name: string;
|
|
24
|
+
readonly diagnostics: readonly SnapshotDiagnostic[];
|
|
25
|
+
readonly issues: readonly SnapshotDiagnostic[];
|
|
26
|
+
constructor(diagnostics: readonly SnapshotDiagnostic[]);
|
|
27
|
+
}
|
|
28
|
+
/** Decode and strictly validate a JSON string or parsed snapshot value. */
|
|
29
|
+
declare function decodeSchemaSnapshot(input: string | unknown): SnapshotDecodeResult;
|
|
30
|
+
/** Validate a snapshot and throw one structured error if it is malformed. */
|
|
31
|
+
declare function assertSchemaSnapshot(input: SchemaSnapshotInput | string): SchemaSnapshot;
|
|
32
|
+
/** Return a fixed-order, deeply immutable copy of a valid snapshot. */
|
|
33
|
+
declare function canonicalizeSchemaSnapshot(input: SchemaSnapshotInput): SchemaSnapshot;
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/snapshot/serialize.d.ts
|
|
36
|
+
/** Error raised when a live Qubu schema cannot be represented as a snapshot. */
|
|
37
|
+
declare class SnapshotSerializationError extends SnapshotValidationError {
|
|
38
|
+
readonly name = "SnapshotSerializationError";
|
|
39
|
+
}
|
|
40
|
+
/** Options for the neutral traversal and a future dialect adapter. */
|
|
41
|
+
interface SchemaSnapshotOptions {
|
|
42
|
+
readonly adapter?: SchemaSnapshotAdapter;
|
|
43
|
+
readonly dialect?: SchemaDialect;
|
|
44
|
+
/** Explicit hook overrides retained for custom tooling integrations. */
|
|
45
|
+
readonly expressionEncoder?: SchemaDialect["schema"]["encodeExpression"];
|
|
46
|
+
readonly storageEncoder?: SchemaDialect["schema"]["encodeStorage"];
|
|
47
|
+
readonly extensionEncoder?: SchemaDialect["schema"]["encodeDialectExtension"];
|
|
48
|
+
readonly namingPolicy?: {
|
|
49
|
+
readonly name: string;
|
|
50
|
+
readonly version?: number;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/** Create a neutral or adapter-owned immutable snapshot from a live schema. */
|
|
54
|
+
declare function createSchemaSnapshot<TSchema extends Schema<any>>(schema: TSchema, options?: SchemaSnapshotOptions): SchemaSnapshot;
|
|
55
|
+
/** Non-throwing form of {@link createSchemaSnapshot}. */
|
|
56
|
+
declare function tryCreateSchemaSnapshot<TSchema extends Schema<any>>(schema: TSchema, options?: SchemaSnapshotOptions): SnapshotCreateResult;
|
|
57
|
+
/** Encode a valid snapshot using fixed property order and canonical JSON. */
|
|
58
|
+
declare function encodeSchemaSnapshot(snapshot: SchemaSnapshot): string;
|
|
59
|
+
/** Alias used by tooling packages that call the operation serialization. */
|
|
60
|
+
declare const serializeSchema: typeof createSchemaSnapshot;
|
|
61
|
+
/** Alias for the canonical snapshot encoder. */
|
|
62
|
+
declare const encodeSnapshot: typeof encodeSchemaSnapshot;
|
|
63
|
+
/** Alias for the canonical snapshot fingerprint helper. */
|
|
64
|
+
declare const fingerprintSchemaSnapshot: typeof schemaSnapshotFingerprint;
|
|
65
|
+
//#endregion
|
|
66
|
+
export { toSnapshotJsonValue as _, encodeSnapshot as a, tryCreateSchemaSnapshot as c, canonicalizeSchemaSnapshot as d, decodeSchemaSnapshot as f, schemaSnapshotFingerprint as g, encodeCanonicalSnapshot as h, encodeSchemaSnapshot as i, SnapshotValidationError as l, canonicalJson as m, SnapshotSerializationError as n, fingerprintSchemaSnapshot as o, SnapshotCanonicalError as p, createSchemaSnapshot as r, serializeSchema as s, SchemaSnapshotOptions as t, assertSchemaSnapshot as u };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Tr as SchemaDialect, Ur as Schema, l as SnapshotCreateResult, m as SnapshotDialect, n as SchemaSnapshot, r as SchemaSnapshotAdapter } from "../types-C0VkiwpR.mjs";
|
|
2
|
+
import { t as SchemaSnapshotOptions } from "../serialize-CEIIlWhC.mjs";
|
|
3
|
+
//#region src/snapshot/mysql.d.ts
|
|
4
|
+
/** MySQL's v1 snapshot extension identity. */
|
|
5
|
+
declare const mysqlSnapshotDialect: SnapshotDialect;
|
|
6
|
+
/** MySQL's query dialect plus its schema metadata behavior. */
|
|
7
|
+
declare const mysqlSchemaDialect: SchemaDialect<"json" | "row-locking">;
|
|
8
|
+
/** Snapshot adapter retaining the historical adapter-shaped entry point. */
|
|
9
|
+
declare const mysqlSnapshotAdapter: SchemaSnapshotAdapter<"json" | "row-locking">;
|
|
10
|
+
/** Create a canonical MySQL schema snapshot. */
|
|
11
|
+
declare function createSchemaSnapshot<TSchema extends Schema<any>>(schema: TSchema, options?: MysqlSnapshotOptions): SchemaSnapshot;
|
|
12
|
+
/** Return MySQL capability diagnostics without throwing. */
|
|
13
|
+
declare function tryCreateSchemaSnapshot<TSchema extends Schema<any>>(schema: TSchema, options?: MysqlSnapshotOptions): SnapshotCreateResult;
|
|
14
|
+
/** Options accepted by the MySQL snapshot convenience functions. */
|
|
15
|
+
type MysqlSnapshotOptions = Omit<SchemaSnapshotOptions, "adapter" | "dialect">;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { MysqlSnapshotOptions, createSchemaSnapshot, mysqlSchemaDialect, mysqlSnapshotAdapter, mysqlSnapshotDialect, tryCreateSchemaSnapshot };
|