@twin.org/document-management-service 0.0.1-next.3 → 0.0.1-next.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.cjs
CHANGED
|
@@ -113,9 +113,9 @@ function generateRestRoutesDocumentManagement(baseRouteName, componentName) {
|
|
|
113
113
|
response: {
|
|
114
114
|
body: {
|
|
115
115
|
"@context": [
|
|
116
|
-
documentManagementModels.
|
|
117
|
-
documentManagementModels.
|
|
118
|
-
standardsSchemaOrg.
|
|
116
|
+
documentManagementModels.DocumentContexts.ContextRoot,
|
|
117
|
+
documentManagementModels.DocumentContexts.ContextRootCommon,
|
|
118
|
+
standardsSchemaOrg.SchemaOrgContexts.ContextRoot
|
|
119
119
|
],
|
|
120
120
|
type: documentManagementModels.DocumentTypes.Document,
|
|
121
121
|
id: "documents:705:2721000:rev-0",
|
|
@@ -147,9 +147,9 @@ function generateRestRoutesDocumentManagement(baseRouteName, componentName) {
|
|
|
147
147
|
response: {
|
|
148
148
|
body: {
|
|
149
149
|
"@context": [
|
|
150
|
-
documentManagementModels.
|
|
151
|
-
documentManagementModels.
|
|
152
|
-
standardsSchemaOrg.
|
|
150
|
+
documentManagementModels.DocumentContexts.ContextRoot,
|
|
151
|
+
documentManagementModels.DocumentContexts.ContextRootCommon,
|
|
152
|
+
standardsSchemaOrg.SchemaOrgContexts.ContextRoot
|
|
153
153
|
],
|
|
154
154
|
type: documentManagementModels.DocumentTypes.Document,
|
|
155
155
|
id: "documents:705:2721000:rev-0",
|
|
@@ -235,14 +235,14 @@ function generateRestRoutesDocumentManagement(baseRouteName, componentName) {
|
|
|
235
235
|
id: "DocumentManagementQueryResponseExample",
|
|
236
236
|
response: {
|
|
237
237
|
body: {
|
|
238
|
-
"@context": [documentManagementModels.
|
|
238
|
+
"@context": [documentManagementModels.DocumentContexts.ContextRoot, documentManagementModels.DocumentContexts.ContextRootCommon],
|
|
239
239
|
type: documentManagementModels.DocumentTypes.DocumentList,
|
|
240
240
|
documents: [
|
|
241
241
|
{
|
|
242
242
|
"@context": [
|
|
243
|
-
documentManagementModels.
|
|
244
|
-
documentManagementModels.
|
|
245
|
-
standardsSchemaOrg.
|
|
243
|
+
documentManagementModels.DocumentContexts.ContextRoot,
|
|
244
|
+
documentManagementModels.DocumentContexts.ContextRootCommon,
|
|
245
|
+
standardsSchemaOrg.SchemaOrgContexts.ContextRoot
|
|
246
246
|
],
|
|
247
247
|
type: documentManagementModels.DocumentTypes.Document,
|
|
248
248
|
id: "documents:705:2721000:rev-0",
|
|
@@ -275,14 +275,14 @@ function generateRestRoutesDocumentManagement(baseRouteName, componentName) {
|
|
|
275
275
|
id: "DocumentManagementListResponseJsonLdExample",
|
|
276
276
|
response: {
|
|
277
277
|
body: {
|
|
278
|
-
"@context": [documentManagementModels.
|
|
278
|
+
"@context": [documentManagementModels.DocumentContexts.ContextRoot, documentManagementModels.DocumentContexts.ContextRootCommon],
|
|
279
279
|
type: documentManagementModels.DocumentTypes.DocumentList,
|
|
280
280
|
documents: [
|
|
281
281
|
{
|
|
282
282
|
"@context": [
|
|
283
|
-
documentManagementModels.
|
|
284
|
-
documentManagementModels.
|
|
285
|
-
standardsSchemaOrg.
|
|
283
|
+
documentManagementModels.DocumentContexts.ContextRoot,
|
|
284
|
+
documentManagementModels.DocumentContexts.ContextRootCommon,
|
|
285
|
+
standardsSchemaOrg.SchemaOrgContexts.ContextRoot
|
|
286
286
|
],
|
|
287
287
|
type: documentManagementModels.DocumentTypes.Document,
|
|
288
288
|
id: "documents:705:2721000:rev-0",
|
|
@@ -330,7 +330,11 @@ async function documentManagementSet(httpRequestContext, componentName, request)
|
|
|
330
330
|
core.Guards.object(ROUTES_SOURCE, "request.body", request.body);
|
|
331
331
|
core.Guards.stringBase64(ROUTES_SOURCE, "request.body.blob", request.body.blob);
|
|
332
332
|
const component = core.ComponentFactory.get(componentName);
|
|
333
|
-
const id = await component.set(request.pathParams.auditableItemGraphId, request.body.documentId, request.body.documentIdFormat, request.body.documentCode, core.Converter.base64ToBytes(request.body.blob), request.body.annotationObject,
|
|
333
|
+
const id = await component.set(request.pathParams.auditableItemGraphId, request.body.documentId, request.body.documentIdFormat, request.body.documentCode, core.Converter.base64ToBytes(request.body.blob), request.body.annotationObject, {
|
|
334
|
+
createAttestation: request.body.createAttestation,
|
|
335
|
+
includeIdAsAlias: request.body.includeIdAsAlias,
|
|
336
|
+
aliasAnnotationObject: request.body.aliasAnnotationObject
|
|
337
|
+
}, httpRequestContext.userIdentity, httpRequestContext.nodeIdentity);
|
|
334
338
|
return {
|
|
335
339
|
statusCode: web.HttpStatusCode.created,
|
|
336
340
|
headers: {
|
|
@@ -463,12 +467,15 @@ class DocumentManagementService {
|
|
|
463
467
|
* @param documentCode The code for the document type.
|
|
464
468
|
* @param blob The data to create the document.
|
|
465
469
|
* @param annotationObject Additional information to associate with the document.
|
|
466
|
-
* @param
|
|
470
|
+
* @param options Additional options for the set operation.
|
|
471
|
+
* @param options.createAttestation Flag to create an attestation for the document, defaults to false.
|
|
472
|
+
* @param options.includeIdAsAlias Include the document id as an alias to the aig vertex, defaults to false.
|
|
473
|
+
* @param options.aliasAnnotationObject Additional information to associate with the alias.
|
|
467
474
|
* @param userIdentity The identity to perform the auditable item graph operation with.
|
|
468
475
|
* @param nodeIdentity The node identity to use for vault operations.
|
|
469
476
|
* @returns The identifier for the document which includes the auditable item graph identifier.
|
|
470
477
|
*/
|
|
471
|
-
async set(auditableItemGraphId, documentId, documentIdFormat, documentCode, blob, annotationObject,
|
|
478
|
+
async set(auditableItemGraphId, documentId, documentIdFormat, documentCode, blob, annotationObject, options, userIdentity, nodeIdentity) {
|
|
472
479
|
core.Guards.stringValue(this.CLASS_NAME, "auditableItemGraphId", auditableItemGraphId);
|
|
473
480
|
core.Guards.stringValue(this.CLASS_NAME, "documentId", documentId);
|
|
474
481
|
core.Guards.arrayOneOf(this.CLASS_NAME, "documentCode", documentCode, Object.values(standardsUnece.UneceDocumentCodes));
|
|
@@ -478,14 +485,32 @@ class DocumentManagementService {
|
|
|
478
485
|
try {
|
|
479
486
|
const vertex = await this._auditableItemGraphComponent.get(auditableItemGraphId);
|
|
480
487
|
vertex.resources = vertex.resources ?? [];
|
|
488
|
+
if (options?.includeIdAsAlias ?? false) {
|
|
489
|
+
vertex.aliases ??= [];
|
|
490
|
+
const found = vertex.aliases.find(a => a.id === documentId);
|
|
491
|
+
if (found) {
|
|
492
|
+
found.annotationObject = options?.aliasAnnotationObject ?? found.annotationObject;
|
|
493
|
+
found.aliasFormat = documentIdFormat ?? found.aliasFormat;
|
|
494
|
+
}
|
|
495
|
+
else {
|
|
496
|
+
vertex.aliases.push({
|
|
497
|
+
"@context": auditableItemGraphModels.AuditableItemGraphContexts.ContextRoot,
|
|
498
|
+
type: auditableItemGraphModels.AuditableItemGraphTypes.Alias,
|
|
499
|
+
id: documentId,
|
|
500
|
+
aliasFormat: documentIdFormat,
|
|
501
|
+
annotationObject: options?.aliasAnnotationObject
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
}
|
|
481
505
|
// Get all the docs from the AIG vertex
|
|
482
506
|
const vertexDocs = this.filterDocumentsFromVertex(vertex);
|
|
483
507
|
// Reduce the list to those with a matching id and code
|
|
484
508
|
const matchingDocIds = this.findMatchingDocs(vertexDocs, documentId, documentCode, true);
|
|
485
509
|
const currentRevision = matchingDocIds[0];
|
|
510
|
+
let createAttestation = options?.createAttestation ?? false;
|
|
486
511
|
// If the create attestation flag is not defined we check to see if any previous
|
|
487
512
|
// revisions have an attestation and if so we create one for the new revision.
|
|
488
|
-
if (core.Is.undefined(createAttestation)) {
|
|
513
|
+
if (core.Is.undefined(options?.createAttestation)) {
|
|
489
514
|
createAttestation = matchingDocIds.some(d => core.Is.stringValue(d.attestationId));
|
|
490
515
|
}
|
|
491
516
|
// Calculate the hash for the blob.
|
|
@@ -504,7 +529,7 @@ class DocumentManagementService {
|
|
|
504
529
|
updated = true;
|
|
505
530
|
}
|
|
506
531
|
if (updated) {
|
|
507
|
-
currentRevision.dateModified = new Date().toISOString();
|
|
532
|
+
currentRevision.dateModified = new Date(Date.now()).toISOString();
|
|
508
533
|
await this._auditableItemGraphComponent.update(vertex, userIdentity, nodeIdentity);
|
|
509
534
|
}
|
|
510
535
|
return currentRevision.id;
|
|
@@ -516,9 +541,9 @@ class DocumentManagementService {
|
|
|
516
541
|
// to determine the next revision number.
|
|
517
542
|
const document = {
|
|
518
543
|
"@context": [
|
|
519
|
-
documentManagementModels.
|
|
520
|
-
documentManagementModels.
|
|
521
|
-
standardsSchemaOrg.
|
|
544
|
+
documentManagementModels.DocumentContexts.ContextRoot,
|
|
545
|
+
documentManagementModels.DocumentContexts.ContextRootCommon,
|
|
546
|
+
standardsSchemaOrg.SchemaOrgContexts.ContextRoot
|
|
522
547
|
],
|
|
523
548
|
type: documentManagementModels.DocumentTypes.Document,
|
|
524
549
|
id: this.createIdentifier(documentCode, documentId, documentRevision),
|
|
@@ -539,7 +564,7 @@ class DocumentManagementService {
|
|
|
539
564
|
}
|
|
540
565
|
// Add the new revision in to the AIG
|
|
541
566
|
vertex.resources.push({
|
|
542
|
-
"@context": auditableItemGraphModels.
|
|
567
|
+
"@context": auditableItemGraphModels.AuditableItemGraphContexts.ContextRoot,
|
|
543
568
|
type: auditableItemGraphModels.AuditableItemGraphTypes.Resource,
|
|
544
569
|
resourceObject: document
|
|
545
570
|
});
|
|
@@ -699,9 +724,9 @@ class DocumentManagementService {
|
|
|
699
724
|
}
|
|
700
725
|
const docList = {
|
|
701
726
|
"@context": [
|
|
702
|
-
documentManagementModels.
|
|
703
|
-
documentManagementModels.
|
|
704
|
-
standardsSchemaOrg.
|
|
727
|
+
documentManagementModels.DocumentContexts.ContextRoot,
|
|
728
|
+
documentManagementModels.DocumentContexts.ContextRootCommon,
|
|
729
|
+
standardsSchemaOrg.SchemaOrgContexts.ContextRoot
|
|
705
730
|
],
|
|
706
731
|
type: documentManagementModels.DocumentTypes.DocumentList,
|
|
707
732
|
documents: finalDocs,
|
|
@@ -857,12 +882,12 @@ class DocumentManagementService {
|
|
|
857
882
|
if (options.includeBlobStorageMetadata || options.includeBlobStorageData) {
|
|
858
883
|
const blobEntry = await this._blobStorageComponent.get(document.blobStorageId, options.includeBlobStorageData, userIdentity, nodeIdentity);
|
|
859
884
|
document.blobStorageEntry = blobEntry;
|
|
860
|
-
document["@context"].push(blobStorageModels.
|
|
885
|
+
document["@context"].push(blobStorageModels.BlobStorageContexts.ContextRoot);
|
|
861
886
|
}
|
|
862
887
|
if (options.includeAttestation && core.Is.stringValue(document.attestationId)) {
|
|
863
888
|
const attestationInformation = await this._attestationComponent.get(document.attestationId);
|
|
864
889
|
document.attestationInformation = attestationInformation;
|
|
865
|
-
document["@context"].push(attestationModels.
|
|
890
|
+
document["@context"].push(attestationModels.AttestationContexts.ContextRoot);
|
|
866
891
|
}
|
|
867
892
|
document.revisions = core.Is.arrayValue(revisions) ? revisions : undefined;
|
|
868
893
|
document.revisionCursor = nextRevisionCursor;
|
|
@@ -878,9 +903,9 @@ class DocumentManagementService {
|
|
|
878
903
|
async createAttestation(document, userIdentity, nodeIdentity) {
|
|
879
904
|
const documentAttestation = {
|
|
880
905
|
"@context": [
|
|
881
|
-
documentManagementModels.
|
|
882
|
-
documentManagementModels.
|
|
883
|
-
standardsSchemaOrg.
|
|
906
|
+
documentManagementModels.DocumentContexts.ContextRoot,
|
|
907
|
+
documentManagementModels.DocumentContexts.ContextRootCommon,
|
|
908
|
+
standardsSchemaOrg.SchemaOrgContexts.ContextRoot
|
|
884
909
|
],
|
|
885
910
|
type: documentManagementModels.DocumentTypes.DocumentAttestation,
|
|
886
911
|
documentId: document.documentId,
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { HttpParameterHelper } from '@twin.org/api-models';
|
|
2
2
|
import { Guards, ComponentFactory, Converter, Coerce, Is, ObjectHelper, BaseError, GeneralError, Urn, NotFoundError } from '@twin.org/core';
|
|
3
|
-
import { DocumentTypes } from '@twin.org/document-management-models';
|
|
4
|
-
import {
|
|
3
|
+
import { DocumentTypes, DocumentContexts } from '@twin.org/document-management-models';
|
|
4
|
+
import { SchemaOrgContexts, SchemaOrgDataTypes } from '@twin.org/standards-schema-org';
|
|
5
5
|
import { UneceDocumentCodes } from '@twin.org/standards-unece';
|
|
6
6
|
import { HttpStatusCode, HeaderTypes, MimeTypes } from '@twin.org/web';
|
|
7
|
-
import {
|
|
8
|
-
import { AuditableItemGraphTypes } from '@twin.org/auditable-item-graph-models';
|
|
9
|
-
import {
|
|
7
|
+
import { AttestationContexts } from '@twin.org/attestation-models';
|
|
8
|
+
import { AuditableItemGraphTypes, AuditableItemGraphContexts } from '@twin.org/auditable-item-graph-models';
|
|
9
|
+
import { BlobStorageContexts } from '@twin.org/blob-storage-models';
|
|
10
10
|
import { Sha256 } from '@twin.org/crypto';
|
|
11
11
|
import { JsonLdProcessor } from '@twin.org/data-json-ld';
|
|
12
12
|
|
|
@@ -111,9 +111,9 @@ function generateRestRoutesDocumentManagement(baseRouteName, componentName) {
|
|
|
111
111
|
response: {
|
|
112
112
|
body: {
|
|
113
113
|
"@context": [
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
DocumentContexts.ContextRoot,
|
|
115
|
+
DocumentContexts.ContextRootCommon,
|
|
116
|
+
SchemaOrgContexts.ContextRoot
|
|
117
117
|
],
|
|
118
118
|
type: DocumentTypes.Document,
|
|
119
119
|
id: "documents:705:2721000:rev-0",
|
|
@@ -145,9 +145,9 @@ function generateRestRoutesDocumentManagement(baseRouteName, componentName) {
|
|
|
145
145
|
response: {
|
|
146
146
|
body: {
|
|
147
147
|
"@context": [
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
148
|
+
DocumentContexts.ContextRoot,
|
|
149
|
+
DocumentContexts.ContextRootCommon,
|
|
150
|
+
SchemaOrgContexts.ContextRoot
|
|
151
151
|
],
|
|
152
152
|
type: DocumentTypes.Document,
|
|
153
153
|
id: "documents:705:2721000:rev-0",
|
|
@@ -233,14 +233,14 @@ function generateRestRoutesDocumentManagement(baseRouteName, componentName) {
|
|
|
233
233
|
id: "DocumentManagementQueryResponseExample",
|
|
234
234
|
response: {
|
|
235
235
|
body: {
|
|
236
|
-
"@context": [
|
|
236
|
+
"@context": [DocumentContexts.ContextRoot, DocumentContexts.ContextRootCommon],
|
|
237
237
|
type: DocumentTypes.DocumentList,
|
|
238
238
|
documents: [
|
|
239
239
|
{
|
|
240
240
|
"@context": [
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
241
|
+
DocumentContexts.ContextRoot,
|
|
242
|
+
DocumentContexts.ContextRootCommon,
|
|
243
|
+
SchemaOrgContexts.ContextRoot
|
|
244
244
|
],
|
|
245
245
|
type: DocumentTypes.Document,
|
|
246
246
|
id: "documents:705:2721000:rev-0",
|
|
@@ -273,14 +273,14 @@ function generateRestRoutesDocumentManagement(baseRouteName, componentName) {
|
|
|
273
273
|
id: "DocumentManagementListResponseJsonLdExample",
|
|
274
274
|
response: {
|
|
275
275
|
body: {
|
|
276
|
-
"@context": [
|
|
276
|
+
"@context": [DocumentContexts.ContextRoot, DocumentContexts.ContextRootCommon],
|
|
277
277
|
type: DocumentTypes.DocumentList,
|
|
278
278
|
documents: [
|
|
279
279
|
{
|
|
280
280
|
"@context": [
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
281
|
+
DocumentContexts.ContextRoot,
|
|
282
|
+
DocumentContexts.ContextRootCommon,
|
|
283
|
+
SchemaOrgContexts.ContextRoot
|
|
284
284
|
],
|
|
285
285
|
type: DocumentTypes.Document,
|
|
286
286
|
id: "documents:705:2721000:rev-0",
|
|
@@ -328,7 +328,11 @@ async function documentManagementSet(httpRequestContext, componentName, request)
|
|
|
328
328
|
Guards.object(ROUTES_SOURCE, "request.body", request.body);
|
|
329
329
|
Guards.stringBase64(ROUTES_SOURCE, "request.body.blob", request.body.blob);
|
|
330
330
|
const component = ComponentFactory.get(componentName);
|
|
331
|
-
const id = await component.set(request.pathParams.auditableItemGraphId, request.body.documentId, request.body.documentIdFormat, request.body.documentCode, Converter.base64ToBytes(request.body.blob), request.body.annotationObject,
|
|
331
|
+
const id = await component.set(request.pathParams.auditableItemGraphId, request.body.documentId, request.body.documentIdFormat, request.body.documentCode, Converter.base64ToBytes(request.body.blob), request.body.annotationObject, {
|
|
332
|
+
createAttestation: request.body.createAttestation,
|
|
333
|
+
includeIdAsAlias: request.body.includeIdAsAlias,
|
|
334
|
+
aliasAnnotationObject: request.body.aliasAnnotationObject
|
|
335
|
+
}, httpRequestContext.userIdentity, httpRequestContext.nodeIdentity);
|
|
332
336
|
return {
|
|
333
337
|
statusCode: HttpStatusCode.created,
|
|
334
338
|
headers: {
|
|
@@ -461,12 +465,15 @@ class DocumentManagementService {
|
|
|
461
465
|
* @param documentCode The code for the document type.
|
|
462
466
|
* @param blob The data to create the document.
|
|
463
467
|
* @param annotationObject Additional information to associate with the document.
|
|
464
|
-
* @param
|
|
468
|
+
* @param options Additional options for the set operation.
|
|
469
|
+
* @param options.createAttestation Flag to create an attestation for the document, defaults to false.
|
|
470
|
+
* @param options.includeIdAsAlias Include the document id as an alias to the aig vertex, defaults to false.
|
|
471
|
+
* @param options.aliasAnnotationObject Additional information to associate with the alias.
|
|
465
472
|
* @param userIdentity The identity to perform the auditable item graph operation with.
|
|
466
473
|
* @param nodeIdentity The node identity to use for vault operations.
|
|
467
474
|
* @returns The identifier for the document which includes the auditable item graph identifier.
|
|
468
475
|
*/
|
|
469
|
-
async set(auditableItemGraphId, documentId, documentIdFormat, documentCode, blob, annotationObject,
|
|
476
|
+
async set(auditableItemGraphId, documentId, documentIdFormat, documentCode, blob, annotationObject, options, userIdentity, nodeIdentity) {
|
|
470
477
|
Guards.stringValue(this.CLASS_NAME, "auditableItemGraphId", auditableItemGraphId);
|
|
471
478
|
Guards.stringValue(this.CLASS_NAME, "documentId", documentId);
|
|
472
479
|
Guards.arrayOneOf(this.CLASS_NAME, "documentCode", documentCode, Object.values(UneceDocumentCodes));
|
|
@@ -476,14 +483,32 @@ class DocumentManagementService {
|
|
|
476
483
|
try {
|
|
477
484
|
const vertex = await this._auditableItemGraphComponent.get(auditableItemGraphId);
|
|
478
485
|
vertex.resources = vertex.resources ?? [];
|
|
486
|
+
if (options?.includeIdAsAlias ?? false) {
|
|
487
|
+
vertex.aliases ??= [];
|
|
488
|
+
const found = vertex.aliases.find(a => a.id === documentId);
|
|
489
|
+
if (found) {
|
|
490
|
+
found.annotationObject = options?.aliasAnnotationObject ?? found.annotationObject;
|
|
491
|
+
found.aliasFormat = documentIdFormat ?? found.aliasFormat;
|
|
492
|
+
}
|
|
493
|
+
else {
|
|
494
|
+
vertex.aliases.push({
|
|
495
|
+
"@context": AuditableItemGraphContexts.ContextRoot,
|
|
496
|
+
type: AuditableItemGraphTypes.Alias,
|
|
497
|
+
id: documentId,
|
|
498
|
+
aliasFormat: documentIdFormat,
|
|
499
|
+
annotationObject: options?.aliasAnnotationObject
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
}
|
|
479
503
|
// Get all the docs from the AIG vertex
|
|
480
504
|
const vertexDocs = this.filterDocumentsFromVertex(vertex);
|
|
481
505
|
// Reduce the list to those with a matching id and code
|
|
482
506
|
const matchingDocIds = this.findMatchingDocs(vertexDocs, documentId, documentCode, true);
|
|
483
507
|
const currentRevision = matchingDocIds[0];
|
|
508
|
+
let createAttestation = options?.createAttestation ?? false;
|
|
484
509
|
// If the create attestation flag is not defined we check to see if any previous
|
|
485
510
|
// revisions have an attestation and if so we create one for the new revision.
|
|
486
|
-
if (Is.undefined(createAttestation)) {
|
|
511
|
+
if (Is.undefined(options?.createAttestation)) {
|
|
487
512
|
createAttestation = matchingDocIds.some(d => Is.stringValue(d.attestationId));
|
|
488
513
|
}
|
|
489
514
|
// Calculate the hash for the blob.
|
|
@@ -502,7 +527,7 @@ class DocumentManagementService {
|
|
|
502
527
|
updated = true;
|
|
503
528
|
}
|
|
504
529
|
if (updated) {
|
|
505
|
-
currentRevision.dateModified = new Date().toISOString();
|
|
530
|
+
currentRevision.dateModified = new Date(Date.now()).toISOString();
|
|
506
531
|
await this._auditableItemGraphComponent.update(vertex, userIdentity, nodeIdentity);
|
|
507
532
|
}
|
|
508
533
|
return currentRevision.id;
|
|
@@ -514,9 +539,9 @@ class DocumentManagementService {
|
|
|
514
539
|
// to determine the next revision number.
|
|
515
540
|
const document = {
|
|
516
541
|
"@context": [
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
542
|
+
DocumentContexts.ContextRoot,
|
|
543
|
+
DocumentContexts.ContextRootCommon,
|
|
544
|
+
SchemaOrgContexts.ContextRoot
|
|
520
545
|
],
|
|
521
546
|
type: DocumentTypes.Document,
|
|
522
547
|
id: this.createIdentifier(documentCode, documentId, documentRevision),
|
|
@@ -537,7 +562,7 @@ class DocumentManagementService {
|
|
|
537
562
|
}
|
|
538
563
|
// Add the new revision in to the AIG
|
|
539
564
|
vertex.resources.push({
|
|
540
|
-
"@context":
|
|
565
|
+
"@context": AuditableItemGraphContexts.ContextRoot,
|
|
541
566
|
type: AuditableItemGraphTypes.Resource,
|
|
542
567
|
resourceObject: document
|
|
543
568
|
});
|
|
@@ -697,9 +722,9 @@ class DocumentManagementService {
|
|
|
697
722
|
}
|
|
698
723
|
const docList = {
|
|
699
724
|
"@context": [
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
725
|
+
DocumentContexts.ContextRoot,
|
|
726
|
+
DocumentContexts.ContextRootCommon,
|
|
727
|
+
SchemaOrgContexts.ContextRoot
|
|
703
728
|
],
|
|
704
729
|
type: DocumentTypes.DocumentList,
|
|
705
730
|
documents: finalDocs,
|
|
@@ -855,12 +880,12 @@ class DocumentManagementService {
|
|
|
855
880
|
if (options.includeBlobStorageMetadata || options.includeBlobStorageData) {
|
|
856
881
|
const blobEntry = await this._blobStorageComponent.get(document.blobStorageId, options.includeBlobStorageData, userIdentity, nodeIdentity);
|
|
857
882
|
document.blobStorageEntry = blobEntry;
|
|
858
|
-
document["@context"].push(
|
|
883
|
+
document["@context"].push(BlobStorageContexts.ContextRoot);
|
|
859
884
|
}
|
|
860
885
|
if (options.includeAttestation && Is.stringValue(document.attestationId)) {
|
|
861
886
|
const attestationInformation = await this._attestationComponent.get(document.attestationId);
|
|
862
887
|
document.attestationInformation = attestationInformation;
|
|
863
|
-
document["@context"].push(
|
|
888
|
+
document["@context"].push(AttestationContexts.ContextRoot);
|
|
864
889
|
}
|
|
865
890
|
document.revisions = Is.arrayValue(revisions) ? revisions : undefined;
|
|
866
891
|
document.revisionCursor = nextRevisionCursor;
|
|
@@ -876,9 +901,9 @@ class DocumentManagementService {
|
|
|
876
901
|
async createAttestation(document, userIdentity, nodeIdentity) {
|
|
877
902
|
const documentAttestation = {
|
|
878
903
|
"@context": [
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
904
|
+
DocumentContexts.ContextRoot,
|
|
905
|
+
DocumentContexts.ContextRootCommon,
|
|
906
|
+
SchemaOrgContexts.ContextRoot
|
|
882
907
|
],
|
|
883
908
|
type: DocumentTypes.DocumentAttestation,
|
|
884
909
|
documentId: document.documentId,
|
|
@@ -29,12 +29,19 @@ export declare class DocumentManagementService implements IDocumentManagementCom
|
|
|
29
29
|
* @param documentCode The code for the document type.
|
|
30
30
|
* @param blob The data to create the document.
|
|
31
31
|
* @param annotationObject Additional information to associate with the document.
|
|
32
|
-
* @param
|
|
32
|
+
* @param options Additional options for the set operation.
|
|
33
|
+
* @param options.createAttestation Flag to create an attestation for the document, defaults to false.
|
|
34
|
+
* @param options.includeIdAsAlias Include the document id as an alias to the aig vertex, defaults to false.
|
|
35
|
+
* @param options.aliasAnnotationObject Additional information to associate with the alias.
|
|
33
36
|
* @param userIdentity The identity to perform the auditable item graph operation with.
|
|
34
37
|
* @param nodeIdentity The node identity to use for vault operations.
|
|
35
38
|
* @returns The identifier for the document which includes the auditable item graph identifier.
|
|
36
39
|
*/
|
|
37
|
-
set(auditableItemGraphId: string, documentId: string, documentIdFormat: string | undefined, documentCode: UneceDocumentCodes, blob: Uint8Array, annotationObject?: IJsonLdNodeObject,
|
|
40
|
+
set(auditableItemGraphId: string, documentId: string, documentIdFormat: string | undefined, documentCode: UneceDocumentCodes, blob: Uint8Array, annotationObject?: IJsonLdNodeObject, options?: {
|
|
41
|
+
createAttestation?: boolean;
|
|
42
|
+
includeIdAsAlias?: boolean;
|
|
43
|
+
aliasAnnotationObject?: IJsonLdNodeObject;
|
|
44
|
+
}, userIdentity?: string, nodeIdentity?: string): Promise<string>;
|
|
38
45
|
/**
|
|
39
46
|
* Get a specific document from an auditable item graph vertex.
|
|
40
47
|
* @param auditableItemGraphId The auditable item graph vertex id to get the document from.
|
package/docs/changelog.md
CHANGED
package/docs/open-api/spec.json
CHANGED
|
@@ -1079,6 +1079,13 @@
|
|
|
1079
1079
|
"createAttestation": {
|
|
1080
1080
|
"type": "boolean",
|
|
1081
1081
|
"description": "Flag to create an attestation for the document, defaults to false"
|
|
1082
|
+
},
|
|
1083
|
+
"includeIdAsAlias": {
|
|
1084
|
+
"type": "boolean",
|
|
1085
|
+
"description": "Include the document id as an alias to the aig vertex, defaults to false."
|
|
1086
|
+
},
|
|
1087
|
+
"aliasAnnotationObject": {
|
|
1088
|
+
"$ref": "#/components/schemas/JsonLdNodeObject"
|
|
1082
1089
|
}
|
|
1083
1090
|
},
|
|
1084
1091
|
"required": [
|
|
@@ -50,7 +50,7 @@ Runtime name for the class.
|
|
|
50
50
|
|
|
51
51
|
### set()
|
|
52
52
|
|
|
53
|
-
> **set**(`auditableItemGraphId`, `documentId`, `documentIdFormat`, `documentCode`, `blob`, `annotationObject`?, `
|
|
53
|
+
> **set**(`auditableItemGraphId`, `documentId`, `documentIdFormat`, `documentCode`, `blob`, `annotationObject`?, `options`?, `userIdentity`?, `nodeIdentity`?): `Promise`\<`string`\>
|
|
54
54
|
|
|
55
55
|
Store a document in an auditable item graph vertex and add its content to blob storage.
|
|
56
56
|
If the document id already exists and the blob data is different a new revision will be created.
|
|
@@ -94,12 +94,28 @@ The data to create the document.
|
|
|
94
94
|
|
|
95
95
|
Additional information to associate with the document.
|
|
96
96
|
|
|
97
|
-
#####
|
|
97
|
+
##### options?
|
|
98
|
+
|
|
99
|
+
Additional options for the set operation.
|
|
100
|
+
|
|
101
|
+
###### createAttestation?
|
|
98
102
|
|
|
99
103
|
`boolean`
|
|
100
104
|
|
|
101
105
|
Flag to create an attestation for the document, defaults to false.
|
|
102
106
|
|
|
107
|
+
###### includeIdAsAlias?
|
|
108
|
+
|
|
109
|
+
`boolean`
|
|
110
|
+
|
|
111
|
+
Include the document id as an alias to the aig vertex, defaults to false.
|
|
112
|
+
|
|
113
|
+
###### aliasAnnotationObject?
|
|
114
|
+
|
|
115
|
+
`IJsonLdNodeObject`
|
|
116
|
+
|
|
117
|
+
Additional information to associate with the alias.
|
|
118
|
+
|
|
103
119
|
##### userIdentity?
|
|
104
120
|
|
|
105
121
|
`string`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/document-management-service",
|
|
3
|
-
"version": "0.0.1-next.
|
|
3
|
+
"version": "0.0.1-next.6",
|
|
4
4
|
"description": "Document management contract implementation and REST endpoint definitions",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"@twin.org/core": "next",
|
|
22
22
|
"@twin.org/crypto": "next",
|
|
23
23
|
"@twin.org/data-json-ld": "next",
|
|
24
|
-
"@twin.org/document-management-models": "0.0.1-next.
|
|
24
|
+
"@twin.org/document-management-models": "0.0.1-next.6",
|
|
25
25
|
"@twin.org/entity": "next",
|
|
26
26
|
"@twin.org/entity-storage-models": "next",
|
|
27
27
|
"@twin.org/nameof": "next",
|