import { IIterable , IIterator } from '@lumino/algorithm' ; import { IDisposable } from '@lumino/disposable' ; import { ISignal } from '@lumino/signaling' ; import { Record , Schema } from '@lumino/datastore' ; /**
 * A schemaed datastore interface.
 */ export interface IDatastore extends IDisposable , IIterable < ITable < Schema > > { /**
     * A signal emitted when changes are made to the store.
     *
     * #### Notes
     * This signal is emitted either at the end of a local mutation,
     * or after a remote mutation has been applied. The storeId can
     * be used to determine its source.
     *
     * The payload represents the set of local changes that were made
     * to bring the store to its current state.
     */ readonly changed : ISignal < IDatastore , IDatastore . IChangedArgs > ; /**
     * The unique id of the store.
     *
     * #### Notes
     * The id is unique among all other collaborating peers.
     */ readonly id : number ; /**
     * Whether a transaction is currently in progress.
     */ readonly inTransaction : boolean ; /**
     * The current version of the datastore.
     *
     * #### Notes
     * This version is automatically increased for each transaction
     * to the store. However, it might not increase linearly (i.e.
     * it might make jumps).
     */ readonly version : number ; returns iter ( ) : IIterator < ITable < Schema > > ; param schema returns throws get < S extends Schema > ( schema ) : ITable < S > ; returns throws beginTransaction ( ) : string ; /**
     * Completes a transaction.
     *
     * #### Notes
     * This completes a transaction previously started with
     * `beginTransaction`. If a change has occurred, the
     * `changed` signal will be emitted.
     */ endTransaction ( ) : void ; param transactionId returns throws undo ( transactionId ) : Promise < void > ; param transactionId returns throws redo ( transactionId ) : Promise < void > ; returns toString ( ) : string ; } export namespace IDatastore { /**
     * A type alias for kinds of transactions.
     */ export type TransactionType = 'transaction' | 'undo' | 'redo' ; /**
     * The arguments object for the store `changed` signal.
     */ export interface IChangedArgs { /**
         * Whether the change was generated by transaction, undo, or redo.
         */ readonly type : TransactionType ; /**
         * The transaction id associated with the change.
         */ readonly transactionId : string ; /**
         * The id of the store responsible for the change.
         */ readonly storeId : number ; /**
         * A mapping of schema id to table change set.
         */ readonly change : Change ; } /**
     * A type alias for a store change.
     */ export type Change = { readonly [ schemaId ] : ITable . Change < Schema > ; } ; } /**
 * A datastore object which holds a collection of records.
 */ export interface ITable < S extends Schema > extends IIterable < Record < S > > { /**
     * The schema for the table.
     */ readonly schema : S ; /**
     * Whether the table is empty.
     */ readonly isEmpty : boolean ; /**
     * The size of the table.
     */ readonly size : number ; returns iter ( ) : IIterator < Record < S > > ; param id returns has ( id ) : boolean ; param id returns get ( id ) : Record < S > | undefined ; param data update ( data ) : void ; } /**
 * The namespace for the `Table` class statics.
 */ export namespace ITable { /**
     * A type alias for the table update type.
     */ export type Update < S extends Schema > = { readonly [ recordId ] : Record . Update < S > ; } ; /**
     * A type alias for the table change type.
     */ export type Change < S extends Schema > = { readonly [ recordId ] : Record . Change < S > ; } ; /**
     * A type alias for the table patch type.
     */ export type Patch < S extends Schema > = { readonly [ recordId ] : Record . Patch < S > ; } ; }