[]
Provides document services for collaborative operational transformation.
Name | Description |
---|---|
S |
The type of snapshot data. |
T |
The type of operation data. |
• new DocumentServices<S
, T
>(config?
)
Name |
---|
S |
T |
Name | Type |
---|---|
config? |
IDocConfig <S , T > |
• db: IDatabaseAdapter
<S
, T
>
The database adapter for storing document data.
template
The type of snapshot data.
template
The type of operation data.
• Optional
maxSubmitRetries: number
The maximum number of retries for submitting an operation.
default
undefined - No retry limit.
• milestoneDb: IMilestoneDatabaseAdapter
<S
>
The milestone database adapter for snapshot milestones.
template
The type of snapshot data.
• submitSnapshotBatchSize: number
The batch size for submitting snapshots.
default
100
▸ fetch(id
, context?
): Promise
<ISnapshot
<S
>>
Fetches the latest snapshot of a document.
Name | Type | Description |
---|---|---|
id |
string |
The ID of the document. |
context? |
IContext |
- |
Promise
<ISnapshot
<S
>>
A promise resolving to the document snapshot.
▸ fetchHistorySnapshot(id
, version?
, context?
): Promise
<ISnapshot
<S
>>
Fetches a historical snapshot of a document by version.
Name | Type | Description |
---|---|---|
id |
string |
The ID of the document. |
version? |
number |
- |
context? |
IContext |
- |
Promise
<ISnapshot
<S
>>
A promise resolving to the historical snapshot.
▸ getOps(id
, from
, to?
, context?
): Promise
<IOp
<T
>[]>
Retrieves operations between two versions (inclusive of 'from', exclusive of 'to').
Name | Type | Description |
---|---|---|
id |
string |
The ID of the document. |
from |
number |
The starting version. |
to? |
number |
- |
context? |
IContext |
- |
Promise
<IOp
<T
>[]>
A promise resolving to an array of operations.
▸ on<K
>(hookName
, hook
): void
Registers a hook for a specific event in the document services.
Name | Type | Description |
---|---|---|
K |
extends keyof IDocHookContext |
The type of the hook name, extending keyof IDocHookContext. |
Name | Type | Description |
---|---|---|
hookName |
K |
The name of the hook to register. |
hook |
IHook <IDocHookContext [K ]> |
The hook to register. |
void
▸ submit(id
, op
, context?
): Promise
<IOp
<T
>[]>
Submits an operation to the document (must include an , , or field).
Name | Type | Description |
---|---|---|
id |
string |
The ID of the document. |
op |
IOp <T > |
The operation to submit. |
context? |
IContext |
- |
Promise
<IOp
<T
>[]>
A promise resolving to the resulting operations.
▸ use<K
>(action
, middleware
): void
Registers a middleware for a specific action in the document services.
Name | Type | Description |
---|---|---|
K |
extends keyof IDocMiddlewareContext <S , T > |
The type of the action name, extending keyof IDocMiddlewareContext<S, T>. |
Name | Type | Description |
---|---|---|
action |
K |
The name of the action to associate with the middleware. |
middleware |
IMiddleware <IDocMiddlewareContext <S , T >[K ]> |
The middleware to register. |
void