@twin.org/document-management-service 0.0.2-next.2 → 0.0.2-next.4

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.
@@ -494,7 +494,7 @@ async function documentManagementGet(httpRequestContext, componentName, request)
494
494
  includeRemoved: core.Coerce.boolean(request.query?.includeRemoved),
495
495
  extractRuleGroupId: request.query?.extractRuleGroupId,
496
496
  extractMimeType: request.query?.extractMimeType
497
- }, request.query?.cursor, core.Coerce.integer(request.query?.pageSize), httpRequestContext.userIdentity, httpRequestContext.nodeIdentity);
497
+ }, request.query?.cursor, core.Coerce.integer(request.query?.limit), httpRequestContext.userIdentity, httpRequestContext.nodeIdentity);
498
498
  return {
499
499
  headers: {
500
500
  [web.HeaderTypes.ContentType]: mimeType === "json" ? web.MimeTypes.Json : web.MimeTypes.JsonLd
@@ -580,7 +580,7 @@ async function documentManagementQuery(httpRequestContext, componentName, reques
580
580
  core.Guards.stringValue(ROUTES_SOURCE, "request.query.documentId", request.query.documentId);
581
581
  const mimeType = request.headers?.[web.HeaderTypes.Accept] === web.MimeTypes.JsonLd ? "jsonld" : "json";
582
582
  const component = core.ComponentFactory.get(componentName);
583
- const result = await component.query(request.query.documentId, request.query?.cursor, core.Coerce.integer(request.query?.pageSize), httpRequestContext.userIdentity, httpRequestContext.nodeIdentity);
583
+ const result = await component.query(request.query.documentId, request.query?.cursor, core.Coerce.integer(request.query?.limit), httpRequestContext.userIdentity, httpRequestContext.nodeIdentity);
584
584
  return {
585
585
  headers: {
586
586
  [web.HeaderTypes.ContentType]: mimeType === "json" ? web.MimeTypes.Json : web.MimeTypes.JsonLd
@@ -596,7 +596,7 @@ class DocumentManagementService {
596
596
  /**
597
597
  * Runtime name for the class.
598
598
  */
599
- CLASS_NAME = "DocumentManagementService";
599
+ static CLASS_NAME = "DocumentManagementService";
600
600
  /**
601
601
  * The component for the auditable item graph.
602
602
  * @internal
@@ -647,17 +647,17 @@ class DocumentManagementService {
647
647
  * @returns The auditable item graph vertex created for the document including its revision.
648
648
  */
649
649
  async create(documentId, documentIdFormat, documentCode, blob, annotationObject, auditableItemGraphEdges, options, userIdentity, nodeIdentity) {
650
- core.Guards.stringValue(this.CLASS_NAME, "documentId", documentId);
651
- core.Guards.arrayOneOf(this.CLASS_NAME, "documentCode", documentCode, Object.values(standardsUnece.UneceDocumentCodes));
652
- core.Guards.uint8Array(this.CLASS_NAME, "blob", blob);
653
- core.Guards.stringValue(this.CLASS_NAME, "userIdentity", userIdentity);
654
- core.Guards.stringValue(this.CLASS_NAME, "nodeIdentity", nodeIdentity);
650
+ core.Guards.stringValue(DocumentManagementService.CLASS_NAME, "documentId", documentId);
651
+ core.Guards.arrayOneOf(DocumentManagementService.CLASS_NAME, "documentCode", documentCode, Object.values(standardsUnece.UneceDocumentCodes));
652
+ core.Guards.uint8Array(DocumentManagementService.CLASS_NAME, "blob", blob);
653
+ core.Guards.stringValue(DocumentManagementService.CLASS_NAME, "userIdentity", userIdentity);
654
+ core.Guards.stringValue(DocumentManagementService.CLASS_NAME, "nodeIdentity", nodeIdentity);
655
655
  try {
656
656
  // Get the connected vertices first, if one fails we abort the create
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 = {};
@@ -714,7 +714,7 @@ class DocumentManagementService {
714
714
  if (core.BaseError.someErrorName(error, "NotFoundError")) {
715
715
  throw error;
716
716
  }
717
- throw new core.GeneralError(this.CLASS_NAME, "createFailed", undefined, error);
717
+ throw new core.GeneralError(DocumentManagementService.CLASS_NAME, "createFailed", undefined, error);
718
718
  }
719
719
  }
720
720
  /**
@@ -730,19 +730,19 @@ class DocumentManagementService {
730
730
  * @returns Nothing.
731
731
  */
732
732
  async update(auditableItemGraphDocumentId, blob, annotationObject, auditableItemGraphEdges, userIdentity, nodeIdentity) {
733
- core.Urn.guard(this.CLASS_NAME, "auditableItemGraphDocumentId", auditableItemGraphDocumentId);
734
- core.Guards.stringValue(this.CLASS_NAME, "userIdentity", userIdentity);
735
- core.Guards.stringValue(this.CLASS_NAME, "nodeIdentity", nodeIdentity);
733
+ core.Urn.guard(DocumentManagementService.CLASS_NAME, "auditableItemGraphDocumentId", auditableItemGraphDocumentId);
734
+ core.Guards.stringValue(DocumentManagementService.CLASS_NAME, "userIdentity", userIdentity);
735
+ core.Guards.stringValue(DocumentManagementService.CLASS_NAME, "nodeIdentity", nodeIdentity);
736
736
  try {
737
737
  const documentVertex = await this._auditableItemGraphComponent.get(auditableItemGraphDocumentId, { includeDeleted: true });
738
738
  if (core.Is.empty(documentVertex.resources)) {
739
- throw new core.NotFoundError(this.CLASS_NAME, "documentRevisionNone");
739
+ throw new core.NotFoundError(DocumentManagementService.CLASS_NAME, "documentRevisionNone");
740
740
  }
741
741
  const documents = await this.getDocumentsFromVertex(documentVertex);
742
742
  const latestRevision = documents.itemListElement[0];
743
743
  documentVertex.resources = documentVertex.resources.filter(r => core.Is.empty(r.dateDeleted));
744
744
  if (core.Is.empty(latestRevision)) {
745
- throw new core.NotFoundError(this.CLASS_NAME, "documentRevisionNone");
745
+ throw new core.NotFoundError(DocumentManagementService.CLASS_NAME, "documentRevisionNone");
746
746
  }
747
747
  // If auditableItemGraphEdges is undefined we are not updating the edges
748
748
  // an empty array can be passed to remove all edges
@@ -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) {
@@ -811,7 +811,7 @@ class DocumentManagementService {
811
811
  if (core.BaseError.someErrorName(error, "NotFoundError")) {
812
812
  throw error;
813
813
  }
814
- throw new core.GeneralError(this.CLASS_NAME, "updateFailed", undefined, error);
814
+ throw new core.GeneralError(DocumentManagementService.CLASS_NAME, "updateFailed", undefined, error);
815
815
  }
816
816
  }
817
817
  /**
@@ -825,24 +825,24 @@ class DocumentManagementService {
825
825
  * @param options.extractRuleGroupId If provided will extract data from the document using the specified rule group id.
826
826
  * @param options.extractMimeType By default extraction will auto detect the mime type of the document, this can be used to override the detection.
827
827
  * @param cursor The cursor to get the next chunk of revisions.
828
- * @param pageSize Page size of items to return, defaults to 1 so only most recent is returned.
828
+ * @param limit Limit the number of items to return, defaults to 1 so only most recent is returned.
829
829
  * @param userIdentity The identity to perform the auditable item graph operation with.
830
830
  * @param nodeIdentity The node identity to use for vault operations.
831
831
  * @returns The documents and revisions if requested, ordered by revision descending, cursor is set if there are more document revisions.
832
832
  */
833
- async get(auditableItemGraphDocumentId, options, cursor, pageSize, userIdentity, nodeIdentity) {
834
- core.Urn.guard(this.CLASS_NAME, "auditableItemGraphDocumentId", auditableItemGraphDocumentId);
833
+ async get(auditableItemGraphDocumentId, options, cursor, limit, userIdentity, nodeIdentity) {
834
+ core.Urn.guard(DocumentManagementService.CLASS_NAME, "auditableItemGraphDocumentId", auditableItemGraphDocumentId);
835
835
  try {
836
836
  const documentVertex = await this._auditableItemGraphComponent.get(auditableItemGraphDocumentId, { includeDeleted: options?.includeRemoved });
837
837
  // Populate the document and revisions with the options set
838
- const documents = await this.getDocumentsFromVertex(documentVertex, options, cursor, pageSize, userIdentity, nodeIdentity);
838
+ const documents = await this.getDocumentsFromVertex(documentVertex, options, cursor, limit, userIdentity, nodeIdentity);
839
839
  return dataJsonLd.JsonLdProcessor.compact(documents, documents["@context"]);
840
840
  }
841
841
  catch (error) {
842
842
  if (core.BaseError.someErrorName(error, "NotFoundError")) {
843
843
  throw error;
844
844
  }
845
- throw new core.GeneralError(this.CLASS_NAME, "getFailed", undefined, error);
845
+ throw new core.GeneralError(DocumentManagementService.CLASS_NAME, "getFailed", undefined, error);
846
846
  }
847
847
  }
848
848
  /**
@@ -860,16 +860,16 @@ class DocumentManagementService {
860
860
  * @returns The documents and revisions if requested, ordered by revision descending, cursor is set if there are more document revisions.
861
861
  */
862
862
  async getRevision(auditableItemGraphDocumentId, revision, options, userIdentity, nodeIdentity) {
863
- core.Urn.guard(this.CLASS_NAME, "auditableItemGraphDocumentId", auditableItemGraphDocumentId);
864
- core.Guards.integer(this.CLASS_NAME, "revision", revision);
863
+ core.Urn.guard(DocumentManagementService.CLASS_NAME, "auditableItemGraphDocumentId", auditableItemGraphDocumentId);
864
+ core.Guards.integer(DocumentManagementService.CLASS_NAME, "revision", revision);
865
865
  try {
866
866
  const documentVertex = await this._auditableItemGraphComponent.get(auditableItemGraphDocumentId, { includeDeleted: true });
867
867
  if (core.Is.empty(documentVertex.resources)) {
868
- throw new core.NotFoundError(this.CLASS_NAME, "documentRevisionNone");
868
+ throw new core.NotFoundError(DocumentManagementService.CLASS_NAME, "documentRevisionNone");
869
869
  }
870
870
  documentVertex.resources = documentVertex.resources.filter(d => d.resourceObject?.documentRevision === revision);
871
871
  if (documentVertex.resources.length === 0) {
872
- throw new core.NotFoundError(this.CLASS_NAME, "documentRevisionNotFound", revision.toString());
872
+ throw new core.NotFoundError(DocumentManagementService.CLASS_NAME, "documentRevisionNotFound", revision.toString());
873
873
  }
874
874
  // Populate the document and revisions with the options set
875
875
  const docList = await this.getDocumentsFromVertex(documentVertex, options, undefined, undefined, userIdentity, nodeIdentity);
@@ -879,7 +879,7 @@ class DocumentManagementService {
879
879
  if (core.BaseError.someErrorName(error, "NotFoundError")) {
880
880
  throw error;
881
881
  }
882
- throw new core.GeneralError(this.CLASS_NAME, "getRevisionFailed", undefined, error);
882
+ throw new core.GeneralError(DocumentManagementService.CLASS_NAME, "getRevisionFailed", undefined, error);
883
883
  }
884
884
  }
885
885
  /**
@@ -892,16 +892,16 @@ class DocumentManagementService {
892
892
  * @returns Nothing.
893
893
  */
894
894
  async removeRevision(auditableItemGraphDocumentId, revision, userIdentity, nodeIdentity) {
895
- core.Urn.guard(this.CLASS_NAME, "auditableItemGraphDocumentId", auditableItemGraphDocumentId);
896
- core.Guards.number(this.CLASS_NAME, "revision", revision);
895
+ core.Urn.guard(DocumentManagementService.CLASS_NAME, "auditableItemGraphDocumentId", auditableItemGraphDocumentId);
896
+ core.Guards.number(DocumentManagementService.CLASS_NAME, "revision", revision);
897
897
  try {
898
898
  const documentVertex = await this._auditableItemGraphComponent.get(auditableItemGraphDocumentId);
899
899
  if (core.Is.empty(documentVertex.resources)) {
900
- throw new core.NotFoundError(this.CLASS_NAME, "documentRevisionNone");
900
+ throw new core.NotFoundError(DocumentManagementService.CLASS_NAME, "documentRevisionNone");
901
901
  }
902
902
  const docRevisionIndex = documentVertex.resources.findIndex(d => d.resourceObject?.documentRevision === revision);
903
903
  if (docRevisionIndex === -1) {
904
- throw new core.NotFoundError(this.CLASS_NAME, "documentRevisionNotFound", revision.toString());
904
+ throw new core.NotFoundError(DocumentManagementService.CLASS_NAME, "documentRevisionNotFound", revision.toString());
905
905
  }
906
906
  documentVertex.resources.splice(docRevisionIndex, 1);
907
907
  await this._auditableItemGraphComponent.update(documentVertex, userIdentity, nodeIdentity);
@@ -910,32 +910,32 @@ class DocumentManagementService {
910
910
  if (core.BaseError.someErrorName(error, "NotFoundError")) {
911
911
  throw error;
912
912
  }
913
- throw new core.GeneralError(this.CLASS_NAME, "removeRevisionFailed", undefined, error);
913
+ throw new core.GeneralError(DocumentManagementService.CLASS_NAME, "removeRevisionFailed", undefined, error);
914
914
  }
915
915
  }
916
916
  /**
917
917
  * Find all the document with a specific id.
918
918
  * @param documentId The document id to find in the graph.
919
919
  * @param cursor The cursor to get the next chunk of documents.
920
- * @param pageSize The page size to get the next chunk of documents.
920
+ * @param limit The limit to get the next chunk of documents.
921
921
  * @param userIdentity The identity to perform the auditable item graph operation with.
922
922
  * @param nodeIdentity The node identity to use for vault operations.
923
923
  * @returns The graph vertices that contain documents referencing the specified document id.
924
924
  */
925
- async query(documentId, cursor, pageSize, userIdentity, nodeIdentity) {
926
- core.Guards.stringValue(this.CLASS_NAME, "documentId", documentId);
925
+ async query(documentId, cursor, limit, userIdentity, nodeIdentity) {
926
+ core.Guards.stringValue(DocumentManagementService.CLASS_NAME, "documentId", documentId);
927
927
  try {
928
928
  return this._auditableItemGraphComponent.query({
929
929
  id: documentId,
930
930
  idMode: "both",
931
931
  resourceTypes: [documentManagementModels.DocumentTypes.Document]
932
- }, undefined, undefined, undefined, ["id", "dateCreated", "dateModified", "aliases", "annotationObject", "resources", "edges"], cursor, pageSize);
932
+ }, undefined, undefined, undefined, ["id", "dateCreated", "dateModified", "aliases", "annotationObject", "resources", "edges"], cursor, limit);
933
933
  }
934
934
  catch (error) {
935
935
  if (core.BaseError.someErrorName(error, "NotFoundError")) {
936
936
  throw error;
937
937
  }
938
- throw new core.GeneralError(this.CLASS_NAME, "queryFailed", undefined, error);
938
+ throw new core.GeneralError(DocumentManagementService.CLASS_NAME, "queryFailed", undefined, error);
939
939
  }
940
940
  }
941
941
  /**
@@ -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;
@@ -1097,13 +1097,13 @@ class DocumentManagementService {
1097
1097
  * @param options.extractRuleGroupId If provided will extract data from the document using the specified rule group id.
1098
1098
  * @param options.extractMimeType By default extraction will auto detect the mime type of the document, this can be used to override the detection.
1099
1099
  * @param cursor The cursor to get the next chunk of revisions.
1100
- * @param pageSize Page size of items to return, defaults to 1 so only most recent is returned.
1100
+ * @param limit Limit the number of items to return, defaults to 1 so only most recent is returned.
1101
1101
  * @param userIdentity The identity to perform the auditable item graph operation with.
1102
1102
  * @param nodeIdentity The node identity to use for vault operations.
1103
1103
  * @returns The finalised list of documents.
1104
1104
  * @internal
1105
1105
  */
1106
- async getDocumentsFromVertex(documentVertex, options, cursor, pageSize, userIdentity, nodeIdentity) {
1106
+ async getDocumentsFromVertex(documentVertex, options, cursor, limit, userIdentity, nodeIdentity) {
1107
1107
  const docList = {
1108
1108
  "@context": [
1109
1109
  standardsSchemaOrg.SchemaOrgContexts.ContextRoot,
@@ -1118,7 +1118,7 @@ class DocumentManagementService {
1118
1118
  documentVertex.resources.sort((a, b) => (core.Coerce.number(b.resourceObject?.documentRevision) ?? 0) -
1119
1119
  (core.Coerce.number(a.resourceObject?.documentRevision) ?? 0));
1120
1120
  const startIndex = core.Coerce.integer(cursor) ?? 0;
1121
- const endIndex = Math.min(startIndex + (pageSize ?? 1), documentVertex.resources.length);
1121
+ const endIndex = Math.min(startIndex + (limit ?? 1), documentVertex.resources.length);
1122
1122
  const slicedResources = documentVertex.resources.slice(startIndex, endIndex);
1123
1123
  docList[standardsSchemaOrg.SchemaOrgTypes.NextItem] =
1124
1124
  documentVertex.resources.length > endIndex ? (endIndex + 1).toString() : undefined;
@@ -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
  }
@@ -492,7 +492,7 @@ async function documentManagementGet(httpRequestContext, componentName, request)
492
492
  includeRemoved: Coerce.boolean(request.query?.includeRemoved),
493
493
  extractRuleGroupId: request.query?.extractRuleGroupId,
494
494
  extractMimeType: request.query?.extractMimeType
495
- }, request.query?.cursor, Coerce.integer(request.query?.pageSize), httpRequestContext.userIdentity, httpRequestContext.nodeIdentity);
495
+ }, request.query?.cursor, Coerce.integer(request.query?.limit), httpRequestContext.userIdentity, httpRequestContext.nodeIdentity);
496
496
  return {
497
497
  headers: {
498
498
  [HeaderTypes.ContentType]: mimeType === "json" ? MimeTypes.Json : MimeTypes.JsonLd
@@ -578,7 +578,7 @@ async function documentManagementQuery(httpRequestContext, componentName, reques
578
578
  Guards.stringValue(ROUTES_SOURCE, "request.query.documentId", request.query.documentId);
579
579
  const mimeType = request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd ? "jsonld" : "json";
580
580
  const component = ComponentFactory.get(componentName);
581
- const result = await component.query(request.query.documentId, request.query?.cursor, Coerce.integer(request.query?.pageSize), httpRequestContext.userIdentity, httpRequestContext.nodeIdentity);
581
+ const result = await component.query(request.query.documentId, request.query?.cursor, Coerce.integer(request.query?.limit), httpRequestContext.userIdentity, httpRequestContext.nodeIdentity);
582
582
  return {
583
583
  headers: {
584
584
  [HeaderTypes.ContentType]: mimeType === "json" ? MimeTypes.Json : MimeTypes.JsonLd
@@ -594,7 +594,7 @@ class DocumentManagementService {
594
594
  /**
595
595
  * Runtime name for the class.
596
596
  */
597
- CLASS_NAME = "DocumentManagementService";
597
+ static CLASS_NAME = "DocumentManagementService";
598
598
  /**
599
599
  * The component for the auditable item graph.
600
600
  * @internal
@@ -645,17 +645,17 @@ class DocumentManagementService {
645
645
  * @returns The auditable item graph vertex created for the document including its revision.
646
646
  */
647
647
  async create(documentId, documentIdFormat, documentCode, blob, annotationObject, auditableItemGraphEdges, options, userIdentity, nodeIdentity) {
648
- Guards.stringValue(this.CLASS_NAME, "documentId", documentId);
649
- Guards.arrayOneOf(this.CLASS_NAME, "documentCode", documentCode, Object.values(UneceDocumentCodes));
650
- Guards.uint8Array(this.CLASS_NAME, "blob", blob);
651
- Guards.stringValue(this.CLASS_NAME, "userIdentity", userIdentity);
652
- Guards.stringValue(this.CLASS_NAME, "nodeIdentity", nodeIdentity);
648
+ Guards.stringValue(DocumentManagementService.CLASS_NAME, "documentId", documentId);
649
+ Guards.arrayOneOf(DocumentManagementService.CLASS_NAME, "documentCode", documentCode, Object.values(UneceDocumentCodes));
650
+ Guards.uint8Array(DocumentManagementService.CLASS_NAME, "blob", blob);
651
+ Guards.stringValue(DocumentManagementService.CLASS_NAME, "userIdentity", userIdentity);
652
+ Guards.stringValue(DocumentManagementService.CLASS_NAME, "nodeIdentity", nodeIdentity);
653
653
  try {
654
654
  // Get the connected vertices first, if one fails we abort the create
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 = {};
@@ -712,7 +712,7 @@ class DocumentManagementService {
712
712
  if (BaseError.someErrorName(error, "NotFoundError")) {
713
713
  throw error;
714
714
  }
715
- throw new GeneralError(this.CLASS_NAME, "createFailed", undefined, error);
715
+ throw new GeneralError(DocumentManagementService.CLASS_NAME, "createFailed", undefined, error);
716
716
  }
717
717
  }
718
718
  /**
@@ -728,19 +728,19 @@ class DocumentManagementService {
728
728
  * @returns Nothing.
729
729
  */
730
730
  async update(auditableItemGraphDocumentId, blob, annotationObject, auditableItemGraphEdges, userIdentity, nodeIdentity) {
731
- Urn.guard(this.CLASS_NAME, "auditableItemGraphDocumentId", auditableItemGraphDocumentId);
732
- Guards.stringValue(this.CLASS_NAME, "userIdentity", userIdentity);
733
- Guards.stringValue(this.CLASS_NAME, "nodeIdentity", nodeIdentity);
731
+ Urn.guard(DocumentManagementService.CLASS_NAME, "auditableItemGraphDocumentId", auditableItemGraphDocumentId);
732
+ Guards.stringValue(DocumentManagementService.CLASS_NAME, "userIdentity", userIdentity);
733
+ Guards.stringValue(DocumentManagementService.CLASS_NAME, "nodeIdentity", nodeIdentity);
734
734
  try {
735
735
  const documentVertex = await this._auditableItemGraphComponent.get(auditableItemGraphDocumentId, { includeDeleted: true });
736
736
  if (Is.empty(documentVertex.resources)) {
737
- throw new NotFoundError(this.CLASS_NAME, "documentRevisionNone");
737
+ throw new NotFoundError(DocumentManagementService.CLASS_NAME, "documentRevisionNone");
738
738
  }
739
739
  const documents = await this.getDocumentsFromVertex(documentVertex);
740
740
  const latestRevision = documents.itemListElement[0];
741
741
  documentVertex.resources = documentVertex.resources.filter(r => Is.empty(r.dateDeleted));
742
742
  if (Is.empty(latestRevision)) {
743
- throw new NotFoundError(this.CLASS_NAME, "documentRevisionNone");
743
+ throw new NotFoundError(DocumentManagementService.CLASS_NAME, "documentRevisionNone");
744
744
  }
745
745
  // If auditableItemGraphEdges is undefined we are not updating the edges
746
746
  // an empty array can be passed to remove all edges
@@ -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) {
@@ -809,7 +809,7 @@ class DocumentManagementService {
809
809
  if (BaseError.someErrorName(error, "NotFoundError")) {
810
810
  throw error;
811
811
  }
812
- throw new GeneralError(this.CLASS_NAME, "updateFailed", undefined, error);
812
+ throw new GeneralError(DocumentManagementService.CLASS_NAME, "updateFailed", undefined, error);
813
813
  }
814
814
  }
815
815
  /**
@@ -823,24 +823,24 @@ class DocumentManagementService {
823
823
  * @param options.extractRuleGroupId If provided will extract data from the document using the specified rule group id.
824
824
  * @param options.extractMimeType By default extraction will auto detect the mime type of the document, this can be used to override the detection.
825
825
  * @param cursor The cursor to get the next chunk of revisions.
826
- * @param pageSize Page size of items to return, defaults to 1 so only most recent is returned.
826
+ * @param limit Limit the number of items to return, defaults to 1 so only most recent is returned.
827
827
  * @param userIdentity The identity to perform the auditable item graph operation with.
828
828
  * @param nodeIdentity The node identity to use for vault operations.
829
829
  * @returns The documents and revisions if requested, ordered by revision descending, cursor is set if there are more document revisions.
830
830
  */
831
- async get(auditableItemGraphDocumentId, options, cursor, pageSize, userIdentity, nodeIdentity) {
832
- Urn.guard(this.CLASS_NAME, "auditableItemGraphDocumentId", auditableItemGraphDocumentId);
831
+ async get(auditableItemGraphDocumentId, options, cursor, limit, userIdentity, nodeIdentity) {
832
+ Urn.guard(DocumentManagementService.CLASS_NAME, "auditableItemGraphDocumentId", auditableItemGraphDocumentId);
833
833
  try {
834
834
  const documentVertex = await this._auditableItemGraphComponent.get(auditableItemGraphDocumentId, { includeDeleted: options?.includeRemoved });
835
835
  // Populate the document and revisions with the options set
836
- const documents = await this.getDocumentsFromVertex(documentVertex, options, cursor, pageSize, userIdentity, nodeIdentity);
836
+ const documents = await this.getDocumentsFromVertex(documentVertex, options, cursor, limit, userIdentity, nodeIdentity);
837
837
  return JsonLdProcessor.compact(documents, documents["@context"]);
838
838
  }
839
839
  catch (error) {
840
840
  if (BaseError.someErrorName(error, "NotFoundError")) {
841
841
  throw error;
842
842
  }
843
- throw new GeneralError(this.CLASS_NAME, "getFailed", undefined, error);
843
+ throw new GeneralError(DocumentManagementService.CLASS_NAME, "getFailed", undefined, error);
844
844
  }
845
845
  }
846
846
  /**
@@ -858,16 +858,16 @@ class DocumentManagementService {
858
858
  * @returns The documents and revisions if requested, ordered by revision descending, cursor is set if there are more document revisions.
859
859
  */
860
860
  async getRevision(auditableItemGraphDocumentId, revision, options, userIdentity, nodeIdentity) {
861
- Urn.guard(this.CLASS_NAME, "auditableItemGraphDocumentId", auditableItemGraphDocumentId);
862
- Guards.integer(this.CLASS_NAME, "revision", revision);
861
+ Urn.guard(DocumentManagementService.CLASS_NAME, "auditableItemGraphDocumentId", auditableItemGraphDocumentId);
862
+ Guards.integer(DocumentManagementService.CLASS_NAME, "revision", revision);
863
863
  try {
864
864
  const documentVertex = await this._auditableItemGraphComponent.get(auditableItemGraphDocumentId, { includeDeleted: true });
865
865
  if (Is.empty(documentVertex.resources)) {
866
- throw new NotFoundError(this.CLASS_NAME, "documentRevisionNone");
866
+ throw new NotFoundError(DocumentManagementService.CLASS_NAME, "documentRevisionNone");
867
867
  }
868
868
  documentVertex.resources = documentVertex.resources.filter(d => d.resourceObject?.documentRevision === revision);
869
869
  if (documentVertex.resources.length === 0) {
870
- throw new NotFoundError(this.CLASS_NAME, "documentRevisionNotFound", revision.toString());
870
+ throw new NotFoundError(DocumentManagementService.CLASS_NAME, "documentRevisionNotFound", revision.toString());
871
871
  }
872
872
  // Populate the document and revisions with the options set
873
873
  const docList = await this.getDocumentsFromVertex(documentVertex, options, undefined, undefined, userIdentity, nodeIdentity);
@@ -877,7 +877,7 @@ class DocumentManagementService {
877
877
  if (BaseError.someErrorName(error, "NotFoundError")) {
878
878
  throw error;
879
879
  }
880
- throw new GeneralError(this.CLASS_NAME, "getRevisionFailed", undefined, error);
880
+ throw new GeneralError(DocumentManagementService.CLASS_NAME, "getRevisionFailed", undefined, error);
881
881
  }
882
882
  }
883
883
  /**
@@ -890,16 +890,16 @@ class DocumentManagementService {
890
890
  * @returns Nothing.
891
891
  */
892
892
  async removeRevision(auditableItemGraphDocumentId, revision, userIdentity, nodeIdentity) {
893
- Urn.guard(this.CLASS_NAME, "auditableItemGraphDocumentId", auditableItemGraphDocumentId);
894
- Guards.number(this.CLASS_NAME, "revision", revision);
893
+ Urn.guard(DocumentManagementService.CLASS_NAME, "auditableItemGraphDocumentId", auditableItemGraphDocumentId);
894
+ Guards.number(DocumentManagementService.CLASS_NAME, "revision", revision);
895
895
  try {
896
896
  const documentVertex = await this._auditableItemGraphComponent.get(auditableItemGraphDocumentId);
897
897
  if (Is.empty(documentVertex.resources)) {
898
- throw new NotFoundError(this.CLASS_NAME, "documentRevisionNone");
898
+ throw new NotFoundError(DocumentManagementService.CLASS_NAME, "documentRevisionNone");
899
899
  }
900
900
  const docRevisionIndex = documentVertex.resources.findIndex(d => d.resourceObject?.documentRevision === revision);
901
901
  if (docRevisionIndex === -1) {
902
- throw new NotFoundError(this.CLASS_NAME, "documentRevisionNotFound", revision.toString());
902
+ throw new NotFoundError(DocumentManagementService.CLASS_NAME, "documentRevisionNotFound", revision.toString());
903
903
  }
904
904
  documentVertex.resources.splice(docRevisionIndex, 1);
905
905
  await this._auditableItemGraphComponent.update(documentVertex, userIdentity, nodeIdentity);
@@ -908,32 +908,32 @@ class DocumentManagementService {
908
908
  if (BaseError.someErrorName(error, "NotFoundError")) {
909
909
  throw error;
910
910
  }
911
- throw new GeneralError(this.CLASS_NAME, "removeRevisionFailed", undefined, error);
911
+ throw new GeneralError(DocumentManagementService.CLASS_NAME, "removeRevisionFailed", undefined, error);
912
912
  }
913
913
  }
914
914
  /**
915
915
  * Find all the document with a specific id.
916
916
  * @param documentId The document id to find in the graph.
917
917
  * @param cursor The cursor to get the next chunk of documents.
918
- * @param pageSize The page size to get the next chunk of documents.
918
+ * @param limit The limit to get the next chunk of documents.
919
919
  * @param userIdentity The identity to perform the auditable item graph operation with.
920
920
  * @param nodeIdentity The node identity to use for vault operations.
921
921
  * @returns The graph vertices that contain documents referencing the specified document id.
922
922
  */
923
- async query(documentId, cursor, pageSize, userIdentity, nodeIdentity) {
924
- Guards.stringValue(this.CLASS_NAME, "documentId", documentId);
923
+ async query(documentId, cursor, limit, userIdentity, nodeIdentity) {
924
+ Guards.stringValue(DocumentManagementService.CLASS_NAME, "documentId", documentId);
925
925
  try {
926
926
  return this._auditableItemGraphComponent.query({
927
927
  id: documentId,
928
928
  idMode: "both",
929
929
  resourceTypes: [DocumentTypes.Document]
930
- }, undefined, undefined, undefined, ["id", "dateCreated", "dateModified", "aliases", "annotationObject", "resources", "edges"], cursor, pageSize);
930
+ }, undefined, undefined, undefined, ["id", "dateCreated", "dateModified", "aliases", "annotationObject", "resources", "edges"], cursor, limit);
931
931
  }
932
932
  catch (error) {
933
933
  if (BaseError.someErrorName(error, "NotFoundError")) {
934
934
  throw error;
935
935
  }
936
- throw new GeneralError(this.CLASS_NAME, "queryFailed", undefined, error);
936
+ throw new GeneralError(DocumentManagementService.CLASS_NAME, "queryFailed", undefined, error);
937
937
  }
938
938
  }
939
939
  /**
@@ -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;
@@ -1095,13 +1095,13 @@ class DocumentManagementService {
1095
1095
  * @param options.extractRuleGroupId If provided will extract data from the document using the specified rule group id.
1096
1096
  * @param options.extractMimeType By default extraction will auto detect the mime type of the document, this can be used to override the detection.
1097
1097
  * @param cursor The cursor to get the next chunk of revisions.
1098
- * @param pageSize Page size of items to return, defaults to 1 so only most recent is returned.
1098
+ * @param limit Limit the number of items to return, defaults to 1 so only most recent is returned.
1099
1099
  * @param userIdentity The identity to perform the auditable item graph operation with.
1100
1100
  * @param nodeIdentity The node identity to use for vault operations.
1101
1101
  * @returns The finalised list of documents.
1102
1102
  * @internal
1103
1103
  */
1104
- async getDocumentsFromVertex(documentVertex, options, cursor, pageSize, userIdentity, nodeIdentity) {
1104
+ async getDocumentsFromVertex(documentVertex, options, cursor, limit, userIdentity, nodeIdentity) {
1105
1105
  const docList = {
1106
1106
  "@context": [
1107
1107
  SchemaOrgContexts.ContextRoot,
@@ -1116,7 +1116,7 @@ class DocumentManagementService {
1116
1116
  documentVertex.resources.sort((a, b) => (Coerce.number(b.resourceObject?.documentRevision) ?? 0) -
1117
1117
  (Coerce.number(a.resourceObject?.documentRevision) ?? 0));
1118
1118
  const startIndex = Coerce.integer(cursor) ?? 0;
1119
- const endIndex = Math.min(startIndex + (pageSize ?? 1), documentVertex.resources.length);
1119
+ const endIndex = Math.min(startIndex + (limit ?? 1), documentVertex.resources.length);
1120
1120
  const slicedResources = documentVertex.resources.slice(startIndex, endIndex);
1121
1121
  docList[SchemaOrgTypes.NextItem] =
1122
1122
  documentVertex.resources.length > endIndex ? (endIndex + 1).toString() : undefined;
@@ -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
  }
@@ -10,7 +10,7 @@ export declare class DocumentManagementService implements IDocumentManagementCom
10
10
  /**
11
11
  * Runtime name for the class.
12
12
  */
13
- readonly CLASS_NAME: string;
13
+ static readonly CLASS_NAME: string;
14
14
  /**
15
15
  * Create a new instance of DocumentManagementService.
16
16
  * @param options The options for the service.
@@ -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>;
@@ -71,7 +71,7 @@ export declare class DocumentManagementService implements IDocumentManagementCom
71
71
  * @param options.extractRuleGroupId If provided will extract data from the document using the specified rule group id.
72
72
  * @param options.extractMimeType By default extraction will auto detect the mime type of the document, this can be used to override the detection.
73
73
  * @param cursor The cursor to get the next chunk of revisions.
74
- * @param pageSize Page size of items to return, defaults to 1 so only most recent is returned.
74
+ * @param limit Limit the number of items to return, defaults to 1 so only most recent is returned.
75
75
  * @param userIdentity The identity to perform the auditable item graph operation with.
76
76
  * @param nodeIdentity The node identity to use for vault operations.
77
77
  * @returns The documents and revisions if requested, ordered by revision descending, cursor is set if there are more document revisions.
@@ -83,7 +83,7 @@ export declare class DocumentManagementService implements IDocumentManagementCom
83
83
  includeRemoved?: boolean;
84
84
  extractRuleGroupId?: string;
85
85
  extractMimeType?: string;
86
- }, cursor?: string, pageSize?: number, userIdentity?: string, nodeIdentity?: string): Promise<IDocumentList>;
86
+ }, cursor?: string, limit?: number, userIdentity?: string, nodeIdentity?: string): Promise<IDocumentList>;
87
87
  /**
88
88
  * Get a document revision using it's auditable item graph vertex id.
89
89
  * @param auditableItemGraphDocumentId The auditable item graph vertex id which contains the document.
@@ -119,12 +119,12 @@ export declare class DocumentManagementService implements IDocumentManagementCom
119
119
  * Find all the document with a specific id.
120
120
  * @param documentId The document id to find in the graph.
121
121
  * @param cursor The cursor to get the next chunk of documents.
122
- * @param pageSize The page size to get the next chunk of documents.
122
+ * @param limit The limit to get the next chunk of documents.
123
123
  * @param userIdentity The identity to perform the auditable item graph operation with.
124
124
  * @param nodeIdentity The node identity to use for vault operations.
125
125
  * @returns The graph vertices that contain documents referencing the specified document id.
126
126
  */
127
- query(documentId: string, cursor?: string, pageSize?: number, userIdentity?: string, nodeIdentity?: string): Promise<IAuditableItemGraphVertexList>;
127
+ query(documentId: string, cursor?: string, limit?: number, userIdentity?: string, nodeIdentity?: string): Promise<IAuditableItemGraphVertexList>;
128
128
  /**
129
129
  * Create an attestation for the document.
130
130
  * @param document The document to create the attestation for.
package/docs/changelog.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # @twin.org/document-management-service - Changelog
2
2
 
3
+ ## [0.0.2-next.4](https://github.com/twinfoundation/document-management/compare/document-management-service-v0.0.2-next.3...document-management-service-v0.0.2-next.4) (2025-10-09)
4
+
5
+
6
+ ### Features
7
+
8
+ * add validate-locales ([b6b6f9e](https://github.com/twinfoundation/document-management/commit/b6b6f9e9d66c17af3d030247ca168ac0b5844bdc))
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.3 to 0.0.2-next.4
16
+
17
+ ## [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)
18
+
19
+
20
+ ### Features
21
+
22
+ * use targetId in AIG for edges ([82dec81](https://github.com/twinfoundation/document-management/commit/82dec8190d8b523b350ef133bdcf648cab1023b0))
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.2 to 0.0.2-next.3
30
+
3
31
  ## [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)
4
32
 
5
33
 
@@ -83,7 +83,7 @@
83
83
  "exampleResponse": {
84
84
  "value": {
85
85
  "name": "GeneralError",
86
- "message": "component.error",
86
+ "message": "errorMessage",
87
87
  "properties": {
88
88
  "foo": "bar"
89
89
  }
@@ -104,7 +104,7 @@
104
104
  "exampleResponse": {
105
105
  "value": {
106
106
  "name": "UnauthorizedError",
107
- "message": "component.error"
107
+ "message": "errorMessage"
108
108
  }
109
109
  }
110
110
  }
@@ -122,7 +122,7 @@
122
122
  "exampleResponse": {
123
123
  "value": {
124
124
  "name": "InternalServerError",
125
- "message": "component.error"
125
+ "message": "errorMessage"
126
126
  }
127
127
  }
128
128
  }
@@ -158,15 +158,12 @@
158
158
  }
159
159
  },
160
160
  {
161
- "name": "pageSize",
161
+ "name": "limit",
162
162
  "description": "The number of documents to return.",
163
163
  "in": "query",
164
164
  "required": false,
165
165
  "schema": {
166
- "type": [
167
- "number",
168
- "string"
169
- ]
166
+ "type": "string"
170
167
  }
171
168
  },
172
169
  {
@@ -270,7 +267,7 @@
270
267
  "exampleResponse": {
271
268
  "value": {
272
269
  "name": "GeneralError",
273
- "message": "component.error",
270
+ "message": "errorMessage",
274
271
  "properties": {
275
272
  "foo": "bar"
276
273
  }
@@ -291,7 +288,7 @@
291
288
  "exampleResponse": {
292
289
  "value": {
293
290
  "name": "UnauthorizedError",
294
- "message": "component.error"
291
+ "message": "errorMessage"
295
292
  }
296
293
  }
297
294
  }
@@ -309,7 +306,7 @@
309
306
  "exampleResponse": {
310
307
  "value": {
311
308
  "name": "InternalServerError",
312
- "message": "component.error"
309
+ "message": "errorMessage"
313
310
  }
314
311
  }
315
312
  }
@@ -382,7 +379,7 @@
382
379
  "exampleResponse": {
383
380
  "value": {
384
381
  "name": "GeneralError",
385
- "message": "component.error",
382
+ "message": "errorMessage",
386
383
  "properties": {
387
384
  "foo": "bar"
388
385
  }
@@ -403,7 +400,7 @@
403
400
  "exampleResponse": {
404
401
  "value": {
405
402
  "name": "UnauthorizedError",
406
- "message": "component.error"
403
+ "message": "errorMessage"
407
404
  }
408
405
  }
409
406
  }
@@ -421,7 +418,7 @@
421
418
  "exampleResponse": {
422
419
  "value": {
423
420
  "name": "InternalServerError",
424
- "message": "component.error"
421
+ "message": "errorMessage"
425
422
  }
426
423
  }
427
424
  }
@@ -515,15 +512,12 @@
515
512
  }
516
513
  },
517
514
  {
518
- "name": "pageSize",
519
- "description": "Page size of items to return, defaults to 1 so only most recent is returned.",
515
+ "name": "limit",
516
+ "description": "PLimit the number of items to return, defaults to 1 so only most recent is returned.",
520
517
  "in": "query",
521
518
  "required": false,
522
519
  "schema": {
523
- "type": [
524
- "number",
525
- "string"
526
- ]
520
+ "type": "string"
527
521
  }
528
522
  },
529
523
  {
@@ -651,7 +645,7 @@
651
645
  "exampleResponse": {
652
646
  "value": {
653
647
  "name": "GeneralError",
654
- "message": "component.error",
648
+ "message": "errorMessage",
655
649
  "properties": {
656
650
  "foo": "bar"
657
651
  }
@@ -672,7 +666,7 @@
672
666
  "exampleResponse": {
673
667
  "value": {
674
668
  "name": "UnauthorizedError",
675
- "message": "component.error"
669
+ "message": "errorMessage"
676
670
  }
677
671
  }
678
672
  }
@@ -690,7 +684,7 @@
690
684
  "exampleResponse": {
691
685
  "value": {
692
686
  "name": "NotFoundError",
693
- "message": "component.error",
687
+ "message": "errorMessage",
694
688
  "properties": {
695
689
  "notFoundId": "1"
696
690
  }
@@ -711,7 +705,7 @@
711
705
  "exampleResponse": {
712
706
  "value": {
713
707
  "name": "InternalServerError",
714
- "message": "component.error"
708
+ "message": "errorMessage"
715
709
  }
716
710
  }
717
711
  }
@@ -838,7 +832,7 @@
838
832
  "exampleResponse": {
839
833
  "value": {
840
834
  "name": "GeneralError",
841
- "message": "component.error",
835
+ "message": "errorMessage",
842
836
  "properties": {
843
837
  "foo": "bar"
844
838
  }
@@ -859,7 +853,7 @@
859
853
  "exampleResponse": {
860
854
  "value": {
861
855
  "name": "UnauthorizedError",
862
- "message": "component.error"
856
+ "message": "errorMessage"
863
857
  }
864
858
  }
865
859
  }
@@ -877,7 +871,7 @@
877
871
  "exampleResponse": {
878
872
  "value": {
879
873
  "name": "NotFoundError",
880
- "message": "component.error",
874
+ "message": "errorMessage",
881
875
  "properties": {
882
876
  "notFoundId": "1"
883
877
  }
@@ -898,7 +892,7 @@
898
892
  "exampleResponse": {
899
893
  "value": {
900
894
  "name": "InternalServerError",
901
- "message": "component.error"
895
+ "message": "errorMessage"
902
896
  }
903
897
  }
904
898
  }
@@ -957,7 +951,7 @@
957
951
  "exampleResponse": {
958
952
  "value": {
959
953
  "name": "GeneralError",
960
- "message": "component.error",
954
+ "message": "errorMessage",
961
955
  "properties": {
962
956
  "foo": "bar"
963
957
  }
@@ -978,7 +972,7 @@
978
972
  "exampleResponse": {
979
973
  "value": {
980
974
  "name": "UnauthorizedError",
981
- "message": "component.error"
975
+ "message": "errorMessage"
982
976
  }
983
977
  }
984
978
  }
@@ -996,7 +990,7 @@
996
990
  "exampleResponse": {
997
991
  "value": {
998
992
  "name": "NotFoundError",
999
- "message": "component.error",
993
+ "message": "errorMessage",
1000
994
  "properties": {
1001
995
  "notFoundId": "1"
1002
996
  }
@@ -1017,7 +1011,7 @@
1017
1011
  "exampleResponse": {
1018
1012
  "value": {
1019
1013
  "name": "InternalServerError",
1020
- "message": "component.error"
1014
+ "message": "errorMessage"
1021
1015
  }
1022
1016
  }
1023
1017
  }
@@ -1203,20 +1197,6 @@
1203
1197
  "additionalProperties": false,
1204
1198
  "description": "Interface describing a list of document entries."
1205
1199
  },
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
1200
  "DocumentManagementCreateRequest": {
1221
1201
  "type": "object",
1222
1202
  "properties": {
@@ -1246,7 +1226,7 @@
1246
1226
  {
1247
1227
  "type": "object",
1248
1228
  "properties": {
1249
- "id": {
1229
+ "targetId": {
1250
1230
  "type": "string"
1251
1231
  },
1252
1232
  "addAlias": {
@@ -1257,7 +1237,7 @@
1257
1237
  }
1258
1238
  },
1259
1239
  "required": [
1260
- "id"
1240
+ "targetId"
1261
1241
  ],
1262
1242
  "additionalProperties": false
1263
1243
  }
@@ -1283,41 +1263,6 @@
1283
1263
  "additionalProperties": false,
1284
1264
  "description": "The body parameters."
1285
1265
  },
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
1266
  "DocumentManagementUpdateRequest": {
1322
1267
  "type": "object",
1323
1268
  "properties": {
@@ -1336,7 +1281,7 @@
1336
1281
  {
1337
1282
  "type": "object",
1338
1283
  "properties": {
1339
- "id": {
1284
+ "targetId": {
1340
1285
  "type": "string"
1341
1286
  },
1342
1287
  "addAlias": {
@@ -1347,7 +1292,7 @@
1347
1292
  }
1348
1293
  },
1349
1294
  "required": [
1350
- "id"
1295
+ "targetId"
1351
1296
  ],
1352
1297
  "additionalProperties": false
1353
1298
  }
@@ -30,14 +30,10 @@ The options for the service.
30
30
 
31
31
  ### CLASS\_NAME
32
32
 
33
- > `readonly` **CLASS\_NAME**: `string`
33
+ > `readonly` `static` **CLASS\_NAME**: `string`
34
34
 
35
35
  Runtime name for the class.
36
36
 
37
- #### Implementation of
38
-
39
- `IDocumentManagementComponent.CLASS_NAME`
40
-
41
37
  ## Methods
42
38
 
43
39
  ### create()
@@ -192,7 +188,7 @@ Nothing.
192
188
 
193
189
  ### get()
194
190
 
195
- > **get**(`auditableItemGraphDocumentId`, `options?`, `cursor?`, `pageSize?`, `userIdentity?`, `nodeIdentity?`): `Promise`\<`IDocumentList`\>
191
+ > **get**(`auditableItemGraphDocumentId`, `options?`, `cursor?`, `limit?`, `userIdentity?`, `nodeIdentity?`): `Promise`\<`IDocumentList`\>
196
192
 
197
193
  Get a document using it's auditable item graph vertex id and optional revision.
198
194
 
@@ -250,11 +246,11 @@ By default extraction will auto detect the mime type of the document, this can b
250
246
 
251
247
  The cursor to get the next chunk of revisions.
252
248
 
253
- ##### pageSize?
249
+ ##### limit?
254
250
 
255
251
  `number`
256
252
 
257
- Page size of items to return, defaults to 1 so only most recent is returned.
253
+ Limit the number of items to return, defaults to 1 so only most recent is returned.
258
254
 
259
255
  ##### userIdentity?
260
256
 
@@ -405,7 +401,7 @@ Nothing.
405
401
 
406
402
  ### query()
407
403
 
408
- > **query**(`documentId`, `cursor?`, `pageSize?`, `userIdentity?`, `nodeIdentity?`): `Promise`\<`IAuditableItemGraphVertexList`\>
404
+ > **query**(`documentId`, `cursor?`, `limit?`, `userIdentity?`, `nodeIdentity?`): `Promise`\<`IAuditableItemGraphVertexList`\>
409
405
 
410
406
  Find all the document with a specific id.
411
407
 
@@ -423,11 +419,11 @@ The document id to find in the graph.
423
419
 
424
420
  The cursor to get the next chunk of documents.
425
421
 
426
- ##### pageSize?
422
+ ##### limit?
427
423
 
428
424
  `number`
429
425
 
430
- The page size to get the next chunk of documents.
426
+ The limit to get the next chunk of documents.
431
427
 
432
428
  ##### userIdentity?
433
429
 
package/locales/en.json CHANGED
@@ -5,11 +5,10 @@
5
5
  "updateFailed": "Failed to update document",
6
6
  "getFailed": "Failed to get document",
7
7
  "getRevisionFailed": "Failed to get document revision",
8
- "removeRevision": "Failed to remove document revision",
9
8
  "queryFailed": "Failed to query document",
10
9
  "documentRevisionNone": "There are no revisions in the document",
11
10
  "documentRevisionNotFound": "There is no revision number \"{notFoundId}\" in the document",
12
- "namespaceMismatch": "The namespace in the urn \"{id}\" does not match the namespace of the Document Management component \"{namespace}\""
11
+ "removeRevisionFailed": "Failed to remove document revision"
13
12
  }
14
13
  }
15
14
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/document-management-service",
3
- "version": "0.0.2-next.2",
3
+ "version": "0.0.2-next.4",
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.2",
25
+ "@twin.org/document-management-models": "0.0.2-next.4",
26
26
  "@twin.org/entity": "next",
27
27
  "@twin.org/entity-storage-models": "next",
28
28
  "@twin.org/nameof": "next",
@@ -47,5 +47,24 @@
47
47
  "dist/types",
48
48
  "locales",
49
49
  "docs"
50
- ]
50
+ ],
51
+ "keywords": [
52
+ "twin",
53
+ "trade",
54
+ "iota",
55
+ "framework",
56
+ "blockchain",
57
+ "document-management",
58
+ "documents",
59
+ "management",
60
+ "storage",
61
+ "rest-api",
62
+ "service",
63
+ "microservice",
64
+ "business-logic"
65
+ ],
66
+ "bugs": {
67
+ "url": "git+https://github.com/twinfoundation/document-management/issues"
68
+ },
69
+ "homepage": "https://twindev.org"
51
70
  }