@twin.org/blob-storage-service 0.0.1-next.9 → 0.0.2-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,5 +1,5 @@
1
- import type { ICreatedResponse, IHttpRequestContext, INoContentResponse, IRestRoute, IRestRouteResponseOptions, ITag } from "@twin.org/api-models";
2
- import type { IBlobStorageCreateRequest, IBlobStorageGetContentRequest, IBlobStorageGetContentResponse, IBlobStorageGetRequest, IBlobStorageGetResponse, IBlobStorageRemoveRequest, IBlobStorageUpdateRequest } from "@twin.org/blob-storage-models";
1
+ import { type ICreatedResponse, type IHttpRequestContext, type INoContentResponse, type IRestRoute, type IRestRouteResponseOptions, type ITag } from "@twin.org/api-models";
2
+ import { type IBlobStorageCreateRequest, type IBlobStorageGetContentRequest, type IBlobStorageGetContentResponse, type IBlobStorageGetRequest, type IBlobStorageGetResponse, type IBlobStorageListRequest, type IBlobStorageListResponse, type IBlobStorageRemoveRequest, type IBlobStorageUpdateRequest } from "@twin.org/blob-storage-models";
3
3
  /**
4
4
  * The tag to associate with the routes.
5
5
  */
@@ -57,3 +57,11 @@ export declare function blobStorageUpdate(httpRequestContext: IHttpRequestContex
57
57
  * @returns The response object with additional http response properties.
58
58
  */
59
59
  export declare function blobStorageRemove(httpRequestContext: IHttpRequestContext, componentName: string, request: IBlobStorageRemoveRequest): Promise<INoContentResponse>;
60
+ /**
61
+ * List the entries from blob storage.
62
+ * @param httpRequestContext The request context for the API.
63
+ * @param componentName The name of the component to use in the routes.
64
+ * @param request The request.
65
+ * @returns The response object with additional http response properties.
66
+ */
67
+ export declare function blobStorageList(httpRequestContext: IHttpRequestContext, componentName: string, request: IBlobStorageListRequest): Promise<IBlobStorageListResponse>;
@@ -1,75 +1,86 @@
1
- import { type IBlobStorageComponent } from "@twin.org/blob-storage-models";
1
+ import { type BlobStorageCompressionType, type IBlobStorageComponent, type IBlobStorageEntry, type IBlobStorageEntryList } from "@twin.org/blob-storage-models";
2
2
  import { type IJsonLdNodeObject } from "@twin.org/data-json-ld";
3
- import type { IBlobStorageServiceConfig } from "./models/IBlobStorageServiceConfig";
3
+ import { SortDirection, type EntityCondition } from "@twin.org/entity";
4
+ import type { IBlobStorageServiceConstructorOptions } from "./models/IBlobStorageServiceConstructorOptions";
4
5
  /**
5
6
  * Service for performing blob storage operations to a connector.
6
7
  */
7
8
  export declare class BlobStorageService implements IBlobStorageComponent {
8
- /**
9
- * The namespace supported by the blob storage service.
10
- */
11
- static readonly NAMESPACE: string;
12
9
  /**
13
10
  * Runtime name for the class.
14
11
  */
15
12
  readonly CLASS_NAME: string;
16
13
  /**
17
14
  * Create a new instance of BlobStorageService.
18
- * @param options The dependencies for the service.
19
- * @param options.metadataEntityStorageType The type of the storage connector for the metadata, defaults to "blob-metadata".
20
- * @param options.vaultConnectorType The type of the vault connector for encryption, if undefined no encryption will be performed.
21
- * @param options.config The configuration for the service.
15
+ * @param options The options for the service.
22
16
  */
23
- constructor(options?: {
24
- metadataEntityStorageType?: string;
25
- vaultConnectorType?: string;
26
- config?: IBlobStorageServiceConfig;
27
- });
17
+ constructor(options?: IBlobStorageServiceConstructorOptions);
28
18
  /**
29
19
  * Create the blob with some metadata.
30
20
  * @param blob The data for the blob in base64 format.
31
- * @param mimeType Mime type for the blob, will be detected if left undefined.
32
- * @param extension Extension for the blob, will be detected if left undefined.
21
+ * @param encodingFormat Mime type for the blob, will be detected if left undefined.
22
+ * @param fileExtension Extension for the blob, will be detected if left undefined.
33
23
  * @param metadata Data for the custom metadata as JSON-LD.
34
- * @param namespace The namespace to use for storing, defaults to component configured namespace.
24
+ * @param options Optional options for the creation of the blob.
25
+ * @param options.disableEncryption Disables encryption if enabled by default.
26
+ * @param options.overrideVaultKeyId Use a different vault key id for encryption, if not provided the default vault key id will be used.
27
+ * @param options.compress Optional compression type to use for the blob, defaults to no compression.*
28
+ * @param options.namespace The namespace to use for storing, defaults to component configured namespace.
35
29
  * @param userIdentity The user identity to use with storage operations.
36
30
  * @param nodeIdentity The node identity to use with storage operations.
37
31
  * @returns The id of the stored blob in urn format.
38
32
  */
39
- create(blob: string, mimeType?: string, extension?: string, metadata?: IJsonLdNodeObject, namespace?: string, userIdentity?: string, nodeIdentity?: string): Promise<string>;
33
+ create(blob: string, encodingFormat?: string, fileExtension?: string, metadata?: IJsonLdNodeObject, options?: {
34
+ disableEncryption?: boolean;
35
+ overrideVaultKeyId?: string;
36
+ compress?: BlobStorageCompressionType;
37
+ namespace?: string;
38
+ }, userIdentity?: string, nodeIdentity?: string): Promise<string>;
40
39
  /**
41
- * Get the blob and metadata.
40
+ * Get the blob entry.
42
41
  * @param id The id of the blob to get in urn format.
43
- * @param includeContent Include the content, or just get the metadata.
42
+ * @param options Optional options for the retrieval of the blob.
43
+ * @param options.includeContent Include the content, or just get the metadata.
44
+ * @param options.overrideVaultKeyId Use a different vault key id for decryption, if not provided the default vault key id will be used.
45
+ * @param options.decompress If the content should be decompressed, if it was compressed when stored, defaults to true.
44
46
  * @param userIdentity The user identity to use with storage operations.
45
47
  * @param nodeIdentity The node identity to use with storage operations.
46
- * @returns The metadata and data for the blob if it can be found.
48
+ * @returns The entry and data for the blob if it can be found.
47
49
  * @throws Not found error if the blob cannot be found.
48
50
  */
49
- get(id: string, includeContent: boolean, userIdentity?: string, nodeIdentity?: string): Promise<{
50
- blob?: string;
51
- mimeType?: string;
52
- extension?: string;
53
- metadata?: IJsonLdNodeObject;
54
- }>;
51
+ get(id: string, options?: {
52
+ includeContent?: boolean;
53
+ decompress?: boolean;
54
+ overrideVaultKeyId?: string;
55
+ }, userIdentity?: string, nodeIdentity?: string): Promise<IBlobStorageEntry>;
55
56
  /**
56
57
  * Update the blob with metadata.
57
- * @param id The id of the blob metadata to update.
58
- * @param mimeType Mime type for the blob, will be detected if left undefined.
59
- * @param extension Extension for the blob, will be detected if left undefined.
58
+ * @param id The id of the blob entry to update.
59
+ * @param encodingFormat Mime type for the blob, will be detected if left undefined.
60
+ * @param fileExtension Extension for the blob, will be detected if left undefined.
60
61
  * @param metadata Data for the custom metadata as JSON-LD.
61
62
  * @param userIdentity The user identity to use with storage operations.
62
- * @param nodeIdentity The node identity to use with storage operations.
63
63
  * @returns Nothing.
64
64
  * @throws Not found error if the blob cannot be found.
65
65
  */
66
- update(id: string, mimeType?: string, extension?: string, metadata?: IJsonLdNodeObject, userIdentity?: string, nodeIdentity?: string): Promise<void>;
66
+ update(id: string, encodingFormat?: string, fileExtension?: string, metadata?: IJsonLdNodeObject, userIdentity?: string): Promise<void>;
67
67
  /**
68
68
  * Remove the blob.
69
69
  * @param id The id of the blob to remove in urn format.
70
70
  * @param userIdentity The user identity to use with storage operations.
71
- * @param nodeIdentity The node identity to use with storage operations.
72
71
  * @returns Nothing.
73
72
  */
74
- remove(id: string, userIdentity?: string, nodeIdentity?: string): Promise<void>;
73
+ remove(id: string, userIdentity?: string): Promise<void>;
74
+ /**
75
+ * Query all the blob storage entries which match the conditions.
76
+ * @param conditions The conditions to match for the entries.
77
+ * @param orderBy The order for the results, defaults to created.
78
+ * @param orderByDirection The direction for the order, defaults to descending.
79
+ * @param cursor The cursor to request the next page of entries.
80
+ * @param pageSize The suggested number of entries to return in each chunk, in some scenarios can return a different amount.
81
+ * @param userIdentity The user identity to use with storage operations.
82
+ * @returns All the entries for the storage matching the conditions,
83
+ * and a cursor which can be used to request more entities.
84
+ */
85
+ query(conditions?: EntityCondition<IBlobStorageEntry>, orderBy?: keyof Pick<IBlobStorageEntry, "dateCreated" | "dateModified">, orderByDirection?: SortDirection, cursor?: string, pageSize?: number, userIdentity?: string): Promise<IBlobStorageEntryList>;
75
86
  }
@@ -0,0 +1,51 @@
1
+ import type { BlobStorageCompressionType } from "@twin.org/blob-storage-models";
2
+ import type { IJsonLdNodeObject } from "@twin.org/data-json-ld";
3
+ /**
4
+ * Class representing entry for the blob storage.
5
+ */
6
+ export declare class BlobStorageEntry {
7
+ /**
8
+ * The id for the blob.
9
+ */
10
+ id: string;
11
+ /**
12
+ * The date/time when the entry was created.
13
+ */
14
+ dateCreated: string;
15
+ /**
16
+ * The date/time when the entry was modified.
17
+ */
18
+ dateModified?: string;
19
+ /**
20
+ * The length of the data in the blob.
21
+ */
22
+ blobSize: number;
23
+ /**
24
+ * The hash of the data in the blob.
25
+ */
26
+ blobHash: string;
27
+ /**
28
+ * The mime type for the blob.
29
+ */
30
+ encodingFormat?: string;
31
+ /**
32
+ * The extension.
33
+ */
34
+ fileExtension?: string;
35
+ /**
36
+ * The metadata for the blob as JSON-LD.
37
+ */
38
+ metadata?: IJsonLdNodeObject;
39
+ /**
40
+ * Is the entry encrypted.
41
+ */
42
+ isEncrypted: boolean;
43
+ /**
44
+ * Is the entry compressed.
45
+ */
46
+ compression?: BlobStorageCompressionType;
47
+ /**
48
+ * The user identity that created the blob.
49
+ */
50
+ userIdentity?: string;
51
+ }
@@ -1,6 +1,7 @@
1
1
  export * from "./blobStorageRoutes";
2
2
  export * from "./blobStorageService";
3
- export * from "./entities/blobMetadata";
3
+ export * from "./entities/blobStorageEntry";
4
4
  export * from "./models/IBlobStorageServiceConfig";
5
+ export * from "./models/IBlobStorageServiceConstructorOptions";
5
6
  export * from "./restEntryPoints";
6
7
  export * from "./schema";
@@ -3,8 +3,7 @@
3
3
  */
4
4
  export interface IBlobStorageServiceConfig {
5
5
  /**
6
- * The name of the vault key to use for encryption if the service has a vault connector configured.
7
- * @default blob-storage.
6
+ * The name of the vault key to use for encryption, if not configured no encryption will happen.
8
7
  */
9
8
  vaultKeyId?: string;
10
9
  /**
@@ -13,11 +12,7 @@ export interface IBlobStorageServiceConfig {
13
12
  */
14
13
  defaultNamespace?: string;
15
14
  /**
16
- * Include the node identity when performing storage operations, defaults to true.
15
+ * Include the user identity when performing storage operations, allow partitioning per user, defaults to false.
17
16
  */
18
- includeNodeIdentity?: boolean;
19
- /**
20
- * Include the user identity when performing storage operations, defaults to true.
21
- */
22
- includeUserIdentity?: boolean;
17
+ partitionPerUser?: boolean;
23
18
  }
@@ -0,0 +1,19 @@
1
+ import type { IBlobStorageServiceConfig } from "./IBlobStorageServiceConfig";
2
+ /**
3
+ * Options for the Blob Storage Service constructor.
4
+ */
5
+ export interface IBlobStorageServiceConstructorOptions {
6
+ /**
7
+ * The type of the storage connector for the metadata.
8
+ * @default blob-storage-entry
9
+ */
10
+ entryEntityStorageType?: string;
11
+ /**
12
+ * The type of the vault connector for encryption.
13
+ */
14
+ vaultConnectorType?: string;
15
+ /**
16
+ * The configuration for the service.
17
+ */
18
+ config?: IBlobStorageServiceConfig;
19
+ }
package/docs/changelog.md CHANGED
@@ -1,5 +1,194 @@
1
1
  # @twin.org/blob-storage-service - Changelog
2
2
 
3
- ## v0.0.1-next.9
3
+ ## [0.0.2-next.1](https://github.com/twinfoundation/blob-storage/compare/blob-storage-service-v0.0.2-next.0...blob-storage-service-v0.0.2-next.1) (2025-07-24)
4
+
5
+
6
+ ### Features
7
+
8
+ * add compression support ([67d239b](https://github.com/twinfoundation/blob-storage/commit/67d239bca8321bd90bf4ff93167c564130309730))
9
+ * additional encryption options on per item basis ([4b95a65](https://github.com/twinfoundation/blob-storage/commit/4b95a656d19e3b571cea905e36f29b679b13e1e8))
10
+ * remove includeNodeIdentity flag ([13bc334](https://github.com/twinfoundation/blob-storage/commit/13bc33445b179879688af3c98e8be8a5609d3f46))
11
+ * remove unused namespace ([6376433](https://github.com/twinfoundation/blob-storage/commit/637643399ffa42dbf6af07e7579e82e392ac90c9))
12
+ * update dependencies ([56f0094](https://github.com/twinfoundation/blob-storage/commit/56f0094b68d8bd22864cd899ac1b61d95540f719))
13
+ * update to support fully qualified data type names ([3297d69](https://github.com/twinfoundation/blob-storage/commit/3297d69d332058b0f0141002087f56ba230620e1))
14
+ * use shared store mechanism ([#12](https://github.com/twinfoundation/blob-storage/issues/12)) ([cae8110](https://github.com/twinfoundation/blob-storage/commit/cae8110681847a1ac4fcac968b8196694e49c320))
15
+ * use standard list json ld types ([d6bdfd6](https://github.com/twinfoundation/blob-storage/commit/d6bdfd68af47f70f3cc53658b4a12543497e1f48))
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * Adding the optional flag to the entity ([#10](https://github.com/twinfoundation/blob-storage/issues/10)) ([626677e](https://github.com/twinfoundation/blob-storage/commit/626677e5730d23535a0eb1f36f8394d941ff2447))
21
+ * query params force coercion ([a5e547a](https://github.com/twinfoundation/blob-storage/commit/a5e547a775f8997cb04780938c7a9561ddb048d1))
22
+
23
+
24
+ ### Dependencies
25
+
26
+ * The following workspace dependencies were updated
27
+ * dependencies
28
+ * @twin.org/blob-storage-models bumped from 0.0.2-next.0 to 0.0.2-next.1
29
+ * devDependencies
30
+ * @twin.org/blob-storage-connector-memory bumped from 0.0.2-next.0 to 0.0.2-next.1
31
+
32
+ ## 0.0.1 (2025-07-04)
33
+
34
+
35
+ ### Features
36
+
37
+ * release to production ([eacfe75](https://github.com/twinfoundation/blob-storage/commit/eacfe754a0dcd9243d9e13d86422327d0a605164))
38
+
39
+
40
+ ### Dependencies
41
+
42
+ * The following workspace dependencies were updated
43
+ * dependencies
44
+ * @twin.org/blob-storage-models bumped from ^0.0.0 to ^0.0.1
45
+ * devDependencies
46
+ * @twin.org/blob-storage-connector-memory bumped from ^0.0.0 to ^0.0.1
47
+
48
+ ## [0.0.1-next.37](https://github.com/twinfoundation/blob-storage/compare/blob-storage-service-v0.0.1-next.36...blob-storage-service-v0.0.1-next.37) (2025-06-20)
49
+
50
+
51
+ ### Bug Fixes
52
+
53
+ * query params force coercion ([a5e547a](https://github.com/twinfoundation/blob-storage/commit/a5e547a775f8997cb04780938c7a9561ddb048d1))
54
+
55
+
56
+ ### Dependencies
57
+
58
+ * The following workspace dependencies were updated
59
+ * dependencies
60
+ * @twin.org/blob-storage-models bumped from 0.0.1-next.36 to 0.0.1-next.37
61
+ * devDependencies
62
+ * @twin.org/blob-storage-connector-memory bumped from 0.0.1-next.36 to 0.0.1-next.37
63
+
64
+ ## [0.0.1-next.36](https://github.com/twinfoundation/blob-storage/compare/blob-storage-service-v0.0.1-next.35...blob-storage-service-v0.0.1-next.36) (2025-06-19)
65
+
66
+
67
+ ### Features
68
+
69
+ * add compression support ([67d239b](https://github.com/twinfoundation/blob-storage/commit/67d239bca8321bd90bf4ff93167c564130309730))
70
+
71
+
72
+ ### Dependencies
73
+
74
+ * The following workspace dependencies were updated
75
+ * dependencies
76
+ * @twin.org/blob-storage-models bumped from 0.0.1-next.35 to 0.0.1-next.36
77
+ * devDependencies
78
+ * @twin.org/blob-storage-connector-memory bumped from 0.0.1-next.35 to 0.0.1-next.36
79
+
80
+ ## [0.0.1-next.35](https://github.com/twinfoundation/blob-storage/compare/blob-storage-service-v0.0.1-next.34...blob-storage-service-v0.0.1-next.35) (2025-06-17)
81
+
82
+
83
+ ### Features
84
+
85
+ * additional encryption options on per item basis ([4b95a65](https://github.com/twinfoundation/blob-storage/commit/4b95a656d19e3b571cea905e36f29b679b13e1e8))
86
+
87
+
88
+ ### Dependencies
89
+
90
+ * The following workspace dependencies were updated
91
+ * dependencies
92
+ * @twin.org/blob-storage-models bumped from 0.0.1-next.34 to 0.0.1-next.35
93
+ * devDependencies
94
+ * @twin.org/blob-storage-connector-memory bumped from 0.0.1-next.34 to 0.0.1-next.35
95
+
96
+ ## [0.0.1-next.34](https://github.com/twinfoundation/blob-storage/compare/blob-storage-service-v0.0.1-next.33...blob-storage-service-v0.0.1-next.34) (2025-06-12)
97
+
98
+
99
+ ### Features
100
+
101
+ * update dependencies ([56f0094](https://github.com/twinfoundation/blob-storage/commit/56f0094b68d8bd22864cd899ac1b61d95540f719))
102
+
103
+
104
+ ### Dependencies
105
+
106
+ * The following workspace dependencies were updated
107
+ * dependencies
108
+ * @twin.org/blob-storage-models bumped from 0.0.1-next.33 to 0.0.1-next.34
109
+ * devDependencies
110
+ * @twin.org/blob-storage-connector-memory bumped from 0.0.1-next.33 to 0.0.1-next.34
111
+
112
+ ## [0.0.1-next.33](https://github.com/twinfoundation/blob-storage/compare/blob-storage-service-v0.0.1-next.32...blob-storage-service-v0.0.1-next.33) (2025-06-03)
113
+
114
+
115
+ ### Miscellaneous Chores
116
+
117
+ * **blob-storage-service:** Synchronize repo versions
118
+
119
+
120
+ ### Dependencies
121
+
122
+ * The following workspace dependencies were updated
123
+ * dependencies
124
+ * @twin.org/blob-storage-models bumped from 0.0.1-next.32 to 0.0.1-next.33
125
+ * devDependencies
126
+ * @twin.org/blob-storage-connector-memory bumped from 0.0.1-next.32 to 0.0.1-next.33
127
+
128
+ ## [0.0.1-next.32](https://github.com/twinfoundation/blob-storage/compare/blob-storage-service-v0.0.1-next.31...blob-storage-service-v0.0.1-next.32) (2025-05-28)
129
+
130
+
131
+ ### Features
132
+
133
+ * update to support fully qualified data type names ([3297d69](https://github.com/twinfoundation/blob-storage/commit/3297d69d332058b0f0141002087f56ba230620e1))
134
+
135
+
136
+ ### Dependencies
137
+
138
+ * The following workspace dependencies were updated
139
+ * dependencies
140
+ * @twin.org/blob-storage-models bumped from 0.0.1-next.31 to 0.0.1-next.32
141
+ * devDependencies
142
+ * @twin.org/blob-storage-connector-memory bumped from 0.0.1-next.31 to 0.0.1-next.32
143
+
144
+ ## [0.0.1-next.31](https://github.com/twinfoundation/blob-storage/compare/blob-storage-service-v0.0.1-next.30...blob-storage-service-v0.0.1-next.31) (2025-05-08)
145
+
146
+
147
+ ### Features
148
+
149
+ * use standard list json ld types ([d6bdfd6](https://github.com/twinfoundation/blob-storage/commit/d6bdfd68af47f70f3cc53658b4a12543497e1f48))
150
+
151
+
152
+ ### Dependencies
153
+
154
+ * The following workspace dependencies were updated
155
+ * dependencies
156
+ * @twin.org/blob-storage-models bumped from 0.0.1-next.30 to 0.0.1-next.31
157
+ * devDependencies
158
+ * @twin.org/blob-storage-connector-memory bumped from 0.0.1-next.30 to 0.0.1-next.31
159
+
160
+ ## [0.0.1-next.30](https://github.com/twinfoundation/blob-storage/compare/blob-storage-service-v0.0.1-next.29...blob-storage-service-v0.0.1-next.30) (2025-04-17)
161
+
162
+
163
+ ### Features
164
+
165
+ * use shared store mechanism ([#12](https://github.com/twinfoundation/blob-storage/issues/12)) ([cae8110](https://github.com/twinfoundation/blob-storage/commit/cae8110681847a1ac4fcac968b8196694e49c320))
166
+
167
+
168
+ ### Dependencies
169
+
170
+ * The following workspace dependencies were updated
171
+ * dependencies
172
+ * @twin.org/blob-storage-models bumped from 0.0.1-next.29 to 0.0.1-next.30
173
+ * devDependencies
174
+ * @twin.org/blob-storage-connector-memory bumped from 0.0.1-next.29 to 0.0.1-next.30
175
+
176
+ ## [0.0.1-next.29](https://github.com/twinfoundation/blob-storage/compare/blob-storage-service-v0.0.1-next.28...blob-storage-service-v0.0.1-next.29) (2025-03-28)
177
+
178
+
179
+ ### Bug Fixes
180
+
181
+ * Adding the optional flag to the entity ([#10](https://github.com/twinfoundation/blob-storage/issues/10)) ([626677e](https://github.com/twinfoundation/blob-storage/commit/626677e5730d23535a0eb1f36f8394d941ff2447))
182
+
183
+
184
+ ### Dependencies
185
+
186
+ * The following workspace dependencies were updated
187
+ * dependencies
188
+ * @twin.org/blob-storage-models bumped from 0.0.1-next.28 to 0.0.1-next.29
189
+ * devDependencies
190
+ * @twin.org/blob-storage-connector-memory bumped from 0.0.1-next.28 to 0.0.1-next.29
191
+
192
+ ## v0.0.1-next.28
4
193
 
5
194
  - Initial Release