Skip to content

Class: DocumentRecord ​

Defined in: application/services/records/document-record.ts:82

Active-record wrapper around a Document. Mutating methods call the document service and replace the wrapped document with the returned one; export methods use the document's profile and the workspace type library.

Implements ​

Constructors ​

Constructor ​

ts
new DocumentRecord(
   _document, 
   workspaceId, 
   services, 
   resolveValidationContext, 
   linkedDocuments?
): DocumentRecord;

Defined in: application/services/records/document-record.ts:89

Parameters ​

ParameterTypeDescription
_documentDocumentDocument entity to wrap.
workspaceIdstringId of the workspace that owns the document.
servicesActiveRecordServicesApplication services to delegate to.
resolveValidationContext() => Promise<{ profile: DocumentProfile; typeLibrary: TypeLibrary; }>Returns the document's profile and the workspace type library.
linkedDocuments?() => object[]The other documents a JSON-LD export may embed when it links to them (the workspace).

Returns ​

DocumentRecord

Properties ​

workspaceId ​

ts
readonly workspaceId: string;

Defined in: application/services/records/document-record.ts:91

Id of the workspace that owns the document.

Implementation of ​

DocumentRecordApi.workspaceId

Accessors ​

data ​

Get Signature ​

ts
get data(): DocumentData;

Defined in: application/services/records/document-record.ts:109

Document data. Setting it changes the wrapped entity only; it is not persisted.

Returns ​

DocumentData

Set Signature ​

ts
set data(value): void;

Defined in: application/services/records/document-record.ts:113

Parameters ​
ParameterType
valueDocumentData
Returns ​

void

Implementation of ​

DocumentRecordApi.data


id ​

Get Signature ​

ts
get id(): string;

Defined in: application/services/records/document-record.ts:99

Document id.

Returns ​

string

Implementation of ​

DocumentRecordApi.id


profileId ​

Get Signature ​

ts
get profileId(): string;

Defined in: application/services/records/document-record.ts:104

Id of the profile the document was created from.

Returns ​

string

Implementation of ​

DocumentRecordApi.profileId


title ​

Get Signature ​

ts
get title(): string | undefined;

Defined in: application/services/records/document-record.ts:118

Document title. Setting it changes the wrapped entity only; it is not persisted.

Returns ​

string | undefined

Set Signature ​

ts
set title(value): void;

Defined in: application/services/records/document-record.ts:122

Parameters ​
ParameterType
valuestring | undefined
Returns ​

void

Implementation of ​

DocumentRecordApi.title

Methods ​

exportHtml() ​

ts
exportHtml(options?): Promise<string>;

Defined in: application/services/records/document-record.ts:219

Render the document as HTML, using the same defaults as DocumentRecord.exportMarkdown plus the transformation service's default CSS.

Parameters ​

ParameterType
options?any

Returns ​

Promise<string>

Implementation of ​

DocumentRecordApi.exportHtml


exportJsonLd() ​

ts
exportJsonLd(options?): Promise<object>;

Defined in: application/services/records/document-record.ts:243

Convert the document data to JSON-LD using its profile id. Links to other documents of the workspace embed their description (pass linkedDocuments: null to export links as IRIs only).

Parameters ​

ParameterType
options?any

Returns ​

Promise<object>

Implementation of ​

DocumentRecordApi.exportJsonLd


exportMarkdown() ​

ts
exportMarkdown(options?): Promise<string>;

Defined in: application/services/records/document-record.ts:204

Render the document as Markdown. Profile schema, field labels, type library and a title are filled in; options override them, except that an empty options.title falls back to a title derived from the data (title, name or label, preferring options.language, then English).

Parameters ​

ParameterType
options?any

Returns ​

Promise<string>

Implementation of ​

DocumentRecordApi.exportMarkdown


exportPdfBlob() ​

ts
exportPdfBlob(options?): Promise<Blob>;

Defined in: application/services/records/document-record.ts:234

Render the document to HTML with DocumentRecord.exportHtml and convert it to a PDF blob.

Parameters ​

ParameterType
options?any

Returns ​

Promise<Blob>

Implementation of ​

DocumentRecordApi.exportPdfBlob


getQAScore() ​

ts
getQAScore(): Promise<number>;

Defined in: application/services/records/document-record.ts:181

Return the QA score computed by the document service.

Returns ​

Promise<number>

Implementation of ​

DocumentRecordApi.getQAScore


patchByPath() ​

ts
patchByPath(path, value): Promise<DocumentRecord>;

Defined in: application/services/records/document-record.ts:155

Set the value at a nested data path through the document service.

Parameters ​

ParameterType
path(string | number)[]
valueany

Returns ​

Promise<DocumentRecord>

Implementation of ​

DocumentRecordApi.patchByPath


refresh() ​

ts
refresh(): Promise<DocumentRecord>;

Defined in: application/services/records/document-record.ts:130

Reload the document from the document service.

Returns ​

Promise<DocumentRecord>

Throws ​

Error when the document no longer exists.

Implementation of ​

DocumentRecordApi.refresh


setField() ​

ts
setField(fieldPath, value): Promise<DocumentRecord>;

Defined in: application/services/records/document-record.ts:142

Replace the values of a top-level field through the document service.

Parameters ​

ParameterType
fieldPathstring
valueFieldValue[]

Returns ​

Promise<DocumentRecord>

Implementation of ​

DocumentRecordApi.setField


toInstance() ​

ts
toInstance(): DocumentInstance;

Defined in: application/services/records/document-record.ts:254

Return the wrapped document as a plain DocumentInstance.

Returns ​

DocumentInstance

Implementation of ​

DocumentRecordApi.toInstance


validate() ​

ts
validate(): Promise<ValidationResult>;

Defined in: application/services/records/document-record.ts:168

Validate the stored document against its profile and the workspace type library.

Returns ​

Promise<ValidationResult>

Implementation of ​

DocumentRecordApi.validate