qubu 0.4.3 → 0.5.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.
@@ -1,202 +0,0 @@
1
- import { T as SnapshotJsonValue, m as SnapshotDialect, n as SchemaSnapshot } from "./types-C0VkiwpR.mjs";
2
- import { S as CompleteSnapshotObjectKind, t as CompleteSchemaSnapshot } from "./complete-types-CY0KbzNw.mjs";
3
- //#region src/diff/types.d.ts
4
- /** Object families understood by the snapshot diff engine. */
5
- type SnapshotDiffObjectKind = CompleteSnapshotObjectKind;
6
- /** A path into a canonical snapshot or one of its object records. */
7
- type SnapshotDiffPath = readonly (string | number)[];
8
- /** A stable reference to an object in a rename hint. */
9
- interface SnapshotRenameTarget {
10
- /** Stable logical ID, when the source or target snapshot has one. */
11
- readonly id?: string;
12
- /** Physical name evidence used when logical IDs changed. */
13
- readonly physicalName?: string;
14
- /** Optional exact object path for a repeated ID in a nested scope. */
15
- readonly path?: SnapshotDiffPath;
16
- }
17
- /**
18
- * An explicit, serializable physical-rename mapping.
19
- *
20
- * `namespace` and `kind` are part of the key. A hint never crosses either boundary, and a hint is
21
- * only authoritative after both targets resolve to exactly one object.
22
- */
23
- interface SnapshotRenameHint {
24
- readonly namespace?: string;
25
- readonly kind: SnapshotDiffObjectKind;
26
- readonly from: string | SnapshotRenameTarget;
27
- readonly to: string | SnapshotRenameTarget;
28
- }
29
- /** Input accepted by the diff and hint helpers. */
30
- type SnapshotDiffInput = SchemaSnapshot | CompleteSchemaSnapshot | string | Readonly<Record<string, unknown>>;
31
- /** Evidence attached to an object, match, operation, or diagnostic. */
32
- interface SnapshotDiffEvidence {
33
- readonly kind: "logical-id" | "physical-name" | "physical-reference" | "provenance" | "dialect" | "canonical" | "explicit-hint" | "structural" | "ambiguity";
34
- readonly path?: SnapshotDiffPath;
35
- readonly value?: SnapshotJsonValue;
36
- readonly message?: string;
37
- readonly confidence?: number;
38
- }
39
- /** An immutable object view retained by a diff result. */
40
- interface SnapshotDiffObject {
41
- readonly kind: SnapshotDiffObjectKind;
42
- /** The deferred or opaque kind observed by an adapter, if any. */
43
- readonly observedKind?: string;
44
- readonly namespace?: string;
45
- readonly path: SnapshotDiffPath;
46
- readonly parent?: SnapshotDiffObjectReference;
47
- readonly id: string;
48
- readonly physicalName?: string;
49
- readonly physicalReference?: SnapshotJsonValue;
50
- readonly dialect: SnapshotDialect;
51
- readonly provenance?: SnapshotJsonValue;
52
- /** The original validated object record, retained as immutable data. */
53
- readonly value: Readonly<Record<string, SnapshotJsonValue>>;
54
- readonly evidence: readonly SnapshotDiffEvidence[];
55
- }
56
- /** A logical object reference used in parent and related-object evidence. */
57
- interface SnapshotDiffObjectReference {
58
- readonly kind: SnapshotDiffObjectKind;
59
- readonly id: string;
60
- readonly namespace?: string;
61
- }
62
- /** One changed property in a matched object pair. */
63
- interface SnapshotDiffPropertyChange {
64
- readonly path: SnapshotDiffPath;
65
- readonly before?: SnapshotJsonValue;
66
- readonly after?: SnapshotJsonValue;
67
- }
68
- /** Categories of emitted diff operations. */
69
- type SnapshotDiffOperationType = "add" | "remove" | "property-change" | "physical-rename";
70
- /** A diff operation. All variants retain both object identity and evidence. */
71
- interface SnapshotDiffOperation {
72
- readonly type: SnapshotDiffOperationType;
73
- /** Alias for callers that use operation terminology. */
74
- readonly operation: SnapshotDiffOperationType;
75
- readonly classification: SnapshotDiffOperationType;
76
- readonly changeKind: SnapshotDiffOperationType;
77
- readonly kind: SnapshotDiffObjectKind;
78
- readonly objectKind: SnapshotDiffObjectKind;
79
- readonly namespace?: string;
80
- readonly path: SnapshotDiffPath;
81
- readonly dialect: SnapshotDialect;
82
- readonly physicalReference?: SnapshotJsonValue;
83
- readonly provenance?: SnapshotJsonValue;
84
- readonly before?: SnapshotDiffObject;
85
- readonly after?: SnapshotDiffObject;
86
- readonly object?: SnapshotDiffObject;
87
- readonly logicalId?: string;
88
- readonly physicalName?: string;
89
- readonly changedProperties?: readonly SnapshotDiffPropertyChange[];
90
- readonly evidence: readonly SnapshotDiffEvidence[];
91
- readonly source: "stable-id" | "explicit-hint";
92
- readonly destructive: boolean;
93
- }
94
- /** A conservative structural match suggestion. It is never an operation. */
95
- interface SnapshotRenameSuggestion {
96
- readonly type: "rename-suggestion";
97
- readonly operation: "rename-suggestion";
98
- readonly kind: SnapshotDiffObjectKind;
99
- readonly objectKind: SnapshotDiffObjectKind;
100
- readonly namespace?: string;
101
- readonly before: SnapshotDiffObject;
102
- readonly after: SnapshotDiffObject;
103
- readonly confidence: number;
104
- readonly evidence: readonly SnapshotDiffEvidence[];
105
- }
106
- /** Diagnostic categories emitted by snapshot comparison and hint validation. */
107
- type SnapshotDiffDiagnosticCode = "ambiguous" | "destructive" | "unsupported" | "unknown" | "lossy" | "invalid-snapshot" | "invalid-rename-hint" | "rename-conflict" | "dialect-mismatch";
108
- /** A path-addressed diff diagnostic with object and dialect context. */
109
- interface SnapshotDiffDiagnostic {
110
- readonly code: SnapshotDiffDiagnosticCode;
111
- readonly category: SnapshotDiffDiagnosticCode;
112
- readonly severity: "error" | "warning";
113
- readonly message: string;
114
- readonly path: SnapshotDiffPath;
115
- readonly relatedPaths?: readonly SnapshotDiffPath[];
116
- readonly kind?: SnapshotDiffObjectKind;
117
- readonly objectKind?: SnapshotDiffObjectKind;
118
- readonly namespace?: string;
119
- readonly logicalId?: string;
120
- readonly physicalName?: string;
121
- readonly dialect?: SnapshotDialect;
122
- readonly evidence?: readonly SnapshotDiffEvidence[];
123
- }
124
- /** Options controlling explicit hints and conservative suggestions. */
125
- interface SnapshotDiffOptions {
126
- /** Authoritative mappings. `renames` is accepted as an ergonomic alias. */
127
- readonly renameHints?: readonly SnapshotRenameHint[];
128
- readonly renames?: readonly SnapshotRenameHint[];
129
- /** Disable structural suggestions while retaining stable and explicit matches. */
130
- readonly suggestions?: boolean;
131
- /** Minimum score for a unique heuristic suggestion. Defaults to 0.75. */
132
- readonly suggestionThreshold?: number;
133
- }
134
- /** The complete immutable output of `diffSnapshots`. */
135
- interface SnapshotDiff {
136
- readonly equal: boolean;
137
- readonly beforeVersion?: 1 | 2;
138
- readonly afterVersion?: 1 | 2;
139
- readonly beforeDialect?: SnapshotDialect;
140
- readonly afterDialect?: SnapshotDialect;
141
- readonly beforeDigest?: string;
142
- readonly afterDigest?: string;
143
- readonly operations: readonly SnapshotDiffOperation[];
144
- readonly changes: readonly SnapshotDiffOperation[];
145
- readonly additions: readonly SnapshotDiffOperation[];
146
- readonly removals: readonly SnapshotDiffOperation[];
147
- readonly propertyChanges: readonly SnapshotDiffOperation[];
148
- readonly renames: readonly SnapshotDiffOperation[];
149
- readonly added: readonly SnapshotDiffOperation[];
150
- readonly removed: readonly SnapshotDiffOperation[];
151
- readonly changed: readonly SnapshotDiffOperation[];
152
- readonly physicalRenames: readonly SnapshotDiffOperation[];
153
- readonly suggestions: readonly SnapshotRenameSuggestion[];
154
- readonly diagnostics: readonly SnapshotDiffDiagnostic[];
155
- readonly issues: readonly SnapshotDiffDiagnostic[];
156
- readonly renameHints: readonly SnapshotRenameHint[];
157
- readonly hints: readonly SnapshotRenameHint[];
158
- }
159
- /** Result returned by serializable rename-hint validation/decoding helpers. */
160
- type SnapshotRenameHintResult = {
161
- readonly ok: true;
162
- readonly value: readonly SnapshotRenameHint[];
163
- readonly diagnostics: readonly SnapshotDiffDiagnostic[];
164
- } | {
165
- readonly ok: false;
166
- readonly value: readonly SnapshotRenameHint[];
167
- readonly diagnostics: readonly SnapshotDiffDiagnostic[];
168
- };
169
- /** Decode diagnostics without throwing, suitable for editor and CLI callers. */
170
- type SnapshotDiffDecodeResult = {
171
- readonly ok: true;
172
- readonly version: 1 | 2;
173
- readonly value: SchemaSnapshot | CompleteSchemaSnapshot;
174
- } | {
175
- readonly ok: false;
176
- readonly diagnostics: readonly SnapshotDiffDiagnostic[];
177
- };
178
- //#endregion
179
- //#region src/diff/diff.d.ts
180
- /**
181
- * Compare Snapshot v1 or v2 values and return immutable, reviewable data.
182
- *
183
- * The function never opens a connection, renders SQL, or turns a heuristic match into a rename.
184
- * Invalid input and malformed hints are represented by diagnostics in the returned value.
185
- */
186
- declare function diffSnapshots(beforeInput: SnapshotDiffInput, afterInput: SnapshotDiffInput, options?: SnapshotDiffOptions): SnapshotDiff;
187
- /** Alias that reads naturally in comparison-oriented callers. */
188
- declare const compareSnapshots: typeof diffSnapshots;
189
- /** Decode and normalize a Snapshot v1 or v2 value without throwing. */
190
- declare function decodeSnapshotForDiff(input: SnapshotDiffInput): SnapshotDiffDecodeResult;
191
- /** Validate rename hints and return a frozen, serializable list. */
192
- declare function validateSnapshotRenameHints(hints: readonly SnapshotRenameHint[] | unknown): SnapshotRenameHintResult;
193
- /** Serialize validated rename hints as deterministic JSON. */
194
- declare function encodeSnapshotRenameHints(hints: readonly SnapshotRenameHint[]): string;
195
- /** Decode deterministic rename-hint JSON without throwing. */
196
- declare function decodeSnapshotRenameHints(input: string | unknown): SnapshotRenameHintResult;
197
- /** Short aliases for callers that keep rename helpers beside `diffSnapshots`. */
198
- declare const validateRenameHints: typeof validateSnapshotRenameHints;
199
- declare const encodeRenameHints: typeof encodeSnapshotRenameHints;
200
- declare const decodeRenameHints: typeof decodeSnapshotRenameHints;
201
- //#endregion
202
- export { SnapshotDiffPropertyChange as C, SnapshotRenameTarget as D, SnapshotRenameSuggestion as E, SnapshotDiffPath as S, SnapshotRenameHintResult as T, SnapshotDiffObjectKind as _, diffSnapshots as a, SnapshotDiffOperationType as b, validateRenameHints as c, SnapshotDiffDecodeResult as d, SnapshotDiffDiagnostic as f, SnapshotDiffObject as g, SnapshotDiffInput as h, decodeSnapshotRenameHints as i, validateSnapshotRenameHints as l, SnapshotDiffEvidence as m, decodeRenameHints as n, encodeRenameHints as o, SnapshotDiffDiagnosticCode as p, decodeSnapshotForDiff as r, encodeSnapshotRenameHints as s, compareSnapshots as t, SnapshotDiff as u, SnapshotDiffObjectReference as v, SnapshotRenameHint as w, SnapshotDiffOptions as x, SnapshotDiffOperation as y };
@@ -1,214 +0,0 @@
1
- import { T as SnapshotJsonValue, m as SnapshotDialect } from "./types-C0VkiwpR.mjs";
2
- import { S as SnapshotDiffPath, _ as SnapshotDiffObjectKind, b as SnapshotDiffOperationType, f as SnapshotDiffDiagnostic, g as SnapshotDiffObject, m as SnapshotDiffEvidence, u as SnapshotDiff } from "./index-C_BQNvbT.mjs";
3
- //#region src/migration/types.d.ts
4
- /** The versioned envelope tag for dialect-neutral migration plans. */
5
- declare const migrationPlanFormat: "qubu-migration-plan";
6
- /** The first strict migration-plan format version. */
7
- declare const migrationPlanVersion: 1;
8
- /** Safety classifications carried by every planned operation. */
9
- type MigrationSafety = "safe" | "review-required" | "destructive" | "unsupported" | "unknown";
10
- /** Lock strength required by a planned operation. */
11
- type MigrationLockRequirement = "none" | "shared" | "exclusive" | "unknown";
12
- /** Transaction behavior required by a planned operation. */
13
- type MigrationTransactionRequirement = "required" | "optional" | "forbidden" | "unknown";
14
- /** Operations that can appear in a migration plan. */
15
- type MigrationOperationType = "add" | "remove" | "property-change" | "physical-rename" | "custom-sql";
16
- /** A condition a later executor must check before applying an operation. */
17
- type MigrationPreconditionType = "snapshot-digest" | "object-present" | "object-absent" | "property-equals";
18
- /** An immutable, serializable migration precondition. */
19
- interface MigrationPrecondition {
20
- readonly type: MigrationPreconditionType;
21
- readonly path: SnapshotDiffPath;
22
- readonly kind: SnapshotDiffObjectKind | "custom-sql";
23
- readonly namespace?: string;
24
- readonly logicalId?: string;
25
- readonly physicalName?: string;
26
- readonly digest?: string;
27
- readonly property?: SnapshotDiffPath;
28
- readonly value?: SnapshotJsonValue;
29
- }
30
- /** The explicit custom SQL escape hatch for one planned operation. */
31
- interface MigrationCustomSql {
32
- readonly sql: string;
33
- readonly dialect: SnapshotDialect;
34
- readonly safety: MigrationSafety;
35
- readonly position: number;
36
- readonly reason: string;
37
- readonly reversible: boolean;
38
- }
39
- /** Input accepted when attaching explicit custom SQL to a plan. */
40
- interface MigrationCustomSqlInput {
41
- readonly sql: string;
42
- readonly dialect: SnapshotDialect;
43
- readonly safety: MigrationSafety;
44
- readonly reason: string;
45
- readonly reversible?: boolean;
46
- /** Target an operation by deterministic ID when it already exists. */
47
- readonly operationId?: string;
48
- /** Or target a diff object by kind, namespace, and path. */
49
- readonly kind?: SnapshotDiffObjectKind;
50
- readonly namespace?: string;
51
- readonly path?: SnapshotDiffPath;
52
- /** Explicit dependency position. It does not render or execute SQL. */
53
- readonly position?: number;
54
- readonly dependsOn?: readonly string[];
55
- }
56
- /** A user's explicit decision for an unsafe or incomplete fact. */
57
- interface MigrationDecision {
58
- readonly action: "allow" | "skip";
59
- readonly reason: string;
60
- readonly operationId?: string;
61
- readonly kind?: SnapshotDiffObjectKind;
62
- readonly namespace?: string;
63
- readonly path?: SnapshotDiffPath;
64
- readonly code?: MigrationDiagnosticCode;
65
- }
66
- /** Why a plan was blocked or needs review. */
67
- type MigrationDiagnosticCode = "decision-required" | "dependency-cycle" | "invalid-plan" | "unknown" | "lossy" | "unsupported" | "destructive" | "ambiguous" | "custom-sql" | "dialect-mismatch" | "non-canonical";
68
- /** A structured plan diagnostic that keeps source diff context. */
69
- interface MigrationDiagnostic {
70
- readonly code: MigrationDiagnosticCode;
71
- readonly severity: "error" | "warning";
72
- readonly message: string;
73
- readonly path: SnapshotDiffPath;
74
- readonly operationId?: string;
75
- readonly kind?: SnapshotDiffObjectKind | "custom-sql";
76
- readonly namespace?: string;
77
- readonly logicalId?: string;
78
- readonly physicalName?: string;
79
- readonly dialect?: SnapshotDialect;
80
- readonly evidence?: readonly SnapshotDiffEvidence[];
81
- readonly source?: SnapshotDiffDiagnostic;
82
- }
83
- /** The source facts preserved on each non-custom migration operation. */
84
- interface MigrationOperationOrigin {
85
- readonly type: SnapshotDiffOperationType;
86
- readonly kind: SnapshotDiffObjectKind;
87
- readonly namespace?: string;
88
- readonly path: SnapshotDiffPath;
89
- readonly logicalId?: string;
90
- readonly physicalName?: string;
91
- readonly physicalReference?: SnapshotJsonValue;
92
- readonly provenance?: SnapshotJsonValue;
93
- readonly before?: SnapshotDiffObject;
94
- readonly after?: SnapshotDiffObject;
95
- readonly evidence: readonly SnapshotDiffEvidence[];
96
- }
97
- /** One immutable operation in a migration plan. */
98
- interface MigrationOperation {
99
- readonly id: string;
100
- readonly type: MigrationOperationType;
101
- readonly kind: SnapshotDiffObjectKind | "custom-sql";
102
- readonly objectKind: SnapshotDiffObjectKind | "custom-sql";
103
- readonly namespace?: string;
104
- readonly path: SnapshotDiffPath;
105
- readonly logicalId?: string;
106
- readonly physicalName?: string;
107
- readonly physicalReference?: SnapshotJsonValue;
108
- readonly provenance?: SnapshotJsonValue;
109
- readonly dialect: SnapshotDialect;
110
- readonly safety: MigrationSafety;
111
- readonly lock: MigrationLockRequirement;
112
- readonly transaction: MigrationTransactionRequirement;
113
- readonly reversible: boolean;
114
- readonly reversibility: "reversible" | "irreversible";
115
- readonly irreversibleReason?: string;
116
- readonly preconditions: readonly MigrationPrecondition[];
117
- readonly dependsOn: readonly string[];
118
- readonly evidence: readonly SnapshotDiffEvidence[];
119
- readonly origin?: MigrationOperationOrigin;
120
- readonly customSql?: MigrationCustomSql;
121
- readonly decision?: MigrationDecision;
122
- readonly status: "approved" | "decision-required" | "skipped";
123
- readonly position: number;
124
- }
125
- /** A dependency edge. `from` must appear before `to`. */
126
- interface MigrationDependency {
127
- readonly from: string;
128
- readonly to: string;
129
- readonly reason: "parent-before-child" | "child-before-parent" | "reference-before-dependent" | "explicit-custom-sql";
130
- }
131
- /** Immutable migration plan data. It contains no executor or SQL renderer. */
132
- interface MigrationPlan {
133
- readonly format: typeof migrationPlanFormat;
134
- readonly version: typeof migrationPlanVersion;
135
- readonly dialect: SnapshotDialect;
136
- readonly beforeDigest?: string;
137
- readonly afterDigest?: string;
138
- readonly safety: MigrationSafety;
139
- readonly ready: boolean;
140
- readonly operations: readonly MigrationOperation[];
141
- readonly dependencies: readonly MigrationDependency[];
142
- readonly decisions: readonly MigrationDecision[];
143
- readonly diagnostics: readonly MigrationDiagnostic[];
144
- }
145
- /** Options for converting a resolved diff into a migration plan. */
146
- interface MigrationPlanOptions {
147
- readonly decisions?: readonly MigrationDecision[];
148
- readonly customSql?: readonly MigrationCustomSqlInput[];
149
- readonly allowUnknown?: boolean;
150
- readonly allowLossy?: boolean;
151
- readonly allowUnsupported?: boolean;
152
- readonly allowDestructive?: boolean;
153
- readonly allowReviewRequired?: boolean;
154
- }
155
- /** A plan result retains a blocked plan so callers can inspect and review it. */
156
- type MigrationPlanResult = {
157
- readonly ok: true;
158
- readonly plan: MigrationPlan;
159
- readonly diagnostics: readonly MigrationDiagnostic[];
160
- } | {
161
- readonly ok: false;
162
- readonly plan: MigrationPlan;
163
- readonly diagnostics: readonly MigrationDiagnostic[];
164
- };
165
- /** Result returned by strict plan decoding. */
166
- type MigrationPlanDecodeResult = {
167
- readonly ok: true;
168
- readonly value: MigrationPlan;
169
- } | {
170
- readonly ok: false;
171
- readonly diagnostics: readonly MigrationDiagnostic[];
172
- };
173
- /** Result returned by non-throwing plan validation. */
174
- type MigrationPlanValidationResult = MigrationPlanDecodeResult;
175
- /** A validation error raised by throwing plan APIs. */
176
- declare class MigrationPlanValidationError extends TypeError {
177
- readonly name = "MigrationPlanValidationError";
178
- readonly diagnostics: readonly MigrationDiagnostic[];
179
- readonly issues: readonly MigrationDiagnostic[];
180
- constructor(diagnostics: readonly MigrationDiagnostic[]);
181
- }
182
- //#endregion
183
- //#region src/migration/plan.d.ts
184
- /**
185
- * Convert a resolved SnapshotDiff into an immutable migration plan.
186
- *
187
- * This function only describes operations. It does not render SQL, open a connection, execute a
188
- * transaction, or infer SQL from opaque snapshot data. A plan that still needs a safety decision is
189
- * returned with `ok: false` so it can be reviewed without being mistaken for an executable plan.
190
- */
191
- declare function createMigrationPlan(diff: SnapshotDiff, options?: MigrationPlanOptions): MigrationPlanResult;
192
- /** Alias for callers that treat plan creation as the main migration action. */
193
- declare const planMigration: typeof createMigrationPlan;
194
- declare const createPlan: typeof createMigrationPlan;
195
- /** Build a plan or throw one structured validation error when it is blocked. */
196
- declare function assertMigrationPlanFromDiff(diff: SnapshotDiff, options?: MigrationPlanOptions): MigrationPlan;
197
- /** Return a fixed-order immutable plan after strict validation. */
198
- declare function canonicalizeMigrationPlan(input: MigrationPlan): MigrationPlan;
199
- /** Encode a validated plan as deterministic JSON. */
200
- declare function encodeMigrationPlan(input: MigrationPlan): string;
201
- /** Decode and strictly validate a migration-plan JSON value. */
202
- declare function decodeMigrationPlan(input: string | unknown): MigrationPlanDecodeResult;
203
- /** Validate a plan without throwing. */
204
- declare function validateMigrationPlan(input: unknown): MigrationPlanValidationResult;
205
- /** Validate a plan and throw one structured error on failure. */
206
- declare function assertMigrationPlan(input: unknown): MigrationPlan;
207
- /** Compute a deterministic digest for cache keys and fixture assertions. */
208
- declare function migrationPlanDigest(input: MigrationPlan | string): string;
209
- declare const encodePlan: typeof encodeMigrationPlan;
210
- declare const decodePlan: typeof decodeMigrationPlan;
211
- declare const assertPlan: typeof assertMigrationPlan;
212
- declare const digestMigrationPlan: typeof migrationPlanDigest;
213
- //#endregion
214
- export { MigrationCustomSql, MigrationCustomSqlInput, MigrationDecision, MigrationDependency, MigrationDiagnostic, MigrationDiagnosticCode, MigrationLockRequirement, MigrationOperation, MigrationOperationOrigin, MigrationOperationType, MigrationPlan, MigrationPlanDecodeResult, MigrationPlanOptions, MigrationPlanResult, MigrationPlanValidationError, MigrationPlanValidationResult, MigrationPrecondition, MigrationPreconditionType, MigrationSafety, MigrationTransactionRequirement, type SnapshotDiff, assertMigrationPlan, assertMigrationPlanFromDiff, assertPlan, canonicalizeMigrationPlan, createMigrationPlan, createPlan, decodeMigrationPlan, decodePlan, digestMigrationPlan, encodeMigrationPlan, encodePlan, migrationPlanDigest, migrationPlanFormat, migrationPlanVersion, planMigration, validateMigrationPlan };