@twin.org/auditable-item-stream-rest-client 0.0.2-next.5 → 0.0.3-next.10

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,14 +1,13 @@
1
- import { BaseRestClient } from '@twin.org/api-core';
2
- import { HttpParameterHelper } from '@twin.org/api-models';
3
- import { Guards, Coerce, NotSupportedError } from '@twin.org/core';
4
- import { HeaderTypes, MimeTypes } from '@twin.org/web';
5
-
6
1
  // Copyright 2024 IOTA Stiftung.
7
2
  // SPDX-License-Identifier: Apache-2.0.
3
+ import { BaseRestClient } from "@twin.org/api-core";
4
+ import { HttpParameterHelper } from "@twin.org/api-models";
5
+ import { Coerce, Guards, Is, NotSupportedError } from "@twin.org/core";
6
+ import { HeaderHelper, HeaderTypes, MimeTypes } from "@twin.org/web";
8
7
  /**
9
8
  * Client for performing auditable item stream through to REST endpoints.
10
9
  */
11
- class AuditableItemStreamRestClient extends BaseRestClient {
10
+ export class AuditableItemStreamRestClient extends BaseRestClient {
12
11
  /**
13
12
  * Runtime name for the class.
14
13
  */
@@ -20,6 +19,13 @@ class AuditableItemStreamRestClient extends BaseRestClient {
20
19
  constructor(config) {
21
20
  super("AuditableItemStreamRestClient", config, "auditable-item-stream");
22
21
  }
22
+ /**
23
+ * Returns the class name of the component.
24
+ * @returns The class name of the component.
25
+ */
26
+ className() {
27
+ return AuditableItemStreamRestClient.CLASS_NAME;
28
+ }
23
29
  /**
24
30
  * Create a new stream.
25
31
  * @param stream The stream to create.
@@ -126,7 +132,11 @@ class AuditableItemStreamRestClient extends BaseRestClient {
126
132
  limit: Coerce.string(limit)
127
133
  }
128
134
  });
129
- return response.body;
135
+ return {
136
+ entries: response.body,
137
+ cursor: HeaderHelper.extractLinkHeaderRelation(response.headers?.[HeaderTypes.Link], "next")
138
+ ?.urlQueryParams?.cursor
139
+ };
130
140
  }
131
141
  /**
132
142
  * Create an entry in the stream.
@@ -136,7 +146,7 @@ class AuditableItemStreamRestClient extends BaseRestClient {
136
146
  */
137
147
  async createEntry(id, entryObject) {
138
148
  Guards.stringValue(AuditableItemStreamRestClient.CLASS_NAME, "id", id);
139
- const response = await this.fetch("/:id", "POST", {
149
+ const response = await this.fetch("/:id/entries", "POST", {
140
150
  pathParams: {
141
151
  id
142
152
  },
@@ -158,7 +168,7 @@ class AuditableItemStreamRestClient extends BaseRestClient {
158
168
  async getEntry(id, entryId, options) {
159
169
  Guards.stringValue(AuditableItemStreamRestClient.CLASS_NAME, "id", id);
160
170
  Guards.stringValue(AuditableItemStreamRestClient.CLASS_NAME, "entryId", entryId);
161
- const response = await this.fetch("/:id/:entryId", "GET", {
171
+ const response = await this.fetch("/:id/entries/:entryId", "GET", {
162
172
  headers: {
163
173
  [HeaderTypes.Accept]: MimeTypes.JsonLd
164
174
  },
@@ -182,7 +192,7 @@ class AuditableItemStreamRestClient extends BaseRestClient {
182
192
  async getEntryObject(id, entryId) {
183
193
  Guards.stringValue(AuditableItemStreamRestClient.CLASS_NAME, "id", id);
184
194
  Guards.stringValue(AuditableItemStreamRestClient.CLASS_NAME, "entryId", entryId);
185
- const response = await this.fetch("/:id/:entryId/object", "GET", {
195
+ const response = await this.fetch("/:id/entries/:entryId/object", "GET", {
186
196
  headers: {
187
197
  [HeaderTypes.Accept]: MimeTypes.JsonLd
188
198
  },
@@ -203,7 +213,7 @@ class AuditableItemStreamRestClient extends BaseRestClient {
203
213
  async updateEntry(id, entryId, entryObject) {
204
214
  Guards.stringValue(AuditableItemStreamRestClient.CLASS_NAME, "id", id);
205
215
  Guards.stringValue(AuditableItemStreamRestClient.CLASS_NAME, "entryId", entryId);
206
- await this.fetch("/:id/:entryId", "PUT", {
216
+ await this.fetch("/:id/entries/:entryId", "PUT", {
207
217
  pathParams: {
208
218
  id,
209
219
  entryId
@@ -222,7 +232,7 @@ class AuditableItemStreamRestClient extends BaseRestClient {
222
232
  async removeEntry(id, entryId) {
223
233
  Guards.stringValue(AuditableItemStreamRestClient.CLASS_NAME, "id", id);
224
234
  Guards.stringValue(AuditableItemStreamRestClient.CLASS_NAME, "entryId", entryId);
225
- await this.fetch("/:id/:entryId", "DELETE", {
235
+ await this.fetch("/:id/entries/:entryId", "DELETE", {
226
236
  pathParams: {
227
237
  id,
228
238
  entryId
@@ -231,7 +241,7 @@ class AuditableItemStreamRestClient extends BaseRestClient {
231
241
  }
232
242
  /**
233
243
  * Get the entries for the stream.
234
- * @param id The id of the stream to get.
244
+ * @param id The id of the stream to get, if undefined returns all matching entries.
235
245
  * @param options Additional options for the get operation.
236
246
  * @param options.conditions The conditions to filter the stream.
237
247
  * @param options.includeDeleted Whether to include deleted entries, defaults to false.
@@ -243,28 +253,44 @@ class AuditableItemStreamRestClient extends BaseRestClient {
243
253
  * @throws NotFoundError if the stream is not found.
244
254
  */
245
255
  async getEntries(id, options) {
246
- Guards.stringValue(AuditableItemStreamRestClient.CLASS_NAME, "id", id);
247
- const response = await this.fetch("/:id/entries", "GET", {
248
- headers: {
249
- [HeaderTypes.Accept]: MimeTypes.JsonLd
250
- },
251
- pathParams: {
252
- id
253
- },
254
- query: {
255
- conditions: HttpParameterHelper.objectToString(options?.conditions),
256
- includeDeleted: Coerce.string(options?.includeDeleted),
257
- verifyEntries: Coerce.string(options?.verifyEntries),
258
- limit: Coerce.string(options?.limit),
259
- cursor: options?.cursor,
260
- order: options?.order
261
- }
262
- });
263
- return response.body;
256
+ const queryParams = {
257
+ conditions: HttpParameterHelper.objectToString(options?.conditions),
258
+ includeDeleted: Coerce.string(options?.includeDeleted),
259
+ verifyEntries: Coerce.string(options?.verifyEntries),
260
+ limit: Coerce.string(options?.limit),
261
+ cursor: options?.cursor,
262
+ order: options?.order
263
+ };
264
+ let response;
265
+ if (!Is.empty(id)) {
266
+ Guards.stringValue(AuditableItemStreamRestClient.CLASS_NAME, "id", id);
267
+ response = await this.fetch("/:id/entries", "GET", {
268
+ headers: {
269
+ [HeaderTypes.Accept]: MimeTypes.JsonLd
270
+ },
271
+ pathParams: {
272
+ id
273
+ },
274
+ query: queryParams
275
+ });
276
+ }
277
+ else {
278
+ response = await this.fetch("/entries", "GET", {
279
+ headers: {
280
+ [HeaderTypes.Accept]: MimeTypes.JsonLd
281
+ },
282
+ query: queryParams
283
+ });
284
+ }
285
+ return {
286
+ entries: response.body,
287
+ cursor: HeaderHelper.extractLinkHeaderRelation(response.headers?.[HeaderTypes.Link], "next")
288
+ ?.urlQueryParams?.cursor
289
+ };
264
290
  }
265
291
  /**
266
292
  * Get the entry objects for the stream.
267
- * @param id The id of the stream to get.
293
+ * @param id The id of the stream to get, if undefined returns all matching entries.
268
294
  * @param options Additional options for the get operation.
269
295
  * @param options.conditions The conditions to filter the stream.
270
296
  * @param options.includeDeleted Whether to include deleted entries, defaults to false.
@@ -275,23 +301,39 @@ class AuditableItemStreamRestClient extends BaseRestClient {
275
301
  * @throws NotFoundError if the stream is not found.
276
302
  */
277
303
  async getEntryObjects(id, options) {
278
- Guards.stringValue(AuditableItemStreamRestClient.CLASS_NAME, "id", id);
279
- const response = await this.fetch("/:id/entries/objects", "GET", {
280
- headers: {
281
- [HeaderTypes.Accept]: MimeTypes.JsonLd
282
- },
283
- pathParams: {
284
- id
285
- },
286
- query: {
287
- conditions: HttpParameterHelper.objectToString(options?.conditions),
288
- includeDeleted: Coerce.string(options?.includeDeleted),
289
- limit: Coerce.string(options?.limit),
290
- cursor: Coerce.string(options?.cursor),
291
- order: options?.order
292
- }
293
- });
294
- return response.body;
304
+ const queryParams = {
305
+ conditions: HttpParameterHelper.objectToString(options?.conditions),
306
+ includeDeleted: Coerce.string(options?.includeDeleted),
307
+ limit: Coerce.string(options?.limit),
308
+ cursor: options?.cursor,
309
+ order: options?.order
310
+ };
311
+ let response;
312
+ if (!Is.empty(id)) {
313
+ Guards.stringValue(AuditableItemStreamRestClient.CLASS_NAME, "id", id);
314
+ response = await this.fetch("/:id/entries/objects", "GET", {
315
+ headers: {
316
+ [HeaderTypes.Accept]: MimeTypes.JsonLd
317
+ },
318
+ pathParams: {
319
+ id
320
+ },
321
+ query: queryParams
322
+ });
323
+ }
324
+ else {
325
+ response = await this.fetch("/entries/objects", "GET", {
326
+ headers: {
327
+ [HeaderTypes.Accept]: MimeTypes.JsonLd
328
+ },
329
+ query: queryParams
330
+ });
331
+ }
332
+ return {
333
+ entries: response.body,
334
+ cursor: HeaderHelper.extractLinkHeaderRelation(response.headers?.[HeaderTypes.Link], "next")
335
+ ?.urlQueryParams?.cursor
336
+ };
295
337
  }
296
338
  /**
297
339
  * Remove the verifiable storage for the stream and entries, not supported on client.
@@ -305,5 +347,4 @@ class AuditableItemStreamRestClient extends BaseRestClient {
305
347
  });
306
348
  }
307
349
  }
308
-
309
- export { AuditableItemStreamRestClient };
350
+ //# sourceMappingURL=auditableItemStreamRestClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auditableItemStreamRestClient.js","sourceRoot":"","sources":["../../src/auditableItemStreamRestClient.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EACN,mBAAmB,EAInB,MAAM,sBAAsB,CAAC;AA6B9B,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAIvE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAErE;;GAEG;AACH,MAAM,OAAO,6BACZ,SAAQ,cAAc;IAGtB;;OAEG;IACI,MAAM,CAAU,UAAU,mCAAmD;IAEpF;;;OAGG;IACH,YAAY,MAA6B;QACxC,KAAK,kCAA0C,MAAM,EAAE,uBAAuB,CAAC,CAAC;IACjF,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,6BAA6B,CAAC,UAAU,CAAC;IACjD,CAAC;IAED;;;;;;;;;OASG;IACI,KAAK,CAAC,MAAM,CAClB,MAKC,EACD,OAEC;QAED,MAAM,C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,kBAAkB;SAC9B,CAAC,CAAC;IACJ,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { BaseRestClient } from \"@twin.org/api-core\";\nimport {\n\tHttpParameterHelper,\n\ttype IBaseRestClientConfig,\n\ttype ICreatedResponse,\n\ttype INoContentResponse\n} from \"@twin.org/api-models\";\nimport type {\n\tIAuditableItemStream,\n\tIAuditableItemStreamComponent,\n\tIAuditableItemStreamCreateEntryRequest,\n\tIAuditableItemStreamCreateRequest,\n\tIAuditableItemStreamDeleteEntryRequest,\n\tIAuditableItemStreamDeleteRequest,\n\tIAuditableItemStreamEntry,\n\tIAuditableItemStreamEntryList,\n\tIAuditableItemStreamEntryObjectList,\n\tIAuditableItemStreamGetEntryObjectRequest,\n\tIAuditableItemStreamGetEntryObjectResponse,\n\tIAuditableItemStreamGetEntryRequest,\n\tIAuditableItemStreamGetEntryResponse,\n\tIAuditableItemStreamGetRequest,\n\tIAuditableItemStreamGetResponse,\n\tIAuditableItemStreamList,\n\tIAuditableItemStreamListEntriesNoStreamRequest,\n\tIAuditableItemStreamListEntriesRequest,\n\tIAuditableItemStreamListEntriesResponse,\n\tIAuditableItemStreamListEntryObjectsNoStreamRequest,\n\tIAuditableItemStreamListEntryObjectsRequest,\n\tIAuditableItemStreamListEntryObjectsResponse,\n\tIAuditableItemStreamListRequest,\n\tIAuditableItemStreamListResponse,\n\tIAuditableItemStreamUpdateEntryRequest,\n\tIAuditableItemStreamUpdateRequest\n} from \"@twin.org/auditable-item-stream-models\";\nimport { Coerce, Guards, Is, NotSupportedError } from \"@twin.org/core\";\nimport type { IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\nimport type { IComparator, SortDirection } from \"@twin.org/entity\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { HeaderHelper, HeaderTypes, MimeTypes } from \"@twin.org/web\";\n\n/**\n * Client for performing auditable item stream through to REST endpoints.\n */\nexport class AuditableItemStreamRestClient\n\textends BaseRestClient\n\timplements IAuditableItemStreamComponent\n{\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<AuditableItemStreamRestClient>();\n\n\t/**\n\t * Create a new instance of AuditableItemStreamRestClient.\n\t * @param config The configuration for the client.\n\t */\n\tconstructor(config: IBaseRestClientConfig) {\n\t\tsuper(nameof<AuditableItemStreamRestClient>(), config, \"auditable-item-stream\");\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 AuditableItemStreamRestClient.CLASS_NAME;\n\t}\n\n\t/**\n\t * Create a new stream.\n\t * @param stream The stream to create.\n\t * @param stream.annotationObject The object for the stream as JSON-LD.\n\t * @param stream.entries Entries to store in the stream.\n\t * @param options Options for creating the stream.\n\t * @param options.immutableInterval After how many entries do we add immutable checks, defaults to service configured value.\n\t * A value of 0 will disable integrity checks, 1 will be every item, or any other integer for an interval.\n\t * @returns The id of the new stream item.\n\t */\n\tpublic async create(\n\t\tstream: {\n\t\t\tannotationObject?: IJsonLdNodeObject;\n\t\t\tentries?: {\n\t\t\t\tentryObject: IJsonLdNodeObject;\n\t\t\t}[];\n\t\t},\n\t\toptions?: {\n\t\t\timmutableInterval?: number;\n\t\t}\n\t): Promise<string> {\n\t\tGuards.object(AuditableItemStreamRestClient.CLASS_NAME, nameof(stream), stream);\n\t\tconst response = await this.fetch<IAuditableItemStreamCreateRequest, ICreatedResponse>(\n\t\t\t\"/\",\n\t\t\t\"POST\",\n\t\t\t{\n\t\t\t\tbody: {\n\t\t\t\t\t...stream,\n\t\t\t\t\timmutableInterval: options?.immutableInterval\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\treturn response.headers[HeaderTypes.Location];\n\t}\n\n\t/**\n\t * Get a stream header without the entries.\n\t * @param id The id of the stream to get.\n\t * @param options Additional options for the get operation.\n\t * @param options.includeEntries Whether to include the entries, defaults to false.\n\t * @param options.includeDeleted Whether to include deleted entries, defaults to false.\n\t * @param options.verifyStream Should the stream be verified, defaults to false.\n\t * @param options.verifyEntries Should the entries be verified, defaults to false.\n\t * @returns The stream and entries if found.\n\t * @throws NotFoundError if the stream is not found\n\t */\n\tpublic async get(\n\t\tid: string,\n\t\toptions?: {\n\t\t\tincludeEntries?: boolean;\n\t\t\tincludeDeleted?: boolean;\n\t\t\tverifyStream?: boolean;\n\t\t\tverifyEntries?: boolean;\n\t\t}\n\t): Promise<IAuditableItemStream> {\n\t\tGuards.stringValue(AuditableItemStreamRestClient.CLASS_NAME, nameof(id), id);\n\n\t\tconst response = await this.fetch<\n\t\t\tIAuditableItemStreamGetRequest,\n\t\t\tIAuditableItemStreamGetResponse\n\t\t>(\"/:id\", \"GET\", {\n\t\t\theaders: {\n\t\t\t\t[HeaderTypes.Accept]: MimeTypes.JsonLd\n\t\t\t},\n\t\t\tpathParams: {\n\t\t\t\tid\n\t\t\t},\n\t\t\tquery: {\n\t\t\t\tincludeEntries: Coerce.string(options?.includeEntries),\n\t\t\t\tincludeDeleted: Coerce.string(options?.includeDeleted),\n\t\t\t\tverifyStream: Coerce.string(options?.verifyStream),\n\t\t\t\tverifyEntries: Coerce.string(options?.verifyEntries)\n\t\t\t}\n\t\t});\n\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Update a stream.\n\t * @param stream The stream to update.\n\t * @param stream.id The id of the stream to update.\n\t * @param stream.annotationObject The object for the stream as JSON-LD.\n\t * @returns Nothing.\n\t */\n\tpublic async update(stream: { id: string; annotationObject?: IJsonLdNodeObject }): Promise<void> {\n\t\tGuards.object(AuditableItemStreamRestClient.CLASS_NAME, nameof(stream), stream);\n\t\tGuards.stringValue(AuditableItemStreamRestClient.CLASS_NAME, nameof(stream.id), stream.id);\n\n\t\tconst { id, annotationObject } = stream;\n\t\tawait this.fetch<IAuditableItemStreamUpdateRequest, INoContentResponse>(\"/:id\", \"PUT\", {\n\t\t\tpathParams: {\n\t\t\t\tid\n\t\t\t},\n\t\t\tbody: {\n\t\t\t\tannotationObject\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Delete the stream.\n\t * @param id The id of the stream to remove.\n\t * @returns Nothing.\n\t */\n\tpublic async remove(id: string): Promise<void> {\n\t\tGuards.stringValue(AuditableItemStreamRestClient.CLASS_NAME, nameof(id), id);\n\n\t\tawait this.fetch<IAuditableItemStreamDeleteRequest, INoContentResponse>(\"/:id\", \"DELETE\", {\n\t\t\tpathParams: {\n\t\t\t\tid\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Query all the streams, will not return entries.\n\t * @param conditions Conditions to use in the query.\n\t * @param orderBy The order for the results, defaults to created.\n\t * @param orderByDirection The direction for the order, defaults to descending.\n\t * @param properties The properties to return, if not provided defaults to id, created and object.\n\t * @param cursor The cursor to request the next chunk of entities.\n\t * @param limit Limit the number of entities to return.\n\t * @returns The entities, which can be partial if a limited keys list was provided.\n\t */\n\tpublic async query(\n\t\tconditions?: IComparator[],\n\t\torderBy?: keyof Pick<IAuditableItemStream, \"dateCreated\" | \"dateModified\">,\n\t\torderByDirection?: SortDirection,\n\t\tproperties?: (keyof IAuditableItemStream)[],\n\t\tcursor?: string,\n\t\tlimit?: number\n\t): Promise<{\n\t\tentries: IAuditableItemStreamList;\n\t\tcursor?: string;\n\t}> {\n\t\tconst response = await this.fetch<\n\t\t\tIAuditableItemStreamListRequest,\n\t\t\tIAuditableItemStreamListResponse\n\t\t>(\"/\", \"GET\", {\n\t\t\theaders: {\n\t\t\t\t[HeaderTypes.Accept]: MimeTypes.JsonLd\n\t\t\t},\n\t\t\tquery: {\n\t\t\t\tconditions: HttpParameterHelper.objectToString(conditions),\n\t\t\t\torderBy,\n\t\t\t\torderByDirection,\n\t\t\t\tproperties: HttpParameterHelper.arrayToString(properties),\n\t\t\t\tcursor,\n\t\t\t\tlimit: Coerce.string(limit)\n\t\t\t}\n\t\t});\n\n\t\treturn {\n\t\t\tentries: response.body,\n\t\t\tcursor: HeaderHelper.extractLinkHeaderRelation(response.headers?.[HeaderTypes.Link], \"next\")\n\t\t\t\t?.urlQueryParams?.cursor\n\t\t};\n\t}\n\n\t/**\n\t * Create an entry in the stream.\n\t * @param id The id of the stream to update.\n\t * @param entryObject The object for the stream as JSON-LD.\n\t * @returns The id of the created entry, if not provided.\n\t */\n\tpublic async createEntry(id: string, entryObject: IJsonLdNodeObject): Promise<string> {\n\t\tGuards.stringValue(AuditableItemStreamRestClient.CLASS_NAME, nameof(id), id);\n\n\t\tconst response = await this.fetch<IAuditableItemStreamCreateEntryRequest, ICreatedResponse>(\n\t\t\t\"/:id/entries\",\n\t\t\t\"POST\",\n\t\t\t{\n\t\t\t\tpathParams: {\n\t\t\t\t\tid\n\t\t\t\t},\n\t\t\t\tbody: {\n\t\t\t\t\tentryObject\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\treturn response.headers[HeaderTypes.Location];\n\t}\n\n\t/**\n\t * Get the entry from the stream.\n\t * @param id The id of the stream to get.\n\t * @param entryId The id of the stream entry to get.\n\t * @param options Additional options for the get operation.\n\t * @param options.verifyEntry Should the entry be verified, defaults to false.\n\t * @returns The stream and entries if found.\n\t * @throws NotFoundError if the stream is not found.\n\t */\n\tpublic async getEntry(\n\t\tid: string,\n\t\tentryId: string,\n\t\toptions?: {\n\t\t\tverifyEntry?: boolean;\n\t\t}\n\t): Promise<IAuditableItemStreamEntry> {\n\t\tGuards.stringValue(AuditableItemStreamRestClient.CLASS_NAME, nameof(id), id);\n\t\tGuards.stringValue(AuditableItemStreamRestClient.CLASS_NAME, nameof(entryId), entryId);\n\n\t\tconst response = await this.fetch<\n\t\t\tIAuditableItemStreamGetEntryRequest,\n\t\t\tIAuditableItemStreamGetEntryResponse\n\t\t>(\"/:id/entries/:entryId\", \"GET\", {\n\t\t\theaders: {\n\t\t\t\t[HeaderTypes.Accept]: MimeTypes.JsonLd\n\t\t\t},\n\t\t\tquery: {\n\t\t\t\tverifyEntry: Coerce.string(options?.verifyEntry)\n\t\t\t},\n\t\t\tpathParams: {\n\t\t\t\tid,\n\t\t\t\tentryId\n\t\t\t}\n\t\t});\n\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Get the entry object from the stream.\n\t * @param id The id of the stream to get.\n\t * @param entryId The id of the stream entry to get.\n\t * @returns The stream and entries if found.\n\t * @throws NotFoundError if the stream is not found.\n\t */\n\tpublic async getEntryObject(id: string, entryId: string): Promise<IJsonLdNodeObject> {\n\t\tGuards.stringValue(AuditableItemStreamRestClient.CLASS_NAME, nameof(id), id);\n\t\tGuards.stringValue(AuditableItemStreamRestClient.CLASS_NAME, nameof(entryId), entryId);\n\n\t\tconst response = await this.fetch<\n\t\t\tIAuditableItemStreamGetEntryObjectRequest,\n\t\t\tIAuditableItemStreamGetEntryObjectResponse\n\t\t>(\"/:id/entries/:entryId/object\", \"GET\", {\n\t\t\theaders: {\n\t\t\t\t[HeaderTypes.Accept]: MimeTypes.JsonLd\n\t\t\t},\n\t\t\tpathParams: {\n\t\t\t\tid,\n\t\t\t\tentryId\n\t\t\t}\n\t\t});\n\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Update an entry in the stream.\n\t * @param id The id of the stream to update.\n\t * @param entryId The id of the entry to update.\n\t * @param entryObject The object for the entry as JSON-LD.\n\t * @returns Nothing.\n\t */\n\tpublic async updateEntry(\n\t\tid: string,\n\t\tentryId: string,\n\t\tentryObject: IJsonLdNodeObject\n\t): Promise<void> {\n\t\tGuards.stringValue(AuditableItemStreamRestClient.CLASS_NAME, nameof(id), id);\n\t\tGuards.stringValue(AuditableItemStreamRestClient.CLASS_NAME, nameof(entryId), entryId);\n\n\t\tawait this.fetch<IAuditableItemStreamUpdateEntryRequest, INoContentResponse>(\n\t\t\t\"/:id/entries/:entryId\",\n\t\t\t\"PUT\",\n\t\t\t{\n\t\t\t\tpathParams: {\n\t\t\t\t\tid,\n\t\t\t\t\tentryId\n\t\t\t\t},\n\t\t\t\tbody: {\n\t\t\t\t\tentryObject\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Remove from the stream.\n\t * @param id The id of the stream to remove from.\n\t * @param entryId The id of the entry to remove.\n\t * @returns Nothing.\n\t */\n\tpublic async removeEntry(id: string, entryId: string): Promise<void> {\n\t\tGuards.stringValue(AuditableItemStreamRestClient.CLASS_NAME, nameof(id), id);\n\t\tGuards.stringValue(AuditableItemStreamRestClient.CLASS_NAME, nameof(entryId), entryId);\n\n\t\tawait this.fetch<IAuditableItemStreamDeleteEntryRequest, INoContentResponse>(\n\t\t\t\"/:id/entries/:entryId\",\n\t\t\t\"DELETE\",\n\t\t\t{\n\t\t\t\tpathParams: {\n\t\t\t\t\tid,\n\t\t\t\t\tentryId\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Get the entries for the stream.\n\t * @param id The id of the stream to get, if undefined returns all matching entries.\n\t * @param options Additional options for the get operation.\n\t * @param options.conditions The conditions to filter the stream.\n\t * @param options.includeDeleted Whether to include deleted entries, defaults to false.\n\t * @param options.verifyEntries Should the entries be verified, defaults to false.\n\t * @param options.limit How many entries to return.\n\t * @param options.cursor Cursor to use for next chunk of data.\n\t * @param options.order Retrieve the entries in ascending/descending time order, defaults to Ascending.\n\t * @returns The stream and entries if found.\n\t * @throws NotFoundError if the stream is not found.\n\t */\n\tpublic async getEntries(\n\t\tid?: string,\n\t\toptions?: {\n\t\t\tconditions?: IComparator[];\n\t\t\tincludeDeleted?: boolean;\n\t\t\tverifyEntries?: boolean;\n\t\t\tlimit?: number;\n\t\t\tcursor?: string;\n\t\t\torder?: SortDirection;\n\t\t}\n\t): Promise<{\n\t\tentries: IAuditableItemStreamEntryList;\n\t\tcursor?: string;\n\t}> {\n\t\tconst queryParams = {\n\t\t\tconditions: HttpParameterHelper.objectToString(options?.conditions),\n\t\t\tincludeDeleted: Coerce.string(options?.includeDeleted),\n\t\t\tverifyEntries: Coerce.string(options?.verifyEntries),\n\t\t\tlimit: Coerce.string(options?.limit),\n\t\t\tcursor: options?.cursor,\n\t\t\torder: options?.order\n\t\t};\n\n\t\tlet response;\n\t\tif (!Is.empty(id)) {\n\t\t\tGuards.stringValue(AuditableItemStreamRestClient.CLASS_NAME, nameof(id), id);\n\n\t\t\tresponse = await this.fetch<\n\t\t\t\tIAuditableItemStreamListEntriesRequest,\n\t\t\t\tIAuditableItemStreamListEntriesResponse\n\t\t\t>(\"/:id/entries\", \"GET\", {\n\t\t\t\theaders: {\n\t\t\t\t\t[HeaderTypes.Accept]: MimeTypes.JsonLd\n\t\t\t\t},\n\t\t\t\tpathParams: {\n\t\t\t\t\tid\n\t\t\t\t},\n\t\t\t\tquery: queryParams\n\t\t\t});\n\t\t} else {\n\t\t\tresponse = await this.fetch<\n\t\t\t\tIAuditableItemStreamListEntriesNoStreamRequest,\n\t\t\t\tIAuditableItemStreamListEntriesResponse\n\t\t\t>(\"/entries\", \"GET\", {\n\t\t\t\theaders: {\n\t\t\t\t\t[HeaderTypes.Accept]: MimeTypes.JsonLd\n\t\t\t\t},\n\t\t\t\tquery: queryParams\n\t\t\t});\n\t\t}\n\n\t\treturn {\n\t\t\tentries: response.body,\n\t\t\tcursor: HeaderHelper.extractLinkHeaderRelation(response.headers?.[HeaderTypes.Link], \"next\")\n\t\t\t\t?.urlQueryParams?.cursor\n\t\t};\n\t}\n\n\t/**\n\t * Get the entry objects for the stream.\n\t * @param id The id of the stream to get, if undefined returns all matching entries.\n\t * @param options Additional options for the get operation.\n\t * @param options.conditions The conditions to filter the stream.\n\t * @param options.includeDeleted Whether to include deleted entries, defaults to false.\n\t * @param options.limit How many entries to return.\n\t * @param options.cursor Cursor to use for next chunk of data.\n\t * @param options.order Retrieve the entries in ascending/descending time order, defaults to Ascending.\n\t * @returns The stream and entries if found.\n\t * @throws NotFoundError if the stream is not found.\n\t */\n\tpublic async getEntryObjects(\n\t\tid?: string,\n\t\toptions?: {\n\t\t\tconditions?: IComparator[];\n\t\t\tincludeDeleted?: boolean;\n\t\t\tlimit?: number;\n\t\t\tcursor?: string;\n\t\t\torder?: SortDirection;\n\t\t}\n\t): Promise<{\n\t\tentries: IAuditableItemStreamEntryObjectList;\n\t\tcursor?: string;\n\t}> {\n\t\tconst queryParams = {\n\t\t\tconditions: HttpParameterHelper.objectToString(options?.conditions),\n\t\t\tincludeDeleted: Coerce.string(options?.includeDeleted),\n\t\t\tlimit: Coerce.string(options?.limit),\n\t\t\tcursor: options?.cursor,\n\t\t\torder: options?.order\n\t\t};\n\n\t\tlet response;\n\t\tif (!Is.empty(id)) {\n\t\t\tGuards.stringValue(AuditableItemStreamRestClient.CLASS_NAME, nameof(id), id);\n\t\t\tresponse = await this.fetch<\n\t\t\t\tIAuditableItemStreamListEntryObjectsRequest,\n\t\t\t\tIAuditableItemStreamListEntryObjectsResponse\n\t\t\t>(\"/:id/entries/objects\", \"GET\", {\n\t\t\t\theaders: {\n\t\t\t\t\t[HeaderTypes.Accept]: MimeTypes.JsonLd\n\t\t\t\t},\n\t\t\t\tpathParams: {\n\t\t\t\t\tid\n\t\t\t\t},\n\t\t\t\tquery: queryParams\n\t\t\t});\n\t\t} else {\n\t\t\tresponse = await this.fetch<\n\t\t\t\tIAuditableItemStreamListEntryObjectsNoStreamRequest,\n\t\t\t\tIAuditableItemStreamListEntryObjectsResponse\n\t\t\t>(\"/entries/objects\", \"GET\", {\n\t\t\t\theaders: {\n\t\t\t\t\t[HeaderTypes.Accept]: MimeTypes.JsonLd\n\t\t\t\t},\n\t\t\t\tquery: queryParams\n\t\t\t});\n\t\t}\n\n\t\treturn {\n\t\t\tentries: response.body,\n\t\t\tcursor: HeaderHelper.extractLinkHeaderRelation(response.headers?.[HeaderTypes.Link], \"next\")\n\t\t\t\t?.urlQueryParams?.cursor\n\t\t};\n\t}\n\n\t/**\n\t * Remove the verifiable storage for the stream and entries, not supported on client.\n\t * @param id The id of the stream to remove the storage from.\n\t * @returns Nothing.\n\t * @throws NotFoundError if the vertex is not found.\n\t */\n\tpublic async removeVerifiable(id: string): Promise<void> {\n\t\tthrow new NotSupportedError(AuditableItemStreamRestClient.CLASS_NAME, \"notSupportedOnClient\", {\n\t\t\tmethodName: \"removeVerifiable\"\n\t\t});\n\t}\n}\n"]}
@@ -0,0 +1,4 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ export * from "./auditableItemStreamRestClient.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,oCAAoC,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./auditableItemStreamRestClient.js\";\n"]}
@@ -16,6 +16,11 @@ export declare class AuditableItemStreamRestClient extends BaseRestClient implem
16
16
  * @param config The configuration for the client.
17
17
  */
18
18
  constructor(config: IBaseRestClientConfig);
19
+ /**
20
+ * Returns the class name of the component.
21
+ * @returns The class name of the component.
22
+ */
23
+ className(): string;
19
24
  /**
20
25
  * Create a new stream.
21
26
  * @param stream The stream to create.
@@ -78,7 +83,10 @@ export declare class AuditableItemStreamRestClient extends BaseRestClient implem
78
83
  * @param limit Limit the number of entities to return.
79
84
  * @returns The entities, which can be partial if a limited keys list was provided.
80
85
  */
81
- query(conditions?: IComparator[], orderBy?: keyof Pick<IAuditableItemStream, "dateCreated" | "dateModified">, orderByDirection?: SortDirection, properties?: (keyof IAuditableItemStream)[], cursor?: string, limit?: number): Promise<IAuditableItemStreamList>;
86
+ query(conditions?: IComparator[], orderBy?: keyof Pick<IAuditableItemStream, "dateCreated" | "dateModified">, orderByDirection?: SortDirection, properties?: (keyof IAuditableItemStream)[], cursor?: string, limit?: number): Promise<{
87
+ entries: IAuditableItemStreamList;
88
+ cursor?: string;
89
+ }>;
82
90
  /**
83
91
  * Create an entry in the stream.
84
92
  * @param id The id of the stream to update.
@@ -123,7 +131,7 @@ export declare class AuditableItemStreamRestClient extends BaseRestClient implem
123
131
  removeEntry(id: string, entryId: string): Promise<void>;
124
132
  /**
125
133
  * Get the entries for the stream.
126
- * @param id The id of the stream to get.
134
+ * @param id The id of the stream to get, if undefined returns all matching entries.
127
135
  * @param options Additional options for the get operation.
128
136
  * @param options.conditions The conditions to filter the stream.
129
137
  * @param options.includeDeleted Whether to include deleted entries, defaults to false.
@@ -134,17 +142,20 @@ export declare class AuditableItemStreamRestClient extends BaseRestClient implem
134
142
  * @returns The stream and entries if found.
135
143
  * @throws NotFoundError if the stream is not found.
136
144
  */
137
- getEntries(id: string, options?: {
145
+ getEntries(id?: string, options?: {
138
146
  conditions?: IComparator[];
139
147
  includeDeleted?: boolean;
140
148
  verifyEntries?: boolean;
141
149
  limit?: number;
142
150
  cursor?: string;
143
151
  order?: SortDirection;
144
- }): Promise<IAuditableItemStreamEntryList>;
152
+ }): Promise<{
153
+ entries: IAuditableItemStreamEntryList;
154
+ cursor?: string;
155
+ }>;
145
156
  /**
146
157
  * Get the entry objects for the stream.
147
- * @param id The id of the stream to get.
158
+ * @param id The id of the stream to get, if undefined returns all matching entries.
148
159
  * @param options Additional options for the get operation.
149
160
  * @param options.conditions The conditions to filter the stream.
150
161
  * @param options.includeDeleted Whether to include deleted entries, defaults to false.
@@ -154,13 +165,16 @@ export declare class AuditableItemStreamRestClient extends BaseRestClient implem
154
165
  * @returns The stream and entries if found.
155
166
  * @throws NotFoundError if the stream is not found.
156
167
  */
157
- getEntryObjects(id: string, options?: {
168
+ getEntryObjects(id?: string, options?: {
158
169
  conditions?: IComparator[];
159
170
  includeDeleted?: boolean;
160
171
  limit?: number;
161
172
  cursor?: string;
162
173
  order?: SortDirection;
163
- }): Promise<IAuditableItemStreamEntryObjectList>;
174
+ }): Promise<{
175
+ entries: IAuditableItemStreamEntryObjectList;
176
+ cursor?: string;
177
+ }>;
164
178
  /**
165
179
  * Remove the verifiable storage for the stream and entries, not supported on client.
166
180
  * @param id The id of the stream to remove the storage from.
@@ -1 +1 @@
1
- export * from "./auditableItemStreamRestClient";
1
+ export * from "./auditableItemStreamRestClient.js";
package/docs/changelog.md CHANGED
@@ -1,5 +1,157 @@
1
1
  # @twin.org/auditable-item-stream-rest-client - Changelog
2
2
 
3
+ ## [0.0.3-next.10](https://github.com/twinfoundation/auditable-item-stream/compare/auditable-item-stream-rest-client-v0.0.3-next.9...auditable-item-stream-rest-client-v0.0.3-next.10) (2026-02-23)
4
+
5
+
6
+ ### Features
7
+
8
+ * query with no stream id ([#53](https://github.com/twinfoundation/auditable-item-stream/issues/53)) ([733fb20](https://github.com/twinfoundation/auditable-item-stream/commit/733fb209dfdb05a5f031bacd47ceab1901140286))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/auditable-item-stream-models bumped from 0.0.3-next.9 to 0.0.3-next.10
16
+
17
+ ## [0.0.3-next.9](https://github.com/twinfoundation/auditable-item-stream/compare/auditable-item-stream-rest-client-v0.0.3-next.8...auditable-item-stream-rest-client-v0.0.3-next.9) (2026-02-12)
18
+
19
+
20
+ ### Features
21
+
22
+ * add number of items ([#47](https://github.com/twinfoundation/auditable-item-stream/issues/47)) ([149fc9f](https://github.com/twinfoundation/auditable-item-stream/commit/149fc9f505a86af0578551c09f7e8aa763f01be7))
23
+
24
+
25
+ ### Dependencies
26
+
27
+ * The following workspace dependencies were updated
28
+ * dependencies
29
+ * @twin.org/auditable-item-stream-models bumped from 0.0.3-next.8 to 0.0.3-next.9
30
+
31
+ ## [0.0.3-next.8](https://github.com/twinfoundation/auditable-item-stream/compare/auditable-item-stream-rest-client-v0.0.3-next.7...auditable-item-stream-rest-client-v0.0.3-next.8) (2026-02-11)
32
+
33
+
34
+ ### Miscellaneous Chores
35
+
36
+ * **auditable-item-stream-rest-client:** Synchronize repo versions
37
+
38
+
39
+ ### Dependencies
40
+
41
+ * The following workspace dependencies were updated
42
+ * dependencies
43
+ * @twin.org/auditable-item-stream-models bumped from 0.0.3-next.7 to 0.0.3-next.8
44
+
45
+ ## [0.0.3-next.7](https://github.com/twinfoundation/auditable-item-stream/compare/auditable-item-stream-rest-client-v0.0.3-next.6...auditable-item-stream-rest-client-v0.0.3-next.7) (2026-01-26)
46
+
47
+
48
+ ### Miscellaneous Chores
49
+
50
+ * **auditable-item-stream-rest-client:** Synchronize repo versions
51
+
52
+
53
+ ### Dependencies
54
+
55
+ * The following workspace dependencies were updated
56
+ * dependencies
57
+ * @twin.org/auditable-item-stream-models bumped from 0.0.3-next.6 to 0.0.3-next.7
58
+
59
+ ## [0.0.3-next.6](https://github.com/twinfoundation/auditable-item-stream/compare/auditable-item-stream-rest-client-v0.0.3-next.5...auditable-item-stream-rest-client-v0.0.3-next.6) (2026-01-23)
60
+
61
+
62
+ ### Features
63
+
64
+ * replace nextItem property with Link header ([#37](https://github.com/twinfoundation/auditable-item-stream/issues/37)) ([83578f1](https://github.com/twinfoundation/auditable-item-stream/commit/83578f19fb964703f1b452c5d13430060e36e620))
65
+
66
+
67
+ ### Dependencies
68
+
69
+ * The following workspace dependencies were updated
70
+ * dependencies
71
+ * @twin.org/auditable-item-stream-models bumped from 0.0.3-next.5 to 0.0.3-next.6
72
+
73
+ ## [0.0.3-next.5](https://github.com/twinfoundation/auditable-item-stream/compare/auditable-item-stream-rest-client-v0.0.3-next.4...auditable-item-stream-rest-client-v0.0.3-next.5) (2026-01-22)
74
+
75
+
76
+ ### Miscellaneous Chores
77
+
78
+ * **auditable-item-stream-rest-client:** Synchronize repo versions
79
+
80
+
81
+ ### Dependencies
82
+
83
+ * The following workspace dependencies were updated
84
+ * dependencies
85
+ * @twin.org/auditable-item-stream-models bumped from 0.0.3-next.4 to 0.0.3-next.5
86
+
87
+ ## [0.0.3-next.4](https://github.com/twinfoundation/auditable-item-stream/compare/auditable-item-stream-rest-client-v0.0.3-next.3...auditable-item-stream-rest-client-v0.0.3-next.4) (2026-01-21)
88
+
89
+
90
+ ### Miscellaneous Chores
91
+
92
+ * **auditable-item-stream-rest-client:** Synchronize repo versions
93
+
94
+
95
+ ### Dependencies
96
+
97
+ * The following workspace dependencies were updated
98
+ * dependencies
99
+ * @twin.org/auditable-item-stream-models bumped from 0.0.3-next.3 to 0.0.3-next.4
100
+
101
+ ## [0.0.3-next.3](https://github.com/twinfoundation/auditable-item-stream/compare/auditable-item-stream-rest-client-v0.0.3-next.2...auditable-item-stream-rest-client-v0.0.3-next.3) (2026-01-14)
102
+
103
+
104
+ ### Miscellaneous Chores
105
+
106
+ * **auditable-item-stream-rest-client:** Synchronize repo versions
107
+
108
+
109
+ ### Dependencies
110
+
111
+ * The following workspace dependencies were updated
112
+ * dependencies
113
+ * @twin.org/auditable-item-stream-models bumped from 0.0.3-next.2 to 0.0.3-next.3
114
+
115
+ ## [0.0.3-next.2](https://github.com/twinfoundation/auditable-item-stream/compare/auditable-item-stream-rest-client-v0.0.3-next.1...auditable-item-stream-rest-client-v0.0.3-next.2) (2025-11-28)
116
+
117
+
118
+ ### Miscellaneous Chores
119
+
120
+ * **auditable-item-stream-rest-client:** Synchronize repo versions
121
+
122
+
123
+ ### Dependencies
124
+
125
+ * The following workspace dependencies were updated
126
+ * dependencies
127
+ * @twin.org/auditable-item-stream-models bumped from 0.0.3-next.1 to 0.0.3-next.2
128
+
129
+ ## [0.0.3-next.1](https://github.com/twinfoundation/auditable-item-stream/compare/auditable-item-stream-rest-client-v0.0.3-next.0...auditable-item-stream-rest-client-v0.0.3-next.1) (2025-11-12)
130
+
131
+
132
+ ### Features
133
+
134
+ * add context id features ([#28](https://github.com/twinfoundation/auditable-item-stream/issues/28)) ([10d788a](https://github.com/twinfoundation/auditable-item-stream/commit/10d788abfd73fdafe40b9218b399c4d652be2370))
135
+ * add validate-locales ([4babc73](https://github.com/twinfoundation/auditable-item-stream/commit/4babc7331f7fed61450fe2e2d8eccee52367f2be))
136
+ * eslint migration to flat config ([bd9cb2e](https://github.com/twinfoundation/auditable-item-stream/commit/bd9cb2ea2599300332c76a9c738a6ff437a5cc5b))
137
+ * export remove verifiable on client ([554749b](https://github.com/twinfoundation/auditable-item-stream/commit/554749b8369896a69de6392881171023a70f5cf1))
138
+ * update dependencies ([9ff038b](https://github.com/twinfoundation/auditable-item-stream/commit/9ff038b7e76e9fb586be4f2321231f04258ef794))
139
+ * update framework core ([5621601](https://github.com/twinfoundation/auditable-item-stream/commit/562160167c5082b9dae1b0bf68482ce2af1e7dce))
140
+ * use new nameof operators ([d1a3bf8](https://github.com/twinfoundation/auditable-item-stream/commit/d1a3bf8369f899fff8fd9d7b3b068f270fd8603d))
141
+ * use shared store mechanism ([#7](https://github.com/twinfoundation/auditable-item-stream/issues/7)) ([2aca4b8](https://github.com/twinfoundation/auditable-item-stream/commit/2aca4b85b0102f91c90619f02b116541786cf539))
142
+
143
+
144
+ ### Bug Fixes
145
+
146
+ * query params force coercion ([fcdd52c](https://github.com/twinfoundation/auditable-item-stream/commit/fcdd52cf8262a3bc19f6e7e9e6ef145890a9c8aa))
147
+
148
+
149
+ ### Dependencies
150
+
151
+ * The following workspace dependencies were updated
152
+ * dependencies
153
+ * @twin.org/auditable-item-stream-models bumped from 0.0.3-next.0 to 0.0.3-next.1
154
+
3
155
  ## [0.0.2-next.5](https://github.com/twinfoundation/auditable-item-stream/compare/auditable-item-stream-rest-client-v0.0.2-next.4...auditable-item-stream-rest-client-v0.0.2-next.5) (2025-10-09)
4
156
 
5
157
 
@@ -44,6 +44,24 @@ Runtime name for the class.
44
44
 
45
45
  ## Methods
46
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
+
59
+ #### Implementation of
60
+
61
+ `IAuditableItemStreamComponent.className`
62
+
63
+ ***
64
+
47
65
  ### create()
48
66
 
49
67
  > **create**(`stream`, `options?`): `Promise`\<`string`\>
@@ -213,7 +231,7 @@ Nothing.
213
231
 
214
232
  ### query()
215
233
 
216
- > **query**(`conditions?`, `orderBy?`, `orderByDirection?`, `properties?`, `cursor?`, `limit?`): `Promise`\<`IAuditableItemStreamList`\>
234
+ > **query**(`conditions?`, `orderBy?`, `orderByDirection?`, `properties?`, `cursor?`, `limit?`): `Promise`\<\{ `entries`: `IAuditableItemStreamList`; `cursor?`: `string`; \}\>
217
235
 
218
236
  Query all the streams, will not return entries.
219
237
 
@@ -257,7 +275,7 @@ Limit the number of entities to return.
257
275
 
258
276
  #### Returns
259
277
 
260
- `Promise`\<`IAuditableItemStreamList`\>
278
+ `Promise`\<\{ `entries`: `IAuditableItemStreamList`; `cursor?`: `string`; \}\>
261
279
 
262
280
  The entities, which can be partial if a limited keys list was provided.
263
281
 
@@ -453,17 +471,17 @@ Nothing.
453
471
 
454
472
  ### getEntries()
455
473
 
456
- > **getEntries**(`id`, `options?`): `Promise`\<`IAuditableItemStreamEntryList`\>
474
+ > **getEntries**(`id?`, `options?`): `Promise`\<\{ `entries`: `IAuditableItemStreamEntryList`; `cursor?`: `string`; \}\>
457
475
 
458
476
  Get the entries for the stream.
459
477
 
460
478
  #### Parameters
461
479
 
462
- ##### id
480
+ ##### id?
463
481
 
464
482
  `string`
465
483
 
466
- The id of the stream to get.
484
+ The id of the stream to get, if undefined returns all matching entries.
467
485
 
468
486
  ##### options?
469
487
 
@@ -507,7 +525,7 @@ Retrieve the entries in ascending/descending time order, defaults to Ascending.
507
525
 
508
526
  #### Returns
509
527
 
510
- `Promise`\<`IAuditableItemStreamEntryList`\>
528
+ `Promise`\<\{ `entries`: `IAuditableItemStreamEntryList`; `cursor?`: `string`; \}\>
511
529
 
512
530
  The stream and entries if found.
513
531
 
@@ -523,17 +541,17 @@ NotFoundError if the stream is not found.
523
541
 
524
542
  ### getEntryObjects()
525
543
 
526
- > **getEntryObjects**(`id`, `options?`): `Promise`\<`IAuditableItemStreamEntryObjectList`\>
544
+ > **getEntryObjects**(`id?`, `options?`): `Promise`\<\{ `entries`: `IAuditableItemStreamEntryObjectList`; `cursor?`: `string`; \}\>
527
545
 
528
546
  Get the entry objects for the stream.
529
547
 
530
548
  #### Parameters
531
549
 
532
- ##### id
550
+ ##### id?
533
551
 
534
552
  `string`
535
553
 
536
- The id of the stream to get.
554
+ The id of the stream to get, if undefined returns all matching entries.
537
555
 
538
556
  ##### options?
539
557
 
@@ -571,7 +589,7 @@ Retrieve the entries in ascending/descending time order, defaults to Ascending.
571
589
 
572
590
  #### Returns
573
591
 
574
- `Promise`\<`IAuditableItemStreamEntryObjectList`\>
592
+ `Promise`\<\{ `entries`: `IAuditableItemStreamEntryObjectList`; `cursor?`: `string`; \}\>
575
593
 
576
594
  The stream and entries if found.
577
595
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/auditable-item-stream-rest-client",
3
- "version": "0.0.2-next.5",
3
+ "version": "0.0.3-next.10",
4
4
  "description": "Auditable Item Stream contract implementation which can connect to REST endpoints",
5
5
  "repository": {
6
6
  "type": "git",
@@ -16,27 +16,25 @@
16
16
  "dependencies": {
17
17
  "@twin.org/api-core": "next",
18
18
  "@twin.org/api-models": "next",
19
- "@twin.org/auditable-item-stream-models": "0.0.2-next.5",
19
+ "@twin.org/auditable-item-stream-models": "0.0.3-next.10",
20
20
  "@twin.org/core": "next",
21
21
  "@twin.org/data-json-ld": "next",
22
22
  "@twin.org/entity": "next",
23
23
  "@twin.org/nameof": "next",
24
24
  "@twin.org/web": "next"
25
25
  },
26
- "main": "./dist/cjs/index.cjs",
27
- "module": "./dist/esm/index.mjs",
26
+ "main": "./dist/es/index.js",
28
27
  "types": "./dist/types/index.d.ts",
29
28
  "exports": {
30
29
  ".": {
31
30
  "types": "./dist/types/index.d.ts",
32
- "require": "./dist/cjs/index.cjs",
33
- "import": "./dist/esm/index.mjs"
31
+ "import": "./dist/es/index.js",
32
+ "default": "./dist/es/index.js"
34
33
  },
35
34
  "./locales/*.json": "./locales/*.json"
36
35
  },
37
36
  "files": [
38
- "dist/cjs",
39
- "dist/esm",
37
+ "dist/es",
40
38
  "dist/types",
41
39
  "locales",
42
40
  "docs"
@@ -1,311 +0,0 @@
1
- 'use strict';
2
-
3
- var apiCore = require('@twin.org/api-core');
4
- var apiModels = require('@twin.org/api-models');
5
- var core = require('@twin.org/core');
6
- var web = require('@twin.org/web');
7
-
8
- // Copyright 2024 IOTA Stiftung.
9
- // SPDX-License-Identifier: Apache-2.0.
10
- /**
11
- * Client for performing auditable item stream through to REST endpoints.
12
- */
13
- class AuditableItemStreamRestClient extends apiCore.BaseRestClient {
14
- /**
15
- * Runtime name for the class.
16
- */
17
- static CLASS_NAME = "AuditableItemStreamRestClient";
18
- /**
19
- * Create a new instance of AuditableItemStreamRestClient.
20
- * @param config The configuration for the client.
21
- */
22
- constructor(config) {
23
- super("AuditableItemStreamRestClient", config, "auditable-item-stream");
24
- }
25
- /**
26
- * Create a new stream.
27
- * @param stream The stream to create.
28
- * @param stream.annotationObject The object for the stream as JSON-LD.
29
- * @param stream.entries Entries to store in the stream.
30
- * @param options Options for creating the stream.
31
- * @param options.immutableInterval After how many entries do we add immutable checks, defaults to service configured value.
32
- * A value of 0 will disable integrity checks, 1 will be every item, or any other integer for an interval.
33
- * @returns The id of the new stream item.
34
- */
35
- async create(stream, options) {
36
- core.Guards.object(AuditableItemStreamRestClient.CLASS_NAME, "stream", stream);
37
- const response = await this.fetch("/", "POST", {
38
- body: {
39
- ...stream,
40
- immutableInterval: options?.immutableInterval
41
- }
42
- });
43
- return response.headers[web.HeaderTypes.Location];
44
- }
45
- /**
46
- * Get a stream header without the entries.
47
- * @param id The id of the stream to get.
48
- * @param options Additional options for the get operation.
49
- * @param options.includeEntries Whether to include the entries, defaults to false.
50
- * @param options.includeDeleted Whether to include deleted entries, defaults to false.
51
- * @param options.verifyStream Should the stream be verified, defaults to false.
52
- * @param options.verifyEntries Should the entries be verified, defaults to false.
53
- * @returns The stream and entries if found.
54
- * @throws NotFoundError if the stream is not found
55
- */
56
- async get(id, options) {
57
- core.Guards.stringValue(AuditableItemStreamRestClient.CLASS_NAME, "id", id);
58
- const response = await this.fetch("/:id", "GET", {
59
- headers: {
60
- [web.HeaderTypes.Accept]: web.MimeTypes.JsonLd
61
- },
62
- pathParams: {
63
- id
64
- },
65
- query: {
66
- includeEntries: core.Coerce.string(options?.includeEntries),
67
- includeDeleted: core.Coerce.string(options?.includeDeleted),
68
- verifyStream: core.Coerce.string(options?.verifyStream),
69
- verifyEntries: core.Coerce.string(options?.verifyEntries)
70
- }
71
- });
72
- return response.body;
73
- }
74
- /**
75
- * Update a stream.
76
- * @param stream The stream to update.
77
- * @param stream.id The id of the stream to update.
78
- * @param stream.annotationObject The object for the stream as JSON-LD.
79
- * @returns Nothing.
80
- */
81
- async update(stream) {
82
- core.Guards.object(AuditableItemStreamRestClient.CLASS_NAME, "stream", stream);
83
- core.Guards.stringValue(AuditableItemStreamRestClient.CLASS_NAME, "stream.id", stream.id);
84
- const { id, annotationObject } = stream;
85
- await this.fetch("/:id", "PUT", {
86
- pathParams: {
87
- id
88
- },
89
- body: {
90
- annotationObject
91
- }
92
- });
93
- }
94
- /**
95
- * Delete the stream.
96
- * @param id The id of the stream to remove.
97
- * @returns Nothing.
98
- */
99
- async remove(id) {
100
- core.Guards.stringValue(AuditableItemStreamRestClient.CLASS_NAME, "id", id);
101
- await this.fetch("/:id", "DELETE", {
102
- pathParams: {
103
- id
104
- }
105
- });
106
- }
107
- /**
108
- * Query all the streams, will not return entries.
109
- * @param conditions Conditions to use in the query.
110
- * @param orderBy The order for the results, defaults to created.
111
- * @param orderByDirection The direction for the order, defaults to descending.
112
- * @param properties The properties to return, if not provided defaults to id, created and object.
113
- * @param cursor The cursor to request the next chunk of entities.
114
- * @param limit Limit the number of entities to return.
115
- * @returns The entities, which can be partial if a limited keys list was provided.
116
- */
117
- async query(conditions, orderBy, orderByDirection, properties, cursor, limit) {
118
- const response = await this.fetch("/", "GET", {
119
- headers: {
120
- [web.HeaderTypes.Accept]: web.MimeTypes.JsonLd
121
- },
122
- query: {
123
- conditions: apiModels.HttpParameterHelper.objectToString(conditions),
124
- orderBy,
125
- orderByDirection,
126
- properties: apiModels.HttpParameterHelper.arrayToString(properties),
127
- cursor,
128
- limit: core.Coerce.string(limit)
129
- }
130
- });
131
- return response.body;
132
- }
133
- /**
134
- * Create an entry in the stream.
135
- * @param id The id of the stream to update.
136
- * @param entryObject The object for the stream as JSON-LD.
137
- * @returns The id of the created entry, if not provided.
138
- */
139
- async createEntry(id, entryObject) {
140
- core.Guards.stringValue(AuditableItemStreamRestClient.CLASS_NAME, "id", id);
141
- const response = await this.fetch("/:id", "POST", {
142
- pathParams: {
143
- id
144
- },
145
- body: {
146
- entryObject
147
- }
148
- });
149
- return response.headers[web.HeaderTypes.Location];
150
- }
151
- /**
152
- * Get the entry from the stream.
153
- * @param id The id of the stream to get.
154
- * @param entryId The id of the stream entry to get.
155
- * @param options Additional options for the get operation.
156
- * @param options.verifyEntry Should the entry be verified, defaults to false.
157
- * @returns The stream and entries if found.
158
- * @throws NotFoundError if the stream is not found.
159
- */
160
- async getEntry(id, entryId, options) {
161
- core.Guards.stringValue(AuditableItemStreamRestClient.CLASS_NAME, "id", id);
162
- core.Guards.stringValue(AuditableItemStreamRestClient.CLASS_NAME, "entryId", entryId);
163
- const response = await this.fetch("/:id/:entryId", "GET", {
164
- headers: {
165
- [web.HeaderTypes.Accept]: web.MimeTypes.JsonLd
166
- },
167
- query: {
168
- verifyEntry: core.Coerce.string(options?.verifyEntry)
169
- },
170
- pathParams: {
171
- id,
172
- entryId
173
- }
174
- });
175
- return response.body;
176
- }
177
- /**
178
- * Get the entry object from the stream.
179
- * @param id The id of the stream to get.
180
- * @param entryId The id of the stream entry to get.
181
- * @returns The stream and entries if found.
182
- * @throws NotFoundError if the stream is not found.
183
- */
184
- async getEntryObject(id, entryId) {
185
- core.Guards.stringValue(AuditableItemStreamRestClient.CLASS_NAME, "id", id);
186
- core.Guards.stringValue(AuditableItemStreamRestClient.CLASS_NAME, "entryId", entryId);
187
- const response = await this.fetch("/:id/:entryId/object", "GET", {
188
- headers: {
189
- [web.HeaderTypes.Accept]: web.MimeTypes.JsonLd
190
- },
191
- pathParams: {
192
- id,
193
- entryId
194
- }
195
- });
196
- return response.body;
197
- }
198
- /**
199
- * Update an entry in the stream.
200
- * @param id The id of the stream to update.
201
- * @param entryId The id of the entry to update.
202
- * @param entryObject The object for the entry as JSON-LD.
203
- * @returns Nothing.
204
- */
205
- async updateEntry(id, entryId, entryObject) {
206
- core.Guards.stringValue(AuditableItemStreamRestClient.CLASS_NAME, "id", id);
207
- core.Guards.stringValue(AuditableItemStreamRestClient.CLASS_NAME, "entryId", entryId);
208
- await this.fetch("/:id/:entryId", "PUT", {
209
- pathParams: {
210
- id,
211
- entryId
212
- },
213
- body: {
214
- entryObject
215
- }
216
- });
217
- }
218
- /**
219
- * Remove from the stream.
220
- * @param id The id of the stream to remove from.
221
- * @param entryId The id of the entry to remove.
222
- * @returns Nothing.
223
- */
224
- async removeEntry(id, entryId) {
225
- core.Guards.stringValue(AuditableItemStreamRestClient.CLASS_NAME, "id", id);
226
- core.Guards.stringValue(AuditableItemStreamRestClient.CLASS_NAME, "entryId", entryId);
227
- await this.fetch("/:id/:entryId", "DELETE", {
228
- pathParams: {
229
- id,
230
- entryId
231
- }
232
- });
233
- }
234
- /**
235
- * Get the entries for the stream.
236
- * @param id The id of the stream to get.
237
- * @param options Additional options for the get operation.
238
- * @param options.conditions The conditions to filter the stream.
239
- * @param options.includeDeleted Whether to include deleted entries, defaults to false.
240
- * @param options.verifyEntries Should the entries be verified, defaults to false.
241
- * @param options.limit How many entries to return.
242
- * @param options.cursor Cursor to use for next chunk of data.
243
- * @param options.order Retrieve the entries in ascending/descending time order, defaults to Ascending.
244
- * @returns The stream and entries if found.
245
- * @throws NotFoundError if the stream is not found.
246
- */
247
- async getEntries(id, options) {
248
- core.Guards.stringValue(AuditableItemStreamRestClient.CLASS_NAME, "id", id);
249
- const response = await this.fetch("/:id/entries", "GET", {
250
- headers: {
251
- [web.HeaderTypes.Accept]: web.MimeTypes.JsonLd
252
- },
253
- pathParams: {
254
- id
255
- },
256
- query: {
257
- conditions: apiModels.HttpParameterHelper.objectToString(options?.conditions),
258
- includeDeleted: core.Coerce.string(options?.includeDeleted),
259
- verifyEntries: core.Coerce.string(options?.verifyEntries),
260
- limit: core.Coerce.string(options?.limit),
261
- cursor: options?.cursor,
262
- order: options?.order
263
- }
264
- });
265
- return response.body;
266
- }
267
- /**
268
- * Get the entry objects for the stream.
269
- * @param id The id of the stream to get.
270
- * @param options Additional options for the get operation.
271
- * @param options.conditions The conditions to filter the stream.
272
- * @param options.includeDeleted Whether to include deleted entries, defaults to false.
273
- * @param options.limit How many entries to return.
274
- * @param options.cursor Cursor to use for next chunk of data.
275
- * @param options.order Retrieve the entries in ascending/descending time order, defaults to Ascending.
276
- * @returns The stream and entries if found.
277
- * @throws NotFoundError if the stream is not found.
278
- */
279
- async getEntryObjects(id, options) {
280
- core.Guards.stringValue(AuditableItemStreamRestClient.CLASS_NAME, "id", id);
281
- const response = await this.fetch("/:id/entries/objects", "GET", {
282
- headers: {
283
- [web.HeaderTypes.Accept]: web.MimeTypes.JsonLd
284
- },
285
- pathParams: {
286
- id
287
- },
288
- query: {
289
- conditions: apiModels.HttpParameterHelper.objectToString(options?.conditions),
290
- includeDeleted: core.Coerce.string(options?.includeDeleted),
291
- limit: core.Coerce.string(options?.limit),
292
- cursor: core.Coerce.string(options?.cursor),
293
- order: options?.order
294
- }
295
- });
296
- return response.body;
297
- }
298
- /**
299
- * Remove the verifiable storage for the stream and entries, not supported on client.
300
- * @param id The id of the stream to remove the storage from.
301
- * @returns Nothing.
302
- * @throws NotFoundError if the vertex is not found.
303
- */
304
- async removeVerifiable(id) {
305
- throw new core.NotSupportedError(AuditableItemStreamRestClient.CLASS_NAME, "notSupportedOnClient", {
306
- methodName: "removeVerifiable"
307
- });
308
- }
309
- }
310
-
311
- exports.AuditableItemStreamRestClient = AuditableItemStreamRestClient;