@twin.org/document-management-service 0.0.2-next.3 → 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,11 +647,11 @@ 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 = {};
@@ -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
@@ -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
  /**
@@ -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;
@@ -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,11 +645,11 @@ 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 = {};
@@ -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
@@ -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
  /**
@@ -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;
@@ -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.
@@ -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,19 @@
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
+
3
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)
4
18
 
5
19
 
@@ -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
  }
@@ -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.3",
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.3",
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
  }