@twin.org/document-management-service 0.0.1-next.13 → 0.0.1-next.15

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.
@@ -147,9 +147,13 @@ function generateRestRoutesDocumentManagement(baseRouteName, componentName) {
147
147
  id: "DocumentManagementGetResponseExample",
148
148
  response: {
149
149
  body: {
150
- "@context": [documentManagementModels.DocumentContexts.ContextRoot, documentManagementModels.DocumentContexts.ContextRootCommon],
151
- type: documentManagementModels.DocumentTypes.DocumentList,
152
- documents: [
150
+ "@context": [
151
+ standardsSchemaOrg.SchemaOrgContexts.ContextRoot,
152
+ documentManagementModels.DocumentContexts.ContextRoot,
153
+ documentManagementModels.DocumentContexts.ContextRootCommon
154
+ ],
155
+ type: standardsSchemaOrg.SchemaOrgTypes.ItemList,
156
+ [standardsSchemaOrg.SchemaOrgTypes.ItemListElement]: [
153
157
  {
154
158
  "@context": [
155
159
  documentManagementModels.DocumentContexts.ContextRoot,
@@ -187,9 +191,13 @@ function generateRestRoutesDocumentManagement(baseRouteName, componentName) {
187
191
  id: "DocumentManagementGetResponseExample",
188
192
  response: {
189
193
  body: {
190
- "@context": [documentManagementModels.DocumentContexts.ContextRoot, documentManagementModels.DocumentContexts.ContextRootCommon],
191
- type: documentManagementModels.DocumentTypes.DocumentList,
192
- documents: [
194
+ "@context": [
195
+ standardsSchemaOrg.SchemaOrgContexts.ContextRoot,
196
+ documentManagementModels.DocumentContexts.ContextRoot,
197
+ documentManagementModels.DocumentContexts.ContextRootCommon
198
+ ],
199
+ type: standardsSchemaOrg.SchemaOrgTypes.ItemList,
200
+ [standardsSchemaOrg.SchemaOrgTypes.ItemListElement]: [
193
201
  {
194
202
  "@context": [
195
203
  documentManagementModels.DocumentContexts.ContextRoot,
@@ -376,9 +384,9 @@ function generateRestRoutesDocumentManagement(baseRouteName, componentName) {
376
384
  id: "DocumentManagementQueryResponseExample",
377
385
  response: {
378
386
  body: {
379
- "@context": [auditableItemGraphModels.AuditableItemGraphContexts.ContextRoot],
380
- type: auditableItemGraphModels.AuditableItemGraphTypes.VertexList,
381
- vertices: [
387
+ "@context": [standardsSchemaOrg.SchemaOrgContexts.ContextRoot, auditableItemGraphModels.AuditableItemGraphContexts.ContextRoot],
388
+ type: standardsSchemaOrg.SchemaOrgTypes.ItemList,
389
+ [standardsSchemaOrg.SchemaOrgTypes.ItemListElement]: [
382
390
  {
383
391
  "@context": [
384
392
  auditableItemGraphModels.AuditableItemGraphContexts.ContextRoot,
@@ -735,7 +743,7 @@ class DocumentManagementService {
735
743
  throw new core.NotFoundError(this.CLASS_NAME, "documentRevisionNone");
736
744
  }
737
745
  const documents = await this.getDocumentsFromVertex(documentVertex);
738
- const latestRevision = documents.documents[0];
746
+ const latestRevision = documents.itemListElement[0];
739
747
  documentVertex.resources = documentVertex.resources.filter(r => core.Is.empty(r.dateDeleted));
740
748
  if (core.Is.empty(latestRevision)) {
741
749
  throw new core.NotFoundError(this.CLASS_NAME, "documentRevisionNone");
@@ -869,7 +877,7 @@ class DocumentManagementService {
869
877
  }
870
878
  // Populate the document and revisions with the options set
871
879
  const docList = await this.getDocumentsFromVertex(documentVertex, options, undefined, undefined, userIdentity, nodeIdentity);
872
- return dataJsonLd.JsonLdProcessor.compact(docList.documents[0], docList.documents[0]["@context"]);
880
+ return dataJsonLd.JsonLdProcessor.compact(docList.itemListElement[0], docList.itemListElement[0]["@context"]);
873
881
  }
874
882
  catch (error) {
875
883
  if (core.BaseError.someErrorName(error, "NotFoundError")) {
@@ -1102,12 +1110,12 @@ class DocumentManagementService {
1102
1110
  async getDocumentsFromVertex(documentVertex, options, cursor, pageSize, userIdentity, nodeIdentity) {
1103
1111
  const docList = {
1104
1112
  "@context": [
1113
+ standardsSchemaOrg.SchemaOrgContexts.ContextRoot,
1105
1114
  documentManagementModels.DocumentContexts.ContextRoot,
1106
- documentManagementModels.DocumentContexts.ContextRootCommon,
1107
- standardsSchemaOrg.SchemaOrgContexts.ContextRoot
1115
+ documentManagementModels.DocumentContexts.ContextRootCommon
1108
1116
  ],
1109
- type: documentManagementModels.DocumentTypes.DocumentList,
1110
- documents: []
1117
+ type: standardsSchemaOrg.SchemaOrgTypes.ItemList,
1118
+ [standardsSchemaOrg.SchemaOrgTypes.ItemListElement]: []
1111
1119
  };
1112
1120
  if (core.Is.arrayValue(documentVertex.resources)) {
1113
1121
  // Sort by newest revision first
@@ -1116,7 +1124,7 @@ class DocumentManagementService {
1116
1124
  const startIndex = core.Coerce.integer(cursor) ?? 0;
1117
1125
  const endIndex = Math.min(startIndex + (pageSize ?? 1), documentVertex.resources.length);
1118
1126
  const slicedResources = documentVertex.resources.slice(startIndex, endIndex);
1119
- docList.cursor =
1127
+ docList[standardsSchemaOrg.SchemaOrgTypes.NextItem] =
1120
1128
  documentVertex.resources.length > endIndex ? (endIndex + 1).toString() : undefined;
1121
1129
  const includeBlobStorageMetadata = options?.includeBlobStorageMetadata ?? false;
1122
1130
  const includeBlobStorageData = options?.includeBlobStorageData ?? false;
@@ -1126,7 +1134,7 @@ class DocumentManagementService {
1126
1134
  const document = slicedResources[i].resourceObject;
1127
1135
  if (core.Is.object(document)) {
1128
1136
  document.dateDeleted = slicedResources[i].dateDeleted;
1129
- docList.documents.push(document);
1137
+ docList[standardsSchemaOrg.SchemaOrgTypes.ItemListElement].push(document);
1130
1138
  const blobRequired = includeBlobStorageMetadata || includeBlobStorageData;
1131
1139
  if (blobRequired || extractData) {
1132
1140
  const blobEntry = await this._blobStorageComponent.get(document.blobStorageId, includeBlobStorageData || extractData, userIdentity, nodeIdentity);
@@ -1,7 +1,7 @@
1
1
  import { AuditableItemGraphTypes, AuditableItemGraphContexts } from '@twin.org/auditable-item-graph-models';
2
2
  import { Guards, ComponentFactory, Converter, Coerce, Is, BaseError, GeneralError, Urn, NotFoundError, ObjectHelper } from '@twin.org/core';
3
3
  import { DocumentTypes, DocumentContexts } from '@twin.org/document-management-models';
4
- import { SchemaOrgContexts, SchemaOrgDataTypes } from '@twin.org/standards-schema-org';
4
+ import { SchemaOrgContexts, SchemaOrgTypes, 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
7
  import { AttestationContexts } from '@twin.org/attestation-models';
@@ -145,9 +145,13 @@ function generateRestRoutesDocumentManagement(baseRouteName, componentName) {
145
145
  id: "DocumentManagementGetResponseExample",
146
146
  response: {
147
147
  body: {
148
- "@context": [DocumentContexts.ContextRoot, DocumentContexts.ContextRootCommon],
149
- type: DocumentTypes.DocumentList,
150
- documents: [
148
+ "@context": [
149
+ SchemaOrgContexts.ContextRoot,
150
+ DocumentContexts.ContextRoot,
151
+ DocumentContexts.ContextRootCommon
152
+ ],
153
+ type: SchemaOrgTypes.ItemList,
154
+ [SchemaOrgTypes.ItemListElement]: [
151
155
  {
152
156
  "@context": [
153
157
  DocumentContexts.ContextRoot,
@@ -185,9 +189,13 @@ function generateRestRoutesDocumentManagement(baseRouteName, componentName) {
185
189
  id: "DocumentManagementGetResponseExample",
186
190
  response: {
187
191
  body: {
188
- "@context": [DocumentContexts.ContextRoot, DocumentContexts.ContextRootCommon],
189
- type: DocumentTypes.DocumentList,
190
- documents: [
192
+ "@context": [
193
+ SchemaOrgContexts.ContextRoot,
194
+ DocumentContexts.ContextRoot,
195
+ DocumentContexts.ContextRootCommon
196
+ ],
197
+ type: SchemaOrgTypes.ItemList,
198
+ [SchemaOrgTypes.ItemListElement]: [
191
199
  {
192
200
  "@context": [
193
201
  DocumentContexts.ContextRoot,
@@ -374,9 +382,9 @@ function generateRestRoutesDocumentManagement(baseRouteName, componentName) {
374
382
  id: "DocumentManagementQueryResponseExample",
375
383
  response: {
376
384
  body: {
377
- "@context": [AuditableItemGraphContexts.ContextRoot],
378
- type: AuditableItemGraphTypes.VertexList,
379
- vertices: [
385
+ "@context": [SchemaOrgContexts.ContextRoot, AuditableItemGraphContexts.ContextRoot],
386
+ type: SchemaOrgTypes.ItemList,
387
+ [SchemaOrgTypes.ItemListElement]: [
380
388
  {
381
389
  "@context": [
382
390
  AuditableItemGraphContexts.ContextRoot,
@@ -733,7 +741,7 @@ class DocumentManagementService {
733
741
  throw new NotFoundError(this.CLASS_NAME, "documentRevisionNone");
734
742
  }
735
743
  const documents = await this.getDocumentsFromVertex(documentVertex);
736
- const latestRevision = documents.documents[0];
744
+ const latestRevision = documents.itemListElement[0];
737
745
  documentVertex.resources = documentVertex.resources.filter(r => Is.empty(r.dateDeleted));
738
746
  if (Is.empty(latestRevision)) {
739
747
  throw new NotFoundError(this.CLASS_NAME, "documentRevisionNone");
@@ -867,7 +875,7 @@ class DocumentManagementService {
867
875
  }
868
876
  // Populate the document and revisions with the options set
869
877
  const docList = await this.getDocumentsFromVertex(documentVertex, options, undefined, undefined, userIdentity, nodeIdentity);
870
- return JsonLdProcessor.compact(docList.documents[0], docList.documents[0]["@context"]);
878
+ return JsonLdProcessor.compact(docList.itemListElement[0], docList.itemListElement[0]["@context"]);
871
879
  }
872
880
  catch (error) {
873
881
  if (BaseError.someErrorName(error, "NotFoundError")) {
@@ -1100,12 +1108,12 @@ class DocumentManagementService {
1100
1108
  async getDocumentsFromVertex(documentVertex, options, cursor, pageSize, userIdentity, nodeIdentity) {
1101
1109
  const docList = {
1102
1110
  "@context": [
1111
+ SchemaOrgContexts.ContextRoot,
1103
1112
  DocumentContexts.ContextRoot,
1104
- DocumentContexts.ContextRootCommon,
1105
- SchemaOrgContexts.ContextRoot
1113
+ DocumentContexts.ContextRootCommon
1106
1114
  ],
1107
- type: DocumentTypes.DocumentList,
1108
- documents: []
1115
+ type: SchemaOrgTypes.ItemList,
1116
+ [SchemaOrgTypes.ItemListElement]: []
1109
1117
  };
1110
1118
  if (Is.arrayValue(documentVertex.resources)) {
1111
1119
  // Sort by newest revision first
@@ -1114,7 +1122,7 @@ class DocumentManagementService {
1114
1122
  const startIndex = Coerce.integer(cursor) ?? 0;
1115
1123
  const endIndex = Math.min(startIndex + (pageSize ?? 1), documentVertex.resources.length);
1116
1124
  const slicedResources = documentVertex.resources.slice(startIndex, endIndex);
1117
- docList.cursor =
1125
+ docList[SchemaOrgTypes.NextItem] =
1118
1126
  documentVertex.resources.length > endIndex ? (endIndex + 1).toString() : undefined;
1119
1127
  const includeBlobStorageMetadata = options?.includeBlobStorageMetadata ?? false;
1120
1128
  const includeBlobStorageData = options?.includeBlobStorageData ?? false;
@@ -1124,7 +1132,7 @@ class DocumentManagementService {
1124
1132
  const document = slicedResources[i].resourceObject;
1125
1133
  if (Is.object(document)) {
1126
1134
  document.dateDeleted = slicedResources[i].dateDeleted;
1127
- docList.documents.push(document);
1135
+ docList[SchemaOrgTypes.ItemListElement].push(document);
1128
1136
  const blobRequired = includeBlobStorageMetadata || includeBlobStorageData;
1129
1137
  if (blobRequired || extractData) {
1130
1138
  const blobEntry = await this._blobStorageComponent.get(document.blobStorageId, includeBlobStorageData || extractData, userIdentity, nodeIdentity);
package/docs/changelog.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # @twin.org/document-management-service - Changelog
2
2
 
3
+ ## [0.0.1-next.15](https://github.com/twinfoundation/document-management/compare/document-management-service-v0.0.1-next.14...document-management-service-v0.0.1-next.15) (2025-05-28)
4
+
5
+
6
+ ### Miscellaneous Chores
7
+
8
+ * **document-management-service:** Synchronize repo versions
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/document-management-models bumped from 0.0.1-next.14 to 0.0.1-next.15
16
+
17
+ ## [0.0.1-next.14](https://github.com/twinfoundation/document-management/compare/document-management-service-v0.0.1-next.13...document-management-service-v0.0.1-next.14) (2025-05-08)
18
+
19
+
20
+ ### Features
21
+
22
+ * use standard list json ld types ([20ea04b](https://github.com/twinfoundation/document-management/commit/20ea04b05fd4bc4fcedce8f66958942c3c2fa303))
23
+
24
+
25
+ ### Dependencies
26
+
27
+ * The following workspace dependencies were updated
28
+ * dependencies
29
+ * @twin.org/document-management-models bumped from 0.0.1-next.13 to 0.0.1-next.14
30
+
3
31
  ## [0.0.1-next.13](https://github.com/twinfoundation/document-management/compare/document-management-service-v0.0.1-next.12...document-management-service-v0.0.1-next.13) (2025-04-30)
4
32
 
5
33
 
@@ -193,10 +193,11 @@
193
193
  "DocumentManagementQueryResponseExample": {
194
194
  "value": {
195
195
  "@context": [
196
+ "https://schema.org",
196
197
  "https://schema.twindev.org/aig/"
197
198
  ],
198
- "type": "AuditableItemGraphVertexList",
199
- "vertices": [
199
+ "type": "ItemList",
200
+ "itemListElement": [
200
201
  {
201
202
  "@context": [
202
203
  "https://schema.twindev.org/aig/",
@@ -540,11 +541,12 @@
540
541
  "DocumentManagementGetResponseExample": {
541
542
  "value": {
542
543
  "@context": [
544
+ "https://schema.org",
543
545
  "https://schema.twindev.org/documents/",
544
546
  "https://schema.twindev.org/common/"
545
547
  ],
546
- "type": "DocumentList",
547
- "documents": [
548
+ "type": "ItemList",
549
+ "itemListElement": [
548
550
  {
549
551
  "@context": [
550
552
  "https://schema.twindev.org/documents/",
@@ -581,11 +583,12 @@
581
583
  "DocumentManagementGetResponseExample": {
582
584
  "value": {
583
585
  "@context": [
586
+ "https://schema.org",
584
587
  "https://schema.twindev.org/documents/",
585
588
  "https://schema.twindev.org/common/"
586
589
  ],
587
- "type": "DocumentList",
588
- "documents": [
590
+ "type": "ItemList",
591
+ "itemListElement": [
589
592
  {
590
593
  "@context": [
591
594
  "https://schema.twindev.org/documents/",
@@ -1488,40 +1491,36 @@
1488
1491
  "type": "object",
1489
1492
  "properties": {
1490
1493
  "@context": {
1491
- "anyOf": [
1494
+ "type": "array",
1495
+ "minItems": 2,
1496
+ "items": [
1492
1497
  {
1493
1498
  "type": "string",
1494
- "const": "https://schema.twindev.org/aig/"
1499
+ "const": "https://schema.org"
1495
1500
  },
1496
1501
  {
1497
- "type": "array",
1498
- "minItems": 1,
1499
- "items": [
1500
- {
1501
- "type": "string",
1502
- "const": "https://schema.twindev.org/aig/"
1503
- }
1504
- ],
1505
- "additionalItems": {
1506
- "$ref": "#/components/schemas/JsonLdContextDefinitionElement"
1507
- }
1502
+ "type": "string",
1503
+ "const": "https://schema.twindev.org/aig/"
1508
1504
  }
1509
1505
  ],
1506
+ "additionalItems": {
1507
+ "$ref": "#/components/schemas/JsonLdContextDefinitionElement"
1508
+ },
1510
1509
  "description": "JSON-LD Context."
1511
1510
  },
1512
1511
  "type": {
1513
1512
  "type": "string",
1514
- "const": "AuditableItemGraphVertexList",
1513
+ "const": "ItemList",
1515
1514
  "description": "JSON-LD Type."
1516
1515
  },
1517
- "vertices": {
1516
+ "itemListElement": {
1518
1517
  "type": "array",
1519
1518
  "items": {
1520
1519
  "$ref": "#/components/schemas/AuditableItemGraphVertex"
1521
1520
  },
1522
1521
  "description": "The list of vertices."
1523
1522
  },
1524
- "cursor": {
1523
+ "nextItem": {
1525
1524
  "type": "string",
1526
1525
  "description": "The cursor to get the next chunk of vertices."
1527
1526
  }
@@ -1529,7 +1528,7 @@
1529
1528
  "required": [
1530
1529
  "@context",
1531
1530
  "type",
1532
- "vertices"
1531
+ "itemListElement"
1533
1532
  ],
1534
1533
  "additionalProperties": false,
1535
1534
  "description": "Interface describing an auditable item graph vertex list."
@@ -1722,8 +1721,12 @@
1722
1721
  "properties": {
1723
1722
  "@context": {
1724
1723
  "type": "array",
1725
- "minItems": 2,
1724
+ "minItems": 3,
1726
1725
  "items": [
1726
+ {
1727
+ "type": "string",
1728
+ "const": "https://schema.org"
1729
+ },
1727
1730
  {
1728
1731
  "type": "string",
1729
1732
  "const": "https://schema.twindev.org/documents/"
@@ -1740,10 +1743,10 @@
1740
1743
  },
1741
1744
  "type": {
1742
1745
  "type": "string",
1743
- "const": "DocumentList",
1746
+ "const": "ItemList",
1744
1747
  "description": "JSON-LD Type."
1745
1748
  },
1746
- "documents": {
1749
+ "itemListElement": {
1747
1750
  "type": "array",
1748
1751
  "items": {
1749
1752
  "$ref": "#/components/schemas/Document"
@@ -1757,7 +1760,7 @@
1757
1760
  },
1758
1761
  "description": "The ids of the other vertices which are connected to the document."
1759
1762
  },
1760
- "cursor": {
1763
+ "nextItem": {
1761
1764
  "type": "string",
1762
1765
  "description": "The cursor to get the next chunk of documents."
1763
1766
  }
@@ -1765,7 +1768,7 @@
1765
1768
  "required": [
1766
1769
  "@context",
1767
1770
  "type",
1768
- "documents"
1771
+ "itemListElement"
1769
1772
  ],
1770
1773
  "additionalProperties": false,
1771
1774
  "description": "Interface describing a list of document entries."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/document-management-service",
3
- "version": "0.0.1-next.13",
3
+ "version": "0.0.1-next.15",
4
4
  "description": "Document management contract implementation and REST endpoint definitions",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,7 +22,7 @@
22
22
  "@twin.org/crypto": "next",
23
23
  "@twin.org/data-json-ld": "next",
24
24
  "@twin.org/data-processing-models": "next",
25
- "@twin.org/document-management-models": "0.0.1-next.13",
25
+ "@twin.org/document-management-models": "0.0.1-next.15",
26
26
  "@twin.org/entity": "next",
27
27
  "@twin.org/entity-storage-models": "next",
28
28
  "@twin.org/nameof": "next",