@twin.org/document-management-rest-client 0.0.1-next.2 → 0.0.1-next.20

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.
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  var apiCore = require('@twin.org/api-core');
4
- var apiModels = require('@twin.org/api-models');
5
4
  var core = require('@twin.org/core');
6
5
  var standardsUnece = require('@twin.org/standards-unece');
7
6
 
@@ -25,118 +24,160 @@ class DocumentManagementClient extends apiCore.BaseRestClient {
25
24
  * @param config The configuration for the client.
26
25
  */
27
26
  constructor(config) {
28
- super(DocumentManagementClient._CLASS_NAME, config, "documents");
27
+ super(DocumentManagementClient._CLASS_NAME, config, "document-management");
29
28
  }
30
29
  /**
31
- * Store a document in an auditable item graph vertex and add its content to blob storage.
30
+ * Store a document as an auditable item graph vertex and add its content to blob storage.
32
31
  * If the document id already exists and the blob data is different a new revision will be created.
33
32
  * For any other changes the current revision will be updated.
34
- * @param auditableItemGraphId The auditable item graph vertex id to create the document on.
35
33
  * @param documentId The document id to create.
36
34
  * @param documentIdFormat The format of the document identifier.
37
35
  * @param documentCode The code for the document type.
38
- * @param blob The data to create the document.
36
+ * @param blob The data to create the document with.
39
37
  * @param annotationObject Additional information to associate with the document.
40
- * @param createAttestation Flag to create an attestation for the document, defaults to false.
41
- * @returns The identifier for the document which includes the auditable item graph identifier.
38
+ * @param auditableItemGraphEdges The auditable item graph vertices to connect the document to.
39
+ * @param options Additional options for the set operation.
40
+ * @param options.createAttestation Flag to create an attestation for the document, defaults to false.
41
+ * @param options.addAlias Flag to add the document id as an alias to the aig vertex, defaults to true.
42
+ * @param options.aliasAnnotationObject Annotation object for the alias.
43
+ * @returns The auditable item graph vertex created for the document including its revision.
42
44
  */
43
- async set(auditableItemGraphId, documentId, documentIdFormat, documentCode, blob, annotationObject, createAttestation) {
44
- core.Guards.stringValue(this.CLASS_NAME, "auditableItemGraphId", auditableItemGraphId);
45
+ async create(documentId, documentIdFormat, documentCode, blob, annotationObject, auditableItemGraphEdges, options) {
45
46
  core.Guards.stringValue(this.CLASS_NAME, "documentId", documentId);
46
47
  core.Guards.arrayOneOf(this.CLASS_NAME, "documentCode", documentCode, Object.values(standardsUnece.UneceDocumentCodes));
47
48
  core.Guards.uint8Array(this.CLASS_NAME, "blob", blob);
48
- const response = await this.fetch("/:auditableItemGraphId", "POST", {
49
- pathParams: {
50
- auditableItemGraphId
51
- },
49
+ const response = await this.fetch("/", "POST", {
52
50
  body: {
53
51
  documentId,
54
52
  documentIdFormat,
55
53
  documentCode,
56
54
  blob: core.Converter.bytesToBase64(blob),
57
55
  annotationObject,
58
- createAttestation
56
+ auditableItemGraphEdges,
57
+ createAttestation: options?.createAttestation,
58
+ addAlias: options?.addAlias,
59
+ aliasAnnotationObject: options?.aliasAnnotationObject
59
60
  }
60
61
  });
61
62
  return response.headers.location;
62
63
  }
63
64
  /**
64
- * Get a specific document from an auditable item graph vertex.
65
- * @param auditableItemGraphId The auditable item graph vertex id to get the document from.
66
- * @param identifier The identifier of the document to get.
65
+ * Update a document as an auditable item graph vertex and add its content to blob storage.
66
+ * If the blob data is different a new revision will be created.
67
+ * For any other changes the current revision will be updated.
68
+ * @param auditableItemGraphDocumentId The auditable item graph vertex id which contains the document.
69
+ * @param blob The data to update the document with.
70
+ * @param annotationObject Additional information to associate with the document.
71
+ * @param auditableItemGraphEdges The auditable item graph vertices to connect the document to, if undefined retains current connections.
72
+ * @returns Nothing.
73
+ */
74
+ async update(auditableItemGraphDocumentId, blob, annotationObject, auditableItemGraphEdges) {
75
+ core.Urn.guard(this.CLASS_NAME, "auditableItemGraphDocumentId", auditableItemGraphDocumentId);
76
+ await this.fetch("/:auditableItemGraphDocumentId", "PUT", {
77
+ pathParams: {
78
+ auditableItemGraphDocumentId
79
+ },
80
+ body: {
81
+ blob: core.Is.uint8Array(blob) ? core.Converter.bytesToBase64(blob) : undefined,
82
+ annotationObject,
83
+ auditableItemGraphEdges
84
+ }
85
+ });
86
+ }
87
+ /**
88
+ * Get a document using it's auditable item graph vertex id and optional revision.
89
+ * @param auditableItemGraphDocumentId The auditable item graph vertex id which contains the document.
67
90
  * @param options Additional options for the get operation.
68
91
  * @param options.includeBlobStorageMetadata Flag to include the blob storage metadata for the document, defaults to false.
69
92
  * @param options.includeBlobStorageData Flag to include the blob storage data for the document, defaults to false.
70
93
  * @param options.includeAttestation Flag to include the attestation information for the document, defaults to false.
71
94
  * @param options.includeRemoved Flag to include deleted documents, defaults to false.
72
- * @param options.maxRevisionCount Max number of revisions to return, defaults to 0.
73
- * @param revisionCursor The cursor to get the next chunk of revisions.
95
+ * @param options.extractRuleGroupId If provided will extract data from the document using the specified rule group id.
96
+ * @param options.extractMimeType By default extraction will auto detect the mime type of the document, this can be used to override the detection.
97
+ * @param cursor The cursor to get the next chunk of revisions.
98
+ * @param pageSize Page size of items to return, defaults to 1 so only most recent is returned.
74
99
  * @returns The documents and revisions if requested, ordered by revision descending, cursor is set if there are more document revisions.
75
100
  */
76
- async get(auditableItemGraphId, identifier, options, revisionCursor) {
77
- core.Urn.guard(this.CLASS_NAME, "auditableItemGraphId", auditableItemGraphId);
78
- core.Urn.guard(this.CLASS_NAME, "identifier", identifier);
79
- const response = await this.fetch("/:auditableItemGraphId/:documentId", "GET", {
101
+ async get(auditableItemGraphDocumentId, options, cursor, pageSize) {
102
+ core.Urn.guard(this.CLASS_NAME, "auditableItemGraphDocumentId", auditableItemGraphDocumentId);
103
+ const response = await this.fetch("/:auditableItemGraphDocumentId", "GET", {
80
104
  pathParams: {
81
- auditableItemGraphId,
82
- documentId: identifier
105
+ auditableItemGraphDocumentId
83
106
  },
84
107
  query: {
85
108
  includeBlobStorageMetadata: options?.includeBlobStorageMetadata,
86
109
  includeBlobStorageData: options?.includeBlobStorageData,
87
110
  includeAttestation: options?.includeAttestation,
88
111
  includeRemoved: options?.includeRemoved,
89
- maxRevisionCount: options?.maxRevisionCount,
90
- revisionCursor
112
+ extractRuleGroupId: options?.extractRuleGroupId,
113
+ extractMimeType: options?.extractMimeType,
114
+ cursor,
115
+ pageSize: core.Coerce.string(pageSize)
91
116
  }
92
117
  });
93
118
  return response.body;
94
119
  }
95
120
  /**
96
- * Remove a specific document from an auditable item graph vertex.
97
- * The documents dateDeleted will be set, but can still be queried with the includeRemoved flag.
98
- * @param auditableItemGraphId The auditable item graph vertex id to remove the document from.
99
- * @param identifier The identifier of the document to remove.
100
- * @param options Additional options for the remove operation.
101
- * @param options.removeAllRevisions Flag to remove all revisions of the document, defaults to false.
102
- * @returns Nothing.
121
+ * Get a document revision using it's auditable item graph vertex id.
122
+ * @param auditableItemGraphDocumentId The auditable item graph vertex id which contains the document.
123
+ * @param revision The revision id for the document.
124
+ * @param options Additional options for the get operation.
125
+ * @param options.includeBlobStorageMetadata Flag to include the blob storage metadata for the document, defaults to false.
126
+ * @param options.includeBlobStorageData Flag to include the blob storage data for the document, defaults to false.
127
+ * @param options.includeAttestation Flag to include the attestation information for the document, defaults to false.
128
+ * @param options.extractRuleGroupId If provided will extract data from the document using the specified rule group id.
129
+ * @param options.extractMimeType By default extraction will auto detect the mime type of the document, this can be used to override the detection.
130
+ * @returns The documents and revisions if requested, ordered by revision descending, cursor is set if there are more document revisions.
103
131
  */
104
- async remove(auditableItemGraphId, identifier, options) {
105
- core.Urn.guard(this.CLASS_NAME, "auditableItemGraphId", auditableItemGraphId);
106
- core.Urn.guard(this.CLASS_NAME, "identifier", identifier);
107
- await this.fetch("/:auditableItemGraphId/:documentId", "DELETE", {
132
+ async getRevision(auditableItemGraphDocumentId, revision, options) {
133
+ core.Urn.guard(this.CLASS_NAME, "auditableItemGraphDocumentId", auditableItemGraphDocumentId);
134
+ core.Guards.integer(this.CLASS_NAME, "revision", revision);
135
+ const response = await this.fetch("/:auditableItemGraphDocumentId/:revision", "GET", {
108
136
  pathParams: {
109
- auditableItemGraphId,
110
- documentId: identifier
137
+ auditableItemGraphDocumentId,
138
+ revision: revision.toString()
111
139
  },
112
140
  query: {
113
- removeAllRevisions: options?.removeAllRevisions
141
+ includeBlobStorageMetadata: options?.includeBlobStorageMetadata,
142
+ includeBlobStorageData: options?.includeBlobStorageData,
143
+ includeAttestation: options?.includeAttestation,
144
+ extractRuleGroupId: options?.extractRuleGroupId,
145
+ extractMimeType: options?.extractMimeType
114
146
  }
115
147
  });
148
+ return response.body;
116
149
  }
117
150
  /**
118
- * Query an auditable item graph vertex for documents.
119
- * @param auditableItemGraphId The auditable item graph vertex to get the documents from.
120
- * @param documentCodes The document codes to query for, if undefined gets all document codes.
121
- * @param options Additional options for the query operation.
122
- * @param options.includeMostRecentRevisions Include the most recent 5 revisions, use the individual get to retrieve more.
123
- * @param options.includeRemoved Flag to include deleted documents, defaults to false.
124
- * @param cursor The cursor to get the next chunk of documents.
125
- * @returns The most recent revisions of each document, cursor is set if there are more documents.
151
+ * Remove an auditable item graph vertex using it's id.
152
+ * The document dateDeleted will be set, but can still be queried with the includeRemoved flag.
153
+ * @param auditableItemGraphDocumentId The auditable item graph vertex id which contains the document.
154
+ * @param revision The revision of the document to remove.
155
+ * @returns Nothing.
126
156
  */
127
- async query(auditableItemGraphId, documentCodes, options, cursor) {
128
- core.Urn.guard(this.CLASS_NAME, "auditableItemGraphId", auditableItemGraphId);
129
- const response = await this.fetch("/:auditableItemGraphId", "GET", {
157
+ async removeRevision(auditableItemGraphDocumentId, revision) {
158
+ core.Urn.guard(this.CLASS_NAME, "auditableItemGraphDocumentId", auditableItemGraphDocumentId);
159
+ core.Guards.number(this.CLASS_NAME, "revision", revision);
160
+ await this.fetch("/:auditableItemGraphDocumentId/:revision", "DELETE", {
130
161
  pathParams: {
131
- auditableItemGraphId
132
- },
162
+ auditableItemGraphDocumentId,
163
+ revision: revision.toString()
164
+ }
165
+ });
166
+ }
167
+ /**
168
+ * Find all the document with a specific id.
169
+ * @param documentId The document id to find in the graph.
170
+ * @param cursor The cursor to get the next chunk of documents.
171
+ * @param pageSize The page size to get the next chunk of documents.
172
+ * @returns The graph vertices that contain documents referencing the specified document id.
173
+ */
174
+ async query(documentId, cursor, pageSize) {
175
+ core.Guards.stringValue(this.CLASS_NAME, "documentId", documentId);
176
+ const response = await this.fetch("/", "GET", {
133
177
  query: {
134
- documentCodes: core.Is.arrayValue(documentCodes)
135
- ? apiModels.HttpParameterHelper.arrayToString(documentCodes)
136
- : undefined,
137
- includeMostRecentRevisions: options?.includeMostRecentRevisions,
138
- includeRemoved: options?.includeRemoved,
139
- cursor
178
+ documentId,
179
+ cursor,
180
+ pageSize: core.Coerce.string(pageSize)
140
181
  }
141
182
  });
142
183
  return response.body;
@@ -1,6 +1,5 @@
1
1
  import { BaseRestClient } from '@twin.org/api-core';
2
- import { HttpParameterHelper } from '@twin.org/api-models';
3
- import { Guards, Converter, Urn, Is } from '@twin.org/core';
2
+ import { Guards, Converter, Urn, Is, Coerce } from '@twin.org/core';
4
3
  import { UneceDocumentCodes } from '@twin.org/standards-unece';
5
4
 
6
5
  // Copyright 2024 IOTA Stiftung.
@@ -23,118 +22,160 @@ class DocumentManagementClient extends BaseRestClient {
23
22
  * @param config The configuration for the client.
24
23
  */
25
24
  constructor(config) {
26
- super(DocumentManagementClient._CLASS_NAME, config, "documents");
25
+ super(DocumentManagementClient._CLASS_NAME, config, "document-management");
27
26
  }
28
27
  /**
29
- * Store a document in an auditable item graph vertex and add its content to blob storage.
28
+ * Store a document as an auditable item graph vertex and add its content to blob storage.
30
29
  * If the document id already exists and the blob data is different a new revision will be created.
31
30
  * For any other changes the current revision will be updated.
32
- * @param auditableItemGraphId The auditable item graph vertex id to create the document on.
33
31
  * @param documentId The document id to create.
34
32
  * @param documentIdFormat The format of the document identifier.
35
33
  * @param documentCode The code for the document type.
36
- * @param blob The data to create the document.
34
+ * @param blob The data to create the document with.
37
35
  * @param annotationObject Additional information to associate with the document.
38
- * @param createAttestation Flag to create an attestation for the document, defaults to false.
39
- * @returns The identifier for the document which includes the auditable item graph identifier.
36
+ * @param auditableItemGraphEdges The auditable item graph vertices to connect the document to.
37
+ * @param options Additional options for the set operation.
38
+ * @param options.createAttestation Flag to create an attestation for the document, defaults to false.
39
+ * @param options.addAlias Flag to add the document id as an alias to the aig vertex, defaults to true.
40
+ * @param options.aliasAnnotationObject Annotation object for the alias.
41
+ * @returns The auditable item graph vertex created for the document including its revision.
40
42
  */
41
- async set(auditableItemGraphId, documentId, documentIdFormat, documentCode, blob, annotationObject, createAttestation) {
42
- Guards.stringValue(this.CLASS_NAME, "auditableItemGraphId", auditableItemGraphId);
43
+ async create(documentId, documentIdFormat, documentCode, blob, annotationObject, auditableItemGraphEdges, options) {
43
44
  Guards.stringValue(this.CLASS_NAME, "documentId", documentId);
44
45
  Guards.arrayOneOf(this.CLASS_NAME, "documentCode", documentCode, Object.values(UneceDocumentCodes));
45
46
  Guards.uint8Array(this.CLASS_NAME, "blob", blob);
46
- const response = await this.fetch("/:auditableItemGraphId", "POST", {
47
- pathParams: {
48
- auditableItemGraphId
49
- },
47
+ const response = await this.fetch("/", "POST", {
50
48
  body: {
51
49
  documentId,
52
50
  documentIdFormat,
53
51
  documentCode,
54
52
  blob: Converter.bytesToBase64(blob),
55
53
  annotationObject,
56
- createAttestation
54
+ auditableItemGraphEdges,
55
+ createAttestation: options?.createAttestation,
56
+ addAlias: options?.addAlias,
57
+ aliasAnnotationObject: options?.aliasAnnotationObject
57
58
  }
58
59
  });
59
60
  return response.headers.location;
60
61
  }
61
62
  /**
62
- * Get a specific document from an auditable item graph vertex.
63
- * @param auditableItemGraphId The auditable item graph vertex id to get the document from.
64
- * @param identifier The identifier of the document to get.
63
+ * Update a document as an auditable item graph vertex and add its content to blob storage.
64
+ * If the blob data is different a new revision will be created.
65
+ * For any other changes the current revision will be updated.
66
+ * @param auditableItemGraphDocumentId The auditable item graph vertex id which contains the document.
67
+ * @param blob The data to update the document with.
68
+ * @param annotationObject Additional information to associate with the document.
69
+ * @param auditableItemGraphEdges The auditable item graph vertices to connect the document to, if undefined retains current connections.
70
+ * @returns Nothing.
71
+ */
72
+ async update(auditableItemGraphDocumentId, blob, annotationObject, auditableItemGraphEdges) {
73
+ Urn.guard(this.CLASS_NAME, "auditableItemGraphDocumentId", auditableItemGraphDocumentId);
74
+ await this.fetch("/:auditableItemGraphDocumentId", "PUT", {
75
+ pathParams: {
76
+ auditableItemGraphDocumentId
77
+ },
78
+ body: {
79
+ blob: Is.uint8Array(blob) ? Converter.bytesToBase64(blob) : undefined,
80
+ annotationObject,
81
+ auditableItemGraphEdges
82
+ }
83
+ });
84
+ }
85
+ /**
86
+ * Get a document using it's auditable item graph vertex id and optional revision.
87
+ * @param auditableItemGraphDocumentId The auditable item graph vertex id which contains the document.
65
88
  * @param options Additional options for the get operation.
66
89
  * @param options.includeBlobStorageMetadata Flag to include the blob storage metadata for the document, defaults to false.
67
90
  * @param options.includeBlobStorageData Flag to include the blob storage data for the document, defaults to false.
68
91
  * @param options.includeAttestation Flag to include the attestation information for the document, defaults to false.
69
92
  * @param options.includeRemoved Flag to include deleted documents, defaults to false.
70
- * @param options.maxRevisionCount Max number of revisions to return, defaults to 0.
71
- * @param revisionCursor The cursor to get the next chunk of revisions.
93
+ * @param options.extractRuleGroupId If provided will extract data from the document using the specified rule group id.
94
+ * @param options.extractMimeType By default extraction will auto detect the mime type of the document, this can be used to override the detection.
95
+ * @param cursor The cursor to get the next chunk of revisions.
96
+ * @param pageSize Page size of items to return, defaults to 1 so only most recent is returned.
72
97
  * @returns The documents and revisions if requested, ordered by revision descending, cursor is set if there are more document revisions.
73
98
  */
74
- async get(auditableItemGraphId, identifier, options, revisionCursor) {
75
- Urn.guard(this.CLASS_NAME, "auditableItemGraphId", auditableItemGraphId);
76
- Urn.guard(this.CLASS_NAME, "identifier", identifier);
77
- const response = await this.fetch("/:auditableItemGraphId/:documentId", "GET", {
99
+ async get(auditableItemGraphDocumentId, options, cursor, pageSize) {
100
+ Urn.guard(this.CLASS_NAME, "auditableItemGraphDocumentId", auditableItemGraphDocumentId);
101
+ const response = await this.fetch("/:auditableItemGraphDocumentId", "GET", {
78
102
  pathParams: {
79
- auditableItemGraphId,
80
- documentId: identifier
103
+ auditableItemGraphDocumentId
81
104
  },
82
105
  query: {
83
106
  includeBlobStorageMetadata: options?.includeBlobStorageMetadata,
84
107
  includeBlobStorageData: options?.includeBlobStorageData,
85
108
  includeAttestation: options?.includeAttestation,
86
109
  includeRemoved: options?.includeRemoved,
87
- maxRevisionCount: options?.maxRevisionCount,
88
- revisionCursor
110
+ extractRuleGroupId: options?.extractRuleGroupId,
111
+ extractMimeType: options?.extractMimeType,
112
+ cursor,
113
+ pageSize: Coerce.string(pageSize)
89
114
  }
90
115
  });
91
116
  return response.body;
92
117
  }
93
118
  /**
94
- * Remove a specific document from an auditable item graph vertex.
95
- * The documents dateDeleted will be set, but can still be queried with the includeRemoved flag.
96
- * @param auditableItemGraphId The auditable item graph vertex id to remove the document from.
97
- * @param identifier The identifier of the document to remove.
98
- * @param options Additional options for the remove operation.
99
- * @param options.removeAllRevisions Flag to remove all revisions of the document, defaults to false.
100
- * @returns Nothing.
119
+ * Get a document revision using it's auditable item graph vertex id.
120
+ * @param auditableItemGraphDocumentId The auditable item graph vertex id which contains the document.
121
+ * @param revision The revision id for the document.
122
+ * @param options Additional options for the get operation.
123
+ * @param options.includeBlobStorageMetadata Flag to include the blob storage metadata for the document, defaults to false.
124
+ * @param options.includeBlobStorageData Flag to include the blob storage data for the document, defaults to false.
125
+ * @param options.includeAttestation Flag to include the attestation information for the document, defaults to false.
126
+ * @param options.extractRuleGroupId If provided will extract data from the document using the specified rule group id.
127
+ * @param options.extractMimeType By default extraction will auto detect the mime type of the document, this can be used to override the detection.
128
+ * @returns The documents and revisions if requested, ordered by revision descending, cursor is set if there are more document revisions.
101
129
  */
102
- async remove(auditableItemGraphId, identifier, options) {
103
- Urn.guard(this.CLASS_NAME, "auditableItemGraphId", auditableItemGraphId);
104
- Urn.guard(this.CLASS_NAME, "identifier", identifier);
105
- await this.fetch("/:auditableItemGraphId/:documentId", "DELETE", {
130
+ async getRevision(auditableItemGraphDocumentId, revision, options) {
131
+ Urn.guard(this.CLASS_NAME, "auditableItemGraphDocumentId", auditableItemGraphDocumentId);
132
+ Guards.integer(this.CLASS_NAME, "revision", revision);
133
+ const response = await this.fetch("/:auditableItemGraphDocumentId/:revision", "GET", {
106
134
  pathParams: {
107
- auditableItemGraphId,
108
- documentId: identifier
135
+ auditableItemGraphDocumentId,
136
+ revision: revision.toString()
109
137
  },
110
138
  query: {
111
- removeAllRevisions: options?.removeAllRevisions
139
+ includeBlobStorageMetadata: options?.includeBlobStorageMetadata,
140
+ includeBlobStorageData: options?.includeBlobStorageData,
141
+ includeAttestation: options?.includeAttestation,
142
+ extractRuleGroupId: options?.extractRuleGroupId,
143
+ extractMimeType: options?.extractMimeType
112
144
  }
113
145
  });
146
+ return response.body;
114
147
  }
115
148
  /**
116
- * Query an auditable item graph vertex for documents.
117
- * @param auditableItemGraphId The auditable item graph vertex to get the documents from.
118
- * @param documentCodes The document codes to query for, if undefined gets all document codes.
119
- * @param options Additional options for the query operation.
120
- * @param options.includeMostRecentRevisions Include the most recent 5 revisions, use the individual get to retrieve more.
121
- * @param options.includeRemoved Flag to include deleted documents, defaults to false.
122
- * @param cursor The cursor to get the next chunk of documents.
123
- * @returns The most recent revisions of each document, cursor is set if there are more documents.
149
+ * Remove an auditable item graph vertex using it's id.
150
+ * The document dateDeleted will be set, but can still be queried with the includeRemoved flag.
151
+ * @param auditableItemGraphDocumentId The auditable item graph vertex id which contains the document.
152
+ * @param revision The revision of the document to remove.
153
+ * @returns Nothing.
124
154
  */
125
- async query(auditableItemGraphId, documentCodes, options, cursor) {
126
- Urn.guard(this.CLASS_NAME, "auditableItemGraphId", auditableItemGraphId);
127
- const response = await this.fetch("/:auditableItemGraphId", "GET", {
155
+ async removeRevision(auditableItemGraphDocumentId, revision) {
156
+ Urn.guard(this.CLASS_NAME, "auditableItemGraphDocumentId", auditableItemGraphDocumentId);
157
+ Guards.number(this.CLASS_NAME, "revision", revision);
158
+ await this.fetch("/:auditableItemGraphDocumentId/:revision", "DELETE", {
128
159
  pathParams: {
129
- auditableItemGraphId
130
- },
160
+ auditableItemGraphDocumentId,
161
+ revision: revision.toString()
162
+ }
163
+ });
164
+ }
165
+ /**
166
+ * Find all the document with a specific id.
167
+ * @param documentId The document id to find in the graph.
168
+ * @param cursor The cursor to get the next chunk of documents.
169
+ * @param pageSize The page size to get the next chunk of documents.
170
+ * @returns The graph vertices that contain documents referencing the specified document id.
171
+ */
172
+ async query(documentId, cursor, pageSize) {
173
+ Guards.stringValue(this.CLASS_NAME, "documentId", documentId);
174
+ const response = await this.fetch("/", "GET", {
131
175
  query: {
132
- documentCodes: Is.arrayValue(documentCodes)
133
- ? HttpParameterHelper.arrayToString(documentCodes)
134
- : undefined,
135
- includeMostRecentRevisions: options?.includeMostRecentRevisions,
136
- includeRemoved: options?.includeRemoved,
137
- cursor
176
+ documentId,
177
+ cursor,
178
+ pageSize: Coerce.string(pageSize)
138
179
  }
139
180
  });
140
181
  return response.body;
@@ -1,5 +1,6 @@
1
1
  import { BaseRestClient } from "@twin.org/api-core";
2
- import { type IBaseRestClientConfig } from "@twin.org/api-models";
2
+ import type { IBaseRestClientConfig } from "@twin.org/api-models";
3
+ import type { IAuditableItemGraphVertexList } from "@twin.org/auditable-item-graph-models";
3
4
  import type { IJsonLdNodeObject } from "@twin.org/data-json-ld";
4
5
  import type { IDocument, IDocumentList, IDocumentManagementComponent } from "@twin.org/document-management-models";
5
6
  import { UneceDocumentCodes } from "@twin.org/standards-unece";
@@ -17,63 +18,100 @@ export declare class DocumentManagementClient extends BaseRestClient implements
17
18
  */
18
19
  constructor(config: IBaseRestClientConfig);
19
20
  /**
20
- * Store a document in an auditable item graph vertex and add its content to blob storage.
21
+ * Store a document as an auditable item graph vertex and add its content to blob storage.
21
22
  * If the document id already exists and the blob data is different a new revision will be created.
22
23
  * For any other changes the current revision will be updated.
23
- * @param auditableItemGraphId The auditable item graph vertex id to create the document on.
24
24
  * @param documentId The document id to create.
25
25
  * @param documentIdFormat The format of the document identifier.
26
26
  * @param documentCode The code for the document type.
27
- * @param blob The data to create the document.
27
+ * @param blob The data to create the document with.
28
28
  * @param annotationObject Additional information to associate with the document.
29
- * @param createAttestation Flag to create an attestation for the document, defaults to false.
30
- * @returns The identifier for the document which includes the auditable item graph identifier.
29
+ * @param auditableItemGraphEdges The auditable item graph vertices to connect the document to.
30
+ * @param options Additional options for the set operation.
31
+ * @param options.createAttestation Flag to create an attestation for the document, defaults to false.
32
+ * @param options.addAlias Flag to add the document id as an alias to the aig vertex, defaults to true.
33
+ * @param options.aliasAnnotationObject Annotation object for the alias.
34
+ * @returns The auditable item graph vertex created for the document including its revision.
31
35
  */
32
- set(auditableItemGraphId: string, documentId: string, documentIdFormat: string | undefined, documentCode: UneceDocumentCodes, blob: Uint8Array, annotationObject?: IJsonLdNodeObject, createAttestation?: boolean): Promise<string>;
36
+ create(documentId: string, documentIdFormat: string | undefined, documentCode: UneceDocumentCodes, blob: Uint8Array, annotationObject?: IJsonLdNodeObject, auditableItemGraphEdges?: {
37
+ id: string;
38
+ addAlias?: boolean;
39
+ aliasAnnotationObject?: IJsonLdNodeObject;
40
+ }[], options?: {
41
+ createAttestation?: boolean;
42
+ addAlias?: boolean;
43
+ aliasAnnotationObject?: IJsonLdNodeObject;
44
+ }): Promise<string>;
33
45
  /**
34
- * Get a specific document from an auditable item graph vertex.
35
- * @param auditableItemGraphId The auditable item graph vertex id to get the document from.
36
- * @param identifier The identifier of the document to get.
46
+ * Update a document as an auditable item graph vertex and add its content to blob storage.
47
+ * If the blob data is different a new revision will be created.
48
+ * For any other changes the current revision will be updated.
49
+ * @param auditableItemGraphDocumentId The auditable item graph vertex id which contains the document.
50
+ * @param blob The data to update the document with.
51
+ * @param annotationObject Additional information to associate with the document.
52
+ * @param auditableItemGraphEdges The auditable item graph vertices to connect the document to, if undefined retains current connections.
53
+ * @returns Nothing.
54
+ */
55
+ update(auditableItemGraphDocumentId: string, blob?: Uint8Array, annotationObject?: IJsonLdNodeObject, auditableItemGraphEdges?: {
56
+ id: string;
57
+ addAlias?: boolean;
58
+ aliasAnnotationObject?: IJsonLdNodeObject;
59
+ }[]): Promise<void>;
60
+ /**
61
+ * Get a document using it's auditable item graph vertex id and optional revision.
62
+ * @param auditableItemGraphDocumentId The auditable item graph vertex id which contains the document.
37
63
  * @param options Additional options for the get operation.
38
64
  * @param options.includeBlobStorageMetadata Flag to include the blob storage metadata for the document, defaults to false.
39
65
  * @param options.includeBlobStorageData Flag to include the blob storage data for the document, defaults to false.
40
66
  * @param options.includeAttestation Flag to include the attestation information for the document, defaults to false.
41
67
  * @param options.includeRemoved Flag to include deleted documents, defaults to false.
42
- * @param options.maxRevisionCount Max number of revisions to return, defaults to 0.
43
- * @param revisionCursor The cursor to get the next chunk of revisions.
68
+ * @param options.extractRuleGroupId If provided will extract data from the document using the specified rule group id.
69
+ * @param options.extractMimeType By default extraction will auto detect the mime type of the document, this can be used to override the detection.
70
+ * @param cursor The cursor to get the next chunk of revisions.
71
+ * @param pageSize Page size of items to return, defaults to 1 so only most recent is returned.
44
72
  * @returns The documents and revisions if requested, ordered by revision descending, cursor is set if there are more document revisions.
45
73
  */
46
- get(auditableItemGraphId: string, identifier: string, options?: {
74
+ get(auditableItemGraphDocumentId: string, options?: {
47
75
  includeBlobStorageMetadata?: boolean;
48
76
  includeBlobStorageData?: boolean;
49
77
  includeAttestation?: boolean;
50
78
  includeRemoved?: boolean;
51
- maxRevisionCount?: number;
52
- }, revisionCursor?: string): Promise<IDocument>;
79
+ extractRuleGroupId?: string;
80
+ extractMimeType?: string;
81
+ }, cursor?: string, pageSize?: number): Promise<IDocumentList>;
53
82
  /**
54
- * Remove a specific document from an auditable item graph vertex.
55
- * The documents dateDeleted will be set, but can still be queried with the includeRemoved flag.
56
- * @param auditableItemGraphId The auditable item graph vertex id to remove the document from.
57
- * @param identifier The identifier of the document to remove.
58
- * @param options Additional options for the remove operation.
59
- * @param options.removeAllRevisions Flag to remove all revisions of the document, defaults to false.
83
+ * Get a document revision using it's auditable item graph vertex id.
84
+ * @param auditableItemGraphDocumentId The auditable item graph vertex id which contains the document.
85
+ * @param revision The revision id for the document.
86
+ * @param options Additional options for the get operation.
87
+ * @param options.includeBlobStorageMetadata Flag to include the blob storage metadata for the document, defaults to false.
88
+ * @param options.includeBlobStorageData Flag to include the blob storage data for the document, defaults to false.
89
+ * @param options.includeAttestation Flag to include the attestation information for the document, defaults to false.
90
+ * @param options.extractRuleGroupId If provided will extract data from the document using the specified rule group id.
91
+ * @param options.extractMimeType By default extraction will auto detect the mime type of the document, this can be used to override the detection.
92
+ * @returns The documents and revisions if requested, ordered by revision descending, cursor is set if there are more document revisions.
93
+ */
94
+ getRevision(auditableItemGraphDocumentId: string, revision: number, options?: {
95
+ includeBlobStorageMetadata?: boolean;
96
+ includeBlobStorageData?: boolean;
97
+ includeAttestation?: boolean;
98
+ extractRuleGroupId?: string;
99
+ extractMimeType?: string;
100
+ }): Promise<IDocument>;
101
+ /**
102
+ * Remove an auditable item graph vertex using it's id.
103
+ * The document dateDeleted will be set, but can still be queried with the includeRemoved flag.
104
+ * @param auditableItemGraphDocumentId The auditable item graph vertex id which contains the document.
105
+ * @param revision The revision of the document to remove.
60
106
  * @returns Nothing.
61
107
  */
62
- remove(auditableItemGraphId: string, identifier: string, options?: {
63
- removeAllRevisions?: boolean;
64
- }): Promise<void>;
108
+ removeRevision(auditableItemGraphDocumentId: string, revision: number): Promise<void>;
65
109
  /**
66
- * Query an auditable item graph vertex for documents.
67
- * @param auditableItemGraphId The auditable item graph vertex to get the documents from.
68
- * @param documentCodes The document codes to query for, if undefined gets all document codes.
69
- * @param options Additional options for the query operation.
70
- * @param options.includeMostRecentRevisions Include the most recent 5 revisions, use the individual get to retrieve more.
71
- * @param options.includeRemoved Flag to include deleted documents, defaults to false.
110
+ * Find all the document with a specific id.
111
+ * @param documentId The document id to find in the graph.
72
112
  * @param cursor The cursor to get the next chunk of documents.
73
- * @returns The most recent revisions of each document, cursor is set if there are more documents.
113
+ * @param pageSize The page size to get the next chunk of documents.
114
+ * @returns The graph vertices that contain documents referencing the specified document id.
74
115
  */
75
- query(auditableItemGraphId: string, documentCodes?: UneceDocumentCodes[], options?: {
76
- includeMostRecentRevisions?: boolean;
77
- includeRemoved?: boolean;
78
- }, cursor?: string): Promise<IDocumentList>;
116
+ query(documentId: string, cursor?: string, pageSize?: number): Promise<IAuditableItemGraphVertexList>;
79
117
  }
package/docs/changelog.md CHANGED
@@ -1,5 +1,195 @@
1
1
  # @twin.org/document-management-rest-client - Changelog
2
2
 
3
- ## v0.0.1-next.2
3
+ ## [0.0.1-next.20](https://github.com/twinfoundation/document-management/compare/document-management-rest-client-v0.0.1-next.19...document-management-rest-client-v0.0.1-next.20) (2025-06-20)
4
+
5
+
6
+ ### Features
7
+
8
+ * document get can perform extraction ([#6](https://github.com/twinfoundation/document-management/issues/6)) ([5ce6d37](https://github.com/twinfoundation/document-management/commit/5ce6d37432ad271ca5783f422846f4be98ec2215))
9
+ * get document revision ([080eddc](https://github.com/twinfoundation/document-management/commit/080eddcc024c622dda6bb36f60f5fa80a86cf5bb))
10
+ * store document as a vertex ([#2](https://github.com/twinfoundation/document-management/issues/2)) ([7febedc](https://github.com/twinfoundation/document-management/commit/7febedc3fb31de9c19565d6326341046834f2c74))
11
+ * update dependencies ([f9d8641](https://github.com/twinfoundation/document-management/commit/f9d86417dba24027699225ec7473296e361dcb00))
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * adding missing route for the document management ([#4](https://github.com/twinfoundation/document-management/issues/4)) ([fd3292e](https://github.com/twinfoundation/document-management/commit/fd3292ede5014847ae2f2bcadb174b6552486154))
17
+
18
+
19
+ ### Dependencies
20
+
21
+ * The following workspace dependencies were updated
22
+ * dependencies
23
+ * @twin.org/document-management-models bumped from 0.0.1-next.19 to 0.0.1-next.20
24
+
25
+ ## [0.0.1-next.19](https://github.com/twinfoundation/document-management/compare/document-management-rest-client-v0.0.1-next.18...document-management-rest-client-v0.0.1-next.19) (2025-06-20)
26
+
27
+
28
+ ### Miscellaneous Chores
29
+
30
+ * **document-management-rest-client:** Synchronize repo versions
31
+
32
+
33
+ ### Dependencies
34
+
35
+ * The following workspace dependencies were updated
36
+ * dependencies
37
+ * @twin.org/document-management-models bumped from 0.0.1-next.18 to 0.0.1-next.19
38
+
39
+ ## [0.0.1-next.18](https://github.com/twinfoundation/document-management/compare/document-management-rest-client-v0.0.1-next.17...document-management-rest-client-v0.0.1-next.18) (2025-06-18)
40
+
41
+
42
+ ### Miscellaneous Chores
43
+
44
+ * **document-management-rest-client:** Synchronize repo versions
45
+
46
+
47
+ ### Dependencies
48
+
49
+ * The following workspace dependencies were updated
50
+ * dependencies
51
+ * @twin.org/document-management-models bumped from 0.0.1-next.17 to 0.0.1-next.18
52
+
53
+ ## [0.0.1-next.17](https://github.com/twinfoundation/document-management/compare/document-management-rest-client-v0.0.1-next.16...document-management-rest-client-v0.0.1-next.17) (2025-06-12)
54
+
55
+
56
+ ### Features
57
+
58
+ * update dependencies ([f9d8641](https://github.com/twinfoundation/document-management/commit/f9d86417dba24027699225ec7473296e361dcb00))
59
+
60
+
61
+ ### Dependencies
62
+
63
+ * The following workspace dependencies were updated
64
+ * dependencies
65
+ * @twin.org/document-management-models bumped from 0.0.1-next.16 to 0.0.1-next.17
66
+
67
+ ## [0.0.1-next.16](https://github.com/twinfoundation/document-management/compare/document-management-rest-client-v0.0.1-next.15...document-management-rest-client-v0.0.1-next.16) (2025-06-03)
68
+
69
+
70
+ ### Miscellaneous Chores
71
+
72
+ * **document-management-rest-client:** Synchronize repo versions
73
+
74
+
75
+ ### Dependencies
76
+
77
+ * The following workspace dependencies were updated
78
+ * dependencies
79
+ * @twin.org/document-management-models bumped from 0.0.1-next.15 to 0.0.1-next.16
80
+
81
+ ## [0.0.1-next.15](https://github.com/twinfoundation/document-management/compare/document-management-rest-client-v0.0.1-next.14...document-management-rest-client-v0.0.1-next.15) (2025-05-28)
82
+
83
+
84
+ ### Miscellaneous Chores
85
+
86
+ * **document-management-rest-client:** Synchronize repo versions
87
+
88
+
89
+ ### Dependencies
90
+
91
+ * The following workspace dependencies were updated
92
+ * dependencies
93
+ * @twin.org/document-management-models bumped from 0.0.1-next.14 to 0.0.1-next.15
94
+
95
+ ## [0.0.1-next.14](https://github.com/twinfoundation/document-management/compare/document-management-rest-client-v0.0.1-next.13...document-management-rest-client-v0.0.1-next.14) (2025-05-08)
96
+
97
+
98
+ ### Miscellaneous Chores
99
+
100
+ * **document-management-rest-client:** Synchronize repo versions
101
+
102
+
103
+ ### Dependencies
104
+
105
+ * The following workspace dependencies were updated
106
+ * dependencies
107
+ * @twin.org/document-management-models bumped from 0.0.1-next.13 to 0.0.1-next.14
108
+
109
+ ## [0.0.1-next.13](https://github.com/twinfoundation/document-management/compare/document-management-rest-client-v0.0.1-next.12...document-management-rest-client-v0.0.1-next.13) (2025-04-30)
110
+
111
+
112
+ ### Miscellaneous Chores
113
+
114
+ * **document-management-rest-client:** Synchronize repo versions
115
+
116
+
117
+ ### Dependencies
118
+
119
+ * The following workspace dependencies were updated
120
+ * dependencies
121
+ * @twin.org/document-management-models bumped from 0.0.1-next.12 to 0.0.1-next.13
122
+
123
+ ## [0.0.1-next.12](https://github.com/twinfoundation/document-management/compare/document-management-rest-client-v0.0.1-next.11...document-management-rest-client-v0.0.1-next.12) (2025-04-30)
124
+
125
+
126
+ ### Features
127
+
128
+ * get document revision ([080eddc](https://github.com/twinfoundation/document-management/commit/080eddcc024c622dda6bb36f60f5fa80a86cf5bb))
129
+
130
+
131
+ ### Dependencies
132
+
133
+ * The following workspace dependencies were updated
134
+ * dependencies
135
+ * @twin.org/document-management-models bumped from 0.0.1-next.11 to 0.0.1-next.12
136
+
137
+ ## [0.0.1-next.11](https://github.com/twinfoundation/document-management/compare/document-management-rest-client-v0.0.1-next.10...document-management-rest-client-v0.0.1-next.11) (2025-04-28)
138
+
139
+
140
+ ### Features
141
+
142
+ * document get can perform extraction ([#6](https://github.com/twinfoundation/document-management/issues/6)) ([5ce6d37](https://github.com/twinfoundation/document-management/commit/5ce6d37432ad271ca5783f422846f4be98ec2215))
143
+
144
+
145
+ ### Dependencies
146
+
147
+ * The following workspace dependencies were updated
148
+ * dependencies
149
+ * @twin.org/document-management-models bumped from 0.0.1-next.10 to 0.0.1-next.11
150
+
151
+ ## [0.0.1-next.10](https://github.com/twinfoundation/document-management/compare/document-management-rest-client-v0.0.1-next.9...document-management-rest-client-v0.0.1-next.10) (2025-04-25)
152
+
153
+
154
+ ### Bug Fixes
155
+
156
+ * adding missing route for the document management ([#4](https://github.com/twinfoundation/document-management/issues/4)) ([fd3292e](https://github.com/twinfoundation/document-management/commit/fd3292ede5014847ae2f2bcadb174b6552486154))
157
+
158
+
159
+ ### Dependencies
160
+
161
+ * The following workspace dependencies were updated
162
+ * dependencies
163
+ * @twin.org/document-management-models bumped from 0.0.1-next.9 to 0.0.1-next.10
164
+
165
+ ## [0.0.1-next.9](https://github.com/twinfoundation/document-management/compare/document-management-rest-client-v0.0.1-next.8...document-management-rest-client-v0.0.1-next.9) (2025-04-17)
166
+
167
+
168
+ ### Features
169
+
170
+ * store document as a vertex ([#2](https://github.com/twinfoundation/document-management/issues/2)) ([7febedc](https://github.com/twinfoundation/document-management/commit/7febedc3fb31de9c19565d6326341046834f2c74))
171
+
172
+
173
+ ### Dependencies
174
+
175
+ * The following workspace dependencies were updated
176
+ * dependencies
177
+ * @twin.org/document-management-models bumped from 0.0.1-next.8 to 0.0.1-next.9
178
+
179
+ ## [0.0.1-next.8](https://github.com/twinfoundation/document-management/compare/document-management-rest-client-v0.0.1-next.7...document-management-rest-client-v0.0.1-next.8) (2025-03-28)
180
+
181
+
182
+ ### Miscellaneous Chores
183
+
184
+ * **document-management-rest-client:** Synchronize repo versions
185
+
186
+
187
+ ### Dependencies
188
+
189
+ * The following workspace dependencies were updated
190
+ * dependencies
191
+ * @twin.org/document-management-models bumped from 0.0.1-next.7 to 0.0.1-next.8
192
+
193
+ ## v0.0.1-next.7
4
194
 
5
195
  - Initial Release
@@ -12,9 +12,9 @@ Client for performing document management through to REST endpoints.
12
12
 
13
13
  ## Constructors
14
14
 
15
- ### new DocumentManagementClient()
15
+ ### Constructor
16
16
 
17
- > **new DocumentManagementClient**(`config`): [`DocumentManagementClient`](DocumentManagementClient.md)
17
+ > **new DocumentManagementClient**(`config`): `DocumentManagementClient`
18
18
 
19
19
  Create a new instance of DocumentManagementClient.
20
20
 
@@ -28,7 +28,7 @@ The configuration for the client.
28
28
 
29
29
  #### Returns
30
30
 
31
- [`DocumentManagementClient`](DocumentManagementClient.md)
31
+ `DocumentManagementClient`
32
32
 
33
33
  #### Overrides
34
34
 
@@ -48,22 +48,16 @@ Runtime name for the class.
48
48
 
49
49
  ## Methods
50
50
 
51
- ### set()
51
+ ### create()
52
52
 
53
- > **set**(`auditableItemGraphId`, `documentId`, `documentIdFormat`, `documentCode`, `blob`, `annotationObject`?, `createAttestation`?): `Promise`\<`string`\>
53
+ > **create**(`documentId`, `documentIdFormat`, `documentCode`, `blob`, `annotationObject?`, `auditableItemGraphEdges?`, `options?`): `Promise`\<`string`\>
54
54
 
55
- Store a document in an auditable item graph vertex and add its content to blob storage.
55
+ Store a document as an auditable item graph vertex and add its content to blob storage.
56
56
  If the document id already exists and the blob data is different a new revision will be created.
57
57
  For any other changes the current revision will be updated.
58
58
 
59
59
  #### Parameters
60
60
 
61
- ##### auditableItemGraphId
62
-
63
- `string`
64
-
65
- The auditable item graph vertex id to create the document on.
66
-
67
61
  ##### documentId
68
62
 
69
63
  `string`
@@ -86,7 +80,7 @@ The code for the document type.
86
80
 
87
81
  `Uint8Array`
88
82
 
89
- The data to create the document.
83
+ The data to create the document with.
90
84
 
91
85
  ##### annotationObject?
92
86
 
@@ -94,87 +88,161 @@ The data to create the document.
94
88
 
95
89
  Additional information to associate with the document.
96
90
 
97
- ##### createAttestation?
91
+ ##### auditableItemGraphEdges?
92
+
93
+ `object`[]
94
+
95
+ The auditable item graph vertices to connect the document to.
96
+
97
+ ##### options?
98
+
99
+ Additional options for the set operation.
100
+
101
+ ###### createAttestation?
98
102
 
99
103
  `boolean`
100
104
 
101
105
  Flag to create an attestation for the document, defaults to false.
102
106
 
107
+ ###### addAlias?
108
+
109
+ `boolean`
110
+
111
+ Flag to add the document id as an alias to the aig vertex, defaults to true.
112
+
113
+ ###### aliasAnnotationObject?
114
+
115
+ `IJsonLdNodeObject`
116
+
117
+ Annotation object for the alias.
118
+
103
119
  #### Returns
104
120
 
105
121
  `Promise`\<`string`\>
106
122
 
107
- The identifier for the document which includes the auditable item graph identifier.
123
+ The auditable item graph vertex created for the document including its revision.
108
124
 
109
125
  #### Implementation of
110
126
 
111
- `IDocumentManagementComponent.set`
127
+ `IDocumentManagementComponent.create`
112
128
 
113
129
  ***
114
130
 
115
- ### get()
131
+ ### update()
116
132
 
117
- > **get**(`auditableItemGraphId`, `identifier`, `options`?, `revisionCursor`?): `Promise`\<`IDocument`\>
133
+ > **update**(`auditableItemGraphDocumentId`, `blob?`, `annotationObject?`, `auditableItemGraphEdges?`): `Promise`\<`void`\>
118
134
 
119
- Get a specific document from an auditable item graph vertex.
135
+ Update a document as an auditable item graph vertex and add its content to blob storage.
136
+ If the blob data is different a new revision will be created.
137
+ For any other changes the current revision will be updated.
120
138
 
121
139
  #### Parameters
122
140
 
123
- ##### auditableItemGraphId
141
+ ##### auditableItemGraphDocumentId
124
142
 
125
143
  `string`
126
144
 
127
- The auditable item graph vertex id to get the document from.
145
+ The auditable item graph vertex id which contains the document.
146
+
147
+ ##### blob?
148
+
149
+ `Uint8Array`\<`ArrayBufferLike`\>
150
+
151
+ The data to update the document with.
152
+
153
+ ##### annotationObject?
154
+
155
+ `IJsonLdNodeObject`
156
+
157
+ Additional information to associate with the document.
128
158
 
129
- ##### identifier
159
+ ##### auditableItemGraphEdges?
160
+
161
+ `object`[]
162
+
163
+ The auditable item graph vertices to connect the document to, if undefined retains current connections.
164
+
165
+ #### Returns
166
+
167
+ `Promise`\<`void`\>
168
+
169
+ Nothing.
170
+
171
+ #### Implementation of
172
+
173
+ `IDocumentManagementComponent.update`
174
+
175
+ ***
176
+
177
+ ### get()
178
+
179
+ > **get**(`auditableItemGraphDocumentId`, `options?`, `cursor?`, `pageSize?`): `Promise`\<`IDocumentList`\>
180
+
181
+ Get a document using it's auditable item graph vertex id and optional revision.
182
+
183
+ #### Parameters
184
+
185
+ ##### auditableItemGraphDocumentId
130
186
 
131
187
  `string`
132
188
 
133
- The identifier of the document to get.
189
+ The auditable item graph vertex id which contains the document.
134
190
 
135
191
  ##### options?
136
192
 
137
193
  Additional options for the get operation.
138
194
 
139
- ###### includeBlobStorageMetadata
195
+ ###### includeBlobStorageMetadata?
140
196
 
141
197
  `boolean`
142
198
 
143
199
  Flag to include the blob storage metadata for the document, defaults to false.
144
200
 
145
- ###### includeBlobStorageData
201
+ ###### includeBlobStorageData?
146
202
 
147
203
  `boolean`
148
204
 
149
205
  Flag to include the blob storage data for the document, defaults to false.
150
206
 
151
- ###### includeAttestation
207
+ ###### includeAttestation?
152
208
 
153
209
  `boolean`
154
210
 
155
211
  Flag to include the attestation information for the document, defaults to false.
156
212
 
157
- ###### includeRemoved
213
+ ###### includeRemoved?
158
214
 
159
215
  `boolean`
160
216
 
161
217
  Flag to include deleted documents, defaults to false.
162
218
 
163
- ###### maxRevisionCount
219
+ ###### extractRuleGroupId?
164
220
 
165
- `number`
221
+ `string`
166
222
 
167
- Max number of revisions to return, defaults to 0.
223
+ If provided will extract data from the document using the specified rule group id.
168
224
 
169
- ##### revisionCursor?
225
+ ###### extractMimeType?
226
+
227
+ `string`
228
+
229
+ By default extraction will auto detect the mime type of the document, this can be used to override the detection.
230
+
231
+ ##### cursor?
170
232
 
171
233
  `string`
172
234
 
173
235
  The cursor to get the next chunk of revisions.
174
236
 
237
+ ##### pageSize?
238
+
239
+ `number`
240
+
241
+ Page size of items to return, defaults to 1 so only most recent is returned.
242
+
175
243
  #### Returns
176
244
 
177
- `Promise`\<`IDocument`\>
245
+ `Promise`\<`IDocumentList`\>
178
246
 
179
247
  The documents and revisions if requested, ordered by revision descending, cursor is set if there are more document revisions.
180
248
 
@@ -184,84 +252,118 @@ The documents and revisions if requested, ordered by revision descending, cursor
184
252
 
185
253
  ***
186
254
 
187
- ### remove()
255
+ ### getRevision()
188
256
 
189
- > **remove**(`auditableItemGraphId`, `identifier`, `options`?): `Promise`\<`void`\>
257
+ > **getRevision**(`auditableItemGraphDocumentId`, `revision`, `options?`): `Promise`\<`IDocument`\>
190
258
 
191
- Remove a specific document from an auditable item graph vertex.
192
- The documents dateDeleted will be set, but can still be queried with the includeRemoved flag.
259
+ Get a document revision using it's auditable item graph vertex id.
193
260
 
194
261
  #### Parameters
195
262
 
196
- ##### auditableItemGraphId
263
+ ##### auditableItemGraphDocumentId
197
264
 
198
265
  `string`
199
266
 
200
- The auditable item graph vertex id to remove the document from.
267
+ The auditable item graph vertex id which contains the document.
201
268
 
202
- ##### identifier
269
+ ##### revision
203
270
 
204
- `string`
271
+ `number`
205
272
 
206
- The identifier of the document to remove.
273
+ The revision id for the document.
207
274
 
208
275
  ##### options?
209
276
 
210
- Additional options for the remove operation.
277
+ Additional options for the get operation.
278
+
279
+ ###### includeBlobStorageMetadata?
280
+
281
+ `boolean`
282
+
283
+ Flag to include the blob storage metadata for the document, defaults to false.
284
+
285
+ ###### includeBlobStorageData?
211
286
 
212
- ###### removeAllRevisions
287
+ `boolean`
288
+
289
+ Flag to include the blob storage data for the document, defaults to false.
290
+
291
+ ###### includeAttestation?
213
292
 
214
293
  `boolean`
215
294
 
216
- Flag to remove all revisions of the document, defaults to false.
295
+ Flag to include the attestation information for the document, defaults to false.
296
+
297
+ ###### extractRuleGroupId?
298
+
299
+ `string`
300
+
301
+ If provided will extract data from the document using the specified rule group id.
302
+
303
+ ###### extractMimeType?
304
+
305
+ `string`
306
+
307
+ By default extraction will auto detect the mime type of the document, this can be used to override the detection.
217
308
 
218
309
  #### Returns
219
310
 
220
- `Promise`\<`void`\>
311
+ `Promise`\<`IDocument`\>
221
312
 
222
- Nothing.
313
+ The documents and revisions if requested, ordered by revision descending, cursor is set if there are more document revisions.
223
314
 
224
315
  #### Implementation of
225
316
 
226
- `IDocumentManagementComponent.remove`
317
+ `IDocumentManagementComponent.getRevision`
227
318
 
228
319
  ***
229
320
 
230
- ### query()
321
+ ### removeRevision()
231
322
 
232
- > **query**(`auditableItemGraphId`, `documentCodes`?, `options`?, `cursor`?): `Promise`\<`IDocumentList`\>
323
+ > **removeRevision**(`auditableItemGraphDocumentId`, `revision`): `Promise`\<`void`\>
233
324
 
234
- Query an auditable item graph vertex for documents.
325
+ Remove an auditable item graph vertex using it's id.
326
+ The document dateDeleted will be set, but can still be queried with the includeRemoved flag.
235
327
 
236
328
  #### Parameters
237
329
 
238
- ##### auditableItemGraphId
330
+ ##### auditableItemGraphDocumentId
239
331
 
240
332
  `string`
241
333
 
242
- The auditable item graph vertex to get the documents from.
334
+ The auditable item graph vertex id which contains the document.
243
335
 
244
- ##### documentCodes?
336
+ ##### revision
245
337
 
246
- `string`[]
338
+ `number`
247
339
 
248
- The document codes to query for, if undefined gets all document codes.
340
+ The revision of the document to remove.
249
341
 
250
- ##### options?
342
+ #### Returns
251
343
 
252
- Additional options for the query operation.
344
+ `Promise`\<`void`\>
253
345
 
254
- ###### includeMostRecentRevisions
346
+ Nothing.
255
347
 
256
- `boolean`
348
+ #### Implementation of
257
349
 
258
- Include the most recent 5 revisions, use the individual get to retrieve more.
350
+ `IDocumentManagementComponent.removeRevision`
259
351
 
260
- ###### includeRemoved
352
+ ***
261
353
 
262
- `boolean`
354
+ ### query()
263
355
 
264
- Flag to include deleted documents, defaults to false.
356
+ > **query**(`documentId`, `cursor?`, `pageSize?`): `Promise`\<`IAuditableItemGraphVertexList`\>
357
+
358
+ Find all the document with a specific id.
359
+
360
+ #### Parameters
361
+
362
+ ##### documentId
363
+
364
+ `string`
365
+
366
+ The document id to find in the graph.
265
367
 
266
368
  ##### cursor?
267
369
 
@@ -269,11 +371,17 @@ Flag to include deleted documents, defaults to false.
269
371
 
270
372
  The cursor to get the next chunk of documents.
271
373
 
374
+ ##### pageSize?
375
+
376
+ `number`
377
+
378
+ The page size to get the next chunk of documents.
379
+
272
380
  #### Returns
273
381
 
274
- `Promise`\<`IDocumentList`\>
382
+ `Promise`\<`IAuditableItemGraphVertexList`\>
275
383
 
276
- The most recent revisions of each document, cursor is set if there are more documents.
384
+ The graph vertices that contain documents referencing the specified document id.
277
385
 
278
386
  #### Implementation of
279
387
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/document-management-rest-client",
3
- "version": "0.0.1-next.2",
3
+ "version": "0.0.1-next.20",
4
4
  "description": "Document management contract implementation which can connect to REST endpoints",
5
5
  "repository": {
6
6
  "type": "git",
@@ -16,9 +16,10 @@
16
16
  "dependencies": {
17
17
  "@twin.org/api-core": "next",
18
18
  "@twin.org/api-models": "next",
19
+ "@twin.org/auditable-item-graph-models": "next",
19
20
  "@twin.org/core": "next",
20
21
  "@twin.org/data-json-ld": "next",
21
- "@twin.org/document-management-models": "0.0.1-next.2",
22
+ "@twin.org/document-management-models": "0.0.1-next.20",
22
23
  "@twin.org/entity": "next",
23
24
  "@twin.org/nameof": "next",
24
25
  "@twin.org/standards-unece": "next",