@twin.org/document-management-service 0.0.1-next.2 → 0.0.1-next.5

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.
@@ -130,7 +130,9 @@ function generateRestRoutesDocumentManagement(baseRouteName, componentName) {
130
130
  "@context": "https://schema.org",
131
131
  "@type": "DigitalDocument",
132
132
  name: "myfile.pdf"
133
- }
133
+ },
134
+ nodeIdentity: "did:entity-storage:0x6363636363636363636363636363636363636363636363636363636363636363",
135
+ userIdentity: "did:entity-storage:0x6363636363636363636363636363636363636363636363636363636363636363"
134
136
  }
135
137
  }
136
138
  }
@@ -162,7 +164,9 @@ function generateRestRoutesDocumentManagement(baseRouteName, componentName) {
162
164
  "@context": "https://schema.org",
163
165
  "@type": "DigitalDocument",
164
166
  name: "myfile.pdf"
165
- }
167
+ },
168
+ nodeIdentity: "did:entity-storage:0x6363636363636363636363636363636363636363636363636363636363636363",
169
+ userIdentity: "did:entity-storage:0x6363636363636363636363636363636363636363636363636363636363636363"
166
170
  }
167
171
  }
168
172
  }
@@ -253,7 +257,9 @@ function generateRestRoutesDocumentManagement(baseRouteName, componentName) {
253
257
  "@context": "https://schema.org",
254
258
  "@type": "DigitalDocument",
255
259
  name: "myfile.pdf"
256
- }
260
+ },
261
+ nodeIdentity: "did:entity-storage:0x6363636363636363636363636363636363636363636363636363636363636363",
262
+ userIdentity: "did:entity-storage:0x6363636363636363636363636363636363636363636363636363636363636363"
257
263
  }
258
264
  ]
259
265
  }
@@ -291,7 +297,9 @@ function generateRestRoutesDocumentManagement(baseRouteName, componentName) {
291
297
  "@context": "https://schema.org",
292
298
  "@type": "DigitalDocument",
293
299
  name: "myfile.pdf"
294
- }
300
+ },
301
+ nodeIdentity: "did:entity-storage:0x6363636363636363636363636363636363636363636363636363636363636363",
302
+ userIdentity: "did:entity-storage:0x6363636363636363636363636363636363636363636363636363636363636363"
295
303
  }
296
304
  ]
297
305
  }
@@ -322,7 +330,11 @@ async function documentManagementSet(httpRequestContext, componentName, request)
322
330
  core.Guards.object(ROUTES_SOURCE, "request.body", request.body);
323
331
  core.Guards.stringBase64(ROUTES_SOURCE, "request.body.blob", request.body.blob);
324
332
  const component = core.ComponentFactory.get(componentName);
325
- 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, request.body.createAttestation, httpRequestContext.userIdentity, httpRequestContext.nodeIdentity);
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);
326
338
  return {
327
339
  statusCode: web.HttpStatusCode.created,
328
340
  headers: {
@@ -455,40 +467,76 @@ class DocumentManagementService {
455
467
  * @param documentCode The code for the document type.
456
468
  * @param blob The data to create the document.
457
469
  * @param annotationObject Additional information to associate with the document.
458
- * @param createAttestation Flag to create an attestation for the document, defaults to false.
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.
459
474
  * @param userIdentity The identity to perform the auditable item graph operation with.
460
475
  * @param nodeIdentity The node identity to use for vault operations.
461
476
  * @returns The identifier for the document which includes the auditable item graph identifier.
462
477
  */
463
- async set(auditableItemGraphId, documentId, documentIdFormat, documentCode, blob, annotationObject, createAttestation, userIdentity, nodeIdentity) {
478
+ async set(auditableItemGraphId, documentId, documentIdFormat, documentCode, blob, annotationObject, options, userIdentity, nodeIdentity) {
464
479
  core.Guards.stringValue(this.CLASS_NAME, "auditableItemGraphId", auditableItemGraphId);
465
480
  core.Guards.stringValue(this.CLASS_NAME, "documentId", documentId);
466
481
  core.Guards.arrayOneOf(this.CLASS_NAME, "documentCode", documentCode, Object.values(standardsUnece.UneceDocumentCodes));
467
482
  core.Guards.uint8Array(this.CLASS_NAME, "blob", blob);
483
+ core.Guards.stringValue(this.CLASS_NAME, "userIdentity", userIdentity);
484
+ core.Guards.stringValue(this.CLASS_NAME, "nodeIdentity", nodeIdentity);
468
485
  try {
469
486
  const vertex = await this._auditableItemGraphComponent.get(auditableItemGraphId);
470
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.AuditableItemGraphTypes.ContextRoot,
498
+ type: auditableItemGraphModels.AuditableItemGraphTypes.Alias,
499
+ id: documentId,
500
+ aliasFormat: documentIdFormat,
501
+ annotationObject: options?.aliasAnnotationObject
502
+ });
503
+ }
504
+ }
471
505
  // Get all the docs from the AIG vertex
472
506
  const vertexDocs = this.filterDocumentsFromVertex(vertex);
473
507
  // Reduce the list to those with a matching id and code
474
508
  const matchingDocIds = this.findMatchingDocs(vertexDocs, documentId, documentCode, true);
509
+ const currentRevision = matchingDocIds[0];
510
+ let createAttestation = options?.createAttestation ?? false;
511
+ // If the create attestation flag is not defined we check to see if any previous
512
+ // revisions have an attestation and if so we create one for the new revision.
513
+ if (core.Is.undefined(options?.createAttestation)) {
514
+ createAttestation = matchingDocIds.some(d => core.Is.stringValue(d.attestationId));
515
+ }
475
516
  // Calculate the hash for the blob.
476
517
  const blobHash = this.generateBlobHash(blob);
477
- let documentRevision;
478
- if (core.Is.arrayValue(matchingDocIds) && matchingDocIds[0].blobHash === blobHash) {
479
- documentRevision = matchingDocIds[0].documentRevision;
480
- // If there is already a doc with the matching blob hash no need to create a new revision
481
- // instead we just update the annotation object if it has changed.
482
- if (!core.ObjectHelper.equal(matchingDocIds[0].annotationObject, annotationObject, false)) {
483
- matchingDocIds[0].dateModified = new Date().toISOString();
484
- matchingDocIds[0].annotationObject = annotationObject;
518
+ // Is the blob data the same as the current revision ?
519
+ if (currentRevision?.blobHash === blobHash) {
520
+ // Blob data matches so no need to create a new revision
521
+ // We update the current object if the annotation or createAttestation flag has changed.
522
+ let updated = false;
523
+ if (!core.ObjectHelper.equal(currentRevision.annotationObject, annotationObject, false)) {
524
+ currentRevision.annotationObject = annotationObject;
525
+ updated = true;
526
+ }
527
+ if (createAttestation && core.Is.empty(currentRevision.attestationId)) {
528
+ currentRevision.attestationId = await this.createAttestation(currentRevision, userIdentity, nodeIdentity);
529
+ updated = true;
530
+ }
531
+ if (updated) {
532
+ currentRevision.dateModified = new Date(Date.now()).toISOString();
485
533
  await this._auditableItemGraphComponent.update(vertex, userIdentity, nodeIdentity);
486
534
  }
487
- return matchingDocIds[0].id;
535
+ return currentRevision.id;
488
536
  }
489
537
  // Nothing matches the current blob hash so upload it to blob storage
490
538
  const blobStorageId = await this._blobStorageComponent.create(core.Converter.bytesToBase64(blob), undefined, undefined, undefined, undefined, userIdentity, nodeIdentity);
491
- documentRevision = matchingDocIds.length;
539
+ const documentRevision = matchingDocIds.length;
492
540
  // We are creating a new document, if there is already docs with the same id and code we use the list length
493
541
  // to determine the next revision number.
494
542
  const document = {
@@ -505,15 +553,15 @@ class DocumentManagementService {
505
553
  documentRevision,
506
554
  blobStorageId,
507
555
  blobHash,
508
- dateCreated: new Date(Date.now()).toISOString()
556
+ annotationObject,
557
+ dateCreated: new Date(Date.now()).toISOString(),
558
+ nodeIdentity,
559
+ userIdentity
509
560
  };
510
561
  // If the attestation flag is set then create it
511
562
  if (createAttestation ?? false) {
512
- document.attestationId = await this._attestationComponent.create(document, undefined, userIdentity, nodeIdentity);
563
+ document.attestationId = await this.createAttestation(document, userIdentity, nodeIdentity);
513
564
  }
514
- // We assign the annotation object after the attestation was created
515
- // as we don't want to include it in the attestation
516
- document.annotationObject = annotationObject;
517
565
  // Add the new revision in to the AIG
518
566
  vertex.resources.push({
519
567
  "@context": auditableItemGraphModels.AuditableItemGraphTypes.ContextRoot,
@@ -845,6 +893,29 @@ class DocumentManagementService {
845
893
  document.revisionCursor = nextRevisionCursor;
846
894
  return document;
847
895
  }
896
+ /**
897
+ * Create an attestation for the document.
898
+ * @param document The document to create the attestation for.
899
+ * @param userIdentity The identity to perform the attestation operation with.
900
+ * @param nodeIdentity The node identity to perform attestation operation with.
901
+ * @returns The attestation identifier.
902
+ */
903
+ async createAttestation(document, userIdentity, nodeIdentity) {
904
+ const documentAttestation = {
905
+ "@context": [
906
+ documentManagementModels.DocumentTypes.ContextRoot,
907
+ documentManagementModels.DocumentTypes.ContextRootCommon,
908
+ standardsSchemaOrg.SchemaOrgTypes.ContextRoot
909
+ ],
910
+ type: documentManagementModels.DocumentTypes.DocumentAttestation,
911
+ documentId: document.documentId,
912
+ documentCode: document.documentCode,
913
+ documentRevision: document.documentRevision,
914
+ dateCreated: document.dateCreated,
915
+ blobHash: document.blobHash
916
+ };
917
+ return this._attestationComponent.create(documentAttestation, undefined, userIdentity, nodeIdentity);
918
+ }
848
919
  }
849
920
 
850
921
  const restEntryPoints = [
@@ -128,7 +128,9 @@ function generateRestRoutesDocumentManagement(baseRouteName, componentName) {
128
128
  "@context": "https://schema.org",
129
129
  "@type": "DigitalDocument",
130
130
  name: "myfile.pdf"
131
- }
131
+ },
132
+ nodeIdentity: "did:entity-storage:0x6363636363636363636363636363636363636363636363636363636363636363",
133
+ userIdentity: "did:entity-storage:0x6363636363636363636363636363636363636363636363636363636363636363"
132
134
  }
133
135
  }
134
136
  }
@@ -160,7 +162,9 @@ function generateRestRoutesDocumentManagement(baseRouteName, componentName) {
160
162
  "@context": "https://schema.org",
161
163
  "@type": "DigitalDocument",
162
164
  name: "myfile.pdf"
163
- }
165
+ },
166
+ nodeIdentity: "did:entity-storage:0x6363636363636363636363636363636363636363636363636363636363636363",
167
+ userIdentity: "did:entity-storage:0x6363636363636363636363636363636363636363636363636363636363636363"
164
168
  }
165
169
  }
166
170
  }
@@ -251,7 +255,9 @@ function generateRestRoutesDocumentManagement(baseRouteName, componentName) {
251
255
  "@context": "https://schema.org",
252
256
  "@type": "DigitalDocument",
253
257
  name: "myfile.pdf"
254
- }
258
+ },
259
+ nodeIdentity: "did:entity-storage:0x6363636363636363636363636363636363636363636363636363636363636363",
260
+ userIdentity: "did:entity-storage:0x6363636363636363636363636363636363636363636363636363636363636363"
255
261
  }
256
262
  ]
257
263
  }
@@ -289,7 +295,9 @@ function generateRestRoutesDocumentManagement(baseRouteName, componentName) {
289
295
  "@context": "https://schema.org",
290
296
  "@type": "DigitalDocument",
291
297
  name: "myfile.pdf"
292
- }
298
+ },
299
+ nodeIdentity: "did:entity-storage:0x6363636363636363636363636363636363636363636363636363636363636363",
300
+ userIdentity: "did:entity-storage:0x6363636363636363636363636363636363636363636363636363636363636363"
293
301
  }
294
302
  ]
295
303
  }
@@ -320,7 +328,11 @@ async function documentManagementSet(httpRequestContext, componentName, request)
320
328
  Guards.object(ROUTES_SOURCE, "request.body", request.body);
321
329
  Guards.stringBase64(ROUTES_SOURCE, "request.body.blob", request.body.blob);
322
330
  const component = ComponentFactory.get(componentName);
323
- 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, request.body.createAttestation, httpRequestContext.userIdentity, httpRequestContext.nodeIdentity);
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);
324
336
  return {
325
337
  statusCode: HttpStatusCode.created,
326
338
  headers: {
@@ -453,40 +465,76 @@ class DocumentManagementService {
453
465
  * @param documentCode The code for the document type.
454
466
  * @param blob The data to create the document.
455
467
  * @param annotationObject Additional information to associate with the document.
456
- * @param createAttestation Flag to create an attestation for the document, defaults to false.
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.
457
472
  * @param userIdentity The identity to perform the auditable item graph operation with.
458
473
  * @param nodeIdentity The node identity to use for vault operations.
459
474
  * @returns The identifier for the document which includes the auditable item graph identifier.
460
475
  */
461
- async set(auditableItemGraphId, documentId, documentIdFormat, documentCode, blob, annotationObject, createAttestation, userIdentity, nodeIdentity) {
476
+ async set(auditableItemGraphId, documentId, documentIdFormat, documentCode, blob, annotationObject, options, userIdentity, nodeIdentity) {
462
477
  Guards.stringValue(this.CLASS_NAME, "auditableItemGraphId", auditableItemGraphId);
463
478
  Guards.stringValue(this.CLASS_NAME, "documentId", documentId);
464
479
  Guards.arrayOneOf(this.CLASS_NAME, "documentCode", documentCode, Object.values(UneceDocumentCodes));
465
480
  Guards.uint8Array(this.CLASS_NAME, "blob", blob);
481
+ Guards.stringValue(this.CLASS_NAME, "userIdentity", userIdentity);
482
+ Guards.stringValue(this.CLASS_NAME, "nodeIdentity", nodeIdentity);
466
483
  try {
467
484
  const vertex = await this._auditableItemGraphComponent.get(auditableItemGraphId);
468
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": AuditableItemGraphTypes.ContextRoot,
496
+ type: AuditableItemGraphTypes.Alias,
497
+ id: documentId,
498
+ aliasFormat: documentIdFormat,
499
+ annotationObject: options?.aliasAnnotationObject
500
+ });
501
+ }
502
+ }
469
503
  // Get all the docs from the AIG vertex
470
504
  const vertexDocs = this.filterDocumentsFromVertex(vertex);
471
505
  // Reduce the list to those with a matching id and code
472
506
  const matchingDocIds = this.findMatchingDocs(vertexDocs, documentId, documentCode, true);
507
+ const currentRevision = matchingDocIds[0];
508
+ let createAttestation = options?.createAttestation ?? false;
509
+ // If the create attestation flag is not defined we check to see if any previous
510
+ // revisions have an attestation and if so we create one for the new revision.
511
+ if (Is.undefined(options?.createAttestation)) {
512
+ createAttestation = matchingDocIds.some(d => Is.stringValue(d.attestationId));
513
+ }
473
514
  // Calculate the hash for the blob.
474
515
  const blobHash = this.generateBlobHash(blob);
475
- let documentRevision;
476
- if (Is.arrayValue(matchingDocIds) && matchingDocIds[0].blobHash === blobHash) {
477
- documentRevision = matchingDocIds[0].documentRevision;
478
- // If there is already a doc with the matching blob hash no need to create a new revision
479
- // instead we just update the annotation object if it has changed.
480
- if (!ObjectHelper.equal(matchingDocIds[0].annotationObject, annotationObject, false)) {
481
- matchingDocIds[0].dateModified = new Date().toISOString();
482
- matchingDocIds[0].annotationObject = annotationObject;
516
+ // Is the blob data the same as the current revision ?
517
+ if (currentRevision?.blobHash === blobHash) {
518
+ // Blob data matches so no need to create a new revision
519
+ // We update the current object if the annotation or createAttestation flag has changed.
520
+ let updated = false;
521
+ if (!ObjectHelper.equal(currentRevision.annotationObject, annotationObject, false)) {
522
+ currentRevision.annotationObject = annotationObject;
523
+ updated = true;
524
+ }
525
+ if (createAttestation && Is.empty(currentRevision.attestationId)) {
526
+ currentRevision.attestationId = await this.createAttestation(currentRevision, userIdentity, nodeIdentity);
527
+ updated = true;
528
+ }
529
+ if (updated) {
530
+ currentRevision.dateModified = new Date(Date.now()).toISOString();
483
531
  await this._auditableItemGraphComponent.update(vertex, userIdentity, nodeIdentity);
484
532
  }
485
- return matchingDocIds[0].id;
533
+ return currentRevision.id;
486
534
  }
487
535
  // Nothing matches the current blob hash so upload it to blob storage
488
536
  const blobStorageId = await this._blobStorageComponent.create(Converter.bytesToBase64(blob), undefined, undefined, undefined, undefined, userIdentity, nodeIdentity);
489
- documentRevision = matchingDocIds.length;
537
+ const documentRevision = matchingDocIds.length;
490
538
  // We are creating a new document, if there is already docs with the same id and code we use the list length
491
539
  // to determine the next revision number.
492
540
  const document = {
@@ -503,15 +551,15 @@ class DocumentManagementService {
503
551
  documentRevision,
504
552
  blobStorageId,
505
553
  blobHash,
506
- dateCreated: new Date(Date.now()).toISOString()
554
+ annotationObject,
555
+ dateCreated: new Date(Date.now()).toISOString(),
556
+ nodeIdentity,
557
+ userIdentity
507
558
  };
508
559
  // If the attestation flag is set then create it
509
560
  if (createAttestation ?? false) {
510
- document.attestationId = await this._attestationComponent.create(document, undefined, userIdentity, nodeIdentity);
561
+ document.attestationId = await this.createAttestation(document, userIdentity, nodeIdentity);
511
562
  }
512
- // We assign the annotation object after the attestation was created
513
- // as we don't want to include it in the attestation
514
- document.annotationObject = annotationObject;
515
563
  // Add the new revision in to the AIG
516
564
  vertex.resources.push({
517
565
  "@context": AuditableItemGraphTypes.ContextRoot,
@@ -843,6 +891,29 @@ class DocumentManagementService {
843
891
  document.revisionCursor = nextRevisionCursor;
844
892
  return document;
845
893
  }
894
+ /**
895
+ * Create an attestation for the document.
896
+ * @param document The document to create the attestation for.
897
+ * @param userIdentity The identity to perform the attestation operation with.
898
+ * @param nodeIdentity The node identity to perform attestation operation with.
899
+ * @returns The attestation identifier.
900
+ */
901
+ async createAttestation(document, userIdentity, nodeIdentity) {
902
+ const documentAttestation = {
903
+ "@context": [
904
+ DocumentTypes.ContextRoot,
905
+ DocumentTypes.ContextRootCommon,
906
+ SchemaOrgTypes.ContextRoot
907
+ ],
908
+ type: DocumentTypes.DocumentAttestation,
909
+ documentId: document.documentId,
910
+ documentCode: document.documentCode,
911
+ documentRevision: document.documentRevision,
912
+ dateCreated: document.dateCreated,
913
+ blobHash: document.blobHash
914
+ };
915
+ return this._attestationComponent.create(documentAttestation, undefined, userIdentity, nodeIdentity);
916
+ }
846
917
  }
847
918
 
848
919
  const restEntryPoints = [
@@ -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 createAttestation Flag to create an attestation for the document, defaults to false.
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, createAttestation?: boolean, userIdentity?: string, nodeIdentity?: string): Promise<string>;
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.
@@ -87,4 +94,12 @@ export declare class DocumentManagementService implements IDocumentManagementCom
87
94
  includeMostRecentRevisions?: boolean;
88
95
  includeRemoved?: boolean;
89
96
  }, cursor?: string, userIdentity?: string, nodeIdentity?: string): Promise<IDocumentList>;
97
+ /**
98
+ * Create an attestation for the document.
99
+ * @param document The document to create the attestation for.
100
+ * @param userIdentity The identity to perform the attestation operation with.
101
+ * @param nodeIdentity The node identity to perform attestation operation with.
102
+ * @returns The attestation identifier.
103
+ */
104
+ private createAttestation;
90
105
  }
package/docs/changelog.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # @twin.org/document-management-service - Changelog
2
2
 
3
- ## v0.0.1-next.2
3
+ ## v0.0.1-next.5
4
4
 
5
5
  - Initial Release
@@ -249,7 +249,9 @@
249
249
  "@context": "https://schema.org",
250
250
  "@type": "DigitalDocument",
251
251
  "name": "myfile.pdf"
252
- }
252
+ },
253
+ "nodeIdentity": "did:entity-storage:0x6363636363636363636363636363636363636363636363636363636363636363",
254
+ "userIdentity": "did:entity-storage:0x6363636363636363636363636363636363636363636363636363636363636363"
253
255
  }
254
256
  ]
255
257
  }
@@ -288,7 +290,9 @@
288
290
  "@context": "https://schema.org",
289
291
  "@type": "DigitalDocument",
290
292
  "name": "myfile.pdf"
291
- }
293
+ },
294
+ "nodeIdentity": "did:entity-storage:0x6363636363636363636363636363636363636363636363636363636363636363",
295
+ "userIdentity": "did:entity-storage:0x6363636363636363636363636363636363636363636363636363636363636363"
292
296
  }
293
297
  ]
294
298
  }
@@ -485,7 +489,9 @@
485
489
  "@context": "https://schema.org",
486
490
  "@type": "DigitalDocument",
487
491
  "name": "myfile.pdf"
488
- }
492
+ },
493
+ "nodeIdentity": "did:entity-storage:0x6363636363636363636363636363636363636363636363636363636363636363",
494
+ "userIdentity": "did:entity-storage:0x6363636363636363636363636363636363636363636363636363636363636363"
489
495
  }
490
496
  }
491
497
  }
@@ -515,7 +521,9 @@
515
521
  "@context": "https://schema.org",
516
522
  "@type": "DigitalDocument",
517
523
  "name": "myfile.pdf"
518
- }
524
+ },
525
+ "nodeIdentity": "did:entity-storage:0x6363636363636363636363636363636363636363636363636363636363636363",
526
+ "userIdentity": "did:entity-storage:0x6363636363636363636363636363636363636363636363636363636363636363"
519
527
  }
520
528
  }
521
529
  }
@@ -965,6 +973,14 @@
965
973
  "type": "string",
966
974
  "description": "The date/time of when the document was deleted, as we never actually remove items."
967
975
  },
976
+ "nodeIdentity": {
977
+ "type": "string",
978
+ "description": "The node which added the document to the graph."
979
+ },
980
+ "userIdentity": {
981
+ "type": "string",
982
+ "description": "The user who added the document to the graph."
983
+ },
968
984
  "revisions": {
969
985
  "type": "array",
970
986
  "items": {
@@ -986,7 +1002,9 @@
986
1002
  "documentRevision",
987
1003
  "blobStorageId",
988
1004
  "blobHash",
989
- "dateCreated"
1005
+ "dateCreated",
1006
+ "nodeIdentity",
1007
+ "userIdentity"
990
1008
  ],
991
1009
  "additionalProperties": false,
992
1010
  "description": "Interface describing a document."
@@ -1061,6 +1079,13 @@
1061
1079
  "createAttestation": {
1062
1080
  "type": "boolean",
1063
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"
1064
1089
  }
1065
1090
  },
1066
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`?, `createAttestation`?, `userIdentity`?, `nodeIdentity`?): `Promise`\<`string`\>
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
- ##### createAttestation?
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.2",
3
+ "version": "0.0.1-next.5",
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.2",
24
+ "@twin.org/document-management-models": "0.0.1-next.5",
25
25
  "@twin.org/entity": "next",
26
26
  "@twin.org/entity-storage-models": "next",
27
27
  "@twin.org/nameof": "next",