Saves JSON-able objects of type T as special Matrix.org rooms identified by stateType and stateKey.

See also MemoryRepository

Type Parameters

Hierarchy

  • MatrixCrudRepository

Implements

Constructors

  • Creates an instance of MatrixCrudRepository.

    Type Parameters

    Parameters

    • client: SimpleMatrixClient

      Use SimpleMatrixClient.login(user, pw) : Promise<SimpleMatrixClient> to get a client instance which has been authenticated.

    • stateType: string

      The MatrixType for this type of resource. Use matrix-style namespace syntax, eg. com.example.foo.dto.

    • stateKey: string = undefined

      Optional. The state key, defaults to ''.

    • serviceAccount: SimpleMatrixClient = undefined

      Optional. If defined, this service account user will be joined to any created rooms and removed from them when resoure-room is destroyed.

    • deletedType: string = undefined

      Optional. The state event type to add to any resource which is deleted. Defaults to MatrixType.FI_NOR_DELETED. NOTE! This only has partial support. Filtering for example does not support it yet.

    • deletedKey: string = undefined

      Optional. The state key for deletedType, defaults to ''.

    • allowedGroups: readonly string[] = undefined

      Optional. List of Matrix rooms who's members will be able to access any resources (eg. rooms) created in this repository without an invite.

    • allowedEvents: readonly string[] = undefined

      Optional. List of allowed event IDs in the room.

    • isT: StoredRepositoryItemTestCallback = undefined

      Optional. Test function to check if the type really is T.

    • tName: string = undefined

      Optional. The name of the T type for debugging purposes. Defaults to "T".

    • explainT: StoredRepositoryItemExplainCallback = undefined

      Optional. Function to explain if isT fails

    Returns MatrixCrudRepository<T>

Properties

_allowedEvents: readonly string[]
_allowedGroups: readonly string[]
_deletedKey: string
_deletedType: string
_serviceAccount: SimpleMatrixClient
_stateKey: string
_stateType: MatrixType
_tName: string

Methods

  • Removes a resource by id from repository.

    This will make the client leave & forget the Matrix room for this resource.

    If the service account is defined, it will also make the service account to leave & forget the room.

    FIXME

    Make the client and/or service account kick every other user out of the room also.

    Returns

    The resource with deleted property as false

    Parameters

    • id: string

      The ID of the resource to delete. This is a Matrix room ID.

    Returns Promise<RepositoryEntry<T>>

  • Search a resource from the repository with this ID.

    Returns

    Promise of the latest resource with this ID, if it's defined, otherwise undefined.

    Parameters

    • id: string

      The ID of the resource. It's also a Matrix Room ID.

    • Optional includeMembers: boolean

      Include list of members who have access to this item.

    Returns Promise<RepositoryEntry<T>>

  • Returns one resource (eg. Matrix room) which have this property defined in their state.

    If no resource found, returns undefined.

    Throws

    TypeError if multiple values found

    Parameters

    • propertyName: string

      This may also be a path to value inside the model, eg. user.id to match {user: {id: 123}}.

    • propertyValue: any

      The value to find

    Returns Promise<RepositoryEntry<T>>

  • Returns all resources (eg. Matrix rooms) which have this property defined in their state.

    Returns

    Array of resources

    Parameters

    • propertyName: string

      This may also be a path to value inside the model, eg. user.id to match {user: {id: 123}}.

    • propertyValue: any

      The value to find

    Returns Promise<readonly RepositoryEntry<T>[]>

Generated using TypeDoc