@voltro/database 0.74.0 → 0.76.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/CHANGELOG.md +723 -0
- package/dist/frameworkTables-CSY95jCs.js +2186 -0
- package/dist/index.d.ts +87 -0
- package/dist/index.js +699 -1189
- package/dist/sql.d.ts +31 -8
- package/dist/sql.js +1347 -1309
- package/package.json +3 -3
- package/dist/frameworkLiveTables-C1WjQ_uI.js +0 -1641
package/dist/index.d.ts
CHANGED
|
@@ -4791,6 +4791,8 @@ export declare const isStagingTableName: (name: string) => boolean;
|
|
|
4791
4791
|
*/
|
|
4792
4792
|
export declare const isTableReactive: (tableName: string) => boolean;
|
|
4793
4793
|
|
|
4794
|
+
export declare const isTransactionAbortedError: (e: unknown) => e is TransactionAbortedError;
|
|
4795
|
+
|
|
4794
4796
|
/**
|
|
4795
4797
|
* Dialect-agnostic: does this error, anywhere down its `cause` chain, carry a
|
|
4796
4798
|
* contention signal any supported engine emits? The mutation runner replays
|
|
@@ -5011,6 +5013,8 @@ export declare interface MakeStoreOptions {
|
|
|
5011
5013
|
readonly cdcConfig?: CdcConfig;
|
|
5012
5014
|
}
|
|
5013
5015
|
|
|
5016
|
+
export declare const makeTransactionAbortTracker: (isFatal: (error: unknown) => boolean, label?: string) => TransactionAbortTracker;
|
|
5017
|
+
|
|
5014
5018
|
export declare const many: (target: TableRef, options?: {
|
|
5015
5019
|
readonly foreignKey?: string;
|
|
5016
5020
|
readonly sourceKey?: string;
|
|
@@ -7130,6 +7134,8 @@ export declare interface RewriteOptions extends EachOptions {
|
|
|
7130
7134
|
* addition to the columns the patch itself changes. A JSON column cannot be
|
|
7131
7135
|
* compared by value on every dialect, so a rewrite of one guards on what
|
|
7132
7136
|
* you name here — an `updatedAt`, a `version` — rather than on the document.
|
|
7137
|
+
* Temporal comparisons retain the database's full precision, even though
|
|
7138
|
+
* the callback's Date values only represent milliseconds.
|
|
7133
7139
|
*/
|
|
7134
7140
|
readonly guard?: ReadonlyArray<string>;
|
|
7135
7141
|
/**
|
|
@@ -7274,6 +7280,28 @@ export declare const runRetryingTransaction: <A>(spec: DialectTransactionSpec &
|
|
|
7274
7280
|
readonly body: (conn: TransactionConnectionContext, attempt: number) => Promise<A>;
|
|
7275
7281
|
}) => Promise<A>;
|
|
7276
7282
|
|
|
7283
|
+
/**
|
|
7284
|
+
* `DataStore.savepoint` for a transactional view — ONE algorithm for every
|
|
7285
|
+
* dialect; the view supplies only how to send one statement on its transaction
|
|
7286
|
+
* and which spelling its engine uses.
|
|
7287
|
+
*
|
|
7288
|
+
* It used to exist on the postgres view alone, while the message a caught
|
|
7289
|
+
* failure raises (`TransactionAbortedError`) names it as THE way to tolerate a
|
|
7290
|
+
* failing statement — so on three dialects, and through the store a handler
|
|
7291
|
+
* holds on all four, the advice pointed at a method that was `undefined`.
|
|
7292
|
+
*
|
|
7293
|
+
* `RELEASE` on success is not optional housekeeping: an unreleased savepoint
|
|
7294
|
+
* keeps a subtransaction alive for the rest of the transaction. SQL Server has
|
|
7295
|
+
* no release — a saved point simply ends with the transaction.
|
|
7296
|
+
*/
|
|
7297
|
+
export declare const runSavepoint: <A>(input: {
|
|
7298
|
+
readonly tracker: TransactionAbortTracker;
|
|
7299
|
+
readonly name: string;
|
|
7300
|
+
/** Send one framework-authored statement on the view's transaction. */
|
|
7301
|
+
readonly exec: (statement: string) => Promise<unknown>;
|
|
7302
|
+
readonly spelling: "standard" | "mssql";
|
|
7303
|
+
}, fn: () => Promise<A>) => Promise<A>;
|
|
7304
|
+
|
|
7277
7305
|
/**
|
|
7278
7306
|
* THE entry point every dialect store's `transactional()` — and postgres'
|
|
7279
7307
|
* `runInNamespace()` — routes through.
|
|
@@ -8787,6 +8815,50 @@ export declare const timestampMs: Schema.Schema<Date, number>;
|
|
|
8787
8815
|
*/
|
|
8788
8816
|
export declare const timestampMsOrNull: Schema.Schema<Date | null, number | null>;
|
|
8789
8817
|
|
|
8818
|
+
/**
|
|
8819
|
+
* `transactional()`'s work caught a statement failure the engine had already
|
|
8820
|
+
* made fatal to the transaction, and returned normally. Nothing was committed —
|
|
8821
|
+
* not even the statements that succeeded before it.
|
|
8822
|
+
*
|
|
8823
|
+
* Raised instead of resolving, because a resolved `transactional()` is read as
|
|
8824
|
+
* "these writes are in the table", and here none are. The swallowed failure is
|
|
8825
|
+
* the `cause`.
|
|
8826
|
+
*/
|
|
8827
|
+
export declare class TransactionAbortedError extends Error {
|
|
8828
|
+
readonly swallowed: unknown;
|
|
8829
|
+
readonly _tag: "TransactionAborted";
|
|
8830
|
+
constructor(label: string, swallowed: unknown);
|
|
8831
|
+
}
|
|
8832
|
+
|
|
8833
|
+
/**
|
|
8834
|
+
* Records, for one transactional view, the first statement failure the engine
|
|
8835
|
+
* made fatal to the transaction — the value `abortedBy()` reports.
|
|
8836
|
+
*
|
|
8837
|
+
* ONE implementation for every dialect view; the dialect supplies only
|
|
8838
|
+
* `isFatal`, because which failures end a transaction IS the dialect's (postgres:
|
|
8839
|
+
* any statement the server rejected; InnoDB: a deadlock, which rolls the whole
|
|
8840
|
+
* transaction back, while most other errors roll back only the statement).
|
|
8841
|
+
*
|
|
8842
|
+
* A failure inside `savepoint()` is not recorded: the savepoint's own rollback
|
|
8843
|
+
* leaves the transaction usable, which is the entire point of taking one. A
|
|
8844
|
+
* failure of that rollback IS recorded — the transaction is then unusable.
|
|
8845
|
+
*/
|
|
8846
|
+
export declare interface TransactionAbortTracker {
|
|
8847
|
+
/**
|
|
8848
|
+
* Send one statement — given as a THUNK, so that after a fatal failure it is
|
|
8849
|
+
* not sent at all (a promise would already be on the wire). Records a fatal
|
|
8850
|
+
* rejection outside a savepoint.
|
|
8851
|
+
*/
|
|
8852
|
+
track<T>(send: () => Promise<T>): Promise<T>;
|
|
8853
|
+
/** Run `fn` as a savepoint body: failures inside it are the savepoint's. */
|
|
8854
|
+
inSavepoint<A>(fn: () => Promise<A>): Promise<A>;
|
|
8855
|
+
/** Record a failure directly (a savepoint rollback that did not succeed). */
|
|
8856
|
+
record(error: unknown): void;
|
|
8857
|
+
abortedBy(): {
|
|
8858
|
+
readonly error: unknown;
|
|
8859
|
+
} | undefined;
|
|
8860
|
+
}
|
|
8861
|
+
|
|
8790
8862
|
/**
|
|
8791
8863
|
* A store's per-transaction `DataStore` view: buffers the ChangeEvents its
|
|
8792
8864
|
* writes produce and drains them to the parent emitter only once the
|
|
@@ -8794,6 +8866,21 @@ export declare const timestampMsOrNull: Schema.Schema<Date | null, number | null
|
|
|
8794
8866
|
*/
|
|
8795
8867
|
export declare interface TransactionalViewHandle {
|
|
8796
8868
|
commitEvents(): void;
|
|
8869
|
+
/**
|
|
8870
|
+
* The first statement failure the ENGINE took as fatal to this transaction,
|
|
8871
|
+
* when the caller caught it and carried on. Absent on a dialect where a failed
|
|
8872
|
+
* statement leaves the transaction usable (mysql, sqlite): there a caught
|
|
8873
|
+
* failure is an ordinary, committable outcome.
|
|
8874
|
+
*
|
|
8875
|
+
* Postgres is the dialect that needs it. A failed statement aborts the whole
|
|
8876
|
+
* transaction; every later statement fails with 25P02, and COMMIT is then
|
|
8877
|
+
* executed AS A ROLLBACK — without raising. Before this existed, a work
|
|
8878
|
+
* callback that caught one failure and returned normally made
|
|
8879
|
+
* `transactional()` resolve, and nothing it wrote was in the table.
|
|
8880
|
+
*/
|
|
8881
|
+
abortedBy?(): {
|
|
8882
|
+
readonly error: unknown;
|
|
8883
|
+
} | undefined;
|
|
8797
8884
|
}
|
|
8798
8885
|
|
|
8799
8886
|
/**
|