@twin.org/document-management-rest-client 0.0.2-next.3 → 0.0.3-next.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,28 +1,29 @@
1
- import { BaseRestClient } from '@twin.org/api-core';
2
- import { Guards, Converter, Urn, Is, Coerce } from '@twin.org/core';
3
- import { UneceDocumentCodes } from '@twin.org/standards-unece';
4
-
5
1
  // Copyright 2024 IOTA Stiftung.
6
2
  // SPDX-License-Identifier: Apache-2.0.
3
+ import { BaseRestClient } from "@twin.org/api-core";
4
+ import { Coerce, Converter, Guards, Is, Urn } from "@twin.org/core";
5
+ import { UneceDocumentCodes } from "@twin.org/standards-unece";
7
6
  /**
8
7
  * Client for performing document management through to REST endpoints.
9
8
  */
10
- class DocumentManagementClient extends BaseRestClient {
9
+ export class DocumentManagementRestClient extends BaseRestClient {
11
10
  /**
12
11
  * Runtime name for the class.
13
- * @internal
14
12
  */
15
- static _CLASS_NAME = "DocumentManagementClient";
13
+ static CLASS_NAME = "DocumentManagementRestClient";
16
14
  /**
17
- * Runtime name for the class.
18
- */
19
- CLASS_NAME = DocumentManagementClient._CLASS_NAME;
20
- /**
21
- * Create a new instance of DocumentManagementClient.
15
+ * Create a new instance of DocumentManagementRestClient.
22
16
  * @param config The configuration for the client.
23
17
  */
24
18
  constructor(config) {
25
- super(DocumentManagementClient._CLASS_NAME, config, "document-management");
19
+ super(DocumentManagementRestClient.CLASS_NAME, config, "document-management");
20
+ }
21
+ /**
22
+ * Returns the class name of the component.
23
+ * @returns The class name of the component.
24
+ */
25
+ className() {
26
+ return DocumentManagementRestClient.CLASS_NAME;
26
27
  }
27
28
  /**
28
29
  * Store a document as an auditable item graph vertex and add its content to blob storage.
@@ -41,9 +42,9 @@ class DocumentManagementClient extends BaseRestClient {
41
42
  * @returns The auditable item graph vertex created for the document including its revision.
42
43
  */
43
44
  async create(documentId, documentIdFormat, documentCode, blob, annotationObject, auditableItemGraphEdges, options) {
44
- Guards.stringValue(this.CLASS_NAME, "documentId", documentId);
45
- Guards.arrayOneOf(this.CLASS_NAME, "documentCode", documentCode, Object.values(UneceDocumentCodes));
46
- Guards.uint8Array(this.CLASS_NAME, "blob", blob);
45
+ Guards.stringValue(DocumentManagementRestClient.CLASS_NAME, "documentId", documentId);
46
+ Guards.arrayOneOf(DocumentManagementRestClient.CLASS_NAME, "documentCode", documentCode, Object.values(UneceDocumentCodes));
47
+ Guards.uint8Array(DocumentManagementRestClient.CLASS_NAME, "blob", blob);
47
48
  const response = await this.fetch("/", "POST", {
48
49
  body: {
49
50
  documentId,
@@ -70,7 +71,7 @@ class DocumentManagementClient extends BaseRestClient {
70
71
  * @returns Nothing.
71
72
  */
72
73
  async update(auditableItemGraphDocumentId, blob, annotationObject, auditableItemGraphEdges) {
73
- Urn.guard(this.CLASS_NAME, "auditableItemGraphDocumentId", auditableItemGraphDocumentId);
74
+ Urn.guard(DocumentManagementRestClient.CLASS_NAME, "auditableItemGraphDocumentId", auditableItemGraphDocumentId);
74
75
  await this.fetch("/:auditableItemGraphDocumentId", "PUT", {
75
76
  pathParams: {
76
77
  auditableItemGraphDocumentId
@@ -93,11 +94,11 @@ class DocumentManagementClient extends BaseRestClient {
93
94
  * @param options.extractRuleGroupId If provided will extract data from the document using the specified rule group id.
94
95
  * @param options.extractMimeType By default extraction will auto detect the mime type of the document, this can be used to override the detection.
95
96
  * @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.
97
+ * @param limit The limit of items to return, defaults to 1 so only most recent is returned.
97
98
  * @returns The documents and revisions if requested, ordered by revision descending, cursor is set if there are more document revisions.
98
99
  */
99
- async get(auditableItemGraphDocumentId, options, cursor, pageSize) {
100
- Urn.guard(this.CLASS_NAME, "auditableItemGraphDocumentId", auditableItemGraphDocumentId);
100
+ async get(auditableItemGraphDocumentId, options, cursor, limit) {
101
+ Urn.guard(DocumentManagementRestClient.CLASS_NAME, "auditableItemGraphDocumentId", auditableItemGraphDocumentId);
101
102
  const response = await this.fetch("/:auditableItemGraphDocumentId", "GET", {
102
103
  pathParams: {
103
104
  auditableItemGraphDocumentId
@@ -110,7 +111,7 @@ class DocumentManagementClient extends BaseRestClient {
110
111
  extractRuleGroupId: options?.extractRuleGroupId,
111
112
  extractMimeType: options?.extractMimeType,
112
113
  cursor,
113
- pageSize: Coerce.string(pageSize)
114
+ limit: Coerce.string(limit)
114
115
  }
115
116
  });
116
117
  return response.body;
@@ -128,8 +129,8 @@ class DocumentManagementClient extends BaseRestClient {
128
129
  * @returns The documents and revisions if requested, ordered by revision descending, cursor is set if there are more document revisions.
129
130
  */
130
131
  async getRevision(auditableItemGraphDocumentId, revision, options) {
131
- Urn.guard(this.CLASS_NAME, "auditableItemGraphDocumentId", auditableItemGraphDocumentId);
132
- Guards.integer(this.CLASS_NAME, "revision", revision);
132
+ Urn.guard(DocumentManagementRestClient.CLASS_NAME, "auditableItemGraphDocumentId", auditableItemGraphDocumentId);
133
+ Guards.integer(DocumentManagementRestClient.CLASS_NAME, "revision", revision);
133
134
  const response = await this.fetch("/:auditableItemGraphDocumentId/:revision", "GET", {
134
135
  pathParams: {
135
136
  auditableItemGraphDocumentId,
@@ -153,8 +154,8 @@ class DocumentManagementClient extends BaseRestClient {
153
154
  * @returns Nothing.
154
155
  */
155
156
  async removeRevision(auditableItemGraphDocumentId, revision) {
156
- Urn.guard(this.CLASS_NAME, "auditableItemGraphDocumentId", auditableItemGraphDocumentId);
157
- Guards.number(this.CLASS_NAME, "revision", revision);
157
+ Urn.guard(DocumentManagementRestClient.CLASS_NAME, "auditableItemGraphDocumentId", auditableItemGraphDocumentId);
158
+ Guards.number(DocumentManagementRestClient.CLASS_NAME, "revision", revision);
158
159
  await this.fetch("/:auditableItemGraphDocumentId/:revision", "DELETE", {
159
160
  pathParams: {
160
161
  auditableItemGraphDocumentId,
@@ -166,20 +167,19 @@ class DocumentManagementClient extends BaseRestClient {
166
167
  * Find all the document with a specific id.
167
168
  * @param documentId The document id to find in the graph.
168
169
  * @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
+ * @param limit The limit to get the next chunk of documents.
170
171
  * @returns The graph vertices that contain documents referencing the specified document id.
171
172
  */
172
- async query(documentId, cursor, pageSize) {
173
- Guards.stringValue(this.CLASS_NAME, "documentId", documentId);
173
+ async query(documentId, cursor, limit) {
174
+ Guards.stringValue(DocumentManagementRestClient.CLASS_NAME, "documentId", documentId);
174
175
  const response = await this.fetch("/", "GET", {
175
176
  query: {
176
177
  documentId,
177
178
  cursor,
178
- pageSize: Coerce.string(pageSize)
179
+ limit: Coerce.string(limit)
179
180
  }
180
181
  });
181
182
  return response.body;
182
183
  }
183
184
  }
184
-
185
- export { DocumentManagementClient };
185
+ //# sourceMappingURL=documentManagementRestClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documentManagementRestClient.js","sourceRoot":"","sources":["../../src/documentManagementRestClient.ts"],"names":[],"mappings":"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","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { BaseRestClient } from \"@twin.org/api-core\";\nimport type {\n\tIBaseRestClientConfig,\n\tICreatedResponse,\n\tINoContentResponse\n} from \"@twin.org/api-models\";\nimport type { IAuditableItemGraphVertexList } from \"@twin.org/auditable-item-graph-models\";\nimport { Coerce, Converter, Guards, Is, Urn } from \"@twin.org/core\";\nimport type { IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\nimport type {\n\tIDocument,\n\tIDocumentList,\n\tIDocumentManagementComponent,\n\tIDocumentManagementCreateRequest,\n\tIDocumentManagementGetRequest,\n\tIDocumentManagementGetResponse,\n\tIDocumentManagementGetRevisionRequest,\n\tIDocumentManagementGetRevisionResponse,\n\tIDocumentManagementQueryRequest,\n\tIDocumentManagementQueryResponse,\n\tIDocumentManagementRemoveRequest,\n\tIDocumentManagementUpdateRequest\n} from \"@twin.org/document-management-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { UneceDocumentCodes } from \"@twin.org/standards-unece\";\n\n/**\n * Client for performing document management through to REST endpoints.\n */\nexport class DocumentManagementRestClient\n\textends BaseRestClient\n\timplements IDocumentManagementComponent\n{\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<DocumentManagementRestClient>();\n\n\t/**\n\t * Create a new instance of DocumentManagementRestClient.\n\t * @param config The configuration for the client.\n\t */\n\tconstructor(config: IBaseRestClientConfig) {\n\t\tsuper(DocumentManagementRestClient.CLASS_NAME, config, \"document-management\");\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn DocumentManagementRestClient.CLASS_NAME;\n\t}\n\n\t/**\n\t * Store a document as an auditable item graph vertex and add its content to blob storage.\n\t * If the document id already exists and the blob data is different a new revision will be created.\n\t * For any other changes the current revision will be updated.\n\t * @param documentId The document id to create.\n\t * @param documentIdFormat The format of the document identifier.\n\t * @param documentCode The code for the document type.\n\t * @param blob The data to create the document with.\n\t * @param annotationObject Additional information to associate with the document.\n\t * @param auditableItemGraphEdges The auditable item graph vertices to connect the document to.\n\t * @param options Additional options for the set operation.\n\t * @param options.createAttestation Flag to create an attestation for the document, defaults to false.\n\t * @param options.addAlias Flag to add the document id as an alias to the aig vertex, defaults to true.\n\t * @param options.aliasAnnotationObject Annotation object for the alias.\n\t * @returns The auditable item graph vertex created for the document including its revision.\n\t */\n\tpublic async create(\n\t\tdocumentId: string,\n\t\tdocumentIdFormat: string | undefined,\n\t\tdocumentCode: UneceDocumentCodes,\n\t\tblob: Uint8Array,\n\t\tannotationObject?: IJsonLdNodeObject,\n\t\tauditableItemGraphEdges?: {\n\t\t\ttargetId: string;\n\t\t\taddAlias?: boolean;\n\t\t\taliasAnnotationObject?: IJsonLdNodeObject;\n\t\t}[],\n\t\toptions?: {\n\t\t\tcreateAttestation?: boolean;\n\t\t\taddAlias?: boolean;\n\t\t\taliasAnnotationObject?: IJsonLdNodeObject;\n\t\t}\n\t): Promise<string> {\n\t\tGuards.stringValue(DocumentManagementRestClient.CLASS_NAME, nameof(documentId), documentId);\n\t\tGuards.arrayOneOf(\n\t\t\tDocumentManagementRestClient.CLASS_NAME,\n\t\t\tnameof(documentCode),\n\t\t\tdocumentCode,\n\t\t\tObject.values(UneceDocumentCodes)\n\t\t);\n\t\tGuards.uint8Array(DocumentManagementRestClient.CLASS_NAME, nameof(blob), blob);\n\n\t\tconst response = await this.fetch<IDocumentManagementCreateRequest, ICreatedResponse>(\n\t\t\t\"/\",\n\t\t\t\"POST\",\n\t\t\t{\n\t\t\t\tbody: {\n\t\t\t\t\tdocumentId,\n\t\t\t\t\tdocumentIdFormat,\n\t\t\t\t\tdocumentCode,\n\t\t\t\t\tblob: Converter.bytesToBase64(blob),\n\t\t\t\t\tannotationObject,\n\t\t\t\t\tauditableItemGraphEdges,\n\t\t\t\t\tcreateAttestation: options?.createAttestation,\n\t\t\t\t\taddAlias: options?.addAlias,\n\t\t\t\t\taliasAnnotationObject: options?.aliasAnnotationObject\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\treturn response.headers.location;\n\t}\n\n\t/**\n\t * Update a document as an auditable item graph vertex and add its content to blob storage.\n\t * If the blob data is different a new revision will be created.\n\t * For any other changes the current revision will be updated.\n\t * @param auditableItemGraphDocumentId The auditable item graph vertex id which contains the document.\n\t * @param blob The data to update the document with.\n\t * @param annotationObject Additional information to associate with the document.\n\t * @param auditableItemGraphEdges The auditable item graph vertices to connect the document to, if undefined retains current connections.\n\t * @returns Nothing.\n\t */\n\tpublic async update(\n\t\tauditableItemGraphDocumentId: string,\n\t\tblob?: Uint8Array,\n\t\tannotationObject?: IJsonLdNodeObject,\n\t\tauditableItemGraphEdges?: {\n\t\t\ttargetId: string;\n\t\t\taddAlias?: boolean;\n\t\t\taliasAnnotationObject?: IJsonLdNodeObject;\n\t\t}[]\n\t): Promise<void> {\n\t\tUrn.guard(\n\t\t\tDocumentManagementRestClient.CLASS_NAME,\n\t\t\tnameof(auditableItemGraphDocumentId),\n\t\t\tauditableItemGraphDocumentId\n\t\t);\n\n\t\tawait this.fetch<IDocumentManagementUpdateRequest, INoContentResponse>(\n\t\t\t\"/:auditableItemGraphDocumentId\",\n\t\t\t\"PUT\",\n\t\t\t{\n\t\t\t\tpathParams: {\n\t\t\t\t\tauditableItemGraphDocumentId\n\t\t\t\t},\n\t\t\t\tbody: {\n\t\t\t\t\tblob: Is.uint8Array(blob) ? Converter.bytesToBase64(blob) : undefined,\n\t\t\t\t\tannotationObject,\n\t\t\t\t\tauditableItemGraphEdges\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Get a document using it's auditable item graph vertex id and optional revision.\n\t * @param auditableItemGraphDocumentId The auditable item graph vertex id which contains the document.\n\t * @param options Additional options for the get operation.\n\t * @param options.includeBlobStorageMetadata Flag to include the blob storage metadata for the document, defaults to false.\n\t * @param options.includeBlobStorageData Flag to include the blob storage data for the document, defaults to false.\n\t * @param options.includeAttestation Flag to include the attestation information for the document, defaults to false.\n\t * @param options.includeRemoved Flag to include deleted documents, defaults to false.\n\t * @param options.extractRuleGroupId If provided will extract data from the document using the specified rule group id.\n\t * @param options.extractMimeType By default extraction will auto detect the mime type of the document, this can be used to override the detection.\n\t * @param cursor The cursor to get the next chunk of revisions.\n\t * @param limit The limit of items to return, defaults to 1 so only most recent is returned.\n\t * @returns The documents and revisions if requested, ordered by revision descending, cursor is set if there are more document revisions.\n\t */\n\tpublic async get(\n\t\tauditableItemGraphDocumentId: string,\n\t\toptions?: {\n\t\t\tincludeBlobStorageMetadata?: boolean;\n\t\t\tincludeBlobStorageData?: boolean;\n\t\t\tincludeAttestation?: boolean;\n\t\t\tincludeRemoved?: boolean;\n\t\t\textractRuleGroupId?: string;\n\t\t\textractMimeType?: string;\n\t\t},\n\t\tcursor?: string,\n\t\tlimit?: number\n\t): Promise<IDocumentList> {\n\t\tUrn.guard(\n\t\t\tDocumentManagementRestClient.CLASS_NAME,\n\t\t\tnameof(auditableItemGraphDocumentId),\n\t\t\tauditableItemGraphDocumentId\n\t\t);\n\n\t\tconst response = await this.fetch<\n\t\t\tIDocumentManagementGetRequest,\n\t\t\tIDocumentManagementGetResponse\n\t\t>(\"/:auditableItemGraphDocumentId\", \"GET\", {\n\t\t\tpathParams: {\n\t\t\t\tauditableItemGraphDocumentId\n\t\t\t},\n\t\t\tquery: {\n\t\t\t\tincludeBlobStorageMetadata: options?.includeBlobStorageMetadata,\n\t\t\t\tincludeBlobStorageData: options?.includeBlobStorageData,\n\t\t\t\tincludeAttestation: options?.includeAttestation,\n\t\t\t\tincludeRemoved: options?.includeRemoved,\n\t\t\t\textractRuleGroupId: options?.extractRuleGroupId,\n\t\t\t\textractMimeType: options?.extractMimeType,\n\t\t\t\tcursor,\n\t\t\t\tlimit: Coerce.string(limit)\n\t\t\t}\n\t\t});\n\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Get a document revision using it's auditable item graph vertex id.\n\t * @param auditableItemGraphDocumentId The auditable item graph vertex id which contains the document.\n\t * @param revision The revision id for the document.\n\t * @param options Additional options for the get operation.\n\t * @param options.includeBlobStorageMetadata Flag to include the blob storage metadata for the document, defaults to false.\n\t * @param options.includeBlobStorageData Flag to include the blob storage data for the document, defaults to false.\n\t * @param options.includeAttestation Flag to include the attestation information for the document, defaults to false.\n\t * @param options.extractRuleGroupId If provided will extract data from the document using the specified rule group id.\n\t * @param options.extractMimeType By default extraction will auto detect the mime type of the document, this can be used to override the detection.\n\t * @returns The documents and revisions if requested, ordered by revision descending, cursor is set if there are more document revisions.\n\t */\n\tpublic async getRevision(\n\t\tauditableItemGraphDocumentId: string,\n\t\trevision: number,\n\t\toptions?: {\n\t\t\tincludeBlobStorageMetadata?: boolean;\n\t\t\tincludeBlobStorageData?: boolean;\n\t\t\tincludeAttestation?: boolean;\n\t\t\textractRuleGroupId?: string;\n\t\t\textractMimeType?: string;\n\t\t}\n\t): Promise<IDocument> {\n\t\tUrn.guard(\n\t\t\tDocumentManagementRestClient.CLASS_NAME,\n\t\t\tnameof(auditableItemGraphDocumentId),\n\t\t\tauditableItemGraphDocumentId\n\t\t);\n\t\tGuards.integer(DocumentManagementRestClient.CLASS_NAME, nameof(revision), revision);\n\n\t\tconst response = await this.fetch<\n\t\t\tIDocumentManagementGetRevisionRequest,\n\t\t\tIDocumentManagementGetRevisionResponse\n\t\t>(\"/:auditableItemGraphDocumentId/:revision\", \"GET\", {\n\t\t\tpathParams: {\n\t\t\t\tauditableItemGraphDocumentId,\n\t\t\t\trevision: revision.toString()\n\t\t\t},\n\t\t\tquery: {\n\t\t\t\tincludeBlobStorageMetadata: options?.includeBlobStorageMetadata,\n\t\t\t\tincludeBlobStorageData: options?.includeBlobStorageData,\n\t\t\t\tincludeAttestation: options?.includeAttestation,\n\t\t\t\textractRuleGroupId: options?.extractRuleGroupId,\n\t\t\t\textractMimeType: options?.extractMimeType\n\t\t\t}\n\t\t});\n\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Remove an auditable item graph vertex using it's id.\n\t * The document dateDeleted will be set, but can still be queried with the includeRemoved flag.\n\t * @param auditableItemGraphDocumentId The auditable item graph vertex id which contains the document.\n\t * @param revision The revision of the document to remove.\n\t * @returns Nothing.\n\t */\n\tpublic async removeRevision(\n\t\tauditableItemGraphDocumentId: string,\n\t\trevision: number\n\t): Promise<void> {\n\t\tUrn.guard(\n\t\t\tDocumentManagementRestClient.CLASS_NAME,\n\t\t\tnameof(auditableItemGraphDocumentId),\n\t\t\tauditableItemGraphDocumentId\n\t\t);\n\t\tGuards.number(DocumentManagementRestClient.CLASS_NAME, nameof(revision), revision);\n\n\t\tawait this.fetch<IDocumentManagementRemoveRequest, INoContentResponse>(\n\t\t\t\"/:auditableItemGraphDocumentId/:revision\",\n\t\t\t\"DELETE\",\n\t\t\t{\n\t\t\t\tpathParams: {\n\t\t\t\t\tauditableItemGraphDocumentId,\n\t\t\t\t\trevision: revision.toString()\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Find all the document with a specific id.\n\t * @param documentId The document id to find in the graph.\n\t * @param cursor The cursor to get the next chunk of documents.\n\t * @param limit The limit to get the next chunk of documents.\n\t * @returns The graph vertices that contain documents referencing the specified document id.\n\t */\n\tpublic async query(\n\t\tdocumentId: string,\n\t\tcursor?: string,\n\t\tlimit?: number\n\t): Promise<IAuditableItemGraphVertexList> {\n\t\tGuards.stringValue(DocumentManagementRestClient.CLASS_NAME, nameof(documentId), documentId);\n\n\t\tconst response = await this.fetch<\n\t\t\tIDocumentManagementQueryRequest,\n\t\t\tIDocumentManagementQueryResponse\n\t\t>(\"/\", \"GET\", {\n\t\t\tquery: {\n\t\t\t\tdocumentId,\n\t\t\t\tcursor,\n\t\t\t\tlimit: Coerce.string(limit)\n\t\t\t}\n\t\t});\n\n\t\treturn response.body;\n\t}\n}\n"]}
@@ -0,0 +1,4 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ export * from "./documentManagementRestClient.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,mCAAmC,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./documentManagementRestClient.js\";\n"]}
@@ -7,16 +7,21 @@ import { UneceDocumentCodes } from "@twin.org/standards-unece";
7
7
  /**
8
8
  * Client for performing document management through to REST endpoints.
9
9
  */
10
- export declare class DocumentManagementClient extends BaseRestClient implements IDocumentManagementComponent {
10
+ export declare class DocumentManagementRestClient extends BaseRestClient implements IDocumentManagementComponent {
11
11
  /**
12
12
  * Runtime name for the class.
13
13
  */
14
- readonly CLASS_NAME: string;
14
+ static readonly CLASS_NAME: string;
15
15
  /**
16
- * Create a new instance of DocumentManagementClient.
16
+ * Create a new instance of DocumentManagementRestClient.
17
17
  * @param config The configuration for the client.
18
18
  */
19
19
  constructor(config: IBaseRestClientConfig);
20
+ /**
21
+ * Returns the class name of the component.
22
+ * @returns The class name of the component.
23
+ */
24
+ className(): string;
20
25
  /**
21
26
  * Store a document as an auditable item graph vertex and add its content to blob storage.
22
27
  * If the document id already exists and the blob data is different a new revision will be created.
@@ -68,7 +73,7 @@ export declare class DocumentManagementClient extends BaseRestClient implements
68
73
  * @param options.extractRuleGroupId If provided will extract data from the document using the specified rule group id.
69
74
  * @param options.extractMimeType By default extraction will auto detect the mime type of the document, this can be used to override the detection.
70
75
  * @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.
76
+ * @param limit The limit of items to return, defaults to 1 so only most recent is returned.
72
77
  * @returns The documents and revisions if requested, ordered by revision descending, cursor is set if there are more document revisions.
73
78
  */
74
79
  get(auditableItemGraphDocumentId: string, options?: {
@@ -78,7 +83,7 @@ export declare class DocumentManagementClient extends BaseRestClient implements
78
83
  includeRemoved?: boolean;
79
84
  extractRuleGroupId?: string;
80
85
  extractMimeType?: string;
81
- }, cursor?: string, pageSize?: number): Promise<IDocumentList>;
86
+ }, cursor?: string, limit?: number): Promise<IDocumentList>;
82
87
  /**
83
88
  * Get a document revision using it's auditable item graph vertex id.
84
89
  * @param auditableItemGraphDocumentId The auditable item graph vertex id which contains the document.
@@ -110,8 +115,8 @@ export declare class DocumentManagementClient extends BaseRestClient implements
110
115
  * Find all the document with a specific id.
111
116
  * @param documentId The document id to find in the graph.
112
117
  * @param cursor The cursor to get the next chunk of documents.
113
- * @param pageSize The page size to get the next chunk of documents.
118
+ * @param limit The limit to get the next chunk of documents.
114
119
  * @returns The graph vertices that contain documents referencing the specified document id.
115
120
  */
116
- query(documentId: string, cursor?: string, pageSize?: number): Promise<IAuditableItemGraphVertexList>;
121
+ query(documentId: string, cursor?: string, limit?: number): Promise<IAuditableItemGraphVertexList>;
117
122
  }
@@ -1 +1 @@
1
- export * from "./documentManagementClient";
1
+ export * from "./documentManagementRestClient.js";
package/docs/changelog.md CHANGED
@@ -1,5 +1,46 @@
1
1
  # @twin.org/document-management-rest-client - Changelog
2
2
 
3
+ ## [0.0.3-next.1](https://github.com/twinfoundation/document-management/compare/document-management-rest-client-v0.0.3-next.0...document-management-rest-client-v0.0.3-next.1) (2025-11-12)
4
+
5
+
6
+ ### Features
7
+
8
+ * add context id features ([#24](https://github.com/twinfoundation/document-management/issues/24)) ([83f65f1](https://github.com/twinfoundation/document-management/commit/83f65f15e55f2293f5ca0d9d1e4679ba67c4ec8d))
9
+ * add validate-locales ([b6b6f9e](https://github.com/twinfoundation/document-management/commit/b6b6f9e9d66c17af3d030247ca168ac0b5844bdc))
10
+ * document get can perform extraction ([#6](https://github.com/twinfoundation/document-management/issues/6)) ([5ce6d37](https://github.com/twinfoundation/document-management/commit/5ce6d37432ad271ca5783f422846f4be98ec2215))
11
+ * eslint migration to flat config ([98635aa](https://github.com/twinfoundation/document-management/commit/98635aa24ebafba265e989e461fe98104f683191))
12
+ * get document revision ([080eddc](https://github.com/twinfoundation/document-management/commit/080eddcc024c622dda6bb36f60f5fa80a86cf5bb))
13
+ * store document as a vertex ([#2](https://github.com/twinfoundation/document-management/issues/2)) ([7febedc](https://github.com/twinfoundation/document-management/commit/7febedc3fb31de9c19565d6326341046834f2c74))
14
+ * update dependencies ([f9d8641](https://github.com/twinfoundation/document-management/commit/f9d86417dba24027699225ec7473296e361dcb00))
15
+ * update framework core ([f991a59](https://github.com/twinfoundation/document-management/commit/f991a59d25ec228bcdd7a5b6bd55578985b55a84))
16
+ * use targetId in AIG for edges ([82dec81](https://github.com/twinfoundation/document-management/commit/82dec8190d8b523b350ef133bdcf648cab1023b0))
17
+
18
+
19
+ ### Bug Fixes
20
+
21
+ * 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))
22
+
23
+
24
+ ### Dependencies
25
+
26
+ * The following workspace dependencies were updated
27
+ * dependencies
28
+ * @twin.org/document-management-models bumped from 0.0.3-next.0 to 0.0.3-next.1
29
+
30
+ ## [0.0.2-next.4](https://github.com/twinfoundation/document-management/compare/document-management-rest-client-v0.0.2-next.3...document-management-rest-client-v0.0.2-next.4) (2025-10-09)
31
+
32
+
33
+ ### Features
34
+
35
+ * add validate-locales ([b6b6f9e](https://github.com/twinfoundation/document-management/commit/b6b6f9e9d66c17af3d030247ca168ac0b5844bdc))
36
+
37
+
38
+ ### Dependencies
39
+
40
+ * The following workspace dependencies were updated
41
+ * dependencies
42
+ * @twin.org/document-management-models bumped from 0.0.2-next.3 to 0.0.2-next.4
43
+
3
44
  ## [0.0.2-next.3](https://github.com/twinfoundation/document-management/compare/document-management-rest-client-v0.0.2-next.2...document-management-rest-client-v0.0.2-next.3) (2025-09-29)
4
45
 
5
46
 
@@ -1,4 +1,4 @@
1
- # Class: DocumentManagementClient
1
+ # Class: DocumentManagementRestClient
2
2
 
3
3
  Client for performing document management through to REST endpoints.
4
4
 
@@ -14,9 +14,9 @@ Client for performing document management through to REST endpoints.
14
14
 
15
15
  ### Constructor
16
16
 
17
- > **new DocumentManagementClient**(`config`): `DocumentManagementClient`
17
+ > **new DocumentManagementRestClient**(`config`): `DocumentManagementRestClient`
18
18
 
19
- Create a new instance of DocumentManagementClient.
19
+ Create a new instance of DocumentManagementRestClient.
20
20
 
21
21
  #### Parameters
22
22
 
@@ -28,7 +28,7 @@ The configuration for the client.
28
28
 
29
29
  #### Returns
30
30
 
31
- `DocumentManagementClient`
31
+ `DocumentManagementRestClient`
32
32
 
33
33
  #### Overrides
34
34
 
@@ -38,15 +38,29 @@ The configuration for the client.
38
38
 
39
39
  ### CLASS\_NAME
40
40
 
41
- > `readonly` **CLASS\_NAME**: `string` = `DocumentManagementClient._CLASS_NAME`
41
+ > `readonly` `static` **CLASS\_NAME**: `string`
42
42
 
43
43
  Runtime name for the class.
44
44
 
45
+ ## Methods
46
+
47
+ ### className()
48
+
49
+ > **className**(): `string`
50
+
51
+ Returns the class name of the component.
52
+
53
+ #### Returns
54
+
55
+ `string`
56
+
57
+ The class name of the component.
58
+
45
59
  #### Implementation of
46
60
 
47
- `IDocumentManagementComponent.CLASS_NAME`
61
+ `IDocumentManagementComponent.className`
48
62
 
49
- ## Methods
63
+ ***
50
64
 
51
65
  ### create()
52
66
 
@@ -68,7 +82,7 @@ The document id to create.
68
82
 
69
83
  The format of the document identifier.
70
84
 
71
- `undefined` | `string`
85
+ `string` | `undefined`
72
86
 
73
87
  ##### documentCode
74
88
 
@@ -176,7 +190,7 @@ Nothing.
176
190
 
177
191
  ### get()
178
192
 
179
- > **get**(`auditableItemGraphDocumentId`, `options?`, `cursor?`, `pageSize?`): `Promise`\<`IDocumentList`\>
193
+ > **get**(`auditableItemGraphDocumentId`, `options?`, `cursor?`, `limit?`): `Promise`\<`IDocumentList`\>
180
194
 
181
195
  Get a document using it's auditable item graph vertex id and optional revision.
182
196
 
@@ -234,11 +248,11 @@ By default extraction will auto detect the mime type of the document, this can b
234
248
 
235
249
  The cursor to get the next chunk of revisions.
236
250
 
237
- ##### pageSize?
251
+ ##### limit?
238
252
 
239
253
  `number`
240
254
 
241
- Page size of items to return, defaults to 1 so only most recent is returned.
255
+ The limit of items to return, defaults to 1 so only most recent is returned.
242
256
 
243
257
  #### Returns
244
258
 
@@ -353,7 +367,7 @@ Nothing.
353
367
 
354
368
  ### query()
355
369
 
356
- > **query**(`documentId`, `cursor?`, `pageSize?`): `Promise`\<`IAuditableItemGraphVertexList`\>
370
+ > **query**(`documentId`, `cursor?`, `limit?`): `Promise`\<`IAuditableItemGraphVertexList`\>
357
371
 
358
372
  Find all the document with a specific id.
359
373
 
@@ -371,11 +385,11 @@ The document id to find in the graph.
371
385
 
372
386
  The cursor to get the next chunk of documents.
373
387
 
374
- ##### pageSize?
388
+ ##### limit?
375
389
 
376
390
  `number`
377
391
 
378
- The page size to get the next chunk of documents.
392
+ The limit to get the next chunk of documents.
379
393
 
380
394
  #### Returns
381
395
 
@@ -2,4 +2,4 @@
2
2
 
3
3
  ## Classes
4
4
 
5
- - [DocumentManagementClient](classes/DocumentManagementClient.md)
5
+ - [DocumentManagementRestClient](classes/DocumentManagementRestClient.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/document-management-rest-client",
3
- "version": "0.0.2-next.3",
3
+ "version": "0.0.3-next.1",
4
4
  "description": "Document management contract implementation which can connect to REST endpoints",
5
5
  "repository": {
6
6
  "type": "git",
@@ -19,28 +19,42 @@
19
19
  "@twin.org/auditable-item-graph-models": "next",
20
20
  "@twin.org/core": "next",
21
21
  "@twin.org/data-json-ld": "next",
22
- "@twin.org/document-management-models": "0.0.2-next.3",
22
+ "@twin.org/document-management-models": "0.0.3-next.1",
23
23
  "@twin.org/entity": "next",
24
24
  "@twin.org/nameof": "next",
25
25
  "@twin.org/standards-unece": "next",
26
26
  "@twin.org/web": "next"
27
27
  },
28
- "main": "./dist/cjs/index.cjs",
29
- "module": "./dist/esm/index.mjs",
28
+ "main": "./dist/es/index.js",
30
29
  "types": "./dist/types/index.d.ts",
31
30
  "exports": {
32
31
  ".": {
33
32
  "types": "./dist/types/index.d.ts",
34
- "require": "./dist/cjs/index.cjs",
35
- "import": "./dist/esm/index.mjs"
33
+ "import": "./dist/es/index.js",
34
+ "default": "./dist/es/index.js"
36
35
  },
37
36
  "./locales/*.json": "./locales/*.json"
38
37
  },
39
38
  "files": [
40
- "dist/cjs",
41
- "dist/esm",
39
+ "dist/es",
42
40
  "dist/types",
43
41
  "locales",
44
42
  "docs"
45
- ]
43
+ ],
44
+ "keywords": [
45
+ "twin",
46
+ "trade",
47
+ "iota",
48
+ "framework",
49
+ "blockchain",
50
+ "document-management",
51
+ "documents",
52
+ "management",
53
+ "storage",
54
+ "rest-api"
55
+ ],
56
+ "bugs": {
57
+ "url": "git+https://github.com/twinfoundation/document-management/issues"
58
+ },
59
+ "homepage": "https://twindev.org"
46
60
  }
@@ -1,187 +0,0 @@
1
- 'use strict';
2
-
3
- var apiCore = require('@twin.org/api-core');
4
- var core = require('@twin.org/core');
5
- var standardsUnece = require('@twin.org/standards-unece');
6
-
7
- // Copyright 2024 IOTA Stiftung.
8
- // SPDX-License-Identifier: Apache-2.0.
9
- /**
10
- * Client for performing document management through to REST endpoints.
11
- */
12
- class DocumentManagementClient extends apiCore.BaseRestClient {
13
- /**
14
- * Runtime name for the class.
15
- * @internal
16
- */
17
- static _CLASS_NAME = "DocumentManagementClient";
18
- /**
19
- * Runtime name for the class.
20
- */
21
- CLASS_NAME = DocumentManagementClient._CLASS_NAME;
22
- /**
23
- * Create a new instance of DocumentManagementClient.
24
- * @param config The configuration for the client.
25
- */
26
- constructor(config) {
27
- super(DocumentManagementClient._CLASS_NAME, config, "document-management");
28
- }
29
- /**
30
- * Store a document as an auditable item graph vertex and add its content to blob storage.
31
- * If the document id already exists and the blob data is different a new revision will be created.
32
- * For any other changes the current revision will be updated.
33
- * @param documentId The document id to create.
34
- * @param documentIdFormat The format of the document identifier.
35
- * @param documentCode The code for the document type.
36
- * @param blob The data to create the document with.
37
- * @param annotationObject Additional information to associate with the document.
38
- * @param auditableItemGraphEdges The auditable item graph vertices to connect the document to.
39
- * @param options Additional options for the set operation.
40
- * @param options.createAttestation Flag to create an attestation for the document, defaults to false.
41
- * @param options.addAlias Flag to add the document id as an alias to the aig vertex, defaults to true.
42
- * @param options.aliasAnnotationObject Annotation object for the alias.
43
- * @returns The auditable item graph vertex created for the document including its revision.
44
- */
45
- async create(documentId, documentIdFormat, documentCode, blob, annotationObject, auditableItemGraphEdges, options) {
46
- core.Guards.stringValue(this.CLASS_NAME, "documentId", documentId);
47
- core.Guards.arrayOneOf(this.CLASS_NAME, "documentCode", documentCode, Object.values(standardsUnece.UneceDocumentCodes));
48
- core.Guards.uint8Array(this.CLASS_NAME, "blob", blob);
49
- const response = await this.fetch("/", "POST", {
50
- body: {
51
- documentId,
52
- documentIdFormat,
53
- documentCode,
54
- blob: core.Converter.bytesToBase64(blob),
55
- annotationObject,
56
- auditableItemGraphEdges,
57
- createAttestation: options?.createAttestation,
58
- addAlias: options?.addAlias,
59
- aliasAnnotationObject: options?.aliasAnnotationObject
60
- }
61
- });
62
- return response.headers.location;
63
- }
64
- /**
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.
90
- * @param options Additional options for the get operation.
91
- * @param options.includeBlobStorageMetadata Flag to include the blob storage metadata for the document, defaults to false.
92
- * @param options.includeBlobStorageData Flag to include the blob storage data for the document, defaults to false.
93
- * @param options.includeAttestation Flag to include the attestation information for the document, defaults to false.
94
- * @param options.includeRemoved Flag to include deleted documents, defaults to false.
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.
99
- * @returns The documents and revisions if requested, ordered by revision descending, cursor is set if there are more document revisions.
100
- */
101
- async get(auditableItemGraphDocumentId, options, cursor, pageSize) {
102
- core.Urn.guard(this.CLASS_NAME, "auditableItemGraphDocumentId", auditableItemGraphDocumentId);
103
- const response = await this.fetch("/:auditableItemGraphDocumentId", "GET", {
104
- pathParams: {
105
- auditableItemGraphDocumentId
106
- },
107
- query: {
108
- includeBlobStorageMetadata: options?.includeBlobStorageMetadata,
109
- includeBlobStorageData: options?.includeBlobStorageData,
110
- includeAttestation: options?.includeAttestation,
111
- includeRemoved: options?.includeRemoved,
112
- extractRuleGroupId: options?.extractRuleGroupId,
113
- extractMimeType: options?.extractMimeType,
114
- cursor,
115
- pageSize: core.Coerce.string(pageSize)
116
- }
117
- });
118
- return response.body;
119
- }
120
- /**
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.
131
- */
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", {
136
- pathParams: {
137
- auditableItemGraphDocumentId,
138
- revision: revision.toString()
139
- },
140
- query: {
141
- includeBlobStorageMetadata: options?.includeBlobStorageMetadata,
142
- includeBlobStorageData: options?.includeBlobStorageData,
143
- includeAttestation: options?.includeAttestation,
144
- extractRuleGroupId: options?.extractRuleGroupId,
145
- extractMimeType: options?.extractMimeType
146
- }
147
- });
148
- return response.body;
149
- }
150
- /**
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.
156
- */
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", {
161
- pathParams: {
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", {
177
- query: {
178
- documentId,
179
- cursor,
180
- pageSize: core.Coerce.string(pageSize)
181
- }
182
- });
183
- return response.body;
184
- }
185
- }
186
-
187
- exports.DocumentManagementClient = DocumentManagementClient;