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

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
 
@@ -28,120 +27,123 @@ class DocumentManagementClient extends apiCore.BaseRestClient {
28
27
  super(DocumentManagementClient._CLASS_NAME, config, "documents");
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 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.
79
97
  * @returns The documents and revisions if requested, ordered by revision descending, cursor is set if there are more document revisions.
80
98
  */
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", {
99
+ async get(auditableItemGraphDocumentId, options, cursor, pageSize) {
100
+ core.Urn.guard(this.CLASS_NAME, "auditableItemGraphDocumentId", auditableItemGraphDocumentId);
101
+ const response = await this.fetch("/:auditableItemGraphDocumentId", "GET", {
85
102
  pathParams: {
86
- auditableItemGraphId,
87
- documentId: identifier
103
+ auditableItemGraphDocumentId
88
104
  },
89
105
  query: {
90
106
  includeBlobStorageMetadata: options?.includeBlobStorageMetadata,
91
107
  includeBlobStorageData: options?.includeBlobStorageData,
92
108
  includeAttestation: options?.includeAttestation,
93
109
  includeRemoved: options?.includeRemoved,
94
- maxRevisionCount: options?.maxRevisionCount,
95
- revisionCursor
110
+ cursor,
111
+ pageSize: core.Coerce.string(pageSize)
96
112
  }
97
113
  });
98
114
  return response.body;
99
115
  }
100
116
  /**
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.
117
+ * Remove an auditable item graph vertex using it's id.
118
+ * The document dateDeleted will be set, but can still be queried with the includeRemoved flag.
119
+ * @param auditableItemGraphDocumentId The auditable item graph vertex id which contains the document.
120
+ * @param revision The revision of the document to remove.
107
121
  * @returns Nothing.
108
122
  */
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", {
123
+ async removeRevision(auditableItemGraphDocumentId, revision) {
124
+ core.Urn.guard(this.CLASS_NAME, "auditableItemGraphDocumentId", auditableItemGraphDocumentId);
125
+ core.Guards.number(this.CLASS_NAME, "revision", revision);
126
+ await this.fetch("/:auditableItemGraphDocumentId/:revision", "DELETE", {
113
127
  pathParams: {
114
- auditableItemGraphId,
115
- documentId: identifier
116
- },
117
- query: {
118
- removeAllRevisions: options?.removeAllRevisions
128
+ auditableItemGraphDocumentId,
129
+ revision: revision.toString()
119
130
  }
120
131
  });
121
132
  }
122
133
  /**
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.
134
+ * Find all the document with a specific id.
135
+ * @param documentId The document id to find in the graph.
129
136
  * @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.
137
+ * @param pageSize The page size to get the next chunk of documents.
138
+ * @returns The graph vertices that contain documents referencing the specified document id.
131
139
  */
132
- async query(auditableItemGraphId, documentCodes, options, cursor) {
133
- core.Urn.guard(this.CLASS_NAME, "auditableItemGraphId", auditableItemGraphId);
134
- const response = await this.fetch("/:auditableItemGraphId", "GET", {
135
- pathParams: {
136
- auditableItemGraphId
137
- },
140
+ async query(documentId, cursor, pageSize) {
141
+ core.Guards.stringValue(this.CLASS_NAME, "documentId", documentId);
142
+ const response = await this.fetch("/", "GET", {
138
143
  query: {
139
- documentCodes: core.Is.arrayValue(documentCodes)
140
- ? apiModels.HttpParameterHelper.arrayToString(documentCodes)
141
- : undefined,
142
- includeMostRecentRevisions: options?.includeMostRecentRevisions,
143
- includeRemoved: options?.includeRemoved,
144
- cursor
144
+ documentId,
145
+ cursor,
146
+ pageSize: core.Coerce.string(pageSize)
145
147
  }
146
148
  });
147
149
  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.
@@ -26,120 +25,123 @@ class DocumentManagementClient extends BaseRestClient {
26
25
  super(DocumentManagementClient._CLASS_NAME, config, "documents");
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 cursor The cursor to get the next chunk of revisions.
94
+ * @param pageSize Page size of items to return, defaults to 1 so only most recent is returned.
77
95
  * @returns The documents and revisions if requested, ordered by revision descending, cursor is set if there are more document revisions.
78
96
  */
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", {
97
+ async get(auditableItemGraphDocumentId, options, cursor, pageSize) {
98
+ Urn.guard(this.CLASS_NAME, "auditableItemGraphDocumentId", auditableItemGraphDocumentId);
99
+ const response = await this.fetch("/:auditableItemGraphDocumentId", "GET", {
83
100
  pathParams: {
84
- auditableItemGraphId,
85
- documentId: identifier
101
+ auditableItemGraphDocumentId
86
102
  },
87
103
  query: {
88
104
  includeBlobStorageMetadata: options?.includeBlobStorageMetadata,
89
105
  includeBlobStorageData: options?.includeBlobStorageData,
90
106
  includeAttestation: options?.includeAttestation,
91
107
  includeRemoved: options?.includeRemoved,
92
- maxRevisionCount: options?.maxRevisionCount,
93
- revisionCursor
108
+ cursor,
109
+ pageSize: Coerce.string(pageSize)
94
110
  }
95
111
  });
96
112
  return response.body;
97
113
  }
98
114
  /**
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.
115
+ * Remove an auditable item graph vertex using it's id.
116
+ * The document dateDeleted will be set, but can still be queried with the includeRemoved flag.
117
+ * @param auditableItemGraphDocumentId The auditable item graph vertex id which contains the document.
118
+ * @param revision The revision of the document to remove.
105
119
  * @returns Nothing.
106
120
  */
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", {
121
+ async removeRevision(auditableItemGraphDocumentId, revision) {
122
+ Urn.guard(this.CLASS_NAME, "auditableItemGraphDocumentId", auditableItemGraphDocumentId);
123
+ Guards.number(this.CLASS_NAME, "revision", revision);
124
+ await this.fetch("/:auditableItemGraphDocumentId/:revision", "DELETE", {
111
125
  pathParams: {
112
- auditableItemGraphId,
113
- documentId: identifier
114
- },
115
- query: {
116
- removeAllRevisions: options?.removeAllRevisions
126
+ auditableItemGraphDocumentId,
127
+ revision: revision.toString()
117
128
  }
118
129
  });
119
130
  }
120
131
  /**
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.
132
+ * Find all the document with a specific id.
133
+ * @param documentId The document id to find in the graph.
127
134
  * @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.
135
+ * @param pageSize The page size to get the next chunk of documents.
136
+ * @returns The graph vertices that contain documents referencing the specified document id.
129
137
  */
130
- async query(auditableItemGraphId, documentCodes, options, cursor) {
131
- Urn.guard(this.CLASS_NAME, "auditableItemGraphId", auditableItemGraphId);
132
- const response = await this.fetch("/:auditableItemGraphId", "GET", {
133
- pathParams: {
134
- auditableItemGraphId
135
- },
138
+ async query(documentId, cursor, pageSize) {
139
+ Guards.stringValue(this.CLASS_NAME, "documentId", documentId);
140
+ const response = await this.fetch("/", "GET", {
136
141
  query: {
137
- documentCodes: Is.arrayValue(documentCodes)
138
- ? HttpParameterHelper.arrayToString(documentCodes)
139
- : undefined,
140
- includeMostRecentRevisions: options?.includeMostRecentRevisions,
141
- includeRemoved: options?.includeRemoved,
142
- cursor
142
+ documentId,
143
+ cursor,
144
+ pageSize: Coerce.string(pageSize)
143
145
  }
144
146
  });
145
147
  return response.body;
@@ -1,7 +1,8 @@
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
- import type { IDocument, IDocumentList, IDocumentManagementComponent } from "@twin.org/document-management-models";
5
+ import type { IDocumentList, IDocumentManagementComponent } from "@twin.org/document-management-models";
5
6
  import { UneceDocumentCodes } from "@twin.org/standards-unece";
6
7
  /**
7
8
  * Client for performing document management through to REST endpoints.
@@ -17,70 +18,77 @@ 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 cursor The cursor to get the next chunk of revisions.
69
+ * @param pageSize Page size of items to return, defaults to 1 so only most recent is returned.
51
70
  * @returns The documents and revisions if requested, ordered by revision descending, cursor is set if there are more document revisions.
52
71
  */
53
- get(auditableItemGraphId: string, identifier: string, options?: {
72
+ get(auditableItemGraphDocumentId: string, options?: {
54
73
  includeBlobStorageMetadata?: boolean;
55
74
  includeBlobStorageData?: boolean;
56
75
  includeAttestation?: boolean;
57
76
  includeRemoved?: boolean;
58
- maxRevisionCount?: number;
59
- }, revisionCursor?: string): Promise<IDocument>;
77
+ }, cursor?: string, pageSize?: number): Promise<IDocumentList>;
60
78
  /**
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.
79
+ * Remove an auditable item graph vertex using it's id.
80
+ * The document dateDeleted will be set, but can still be queried with the includeRemoved flag.
81
+ * @param auditableItemGraphDocumentId The auditable item graph vertex id which contains the document.
82
+ * @param revision The revision of the document to remove.
67
83
  * @returns Nothing.
68
84
  */
69
- remove(auditableItemGraphId: string, identifier: string, options?: {
70
- removeAllRevisions?: boolean;
71
- }): Promise<void>;
85
+ removeRevision(auditableItemGraphDocumentId: string, revision: number): Promise<void>;
72
86
  /**
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.
87
+ * Find all the document with a specific id.
88
+ * @param documentId The document id to find in the graph.
79
89
  * @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.
90
+ * @param pageSize The page size to get the next chunk of documents.
91
+ * @returns The graph vertices that contain documents referencing the specified document id.
81
92
  */
82
- query(auditableItemGraphId: string, documentCodes?: UneceDocumentCodes[], options?: {
83
- includeMostRecentRevisions?: boolean;
84
- includeRemoved?: boolean;
85
- }, cursor?: string): Promise<IDocumentList>;
93
+ query(documentId: string, cursor?: string, pageSize?: number): Promise<IAuditableItemGraphVertexList>;
86
94
  }
package/docs/changelog.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @twin.org/document-management-rest-client - Changelog
2
2
 
3
+ ## [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)
4
+
5
+
6
+ ### Features
7
+
8
+ * store document as a vertex ([#2](https://github.com/twinfoundation/document-management/issues/2)) ([7febedc](https://github.com/twinfoundation/document-management/commit/7febedc3fb31de9c19565d6326341046834f2c74))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/document-management-models bumped from 0.0.1-next.8 to 0.0.1-next.9
16
+
3
17
  ## [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
18
 
5
19
 
@@ -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`\>
150
+
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`[]
144
162
 
145
- ##### identifier
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,21 @@ 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
+ ##### cursor?
180
220
 
181
- `number`
221
+ `string`
182
222
 
183
- Max number of revisions to return, defaults to 0.
223
+ The cursor to get the next chunk of revisions.
184
224
 
185
- ##### revisionCursor?
225
+ ##### pageSize?
186
226
 
187
- `string`
227
+ `number`
188
228
 
189
- The cursor to get the next chunk of revisions.
229
+ Page size of items to return, defaults to 1 so only most recent is returned.
190
230
 
191
231
  #### Returns
192
232
 
193
- `Promise`\<`IDocument`\>
233
+ `Promise`\<`IDocumentList`\>
194
234
 
195
235
  The documents and revisions if requested, ordered by revision descending, cursor is set if there are more document revisions.
196
236
 
@@ -200,36 +240,26 @@ The documents and revisions if requested, ordered by revision descending, cursor
200
240
 
201
241
  ***
202
242
 
203
- ### remove()
243
+ ### removeRevision()
204
244
 
205
- > **remove**(`auditableItemGraphId`, `identifier`, `options`?): `Promise`\<`void`\>
245
+ > **removeRevision**(`auditableItemGraphDocumentId`, `revision`): `Promise`\<`void`\>
206
246
 
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.
247
+ Remove an auditable item graph vertex using it's id.
248
+ The document dateDeleted will be set, but can still be queried with the includeRemoved flag.
209
249
 
210
250
  #### Parameters
211
251
 
212
- ##### auditableItemGraphId
252
+ ##### auditableItemGraphDocumentId
213
253
 
214
254
  `string`
215
255
 
216
- The auditable item graph vertex id to remove the document from.
217
-
218
- ##### identifier
219
-
220
- `string`
256
+ The auditable item graph vertex id which contains the document.
221
257
 
222
- The identifier of the document to remove.
258
+ ##### revision
223
259
 
224
- ##### options?
225
-
226
- Additional options for the remove operation.
227
-
228
- ###### removeAllRevisions?
229
-
230
- `boolean`
260
+ `number`
231
261
 
232
- Flag to remove all revisions of the document, defaults to false.
262
+ The revision of the document to remove.
233
263
 
234
264
  #### Returns
235
265
 
@@ -239,45 +269,23 @@ Nothing.
239
269
 
240
270
  #### Implementation of
241
271
 
242
- `IDocumentManagementComponent.remove`
272
+ `IDocumentManagementComponent.removeRevision`
243
273
 
244
274
  ***
245
275
 
246
276
  ### query()
247
277
 
248
- > **query**(`auditableItemGraphId`, `documentCodes`?, `options`?, `cursor`?): `Promise`\<`IDocumentList`\>
278
+ > **query**(`documentId`, `cursor?`, `pageSize?`): `Promise`\<`IAuditableItemGraphVertexList`\>
249
279
 
250
- Query an auditable item graph vertex for documents.
280
+ Find all the document with a specific id.
251
281
 
252
282
  #### Parameters
253
283
 
254
- ##### auditableItemGraphId
284
+ ##### documentId
255
285
 
256
286
  `string`
257
287
 
258
- The auditable item graph vertex to get the documents from.
259
-
260
- ##### documentCodes?
261
-
262
- `string`[]
263
-
264
- The document codes to query for, if undefined gets all document codes.
265
-
266
- ##### options?
267
-
268
- Additional options for the query operation.
269
-
270
- ###### includeMostRecentRevisions?
271
-
272
- `boolean`
273
-
274
- Include the most recent 5 revisions, use the individual get to retrieve more.
275
-
276
- ###### includeRemoved?
277
-
278
- `boolean`
279
-
280
- Flag to include deleted documents, defaults to false.
288
+ The document id to find in the graph.
281
289
 
282
290
  ##### cursor?
283
291
 
@@ -285,11 +293,17 @@ Flag to include deleted documents, defaults to false.
285
293
 
286
294
  The cursor to get the next chunk of documents.
287
295
 
296
+ ##### pageSize?
297
+
298
+ `number`
299
+
300
+ The page size to get the next chunk of documents.
301
+
288
302
  #### Returns
289
303
 
290
- `Promise`\<`IDocumentList`\>
304
+ `Promise`\<`IAuditableItemGraphVertexList`\>
291
305
 
292
- The most recent revisions of each document, cursor is set if there are more documents.
306
+ The graph vertices that contain documents referencing the specified document id.
293
307
 
294
308
  #### Implementation of
295
309
 
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-next.9",
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.8",
22
+ "@twin.org/document-management-models": "0.0.1-next.9",
22
23
  "@twin.org/entity": "next",
23
24
  "@twin.org/nameof": "next",
24
25
  "@twin.org/standards-unece": "next",