@dexto/storage 1.16.6 → 1.17.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.
- package/dist/blob/local-blob-store.cjs +4 -19
- package/dist/blob/local-blob-store.d.ts +0 -4
- package/dist/blob/local-blob-store.d.ts.map +1 -1
- package/dist/blob/local-blob-store.js +4 -19
- package/dist/blob/memory-blob-store.cjs +4 -20
- package/dist/blob/memory-blob-store.d.ts +0 -5
- package/dist/blob/memory-blob-store.d.ts.map +1 -1
- package/dist/blob/memory-blob-store.js +4 -20
- package/dist/blob/reference.cjs +42 -0
- package/dist/blob/reference.d.ts +3 -0
- package/dist/blob/reference.d.ts.map +1 -0
- package/dist/blob/reference.js +18 -0
- package/dist/index.d.cts +0 -9
- package/package.json +2 -2
|
@@ -36,6 +36,7 @@ var import_path = __toESM(require("path"), 1);
|
|
|
36
36
|
var import_crypto = require("crypto");
|
|
37
37
|
var import_url = require("url");
|
|
38
38
|
var import_core = require("@dexto/core");
|
|
39
|
+
var import_reference = require("./reference.js");
|
|
39
40
|
function isPlainObject(value) {
|
|
40
41
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
41
42
|
}
|
|
@@ -192,7 +193,7 @@ class LocalBlobStore {
|
|
|
192
193
|
if (!this.connected) {
|
|
193
194
|
throw import_core.StorageError.blobBackendNotConnected("local");
|
|
194
195
|
}
|
|
195
|
-
const id =
|
|
196
|
+
const id = (0, import_reference.parseBlobReference)(reference);
|
|
196
197
|
const blobPath = import_path.default.join(this.storePath, `${id}.dat`);
|
|
197
198
|
const metaPath = import_path.default.join(this.storePath, `${id}.meta.json`);
|
|
198
199
|
try {
|
|
@@ -238,7 +239,7 @@ class LocalBlobStore {
|
|
|
238
239
|
if (!this.connected) {
|
|
239
240
|
throw import_core.StorageError.blobBackendNotConnected("local");
|
|
240
241
|
}
|
|
241
|
-
const id =
|
|
242
|
+
const id = (0, import_reference.parseBlobReference)(reference);
|
|
242
243
|
const blobPath = import_path.default.join(this.storePath, `${id}.dat`);
|
|
243
244
|
const metaPath = import_path.default.join(this.storePath, `${id}.meta.json`);
|
|
244
245
|
try {
|
|
@@ -252,7 +253,7 @@ class LocalBlobStore {
|
|
|
252
253
|
if (!this.connected) {
|
|
253
254
|
throw import_core.StorageError.blobBackendNotConnected("local");
|
|
254
255
|
}
|
|
255
|
-
const id =
|
|
256
|
+
const id = (0, import_reference.parseBlobReference)(reference);
|
|
256
257
|
const blobPath = import_path.default.join(this.storePath, `${id}.dat`);
|
|
257
258
|
const metaPath = import_path.default.join(this.storePath, `${id}.meta.json`);
|
|
258
259
|
try {
|
|
@@ -453,22 +454,6 @@ class LocalBlobStore {
|
|
|
453
454
|
}
|
|
454
455
|
throw import_core.StorageError.blobInvalidInput(input, `Unsupported input type: ${typeof input}`);
|
|
455
456
|
}
|
|
456
|
-
/**
|
|
457
|
-
* Parse blob reference to extract ID
|
|
458
|
-
*/
|
|
459
|
-
parseReference(reference) {
|
|
460
|
-
if (!reference) {
|
|
461
|
-
throw import_core.StorageError.blobInvalidReference(reference, "Empty reference");
|
|
462
|
-
}
|
|
463
|
-
if (reference.startsWith("blob:")) {
|
|
464
|
-
const id = reference.substring(5);
|
|
465
|
-
if (!id) {
|
|
466
|
-
throw import_core.StorageError.blobInvalidReference(reference, "Empty blob ID after prefix");
|
|
467
|
-
}
|
|
468
|
-
return id;
|
|
469
|
-
}
|
|
470
|
-
return reference;
|
|
471
|
-
}
|
|
472
457
|
/**
|
|
473
458
|
* Detect MIME type from buffer content and/or filename
|
|
474
459
|
*/
|
|
@@ -38,10 +38,6 @@ export declare class LocalBlobStore implements BlobStore {
|
|
|
38
38
|
* Convert various input types to Buffer
|
|
39
39
|
*/
|
|
40
40
|
private inputToBuffer;
|
|
41
|
-
/**
|
|
42
|
-
* Parse blob reference to extract ID
|
|
43
|
-
*/
|
|
44
|
-
private parseReference;
|
|
45
41
|
/**
|
|
46
42
|
* Detect MIME type from buffer content and/or filename
|
|
47
43
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-blob-store.d.ts","sourceRoot":"","sources":["../../src/blob/local-blob-store.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,KAAK,EACR,SAAS,EACT,SAAS,EACT,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,SAAS,EAEZ,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"local-blob-store.d.ts","sourceRoot":"","sources":["../../src/blob/local-blob-store.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,KAAK,EACR,SAAS,EACT,SAAS,EACT,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,SAAS,EAEZ,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAmEzD;;;;;;GAMG;AACH,qBAAa,cAAe,YAAW,SAAS;IAC5C,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,UAAU,CAAqD;IACvE,OAAO,CAAC,iBAAiB,CAA8B;IACvD,OAAO,CAAC,gBAAgB,CAAa;IACrC,OAAO,CAAC,MAAM,CAAS;IAEvB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,yBAAyB,CAAS;gBAE9C,MAAM,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM;IAOlD,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAoBxB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAKjC,WAAW,IAAI,OAAO;IAItB,YAAY,IAAI,MAAM;IAIhB,KAAK,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,GAAE,YAAiB,GAAG,OAAO,CAAC,aAAa,CAAC;IAyF5E,QAAQ,CACV,SAAS,EAAE,MAAM,EACjB,MAAM,GAAE,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAgB,GACnE,OAAO,CAAC,QAAQ,CAAC;IAsDd,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAiB3C,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAwBxC,OAAO,CAAC,SAAS,CAAC,EAAE,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC;IAiD1C,QAAQ,IAAI,OAAO,CAAC,SAAS,CAAC;IAepC,cAAc,IAAI,MAAM,GAAG,SAAS;IAI9B,SAAS,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;YAqC7B,gBAAgB;YAsBhB,iBAAiB;IAwB/B,OAAO,CAAC,0BAA0B;IASlC,OAAO,CAAC,2BAA2B;IASnC;;OAEG;YACW,aAAa;IAgD3B;;OAEG;IACH,OAAO,CAAC,cAAc;IAiDtB;;OAEG;IACH,OAAO,CAAC,YAAY;CAiBvB"}
|
|
@@ -3,6 +3,7 @@ import path from "path";
|
|
|
3
3
|
import { createHash } from "crypto";
|
|
4
4
|
import { pathToFileURL } from "url";
|
|
5
5
|
import { DextoLogComponent, StorageError } from "@dexto/core";
|
|
6
|
+
import { parseBlobReference } from "./reference.js";
|
|
6
7
|
function isPlainObject(value) {
|
|
7
8
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8
9
|
}
|
|
@@ -159,7 +160,7 @@ class LocalBlobStore {
|
|
|
159
160
|
if (!this.connected) {
|
|
160
161
|
throw StorageError.blobBackendNotConnected("local");
|
|
161
162
|
}
|
|
162
|
-
const id =
|
|
163
|
+
const id = parseBlobReference(reference);
|
|
163
164
|
const blobPath = path.join(this.storePath, `${id}.dat`);
|
|
164
165
|
const metaPath = path.join(this.storePath, `${id}.meta.json`);
|
|
165
166
|
try {
|
|
@@ -205,7 +206,7 @@ class LocalBlobStore {
|
|
|
205
206
|
if (!this.connected) {
|
|
206
207
|
throw StorageError.blobBackendNotConnected("local");
|
|
207
208
|
}
|
|
208
|
-
const id =
|
|
209
|
+
const id = parseBlobReference(reference);
|
|
209
210
|
const blobPath = path.join(this.storePath, `${id}.dat`);
|
|
210
211
|
const metaPath = path.join(this.storePath, `${id}.meta.json`);
|
|
211
212
|
try {
|
|
@@ -219,7 +220,7 @@ class LocalBlobStore {
|
|
|
219
220
|
if (!this.connected) {
|
|
220
221
|
throw StorageError.blobBackendNotConnected("local");
|
|
221
222
|
}
|
|
222
|
-
const id =
|
|
223
|
+
const id = parseBlobReference(reference);
|
|
223
224
|
const blobPath = path.join(this.storePath, `${id}.dat`);
|
|
224
225
|
const metaPath = path.join(this.storePath, `${id}.meta.json`);
|
|
225
226
|
try {
|
|
@@ -420,22 +421,6 @@ class LocalBlobStore {
|
|
|
420
421
|
}
|
|
421
422
|
throw StorageError.blobInvalidInput(input, `Unsupported input type: ${typeof input}`);
|
|
422
423
|
}
|
|
423
|
-
/**
|
|
424
|
-
* Parse blob reference to extract ID
|
|
425
|
-
*/
|
|
426
|
-
parseReference(reference) {
|
|
427
|
-
if (!reference) {
|
|
428
|
-
throw StorageError.blobInvalidReference(reference, "Empty reference");
|
|
429
|
-
}
|
|
430
|
-
if (reference.startsWith("blob:")) {
|
|
431
|
-
const id = reference.substring(5);
|
|
432
|
-
if (!id) {
|
|
433
|
-
throw StorageError.blobInvalidReference(reference, "Empty blob ID after prefix");
|
|
434
|
-
}
|
|
435
|
-
return id;
|
|
436
|
-
}
|
|
437
|
-
return reference;
|
|
438
|
-
}
|
|
439
424
|
/**
|
|
440
425
|
* Detect MIME type from buffer content and/or filename
|
|
441
426
|
*/
|
|
@@ -24,6 +24,7 @@ module.exports = __toCommonJS(memory_blob_store_exports);
|
|
|
24
24
|
var import_crypto = require("crypto");
|
|
25
25
|
var import_stream = require("stream");
|
|
26
26
|
var import_core = require("@dexto/core");
|
|
27
|
+
var import_reference = require("./reference.js");
|
|
27
28
|
var import_schemas = require("./schemas.js");
|
|
28
29
|
const MemoryBlobStoreOptionsSchema = import_schemas.InMemoryBlobStoreSchema.omit({ type: true });
|
|
29
30
|
class MemoryBlobStore {
|
|
@@ -100,7 +101,7 @@ class MemoryBlobStore {
|
|
|
100
101
|
if (!this.connected) {
|
|
101
102
|
throw import_core.StorageError.blobBackendNotConnected("in-memory");
|
|
102
103
|
}
|
|
103
|
-
const id =
|
|
104
|
+
const id = (0, import_reference.parseBlobReference)(reference);
|
|
104
105
|
const blob = this.blobs.get(id);
|
|
105
106
|
if (!blob) {
|
|
106
107
|
throw import_core.StorageError.blobNotFound(reference);
|
|
@@ -148,14 +149,14 @@ class MemoryBlobStore {
|
|
|
148
149
|
if (!this.connected) {
|
|
149
150
|
throw import_core.StorageError.blobBackendNotConnected("in-memory");
|
|
150
151
|
}
|
|
151
|
-
const id =
|
|
152
|
+
const id = (0, import_reference.parseBlobReference)(reference);
|
|
152
153
|
return this.blobs.has(id);
|
|
153
154
|
}
|
|
154
155
|
async delete(reference) {
|
|
155
156
|
if (!this.connected) {
|
|
156
157
|
throw import_core.StorageError.blobBackendNotConnected("in-memory");
|
|
157
158
|
}
|
|
158
|
-
const id =
|
|
159
|
+
const id = (0, import_reference.parseBlobReference)(reference);
|
|
159
160
|
if (!this.blobs.has(id)) {
|
|
160
161
|
throw import_core.StorageError.blobNotFound(reference);
|
|
161
162
|
}
|
|
@@ -244,23 +245,6 @@ class MemoryBlobStore {
|
|
|
244
245
|
}
|
|
245
246
|
throw import_core.StorageError.blobInvalidInput(input, `Unsupported input type: ${typeof input}`);
|
|
246
247
|
}
|
|
247
|
-
/**
|
|
248
|
-
* Parse blob reference to extract ID.
|
|
249
|
-
* Copied from LocalBlobStore.
|
|
250
|
-
*/
|
|
251
|
-
parseReference(reference) {
|
|
252
|
-
if (!reference) {
|
|
253
|
-
throw import_core.StorageError.blobInvalidReference(reference, "Empty reference");
|
|
254
|
-
}
|
|
255
|
-
if (reference.startsWith("blob:")) {
|
|
256
|
-
const id = reference.substring(5);
|
|
257
|
-
if (!id) {
|
|
258
|
-
throw import_core.StorageError.blobInvalidReference(reference, "Empty blob ID after prefix");
|
|
259
|
-
}
|
|
260
|
-
return id;
|
|
261
|
-
}
|
|
262
|
-
return reference;
|
|
263
|
-
}
|
|
264
248
|
/**
|
|
265
249
|
* Detect MIME type from buffer content and/or filename.
|
|
266
250
|
* Copied from LocalBlobStore.
|
|
@@ -48,11 +48,6 @@ export declare class MemoryBlobStore implements BlobStore {
|
|
|
48
48
|
* Copied from LocalBlobStore with minor adaptations.
|
|
49
49
|
*/
|
|
50
50
|
private inputToBuffer;
|
|
51
|
-
/**
|
|
52
|
-
* Parse blob reference to extract ID.
|
|
53
|
-
* Copied from LocalBlobStore.
|
|
54
|
-
*/
|
|
55
|
-
private parseReference;
|
|
56
51
|
/**
|
|
57
52
|
* Detect MIME type from buffer content and/or filename.
|
|
58
53
|
* Copied from LocalBlobStore.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory-blob-store.d.ts","sourceRoot":"","sources":["../../src/blob/memory-blob-store.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,KAAK,EACR,SAAS,EACT,SAAS,EACT,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,SAAS,EAEZ,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"memory-blob-store.d.ts","sourceRoot":"","sources":["../../src/blob/memory-blob-store.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,KAAK,EACR,SAAS,EACT,SAAS,EACT,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,SAAS,EAEZ,MAAM,YAAY,CAAC;AAGpB,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAC;AAEjE;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,sBAAsB,GAAG,IAAI,CAAC,4BAA4B,EAAE,MAAM,CAAC,CAAC;AAIhF,qBAAa,eAAgB,YAAW,SAAS;IAC7C,OAAO,CAAC,MAAM,CAAwC;IACtD,OAAO,CAAC,KAAK,CAA0E;IACvF,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,MAAM,CAAS;gBAEX,OAAO,EAAE,sBAAsB,EAAE,MAAM,EAAE,MAAM;IAKrD,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAMxB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAOjC,WAAW,IAAI,OAAO;IAItB,YAAY,IAAI,MAAM;IAIhB,KAAK,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,GAAE,YAAiB,GAAG,OAAO,CAAC,aAAa,CAAC;IA8D5E,QAAQ,CACV,SAAS,EAAE,MAAM,EACjB,MAAM,GAAE,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAgB,GACnE,OAAO,CAAC,QAAQ,CAAC;IA6Dd,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAS3C,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAexC,OAAO,CAAC,SAAS,CAAC,EAAE,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC;IAwB1C,QAAQ,IAAI,OAAO,CAAC,SAAS,CAAC;IAc9B,SAAS,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;IAY3C,cAAc,IAAI,MAAM,GAAG,SAAS;IAKpC;;OAEG;IACH,OAAO,CAAC,YAAY;IAIpB;;;OAGG;YACW,aAAa;IAuC3B;;;OAGG;IACH,OAAO,CAAC,cAAc;IAkDtB;;;OAGG;IACH,OAAO,CAAC,YAAY;CAiBvB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createHash } from "crypto";
|
|
2
2
|
import { Readable } from "stream";
|
|
3
3
|
import { DextoLogComponent, StorageError } from "@dexto/core";
|
|
4
|
+
import { parseBlobReference } from "./reference.js";
|
|
4
5
|
import { InMemoryBlobStoreSchema } from "./schemas.js";
|
|
5
6
|
const MemoryBlobStoreOptionsSchema = InMemoryBlobStoreSchema.omit({ type: true });
|
|
6
7
|
class MemoryBlobStore {
|
|
@@ -77,7 +78,7 @@ class MemoryBlobStore {
|
|
|
77
78
|
if (!this.connected) {
|
|
78
79
|
throw StorageError.blobBackendNotConnected("in-memory");
|
|
79
80
|
}
|
|
80
|
-
const id =
|
|
81
|
+
const id = parseBlobReference(reference);
|
|
81
82
|
const blob = this.blobs.get(id);
|
|
82
83
|
if (!blob) {
|
|
83
84
|
throw StorageError.blobNotFound(reference);
|
|
@@ -125,14 +126,14 @@ class MemoryBlobStore {
|
|
|
125
126
|
if (!this.connected) {
|
|
126
127
|
throw StorageError.blobBackendNotConnected("in-memory");
|
|
127
128
|
}
|
|
128
|
-
const id =
|
|
129
|
+
const id = parseBlobReference(reference);
|
|
129
130
|
return this.blobs.has(id);
|
|
130
131
|
}
|
|
131
132
|
async delete(reference) {
|
|
132
133
|
if (!this.connected) {
|
|
133
134
|
throw StorageError.blobBackendNotConnected("in-memory");
|
|
134
135
|
}
|
|
135
|
-
const id =
|
|
136
|
+
const id = parseBlobReference(reference);
|
|
136
137
|
if (!this.blobs.has(id)) {
|
|
137
138
|
throw StorageError.blobNotFound(reference);
|
|
138
139
|
}
|
|
@@ -221,23 +222,6 @@ class MemoryBlobStore {
|
|
|
221
222
|
}
|
|
222
223
|
throw StorageError.blobInvalidInput(input, `Unsupported input type: ${typeof input}`);
|
|
223
224
|
}
|
|
224
|
-
/**
|
|
225
|
-
* Parse blob reference to extract ID.
|
|
226
|
-
* Copied from LocalBlobStore.
|
|
227
|
-
*/
|
|
228
|
-
parseReference(reference) {
|
|
229
|
-
if (!reference) {
|
|
230
|
-
throw StorageError.blobInvalidReference(reference, "Empty reference");
|
|
231
|
-
}
|
|
232
|
-
if (reference.startsWith("blob:")) {
|
|
233
|
-
const id = reference.substring(5);
|
|
234
|
-
if (!id) {
|
|
235
|
-
throw StorageError.blobInvalidReference(reference, "Empty blob ID after prefix");
|
|
236
|
-
}
|
|
237
|
-
return id;
|
|
238
|
-
}
|
|
239
|
-
return reference;
|
|
240
|
-
}
|
|
241
225
|
/**
|
|
242
226
|
* Detect MIME type from buffer content and/or filename.
|
|
243
227
|
* Copied from LocalBlobStore.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var reference_exports = {};
|
|
20
|
+
__export(reference_exports, {
|
|
21
|
+
parseBlobReference: () => parseBlobReference
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(reference_exports);
|
|
24
|
+
var import_core = require("@dexto/core");
|
|
25
|
+
const BLOB_ID_PATTERN = /^[0-9a-f]{16}$/;
|
|
26
|
+
function parseBlobReference(reference) {
|
|
27
|
+
if (!reference) {
|
|
28
|
+
throw import_core.StorageError.blobInvalidReference(reference, "Empty reference");
|
|
29
|
+
}
|
|
30
|
+
const id = reference.startsWith("blob:") ? reference.substring(5) : reference;
|
|
31
|
+
if (!id) {
|
|
32
|
+
throw import_core.StorageError.blobInvalidReference(reference, "Empty blob ID after prefix");
|
|
33
|
+
}
|
|
34
|
+
if (!BLOB_ID_PATTERN.test(id)) {
|
|
35
|
+
throw import_core.StorageError.blobInvalidReference(reference, "Blob ID is not a valid blob id");
|
|
36
|
+
}
|
|
37
|
+
return id;
|
|
38
|
+
}
|
|
39
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
+
0 && (module.exports = {
|
|
41
|
+
parseBlobReference
|
|
42
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reference.d.ts","sourceRoot":"","sources":["../../src/blob/reference.ts"],"names":[],"mappings":"AAKA,mGAAmG;AACnG,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAa5D"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { StorageError } from "@dexto/core";
|
|
2
|
+
const BLOB_ID_PATTERN = /^[0-9a-f]{16}$/;
|
|
3
|
+
function parseBlobReference(reference) {
|
|
4
|
+
if (!reference) {
|
|
5
|
+
throw StorageError.blobInvalidReference(reference, "Empty reference");
|
|
6
|
+
}
|
|
7
|
+
const id = reference.startsWith("blob:") ? reference.substring(5) : reference;
|
|
8
|
+
if (!id) {
|
|
9
|
+
throw StorageError.blobInvalidReference(reference, "Empty blob ID after prefix");
|
|
10
|
+
}
|
|
11
|
+
if (!BLOB_ID_PATTERN.test(id)) {
|
|
12
|
+
throw StorageError.blobInvalidReference(reference, "Blob ID is not a valid blob id");
|
|
13
|
+
}
|
|
14
|
+
return id;
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
parseBlobReference
|
|
18
|
+
};
|
package/dist/index.d.cts
CHANGED
|
@@ -227,10 +227,6 @@ declare class LocalBlobStore implements BlobStore {
|
|
|
227
227
|
* Convert various input types to Buffer
|
|
228
228
|
*/
|
|
229
229
|
private inputToBuffer;
|
|
230
|
-
/**
|
|
231
|
-
* Parse blob reference to extract ID
|
|
232
|
-
*/
|
|
233
|
-
private parseReference;
|
|
234
230
|
/**
|
|
235
231
|
* Detect MIME type from buffer content and/or filename
|
|
236
232
|
*/
|
|
@@ -288,11 +284,6 @@ declare class MemoryBlobStore implements BlobStore {
|
|
|
288
284
|
* Copied from LocalBlobStore with minor adaptations.
|
|
289
285
|
*/
|
|
290
286
|
private inputToBuffer;
|
|
291
|
-
/**
|
|
292
|
-
* Parse blob reference to extract ID.
|
|
293
|
-
* Copied from LocalBlobStore.
|
|
294
|
-
*/
|
|
295
|
-
private parseReference;
|
|
296
287
|
/**
|
|
297
288
|
* Detect MIME type from buffer content and/or filename.
|
|
298
289
|
* Copied from LocalBlobStore.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dexto/storage",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.17.0",
|
|
4
4
|
"description": "Storage backends and config schemas for Dexto agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"zod": "^4.3.6",
|
|
24
|
-
"@dexto/core": "1.
|
|
24
|
+
"@dexto/core": "1.17.0"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"better-sqlite3": "^11.10.0",
|