@twin.org/auditable-item-stream-service 0.0.3-next.9 → 0.9.0

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.
Files changed (39) hide show
  1. package/README.md +2 -2
  2. package/dist/es/auditableItemStreamRoutes.js +401 -73
  3. package/dist/es/auditableItemStreamRoutes.js.map +1 -1
  4. package/dist/es/auditableItemStreamService.js +304 -113
  5. package/dist/es/auditableItemStreamService.js.map +1 -1
  6. package/dist/es/entities/auditableItemStream.js +17 -3
  7. package/dist/es/entities/auditableItemStream.js.map +1 -1
  8. package/dist/es/models/IAuditableItemStreamServiceConfig.js.map +1 -1
  9. package/dist/es/models/IAuditableItemStreamServiceConstructorOptions.js.map +1 -1
  10. package/dist/es/models/IAuditableItemStreamServiceContext.js.map +1 -1
  11. package/dist/es/restEntryPoints.js +3 -0
  12. package/dist/es/restEntryPoints.js.map +1 -1
  13. package/dist/types/auditableItemStreamRoutes.d.ts +37 -5
  14. package/dist/types/auditableItemStreamService.d.ts +37 -38
  15. package/dist/types/entities/auditableItemStream.d.ts +10 -1
  16. package/dist/types/models/IAuditableItemStreamServiceConfig.d.ts +4 -0
  17. package/dist/types/models/IAuditableItemStreamServiceConstructorOptions.d.ts +4 -0
  18. package/dist/types/models/IAuditableItemStreamServiceContext.d.ts +4 -0
  19. package/dist/types/restEntryPoints.d.ts +3 -0
  20. package/docs/changelog.md +396 -92
  21. package/docs/examples.md +211 -1
  22. package/docs/open-api/spec.json +832 -169
  23. package/docs/reference/classes/AuditableItemStream.md +30 -14
  24. package/docs/reference/classes/AuditableItemStreamEntry.md +13 -13
  25. package/docs/reference/classes/AuditableItemStreamService.md +109 -84
  26. package/docs/reference/functions/auditableItemStreamClose.md +31 -0
  27. package/docs/reference/functions/auditableItemStreamDeleteEntry.md +1 -1
  28. package/docs/reference/functions/auditableItemStreamList.md +1 -1
  29. package/docs/reference/functions/auditableItemStreamListEntries.md +1 -1
  30. package/docs/reference/functions/auditableItemStreamListEntriesNoStream.md +31 -0
  31. package/docs/reference/functions/auditableItemStreamListEntryObjects.md +1 -1
  32. package/docs/reference/functions/auditableItemStreamListEntryObjectsNoStream.md +31 -0
  33. package/docs/reference/functions/auditableItemStreamRemoveProof.md +31 -0
  34. package/docs/reference/index.md +4 -0
  35. package/docs/reference/interfaces/IAuditableItemStreamServiceConfig.md +10 -2
  36. package/docs/reference/interfaces/IAuditableItemStreamServiceConstructorOptions.md +18 -10
  37. package/docs/reference/variables/restEntryPoints.md +2 -0
  38. package/locales/en.json +6 -1
  39. package/package.json +19 -18
@@ -1,5 +1,5 @@
1
1
  import { type ICreatedResponse, type IHttpRequestContext, type INoContentResponse, type IRestRoute, type ITag } from "@twin.org/api-models";
2
- import { type IAuditableItemStreamCreateEntryRequest, type IAuditableItemStreamCreateRequest, type IAuditableItemStreamDeleteEntryRequest, type IAuditableItemStreamDeleteRequest, type IAuditableItemStreamGetEntryObjectRequest, type IAuditableItemStreamGetEntryObjectResponse, type IAuditableItemStreamGetEntryRequest, type IAuditableItemStreamGetEntryResponse, type IAuditableItemStreamGetRequest, type IAuditableItemStreamGetResponse, type IAuditableItemStreamListEntriesRequest, type IAuditableItemStreamListEntriesResponse, type IAuditableItemStreamListEntryObjectsRequest, type IAuditableItemStreamListEntryObjectsResponse, type IAuditableItemStreamListRequest, type IAuditableItemStreamListResponse, type IAuditableItemStreamUpdateEntryRequest, type IAuditableItemStreamUpdateRequest } from "@twin.org/auditable-item-stream-models";
2
+ import { type IAuditableItemStreamListEntriesNoStreamRequest, type IAuditableItemStreamListEntryObjectsNoStreamRequest, type IAuditableItemStreamCloseRequest, type IAuditableItemStreamCreateEntryRequest, type IAuditableItemStreamCreateRequest, type IAuditableItemStreamDeleteEntryRequest, type IAuditableItemStreamDeleteRequest, type IAuditableItemStreamGetEntryObjectRequest, type IAuditableItemStreamGetEntryObjectResponse, type IAuditableItemStreamGetEntryRequest, type IAuditableItemStreamGetEntryResponse, type IAuditableItemStreamGetRequest, type IAuditableItemStreamGetResponse, type IAuditableItemStreamListEntriesRequest, type IAuditableItemStreamListEntriesResponse, type IAuditableItemStreamListEntryObjectsRequest, type IAuditableItemStreamListEntryObjectsResponse, type IAuditableItemStreamListRequest, type IAuditableItemStreamListResponse, type IAuditableItemStreamRemoveProofRequest, type IAuditableItemStreamUpdateEntryRequest, type IAuditableItemStreamUpdateRequest } from "@twin.org/auditable-item-stream-models";
3
3
  /**
4
4
  * The tag to associate with the routes.
5
5
  */
@@ -44,7 +44,15 @@ export declare function auditableItemStreamUpdate(httpRequestContext: IHttpReque
44
44
  */
45
45
  export declare function auditableItemStreamDelete(httpRequestContext: IHttpRequestContext, componentName: string, request: IAuditableItemStreamDeleteRequest): Promise<INoContentResponse>;
46
46
  /**
47
- * Query the stream.
47
+ * Close the stream.
48
+ * @param httpRequestContext The request context for the API.
49
+ * @param componentName The name of the component to use in the routes.
50
+ * @param request The request.
51
+ * @returns The response object with additional http response properties.
52
+ */
53
+ export declare function auditableItemStreamClose(httpRequestContext: IHttpRequestContext, componentName: string, request: IAuditableItemStreamCloseRequest): Promise<INoContentResponse>;
54
+ /**
55
+ * List all streams.
48
56
  * @param httpRequestContext The request context for the API.
49
57
  * @param componentName The name of the component to use in the routes.
50
58
  * @param request The request.
@@ -60,7 +68,7 @@ export declare function auditableItemStreamList(httpRequestContext: IHttpRequest
60
68
  */
61
69
  export declare function auditableItemStreamCreateEntry(httpRequestContext: IHttpRequestContext, componentName: string, request: IAuditableItemStreamCreateEntryRequest): Promise<ICreatedResponse>;
62
70
  /**
63
- * Get the stream.
71
+ * Delete an entry from the stream.
64
72
  * @param httpRequestContext The request context for the API.
65
73
  * @param componentName The name of the component to use in the routes.
66
74
  * @param request The request.
@@ -92,7 +100,7 @@ export declare function auditableItemStreamGetEntry(httpRequestContext: IHttpReq
92
100
  */
93
101
  export declare function auditableItemStreamGetEntryObject(httpRequestContext: IHttpRequestContext, componentName: string, request: IAuditableItemStreamGetEntryObjectRequest): Promise<IAuditableItemStreamGetEntryObjectResponse>;
94
102
  /**
95
- * Query the stream.
103
+ * List the entries for a stream.
96
104
  * @param httpRequestContext The request context for the API.
97
105
  * @param componentName The name of the component to use in the routes.
98
106
  * @param request The request.
@@ -100,10 +108,34 @@ export declare function auditableItemStreamGetEntryObject(httpRequestContext: IH
100
108
  */
101
109
  export declare function auditableItemStreamListEntries(httpRequestContext: IHttpRequestContext, componentName: string, request: IAuditableItemStreamListEntriesRequest): Promise<IAuditableItemStreamListEntriesResponse>;
102
110
  /**
103
- * Query the stream objects.
111
+ * List entries across all streams.
112
+ * @param httpRequestContext The request context for the API.
113
+ * @param componentName The name of the component to use in the routes.
114
+ * @param request The request.
115
+ * @returns The response object with additional http response properties.
116
+ */
117
+ export declare function auditableItemStreamListEntriesNoStream(httpRequestContext: IHttpRequestContext, componentName: string, request: IAuditableItemStreamListEntriesNoStreamRequest): Promise<IAuditableItemStreamListEntriesResponse>;
118
+ /**
119
+ * List the entry objects for a stream.
104
120
  * @param httpRequestContext The request context for the API.
105
121
  * @param componentName The name of the component to use in the routes.
106
122
  * @param request The request.
107
123
  * @returns The response object with additional http response properties.
108
124
  */
109
125
  export declare function auditableItemStreamListEntryObjects(httpRequestContext: IHttpRequestContext, componentName: string, request: IAuditableItemStreamListEntryObjectsRequest): Promise<IAuditableItemStreamListEntryObjectsResponse>;
126
+ /**
127
+ * List entry objects across all streams.
128
+ * @param httpRequestContext The request context for the API.
129
+ * @param componentName The name of the component to use in the routes.
130
+ * @param request The request.
131
+ * @returns The response object with additional http response properties.
132
+ */
133
+ export declare function auditableItemStreamListEntryObjectsNoStream(httpRequestContext: IHttpRequestContext, componentName: string, request: IAuditableItemStreamListEntryObjectsNoStreamRequest): Promise<IAuditableItemStreamListEntryObjectsResponse>;
134
+ /**
135
+ * Remove the proof from a stream.
136
+ * @param httpRequestContext The request context for the API.
137
+ * @param componentName The name of the component to use in the routes.
138
+ * @param request The request.
139
+ * @returns The response object with additional http response properties.
140
+ */
141
+ export declare function auditableItemStreamRemoveProof(httpRequestContext: IHttpRequestContext, componentName: string, request: IAuditableItemStreamRemoveProofRequest): Promise<INoContentResponse>;
@@ -1,4 +1,4 @@
1
- import { type IAuditableItemStream, type IAuditableItemStreamComponent, type IAuditableItemStreamEntry, type IAuditableItemStreamEntryList, type IAuditableItemStreamEntryObjectList, type IAuditableItemStreamList } from "@twin.org/auditable-item-stream-models";
1
+ import { type IAuditableItemStream, type IAuditableItemStreamBase, type IAuditableItemStreamComponent, type IAuditableItemStreamEntry, type IAuditableItemStreamEntryList, type IAuditableItemStreamEntryObjectList, type IAuditableItemStreamList } from "@twin.org/auditable-item-stream-models";
2
2
  import { type IJsonLdNodeObject } from "@twin.org/data-json-ld";
3
3
  import { SortDirection, type IComparator } from "@twin.org/entity";
4
4
  import type { IAuditableItemStreamServiceConstructorOptions } from "./models/IAuditableItemStreamServiceConstructorOptions.js";
@@ -20,27 +20,34 @@ export declare class AuditableItemStreamService implements IAuditableItemStreamC
20
20
  * @returns The class name of the component.
21
21
  */
22
22
  className(): string;
23
+ /**
24
+ * Register all AIS metrics with the telemetry component.
25
+ * @returns A promise that resolves when the metrics have been registered.
26
+ */
27
+ start(): Promise<void>;
23
28
  /**
24
29
  * Create a new stream.
25
30
  * @param stream The stream to create.
26
- * @param stream.annotationObject The object for the stream as JSON-LD.
27
- * @param stream.entries Entries to store in the stream.
28
- * @param options Options for creating the stream.
29
- * @param options.immutableInterval After how many entries do we add immutable checks, defaults to service configured value.
30
- * A value of 0 will disable integrity checks, 1 will be every item, or any other integer for an interval.
31
31
  * @returns The id of the new stream item.
32
32
  */
33
- create(stream: {
34
- annotationObject?: IJsonLdNodeObject;
35
- entries?: {
36
- entryObject: IJsonLdNodeObject;
37
- }[];
38
- }, options?: {
39
- immutableInterval?: number;
40
- }): Promise<string>;
33
+ create(stream: IAuditableItemStreamBase): Promise<string>;
34
+ /**
35
+ * Close a stream.
36
+ * @param id The id of the stream to close.
37
+ * @returns A promise that resolves when the stream has been closed.
38
+ */
39
+ close(id: string): Promise<void>;
40
+ /**
41
+ * Update a stream.
42
+ * @param stream The stream to update, does not update entries.
43
+ * @returns A promise that resolves when the stream has been updated.
44
+ */
45
+ update(stream: Pick<IAuditableItemStream, "@context" | "type" | "id" | "annotationObject">): Promise<void>;
41
46
  /**
42
47
  * Get a stream header without the entries.
43
48
  * @param id The id of the stream to get.
49
+ * @param cursor Cursor to use for next chunk of entries.
50
+ * @param limit Limit the number of entries to return, only applicable if includeEntries is true.
44
51
  * @param options Additional options for the get operation.
45
52
  * @param options.includeEntries Whether to include the entries, defaults to false.
46
53
  * @param options.includeDeleted Whether to include deleted entries, defaults to false.
@@ -49,27 +56,19 @@ export declare class AuditableItemStreamService implements IAuditableItemStreamC
49
56
  * @returns The stream and entries if found.
50
57
  * @throws NotFoundError if the stream is not found
51
58
  */
52
- get(id: string, options?: {
59
+ get(id: string, cursor?: string, limit?: number, options?: {
53
60
  includeEntries?: boolean;
54
61
  includeDeleted?: boolean;
55
62
  verifyStream?: boolean;
56
63
  verifyEntries?: boolean;
57
- }): Promise<IAuditableItemStream>;
58
- /**
59
- * Update a stream.
60
- * @param stream The stream to update.
61
- * @param stream.id The id of the stream to update.
62
- * @param stream.annotationObject The object for the stream as JSON-LD.
63
- * @returns Nothing.
64
- */
65
- update(stream: {
66
- id: string;
67
- annotationObject?: IJsonLdNodeObject;
68
- }): Promise<void>;
64
+ }): Promise<{
65
+ stream: IAuditableItemStream;
66
+ cursor?: string;
67
+ }>;
69
68
  /**
70
69
  * Delete the stream.
71
70
  * @param id The id of the stream to remove.
72
- * @returns Nothing.
71
+ * @returns A promise that resolves when the stream has been removed.
73
72
  */
74
73
  remove(id: string): Promise<void>;
75
74
  /**
@@ -118,19 +117,19 @@ export declare class AuditableItemStreamService implements IAuditableItemStreamC
118
117
  * @param streamId The id of the stream to update.
119
118
  * @param entryId The id of the entry to update.
120
119
  * @param entryObject The object for the entry as JSON-LD.
121
- * @returns Nothing.
120
+ * @returns A promise that resolves when the entry has been updated.
122
121
  */
123
122
  updateEntry(streamId: string, entryId: string, entryObject: IJsonLdNodeObject): Promise<void>;
124
123
  /**
125
124
  * Delete from the stream.
126
125
  * @param streamId The id of the stream to remove from.
127
126
  * @param entryId The id of the entry to remove.
128
- * @returns Nothing.
127
+ * @returns A promise that resolves when the entry has been removed.
129
128
  */
130
129
  removeEntry(streamId: string, entryId: string): Promise<void>;
131
130
  /**
132
131
  * Get the entries for the stream.
133
- * @param streamId The id of the stream to get.
132
+ * @param streamId The id of the stream to get, if undefined returns all matching entries.
134
133
  * @param options Additional options for the get operation.
135
134
  * @param options.conditions The conditions to filter the stream.
136
135
  * @param options.includeDeleted Whether to include deleted entries, defaults to false.
@@ -141,7 +140,7 @@ export declare class AuditableItemStreamService implements IAuditableItemStreamC
141
140
  * @returns The stream and entries if found.
142
141
  * @throws NotFoundError if the stream is not found.
143
142
  */
144
- getEntries(streamId: string, options?: {
143
+ getEntries(streamId?: string, options?: {
145
144
  conditions?: IComparator[];
146
145
  includeDeleted?: boolean;
147
146
  verifyEntries?: boolean;
@@ -154,7 +153,7 @@ export declare class AuditableItemStreamService implements IAuditableItemStreamC
154
153
  }>;
155
154
  /**
156
155
  * Get the entry objects for the stream.
157
- * @param streamId The id of the stream to get.
156
+ * @param streamId The id of the stream to get, if undefined returns all matching entries.
158
157
  * @param options Additional options for the get operation.
159
158
  * @param options.conditions The conditions to filter the stream.
160
159
  * @param options.includeDeleted Whether to include deleted entries, defaults to false.
@@ -164,7 +163,7 @@ export declare class AuditableItemStreamService implements IAuditableItemStreamC
164
163
  * @returns The stream and entries if found.
165
164
  * @throws NotFoundError if the stream is not found.
166
165
  */
167
- getEntryObjects(streamId: string, options?: {
166
+ getEntryObjects(streamId?: string, options?: {
168
167
  conditions?: IComparator[];
169
168
  includeDeleted?: boolean;
170
169
  limit?: number;
@@ -175,10 +174,10 @@ export declare class AuditableItemStreamService implements IAuditableItemStreamC
175
174
  cursor?: string;
176
175
  }>;
177
176
  /**
178
- * Remove the verifiable storage for the stream and entries.
179
- * @param streamId The id of the stream to remove the storage from.
180
- * @returns Nothing.
177
+ * Remove the proof for the stream and entries.
178
+ * @param streamId The id of the stream to remove the proof from.
179
+ * @returns A promise that resolves when the proof has been removed.
181
180
  * @throws NotFoundError if the vertex is not found.
182
181
  */
183
- removeVerifiable(streamId: string): Promise<void>;
182
+ removeProof(streamId: string): Promise<void>;
184
183
  }
@@ -1,3 +1,4 @@
1
+ import type { AuditableItemStreamModes } from "@twin.org/auditable-item-stream-models";
1
2
  import { type IJsonLdNodeObject } from "@twin.org/data-json-ld";
2
3
  /**
3
4
  * Class describing the auditable item stream.
@@ -18,7 +19,7 @@ export declare class AuditableItemStream {
18
19
  /**
19
20
  * The identity of the organization which controls the stream.
20
21
  */
21
- organizationIdentity?: string;
22
+ organizationIdentity: string;
22
23
  /**
23
24
  * The identity of the user which created the stream.
24
25
  */
@@ -35,6 +36,14 @@ export declare class AuditableItemStream {
35
36
  * After how many entries do we add immutable checks.
36
37
  */
37
38
  immutableInterval: number;
39
+ /**
40
+ * Is the stream closed for entry updates.
41
+ */
42
+ closed?: boolean;
43
+ /**
44
+ * The operation mode for the stream.
45
+ */
46
+ mode?: AuditableItemStreamModes;
38
47
  /**
39
48
  * The immutable proof id.
40
49
  */
@@ -9,4 +9,8 @@ export interface IAuditableItemStreamServiceConfig {
9
9
  * @default 10
10
10
  */
11
11
  defaultImmutableInterval?: number;
12
+ /**
13
+ * The timeout in milliseconds to wait when acquiring a mutex lock, defaults to the Mutex default of 5000ms.
14
+ */
15
+ mutexTimeoutMs?: number;
12
16
  }
@@ -22,6 +22,10 @@ export interface IAuditableItemStreamServiceConstructorOptions {
22
22
  * The event bus component type, defaults to no event bus.
23
23
  */
24
24
  eventBusComponentType?: string;
25
+ /**
26
+ * The component type for the optional telemetry component used for event metrics.
27
+ */
28
+ telemetryComponentType?: string;
25
29
  /**
26
30
  * The configuration for the connector.
27
31
  */
@@ -19,4 +19,8 @@ export interface IAuditableItemStreamServiceContext {
19
19
  * The immutable check interval.
20
20
  */
21
21
  immutableInterval: number;
22
+ /**
23
+ * The identity of the organization which controls the stream.
24
+ */
25
+ organizationIdentity: string;
22
26
  }
@@ -1,2 +1,5 @@
1
1
  import type { IRestRouteEntryPoint } from "@twin.org/api-models";
2
+ /**
3
+ * The REST route entry points for the auditable item stream service.
4
+ */
2
5
  export declare const restEntryPoints: IRestRouteEntryPoint[];