@twin.org/blob-storage-connector-ipfs 0.0.1-next.3 → 0.0.1-next.5

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.
@@ -58,9 +58,8 @@ class IpfsBlobStorageConnector {
58
58
  const result = (await response.json());
59
59
  return `blob:${new core.Urn(IpfsBlobStorageConnector.NAMESPACE, result.Hash).toString()}`;
60
60
  }
61
- throw new core.GeneralError(this.CLASS_NAME, "fetchFail", {
62
- message: response.statusText
63
- });
61
+ const error = await response.json();
62
+ throw new core.GeneralError(this.CLASS_NAME, "fetchFail", error);
64
63
  }
65
64
  catch (err) {
66
65
  throw new core.GeneralError(this.CLASS_NAME, "setBlobFailed", undefined, err);
@@ -93,8 +92,12 @@ class IpfsBlobStorageConnector {
93
92
  const result = await response.arrayBuffer();
94
93
  return new Uint8Array(result);
95
94
  }
95
+ const error = await response.json();
96
+ throw new core.GeneralError(this.CLASS_NAME, "fetchFail", error);
97
+ }
98
+ catch (err) {
99
+ throw new core.GeneralError(this.CLASS_NAME, "getBlobFailed", undefined, err);
96
100
  }
97
- catch { }
98
101
  }
99
102
  /**
100
103
  * Remove the blob.
@@ -122,9 +125,12 @@ class IpfsBlobStorageConnector {
122
125
  if (response.ok) {
123
126
  return true;
124
127
  }
128
+ const error = await response.json();
129
+ throw new core.GeneralError(this.CLASS_NAME, "fetchFail", error);
130
+ }
131
+ catch (err) {
132
+ throw new core.GeneralError(this.CLASS_NAME, "removeBlobFailed", undefined, err);
125
133
  }
126
- catch { }
127
- return false;
128
134
  }
129
135
  /**
130
136
  * Add the security to the request.
@@ -56,9 +56,8 @@ class IpfsBlobStorageConnector {
56
56
  const result = (await response.json());
57
57
  return `blob:${new Urn(IpfsBlobStorageConnector.NAMESPACE, result.Hash).toString()}`;
58
58
  }
59
- throw new GeneralError(this.CLASS_NAME, "fetchFail", {
60
- message: response.statusText
61
- });
59
+ const error = await response.json();
60
+ throw new GeneralError(this.CLASS_NAME, "fetchFail", error);
62
61
  }
63
62
  catch (err) {
64
63
  throw new GeneralError(this.CLASS_NAME, "setBlobFailed", undefined, err);
@@ -91,8 +90,12 @@ class IpfsBlobStorageConnector {
91
90
  const result = await response.arrayBuffer();
92
91
  return new Uint8Array(result);
93
92
  }
93
+ const error = await response.json();
94
+ throw new GeneralError(this.CLASS_NAME, "fetchFail", error);
95
+ }
96
+ catch (err) {
97
+ throw new GeneralError(this.CLASS_NAME, "getBlobFailed", undefined, err);
94
98
  }
95
- catch { }
96
99
  }
97
100
  /**
98
101
  * Remove the blob.
@@ -120,9 +123,12 @@ class IpfsBlobStorageConnector {
120
123
  if (response.ok) {
121
124
  return true;
122
125
  }
126
+ const error = await response.json();
127
+ throw new GeneralError(this.CLASS_NAME, "fetchFail", error);
128
+ }
129
+ catch (err) {
130
+ throw new GeneralError(this.CLASS_NAME, "removeBlobFailed", undefined, err);
123
131
  }
124
- catch { }
125
- return false;
126
132
  }
127
133
  /**
128
134
  * Add the security to the request.
package/docs/changelog.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # @twin.org/blob-storage-connector-ipfs - Changelog
2
2
 
3
- ## v0.0.1-next.3
3
+ ## v0.0.1-next.5
4
4
 
5
5
  - Initial Release
package/locales/en.json CHANGED
@@ -3,7 +3,9 @@
3
3
  "ipfsBlobStorageConnector": {
4
4
  "namespaceMismatch": "The namespace in the urn \"{id}\" does not match the namespace of the blob storage \"{namespace}\"",
5
5
  "fetchFail": "Failure during IPFS fetch \"{message}\"",
6
- "setBlobFailed": "Failed to store blob in IPFS"
6
+ "setBlobFailed": "Failed to store blob in IPFS",
7
+ "getBlobFailed": "Failed to get blob from IPFS",
8
+ "removeBlobFailed": "Failed to remove blob from IPFS"
7
9
  }
8
10
  }
9
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/blob-storage-connector-ipfs",
3
- "version": "0.0.1-next.3",
3
+ "version": "0.0.1-next.5",
4
4
  "description": "Blob Storage connector implementation using IPFS",
5
5
  "repository": {
6
6
  "type": "git",
@@ -13,41 +13,13 @@
13
13
  "engines": {
14
14
  "node": ">=20.0.0"
15
15
  },
16
- "scripts": {
17
- "clean": "rimraf dist coverage docs/reference",
18
- "build": "tspc",
19
- "test": "vitest --run --config ./vitest.config.ts --no-cache",
20
- "coverage": "vitest --run --coverage --config ./vitest.config.ts --no-cache",
21
- "bundle:esm": "rollup --config rollup.config.mjs --environment MODULE:esm",
22
- "bundle:cjs": "rollup --config rollup.config.mjs --environment MODULE:cjs",
23
- "bundle": "npm run bundle:esm && npm run bundle:cjs",
24
- "docs:clean": "rimraf docs/reference",
25
- "docs:generate": "typedoc",
26
- "docs": "npm run docs:clean && npm run docs:generate",
27
- "dist": "npm run clean && npm run build && npm run test && npm run bundle && npm run docs"
28
- },
29
16
  "dependencies": {
30
- "@twin.org/blob-storage-models": "0.0.1-next.3",
17
+ "@twin.org/blob-storage-models": "0.0.1-next.5",
31
18
  "@twin.org/core": "next",
32
19
  "@twin.org/crypto": "next",
33
20
  "@twin.org/nameof": "next",
34
21
  "@twin.org/web": "next"
35
22
  },
36
- "devDependencies": {
37
- "@twin.org/nameof-transformer": "next",
38
- "@vitest/coverage-v8": "2.1.1",
39
- "copyfiles": "2.4.1",
40
- "dotenv": "16.4.5",
41
- "rimraf": "6.0.1",
42
- "rollup": "4.22.0",
43
- "rollup-plugin-copy": "3.5.0",
44
- "rollup-plugin-typescript2": "0.36.0",
45
- "ts-patch": "3.2.1",
46
- "typedoc": "0.26.7",
47
- "typedoc-plugin-markdown": "4.2.7",
48
- "typescript": "5.6.2",
49
- "vitest": "2.1.1"
50
- },
51
23
  "main": "./dist/cjs/index.cjs",
52
24
  "module": "./dist/esm/index.mjs",
53
25
  "types": "./dist/types/index.d.ts",