@twin.org/blob-storage-models 0.0.1-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.
Files changed (36) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +21 -0
  3. package/dist/cjs/index.cjs +13 -0
  4. package/dist/esm/index.mjs +11 -0
  5. package/dist/types/factories/blobStorageConnectorFactory.d.ts +6 -0
  6. package/dist/types/index.d.ts +13 -0
  7. package/dist/types/models/IBlobStorageComponent.d.ts +81 -0
  8. package/dist/types/models/IBlobStorageConnector.d.ts +24 -0
  9. package/dist/types/models/IBlobStorageEntry.d.ts +22 -0
  10. package/dist/types/models/api/IBlobStorageCreateRequest.d.ts +31 -0
  11. package/dist/types/models/api/IBlobStorageGetContentRequest.d.ts +30 -0
  12. package/dist/types/models/api/IBlobStorageGetContentResponse.d.ts +9 -0
  13. package/dist/types/models/api/IBlobStorageGetRequest.d.ts +24 -0
  14. package/dist/types/models/api/IBlobStorageGetResponse.d.ts +27 -0
  15. package/dist/types/models/api/IBlobStorageListRequest.d.ts +26 -0
  16. package/dist/types/models/api/IBlobStorageListResponse.d.ts +19 -0
  17. package/dist/types/models/api/IBlobStorageRemoveRequest.d.ts +14 -0
  18. package/dist/types/models/api/IBlobStorageUpdateRequest.d.ts +32 -0
  19. package/docs/changelog.md +5 -0
  20. package/docs/examples.md +1 -0
  21. package/docs/reference/index.md +20 -0
  22. package/docs/reference/interfaces/IBlobStorageComponent.md +232 -0
  23. package/docs/reference/interfaces/IBlobStorageConnector.md +67 -0
  24. package/docs/reference/interfaces/IBlobStorageCreateRequest.md +41 -0
  25. package/docs/reference/interfaces/IBlobStorageEntry.md +35 -0
  26. package/docs/reference/interfaces/IBlobStorageGetContentRequest.md +45 -0
  27. package/docs/reference/interfaces/IBlobStorageGetContentResponse.md +11 -0
  28. package/docs/reference/interfaces/IBlobStorageGetRequest.md +37 -0
  29. package/docs/reference/interfaces/IBlobStorageGetResponse.md +35 -0
  30. package/docs/reference/interfaces/IBlobStorageListRequest.md +35 -0
  31. package/docs/reference/interfaces/IBlobStorageListResponse.md +23 -0
  32. package/docs/reference/interfaces/IBlobStorageRemoveRequest.md +17 -0
  33. package/docs/reference/interfaces/IBlobStorageUpdateRequest.md +43 -0
  34. package/docs/reference/variables/BlobStorageConnectorFactory.md +5 -0
  35. package/locales/en.json +3 -0
  36. package/package.json +40 -0
@@ -0,0 +1,232 @@
1
+ # Interface: IBlobStorageComponent
2
+
3
+ Interface describing an blob storage component.
4
+
5
+ ## Extends
6
+
7
+ - `IComponent`
8
+
9
+ ## Methods
10
+
11
+ ### create()
12
+
13
+ > **create**(`blob`, `mimeType`?, `extension`?, `metadata`?, `namespace`?, `userIdentity`?, `nodeIdentity`?): `Promise`\<`string`\>
14
+
15
+ Create the blob with some metadata.
16
+
17
+ #### Parameters
18
+
19
+ • **blob**: `string`
20
+
21
+ The data for the blob in base64 format.
22
+
23
+ • **mimeType?**: `string`
24
+
25
+ Mime type for the blob, will be detected if left undefined.
26
+
27
+ • **extension?**: `string`
28
+
29
+ Extension for the blob, will be detected if left undefined.
30
+
31
+ • **metadata?**: `IJsonLdNodeObject`
32
+
33
+ Data for the custom metadata as JSON-LD.
34
+
35
+ • **namespace?**: `string`
36
+
37
+ The namespace to use for storing, defaults to component configured namespace.
38
+
39
+ • **userIdentity?**: `string`
40
+
41
+ The user identity to use with storage operations.
42
+
43
+ • **nodeIdentity?**: `string`
44
+
45
+ The node identity to use with storage operations.
46
+
47
+ #### Returns
48
+
49
+ `Promise`\<`string`\>
50
+
51
+ The id of the stored blob in urn format.
52
+
53
+ ***
54
+
55
+ ### get()
56
+
57
+ > **get**(`id`, `includeContent`, `userIdentity`?, `nodeIdentity`?): `Promise`\<`object`\>
58
+
59
+ Get the blob and metadata.
60
+
61
+ #### Parameters
62
+
63
+ • **id**: `string`
64
+
65
+ The id of the blob to get in urn format.
66
+
67
+ • **includeContent**: `boolean`
68
+
69
+ Include the content, or just get the metadata.
70
+
71
+ • **userIdentity?**: `string`
72
+
73
+ The user identity to use with storage operations.
74
+
75
+ • **nodeIdentity?**: `string`
76
+
77
+ The node identity to use with storage operations.
78
+
79
+ #### Returns
80
+
81
+ `Promise`\<`object`\>
82
+
83
+ The data and metadata for the blob if it can be found.
84
+
85
+ ##### blob?
86
+
87
+ > `optional` **blob**: `string`
88
+
89
+ ##### mimeType?
90
+
91
+ > `optional` **mimeType**: `string`
92
+
93
+ ##### extension?
94
+
95
+ > `optional` **extension**: `string`
96
+
97
+ ##### metadata?
98
+
99
+ > `optional` **metadata**: `IJsonLdNodeObject`
100
+
101
+ #### Throws
102
+
103
+ Not found error if the blob cannot be found.
104
+
105
+ ***
106
+
107
+ ### update()
108
+
109
+ > **update**(`id`, `mimeType`?, `extension`?, `metadata`?, `userIdentity`?, `nodeIdentity`?): `Promise`\<`void`\>
110
+
111
+ Update the blob with metadata.
112
+
113
+ #### Parameters
114
+
115
+ • **id**: `string`
116
+
117
+ The id of the blob metadata to update.
118
+
119
+ • **mimeType?**: `string`
120
+
121
+ Mime type for the blob, will be detected if left undefined.
122
+
123
+ • **extension?**: `string`
124
+
125
+ Extension for the blob, will be detected if left undefined.
126
+
127
+ • **metadata?**: `IJsonLdNodeObject`
128
+
129
+ Data for the custom metadata as JSON-LD.
130
+
131
+ • **userIdentity?**: `string`
132
+
133
+ The user identity to use with storage operations.
134
+
135
+ • **nodeIdentity?**: `string`
136
+
137
+ The node identity to use with storage operations.
138
+
139
+ #### Returns
140
+
141
+ `Promise`\<`void`\>
142
+
143
+ Nothing.
144
+
145
+ #### Throws
146
+
147
+ Not found error if the blob cannot be found.
148
+
149
+ ***
150
+
151
+ ### remove()
152
+
153
+ > **remove**(`id`, `userIdentity`?, `nodeIdentity`?): `Promise`\<`void`\>
154
+
155
+ Remove the blob.
156
+
157
+ #### Parameters
158
+
159
+ • **id**: `string`
160
+
161
+ The id of the blob to remove in urn format.
162
+
163
+ • **userIdentity?**: `string`
164
+
165
+ The user identity to use with storage operations.
166
+
167
+ • **nodeIdentity?**: `string`
168
+
169
+ The node identity to use with storage operations.
170
+
171
+ #### Returns
172
+
173
+ `Promise`\<`void`\>
174
+
175
+ Nothing.
176
+
177
+ #### Throws
178
+
179
+ Not found error if the blob cannot be found.
180
+
181
+ ***
182
+
183
+ ### query()
184
+
185
+ > **query**(`conditions`?, `sortProperties`?, `cursor`?, `pageSize`?, `userIdentity`?, `nodeIdentity`?): `Promise`\<`object`\>
186
+
187
+ Query all the blob storage entries which match the conditions.
188
+
189
+ #### Parameters
190
+
191
+ • **conditions?**: `EntityCondition`\<[`IBlobStorageEntry`](IBlobStorageEntry.md)\>
192
+
193
+ The conditions to match for the entries.
194
+
195
+ • **sortProperties?**: `object`[]
196
+
197
+ The optional sort order.
198
+
199
+ • **cursor?**: `string`
200
+
201
+ The cursor to request the next page of entries.
202
+
203
+ • **pageSize?**: `number`
204
+
205
+ The suggested number of entries to return in each chunk, in some scenarios can return a different amount.
206
+
207
+ • **userIdentity?**: `string`
208
+
209
+ The user identity to use with storage operations.
210
+
211
+ • **nodeIdentity?**: `string`
212
+
213
+ The node identity to use with storage operations.
214
+
215
+ #### Returns
216
+
217
+ `Promise`\<`object`\>
218
+
219
+ All the entries for the storage matching the conditions,
220
+ and a cursor which can be used to request more entities.
221
+
222
+ ##### entities
223
+
224
+ > **entities**: [`IBlobStorageEntry`](IBlobStorageEntry.md)[]
225
+
226
+ The entities.
227
+
228
+ ##### cursor?
229
+
230
+ > `optional` **cursor**: `string`
231
+
232
+ An optional cursor, when defined can be used to call find to get more entities.
@@ -0,0 +1,67 @@
1
+ # Interface: IBlobStorageConnector
2
+
3
+ Interface describing an blob storage connector.
4
+
5
+ ## Extends
6
+
7
+ - `IComponent`
8
+
9
+ ## Methods
10
+
11
+ ### set()
12
+
13
+ > **set**(`blob`): `Promise`\<`string`\>
14
+
15
+ Set the blob.
16
+
17
+ #### Parameters
18
+
19
+ • **blob**: `Uint8Array`
20
+
21
+ The data for the blob.
22
+
23
+ #### Returns
24
+
25
+ `Promise`\<`string`\>
26
+
27
+ The id of the stored blob in urn format.
28
+
29
+ ***
30
+
31
+ ### get()
32
+
33
+ > **get**(`id`): `Promise`\<`undefined` \| `Uint8Array`\>
34
+
35
+ Get the blob.
36
+
37
+ #### Parameters
38
+
39
+ • **id**: `string`
40
+
41
+ The id of the blob to get in urn format.
42
+
43
+ #### Returns
44
+
45
+ `Promise`\<`undefined` \| `Uint8Array`\>
46
+
47
+ The data for the blob if it can be found or undefined.
48
+
49
+ ***
50
+
51
+ ### remove()
52
+
53
+ > **remove**(`id`): `Promise`\<`boolean`\>
54
+
55
+ Remove the blob.
56
+
57
+ #### Parameters
58
+
59
+ • **id**: `string`
60
+
61
+ The id of the blob to remove in urn format.
62
+
63
+ #### Returns
64
+
65
+ `Promise`\<`boolean`\>
66
+
67
+ True if the blob was found.
@@ -0,0 +1,41 @@
1
+ # Interface: IBlobStorageCreateRequest
2
+
3
+ Request to create an entry in blob storage.
4
+
5
+ ## Properties
6
+
7
+ ### body
8
+
9
+ > **body**: `object`
10
+
11
+ The body parameters.
12
+
13
+ #### blob
14
+
15
+ > **blob**: `string`
16
+
17
+ The data to store in base64 encoding.
18
+
19
+ #### mimeType?
20
+
21
+ > `optional` **mimeType**: `string`
22
+
23
+ The mime type of the blob, will be detected if left undefined.
24
+
25
+ #### extension?
26
+
27
+ > `optional` **extension**: `string`
28
+
29
+ The extension of the blob, will be detected if left undefined.
30
+
31
+ #### metadata?
32
+
33
+ > `optional` **metadata**: `IJsonLdNodeObject`
34
+
35
+ Custom metadata to associate with the blob as JSON-LD.
36
+
37
+ #### namespace?
38
+
39
+ > `optional` **namespace**: `string`
40
+
41
+ The namespace to store the data in, defaults to component configured namespace.
@@ -0,0 +1,35 @@
1
+ # Interface: IBlobStorageEntry
2
+
3
+ Interface describing a blob storage entry.
4
+
5
+ ## Properties
6
+
7
+ ### id
8
+
9
+ > **id**: `string`
10
+
11
+ The id for the blob.
12
+
13
+ ***
14
+
15
+ ### mimeType?
16
+
17
+ > `optional` **mimeType**: `string`
18
+
19
+ The mime type for the blob.
20
+
21
+ ***
22
+
23
+ ### extension?
24
+
25
+ > `optional` **extension**: `string`
26
+
27
+ The extension.
28
+
29
+ ***
30
+
31
+ ### metadata?
32
+
33
+ > `optional` **metadata**: `IJsonLdNodeObject`
34
+
35
+ The metadata for the blob as JSON-LD.
@@ -0,0 +1,45 @@
1
+ # Interface: IBlobStorageGetContentRequest
2
+
3
+ Request to get the content from blob storage.
4
+
5
+ ## Properties
6
+
7
+ ### pathParams
8
+
9
+ > **pathParams**: `object`
10
+
11
+ The path parameters.
12
+
13
+ #### id
14
+
15
+ > **id**: `string`
16
+
17
+ The id of the blob to get in urn format.
18
+
19
+ ***
20
+
21
+ ### query?
22
+
23
+ > `optional` **query**: `object`
24
+
25
+ The query parameters.
26
+
27
+ #### download?
28
+
29
+ > `optional` **download**: `boolean`
30
+
31
+ Set the download flag which should prompt the browser to save the file.
32
+ Otherwise the browser should show the content inside the page.
33
+
34
+ ##### Default
35
+
36
+ ```ts
37
+ false
38
+ ```
39
+
40
+ #### filename?
41
+
42
+ > `optional` **filename**: `string`
43
+
44
+ Set the filename to use when a download is triggered.
45
+ A filename will be generated if not provided.
@@ -0,0 +1,11 @@
1
+ # Interface: IBlobStorageGetContentResponse
2
+
3
+ Response to get an entry from blob storage.
4
+
5
+ ## Properties
6
+
7
+ ### body
8
+
9
+ > **body**: `Uint8Array`
10
+
11
+ The body parameters.
@@ -0,0 +1,37 @@
1
+ # Interface: IBlobStorageGetRequest
2
+
3
+ Request to get an entry from blob storage.
4
+
5
+ ## Properties
6
+
7
+ ### pathParams
8
+
9
+ > **pathParams**: `object`
10
+
11
+ The path parameters.
12
+
13
+ #### id
14
+
15
+ > **id**: `string`
16
+
17
+ The id of the blob to get in urn format.
18
+
19
+ ***
20
+
21
+ ### query?
22
+
23
+ > `optional` **query**: `object`
24
+
25
+ The query parameters.
26
+
27
+ #### includeContent?
28
+
29
+ > `optional` **includeContent**: `boolean`
30
+
31
+ Include the content in the response, otherwise only metadata is returned.
32
+
33
+ ##### Default
34
+
35
+ ```ts
36
+ false
37
+ ```
@@ -0,0 +1,35 @@
1
+ # Interface: IBlobStorageGetResponse
2
+
3
+ Response to get an entry from blob storage.
4
+
5
+ ## Properties
6
+
7
+ ### body
8
+
9
+ > **body**: `object`
10
+
11
+ The body parameters.
12
+
13
+ #### mimeType?
14
+
15
+ > `optional` **mimeType**: `string`
16
+
17
+ The mime type of the blob.
18
+
19
+ #### extension?
20
+
21
+ > `optional` **extension**: `string`
22
+
23
+ The extension of the blob.
24
+
25
+ #### metadata?
26
+
27
+ > `optional` **metadata**: `IJsonLdNodeObject`
28
+
29
+ Custom metadata to associate with the blob as JSON-LD.
30
+
31
+ #### blob?
32
+
33
+ > `optional` **blob**: `string`
34
+
35
+ The blob in base64 format, if the includeContent flag was set in the request.
@@ -0,0 +1,35 @@
1
+ # Interface: IBlobStorageListRequest
2
+
3
+ Query the entries from blob storage.
4
+
5
+ ## Properties
6
+
7
+ ### query?
8
+
9
+ > `optional` **query**: `object`
10
+
11
+ The parameters from the query.
12
+
13
+ #### conditions?
14
+
15
+ > `optional` **conditions**: `string`
16
+
17
+ The condition for the query as JSON version of EntityCondition type.
18
+
19
+ #### sortProperties?
20
+
21
+ > `optional` **sortProperties**: `string`
22
+
23
+ The sort property array as JSON serialization of property,direction.
24
+
25
+ #### pageSize?
26
+
27
+ > `optional` **pageSize**: `number`
28
+
29
+ The number of entries to return per page.
30
+
31
+ #### cursor?
32
+
33
+ > `optional` **cursor**: `string`
34
+
35
+ The cursor to get next chunk of data, returned in previous response.
@@ -0,0 +1,23 @@
1
+ # Interface: IBlobStorageListResponse
2
+
3
+ Response to getting the list of entries from a query.
4
+
5
+ ## Properties
6
+
7
+ ### body
8
+
9
+ > **body**: `object`
10
+
11
+ The list of entries from the query.
12
+
13
+ #### entities
14
+
15
+ > **entities**: [`IBlobStorageEntry`](IBlobStorageEntry.md)[]
16
+
17
+ The entities from the query.
18
+
19
+ #### cursor?
20
+
21
+ > `optional` **cursor**: `string`
22
+
23
+ The cursor for the next page.
@@ -0,0 +1,17 @@
1
+ # Interface: IBlobStorageRemoveRequest
2
+
3
+ Request to remove an entry from blob storage.
4
+
5
+ ## Properties
6
+
7
+ ### pathParams
8
+
9
+ > **pathParams**: `object`
10
+
11
+ The path parameters.
12
+
13
+ #### id
14
+
15
+ > **id**: `string`
16
+
17
+ The id of the blob to remove in urn format.
@@ -0,0 +1,43 @@
1
+ # Interface: IBlobStorageUpdateRequest
2
+
3
+ Request to update a blob entry.
4
+
5
+ ## Properties
6
+
7
+ ### pathParams
8
+
9
+ > **pathParams**: `object`
10
+
11
+ The path parameters.
12
+
13
+ #### id
14
+
15
+ > **id**: `string`
16
+
17
+ The id of the blob to get in urn format.
18
+
19
+ ***
20
+
21
+ ### body
22
+
23
+ > **body**: `object`
24
+
25
+ The body parameters.
26
+
27
+ #### mimeType?
28
+
29
+ > `optional` **mimeType**: `string`
30
+
31
+ The mime type of the blob, will be detected if left undefined.
32
+
33
+ #### extension?
34
+
35
+ > `optional` **extension**: `string`
36
+
37
+ The extension of the blob, will be detected if left undefined.
38
+
39
+ #### metadata?
40
+
41
+ > `optional` **metadata**: `IJsonLdNodeObject`
42
+
43
+ Custom metadata to associate with the blob as JSON-LD.
@@ -0,0 +1,5 @@
1
+ # Variable: BlobStorageConnectorFactory
2
+
3
+ > `const` **BlobStorageConnectorFactory**: `Factory`\<[`IBlobStorageConnector`](../interfaces/IBlobStorageConnector.md)\>
4
+
5
+ Factory for creating blob storage connectors.
@@ -0,0 +1,3 @@
1
+ {
2
+ "error": {}
3
+ }
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@twin.org/blob-storage-models",
3
+ "version": "0.0.1-next.10",
4
+ "description": "Models which define the structure of the blob storage contracts and connectors",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/twinfoundation/blob-storage.git",
8
+ "directory": "packages/blob-storage-models"
9
+ },
10
+ "author": "martyn.janes@iota.org",
11
+ "license": "Apache-2.0",
12
+ "type": "module",
13
+ "engines": {
14
+ "node": ">=20.0.0"
15
+ },
16
+ "dependencies": {
17
+ "@twin.org/core": "next",
18
+ "@twin.org/data-json-ld": "next",
19
+ "@twin.org/entity": "next",
20
+ "@twin.org/nameof": "next"
21
+ },
22
+ "main": "./dist/cjs/index.cjs",
23
+ "module": "./dist/esm/index.mjs",
24
+ "types": "./dist/types/index.d.ts",
25
+ "exports": {
26
+ ".": {
27
+ "require": "./dist/cjs/index.cjs",
28
+ "import": "./dist/esm/index.mjs",
29
+ "types": "./dist/types/index.d.ts"
30
+ },
31
+ "./locales": "./locales"
32
+ },
33
+ "files": [
34
+ "dist/cjs",
35
+ "dist/esm",
36
+ "dist/types",
37
+ "locales",
38
+ "docs"
39
+ ]
40
+ }