Options
Menu

Interface IModelStore

IModelStore defines the methods for storing and processing Realtime Models when offline.

Hierarchy

  • IModelStore

Index

Methods

claimValueIdPrefix

  • claimValueIdPrefix(modelId: string): Promise<{ increment: number; prefix: string }>
  • Gets and increments the value id prefix for a given model.

    Parameters

    • modelId: string

      The model id to get and increment the prefix for.

    Returns Promise<{ increment: number; prefix: string }>

    The claimed value id prefix.

completeModelCreation

  • completeModelCreation(modelId: string): Promise<void>
  • Indicates that the model creation process has completed. This can happen when online and the server responds, or as part of the resync process.

    Parameters

    • modelId: string

      The id of the model that was created.

    Returns Promise<void>

completeModelDeletion

  • completeModelDeletion(modelId: string): Promise<void>
  • Completes the deletion of the model by removing the deleted flag on the model.

    Parameters

    • modelId: string

      The id of the model to complete the deletion for.

    Returns Promise<void>

deleteModels

  • deleteModels(modelId: string[]): Promise<void>
  • Deletes the offline record of the model.

    Parameters

    • modelId: string[]

      The id of the model to delete.

    Returns Promise<void>

getAllModelMetaData

  • Gets all current model meta data records in the system.

    Returns Promise<IModelMetaData[]>

    All meta data records.

getModelCreationData

  • Gets the model creation data for a model that is currently in progress of creation, or null if a model with that id is not being created.

    Parameters

    • modelId: string

      The id of the model to get the creation data of.

    Returns Promise<IModelCreationData | null>

    The IModelCreationData for this model or null if it is not set.

getModelMetaData

  • Gets the model meta data for the specified model or null if meta data for the model does not exist.

    Parameters

    • modelId: string

      The id of the model to get the meta data for.

    Returns Promise<IModelMetaData | null>

    The model meta data for the model or null if no record exists.

getModelState

  • getModelState(modelId: string): Promise<IModelState | null>
  • Gets the current state for a locally available model. The method will return null for a model that does not exist or is not available locally.

    Parameters

    • modelId: string

      The id of the model to get the state of.

    Returns Promise<IModelState | null>

    The model state for the given model id, or null if the model is not available locally.

getModelsRequiringSync

  • Gets all model records for models that require synchronization to the server.

    Returns Promise<IModelMetaData[]>

    Model meta data for models that are deletes, created, or uncommitted.

getSubscribedModels

  • Gets a model records for models that are subscribed.

    Returns Promise<IModelMetaData[]>

    All meta data entries for models with the subscribed flag set.

initiateModelCreation

  • Begins the process of creating a model. This happens when the client creates the model, but before the server acknowledges the creation. This could be when the client is offline or even when online since the process with the server is async.

    Parameters

    Returns Promise<IModelMetaData>

    The meta data record created by this operation.

initiateModelDeletion

  • initiateModelDeletion(modelId: string): Promise<void>
  • Initiates the deletion of a model. This will remove the local model data but leave the model marked as deletion until the model deletion is confirmed.

    Parameters

    • modelId: string

      The id of the model to delete.

    Returns Promise<void>

modelMetaDataExists

  • modelMetaDataExists(modelId: string): Promise<boolean>
  • Determines if a model record exists for the specified model id. This does not imply that the model is subscribed, or available.

    Parameters

    • modelId: string

      The id of the model to check.

    Returns Promise<boolean>

    True if a meta data record exists; false otherwise.

processLocalOperation

  • Processes a new local operation. The modelId will be read from the local operation. The local operation operation will be stored. The model meta data will be updated to indicate that the model has uncommitted changes and the lastSequenceNumber number will be updated in the model details. The syncRequired flag will also be updated appropriately.

    Parameters

    Returns Promise<void>

processOfflineModelUpdate

  • processOfflineModelUpdate(update: IModelUpdate): Promise<void>
  • Updates the model state based on an update. Updates can either contain a data update or a permission update.

    Parameters

    Returns Promise<void>

processOperationAck

  • processOperationAck(modelId: string, seqNo: number, serverOp: IServerOperationData): Promise<void>
  • Processes a local operation acknowledgment from the server. This will remove the corresponding local operation and store the new server operation, which is essentially the version of the local operation that was (potentially) transformed such that it now represents the version of the local operation that the server executed. The uncommitted and syncRequired flags will be updated appropriately if this ack means that there are no more outstanding changes in the model.

    Parameters

    • modelId: string

      The id of the model that received the ack.

    • seqNo: number

      The sequence number of the local operation that was acknowledged.

    • serverOp: IServerOperationData

      The server operation to store in place of the local operation.

    Returns Promise<void>

processServerOperation

  • Processes a new server operation for a model. The modelId is inferred from the id in the serverOp. The localOps passed in are the new local operations that are the result of their transformation against the new server operation. Not the modelId of the localOperations must al match the modelId of the serverOp. This operation will update the modified time and version of the model meta data. The new server operation will be stored.

    Parameters

    Returns Promise<void>

setModelState

  • setModelState(modelState: IModelState): Promise<void>
  • Sets the models state. This will merge the state of the model with any existing meta data records for the model.

    Parameters

    Returns Promise<void>

snapshotModel

  • snapshotModel(modelId: string, version: number, sequenceNumber: number, modelData: IObjectValue): Promise<void>
  • Updates an offline models snapshot. This only applies to models that are locally available.

    Parameters

    • modelId: string

      The id of the model to set the snapshot for.

    • version: number

      The new version of the snapshot.

    • sequenceNumber: number

      The current sequence number for the local client.

    • modelData: IObjectValue

      The data of the model at the version.

    Returns Promise<void>

updateSubscriptions

  • updateSubscriptions(subscribe: string[], unsubscribe: string[]): Promise<void>
  • Adds and or removes subscriptions. If no model record exists it will be created. If the record exists, the subscribed flags will be modified. If a model is already subscribe and it is subscribed again, the operation will be a no-op for that model. If the model does not exist or is not subscribed and is asked to be unsubscribed it will be a no-op for that model.

    Parameters

    • subscribe: string[]

      The set of model ids to subscribe.

    • unsubscribe: string[]

      The set of model ids to unsubscribe.

    Returns Promise<void>