Skip to content

API reference / @docmentis/udoc-server / DirectoryDocumentStore

Class: DirectoryDocumentStore ​

A DocumentStore over a directory: one directory per document, named by its id, holding its original, its checkpoints and its edit log.

Implements ​

Constructors ​

Constructor ​

ts
new DirectoryDocumentStore(directory): DirectoryDocumentStore;

Parameters ​

ParameterType
directorystring

Methods ​

put() ​

ts
put(id, document): Promise<void>;

Keep a new document as id. Refused when id is already kept.

Parameters ​

ParameterType
idstring
documentKeptDocument

Implementation of ​

DocumentStore.put


getOriginal() ​

ts
getOriginal(id): Promise<Original | undefined>;

Document id's original, or undefined when nothing is kept.

Parameters ​

ParameterType
idstring

Implementation of ​

DocumentStore.getOriginal


getCheckpoint() ​

ts
getCheckpoint(id): Promise<Uint8Array<ArrayBufferLike> | undefined>;

Document id's latest checkpoint, or undefined when nothing is kept.

Parameters ​

ParameterType
idstring

Implementation of ​

DocumentStore.getCheckpoint


putCheckpoint() ​

ts
putCheckpoint(
   id, 
   version, 
   checkpoint
): Promise<void>;

Keep checkpoint, the udoc package of document id's checkpoint version, beside the earlier ones, as its latest; then forget each opaque part and blob kept beside them that it holds. Refused when no checkpoint is kept as id, or version is kept already.

Parameters ​

ParameterType
idstring
versionnumber
checkpointUint8Array

Implementation of ​

DocumentStore.putCheckpoint


getDescription() ​

ts
getDescription(id): Promise<PackageDescription | undefined>;

Document id's package description, from its latest checkpoint, or undefined when it has none.

Parameters ​

ParameterType
idstring

Implementation of ​

DocumentStore.getDescription


getPart() ​

ts
getPart(
   id, 
   kinds, 
   partId
): Promise<Uint8Array<ArrayBufferLike> | undefined>;

One part of document id, as its JSON deflated — raw DEFLATE (RFC 1951) — by its route: kinds, its kind in kebab-case and plural, and partId, its id's key. Its latest checkpoint's, or an opaque part an edit brought, kept beside the checkpoints, or, held by neither, the newest earlier checkpoint's. undefined when there is no such part, or no checkpoint.

Parameters ​

ParameterType
idstring
kindsstring
partIdstring

Implementation of ​

DocumentStore.getPart


getBlob() ​

ts
getBlob(id, key): Promise<Uint8Array<ArrayBufferLike> | undefined>;

One blob of document id, deflated, by its key — found as a part is — or undefined when it has none.

Parameters ​

ParameterType
idstring
keystring

Implementation of ​

DocumentStore.getBlob


putOpaqueParts() ​

ts
putOpaqueParts(id, parts): Promise<void>;

Keep every part and blob of parts — a client's opaque parts, a zip in a package's own layout — beside document id's checkpoints, by route. What is kept already stays as it was. Refused when nothing is kept as id.

Parameters ​

ParameterType
idstring
partsUint8Array

Implementation of ​

DocumentStore.putOpaqueParts


getLog() ​

ts
getLog(id): Promise<Uint8Array<ArrayBufferLike> | undefined>;

Document id's edit log, or undefined when it has none: the one kept, or, for a document checkpointed before any edit was kept, its latest checkpoint's own.

Parameters ​

ParameterType
idstring

Implementation of ​

DocumentStore.getLog


putLog() ​

ts
putLog(id, log): Promise<void>;

Keep log as document id's edit log, in place of the one kept — whole or not at all. Refused when nothing is kept as id.

Parameters ​

ParameterType
idstring
logUint8Array

Implementation of ​

DocumentStore.putLog


delete() ​

ts
delete(id): Promise<boolean>;

Forget document id; answers whether anything was kept.

Parameters ​

ParameterType
idstring

Implementation of ​

DocumentStore.delete