@@ -56,18 +56,6 @@ export type Read = IAttestation;
5656 */
5757export type Write = IAttestation ;
5858
59- export interface IStorageTransactionInvariant {
60- read ?: IStorageInvariant ;
61- write ?: IStorageInvariant ;
62- }
63-
64- export interface IStorageTransactionLog {
65- get ( address : IMemorySpaceAddress ) : IStorageTransactionInvariant ;
66- addRead ( read : IStorageInvariant ) : void ;
67- addWrite ( write : IStorageInvariant ) : void ;
68- [ Symbol . iterator ] ( ) : Iterator < IStorageTransactionInvariant > ;
69- }
70-
7159// This type is used to tag a document with any important metadata.
7260// Currently, the only supported type is the classification.
7361export type Labels = {
@@ -371,20 +359,15 @@ export interface IMemoryChange {
371359 after : JSONValue | undefined ;
372360}
373361
374- export type IStorageTransactionProgress = Variant < {
375- open : IStorageTransactionLog ;
376- pending : IStorageTransactionLog ;
377- done : IStorageTransactionLog ;
378- } > ;
379- export type StorageTransactionStatus = Result <
380- IStorageTransactionState ,
381- StorageTransactionFailed
382- > ;
383-
384- export type IStorageTransactionState =
362+ export type StorageTransactionStatus =
385363 | { status : "ready" ; journal : ITransactionJournal }
386364 | { status : "pending" ; journal : ITransactionJournal }
387- | { status : "done" ; journal : ITransactionJournal } ;
365+ | { status : "done" ; journal : ITransactionJournal }
366+ | {
367+ status : "error" ;
368+ journal : ITransactionJournal ;
369+ error : StorageTransactionFailed ;
370+ } ;
388371
389372/**
390373 * Representation of a storage transaction, which can be used to query facts and
@@ -400,19 +383,22 @@ export type IStorageTransactionState =
400383 */
401384export interface IStorageTransaction {
402385 /**
403- * Describes current status of the transaction. If transaction has failed
404- * or was cancelled result will be an error with a corresponding error variant.
405- * If transaction is being built it will have `open` status, if commit was
406- * called but promise has not resolved yet it will be `pending`. If commit
407- * successfully completed it will be `done`.
408- *
409- * Please note that if storage was updated since transaction was created such
410- * that any of the invariants have changed status will be change to
411- * `IStorageConsistencyError` even though transaction has not being commited.
412- * This allows transactor to cancel and recreate transaction with a current
413- * state without having to build up a whole transaction and commiting it.
386+ * The transaction journal containing all read and write activities.
387+ * Provides access to transaction operations and dependency tracking.
388+ */
389+ readonly journal : ITransactionJournal ;
390+
391+ /**
392+ * Describes current status of the transaction. Returns a union type with
393+ * status field indicating the current state:
394+ * - `"ready"`: Transaction is being built and ready for operations
395+ * - `"pending"`: Commit was called but promise has not resolved yet
396+ * - `"done"`: Commit successfully completed
397+ * - `"error"`: Transaction has failed or was cancelled, includes error details
398+
399+ * Each status variant includes a `journal` field with transaction operations.
414400 */
415- // status(): StorageTransactionStatus;
401+ status ( ) : StorageTransactionStatus ;
416402
417403 /**
418404 * Helper that is the same as `reader().read()` but more convenient, as it
@@ -495,21 +481,6 @@ export interface IStorageTransaction {
495481}
496482
497483export interface IExtendedStorageTransaction extends IStorageTransaction {
498- /**
499- * Describes current status of the transaction. If transaction has failed
500- * or was cancelled result will be an error with a corresponding error variant.
501- * If transaction is being built it will have `open` status, if commit was
502- * called but promise has not resolved yet it will be `pending`. If commit
503- * successfully completed it will be `done`.
504- *
505- * Please note that if storage was updated since transaction was created such
506- * that any of the invariants have changed status will be change to
507- * `IStorageConsistencyError` even though transaction has not being commited.
508- * This allows transactor to cancel and recreate transaction with a current
509- * state without having to build up a whole transaction and commiting it.
510- */
511- status ( ) : Result < IStorageTransactionProgress , StorageTransactionFailed > ;
512-
513484 /**
514485 * Reads a value from a (local) memory address and throws on error, except for
515486 * `NotFoundError` which is returned as undefined.
@@ -556,19 +527,6 @@ export interface IExtendedStorageTransaction extends IStorageTransaction {
556527 value : JSONValue | undefined ,
557528 ) : void ;
558529
559- /**
560- * Returns the log of the transaction.
561- *
562- * The log is a list of changes that have been made to the transaction.
563- * It is used to track the dependencies of the transaction.
564- *
565- * If the transaction is aborted, the log reflects the attempted reads and
566- * writes. If the transaction is committed, the log reflects the actual reads
567- * and writes.
568- *
569- * @deprecated
570- */
571- log ( ) : IStorageTransactionLog ;
572530}
573531
574532export interface ITransactionReader {
@@ -842,32 +800,6 @@ export interface ITransactionJournal {
842800
843801 novelty ( space : MemorySpace ) : Iterable < IAttestation > ;
844802 history ( space : MemorySpace ) : Iterable < IAttestation > ;
845-
846- reader (
847- space : MemorySpace ,
848- ) : Result < ITransactionReader , InactiveTransactionError > ;
849-
850- writer (
851- space : MemorySpace ,
852- ) : Result < ITransactionWriter , InactiveTransactionError > ;
853-
854- /**
855- * Closes underlying transaction, making it non-editable going forward. Any
856- * attempts to edit it will fail.
857- */
858- close ( ) : Result < Map < MemorySpace , ITransaction > , InactiveTransactionError > ;
859-
860- /**
861- * Aborts underlying transaction, making it non-editable going forward. Any
862- * attempts to edit it will fail.
863- */
864- abort ( reason ?: unknown ) : Result < Unit , InactiveTransactionError > ;
865- }
866-
867- export interface EditableJournal {
868- activity ( ) : Iterable < Activity > ;
869- novelty : Iterable < IAttestation > ;
870- history ( ) : Iterable < IAttestation > ;
871803}
872804
873805export interface ITransaction {
@@ -929,8 +861,3 @@ export interface IAttestation {
929861 readonly address : IMemoryAddress ;
930862 readonly value ?: JSONValue ;
931863}
932-
933- export interface IStorageInvariant {
934- readonly address : IMemorySpaceAddress ;
935- readonly value ?: JSONValue ;
936- }
0 commit comments