Skip to main content
Version: 0.17

Class: MemorySource<QO, TO, QB, TB, QRD, TRD>

Type parameters

NameType
QOextends RequestOptions = RecordSourceQueryOptions
TOextends RequestOptions = RequestOptions
QBRecordQueryBuilder
TBRecordTransformBuilder
QRDunknown
TRDextends RecordCacheUpdateDetails = RecordCacheUpdateDetails

Hierarchy

  • RecordSource<QO, TO, QB, TB>

  • RecordSyncable

  • RecordQueryable<QRD, QB, QO>

  • RecordUpdatable<TRD, TB, TO>

    MemorySource

Implements

  • RecordSyncable
  • RecordQueryable<QRD, QB, QO>
  • RecordUpdatable<TRD, TB, TO>
  • Resettable

Constructors

constructor

new MemorySource<QO, TO, QB, TB, QRD, TRD>(settings)

Type parameters

NameType
QOextends RequestOptions = RecordSourceQueryOptions
TOextends RequestOptions = RequestOptions
QBRecordQueryBuilder<string, RecordIdentity>
TBRecordTransformBuilder<string, RecordIdentity, UninitializedRecord>
QRDunknown
TRDextends RecordCacheUpdateDetails = RecordCacheUpdateDetails

Parameters

NameType
settingsMemorySourceSettings<QO, TO, QB, TB, QRD, TRD>

Inherited from

RecordSource<QO, TO, QB, TB>.constructor

Defined in

memory/src/memory-source.ts:103

Accessors

activated

get activated(): Promise<void>

Returns

Promise<void>

Inherited from

RecordSource.activated

Defined in

data/dist/modules/source.d.ts:54


base

get base(): undefined | MemorySource<QO, TO, QB, TB, QRD, TRD>

Returns

undefined | MemorySource<QO, TO, QB, TB, QRD, TRD>

Defined in

memory/src/memory-source.ts:151


bucket

get bucket(): undefined | Bucket<unknown>

Returns

undefined | Bucket<unknown>

Inherited from

RecordSource.bucket

Defined in

data/dist/modules/source.d.ts:37


cache

get cache(): MemoryCache<QO, TO, QB, TB, QRD, TRD>

Returns

MemoryCache<QO, TO, QB, TB, QRD, TRD>

Defined in

memory/src/memory-source.ts:147


defaultQueryOptions

get defaultQueryOptions(): undefined | DefaultRequestOptions<QO>

Returns

undefined | DefaultRequestOptions<QO>

Inherited from

RecordSource.defaultQueryOptions

Defined in

memory/src/memory-source.ts:477

set defaultQueryOptions(options): void

Parameters

NameType
optionsundefined | DefaultRequestOptions<QO>

Returns

void

Inherited from

RecordSource.defaultQueryOptions

Defined in

memory/src/memory-source.ts:481


defaultTransformOptions

get defaultTransformOptions(): undefined | DefaultRequestOptions<TO>

Returns

undefined | DefaultRequestOptions<TO>

Inherited from

RecordSource.defaultTransformOptions

Defined in

memory/src/memory-source.ts:485

set defaultTransformOptions(options): void

Parameters

NameType
optionsundefined | DefaultRequestOptions<TO>

Returns

void

Inherited from

RecordSource.defaultTransformOptions

Defined in

memory/src/memory-source.ts:489


forkPoint

get forkPoint(): undefined | string

Returns

undefined | string

Defined in

memory/src/memory-source.ts:155


keyMap

get keyMap(): undefined | RecordKeyMap

Returns

undefined | RecordKeyMap

Inherited from

RecordSource.keyMap

Defined in

records/dist/modules/record-source.d.ts:57


name

get name(): undefined | string

Returns

undefined | string

Inherited from

RecordSource.name

Defined in

data/dist/modules/source.d.ts:36


queryBuilder

get queryBuilder(): QB

Returns

QB

Inherited from

RecordSource.queryBuilder

Defined in

records/dist/modules/record-source.d.ts:59


requestQueue

get requestQueue(): TaskQueue<string, unknown, unknown, unknown>

Returns

TaskQueue<string, unknown, unknown, unknown>

Inherited from

RecordSource.requestQueue

Defined in

data/dist/modules/source.d.ts:39


schema

get schema(): RecordSchema

Returns

RecordSchema

Inherited from

RecordSource.schema

Defined in

records/dist/modules/record-source.d.ts:56


syncQueue

get syncQueue(): TaskQueue<string, unknown, unknown, unknown>

Returns

TaskQueue<string, unknown, unknown, unknown>

Inherited from

RecordSource.syncQueue

Defined in

data/dist/modules/source.d.ts:40


transformBuilder

get transformBuilder(): TB

Returns

TB

Inherited from

RecordSource.transformBuilder

Defined in

records/dist/modules/record-source.d.ts:60


transformLog

get transformLog(): Log

Returns

Log

Inherited from

RecordSource.transformLog

Defined in

data/dist/modules/source.d.ts:38


validatorFor

get validatorFor(): undefined | ValidatorForFn<StandardValidator | StandardRecordValidator>

Returns

undefined | ValidatorForFn<StandardValidator | StandardRecordValidator>

Inherited from

RecordSource.validatorFor

Defined in

records/dist/modules/record-source.d.ts:58

Methods

_query

_query(query, hints?): Promise<FullResponse<RecordQueryResult<InitializedRecord>, QRD, RecordOperation>>

Parameters

NameType
queryRecordQuery
hints?ResponseHints<RecordQueryResult<InitializedRecord>, QRD>

Returns

Promise<FullResponse<RecordQueryResult<InitializedRecord>, QRD, RecordOperation>>

Inherited from

RecordQueryable._query

Defined in

memory/src/memory-source.ts:224


_sync

_sync(transform): Promise<void>

Parameters

NameType
transformRecordTransform

Returns

Promise<void>

Inherited from

RecordSyncable._sync

Defined in

memory/src/memory-source.ts:167


_update

_update(transform, hints?): Promise<FullResponse<RecordTransformResult<InitializedRecord>, TRD, RecordOperation>>

Parameters

NameType
transformRecordTransform
hints?ResponseHints<RecordTransformResult<InitializedRecord>, TRD>

Returns

Promise<FullResponse<RecordTransformResult<InitializedRecord>, TRD, RecordOperation>>

Inherited from

RecordUpdatable._update

Defined in

memory/src/memory-source.ts:178


activate

activate(): Promise<void>

Returns

Promise<void>

Inherited from

RecordSource.activate

Defined in

data/dist/modules/source.d.ts:55


allTransforms

allTransforms(): RecordTransform[]

deprecated since v0.17, call getAllTransforms instead

Returns

RecordTransform[]

Defined in

memory/src/memory-source.ts:462


deactivate

deactivate(): Promise<void>

Returns

Promise<void>

Inherited from

RecordSource.deactivate

Defined in

data/dist/modules/source.d.ts:56


emit

emit(event, ...args): void

Parameters

NameType
eventEvent
...argsunknown[]

Returns

void

Inherited from

RecordSource.emit

Defined in

core/dist/modules/evented.d.ts:23


fork

fork(settings?): MemorySource<QO, TO, QB, TB, QRD, TRD>

Create a clone, or "fork", from a "base" source.

The forked source will have the same schema and keyMap as its base source. The forked source's cache will start with the same immutable document as the base source. Its contents and log will evolve independently.

Parameters

NameType
settingsPartial<MemorySourceSettings<QO, TO, QB, TB, QRD, TRD>>

Returns

MemorySource<QO, TO, QB, TB, QRD, TRD>

The forked source.

Defined in

memory/src/memory-source.ts:272


getAllTransforms

getAllTransforms(): RecordTransform[]

Returns all logged transforms.

Returns

RecordTransform[]

Defined in

memory/src/memory-source.ts:455


getInverseOperations

getInverseOperations(transformId): RecordOperation[]

Parameters

NameType
transformIdstring

Returns

RecordOperation[]

Defined in

memory/src/memory-source.ts:473


getQueryOptions

getQueryOptions(query, expression?): undefined | QO

Parameters

NameType
queryQuery<QueryExpression>
expression?QueryExpression

Returns

undefined | QO

Inherited from

RecordSource.getQueryOptions

Defined in

data/dist/modules/source.d.ts:47


getTransform

getTransform(transformId): RecordTransform

Parameters

NameType
transformIdstring

Returns

RecordTransform

Defined in

memory/src/memory-source.ts:469


getTransformOptions

getTransformOptions(transform, operation?): undefined | TO

Parameters

NameType
transformTransform<Operation>
operation?Operation

Returns

undefined | TO

Inherited from

RecordSource.getTransformOptions

Defined in

data/dist/modules/source.d.ts:48


getTransformsSince

getTransformsSince(transformId): RecordTransform[]

Returns all logged transforms since a particular transformId.

Parameters

NameType
transformIdstring

Returns

RecordTransform[]

Defined in

memory/src/memory-source.ts:436


listeners

listeners(event): Listener[]

Parameters

NameType
eventEvent

Returns

Listener[]

Inherited from

RecordSource.listeners

Defined in

core/dist/modules/evented.d.ts:24


merge

merge<RequestData>(forkedSource, options?): Promise<RequestData>

Merge transforms from a forked source back into a base source.

By default, all of the operations from all of the transforms in the forked source's history will be reduced into a single transform. A subset of operations can be selected by specifying the sinceTransformId option.

The coalesce option controls whether operations are coalesced into a minimal equivalent set before being reduced into a transform.

Type parameters

NameType
RequestDataextends RecordTransformResult<InitializedRecord> = RecordTransformResult<InitializedRecord>

Parameters

NameTypeDescription
forkedSourceMemorySource<QO, TO, QB, TB, QRD, TRD>The source to merge.
options?TO & { fullResponse?: false } & MemorySourceMergeOptionsMerge options

Returns

Promise<RequestData>

The result of calling update() with the forked transforms.

Defined in

memory/src/memory-source.ts:314

merge<RequestData>(forkedSource, options): Promise<FullResponse<RequestData, TRD, RecordOperation>>

Type parameters

NameType
RequestDataextends RecordTransformResult<InitializedRecord> = RecordTransformResult<InitializedRecord>

Parameters

NameType
forkedSourceMemorySource<QO, TO, QB, TB, QRD, TRD>
optionsTO & { fullResponse: true } & MemorySourceMergeOptions

Returns

Promise<FullResponse<RequestData, TRD, RecordOperation>>

Defined in

memory/src/memory-source.ts:318


off

off(event, listener?): void

Parameters

NameType
eventEvent
listener?Listener

Returns

void

Inherited from

RecordSource.off

Defined in

core/dist/modules/evented.d.ts:21


on

on(event, listener): () => void

Parameters

NameType
eventEvent
listenerListener

Returns

fn

▸ (): void

Returns

void

Inherited from

RecordSource.on

Defined in

core/dist/modules/evented.d.ts:20


one

one(event, listener): () => void

Parameters

NameType
eventEvent
listenerListener

Returns

fn

▸ (): void

Returns

void

Inherited from

RecordSource.one

Defined in

core/dist/modules/evented.d.ts:22


perform

perform(task): Promise<unknown>

Parameters

NameType
taskTask<string, unknown, unknown>

Returns

Promise<unknown>

Inherited from

RecordSource.perform

Defined in

data/dist/modules/source.d.ts:49


query

query<RequestData>(queryOrExpressions, options?, id?): Promise<RequestData>

Type parameters

NameType
RequestDataextends RecordQueryResult<InitializedRecord> = RecordQueryResult<InitializedRecord>

Parameters

NameType
queryOrExpressionsQueryOrExpressions<RecordQueryExpression, QB>
options?DefaultRequestOptions<QO>
id?string

Returns

Promise<RequestData>

Inherited from

RecordQueryable.query

Defined in

data/dist/modules/queryable.d.ts:7

query<RequestData, RequestDetails, RequestOperation>(queryOrExpressions, options, id?): Promise<FullResponse<RequestData, RequestDetails, RequestOperation>>

Type parameters

NameType
RequestDataextends RecordQueryResult<InitializedRecord> = RecordQueryResult<InitializedRecord>
RequestDetailsQRD
RequestOperationextends RecordOperation = RecordOperation

Parameters

NameType
queryOrExpressionsQueryOrExpressions<RecordQueryExpression, QB>
optionsFullRequestOptions<QO>
id?string

Returns

Promise<FullResponse<RequestData, RequestDetails, RequestOperation>>

Inherited from

RecordQueryable.query

Defined in

data/dist/modules/queryable.d.ts:8


rebase

rebase(): void

Rebase works similarly to a git rebase:

After a source is forked, there is a parent- and a child-source. Both may be updated with transforms. When childSource.rebase() is called, the child source's state will be reset to match the current state of its parent, and then any locally made transforms will be replayed on the child source.

Returns

void

Defined in

memory/src/memory-source.ts:389


reset

reset(): Promise<void>

Reset the source's cache and transform log to its initial state, which will be either empty or a matching its base, if it has one.

Returns

Promise<void>

Defined in

memory/src/memory-source.ts:412


rollback

rollback(transformId, relativePosition?): Promise<void>

Rolls back the source to a particular transformId.

relativePosition can be a positive or negative integer used to specify a position relative to transformId.

Parameters

NameTypeDefault value
transformIdstringundefined
relativePositionnumber0

Returns

Promise<void>

Defined in

memory/src/memory-source.ts:429


sync

sync(transformOrTransforms): Promise<void>

The sync method to a source. This method accepts a Transform or array of Transforms as an argument and applies it to the source.

Parameters

NameType
transformOrTransformsTransform<RecordOperation> | Transform<RecordOperation>[] | TransformBuilderFunc<RecordOperation, RecordTransformBuilder<string, RecordIdentity, UninitializedRecord>>

Returns

Promise<void>

Inherited from

RecordSyncable.sync

Defined in

data/dist/modules/source-interfaces/syncable.d.ts:17


transformed

transformed(transforms): Promise<void>

Notifies listeners that this source has been transformed by emitting the transform event.

Resolves when any promises returned to event listeners are resolved.

Also, adds an entry to the Source's transformLog for each transform.

Parameters

NameType
transformsTransform<Operation>[]

Returns

Promise<void>

Inherited from

RecordSource.transformed

Defined in

data/dist/modules/source.d.ts:65


transformsSince

transformsSince(transformId): RecordTransform[]

deprecated since v0.17, call getTransformsSince instead

Parameters

NameType
transformIdstring

Returns

RecordTransform[]

Defined in

memory/src/memory-source.ts:445


update

update<RequestData>(transformOrOperations, options?, id?): Promise<RequestData>

Type parameters

NameType
RequestDataextends RecordTransformResult<InitializedRecord> = RecordTransformResult<InitializedRecord>

Parameters

NameType
transformOrOperationsTransformOrOperations<RecordOperation, TB>
options?DefaultRequestOptions<TO>
id?string

Returns

Promise<RequestData>

Inherited from

RecordUpdatable.update

Defined in

data/dist/modules/updatable.d.ts:6

update<RequestData, RequestDetails, RequestOperation>(transformOrOperations, options, id?): Promise<FullResponse<RequestData, RequestDetails, RequestOperation>>

Type parameters

NameType
RequestDataextends RecordTransformResult<InitializedRecord> = RecordTransformResult<InitializedRecord>
RequestDetailsextends RecordCacheUpdateDetails = TRD
RequestOperationextends RecordOperation = RecordOperation

Parameters

NameType
transformOrOperationsTransformOrOperations<RecordOperation, TB>
optionsFullRequestOptions<TO>
id?string

Returns

Promise<FullResponse<RequestData, RequestDetails, RequestOperation>>

Inherited from

RecordUpdatable.update

Defined in

data/dist/modules/updatable.d.ts:7


upgrade

upgrade(): Promise<void>

Returns

Promise<void>

Inherited from

RecordSource.upgrade

Defined in

memory/src/memory-source.ts:159