@twin.org/blob-storage-service 0.0.1-next.3 → 0.0.1-next.30
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.
- package/dist/cjs/index.cjs +563 -101
- package/dist/esm/index.mjs +565 -104
- package/dist/types/blobStorageRoutes.d.ts +17 -3
- package/dist/types/blobStorageService.d.ts +37 -29
- package/dist/types/entities/blobStorageEntry.d.ts +46 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/models/IBlobStorageServiceConfig.d.ts +8 -0
- package/dist/types/models/IBlobStorageServiceConstructorOptions.d.ts +19 -0
- package/dist/types/restEntryPoints.d.ts +5 -0
- package/docs/changelog.md +33 -1
- package/docs/open-api/spec.json +2241 -1906
- package/docs/reference/classes/BlobStorageEntry.md +93 -0
- package/docs/reference/classes/BlobStorageService.md +154 -53
- package/docs/reference/functions/blobStorageCreate.md +9 -3
- package/docs/reference/functions/blobStorageGet.md +9 -3
- package/docs/reference/functions/blobStorageGetContent.md +9 -3
- package/docs/reference/functions/blobStorageList.md +31 -0
- package/docs/reference/functions/blobStorageRemove.md +9 -3
- package/docs/reference/functions/blobStorageUpdate.md +9 -3
- package/docs/reference/functions/generateRestRoutesBlobStorage.md +24 -4
- package/docs/reference/index.md +3 -1
- package/docs/reference/interfaces/IBlobStorageServiceConfig.md +16 -0
- package/docs/reference/interfaces/IBlobStorageServiceConstructorOptions.md +33 -0
- package/docs/reference/variables/restEntryPoints.md +4 -0
- package/package.json +7 -33
- package/dist/types/entities/blobMetadata.d.ts +0 -22
- package/docs/reference/classes/BlobMetadata.md +0 -45
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type
|
|
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
|
*/
|
|
@@ -8,9 +8,15 @@ export declare const tagsBlobStorage: ITag[];
|
|
|
8
8
|
* The REST routes for blob storage.
|
|
9
9
|
* @param baseRouteName Prefix to prepend to the paths.
|
|
10
10
|
* @param componentName The name of the component to use in the routes stored in the ComponentFactory.
|
|
11
|
+
* @param options Additional options for the routes.
|
|
12
|
+
* @param options.typeName Optional type name to use in the routes, defaults to Blob Storage.
|
|
13
|
+
* @param options.tagName Optional name to use in OpenAPI spec for tag.
|
|
11
14
|
* @returns The generated routes.
|
|
12
15
|
*/
|
|
13
|
-
export declare function generateRestRoutesBlobStorage(baseRouteName: string, componentName: string
|
|
16
|
+
export declare function generateRestRoutesBlobStorage(baseRouteName: string, componentName: string, options?: {
|
|
17
|
+
typeName?: string;
|
|
18
|
+
tagName?: string;
|
|
19
|
+
}): IRestRoute[];
|
|
14
20
|
/**
|
|
15
21
|
* Create a blob in storage.
|
|
16
22
|
* @param httpRequestContext The request context for the API.
|
|
@@ -51,3 +57,11 @@ export declare function blobStorageUpdate(httpRequestContext: IHttpRequestContex
|
|
|
51
57
|
* @returns The response object with additional http response properties.
|
|
52
58
|
*/
|
|
53
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,6 +1,7 @@
|
|
|
1
|
-
import { type IBlobStorageComponent } from "@twin.org/blob-storage-models";
|
|
1
|
+
import { 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
|
|
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
|
*/
|
|
@@ -15,55 +16,62 @@ export declare class BlobStorageService implements IBlobStorageComponent {
|
|
|
15
16
|
readonly CLASS_NAME: string;
|
|
16
17
|
/**
|
|
17
18
|
* Create a new instance of BlobStorageService.
|
|
18
|
-
* @param options The
|
|
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.
|
|
19
|
+
* @param options The options for the service.
|
|
22
20
|
*/
|
|
23
|
-
constructor(options?:
|
|
24
|
-
metadataEntityStorageType?: string;
|
|
25
|
-
vaultConnectorType?: string;
|
|
26
|
-
config?: IBlobStorageServiceConfig;
|
|
27
|
-
});
|
|
21
|
+
constructor(options?: IBlobStorageServiceConstructorOptions);
|
|
28
22
|
/**
|
|
29
23
|
* Create the blob with some metadata.
|
|
30
24
|
* @param blob The data for the blob in base64 format.
|
|
31
|
-
* @param
|
|
32
|
-
* @param
|
|
25
|
+
* @param encodingFormat Mime type for the blob, will be detected if left undefined.
|
|
26
|
+
* @param fileExtension Extension for the blob, will be detected if left undefined.
|
|
33
27
|
* @param metadata Data for the custom metadata as JSON-LD.
|
|
34
28
|
* @param namespace The namespace to use for storing, defaults to component configured namespace.
|
|
35
|
-
* @param
|
|
29
|
+
* @param userIdentity The user identity to use with storage operations.
|
|
30
|
+
* @param nodeIdentity The node identity to use with storage operations.
|
|
36
31
|
* @returns The id of the stored blob in urn format.
|
|
37
32
|
*/
|
|
38
|
-
create(blob: string,
|
|
33
|
+
create(blob: string, encodingFormat?: string, fileExtension?: string, metadata?: IJsonLdNodeObject, namespace?: string, userIdentity?: string, nodeIdentity?: string): Promise<string>;
|
|
39
34
|
/**
|
|
40
|
-
* Get the blob
|
|
35
|
+
* Get the blob entry.
|
|
41
36
|
* @param id The id of the blob to get in urn format.
|
|
42
37
|
* @param includeContent Include the content, or just get the metadata.
|
|
43
|
-
* @param
|
|
44
|
-
* @
|
|
38
|
+
* @param userIdentity The user identity to use with storage operations.
|
|
39
|
+
* @param nodeIdentity The node identity to use with storage operations.
|
|
40
|
+
* @returns The entry and data for the blob if it can be found.
|
|
45
41
|
* @throws Not found error if the blob cannot be found.
|
|
46
42
|
*/
|
|
47
|
-
get(id: string, includeContent: boolean, nodeIdentity?: string): Promise<
|
|
48
|
-
blob?: string;
|
|
49
|
-
mimeType?: string;
|
|
50
|
-
extension?: string;
|
|
51
|
-
metadata?: IJsonLdNodeObject;
|
|
52
|
-
}>;
|
|
43
|
+
get(id: string, includeContent: boolean, userIdentity?: string, nodeIdentity?: string): Promise<IBlobStorageEntry>;
|
|
53
44
|
/**
|
|
54
45
|
* Update the blob with metadata.
|
|
55
|
-
* @param id The id of the blob
|
|
56
|
-
* @param
|
|
57
|
-
* @param
|
|
46
|
+
* @param id The id of the blob entry to update.
|
|
47
|
+
* @param encodingFormat Mime type for the blob, will be detected if left undefined.
|
|
48
|
+
* @param fileExtension Extension for the blob, will be detected if left undefined.
|
|
58
49
|
* @param metadata Data for the custom metadata as JSON-LD.
|
|
50
|
+
* @param userIdentity The user identity to use with storage operations.
|
|
51
|
+
* @param nodeIdentity The node identity to use with storage operations.
|
|
59
52
|
* @returns Nothing.
|
|
60
53
|
* @throws Not found error if the blob cannot be found.
|
|
61
54
|
*/
|
|
62
|
-
update(id: string,
|
|
55
|
+
update(id: string, encodingFormat?: string, fileExtension?: string, metadata?: IJsonLdNodeObject, userIdentity?: string, nodeIdentity?: string): Promise<void>;
|
|
63
56
|
/**
|
|
64
57
|
* Remove the blob.
|
|
65
58
|
* @param id The id of the blob to remove in urn format.
|
|
59
|
+
* @param userIdentity The user identity to use with storage operations.
|
|
60
|
+
* @param nodeIdentity The node identity to use with storage operations.
|
|
66
61
|
* @returns Nothing.
|
|
67
62
|
*/
|
|
68
|
-
remove(id: string): Promise<void>;
|
|
63
|
+
remove(id: string, userIdentity?: string, nodeIdentity?: string): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Query all the blob storage entries which match the conditions.
|
|
66
|
+
* @param conditions The conditions to match for the entries.
|
|
67
|
+
* @param orderBy The order for the results, defaults to created.
|
|
68
|
+
* @param orderByDirection The direction for the order, defaults to descending.
|
|
69
|
+
* @param cursor The cursor to request the next page of entries.
|
|
70
|
+
* @param pageSize The suggested number of entries to return in each chunk, in some scenarios can return a different amount.
|
|
71
|
+
* @param userIdentity The user identity to use with storage operations.
|
|
72
|
+
* @param nodeIdentity The node identity to use with storage operations.
|
|
73
|
+
* @returns All the entries for the storage matching the conditions,
|
|
74
|
+
* and a cursor which can be used to request more entities.
|
|
75
|
+
*/
|
|
76
|
+
query(conditions?: EntityCondition<IBlobStorageEntry>, orderBy?: keyof Pick<IBlobStorageEntry, "dateCreated" | "dateModified">, orderByDirection?: SortDirection, cursor?: string, pageSize?: number, userIdentity?: string, nodeIdentity?: string): Promise<IBlobStorageEntryList>;
|
|
69
77
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { IJsonLdNodeObject } from "@twin.org/data-json-ld";
|
|
2
|
+
/**
|
|
3
|
+
* Class representing entry for the blob storage.
|
|
4
|
+
*/
|
|
5
|
+
export declare class BlobStorageEntry {
|
|
6
|
+
/**
|
|
7
|
+
* The id for the blob.
|
|
8
|
+
*/
|
|
9
|
+
id: string;
|
|
10
|
+
/**
|
|
11
|
+
* The date/time when the entry was created.
|
|
12
|
+
*/
|
|
13
|
+
dateCreated: string;
|
|
14
|
+
/**
|
|
15
|
+
* The date/time when the entry was modified.
|
|
16
|
+
*/
|
|
17
|
+
dateModified?: string;
|
|
18
|
+
/**
|
|
19
|
+
* The length of the data in the blob.
|
|
20
|
+
*/
|
|
21
|
+
blobSize: number;
|
|
22
|
+
/**
|
|
23
|
+
* The hash of the data in the blob.
|
|
24
|
+
*/
|
|
25
|
+
blobHash: string;
|
|
26
|
+
/**
|
|
27
|
+
* The mime type for the blob.
|
|
28
|
+
*/
|
|
29
|
+
encodingFormat?: string;
|
|
30
|
+
/**
|
|
31
|
+
* The extension.
|
|
32
|
+
*/
|
|
33
|
+
fileExtension?: string;
|
|
34
|
+
/**
|
|
35
|
+
* The metadata for the blob as JSON-LD.
|
|
36
|
+
*/
|
|
37
|
+
metadata?: IJsonLdNodeObject;
|
|
38
|
+
/**
|
|
39
|
+
* The user identity that created the blob.
|
|
40
|
+
*/
|
|
41
|
+
userIdentity?: string;
|
|
42
|
+
/**
|
|
43
|
+
* The node identity that created the blob.
|
|
44
|
+
*/
|
|
45
|
+
nodeIdentity?: string;
|
|
46
|
+
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from "./blobStorageRoutes";
|
|
2
2
|
export * from "./blobStorageService";
|
|
3
|
-
export * from "./entities/
|
|
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";
|
|
@@ -12,4 +12,12 @@ export interface IBlobStorageServiceConfig {
|
|
|
12
12
|
* Defaults to the first entry in the factory if not provided.
|
|
13
13
|
*/
|
|
14
14
|
defaultNamespace?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Include the node identity when performing storage operations, defaults to true.
|
|
17
|
+
*/
|
|
18
|
+
includeNodeIdentity?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Include the user identity when performing storage operations, defaults to true.
|
|
21
|
+
*/
|
|
22
|
+
includeUserIdentity?: boolean;
|
|
15
23
|
}
|
|
@@ -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, if undefined no encryption will be performed.
|
|
13
|
+
*/
|
|
14
|
+
vaultConnectorType?: string;
|
|
15
|
+
/**
|
|
16
|
+
* The configuration for the service.
|
|
17
|
+
*/
|
|
18
|
+
config?: IBlobStorageServiceConfig;
|
|
19
|
+
}
|
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
import type { IRestRouteEntryPoint } from "@twin.org/api-models";
|
|
2
|
+
/**
|
|
3
|
+
* These are dummy entry points for the blob storage service.
|
|
4
|
+
* In reality your application would create its own entry points based on the
|
|
5
|
+
* blob types it wants to store, using a custom defaultBaseRoute.
|
|
6
|
+
*/
|
|
2
7
|
export declare const restEntryPoints: IRestRouteEntryPoint[];
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# @twin.org/blob-storage-service - Changelog
|
|
2
2
|
|
|
3
|
-
## v0.0.1-next.
|
|
3
|
+
## [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)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* use shared store mechanism ([#12](https://github.com/twinfoundation/blob-storage/issues/12)) ([cae8110](https://github.com/twinfoundation/blob-storage/commit/cae8110681847a1ac4fcac968b8196694e49c320))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/blob-storage-models bumped from 0.0.1-next.29 to 0.0.1-next.30
|
|
16
|
+
* devDependencies
|
|
17
|
+
* @twin.org/blob-storage-connector-memory bumped from 0.0.1-next.29 to 0.0.1-next.30
|
|
18
|
+
|
|
19
|
+
## [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)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
* 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))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Dependencies
|
|
28
|
+
|
|
29
|
+
* The following workspace dependencies were updated
|
|
30
|
+
* dependencies
|
|
31
|
+
* @twin.org/blob-storage-models bumped from 0.0.1-next.28 to 0.0.1-next.29
|
|
32
|
+
* devDependencies
|
|
33
|
+
* @twin.org/blob-storage-connector-memory bumped from 0.0.1-next.28 to 0.0.1-next.29
|
|
34
|
+
|
|
35
|
+
## v0.0.1-next.28
|
|
4
36
|
|
|
5
37
|
- Initial Release
|