@voltro/database 0.83.0 → 0.84.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/sql.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { ConfigError } from 'effect';
2
+ import { Connection } from '@effect/sql/SqlConnection';
2
3
  import { Effect } from 'effect';
3
4
  import { Fragment } from '@effect/sql/Statement';
4
5
  import { Layer } from 'effect';
@@ -719,6 +720,10 @@ export declare const chunkTables: <T>(xs: ReadonlyArray<T>, n: number) => T[][];
719
720
  */
720
721
  export declare const classifyRollingDeploySafety: (op: MigrationOperation, context?: RollingDeployContext) => RollingDeploySafety;
721
722
 
723
+ /** Explicit finalization removes verified retained artifacts, never the receipt.
724
+ * Finalizing a published conversion permanently closes its rollback window. */
725
+ export declare const cleanupSqliteDecimalPublication: (sql: SqlClient.SqlClient, request: SqliteRetainedSourceRequest, target: TableSnapshot, triggers?: ReadonlyArray<SqliteDecimalTargetTrigger>) => Effect.Effect<void, SqlError>;
726
+
722
727
  /**
723
728
  * Every resume-ledger row, gone — for a caller that has just UNDONE the run
724
729
  * the rows describe. A ledger that outlives the work it recorded would make
@@ -964,6 +969,14 @@ declare interface ColumnDefinition<TsType, Type extends ColumnType = ColumnType,
964
969
  * column is just `bytes` with server-merge semantics.
965
970
  */
966
971
  readonly crdtManaged?: boolean;
972
+ /**
973
+ * End-to-end-sealed CRDT marker, set by `crdtSealed()`. The column holds an
974
+ * append-only LOG of encrypted CRDT updates the server cannot read: the
975
+ * write path appends an incoming frame (or applies a client's snapshot
976
+ * frame) and never decodes or merges — clients holding the key do. Same
977
+ * `bytes` storage and zero DDL churn as `crdtManaged`.
978
+ */
979
+ readonly crdtSealed?: boolean;
967
980
  /**
968
981
  * Optimistic-concurrency marker, set by `.version()`.
969
982
  *
@@ -1021,6 +1034,7 @@ declare interface ColumnDefinition<TsType, Type extends ColumnType = ColumnType,
1021
1034
  * MUST be `<= precision`. See {@link ColumnDefinition.precision}.
1022
1035
  */
1023
1036
  readonly scale?: number;
1037
+ /* Excluded from this release type: sqliteDecimalEncoding */
1024
1038
  /**
1025
1039
  * Vector dimensionality. Populated only when `type === 'vector'`.
1026
1040
  * The migration emitter uses it to size the column DDL —
@@ -1386,6 +1400,14 @@ declare interface ColumnDefinition_2<TsType, Type extends ColumnType_2 = ColumnT
1386
1400
  * column is just `bytes` with server-merge semantics.
1387
1401
  */
1388
1402
  readonly crdtManaged?: boolean;
1403
+ /**
1404
+ * End-to-end-sealed CRDT marker, set by `crdtSealed()`. The column holds an
1405
+ * append-only LOG of encrypted CRDT updates the server cannot read: the
1406
+ * write path appends an incoming frame (or applies a client's snapshot
1407
+ * frame) and never decodes or merges — clients holding the key do. Same
1408
+ * `bytes` storage and zero DDL churn as `crdtManaged`.
1409
+ */
1410
+ readonly crdtSealed?: boolean;
1389
1411
  /**
1390
1412
  * Optimistic-concurrency marker, set by `.version()`.
1391
1413
  *
@@ -1443,6 +1465,7 @@ declare interface ColumnDefinition_2<TsType, Type extends ColumnType_2 = ColumnT
1443
1465
  * MUST be `<= precision`. See {@link ColumnDefinition.precision}.
1444
1466
  */
1445
1467
  readonly scale?: number;
1468
+ /* Excluded from this release type: sqliteDecimalEncoding */
1446
1469
  /**
1447
1470
  * Vector dimensionality. Populated only when `type === 'vector'`.
1448
1471
  * The migration emitter uses it to size the column DDL —
@@ -1703,6 +1726,10 @@ export declare interface ColumnSnapshot {
1703
1726
  */
1704
1727
  readonly precision?: number;
1705
1728
  readonly scale?: number;
1729
+ /** Physical SQLite-family exact-decimal representation. Absent on ordinary
1730
+ * NUMERIC columns. The marker is observable schema state, not a DSL hint:
1731
+ * changing it requires data conversion, never a plain SQL type cast. */
1732
+ readonly sqliteDecimalEncoding?: 'sortable-v1';
1706
1733
  /**
1707
1734
  * Id-generation scheme for `type: 'id'` columns. Mirrors
1708
1735
  * `ColumnDefinition.idScheme.kind` so the applier can tell a numeric
@@ -3315,6 +3342,12 @@ export declare const fingerprintSchema: (snapshot: SchemaSnapshot) => string;
3315
3342
 
3316
3343
  export declare const fnv1a64: (input: string) => bigint;
3317
3344
 
3345
+ /** Read identities and decimal observations before driver numeric conversion.
3346
+ * Keys include storage type: text/blob use full hex (including NUL); numeric
3347
+ * keys use the engine's SQL literal. Duplicate selected keys refuse conversion.
3348
+ * This reads only; its caller owns exclusion and retained-artifact verification. */
3349
+ export declare const forEachSqliteDecimalSourcePage: <E, R>(connection: Pick<Connection, "executeUnprepared">, retained: string, keys: ReadonlyArray<string>, columns: ReadonlyArray<SqliteDecimalSourceColumn>, visit: (cells: ReadonlyArray<SqliteDecimalReviewedCell>) => Effect.Effect<void, E, R>) => Effect.Effect<void, SqlError | E, R>;
3350
+
3318
3351
  /** The refusal a foreign claim produces — one sentence for both boot paths. */
3319
3352
  export declare const foreignOwnerMessage: (self: string, owner: string, claimedAt: string | undefined) => string;
3320
3353
 
@@ -3776,6 +3809,8 @@ export declare type MigrationAtomicity = 'plan-transactional' | 'per-operation';
3776
3809
 
3777
3810
  export declare const migrationAtomicityFor: (dialect: DialectId) => MigrationAtomicity;
3778
3811
 
3812
+ declare type MigrationBatch = (statements: ReadonlyArray<string>) => Effect.Effect<void, SqlError>;
3813
+
3779
3814
  /**
3780
3815
  * The hash of a migration file's SOURCE, recorded beside its ledger row.
3781
3816
  *
@@ -4675,6 +4710,10 @@ declare interface PredicateLeaf_2 {
4675
4710
  readonly path?: ReadonlyArray<string | number>;
4676
4711
  }
4677
4712
 
4713
+ /** Internal encoded stage. The reviewed target is bound into retained ownership;
4714
+ * source publication and artifact cleanup remain separate operations. */
4715
+ export declare const prepareSqliteDecimalStage: (sql: SqlClient.SqlClient, request: SqliteRetainedSourceRequest, target: TableSnapshot) => Effect.Effect<SqliteDecimalStage, SqlError>;
4716
+
4678
4717
  /** Read the complete eligible history, independent of the dashboard's recent
4679
4718
  * history limit. The token must be rechecked by squashMigrationPlans on write. */
4680
4719
  export declare const previewMigrationSquash: (options: Pick<SquashOptions, "before" | "fingerprint">) => Effect.Effect<MigrationSquashPreview, Error, SqlClient.SqlClient>;
@@ -4704,6 +4743,15 @@ export declare const previewMigrationSquash: (options: Pick<SquashOptions, "befo
4704
4743
  */
4705
4744
  export declare const provisionTenantNamespace: (tables: ReadonlyArray<AnyTable>, namespace: string, sqlLayer: Layer.Layer<SqlClient.SqlClient, ConfigError.ConfigError | SqlError_2.SqlError, never>, dialect?: DialectId, options?: SchemaApplyOptions) => Promise<void>;
4706
4745
 
4746
+ /** Internal offline publication. Receipt and published image share the same
4747
+ * commit as table replacement. Retry verifies receipt/schema/retained artifacts
4748
+ * without requiring live rows to remain unchanged after successful publication. */
4749
+ export declare const publishSqliteDecimalStage: (sql: SqlClient.SqlClient, request: SqliteRetainedSourceRequest, target: TableSnapshot, triggers?: ReadonlyArray<SqliteDecimalTargetTrigger>) => Effect.Effect<{
4750
+ readonly marker: string;
4751
+ readonly image: string;
4752
+ readonly sourceCopy: string;
4753
+ }, SqlError>;
4754
+
4707
4755
  /**
4708
4756
  * The runtime-facing materialized query — a plain bag of strings the store and
4709
4757
  * the matcher consume.
@@ -5407,6 +5455,12 @@ export declare const reactiveTriggerRepairSql: (input: {
5407
5455
 
5408
5456
  export declare const readMigrationSnapshotCandidates: (sql: SqlClient.SqlClient, live: SchemaSnapshot) => Effect.Effect<ReadonlyArray<MigrationSnapshotCandidate>, SqlError>;
5409
5457
 
5458
+ /** Collect observations for callers that explicitly need a complete review.
5459
+ * Retained-source validation consumes pages directly instead. */
5460
+ export declare const readSqliteDecimalSource: (connection: Pick<Connection, "executeUnprepared">, retained: string, keys: ReadonlyArray<string>, columns: ReadonlyArray<SqliteDecimalSourceColumn>) => Effect.Effect<ReadonlyArray<SqliteDecimalReviewedCell>, SqlError>;
5461
+
5462
+ export declare const readSqliteTableSchema: (connection: Pick<Connection, "executeUnprepared">, table: string) => Effect.Effect<SqliteTableSchema, SqlError>;
5463
+
5410
5464
  /** Every string column of a base table in the connected database. */
5411
5465
  export declare const readUndeclaredCharsetColumns: (sql: SqlClient.SqlClient) => Effect.Effect<ReadonlyArray<UndeclaredCharsetColumn>, SqlError>;
5412
5466
 
@@ -5462,6 +5516,8 @@ export declare const recordUpToDate: (sql: SqlClient.SqlClient, plan: MigrationP
5462
5516
  readonly source: string;
5463
5517
  }) => Effect.Effect<"recorded" | "already-current", never>;
5464
5518
 
5519
+ /* Excluded from this release type: registerSqliteMigrationBatch */
5520
+
5465
5521
  /* Excluded from this release type: registerSqlPoolCapacity */
5466
5522
 
5467
5523
  export declare type RehearsalOutcome =
@@ -5576,6 +5632,11 @@ export declare const rollbackFileBasedMigration: (sql: SqlClient.SqlClient, ctx:
5576
5632
  durationMs: number;
5577
5633
  }, unknown>;
5578
5634
 
5635
+ /** Restore original declared values only while the published rows are unchanged.
5636
+ * The receipt changes in the same commit, so a retry preserves subsequent writes.
5637
+ * Retained copies remain owned until a separate explicit cleanup. */
5638
+ export declare const rollbackSqliteDecimalPublication: (sql: SqlClient.SqlClient, request: SqliteRetainedSourceRequest, target: TableSnapshot, triggers?: ReadonlyArray<SqliteDecimalTargetTrigger>) => Effect.Effect<void, SqlError>;
5639
+
5579
5640
  /**
5580
5641
  * What the plan already knows that a single operation does not: the tables it
5581
5642
  * creates. Optional — without it nothing is known to be new and every verdict
@@ -5779,6 +5840,11 @@ export declare const runSchemaOp: (sql: SqlClient.SqlClient, op: MigrationSchema
5779
5840
  /** Runs one Effect over the connection — the shape `ManagedRuntime.runPromise` and a store's `run` share. */
5780
5841
  export declare type RunSql = <A>(effect: Effect.Effect<A, SqlError, SqlClient.SqlClient>) => Promise<A>;
5781
5842
 
5843
+ /** Execute one SQLite-family schema rewrite atomically. This is an operation
5844
+ * boundary, not a transaction over the complete migration plan. Call outside
5845
+ * existing transactions so FK enforcement can be changed before BEGIN. */
5846
+ export declare const runSqliteMigrationBatch: (sql: SqlClient.SqlClient, statements: ReadonlyArray<string>) => Effect.Effect<void, SqlError>;
5847
+
5782
5848
  export declare const SCHEMA_OWNER_TABLE = "_voltro_schema_owner";
5783
5849
 
5784
5850
  /**
@@ -6004,6 +6070,131 @@ declare interface SpatialClause_2 {
6004
6070
  */
6005
6071
  export declare const sql: (strings: TemplateStringsArray, ...values: ReadonlyArray<unknown>) => RawSqlFragment;
6006
6072
 
6073
+ /** Internal conversion input. NUMERIC affinity may already have rounded even
6074
+ * integer-looking values. Its driver result is never an exact decimal source. */
6075
+ export declare type SqliteDecimalConversionSource = {
6076
+ readonly kind: 'text';
6077
+ readonly value: unknown;
6078
+ } | {
6079
+ readonly kind: 'sortable-v1';
6080
+ readonly value: unknown;
6081
+ readonly shape: SqliteDecimalShape;
6082
+ } | {
6083
+ readonly kind: 'numeric';
6084
+ readonly value: unknown;
6085
+ /** An explicit per-value decision, not an automatic String(number) cast.
6086
+ * Supply an authoritative decimal or deliberately accept a rounded value.
6087
+ * Acknowledging possible prior loss does not recover the original digits. */
6088
+ readonly resolution?: {
6089
+ readonly decimal: string;
6090
+ readonly acknowledgePriorRounding: true;
6091
+ };
6092
+ };
6093
+
6094
+ declare interface SqliteDecimalDecision {
6095
+ readonly rowIdentity: string;
6096
+ readonly column: string;
6097
+ readonly encoded: string | null;
6098
+ readonly sourceIdentity: string;
6099
+ readonly target: SqliteDecimalShape;
6100
+ }
6101
+
6102
+ /** Canonical identity order shared by array reviews and streamed witnesses. */
6103
+ export declare const sqliteDecimalDecisionIdentity: (cell: Pick<SqliteDecimalDecision, "rowIdentity" | "column">) => string;
6104
+
6105
+ /** Internal reviewed cell input. Row identities come from the retained source,
6106
+ * not positional array indexes or driver-rounded numeric primary keys. */
6107
+ export declare interface SqliteDecimalReviewedCell {
6108
+ readonly rowIdentity: string;
6109
+ readonly column: string;
6110
+ readonly source: SqliteDecimalConversionSource;
6111
+ readonly target: SqliteDecimalShape;
6112
+ }
6113
+
6114
+ /** Internal candidate storage codec. Not yet connected to DDL or store writes. */
6115
+ export declare interface SqliteDecimalShape {
6116
+ readonly precision: number;
6117
+ readonly scale: number;
6118
+ }
6119
+
6120
+ export declare interface SqliteDecimalSourceColumn {
6121
+ readonly name: string;
6122
+ readonly source: 'text' | 'numeric' | {
6123
+ readonly encoding: 'sortable-v1';
6124
+ readonly shape: SqliteDecimalShape;
6125
+ };
6126
+ readonly target: SqliteDecimalShape;
6127
+ }
6128
+
6129
+ export declare interface SqliteDecimalStage {
6130
+ readonly stage: string;
6131
+ readonly marker: string;
6132
+ readonly sourceCopy: string;
6133
+ readonly sourceMarker: string;
6134
+ readonly sourceManifest: string;
6135
+ readonly sourceContents: SqliteTableContents;
6136
+ readonly sourceRowIdentity: SqliteRowIdentity;
6137
+ readonly manifest: string;
6138
+ readonly schema: SqliteTableSchema;
6139
+ /** Captured before final source/stage validation. Publication must assert
6140
+ * this epoch rather than recapturing it after validation has completed. */
6141
+ readonly validationEpoch: number;
6142
+ readonly indexes: ReadonlyArray<string>;
6143
+ }
6144
+
6145
+ export declare interface SqliteDecimalTargetTrigger {
6146
+ readonly name: string;
6147
+ readonly sql: string;
6148
+ }
6149
+
6150
+ /* Excluded from this release type: sqliteMigrationBatchStatements */
6151
+
6152
+ /** Internal preparation input from an existing file migration. The caller owns
6153
+ * offline exclusion; this is artifact metadata, not a second migration runner. */
6154
+ export declare interface SqliteRetainedSourceRequest {
6155
+ readonly migrationId: string;
6156
+ readonly source: string;
6157
+ readonly targetIdentity: string;
6158
+ readonly reviewedSchema: SqliteTableSchema;
6159
+ readonly decimalReview?: {
6160
+ readonly keys: ReadonlyArray<string>;
6161
+ readonly columns: ReadonlyArray<SqliteDecimalSourceColumn>;
6162
+ /** Repeatable input in unique canonical decision order; may stream from disk. */
6163
+ readonly cells: Iterable<SqliteDecimalReviewedCell>;
6164
+ };
6165
+ }
6166
+
6167
+ /** Physical identity retained separately from declared row values. Integer
6168
+ * identities and sequence watermarks never pass through JavaScript numbers. */
6169
+ declare interface SqliteRowIdentity {
6170
+ readonly alias: string | null;
6171
+ readonly columns: ReadonlyArray<string>;
6172
+ readonly rowCount: number;
6173
+ readonly digest: string;
6174
+ readonly sequence: string | null;
6175
+ readonly autoincrement: boolean;
6176
+ readonly sequenceBackend: 'sqlite' | 'turso';
6177
+ }
6178
+
6179
+ /** Internal multiset witness: includes storage classes and duplicate counts,
6180
+ * with values formatted in SQL before the driver can narrow integer/real data.
6181
+ * Independent of row order; not a lock or protection against a forged manifest. */
6182
+ declare interface SqliteTableContents {
6183
+ readonly columns: ReadonlyArray<string>;
6184
+ readonly digest: string;
6185
+ }
6186
+
6187
+ /** Internal, serializable schema witness for one ordinary main-schema table.
6188
+ * SQL is retained exactly: even semantically equivalent DDL changes require a
6189
+ * new review. This is neither artifact ownership nor a writer exclusion lock. */
6190
+ export declare interface SqliteTableSchema {
6191
+ readonly objects: ReadonlyArray<{
6192
+ readonly type: string;
6193
+ readonly name: string;
6194
+ readonly sql: string | null;
6195
+ }>;
6196
+ }
6197
+
6007
6198
  /* Excluded from this release type: sqlPoolCapacity */
6008
6199
 
6009
6200
  /**
@@ -6905,6 +7096,11 @@ declare type VectorDistance = 'cosine' | 'l2' | 'inner';
6905
7096
  */
6906
7097
  declare type VectorDistance_2 = 'cosine' | 'l2' | 'inner';
6907
7098
 
7099
+ /** A matching recorded fingerprint cannot certify a partially converted table.
7100
+ * Read physical markers before accepting a SQLite-family boot. No data or DDL
7101
+ * is touched, and ordinary schemas do not incur per-table catalog queries. */
7102
+ export declare const verifySqliteDecimalStorage: (sql: SqlClient.SqlClient, declared: ReadonlyArray<TableLike>) => Effect.Effect<void, SqlError>;
7103
+
6908
7104
  /**
6909
7105
  * A read-only SQL view descriptor. Structurally a `TableLike` (carries
6910
7106
  * `tableName` + `fields`) so the query builder + row decoder + by-name