@twin.org/blob-storage-models 0.0.1-next.8 → 0.0.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.
- package/dist/cjs/index.cjs +188 -0
- package/dist/esm/index.mjs +185 -1
- package/dist/types/dataTypes/blobStorageDataTypes.d.ts +9 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/models/IBlobStorageComponent.d.ts +51 -17
- package/dist/types/models/IBlobStorageEntry.d.ts +65 -0
- package/dist/types/models/IBlobStorageEntryList.d.ts +30 -0
- package/dist/types/models/api/IBlobStorageCreateRequest.d.ts +17 -2
- package/dist/types/models/api/IBlobStorageGetContentRequest.d.ts +11 -1
- package/dist/types/models/api/IBlobStorageGetRequest.d.ts +18 -1
- package/dist/types/models/api/IBlobStorageGetResponse.d.ts +9 -19
- package/dist/types/models/api/IBlobStorageListRequest.d.ts +39 -0
- package/dist/types/models/api/IBlobStorageListResponse.d.ts +17 -0
- package/dist/types/models/api/IBlobStorageUpdateRequest.d.ts +2 -2
- package/dist/types/models/blobStorageCompressionType.d.ts +17 -0
- package/dist/types/models/blobStorageContexts.d.ts +17 -0
- package/dist/types/models/blobStorageTypes.d.ts +17 -0
- package/docs/changelog.md +71 -1
- package/docs/reference/classes/BlobStorageDataTypes.md +25 -0
- package/docs/reference/index.md +17 -0
- package/docs/reference/interfaces/IBlobStorageComponent.md +176 -31
- package/docs/reference/interfaces/IBlobStorageConnector.md +11 -5
- package/docs/reference/interfaces/IBlobStorageCreateRequest.md +34 -4
- package/docs/reference/interfaces/IBlobStorageEntry.md +107 -0
- package/docs/reference/interfaces/IBlobStorageEntryList.md +35 -0
- package/docs/reference/interfaces/IBlobStorageGetContentRequest.md +25 -1
- package/docs/reference/interfaces/IBlobStorageGetRequest.md +37 -1
- package/docs/reference/interfaces/IBlobStorageGetResponse.md +9 -21
- package/docs/reference/interfaces/IBlobStorageListRequest.md +53 -0
- package/docs/reference/interfaces/IBlobStorageListResponse.md +23 -0
- package/docs/reference/interfaces/IBlobStorageUpdateRequest.md +4 -4
- package/docs/reference/type-aliases/BlobStorageCompressionType.md +5 -0
- package/docs/reference/type-aliases/BlobStorageContexts.md +5 -0
- package/docs/reference/type-aliases/BlobStorageTypes.md +5 -0
- package/docs/reference/variables/BlobStorageCompressionType.md +19 -0
- package/docs/reference/variables/BlobStorageContexts.md +19 -0
- package/docs/reference/variables/BlobStorageTypes.md +19 -0
- package/package.json +11 -7
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,7 +1,174 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var dataCore = require('@twin.org/data-core');
|
|
3
4
|
var core = require('@twin.org/core');
|
|
4
5
|
|
|
6
|
+
// Copyright 2024 IOTA Stiftung.
|
|
7
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
8
|
+
/**
|
|
9
|
+
* The contexts of blob storage data.
|
|
10
|
+
*/
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
12
|
+
const BlobStorageContexts = {
|
|
13
|
+
/**
|
|
14
|
+
* The context root for the blob storage types.
|
|
15
|
+
*/
|
|
16
|
+
ContextRoot: "https://schema.twindev.org/blob-storage/",
|
|
17
|
+
/**
|
|
18
|
+
* The context root for the common types.
|
|
19
|
+
*/
|
|
20
|
+
ContextRootCommon: "https://schema.twindev.org/common/"
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// Copyright 2024 IOTA Stiftung.
|
|
24
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
25
|
+
/**
|
|
26
|
+
* The types of blob storage data.
|
|
27
|
+
*/
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
29
|
+
const BlobStorageTypes = {
|
|
30
|
+
/**
|
|
31
|
+
* Represents blob storage entry.
|
|
32
|
+
*/
|
|
33
|
+
Entry: "BlobStorageEntry",
|
|
34
|
+
/**
|
|
35
|
+
* Represents blob storage entry compression.
|
|
36
|
+
*/
|
|
37
|
+
CompressionType: "BlobStorageCompressionType"
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
var $schema$1 = "https://json-schema.org/draft/2020-12/schema";
|
|
41
|
+
var $id$1 = "https://schema.twindev.org/blob-storage/BlobStorageCompressionType";
|
|
42
|
+
var description$1 = "The types of compression for blob storage data.";
|
|
43
|
+
var type$1 = "string";
|
|
44
|
+
var BlobStorageCompressionTypeSchema = {
|
|
45
|
+
$schema: $schema$1,
|
|
46
|
+
$id: $id$1,
|
|
47
|
+
description: description$1,
|
|
48
|
+
type: type$1,
|
|
49
|
+
"enum": [
|
|
50
|
+
"gzip",
|
|
51
|
+
"deflate"
|
|
52
|
+
]
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
var $schema = "https://json-schema.org/draft/2020-12/schema";
|
|
56
|
+
var $id = "https://schema.twindev.org/blob-storage/BlobStorageEntry";
|
|
57
|
+
var description = "Interface describing a blob storage entry.";
|
|
58
|
+
var type = "object";
|
|
59
|
+
var properties = {
|
|
60
|
+
"@context": {
|
|
61
|
+
type: "array",
|
|
62
|
+
minItems: 2,
|
|
63
|
+
items: {
|
|
64
|
+
$ref: "https://schema.twindev.org/json-ld/JsonLdContextDefinitionElement"
|
|
65
|
+
},
|
|
66
|
+
description: "JSON-LD Context.",
|
|
67
|
+
prefixItems: [
|
|
68
|
+
{
|
|
69
|
+
type: "string",
|
|
70
|
+
"const": "https://schema.twindev.org/blob-storage/"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
type: "string",
|
|
74
|
+
"const": "https://schema.twindev.org/common/"
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
},
|
|
78
|
+
type: {
|
|
79
|
+
type: "string",
|
|
80
|
+
"const": "BlobStorageEntry",
|
|
81
|
+
description: "JSON-LD Type."
|
|
82
|
+
},
|
|
83
|
+
id: {
|
|
84
|
+
type: "string",
|
|
85
|
+
description: "The id for the blob."
|
|
86
|
+
},
|
|
87
|
+
dateCreated: {
|
|
88
|
+
type: "string",
|
|
89
|
+
description: "The date/time when the entry was created."
|
|
90
|
+
},
|
|
91
|
+
dateModified: {
|
|
92
|
+
type: "string",
|
|
93
|
+
description: "The date/time when the entry was modified."
|
|
94
|
+
},
|
|
95
|
+
blobSize: {
|
|
96
|
+
type: "number",
|
|
97
|
+
description: "The size of the data in the blob."
|
|
98
|
+
},
|
|
99
|
+
blobHash: {
|
|
100
|
+
type: "string",
|
|
101
|
+
description: "The hash of the data in the blob."
|
|
102
|
+
},
|
|
103
|
+
encodingFormat: {
|
|
104
|
+
type: "string",
|
|
105
|
+
description: "The mime type for the blob."
|
|
106
|
+
},
|
|
107
|
+
isEncrypted: {
|
|
108
|
+
type: "boolean",
|
|
109
|
+
description: "Indicates if the blob is encrypted."
|
|
110
|
+
},
|
|
111
|
+
compression: {
|
|
112
|
+
$ref: "https://schema.twindev.org/blob-storage/BlobStorageCompressionType",
|
|
113
|
+
description: "The type of compression used for the blob, if not set it is not stored with compression."
|
|
114
|
+
},
|
|
115
|
+
fileExtension: {
|
|
116
|
+
type: "string",
|
|
117
|
+
description: "The extension."
|
|
118
|
+
},
|
|
119
|
+
metadata: {
|
|
120
|
+
$ref: "https://schema.twindev.org/json-ld/JsonLdNodeObject",
|
|
121
|
+
description: "The metadata for the blob as JSON-LD."
|
|
122
|
+
},
|
|
123
|
+
blob: {
|
|
124
|
+
type: "string",
|
|
125
|
+
description: "The blob in base64 format, included if the includeContent flag was set in the request."
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
var required = [
|
|
129
|
+
"@context",
|
|
130
|
+
"type",
|
|
131
|
+
"id",
|
|
132
|
+
"dateCreated",
|
|
133
|
+
"blobSize",
|
|
134
|
+
"blobHash"
|
|
135
|
+
];
|
|
136
|
+
var additionalProperties = false;
|
|
137
|
+
var BlobStorageEntrySchema = {
|
|
138
|
+
$schema: $schema,
|
|
139
|
+
$id: $id,
|
|
140
|
+
description: description,
|
|
141
|
+
type: type,
|
|
142
|
+
properties: properties,
|
|
143
|
+
required: required,
|
|
144
|
+
additionalProperties: additionalProperties
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
// Copyright 2024 IOTA Stiftung.
|
|
148
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
149
|
+
/**
|
|
150
|
+
* Handle all the data types for blob storage.
|
|
151
|
+
*/
|
|
152
|
+
class BlobStorageDataTypes {
|
|
153
|
+
/**
|
|
154
|
+
* Register all the data types.
|
|
155
|
+
*/
|
|
156
|
+
static registerTypes() {
|
|
157
|
+
dataCore.DataTypeHandlerFactory.register(`${BlobStorageContexts.ContextRoot}${BlobStorageTypes.Entry}`, () => ({
|
|
158
|
+
context: BlobStorageContexts.ContextRoot,
|
|
159
|
+
type: BlobStorageTypes.Entry,
|
|
160
|
+
defaultValue: {},
|
|
161
|
+
jsonSchema: async () => BlobStorageEntrySchema
|
|
162
|
+
}));
|
|
163
|
+
dataCore.DataTypeHandlerFactory.register(`${BlobStorageContexts.ContextRoot}${BlobStorageTypes.CompressionType}`, () => ({
|
|
164
|
+
context: BlobStorageContexts.ContextRoot,
|
|
165
|
+
type: BlobStorageTypes.CompressionType,
|
|
166
|
+
defaultValue: {},
|
|
167
|
+
jsonSchema: async () => BlobStorageCompressionTypeSchema
|
|
168
|
+
}));
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
5
172
|
// Copyright 2024 IOTA Stiftung.
|
|
6
173
|
// SPDX-License-Identifier: Apache-2.0.
|
|
7
174
|
/**
|
|
@@ -10,4 +177,25 @@ var core = require('@twin.org/core');
|
|
|
10
177
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
11
178
|
const BlobStorageConnectorFactory = core.Factory.createFactory("blob-storage");
|
|
12
179
|
|
|
180
|
+
// Copyright 2024 IOTA Stiftung.
|
|
181
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
182
|
+
/**
|
|
183
|
+
* The types of compression for blob storage data.
|
|
184
|
+
*/
|
|
185
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
186
|
+
const BlobStorageCompressionType = {
|
|
187
|
+
/**
|
|
188
|
+
* Gzip.
|
|
189
|
+
*/
|
|
190
|
+
Gzip: "gzip",
|
|
191
|
+
/**
|
|
192
|
+
* Deflate.
|
|
193
|
+
*/
|
|
194
|
+
Deflate: "deflate"
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
exports.BlobStorageCompressionType = BlobStorageCompressionType;
|
|
13
198
|
exports.BlobStorageConnectorFactory = BlobStorageConnectorFactory;
|
|
199
|
+
exports.BlobStorageContexts = BlobStorageContexts;
|
|
200
|
+
exports.BlobStorageDataTypes = BlobStorageDataTypes;
|
|
201
|
+
exports.BlobStorageTypes = BlobStorageTypes;
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,5 +1,172 @@
|
|
|
1
|
+
import { DataTypeHandlerFactory } from '@twin.org/data-core';
|
|
1
2
|
import { Factory } from '@twin.org/core';
|
|
2
3
|
|
|
4
|
+
// Copyright 2024 IOTA Stiftung.
|
|
5
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
6
|
+
/**
|
|
7
|
+
* The contexts of blob storage data.
|
|
8
|
+
*/
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
10
|
+
const BlobStorageContexts = {
|
|
11
|
+
/**
|
|
12
|
+
* The context root for the blob storage types.
|
|
13
|
+
*/
|
|
14
|
+
ContextRoot: "https://schema.twindev.org/blob-storage/",
|
|
15
|
+
/**
|
|
16
|
+
* The context root for the common types.
|
|
17
|
+
*/
|
|
18
|
+
ContextRootCommon: "https://schema.twindev.org/common/"
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// Copyright 2024 IOTA Stiftung.
|
|
22
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
23
|
+
/**
|
|
24
|
+
* The types of blob storage data.
|
|
25
|
+
*/
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
27
|
+
const BlobStorageTypes = {
|
|
28
|
+
/**
|
|
29
|
+
* Represents blob storage entry.
|
|
30
|
+
*/
|
|
31
|
+
Entry: "BlobStorageEntry",
|
|
32
|
+
/**
|
|
33
|
+
* Represents blob storage entry compression.
|
|
34
|
+
*/
|
|
35
|
+
CompressionType: "BlobStorageCompressionType"
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
var $schema$1 = "https://json-schema.org/draft/2020-12/schema";
|
|
39
|
+
var $id$1 = "https://schema.twindev.org/blob-storage/BlobStorageCompressionType";
|
|
40
|
+
var description$1 = "The types of compression for blob storage data.";
|
|
41
|
+
var type$1 = "string";
|
|
42
|
+
var BlobStorageCompressionTypeSchema = {
|
|
43
|
+
$schema: $schema$1,
|
|
44
|
+
$id: $id$1,
|
|
45
|
+
description: description$1,
|
|
46
|
+
type: type$1,
|
|
47
|
+
"enum": [
|
|
48
|
+
"gzip",
|
|
49
|
+
"deflate"
|
|
50
|
+
]
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
var $schema = "https://json-schema.org/draft/2020-12/schema";
|
|
54
|
+
var $id = "https://schema.twindev.org/blob-storage/BlobStorageEntry";
|
|
55
|
+
var description = "Interface describing a blob storage entry.";
|
|
56
|
+
var type = "object";
|
|
57
|
+
var properties = {
|
|
58
|
+
"@context": {
|
|
59
|
+
type: "array",
|
|
60
|
+
minItems: 2,
|
|
61
|
+
items: {
|
|
62
|
+
$ref: "https://schema.twindev.org/json-ld/JsonLdContextDefinitionElement"
|
|
63
|
+
},
|
|
64
|
+
description: "JSON-LD Context.",
|
|
65
|
+
prefixItems: [
|
|
66
|
+
{
|
|
67
|
+
type: "string",
|
|
68
|
+
"const": "https://schema.twindev.org/blob-storage/"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
type: "string",
|
|
72
|
+
"const": "https://schema.twindev.org/common/"
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
},
|
|
76
|
+
type: {
|
|
77
|
+
type: "string",
|
|
78
|
+
"const": "BlobStorageEntry",
|
|
79
|
+
description: "JSON-LD Type."
|
|
80
|
+
},
|
|
81
|
+
id: {
|
|
82
|
+
type: "string",
|
|
83
|
+
description: "The id for the blob."
|
|
84
|
+
},
|
|
85
|
+
dateCreated: {
|
|
86
|
+
type: "string",
|
|
87
|
+
description: "The date/time when the entry was created."
|
|
88
|
+
},
|
|
89
|
+
dateModified: {
|
|
90
|
+
type: "string",
|
|
91
|
+
description: "The date/time when the entry was modified."
|
|
92
|
+
},
|
|
93
|
+
blobSize: {
|
|
94
|
+
type: "number",
|
|
95
|
+
description: "The size of the data in the blob."
|
|
96
|
+
},
|
|
97
|
+
blobHash: {
|
|
98
|
+
type: "string",
|
|
99
|
+
description: "The hash of the data in the blob."
|
|
100
|
+
},
|
|
101
|
+
encodingFormat: {
|
|
102
|
+
type: "string",
|
|
103
|
+
description: "The mime type for the blob."
|
|
104
|
+
},
|
|
105
|
+
isEncrypted: {
|
|
106
|
+
type: "boolean",
|
|
107
|
+
description: "Indicates if the blob is encrypted."
|
|
108
|
+
},
|
|
109
|
+
compression: {
|
|
110
|
+
$ref: "https://schema.twindev.org/blob-storage/BlobStorageCompressionType",
|
|
111
|
+
description: "The type of compression used for the blob, if not set it is not stored with compression."
|
|
112
|
+
},
|
|
113
|
+
fileExtension: {
|
|
114
|
+
type: "string",
|
|
115
|
+
description: "The extension."
|
|
116
|
+
},
|
|
117
|
+
metadata: {
|
|
118
|
+
$ref: "https://schema.twindev.org/json-ld/JsonLdNodeObject",
|
|
119
|
+
description: "The metadata for the blob as JSON-LD."
|
|
120
|
+
},
|
|
121
|
+
blob: {
|
|
122
|
+
type: "string",
|
|
123
|
+
description: "The blob in base64 format, included if the includeContent flag was set in the request."
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
var required = [
|
|
127
|
+
"@context",
|
|
128
|
+
"type",
|
|
129
|
+
"id",
|
|
130
|
+
"dateCreated",
|
|
131
|
+
"blobSize",
|
|
132
|
+
"blobHash"
|
|
133
|
+
];
|
|
134
|
+
var additionalProperties = false;
|
|
135
|
+
var BlobStorageEntrySchema = {
|
|
136
|
+
$schema: $schema,
|
|
137
|
+
$id: $id,
|
|
138
|
+
description: description,
|
|
139
|
+
type: type,
|
|
140
|
+
properties: properties,
|
|
141
|
+
required: required,
|
|
142
|
+
additionalProperties: additionalProperties
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
// Copyright 2024 IOTA Stiftung.
|
|
146
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
147
|
+
/**
|
|
148
|
+
* Handle all the data types for blob storage.
|
|
149
|
+
*/
|
|
150
|
+
class BlobStorageDataTypes {
|
|
151
|
+
/**
|
|
152
|
+
* Register all the data types.
|
|
153
|
+
*/
|
|
154
|
+
static registerTypes() {
|
|
155
|
+
DataTypeHandlerFactory.register(`${BlobStorageContexts.ContextRoot}${BlobStorageTypes.Entry}`, () => ({
|
|
156
|
+
context: BlobStorageContexts.ContextRoot,
|
|
157
|
+
type: BlobStorageTypes.Entry,
|
|
158
|
+
defaultValue: {},
|
|
159
|
+
jsonSchema: async () => BlobStorageEntrySchema
|
|
160
|
+
}));
|
|
161
|
+
DataTypeHandlerFactory.register(`${BlobStorageContexts.ContextRoot}${BlobStorageTypes.CompressionType}`, () => ({
|
|
162
|
+
context: BlobStorageContexts.ContextRoot,
|
|
163
|
+
type: BlobStorageTypes.CompressionType,
|
|
164
|
+
defaultValue: {},
|
|
165
|
+
jsonSchema: async () => BlobStorageCompressionTypeSchema
|
|
166
|
+
}));
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
3
170
|
// Copyright 2024 IOTA Stiftung.
|
|
4
171
|
// SPDX-License-Identifier: Apache-2.0.
|
|
5
172
|
/**
|
|
@@ -8,4 +175,21 @@ import { Factory } from '@twin.org/core';
|
|
|
8
175
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
9
176
|
const BlobStorageConnectorFactory = Factory.createFactory("blob-storage");
|
|
10
177
|
|
|
11
|
-
|
|
178
|
+
// Copyright 2024 IOTA Stiftung.
|
|
179
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
180
|
+
/**
|
|
181
|
+
* The types of compression for blob storage data.
|
|
182
|
+
*/
|
|
183
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
184
|
+
const BlobStorageCompressionType = {
|
|
185
|
+
/**
|
|
186
|
+
* Gzip.
|
|
187
|
+
*/
|
|
188
|
+
Gzip: "gzip",
|
|
189
|
+
/**
|
|
190
|
+
* Deflate.
|
|
191
|
+
*/
|
|
192
|
+
Deflate: "deflate"
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
export { BlobStorageCompressionType, BlobStorageConnectorFactory, BlobStorageContexts, BlobStorageDataTypes, BlobStorageTypes };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
|
+
export * from "./dataTypes/blobStorageDataTypes";
|
|
1
2
|
export * from "./factories/blobStorageConnectorFactory";
|
|
2
3
|
export * from "./models/api/IBlobStorageCreateRequest";
|
|
3
4
|
export * from "./models/api/IBlobStorageGetContentRequest";
|
|
4
5
|
export * from "./models/api/IBlobStorageGetContentResponse";
|
|
5
6
|
export * from "./models/api/IBlobStorageGetRequest";
|
|
6
7
|
export * from "./models/api/IBlobStorageGetResponse";
|
|
8
|
+
export * from "./models/api/IBlobStorageListRequest";
|
|
9
|
+
export * from "./models/api/IBlobStorageListResponse";
|
|
7
10
|
export * from "./models/api/IBlobStorageRemoveRequest";
|
|
8
11
|
export * from "./models/api/IBlobStorageUpdateRequest";
|
|
12
|
+
export * from "./models/blobStorageCompressionType";
|
|
13
|
+
export * from "./models/blobStorageContexts";
|
|
14
|
+
export * from "./models/blobStorageTypes";
|
|
9
15
|
export * from "./models/IBlobStorageComponent";
|
|
10
16
|
export * from "./models/IBlobStorageConnector";
|
|
17
|
+
export * from "./models/IBlobStorageEntry";
|
|
18
|
+
export * from "./models/IBlobStorageEntryList";
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { IComponent } from "@twin.org/core";
|
|
2
2
|
import type { IJsonLdNodeObject } from "@twin.org/data-json-ld";
|
|
3
|
+
import type { EntityCondition, SortDirection } from "@twin.org/entity";
|
|
4
|
+
import type { BlobStorageCompressionType } from "./blobStorageCompressionType";
|
|
5
|
+
import type { IBlobStorageEntry } from "./IBlobStorageEntry";
|
|
6
|
+
import type { IBlobStorageEntryList } from "./IBlobStorageEntryList";
|
|
3
7
|
/**
|
|
4
8
|
* Interface describing an blob storage component.
|
|
5
9
|
*/
|
|
@@ -7,43 +11,73 @@ export interface IBlobStorageComponent extends IComponent {
|
|
|
7
11
|
/**
|
|
8
12
|
* Create the blob with some metadata.
|
|
9
13
|
* @param blob The data for the blob in base64 format.
|
|
10
|
-
* @param
|
|
11
|
-
* @param
|
|
14
|
+
* @param encodingFormat Mime type for the blob, will be detected if left undefined.
|
|
15
|
+
* @param fileExtension Extension for the blob, will be detected if left undefined.
|
|
12
16
|
* @param metadata Data for the custom metadata as JSON-LD.
|
|
13
|
-
* @param
|
|
14
|
-
* @param
|
|
17
|
+
* @param options Optional options for the creation of the blob.
|
|
18
|
+
* @param options.disableEncryption Disables encryption if enabled by default.
|
|
19
|
+
* @param options.overrideVaultKeyId Use a different vault key id for encryption, if not provided the default vault key id will be used.
|
|
20
|
+
* @param options.compress Optional compression type to use for the blob, defaults to no compression.
|
|
21
|
+
* @param options.namespace The namespace to use for storing, defaults to component configured namespace.
|
|
22
|
+
* @param userIdentity The user identity to use with storage operations.
|
|
23
|
+
* @param nodeIdentity The node identity to use with storage operations.
|
|
15
24
|
* @returns The id of the stored blob in urn format.
|
|
16
25
|
*/
|
|
17
|
-
create(blob: string,
|
|
26
|
+
create(blob: string, encodingFormat?: string, fileExtension?: string, metadata?: IJsonLdNodeObject, options?: {
|
|
27
|
+
disableEncryption?: boolean;
|
|
28
|
+
overrideVaultKeyId?: string;
|
|
29
|
+
compress?: BlobStorageCompressionType;
|
|
30
|
+
namespace?: string;
|
|
31
|
+
}, userIdentity?: string, nodeIdentity?: string): Promise<string>;
|
|
18
32
|
/**
|
|
19
33
|
* Get the blob and metadata.
|
|
20
34
|
* @param id The id of the blob to get in urn format.
|
|
21
|
-
* @param
|
|
22
|
-
* @param
|
|
35
|
+
* @param options Optional options for the retrieval of the blob.
|
|
36
|
+
* @param options.includeContent Include the content, or just get the metadata.
|
|
37
|
+
* @param options.overrideVaultKeyId Use a different vault key id for decryption, if not provided the default vault key id will be used.
|
|
38
|
+
* @param options.decompress If the content should be decompressed, if it was compressed when stored, defaults to true.
|
|
39
|
+
* @param userIdentity The user identity to use with storage operations.
|
|
40
|
+
* @param nodeIdentity The node identity to use with storage operations.
|
|
23
41
|
* @returns The data and metadata for the blob if it can be found.
|
|
24
42
|
* @throws Not found error if the blob cannot be found.
|
|
25
43
|
*/
|
|
26
|
-
get(id: string,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}>;
|
|
44
|
+
get(id: string, options?: {
|
|
45
|
+
includeContent?: boolean;
|
|
46
|
+
decompress?: boolean;
|
|
47
|
+
overrideVaultKeyId?: string;
|
|
48
|
+
}, userIdentity?: string, nodeIdentity?: string): Promise<IBlobStorageEntry>;
|
|
32
49
|
/**
|
|
33
50
|
* Update the blob with metadata.
|
|
34
51
|
* @param id The id of the blob metadata to update.
|
|
35
|
-
* @param
|
|
36
|
-
* @param
|
|
52
|
+
* @param encodingFormat Mime type for the blob, will be detected if left undefined.
|
|
53
|
+
* @param fileExtension Extension for the blob, will be detected if left undefined.
|
|
37
54
|
* @param metadata Data for the custom metadata as JSON-LD.
|
|
55
|
+
* @param userIdentity The user identity to use with storage operations.
|
|
56
|
+
* @param nodeIdentity The node identity to use with storage operations.
|
|
38
57
|
* @returns Nothing.
|
|
39
58
|
* @throws Not found error if the blob cannot be found.
|
|
40
59
|
*/
|
|
41
|
-
update(id: string,
|
|
60
|
+
update(id: string, encodingFormat?: string, fileExtension?: string, metadata?: IJsonLdNodeObject, userIdentity?: string, nodeIdentity?: string): Promise<void>;
|
|
42
61
|
/**
|
|
43
62
|
* Remove the blob.
|
|
44
63
|
* @param id The id of the blob to remove in urn format.
|
|
64
|
+
* @param userIdentity The user identity to use with storage operations.
|
|
65
|
+
* @param nodeIdentity The node identity to use with storage operations.
|
|
45
66
|
* @returns Nothing.
|
|
46
67
|
* @throws Not found error if the blob cannot be found.
|
|
47
68
|
*/
|
|
48
|
-
remove(id: string): Promise<void>;
|
|
69
|
+
remove(id: string, userIdentity?: string, nodeIdentity?: string): Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* Query all the blob storage entries which match the conditions.
|
|
72
|
+
* @param conditions The conditions to match for the entries.
|
|
73
|
+
* @param orderBy The order for the results, defaults to created.
|
|
74
|
+
* @param orderByDirection The direction for the order, defaults to descending.
|
|
75
|
+
* @param cursor The cursor to request the next page of entries.
|
|
76
|
+
* @param pageSize The suggested number of entries to return in each chunk, in some scenarios can return a different amount.
|
|
77
|
+
* @param userIdentity The user identity to use with storage operations.
|
|
78
|
+
* @param nodeIdentity The node identity to use with storage operations.
|
|
79
|
+
* @returns All the entries for the storage matching the conditions,
|
|
80
|
+
* and a cursor which can be used to request more entities.
|
|
81
|
+
*/
|
|
82
|
+
query(conditions?: EntityCondition<IBlobStorageEntry>, orderBy?: keyof Pick<IBlobStorageEntry, "dateCreated" | "dateModified">, orderByDirection?: SortDirection, cursor?: string, pageSize?: number, userIdentity?: string, nodeIdentity?: string): Promise<IBlobStorageEntryList>;
|
|
49
83
|
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { IJsonLdContextDefinitionElement, IJsonLdNodeObject } from "@twin.org/data-json-ld";
|
|
2
|
+
import type { BlobStorageCompressionType } from "./blobStorageCompressionType";
|
|
3
|
+
import type { BlobStorageContexts } from "./blobStorageContexts";
|
|
4
|
+
import type { BlobStorageTypes } from "./blobStorageTypes";
|
|
5
|
+
/**
|
|
6
|
+
* Interface describing a blob storage entry.
|
|
7
|
+
*/
|
|
8
|
+
export interface IBlobStorageEntry {
|
|
9
|
+
/**
|
|
10
|
+
* JSON-LD Context.
|
|
11
|
+
*/
|
|
12
|
+
"@context": [
|
|
13
|
+
typeof BlobStorageContexts.ContextRoot,
|
|
14
|
+
typeof BlobStorageContexts.ContextRootCommon,
|
|
15
|
+
...IJsonLdContextDefinitionElement[]
|
|
16
|
+
];
|
|
17
|
+
/**
|
|
18
|
+
* JSON-LD Type.
|
|
19
|
+
*/
|
|
20
|
+
type: typeof BlobStorageTypes.Entry;
|
|
21
|
+
/**
|
|
22
|
+
* The id for the blob.
|
|
23
|
+
*/
|
|
24
|
+
id: string;
|
|
25
|
+
/**
|
|
26
|
+
* The date/time when the entry was created.
|
|
27
|
+
*/
|
|
28
|
+
dateCreated: string;
|
|
29
|
+
/**
|
|
30
|
+
* The date/time when the entry was modified.
|
|
31
|
+
*/
|
|
32
|
+
dateModified?: string;
|
|
33
|
+
/**
|
|
34
|
+
* The size of the data in the blob.
|
|
35
|
+
*/
|
|
36
|
+
blobSize: number;
|
|
37
|
+
/**
|
|
38
|
+
* The hash of the data in the blob.
|
|
39
|
+
*/
|
|
40
|
+
blobHash: string;
|
|
41
|
+
/**
|
|
42
|
+
* The mime type for the blob.
|
|
43
|
+
*/
|
|
44
|
+
encodingFormat?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Indicates if the blob is encrypted.
|
|
47
|
+
*/
|
|
48
|
+
isEncrypted?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* The type of compression used for the blob, if not set it is not stored with compression.
|
|
51
|
+
*/
|
|
52
|
+
compression?: BlobStorageCompressionType;
|
|
53
|
+
/**
|
|
54
|
+
* The extension.
|
|
55
|
+
*/
|
|
56
|
+
fileExtension?: string;
|
|
57
|
+
/**
|
|
58
|
+
* The metadata for the blob as JSON-LD.
|
|
59
|
+
*/
|
|
60
|
+
metadata?: IJsonLdNodeObject;
|
|
61
|
+
/**
|
|
62
|
+
* The blob in base64 format, included if the includeContent flag was set in the request.
|
|
63
|
+
*/
|
|
64
|
+
blob?: string;
|
|
65
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { IJsonLdContextDefinitionElement } from "@twin.org/data-json-ld";
|
|
2
|
+
import type { SchemaOrgContexts, SchemaOrgTypes } from "@twin.org/standards-schema-org";
|
|
3
|
+
import type { BlobStorageContexts } from "./blobStorageContexts";
|
|
4
|
+
import type { IBlobStorageEntry } from "./IBlobStorageEntry";
|
|
5
|
+
/**
|
|
6
|
+
* Interface describing an blob storage entry list.
|
|
7
|
+
*/
|
|
8
|
+
export interface IBlobStorageEntryList {
|
|
9
|
+
/**
|
|
10
|
+
* JSON-LD Context.
|
|
11
|
+
*/
|
|
12
|
+
"@context": [
|
|
13
|
+
typeof SchemaOrgContexts.ContextRoot,
|
|
14
|
+
typeof BlobStorageContexts.ContextRoot,
|
|
15
|
+
typeof BlobStorageContexts.ContextRootCommon,
|
|
16
|
+
...IJsonLdContextDefinitionElement[]
|
|
17
|
+
];
|
|
18
|
+
/**
|
|
19
|
+
* JSON-LD Type.
|
|
20
|
+
*/
|
|
21
|
+
type: typeof SchemaOrgTypes.ItemList;
|
|
22
|
+
/**
|
|
23
|
+
* The list of entries.
|
|
24
|
+
*/
|
|
25
|
+
[SchemaOrgTypes.ItemListElement]: IBlobStorageEntry[];
|
|
26
|
+
/**
|
|
27
|
+
* The cursor to get the next chunk of entries.
|
|
28
|
+
*/
|
|
29
|
+
[SchemaOrgTypes.NextItem]?: string;
|
|
30
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { IJsonLdNodeObject } from "@twin.org/data-json-ld";
|
|
2
|
+
import type { BlobStorageCompressionType } from "../blobStorageCompressionType";
|
|
2
3
|
/**
|
|
3
4
|
* Request to create an entry in blob storage.
|
|
4
5
|
*/
|
|
@@ -14,15 +15,29 @@ export interface IBlobStorageCreateRequest {
|
|
|
14
15
|
/**
|
|
15
16
|
* The mime type of the blob, will be detected if left undefined.
|
|
16
17
|
*/
|
|
17
|
-
|
|
18
|
+
encodingFormat?: string;
|
|
18
19
|
/**
|
|
19
20
|
* The extension of the blob, will be detected if left undefined.
|
|
20
21
|
*/
|
|
21
|
-
|
|
22
|
+
fileExtension?: string;
|
|
22
23
|
/**
|
|
23
24
|
* Custom metadata to associate with the blob as JSON-LD.
|
|
24
25
|
*/
|
|
25
26
|
metadata?: IJsonLdNodeObject;
|
|
27
|
+
/**
|
|
28
|
+
* Disables encryption if enabled by default.
|
|
29
|
+
* @default false
|
|
30
|
+
*/
|
|
31
|
+
disableEncryption?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Optional compression type to use for the blob, defaults to no compression.
|
|
34
|
+
*/
|
|
35
|
+
compress?: BlobStorageCompressionType;
|
|
36
|
+
/**
|
|
37
|
+
* Use a different vault key id for encryption, if not provided the default vault key id will be used.
|
|
38
|
+
* @default undefined
|
|
39
|
+
*/
|
|
40
|
+
overrideVaultKeyId?: string;
|
|
26
41
|
/**
|
|
27
42
|
* The namespace to store the data in, defaults to component configured namespace.
|
|
28
43
|
*/
|
|
@@ -15,12 +15,22 @@ export interface IBlobStorageGetContentRequest {
|
|
|
15
15
|
* The query parameters.
|
|
16
16
|
*/
|
|
17
17
|
query?: {
|
|
18
|
+
/**
|
|
19
|
+
* If the content should be decompressed, if it was compressed when stored, defaults to true.
|
|
20
|
+
* @default true
|
|
21
|
+
*/
|
|
22
|
+
decompress?: boolean | string;
|
|
23
|
+
/**
|
|
24
|
+
* Use a different vault key id for decryption, if not provided the default vault key id will be used.
|
|
25
|
+
* @default undefined
|
|
26
|
+
*/
|
|
27
|
+
overrideVaultKeyId?: string;
|
|
18
28
|
/**
|
|
19
29
|
* Set the download flag which should prompt the browser to save the file.
|
|
20
30
|
* Otherwise the browser should show the content inside the page.
|
|
21
31
|
* @default false
|
|
22
32
|
*/
|
|
23
|
-
download?: boolean;
|
|
33
|
+
download?: boolean | string;
|
|
24
34
|
/**
|
|
25
35
|
* Set the filename to use when a download is triggered.
|
|
26
36
|
* A filename will be generated if not provided.
|