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

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,123 +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.
38
+ * @param auditableItemGraphEdges The auditable item graph vertices to connect the document to.
40
39
  * @param options Additional options for the set operation.
41
40
  * @param options.createAttestation Flag to create an attestation for the document, defaults to false.
42
- * @param options.includeIdAsAlias Include the document id as an alias to the aig vertex, defaults to false.
43
- * @param options.aliasAnnotationObject Additional information to associate with the alias.
44
- * @returns The identifier for the document which includes the auditable item graph identifier.
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.
45
44
  */
46
- async set(auditableItemGraphId, documentId, documentIdFormat, documentCode, blob, annotationObject, options) {
47
- core.Guards.stringValue(this.CLASS_NAME, "auditableItemGraphId", auditableItemGraphId);
45
+ async create(documentId, documentIdFormat, documentCode, blob, annotationObject, auditableItemGraphEdges, options) {
48
46
  core.Guards.stringValue(this.CLASS_NAME, "documentId", documentId);
49
47
  core.Guards.arrayOneOf(this.CLASS_NAME, "documentCode", documentCode, Object.values(standardsUnece.UneceDocumentCodes));
50
48
  core.Guards.uint8Array(this.CLASS_NAME, "blob", blob);
51
- const response = await this.fetch("/:auditableItemGraphId", "POST", {
52
- pathParams: {
53
- auditableItemGraphId
54
- },
49
+ const response = await this.fetch("/", "POST", {
55
50
  body: {
56
51
  documentId,
57
52
  documentIdFormat,
58
53
  documentCode,
59
54
  blob: core.Converter.bytesToBase64(blob),
60
55
  annotationObject,
56
+ auditableItemGraphEdges,
61
57
  createAttestation: options?.createAttestation,
62
- includeIdAsAlias: options?.includeIdAsAlias,
58
+ addAlias: options?.addAlias,
63
59
  aliasAnnotationObject: options?.aliasAnnotationObject
64
60
  }
65
61
  });
66
62
  return response.headers.location;
67
63
  }
68
64
  /**
69
- * Get a specific document from an auditable item graph vertex.
70
- * @param auditableItemGraphId The auditable item graph vertex id to get the document from.
71
- * @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.
72
90
  * @param options Additional options for the get operation.
73
91
  * @param options.includeBlobStorageMetadata Flag to include the blob storage metadata for the document, defaults to false.
74
92
  * @param options.includeBlobStorageData Flag to include the blob storage data for the document, defaults to false.
75
93
  * @param options.includeAttestation Flag to include the attestation information for the document, defaults to false.
76
94
  * @param options.includeRemoved Flag to include deleted documents, defaults to false.
77
- * @param options.maxRevisionCount Max number of revisions to return, defaults to 0.
78
- * @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.
79
99
  * @returns The documents and revisions if requested, ordered by revision descending, cursor is set if there are more document revisions.
80
100
  */
81
- async get(auditableItemGraphId, identifier, options, revisionCursor) {
82
- core.Urn.guard(this.CLASS_NAME, "auditableItemGraphId", auditableItemGraphId);
83
- core.Urn.guard(this.CLASS_NAME, "identifier", identifier);
84
- 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", {
85
104
  pathParams: {
86
- auditableItemGraphId,
87
- documentId: identifier
105
+ auditableItemGraphDocumentId
88
106
  },
89
107
  query: {
90
108
  includeBlobStorageMetadata: options?.includeBlobStorageMetadata,
91
109
  includeBlobStorageData: options?.includeBlobStorageData,
92
110
  includeAttestation: options?.includeAttestation,
93
111
  includeRemoved: options?.includeRemoved,
94
- maxRevisionCount: options?.maxRevisionCount,
95
- revisionCursor
112
+ extractRuleGroupId: options?.extractRuleGroupId,
113
+ extractMimeType: options?.extractMimeType,
114
+ cursor,
115
+ pageSize: core.Coerce.string(pageSize)
96
116
  }
97
117
  });
98
118
  return response.body;
99
119
  }
100
120
  /**
101
- * Remove a specific document from an auditable item graph vertex.
102
- * The documents dateDeleted will be set, but can still be queried with the includeRemoved flag.
103
- * @param auditableItemGraphId The auditable item graph vertex id to remove the document from.
104
- * @param identifier The identifier of the document to remove.
105
- * @param options Additional options for the remove operation.
106
- * @param options.removeAllRevisions Flag to remove all revisions of the document, defaults to false.
107
- * @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.
108
131
  */
109
- async remove(auditableItemGraphId, identifier, options) {
110
- core.Urn.guard(this.CLASS_NAME, "auditableItemGraphId", auditableItemGraphId);
111
- core.Urn.guard(this.CLASS_NAME, "identifier", identifier);
112
- 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", {
113
136
  pathParams: {
114
- auditableItemGraphId,
115
- documentId: identifier
137
+ auditableItemGraphDocumentId,
138
+ revision: revision.toString()
116
139
  },
117
140
  query: {
118
- removeAllRevisions: options?.removeAllRevisions
141
+ includeBlobStorageMetadata: options?.includeBlobStorageMetadata,
142
+ includeBlobStorageData: options?.includeBlobStorageData,
143
+ includeAttestation: options?.includeAttestation,
144
+ extractRuleGroupId: options?.extractRuleGroupId,
145
+ extractMimeType: options?.extractMimeType
119
146
  }
120
147
  });
148
+ return response.body;
121
149
  }
122
150
  /**
123
- * Query an auditable item graph vertex for documents.
124
- * @param auditableItemGraphId The auditable item graph vertex to get the documents from.
125
- * @param documentCodes The document codes to query for, if undefined gets all document codes.
126
- * @param options Additional options for the query operation.
127
- * @param options.includeMostRecentRevisions Include the most recent 5 revisions, use the individual get to retrieve more.
128
- * @param options.includeRemoved Flag to include deleted documents, defaults to false.
129
- * @param cursor The cursor to get the next chunk of documents.
130
- * @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.
131
156
  */
132
- async query(auditableItemGraphId, documentCodes, options, cursor) {
133
- core.Urn.guard(this.CLASS_NAME, "auditableItemGraphId", auditableItemGraphId);
134
- 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", {
135
161
  pathParams: {
136
- auditableItemGraphId
137
- },
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", {
138
177
  query: {
139
- documentCodes: core.Is.arrayValue(documentCodes)
140
- ? apiModels.HttpParameterHelper.arrayToString(documentCodes)
141
- : undefined,
142
- includeMostRecentRevisions: options?.includeMostRecentRevisions,
143
- includeRemoved: options?.includeRemoved,
144
- cursor
178
+ documentId,
179
+ cursor,
180
+ pageSize: core.Coerce.string(pageSize)
145
181
  }
146
182
  });
147
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,123 +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.
36
+ * @param auditableItemGraphEdges The auditable item graph vertices to connect the document to.
38
37
  * @param options Additional options for the set operation.
39
38
  * @param options.createAttestation Flag to create an attestation for the document, defaults to false.
40
- * @param options.includeIdAsAlias Include the document id as an alias to the aig vertex, defaults to false.
41
- * @param options.aliasAnnotationObject Additional information to associate with the alias.
42
- * @returns The identifier for the document which includes the auditable item graph identifier.
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.
43
42
  */
44
- async set(auditableItemGraphId, documentId, documentIdFormat, documentCode, blob, annotationObject, options) {
45
- Guards.stringValue(this.CLASS_NAME, "auditableItemGraphId", auditableItemGraphId);
43
+ async create(documentId, documentIdFormat, documentCode, blob, annotationObject, auditableItemGraphEdges, options) {
46
44
  Guards.stringValue(this.CLASS_NAME, "documentId", documentId);
47
45
  Guards.arrayOneOf(this.CLASS_NAME, "documentCode", documentCode, Object.values(UneceDocumentCodes));
48
46
  Guards.uint8Array(this.CLASS_NAME, "blob", blob);
49
- const response = await this.fetch("/:auditableItemGraphId", "POST", {
50
- pathParams: {
51
- auditableItemGraphId
52
- },
47
+ const response = await this.fetch("/", "POST", {
53
48
  body: {
54
49
  documentId,
55
50
  documentIdFormat,
56
51
  documentCode,
57
52
  blob: Converter.bytesToBase64(blob),
58
53
  annotationObject,
54
+ auditableItemGraphEdges,
59
55
  createAttestation: options?.createAttestation,
60
- includeIdAsAlias: options?.includeIdAsAlias,
56
+ addAlias: options?.addAlias,
61
57
  aliasAnnotationObject: options?.aliasAnnotationObject
62
58
  }
63
59
  });
64
60
  return response.headers.location;
65
61
  }
66
62
  /**
67
- * Get a specific document from an auditable item graph vertex.
68
- * @param auditableItemGraphId The auditable item graph vertex id to get the document from.
69
- * @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.
70
88
  * @param options Additional options for the get operation.
71
89
  * @param options.includeBlobStorageMetadata Flag to include the blob storage metadata for the document, defaults to false.
72
90
  * @param options.includeBlobStorageData Flag to include the blob storage data for the document, defaults to false.
73
91
  * @param options.includeAttestation Flag to include the attestation information for the document, defaults to false.
74
92
  * @param options.includeRemoved Flag to include deleted documents, defaults to false.
75
- * @param options.maxRevisionCount Max number of revisions to return, defaults to 0.
76
- * @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.
77
97
  * @returns The documents and revisions if requested, ordered by revision descending, cursor is set if there are more document revisions.
78
98
  */
79
- async get(auditableItemGraphId, identifier, options, revisionCursor) {
80
- Urn.guard(this.CLASS_NAME, "auditableItemGraphId", auditableItemGraphId);
81
- Urn.guard(this.CLASS_NAME, "identifier", identifier);
82
- 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", {
83
102
  pathParams: {
84
- auditableItemGraphId,
85
- documentId: identifier
103
+ auditableItemGraphDocumentId
86
104
  },
87
105
  query: {
88
106
  includeBlobStorageMetadata: options?.includeBlobStorageMetadata,
89
107
  includeBlobStorageData: options?.includeBlobStorageData,
90
108
  includeAttestation: options?.includeAttestation,
91
109
  includeRemoved: options?.includeRemoved,
92
- maxRevisionCount: options?.maxRevisionCount,
93
- revisionCursor
110
+ extractRuleGroupId: options?.extractRuleGroupId,
111
+ extractMimeType: options?.extractMimeType,
112
+ cursor,
113
+ pageSize: Coerce.string(pageSize)
94
114
  }
95
115
  });
96
116
  return response.body;
97
117
  }
98
118
  /**
99
- * Remove a specific document from an auditable item graph vertex.
100
- * The documents dateDeleted will be set, but can still be queried with the includeRemoved flag.
101
- * @param auditableItemGraphId The auditable item graph vertex id to remove the document from.
102
- * @param identifier The identifier of the document to remove.
103
- * @param options Additional options for the remove operation.
104
- * @param options.removeAllRevisions Flag to remove all revisions of the document, defaults to false.
105
- * @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.
106
129
  */
107
- async remove(auditableItemGraphId, identifier, options) {
108
- Urn.guard(this.CLASS_NAME, "auditableItemGraphId", auditableItemGraphId);
109
- Urn.guard(this.CLASS_NAME, "identifier", identifier);
110
- 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", {
111
134
  pathParams: {
112
- auditableItemGraphId,
113
- documentId: identifier
135
+ auditableItemGraphDocumentId,
136
+ revision: revision.toString()
114
137
  },
115
138
  query: {
116
- removeAllRevisions: options?.removeAllRevisions
139
+ includeBlobStorageMetadata: options?.includeBlobStorageMetadata,
140
+ includeBlobStorageData: options?.includeBlobStorageData,
141
+ includeAttestation: options?.includeAttestation,
142
+ extractRuleGroupId: options?.extractRuleGroupId,
143
+ extractMimeType: options?.extractMimeType
117
144
  }
118
145
  });
146
+ return response.body;
119
147
  }
120
148
  /**
121
- * Query an auditable item graph vertex for documents.
122
- * @param auditableItemGraphId The auditable item graph vertex to get the documents from.
123
- * @param documentCodes The document codes to query for, if undefined gets all document codes.
124
- * @param options Additional options for the query operation.
125
- * @param options.includeMostRecentRevisions Include the most recent 5 revisions, use the individual get to retrieve more.
126
- * @param options.includeRemoved Flag to include deleted documents, defaults to false.
127
- * @param cursor The cursor to get the next chunk of documents.
128
- * @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.
129
154
  */
130
- async query(auditableItemGraphId, documentCodes, options, cursor) {
131
- Urn.guard(this.CLASS_NAME, "auditableItemGraphId", auditableItemGraphId);
132
- 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", {
133
159
  pathParams: {
134
- auditableItemGraphId
135
- },
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", {
136
175
  query: {
137
- documentCodes: Is.arrayValue(documentCodes)
138
- ? HttpParameterHelper.arrayToString(documentCodes)
139
- : undefined,
140
- includeMostRecentRevisions: options?.includeMostRecentRevisions,
141
- includeRemoved: options?.includeRemoved,
142
- cursor
176
+ documentId,
177
+ cursor,
178
+ pageSize: Coerce.string(pageSize)
143
179
  }
144
180
  });
145
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,70 +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 auditableItemGraphEdges The auditable item graph vertices to connect the document to.
29
30
  * @param options Additional options for the set operation.
30
31
  * @param options.createAttestation Flag to create an attestation for the document, defaults to false.
31
- * @param options.includeIdAsAlias Include the document id as an alias to the aig vertex, defaults to false.
32
- * @param options.aliasAnnotationObject Additional information to associate with the alias.
33
- * @returns The identifier for the document which includes the auditable item graph identifier.
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.
34
35
  */
35
- set(auditableItemGraphId: string, documentId: string, documentIdFormat: string | undefined, documentCode: UneceDocumentCodes, blob: Uint8Array, annotationObject?: IJsonLdNodeObject, options?: {
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?: {
36
41
  createAttestation?: boolean;
37
- includeIdAsAlias?: boolean;
42
+ addAlias?: boolean;
38
43
  aliasAnnotationObject?: IJsonLdNodeObject;
39
44
  }): Promise<string>;
40
45
  /**
41
- * Get a specific document from an auditable item graph vertex.
42
- * @param auditableItemGraphId The auditable item graph vertex id to get the document from.
43
- * @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.
44
63
  * @param options Additional options for the get operation.
45
64
  * @param options.includeBlobStorageMetadata Flag to include the blob storage metadata for the document, defaults to false.
46
65
  * @param options.includeBlobStorageData Flag to include the blob storage data for the document, defaults to false.
47
66
  * @param options.includeAttestation Flag to include the attestation information for the document, defaults to false.
48
67
  * @param options.includeRemoved Flag to include deleted documents, defaults to false.
49
- * @param options.maxRevisionCount Max number of revisions to return, defaults to 0.
50
- * @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.
51
72
  * @returns The documents and revisions if requested, ordered by revision descending, cursor is set if there are more document revisions.
52
73
  */
53
- get(auditableItemGraphId: string, identifier: string, options?: {
74
+ get(auditableItemGraphDocumentId: string, options?: {
54
75
  includeBlobStorageMetadata?: boolean;
55
76
  includeBlobStorageData?: boolean;
56
77
  includeAttestation?: boolean;
57
78
  includeRemoved?: boolean;
58
- maxRevisionCount?: number;
59
- }, revisionCursor?: string): Promise<IDocument>;
79
+ extractRuleGroupId?: string;
80
+ extractMimeType?: string;
81
+ }, cursor?: string, pageSize?: number): Promise<IDocumentList>;
60
82
  /**
61
- * Remove a specific document from an auditable item graph vertex.
62
- * The documents dateDeleted will be set, but can still be queried with the includeRemoved flag.
63
- * @param auditableItemGraphId The auditable item graph vertex id to remove the document from.
64
- * @param identifier The identifier of the document to remove.
65
- * @param options Additional options for the remove operation.
66
- * @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.
67
106
  * @returns Nothing.
68
107
  */
69
- remove(auditableItemGraphId: string, identifier: string, options?: {
70
- removeAllRevisions?: boolean;
71
- }): Promise<void>;
108
+ removeRevision(auditableItemGraphDocumentId: string, revision: number): Promise<void>;
72
109
  /**
73
- * Query an auditable item graph vertex for documents.
74
- * @param auditableItemGraphId The auditable item graph vertex to get the documents from.
75
- * @param documentCodes The document codes to query for, if undefined gets all document codes.
76
- * @param options Additional options for the query operation.
77
- * @param options.includeMostRecentRevisions Include the most recent 5 revisions, use the individual get to retrieve more.
78
- * @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.
79
112
  * @param cursor The cursor to get the next chunk of documents.
80
- * @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.
81
115
  */
82
- query(auditableItemGraphId: string, documentCodes?: UneceDocumentCodes[], options?: {
83
- includeMostRecentRevisions?: boolean;
84
- includeRemoved?: boolean;
85
- }, cursor?: string): Promise<IDocumentList>;
116
+ query(documentId: string, cursor?: string, pageSize?: number): Promise<IAuditableItemGraphVertexList>;
86
117
  }
package/docs/changelog.md CHANGED
@@ -1,5 +1,195 @@
1
1
  # @twin.org/document-management-rest-client - Changelog
2
2
 
3
+ ## 0.0.1 (2025-07-09)
4
+
5
+
6
+ ### Features
7
+
8
+ * release to production ([a009526](https://github.com/twinfoundation/document-management/commit/a009526032a0ee6e6b74f476a01fbe5f4c7fd4da))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/document-management-models bumped from ^0.0.0 to ^0.0.1
16
+
17
+ ## [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)
18
+
19
+
20
+ ### Features
21
+
22
+ * document get can perform extraction ([#6](https://github.com/twinfoundation/document-management/issues/6)) ([5ce6d37](https://github.com/twinfoundation/document-management/commit/5ce6d37432ad271ca5783f422846f4be98ec2215))
23
+ * get document revision ([080eddc](https://github.com/twinfoundation/document-management/commit/080eddcc024c622dda6bb36f60f5fa80a86cf5bb))
24
+ * store document as a vertex ([#2](https://github.com/twinfoundation/document-management/issues/2)) ([7febedc](https://github.com/twinfoundation/document-management/commit/7febedc3fb31de9c19565d6326341046834f2c74))
25
+ * update dependencies ([f9d8641](https://github.com/twinfoundation/document-management/commit/f9d86417dba24027699225ec7473296e361dcb00))
26
+
27
+
28
+ ### Bug Fixes
29
+
30
+ * 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))
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.19 to 0.0.1-next.20
38
+
39
+ ## [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)
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.18 to 0.0.1-next.19
52
+
53
+ ## [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)
54
+
55
+
56
+ ### Miscellaneous Chores
57
+
58
+ * **document-management-rest-client:** Synchronize repo versions
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.17 to 0.0.1-next.18
66
+
67
+ ## [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)
68
+
69
+
70
+ ### Features
71
+
72
+ * update dependencies ([f9d8641](https://github.com/twinfoundation/document-management/commit/f9d86417dba24027699225ec7473296e361dcb00))
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.16 to 0.0.1-next.17
80
+
81
+ ## [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)
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.15 to 0.0.1-next.16
94
+
95
+ ## [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)
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.14 to 0.0.1-next.15
108
+
109
+ ## [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)
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.13 to 0.0.1-next.14
122
+
123
+ ## [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)
124
+
125
+
126
+ ### Miscellaneous Chores
127
+
128
+ * **document-management-rest-client:** Synchronize repo versions
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.12 to 0.0.1-next.13
136
+
137
+ ## [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)
138
+
139
+
140
+ ### Features
141
+
142
+ * get document revision ([080eddc](https://github.com/twinfoundation/document-management/commit/080eddcc024c622dda6bb36f60f5fa80a86cf5bb))
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.11 to 0.0.1-next.12
150
+
151
+ ## [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)
152
+
153
+
154
+ ### Features
155
+
156
+ * document get can perform extraction ([#6](https://github.com/twinfoundation/document-management/issues/6)) ([5ce6d37](https://github.com/twinfoundation/document-management/commit/5ce6d37432ad271ca5783f422846f4be98ec2215))
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.10 to 0.0.1-next.11
164
+
165
+ ## [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)
166
+
167
+
168
+ ### Bug Fixes
169
+
170
+ * 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))
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.9 to 0.0.1-next.10
178
+
179
+ ## [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)
180
+
181
+
182
+ ### Features
183
+
184
+ * store document as a vertex ([#2](https://github.com/twinfoundation/document-management/issues/2)) ([7febedc](https://github.com/twinfoundation/document-management/commit/7febedc3fb31de9c19565d6326341046834f2c74))
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.8 to 0.0.1-next.9
192
+
3
193
  ## [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)
4
194
 
5
195
 
@@ -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`?, `options`?): `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,6 +88,12 @@ The data to create the document.
94
88
 
95
89
  Additional information to associate with the document.
96
90
 
91
+ ##### auditableItemGraphEdges?
92
+
93
+ `object`[]
94
+
95
+ The auditable item graph vertices to connect the document to.
96
+
97
97
  ##### options?
98
98
 
99
99
  Additional options for the set operation.
@@ -104,49 +104,89 @@ Additional options for the set operation.
104
104
 
105
105
  Flag to create an attestation for the document, defaults to false.
106
106
 
107
- ###### includeIdAsAlias?
107
+ ###### addAlias?
108
108
 
109
109
  `boolean`
110
110
 
111
- Include the document id as an alias to the aig vertex, defaults to false.
111
+ Flag to add the document id as an alias to the aig vertex, defaults to true.
112
112
 
113
113
  ###### aliasAnnotationObject?
114
114
 
115
115
  `IJsonLdNodeObject`
116
116
 
117
- Additional information to associate with the alias.
117
+ Annotation object for the alias.
118
118
 
119
119
  #### Returns
120
120
 
121
121
  `Promise`\<`string`\>
122
122
 
123
- 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.
124
124
 
125
125
  #### Implementation of
126
126
 
127
- `IDocumentManagementComponent.set`
127
+ `IDocumentManagementComponent.create`
128
128
 
129
129
  ***
130
130
 
131
- ### get()
131
+ ### update()
132
132
 
133
- > **get**(`auditableItemGraphId`, `identifier`, `options`?, `revisionCursor`?): `Promise`\<`IDocument`\>
133
+ > **update**(`auditableItemGraphDocumentId`, `blob?`, `annotationObject?`, `auditableItemGraphEdges?`): `Promise`\<`void`\>
134
134
 
135
- 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.
136
138
 
137
139
  #### Parameters
138
140
 
139
- ##### auditableItemGraphId
141
+ ##### auditableItemGraphDocumentId
140
142
 
141
143
  `string`
142
144
 
143
- 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`\>
144
150
 
145
- ##### identifier
151
+ The data to update the document with.
152
+
153
+ ##### annotationObject?
154
+
155
+ `IJsonLdNodeObject`
156
+
157
+ Additional information to associate with the document.
158
+
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
146
186
 
147
187
  `string`
148
188
 
149
- The identifier of the document to get.
189
+ The auditable item graph vertex id which contains the document.
150
190
 
151
191
  ##### options?
152
192
 
@@ -176,21 +216,33 @@ Flag to include the attestation information for the document, defaults to false.
176
216
 
177
217
  Flag to include deleted documents, defaults to false.
178
218
 
179
- ###### maxRevisionCount?
219
+ ###### extractRuleGroupId?
180
220
 
181
- `number`
221
+ `string`
182
222
 
183
- Max number of revisions to return, defaults to 0.
223
+ If provided will extract data from the document using the specified rule group id.
184
224
 
185
- ##### 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?
186
232
 
187
233
  `string`
188
234
 
189
235
  The cursor to get the next chunk of revisions.
190
236
 
237
+ ##### pageSize?
238
+
239
+ `number`
240
+
241
+ Page size of items to return, defaults to 1 so only most recent is returned.
242
+
191
243
  #### Returns
192
244
 
193
- `Promise`\<`IDocument`\>
245
+ `Promise`\<`IDocumentList`\>
194
246
 
195
247
  The documents and revisions if requested, ordered by revision descending, cursor is set if there are more document revisions.
196
248
 
@@ -200,84 +252,118 @@ The documents and revisions if requested, ordered by revision descending, cursor
200
252
 
201
253
  ***
202
254
 
203
- ### remove()
255
+ ### getRevision()
204
256
 
205
- > **remove**(`auditableItemGraphId`, `identifier`, `options`?): `Promise`\<`void`\>
257
+ > **getRevision**(`auditableItemGraphDocumentId`, `revision`, `options?`): `Promise`\<`IDocument`\>
206
258
 
207
- Remove a specific document from an auditable item graph vertex.
208
- 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.
209
260
 
210
261
  #### Parameters
211
262
 
212
- ##### auditableItemGraphId
263
+ ##### auditableItemGraphDocumentId
213
264
 
214
265
  `string`
215
266
 
216
- The auditable item graph vertex id to remove the document from.
267
+ The auditable item graph vertex id which contains the document.
217
268
 
218
- ##### identifier
269
+ ##### revision
219
270
 
220
- `string`
271
+ `number`
221
272
 
222
- The identifier of the document to remove.
273
+ The revision id for the document.
223
274
 
224
275
  ##### options?
225
276
 
226
- 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.
227
284
 
228
- ###### removeAllRevisions?
285
+ ###### includeBlobStorageData?
229
286
 
230
287
  `boolean`
231
288
 
232
- Flag to remove all revisions of the document, defaults to false.
289
+ Flag to include the blob storage data for the document, defaults to false.
290
+
291
+ ###### includeAttestation?
292
+
293
+ `boolean`
294
+
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.
233
308
 
234
309
  #### Returns
235
310
 
236
- `Promise`\<`void`\>
311
+ `Promise`\<`IDocument`\>
237
312
 
238
- Nothing.
313
+ The documents and revisions if requested, ordered by revision descending, cursor is set if there are more document revisions.
239
314
 
240
315
  #### Implementation of
241
316
 
242
- `IDocumentManagementComponent.remove`
317
+ `IDocumentManagementComponent.getRevision`
243
318
 
244
319
  ***
245
320
 
246
- ### query()
321
+ ### removeRevision()
247
322
 
248
- > **query**(`auditableItemGraphId`, `documentCodes`?, `options`?, `cursor`?): `Promise`\<`IDocumentList`\>
323
+ > **removeRevision**(`auditableItemGraphDocumentId`, `revision`): `Promise`\<`void`\>
249
324
 
250
- 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.
251
327
 
252
328
  #### Parameters
253
329
 
254
- ##### auditableItemGraphId
330
+ ##### auditableItemGraphDocumentId
255
331
 
256
332
  `string`
257
333
 
258
- The auditable item graph vertex to get the documents from.
334
+ The auditable item graph vertex id which contains the document.
259
335
 
260
- ##### documentCodes?
336
+ ##### revision
261
337
 
262
- `string`[]
338
+ `number`
263
339
 
264
- The document codes to query for, if undefined gets all document codes.
340
+ The revision of the document to remove.
265
341
 
266
- ##### options?
342
+ #### Returns
267
343
 
268
- Additional options for the query operation.
344
+ `Promise`\<`void`\>
269
345
 
270
- ###### includeMostRecentRevisions?
346
+ Nothing.
271
347
 
272
- `boolean`
348
+ #### Implementation of
273
349
 
274
- Include the most recent 5 revisions, use the individual get to retrieve more.
350
+ `IDocumentManagementComponent.removeRevision`
275
351
 
276
- ###### includeRemoved?
352
+ ***
277
353
 
278
- `boolean`
354
+ ### query()
279
355
 
280
- 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.
281
367
 
282
368
  ##### cursor?
283
369
 
@@ -285,11 +371,17 @@ Flag to include deleted documents, defaults to false.
285
371
 
286
372
  The cursor to get the next chunk of documents.
287
373
 
374
+ ##### pageSize?
375
+
376
+ `number`
377
+
378
+ The page size to get the next chunk of documents.
379
+
288
380
  #### Returns
289
381
 
290
- `Promise`\<`IDocumentList`\>
382
+ `Promise`\<`IAuditableItemGraphVertexList`\>
291
383
 
292
- 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.
293
385
 
294
386
  #### Implementation of
295
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.8",
3
+ "version": "0.0.1",
4
4
  "description": "Document management contract implementation which can connect to REST endpoints",
5
5
  "repository": {
6
6
  "type": "git",
@@ -13,16 +13,47 @@
13
13
  "engines": {
14
14
  "node": ">=20.0.0"
15
15
  },
16
+ "scripts": {
17
+ "clean": "rimraf dist coverage docs/reference",
18
+ "build": "tsc",
19
+ "dev": "nodemon --watch src --ext ts --exec \"npm run build && npm run bundle:esm\"",
20
+ "test": "vitest --run --config ./vitest.config.ts --no-cache",
21
+ "coverage": "vitest --run --coverage --config ./vitest.config.ts --no-cache",
22
+ "bundle:esm": "rollup --config rollup.config.mjs --environment MODULE:esm",
23
+ "bundle:cjs": "rollup --config rollup.config.mjs --environment MODULE:cjs",
24
+ "bundle": "npm run bundle:esm && npm run bundle:cjs",
25
+ "docs:clean": "rimraf docs/reference",
26
+ "docs:generate": "typedoc",
27
+ "docs": "npm run docs:clean && npm run docs:generate",
28
+ "dist": "npm run clean && npm run build && npm run test && npm run bundle && npm run docs",
29
+ "dist:no-test": "npm run clean && npm run build && npm run bundle && npm run docs",
30
+ "prepare": "ts-patch install -s"
31
+ },
16
32
  "dependencies": {
17
- "@twin.org/api-core": "next",
18
- "@twin.org/api-models": "next",
19
- "@twin.org/core": "next",
20
- "@twin.org/data-json-ld": "next",
21
- "@twin.org/document-management-models": "0.0.1-next.8",
22
- "@twin.org/entity": "next",
23
- "@twin.org/nameof": "next",
24
- "@twin.org/standards-unece": "next",
25
- "@twin.org/web": "next"
33
+ "@twin.org/api-core": "^0.0.2-next.1",
34
+ "@twin.org/api-models": "^0.0.2-next.1",
35
+ "@twin.org/auditable-item-graph-models": "^0.0.1",
36
+ "@twin.org/core": "^0.0.1",
37
+ "@twin.org/data-json-ld": "^0.0.1",
38
+ "@twin.org/document-management-models": "^0.0.1",
39
+ "@twin.org/entity": "^0.0.1",
40
+ "@twin.org/nameof": "^0.0.1",
41
+ "@twin.org/standards-unece": "^0.0.1",
42
+ "@twin.org/web": "^0.0.1"
43
+ },
44
+ "devDependencies": {
45
+ "@twin.org/nameof-transformer": "^0.0.1",
46
+ "@twin.org/nameof-vitest-plugin": "^0.0.1",
47
+ "@vitest/coverage-v8": "3.2.3",
48
+ "copyfiles": "2.4.1",
49
+ "nodemon": "3.1.10",
50
+ "rimraf": "6.0.1",
51
+ "rollup": "4.43.0",
52
+ "ts-patch": "3.3.0",
53
+ "typedoc": "0.28.5",
54
+ "typedoc-plugin-markdown": "4.6.4",
55
+ "typescript": "5.8.3",
56
+ "vitest": "3.2.3"
26
57
  },
27
58
  "main": "./dist/cjs/index.cjs",
28
59
  "module": "./dist/esm/index.mjs",