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
new DocumentRecord(
_document,
workspaceId,
services,
resolveValidationContext,
linkedDocuments?
): DocumentRecord;Defined in: application/services/records/document-record.ts:89
Parameters
| Parameter | Type | Description |
|---|---|---|
_document | Document | Document entity to wrap. |
workspaceId | string | Id of the workspace that owns the document. |
services | ActiveRecordServices | Application 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
readonly workspaceId: string;Defined in: application/services/records/document-record.ts:91
Id of the workspace that owns the document.
Implementation of
Accessors
data
Get Signature
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
Set Signature
set data(value): void;Defined in: application/services/records/document-record.ts:113
Parameters
| Parameter | Type |
|---|---|
value | DocumentData |
Returns
void
Implementation of
id
Get Signature
get id(): string;Defined in: application/services/records/document-record.ts:99
Document id.
Returns
string
Implementation of
profileId
Get Signature
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
title
Get Signature
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
set title(value): void;Defined in: application/services/records/document-record.ts:122
Parameters
| Parameter | Type |
|---|---|
value | string | undefined |
Returns
void
Implementation of
Methods
exportHtml()
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
| Parameter | Type |
|---|---|
options? | any |
Returns
Promise<string>
Implementation of
exportJsonLd()
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
| Parameter | Type |
|---|---|
options? | any |
Returns
Promise<object>
Implementation of
DocumentRecordApi.exportJsonLd
exportMarkdown()
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
| Parameter | Type |
|---|---|
options? | any |
Returns
Promise<string>
Implementation of
DocumentRecordApi.exportMarkdown
exportPdfBlob()
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
| Parameter | Type |
|---|---|
options? | any |
Returns
Promise<Blob>
Implementation of
DocumentRecordApi.exportPdfBlob
getQAScore()
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
patchByPath()
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
| Parameter | Type |
|---|---|
path | (string | number)[] |
value | any |
Returns
Promise<DocumentRecord>
Implementation of
refresh()
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
setField()
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
| Parameter | Type |
|---|---|
fieldPath | string |
value | FieldValue[] |
Returns
Promise<DocumentRecord>
Implementation of
toInstance()
toInstance(): DocumentInstance;Defined in: application/services/records/document-record.ts:254
Return the wrapped document as a plain DocumentInstance.
Returns
Implementation of
validate()
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>