@twin.org/document-management-service 0.0.2-next.1 → 0.0.2-next.3

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.
@@ -657,7 +657,7 @@ class DocumentManagementService {
657
657
  const connectedVertices = {};
658
658
  if (core.Is.arrayValue(auditableItemGraphEdges)) {
659
659
  for (const edge of auditableItemGraphEdges) {
660
- connectedVertices[edge.id] = await this._auditableItemGraphComponent.get(edge.id);
660
+ connectedVertices[edge.targetId] = await this._auditableItemGraphComponent.get(edge.targetId);
661
661
  }
662
662
  }
663
663
  const documentVertex = {};
@@ -750,7 +750,7 @@ class DocumentManagementService {
750
750
  if (core.Is.array(auditableItemGraphEdges)) {
751
751
  // Get the updated connected vertices first, if one fails we abort the update
752
752
  for (const edge of auditableItemGraphEdges) {
753
- connectedVertices[edge.id] = await this._auditableItemGraphComponent.get(edge.id);
753
+ connectedVertices[edge.targetId] = await this._auditableItemGraphComponent.get(edge.targetId);
754
754
  }
755
755
  // Also get the current edges in case some need disconnecting
756
756
  if (core.Is.arrayValue(documents.edges)) {
@@ -794,7 +794,7 @@ class DocumentManagementService {
794
794
  latestRevision.annotationObject = annotationObject;
795
795
  latestRevision.dateModified = new Date(Date.now()).toISOString();
796
796
  }
797
- const existingEdgeIds = documentVertex.edges?.map(e => e.id) ?? [];
797
+ const existingEdgeIds = documentVertex.edges?.map(e => e.targetId) ?? [];
798
798
  // Update the edges from the document to the items
799
799
  const edgesUpdated = this.updateEdges(documentVertex, auditableItemGraphEdges);
800
800
  if (edgesUpdated) {
@@ -947,10 +947,10 @@ class DocumentManagementService {
947
947
  */
948
948
  updateEdges(documentVertex, auditableItemGraphEdges) {
949
949
  let changed = false;
950
- const existingEdgeIds = documentVertex.edges?.map(e => e.id) ?? [];
950
+ const existingEdgeIds = documentVertex.edges?.map(e => e.targetId) ?? [];
951
951
  if (core.Is.array(auditableItemGraphEdges)) {
952
952
  for (const aigEdge of auditableItemGraphEdges) {
953
- const existingIndex = existingEdgeIds.indexOf(aigEdge.id);
953
+ const existingIndex = existingEdgeIds.indexOf(aigEdge.targetId);
954
954
  if (existingIndex !== -1) {
955
955
  // If the edge already exists then we don't need to add it again
956
956
  // We just need to remove it from the list of existing ids
@@ -961,7 +961,7 @@ class DocumentManagementService {
961
961
  const vertexEdge = {
962
962
  "@context": auditableItemGraphModels.AuditableItemGraphContexts.ContextRoot,
963
963
  type: auditableItemGraphModels.AuditableItemGraphTypes.Edge,
964
- id: aigEdge.id,
964
+ targetId: aigEdge.targetId,
965
965
  edgeRelationships: ["document"]
966
966
  };
967
967
  documentVertex.edges ??= [];
@@ -972,7 +972,7 @@ class DocumentManagementService {
972
972
  // Anything left in the existingEdgeIds array means they need to be removed
973
973
  if (existingEdgeIds.length > 0 && core.Is.array(documentVertex.edges)) {
974
974
  for (const existingEdgeId of existingEdgeIds) {
975
- const existingIndex = documentVertex.edges.findIndex(e => e.id === existingEdgeId);
975
+ const existingIndex = documentVertex.edges.findIndex(e => e.targetId === existingEdgeId);
976
976
  if (existingIndex !== -1) {
977
977
  documentVertex.edges.splice(existingIndex, 1);
978
978
  changed = true;
@@ -997,22 +997,22 @@ class DocumentManagementService {
997
997
  async updateConnectedEdges(connectedVertices, auditableItemGraphDocumentId, existingEdgeIds, auditableItemGraphEdges, documentId, documentIdFormat, userIdentity, nodeIdentity) {
998
998
  if (core.Is.array(auditableItemGraphEdges)) {
999
999
  for (const aigEdge of auditableItemGraphEdges) {
1000
- const connected = connectedVertices[aigEdge.id];
1000
+ const connected = connectedVertices[aigEdge.targetId];
1001
1001
  if (!core.Is.empty(connected)) {
1002
1002
  let updatedConnected = false;
1003
- const existingIndex = existingEdgeIds.indexOf(aigEdge.id);
1003
+ const existingIndex = existingEdgeIds.indexOf(aigEdge.targetId);
1004
1004
  if (existingIndex !== -1) {
1005
1005
  // If the edge already exists we remove it from the list of existing ids
1006
1006
  // any remaining after this loop will be need to be disconnected
1007
1007
  existingEdgeIds.splice(existingIndex, 1);
1008
1008
  }
1009
1009
  // Add the edge with the document vertex id if it doesn't already exist
1010
- const hasEdge = connected.edges?.some(e => e.id === auditableItemGraphDocumentId);
1010
+ const hasEdge = connected.edges?.some(e => e.targetId === auditableItemGraphDocumentId);
1011
1011
  if (!hasEdge) {
1012
1012
  const vertexEdge = {
1013
1013
  "@context": auditableItemGraphModels.AuditableItemGraphContexts.ContextRoot,
1014
1014
  type: auditableItemGraphModels.AuditableItemGraphTypes.Edge,
1015
- id: auditableItemGraphDocumentId,
1015
+ targetId: auditableItemGraphDocumentId,
1016
1016
  edgeRelationships: ["document"]
1017
1017
  };
1018
1018
  connected.edges ??= [];
@@ -1057,7 +1057,7 @@ class DocumentManagementService {
1057
1057
  let updatedConnected = false;
1058
1058
  // Remove the edge from the connected vertex
1059
1059
  if (core.Is.arrayValue(connected.edges)) {
1060
- const existingIndex = connected.edges.findIndex(e => e.id === auditableItemGraphDocumentId);
1060
+ const existingIndex = connected.edges.findIndex(e => e.targetId === auditableItemGraphDocumentId);
1061
1061
  if (existingIndex !== -1) {
1062
1062
  connected.edges.splice(existingIndex, 1);
1063
1063
  updatedConnected = true;
@@ -1169,7 +1169,7 @@ class DocumentManagementService {
1169
1169
  docList.edges ??= [];
1170
1170
  for (const edge of documentVertex.edges) {
1171
1171
  if (core.Is.object(edge)) {
1172
- docList.edges.push(edge.id);
1172
+ docList.edges.push(edge.targetId);
1173
1173
  }
1174
1174
  }
1175
1175
  }
@@ -655,7 +655,7 @@ class DocumentManagementService {
655
655
  const connectedVertices = {};
656
656
  if (Is.arrayValue(auditableItemGraphEdges)) {
657
657
  for (const edge of auditableItemGraphEdges) {
658
- connectedVertices[edge.id] = await this._auditableItemGraphComponent.get(edge.id);
658
+ connectedVertices[edge.targetId] = await this._auditableItemGraphComponent.get(edge.targetId);
659
659
  }
660
660
  }
661
661
  const documentVertex = {};
@@ -748,7 +748,7 @@ class DocumentManagementService {
748
748
  if (Is.array(auditableItemGraphEdges)) {
749
749
  // Get the updated connected vertices first, if one fails we abort the update
750
750
  for (const edge of auditableItemGraphEdges) {
751
- connectedVertices[edge.id] = await this._auditableItemGraphComponent.get(edge.id);
751
+ connectedVertices[edge.targetId] = await this._auditableItemGraphComponent.get(edge.targetId);
752
752
  }
753
753
  // Also get the current edges in case some need disconnecting
754
754
  if (Is.arrayValue(documents.edges)) {
@@ -792,7 +792,7 @@ class DocumentManagementService {
792
792
  latestRevision.annotationObject = annotationObject;
793
793
  latestRevision.dateModified = new Date(Date.now()).toISOString();
794
794
  }
795
- const existingEdgeIds = documentVertex.edges?.map(e => e.id) ?? [];
795
+ const existingEdgeIds = documentVertex.edges?.map(e => e.targetId) ?? [];
796
796
  // Update the edges from the document to the items
797
797
  const edgesUpdated = this.updateEdges(documentVertex, auditableItemGraphEdges);
798
798
  if (edgesUpdated) {
@@ -945,10 +945,10 @@ class DocumentManagementService {
945
945
  */
946
946
  updateEdges(documentVertex, auditableItemGraphEdges) {
947
947
  let changed = false;
948
- const existingEdgeIds = documentVertex.edges?.map(e => e.id) ?? [];
948
+ const existingEdgeIds = documentVertex.edges?.map(e => e.targetId) ?? [];
949
949
  if (Is.array(auditableItemGraphEdges)) {
950
950
  for (const aigEdge of auditableItemGraphEdges) {
951
- const existingIndex = existingEdgeIds.indexOf(aigEdge.id);
951
+ const existingIndex = existingEdgeIds.indexOf(aigEdge.targetId);
952
952
  if (existingIndex !== -1) {
953
953
  // If the edge already exists then we don't need to add it again
954
954
  // We just need to remove it from the list of existing ids
@@ -959,7 +959,7 @@ class DocumentManagementService {
959
959
  const vertexEdge = {
960
960
  "@context": AuditableItemGraphContexts.ContextRoot,
961
961
  type: AuditableItemGraphTypes.Edge,
962
- id: aigEdge.id,
962
+ targetId: aigEdge.targetId,
963
963
  edgeRelationships: ["document"]
964
964
  };
965
965
  documentVertex.edges ??= [];
@@ -970,7 +970,7 @@ class DocumentManagementService {
970
970
  // Anything left in the existingEdgeIds array means they need to be removed
971
971
  if (existingEdgeIds.length > 0 && Is.array(documentVertex.edges)) {
972
972
  for (const existingEdgeId of existingEdgeIds) {
973
- const existingIndex = documentVertex.edges.findIndex(e => e.id === existingEdgeId);
973
+ const existingIndex = documentVertex.edges.findIndex(e => e.targetId === existingEdgeId);
974
974
  if (existingIndex !== -1) {
975
975
  documentVertex.edges.splice(existingIndex, 1);
976
976
  changed = true;
@@ -995,22 +995,22 @@ class DocumentManagementService {
995
995
  async updateConnectedEdges(connectedVertices, auditableItemGraphDocumentId, existingEdgeIds, auditableItemGraphEdges, documentId, documentIdFormat, userIdentity, nodeIdentity) {
996
996
  if (Is.array(auditableItemGraphEdges)) {
997
997
  for (const aigEdge of auditableItemGraphEdges) {
998
- const connected = connectedVertices[aigEdge.id];
998
+ const connected = connectedVertices[aigEdge.targetId];
999
999
  if (!Is.empty(connected)) {
1000
1000
  let updatedConnected = false;
1001
- const existingIndex = existingEdgeIds.indexOf(aigEdge.id);
1001
+ const existingIndex = existingEdgeIds.indexOf(aigEdge.targetId);
1002
1002
  if (existingIndex !== -1) {
1003
1003
  // If the edge already exists we remove it from the list of existing ids
1004
1004
  // any remaining after this loop will be need to be disconnected
1005
1005
  existingEdgeIds.splice(existingIndex, 1);
1006
1006
  }
1007
1007
  // Add the edge with the document vertex id if it doesn't already exist
1008
- const hasEdge = connected.edges?.some(e => e.id === auditableItemGraphDocumentId);
1008
+ const hasEdge = connected.edges?.some(e => e.targetId === auditableItemGraphDocumentId);
1009
1009
  if (!hasEdge) {
1010
1010
  const vertexEdge = {
1011
1011
  "@context": AuditableItemGraphContexts.ContextRoot,
1012
1012
  type: AuditableItemGraphTypes.Edge,
1013
- id: auditableItemGraphDocumentId,
1013
+ targetId: auditableItemGraphDocumentId,
1014
1014
  edgeRelationships: ["document"]
1015
1015
  };
1016
1016
  connected.edges ??= [];
@@ -1055,7 +1055,7 @@ class DocumentManagementService {
1055
1055
  let updatedConnected = false;
1056
1056
  // Remove the edge from the connected vertex
1057
1057
  if (Is.arrayValue(connected.edges)) {
1058
- const existingIndex = connected.edges.findIndex(e => e.id === auditableItemGraphDocumentId);
1058
+ const existingIndex = connected.edges.findIndex(e => e.targetId === auditableItemGraphDocumentId);
1059
1059
  if (existingIndex !== -1) {
1060
1060
  connected.edges.splice(existingIndex, 1);
1061
1061
  updatedConnected = true;
@@ -1167,7 +1167,7 @@ class DocumentManagementService {
1167
1167
  docList.edges ??= [];
1168
1168
  for (const edge of documentVertex.edges) {
1169
1169
  if (Is.object(edge)) {
1170
- docList.edges.push(edge.id);
1170
+ docList.edges.push(edge.targetId);
1171
1171
  }
1172
1172
  }
1173
1173
  }
@@ -35,7 +35,7 @@ export declare class DocumentManagementService implements IDocumentManagementCom
35
35
  * @returns The auditable item graph vertex created for the document including its revision.
36
36
  */
37
37
  create(documentId: string, documentIdFormat: string | undefined, documentCode: UneceDocumentCodes, blob: Uint8Array, annotationObject?: IJsonLdNodeObject, auditableItemGraphEdges?: {
38
- id: string;
38
+ targetId: string;
39
39
  addAlias?: boolean;
40
40
  aliasAnnotationObject?: IJsonLdNodeObject;
41
41
  }[], options?: {
@@ -56,7 +56,7 @@ export declare class DocumentManagementService implements IDocumentManagementCom
56
56
  * @returns Nothing.
57
57
  */
58
58
  update(auditableItemGraphDocumentId: string, blob?: Uint8Array, annotationObject?: IJsonLdNodeObject, auditableItemGraphEdges?: {
59
- id: string;
59
+ targetId: string;
60
60
  addAlias?: boolean;
61
61
  aliasAnnotationObject?: IJsonLdNodeObject;
62
62
  }[], userIdentity?: string, nodeIdentity?: string): Promise<void>;
package/docs/changelog.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # @twin.org/document-management-service - Changelog
2
2
 
3
+ ## [0.0.2-next.3](https://github.com/twinfoundation/document-management/compare/document-management-service-v0.0.2-next.2...document-management-service-v0.0.2-next.3) (2025-09-29)
4
+
5
+
6
+ ### Features
7
+
8
+ * use targetId in AIG for edges ([82dec81](https://github.com/twinfoundation/document-management/commit/82dec8190d8b523b350ef133bdcf648cab1023b0))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/document-management-models bumped from 0.0.2-next.2 to 0.0.2-next.3
16
+
17
+ ## [0.0.2-next.2](https://github.com/twinfoundation/document-management/compare/document-management-service-v0.0.2-next.1...document-management-service-v0.0.2-next.2) (2025-08-29)
18
+
19
+
20
+ ### Features
21
+
22
+ * eslint migration to flat config ([98635aa](https://github.com/twinfoundation/document-management/commit/98635aa24ebafba265e989e461fe98104f683191))
23
+
24
+
25
+ ### Dependencies
26
+
27
+ * The following workspace dependencies were updated
28
+ * dependencies
29
+ * @twin.org/document-management-models bumped from 0.0.2-next.1 to 0.0.2-next.2
30
+
3
31
  ## [0.0.2-next.1](https://github.com/twinfoundation/document-management/compare/document-management-service-v0.0.2-next.0...document-management-service-v0.0.2-next.1) (2025-08-21)
4
32
 
5
33
 
@@ -1203,20 +1203,6 @@
1203
1203
  "additionalProperties": false,
1204
1204
  "description": "Interface describing a list of document entries."
1205
1205
  },
1206
- "DocumentManagementComponent": {
1207
- "type": "object",
1208
- "additionalProperties": false,
1209
- "properties": {
1210
- "CLASS_NAME": {
1211
- "type": "string",
1212
- "description": "The name of the component."
1213
- }
1214
- },
1215
- "required": [
1216
- "CLASS_NAME"
1217
- ],
1218
- "description": "Interface describing an document management contract."
1219
- },
1220
1206
  "DocumentManagementCreateRequest": {
1221
1207
  "type": "object",
1222
1208
  "properties": {
@@ -1246,7 +1232,7 @@
1246
1232
  {
1247
1233
  "type": "object",
1248
1234
  "properties": {
1249
- "id": {
1235
+ "targetId": {
1250
1236
  "type": "string"
1251
1237
  },
1252
1238
  "addAlias": {
@@ -1257,7 +1243,7 @@
1257
1243
  }
1258
1244
  },
1259
1245
  "required": [
1260
- "id"
1246
+ "targetId"
1261
1247
  ],
1262
1248
  "additionalProperties": false
1263
1249
  }
@@ -1283,41 +1269,6 @@
1283
1269
  "additionalProperties": false,
1284
1270
  "description": "The body parameters."
1285
1271
  },
1286
- "DocumentManagementServiceConfig": {
1287
- "type": "object",
1288
- "additionalProperties": false,
1289
- "description": "Configuration for the document management service."
1290
- },
1291
- "DocumentManagementServiceConstructorOptions": {
1292
- "type": "object",
1293
- "properties": {
1294
- "auditableItemGraphComponentType": {
1295
- "type": "string",
1296
- "description": "The type of the auditable item graph component.",
1297
- "default": "auditable-item-graph"
1298
- },
1299
- "blobStorageComponentType": {
1300
- "type": "string",
1301
- "description": "The type of the blob storage component.",
1302
- "default": "blob-storage"
1303
- },
1304
- "attestationComponentType": {
1305
- "type": "string",
1306
- "description": "The type of the attestation component.",
1307
- "default": "attestation"
1308
- },
1309
- "dataProcessingComponentType": {
1310
- "type": "string",
1311
- "description": "The type of the data processing component.",
1312
- "default": "data-processing"
1313
- },
1314
- "config": {
1315
- "$ref": "#/components/schemas/DocumentManagementServiceConfig"
1316
- }
1317
- },
1318
- "additionalProperties": false,
1319
- "description": "Options for the document management Service constructor."
1320
- },
1321
1272
  "DocumentManagementUpdateRequest": {
1322
1273
  "type": "object",
1323
1274
  "properties": {
@@ -1336,7 +1287,7 @@
1336
1287
  {
1337
1288
  "type": "object",
1338
1289
  "properties": {
1339
- "id": {
1290
+ "targetId": {
1340
1291
  "type": "string"
1341
1292
  },
1342
1293
  "addAlias": {
@@ -1347,7 +1298,7 @@
1347
1298
  }
1348
1299
  },
1349
1300
  "required": [
1350
- "id"
1301
+ "targetId"
1351
1302
  ],
1352
1303
  "additionalProperties": false
1353
1304
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/document-management-service",
3
- "version": "0.0.2-next.1",
3
+ "version": "0.0.2-next.3",
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.2-next.1",
25
+ "@twin.org/document-management-models": "0.0.2-next.3",
26
26
  "@twin.org/entity": "next",
27
27
  "@twin.org/entity-storage-models": "next",
28
28
  "@twin.org/nameof": "next",