@internxt/sdk 1.15.8 → 1.15.9
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/network/upload.js +1 -1
- package/dist/shared/http/client.js +9 -15
- package/dist/shared/types/errors.d.ts +14 -0
- package/dist/shared/types/errors.js +29 -0
- package/dist/utils.d.ts +0 -2
- package/dist/utils.js +0 -17
- package/package.json +3 -4
package/dist/network/upload.js
CHANGED
|
@@ -129,7 +129,7 @@ function uploadMultipartFile(network_1, crypto_1, bucketId_1, mnemonic_1, fileSi
|
|
|
129
129
|
index: index.toString('hex'),
|
|
130
130
|
shards: [{ hash: hash, uuid: uuid, UploadId: UploadId, parts: uploadedPartsReference }],
|
|
131
131
|
};
|
|
132
|
-
return [4 /*yield*/, network.
|
|
132
|
+
return [4 /*yield*/, network.finishMultipartUpload(bucketId, finishUploadPayload, signal)];
|
|
133
133
|
case 5:
|
|
134
134
|
finishUploadResponse = _c.sent();
|
|
135
135
|
return [2 /*return*/, finishUploadResponse.id];
|
|
@@ -41,7 +41,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
42
|
exports.HttpClient = void 0;
|
|
43
43
|
var axios_1 = __importDefault(require("axios"));
|
|
44
|
-
var errors_1 =
|
|
44
|
+
var errors_1 = require("../types/errors");
|
|
45
45
|
var retryWithBackoff_1 = require("./retryWithBackoff");
|
|
46
46
|
var HttpClient = /** @class */ (function () {
|
|
47
47
|
function HttpClient(baseURL, unauthorizedCallback, retryOptions) {
|
|
@@ -277,26 +277,20 @@ var HttpClient = /** @class */ (function () {
|
|
|
277
277
|
* @private
|
|
278
278
|
*/
|
|
279
279
|
HttpClient.prototype.normalizeError = function (error) {
|
|
280
|
-
var
|
|
280
|
+
var _a, _b, _c, _d, _e, _f;
|
|
281
|
+
var baseUrl = (_b = (_a = error.config) === null || _a === void 0 ? void 0 : _a.baseURL) !== null && _b !== void 0 ? _b : '';
|
|
282
|
+
var url = (_d = (_c = error.config) === null || _c === void 0 ? void 0 : _c.url) !== null && _d !== void 0 ? _d : '';
|
|
283
|
+
var method = (_f = (_e = error.config) === null || _e === void 0 ? void 0 : _e.method) !== null && _f !== void 0 ? _f : '';
|
|
284
|
+
var request = "".concat(method, " ").concat(baseUrl).concat(url);
|
|
281
285
|
if (error.response) {
|
|
282
|
-
|
|
283
|
-
if (response.status === 401) {
|
|
286
|
+
if (error.response.status === 401) {
|
|
284
287
|
this.unauthorizedCallback();
|
|
285
288
|
}
|
|
286
|
-
|
|
287
|
-
errorStatus = response.status;
|
|
288
|
-
errorCode = response.data.code;
|
|
289
|
-
errorHeaders = response.headers;
|
|
290
|
-
}
|
|
291
|
-
else if (error.request) {
|
|
292
|
-
errorMessage = 'Server unavailable';
|
|
293
|
-
errorStatus = 500;
|
|
289
|
+
throw new errors_1.AxiosResponseError(error.message, request, error.response);
|
|
294
290
|
}
|
|
295
291
|
else {
|
|
296
|
-
|
|
297
|
-
errorStatus = 400;
|
|
292
|
+
throw new errors_1.AxiosUnknownError(error.message, request, error);
|
|
298
293
|
}
|
|
299
|
-
throw new errors_1.default(errorMessage, errorStatus, errorCode, errorHeaders);
|
|
300
294
|
};
|
|
301
295
|
HttpClient.globalInterceptors = [];
|
|
302
296
|
return HttpClient;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AxiosError, AxiosResponse } from 'axios';
|
|
1
2
|
export default class AppError extends Error {
|
|
2
3
|
readonly status?: number;
|
|
3
4
|
readonly code?: string;
|
|
@@ -5,3 +6,16 @@ export default class AppError extends Error {
|
|
|
5
6
|
readonly requestId?: string;
|
|
6
7
|
constructor(message: string, status?: number, code?: string, headers?: Record<string, string>);
|
|
7
8
|
}
|
|
9
|
+
export declare class AxiosResponseError extends Error {
|
|
10
|
+
readonly request: string;
|
|
11
|
+
readonly data: unknown;
|
|
12
|
+
readonly status: number;
|
|
13
|
+
readonly xRequestId: string | undefined;
|
|
14
|
+
constructor(message: string, request: string, response: AxiosResponse);
|
|
15
|
+
}
|
|
16
|
+
export declare class AxiosUnknownError extends Error {
|
|
17
|
+
readonly request: string;
|
|
18
|
+
readonly status: number;
|
|
19
|
+
readonly code: string | undefined;
|
|
20
|
+
constructor(message: string, request: string, error: AxiosError);
|
|
21
|
+
}
|
|
@@ -15,6 +15,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
15
15
|
};
|
|
16
16
|
})();
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.AxiosUnknownError = exports.AxiosResponseError = void 0;
|
|
18
19
|
var AppError = /** @class */ (function (_super) {
|
|
19
20
|
__extends(AppError, _super);
|
|
20
21
|
function AppError(message, status, code, headers) {
|
|
@@ -29,3 +30,31 @@ var AppError = /** @class */ (function (_super) {
|
|
|
29
30
|
return AppError;
|
|
30
31
|
}(Error));
|
|
31
32
|
exports.default = AppError;
|
|
33
|
+
var AxiosResponseError = /** @class */ (function (_super) {
|
|
34
|
+
__extends(AxiosResponseError, _super);
|
|
35
|
+
function AxiosResponseError(message, request, response) {
|
|
36
|
+
var _a;
|
|
37
|
+
var _this = _super.call(this, message) || this;
|
|
38
|
+
_this.request = request;
|
|
39
|
+
_this.data = response.data;
|
|
40
|
+
_this.status = response.status;
|
|
41
|
+
_this.xRequestId = (_a = response.headers) === null || _a === void 0 ? void 0 : _a['x-request-id'];
|
|
42
|
+
Object.setPrototypeOf(_this, AxiosResponseError.prototype);
|
|
43
|
+
return _this;
|
|
44
|
+
}
|
|
45
|
+
return AxiosResponseError;
|
|
46
|
+
}(Error));
|
|
47
|
+
exports.AxiosResponseError = AxiosResponseError;
|
|
48
|
+
var AxiosUnknownError = /** @class */ (function (_super) {
|
|
49
|
+
__extends(AxiosUnknownError, _super);
|
|
50
|
+
function AxiosUnknownError(message, request, error) {
|
|
51
|
+
var _this = _super.call(this, message) || this;
|
|
52
|
+
_this.request = request;
|
|
53
|
+
_this.status = error.request ? 500 : 400;
|
|
54
|
+
_this.code = error.code;
|
|
55
|
+
Object.setPrototypeOf(_this, AxiosUnknownError.prototype);
|
|
56
|
+
return _this;
|
|
57
|
+
}
|
|
58
|
+
return AxiosUnknownError;
|
|
59
|
+
}(Error));
|
|
60
|
+
exports.AxiosUnknownError = AxiosUnknownError;
|
package/dist/utils.d.ts
CHANGED
package/dist/utils.js
CHANGED
|
@@ -1,23 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.extractAxiosErrorMessage = extractAxiosErrorMessage;
|
|
4
3
|
exports.isHexString = isHexString;
|
|
5
|
-
function extractAxiosErrorMessage(err) {
|
|
6
|
-
var errMsg;
|
|
7
|
-
var error = err;
|
|
8
|
-
var isServerError = !!error.response;
|
|
9
|
-
var serverUnavailable = !!error.request;
|
|
10
|
-
if (isServerError) {
|
|
11
|
-
errMsg = error.response.data.error;
|
|
12
|
-
}
|
|
13
|
-
else if (serverUnavailable) {
|
|
14
|
-
errMsg = 'Server not available';
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
errMsg = error.message;
|
|
18
|
-
}
|
|
19
|
-
return errMsg;
|
|
20
|
-
}
|
|
21
4
|
function isHexString(string) {
|
|
22
5
|
// TODO: replace with proper library
|
|
23
6
|
return /^([0-9a-fA-F]{2})+$/.test(string);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@internxt/sdk",
|
|
3
3
|
"author": "Internxt <hello@internxt.com>",
|
|
4
|
-
"version": "1.15.
|
|
4
|
+
"version": "1.15.9",
|
|
5
5
|
"description": "An sdk for interacting with Internxt's services",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"prepare": "husky",
|
|
22
22
|
"test": "vitest run --coverage",
|
|
23
23
|
"test:watch": "vitest watch",
|
|
24
|
-
"clean": "rimraf dist coverage
|
|
24
|
+
"clean": "rimraf dist coverage",
|
|
25
25
|
"build": "yarn clean && tsc",
|
|
26
26
|
"lint": "eslint ./src",
|
|
27
27
|
"format": "prettier --write **/*.{js,jsx,tsx,ts}",
|
|
@@ -30,10 +30,9 @@
|
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@internxt/eslint-config-internxt": "2.1.0",
|
|
33
|
-
"@internxt/prettier-config": "internxt/prettier-config#
|
|
33
|
+
"@internxt/prettier-config": "internxt/prettier-config#v2.0.0",
|
|
34
34
|
"@types/node": "25.5.0",
|
|
35
35
|
"@vitest/coverage-istanbul": "4.1.0",
|
|
36
|
-
"@vitest/spy": "4.1.0",
|
|
37
36
|
"eslint": "10.0.3",
|
|
38
37
|
"husky": "9.1.7",
|
|
39
38
|
"lint-staged": "16.4.0",
|