@ardrive/turbo-sdk 1.22.0-alpha.1 → 1.22.0-alpha.2
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/bundles/web.bundle.min.js +114 -68
- package/lib/cjs/common/http.js +37 -19
- package/lib/cjs/common/upload.js +72 -25
- package/lib/cjs/utils/axiosClient.js +9 -7
- package/lib/cjs/utils/errors.js +2 -2
- package/lib/cjs/version.js +1 -1
- package/lib/esm/common/http.js +37 -19
- package/lib/esm/common/upload.js +72 -25
- package/lib/esm/utils/axiosClient.js +7 -6
- package/lib/esm/utils/errors.js +2 -2
- package/lib/esm/version.js +1 -1
- package/lib/types/common/http.d.ts +1 -0
- package/lib/types/common/http.d.ts.map +1 -1
- package/lib/types/common/upload.d.ts +3 -16
- package/lib/types/common/upload.d.ts.map +1 -1
- package/lib/types/utils/axiosClient.d.ts +1 -0
- package/lib/types/utils/axiosClient.d.ts.map +1 -1
- package/lib/types/utils/errors.d.ts +1 -1
- package/lib/types/utils/errors.d.ts.map +1 -1
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
@@ -310551,7 +310551,7 @@ var import_winston = __toESM(require_winston(), 1);
|
|
310551
310551
|
init_dirname();
|
310552
310552
|
init_buffer2();
|
310553
310553
|
init_process2();
|
310554
|
-
var version16 = "1.
|
310554
|
+
var version16 = "1.22.0-alpha.1";
|
310555
310555
|
|
310556
310556
|
// src/common/logger.ts
|
310557
310557
|
var TurboWinstonLogger = class _TurboWinstonLogger {
|
@@ -312124,11 +312124,6 @@ init_dirname();
|
|
312124
312124
|
init_buffer2();
|
312125
312125
|
init_process2();
|
312126
312126
|
|
312127
|
-
// src/utils/axiosClient.ts
|
312128
|
-
init_dirname();
|
312129
|
-
init_buffer2();
|
312130
|
-
init_process2();
|
312131
|
-
|
312132
312127
|
// node_modules/axios/index.js
|
312133
312128
|
init_dirname();
|
312134
312129
|
init_buffer2();
|
@@ -314400,6 +314395,11 @@ var {
|
|
314400
314395
|
mergeConfig: mergeConfig2
|
314401
314396
|
} = axios_default;
|
314402
314397
|
|
314398
|
+
// src/utils/axiosClient.ts
|
314399
|
+
init_dirname();
|
314400
|
+
init_buffer2();
|
314401
|
+
init_process2();
|
314402
|
+
|
314403
314403
|
// node_modules/axios-retry/lib/esm/index.js
|
314404
314404
|
init_dirname();
|
314405
314405
|
init_buffer2();
|
@@ -314609,19 +314609,20 @@ var defaultRequestHeaders = {
|
|
314609
314609
|
"x-turbo-source-version": version16,
|
314610
314610
|
"x-turbo-source-identifier": "turbo-sdk"
|
314611
314611
|
};
|
314612
|
+
var defaultRetryConfig = (logger15 = TurboWinstonLogger.default) => ({
|
314613
|
+
retryDelay: axiosRetry.exponentialDelay,
|
314614
|
+
retries: 5,
|
314615
|
+
retryCondition: (error) => {
|
314616
|
+
return !(error instanceof CanceledError2) && axiosRetry.isIdempotentRequestError(error) && axiosRetry.isNetworkError(error);
|
314617
|
+
},
|
314618
|
+
onRetry: (retryCount, error) => {
|
314619
|
+
logger15.debug(`Request failed, ${error}. Retry attempt #${retryCount}...`);
|
314620
|
+
}
|
314621
|
+
});
|
314612
314622
|
var createAxiosInstance = ({
|
314613
314623
|
logger: logger15 = TurboWinstonLogger.default,
|
314614
314624
|
axiosConfig = {},
|
314615
|
-
retryConfig =
|
314616
|
-
retryDelay: axiosRetry.exponentialDelay,
|
314617
|
-
retries: 3,
|
314618
|
-
retryCondition: (error) => {
|
314619
|
-
return !(error instanceof CanceledError2) && axiosRetry.isNetworkOrIdempotentRequestError(error);
|
314620
|
-
},
|
314621
|
-
onRetry: (retryCount, error) => {
|
314622
|
-
logger15.debug(`Request failed, ${error}. Retry attempt #${retryCount}...`);
|
314623
|
-
}
|
314624
|
-
}
|
314625
|
+
retryConfig = defaultRetryConfig(logger15)
|
314625
314626
|
} = {}) => {
|
314626
314627
|
const axiosInstance = axios_default.create({
|
314627
314628
|
...axiosConfig,
|
@@ -314632,7 +314633,7 @@ var createAxiosInstance = ({
|
|
314632
314633
|
validateStatus: () => true
|
314633
314634
|
// don't throw on non-200 status codes
|
314634
314635
|
});
|
314635
|
-
if (retryConfig.retries && retryConfig.retries > 0) {
|
314636
|
+
if (retryConfig.retries !== void 0 && retryConfig.retries > 0) {
|
314636
314637
|
axiosRetry(axiosInstance, retryConfig);
|
314637
314638
|
}
|
314638
314639
|
return axiosInstance;
|
@@ -314649,8 +314650,10 @@ var BaseError = class extends Error {
|
|
314649
314650
|
}
|
314650
314651
|
};
|
314651
314652
|
var FailedRequestError = class extends BaseError {
|
314652
|
-
constructor(
|
314653
|
-
super(
|
314653
|
+
constructor(message, status) {
|
314654
|
+
super(
|
314655
|
+
`Failed request:${status !== void 0 ? ` ${status}:` : ""} ${message}`
|
314656
|
+
);
|
314654
314657
|
}
|
314655
314658
|
};
|
314656
314659
|
var ProvidedInputError = class extends BaseError {
|
@@ -314693,18 +314696,10 @@ var TurboHTTPService = class {
|
|
314693
314696
|
allowedStatuses = [200, 202],
|
314694
314697
|
headers
|
314695
314698
|
}) {
|
314696
|
-
|
314697
|
-
headers,
|
314698
|
-
|
314699
|
-
|
314700
|
-
if (!allowedStatuses.includes(status)) {
|
314701
|
-
throw new FailedRequestError(
|
314702
|
-
status,
|
314703
|
-
// Return error message from server if available
|
314704
|
-
typeof data === "string" ? data : statusText
|
314705
|
-
);
|
314706
|
-
}
|
314707
|
-
return data;
|
314699
|
+
return this.tryRequest(
|
314700
|
+
() => this.axios.get(endpoint, { headers, signal }),
|
314701
|
+
allowedStatuses
|
314702
|
+
);
|
314708
314703
|
}
|
314709
314704
|
async post({
|
314710
314705
|
endpoint,
|
@@ -314713,22 +314708,31 @@ var TurboHTTPService = class {
|
|
314713
314708
|
headers,
|
314714
314709
|
data
|
314715
314710
|
}) {
|
314716
|
-
|
314717
|
-
|
314718
|
-
|
314719
|
-
|
314720
|
-
|
314721
|
-
|
314722
|
-
|
314723
|
-
|
314724
|
-
|
314725
|
-
|
314726
|
-
|
314727
|
-
|
314728
|
-
|
314729
|
-
|
314711
|
+
return this.tryRequest(
|
314712
|
+
() => this.axios.post(endpoint, data, { headers, signal }),
|
314713
|
+
allowedStatuses
|
314714
|
+
);
|
314715
|
+
}
|
314716
|
+
async tryRequest(request3, allowedStatuses) {
|
314717
|
+
try {
|
314718
|
+
const { status, data, statusText } = await request3();
|
314719
|
+
if (!allowedStatuses.includes(status)) {
|
314720
|
+
throw new FailedRequestError(
|
314721
|
+
// Return error message from server if available
|
314722
|
+
typeof data === "string" ? data : statusText,
|
314723
|
+
status
|
314724
|
+
);
|
314725
|
+
}
|
314726
|
+
return data;
|
314727
|
+
} catch (error) {
|
314728
|
+
if (error instanceof CanceledError2) {
|
314729
|
+
throw error;
|
314730
|
+
}
|
314731
|
+
if (error instanceof AxiosError2) {
|
314732
|
+
throw new FailedRequestError(error.code ?? error.message, error.status);
|
314733
|
+
}
|
314734
|
+
throw error;
|
314730
314735
|
}
|
314731
|
-
return response;
|
314732
314736
|
}
|
314733
314737
|
};
|
314734
314738
|
|
@@ -349691,8 +349695,8 @@ var defaultUploadServiceURL = "https://upload.ardrive.io";
|
|
349691
349695
|
var TurboUnauthenticatedUploadService = class {
|
349692
349696
|
constructor({
|
349693
349697
|
url = defaultUploadServiceURL,
|
349694
|
-
retryConfig,
|
349695
349698
|
logger: logger15 = TurboWinstonLogger.default,
|
349699
|
+
retryConfig = defaultRetryConfig(logger15),
|
349696
349700
|
token = "arweave"
|
349697
349701
|
}) {
|
349698
349702
|
this.token = token;
|
@@ -349702,6 +349706,7 @@ var TurboUnauthenticatedUploadService = class {
|
|
349702
349706
|
retryConfig,
|
349703
349707
|
logger: this.logger
|
349704
349708
|
});
|
349709
|
+
this.retryConfig = retryConfig;
|
349705
349710
|
}
|
349706
349711
|
async uploadSignedDataItem({
|
349707
349712
|
dataItemStreamFactory,
|
@@ -349738,29 +349743,70 @@ var TurboAuthenticatedBaseUploadService = class extends TurboUnauthenticatedUplo
|
|
349738
349743
|
signal,
|
349739
349744
|
dataItemOpts
|
349740
349745
|
}) {
|
349741
|
-
|
349742
|
-
|
349743
|
-
|
349744
|
-
|
349745
|
-
|
349746
|
-
|
349747
|
-
|
349748
|
-
|
349749
|
-
|
349750
|
-
|
349751
|
-
|
349752
|
-
|
349753
|
-
|
349754
|
-
|
349755
|
-
|
349746
|
+
let retries = 0;
|
349747
|
+
const maxRetries = this.retryConfig.retries ?? 3;
|
349748
|
+
const retryDelay = this.retryConfig.retryDelay ?? ((retryNumber) => retryNumber * 1e3);
|
349749
|
+
let lastError = void 0;
|
349750
|
+
let lastStatusCode = void 0;
|
349751
|
+
while (retries < maxRetries) {
|
349752
|
+
if (signal?.aborted) {
|
349753
|
+
throw new CanceledError2();
|
349754
|
+
}
|
349755
|
+
const { dataItemStreamFactory, dataItemSizeFactory } = await this.signer.signDataItem({
|
349756
|
+
fileStreamFactory,
|
349757
|
+
fileSizeFactory,
|
349758
|
+
dataItemOpts
|
349759
|
+
});
|
349760
|
+
try {
|
349761
|
+
this.logger.debug("Uploading signed data item...");
|
349762
|
+
const headers = {
|
349763
|
+
"content-type": "application/octet-stream",
|
349764
|
+
"content-length": `${dataItemSizeFactory()}`
|
349765
|
+
};
|
349766
|
+
if (dataItemOpts !== void 0 && dataItemOpts.paidBy !== void 0) {
|
349767
|
+
const paidBy = Array.isArray(dataItemOpts.paidBy) ? dataItemOpts.paidBy : [dataItemOpts.paidBy];
|
349768
|
+
if (dataItemOpts.paidBy.length > 0) {
|
349769
|
+
headers["x-paid-by"] = paidBy;
|
349770
|
+
}
|
349771
|
+
}
|
349772
|
+
const data = await this.httpService.post({
|
349773
|
+
endpoint: `/tx/${this.token}`,
|
349774
|
+
signal,
|
349775
|
+
data: dataItemStreamFactory(),
|
349776
|
+
headers
|
349777
|
+
});
|
349778
|
+
return data;
|
349779
|
+
} catch (error) {
|
349780
|
+
if (error instanceof FailedRequestError) {
|
349781
|
+
throw error;
|
349782
|
+
}
|
349783
|
+
if (error instanceof AxiosError2) {
|
349784
|
+
lastStatusCode = error.response?.status;
|
349785
|
+
lastError = error.code ?? error.message;
|
349786
|
+
} else {
|
349787
|
+
lastError = error instanceof Error && error.message !== void 0 ? error.message : `${error}`;
|
349788
|
+
}
|
349789
|
+
this.logger.debug(
|
349790
|
+
`Upload failed on attempt ${retries + 1}/${maxRetries + 1}`,
|
349791
|
+
{ message: lastError },
|
349792
|
+
error
|
349793
|
+
);
|
349794
|
+
retries++;
|
349795
|
+
const abortEventPromise = new Promise((resolve3) => {
|
349796
|
+
signal?.addEventListener("abort", () => {
|
349797
|
+
resolve3();
|
349798
|
+
});
|
349799
|
+
});
|
349800
|
+
await Promise.race([
|
349801
|
+
sleep(retryDelay(retries, error)),
|
349802
|
+
abortEventPromise
|
349803
|
+
]);
|
349756
349804
|
}
|
349757
349805
|
}
|
349758
|
-
|
349759
|
-
|
349760
|
-
|
349761
|
-
|
349762
|
-
headers
|
349763
|
-
});
|
349806
|
+
throw new FailedRequestError(
|
349807
|
+
`Failed to upload file after ${maxRetries} attempts${lastError !== void 0 && lastError.length > 0 ? `: ${lastError}` : ""}`,
|
349808
|
+
lastStatusCode
|
349809
|
+
);
|
349764
349810
|
}
|
349765
349811
|
async generateManifest({
|
349766
349812
|
paths,
|
package/lib/cjs/common/http.js
CHANGED
@@ -1,6 +1,22 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.TurboHTTPService = void 0;
|
4
|
+
/**
|
5
|
+
* Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
|
6
|
+
*
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
* you may not use this file except in compliance with the License.
|
9
|
+
* You may obtain a copy of the License at
|
10
|
+
*
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
*
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
* See the License for the specific language governing permissions and
|
17
|
+
* limitations under the License.
|
18
|
+
*/
|
19
|
+
const axios_1 = require("axios");
|
4
20
|
const axiosClient_js_1 = require("../utils/axiosClient.js");
|
5
21
|
const errors_js_1 = require("../utils/errors.js");
|
6
22
|
class TurboHTTPService {
|
@@ -26,28 +42,30 @@ class TurboHTTPService {
|
|
26
42
|
});
|
27
43
|
}
|
28
44
|
async get({ endpoint, signal, allowedStatuses = [200, 202], headers, }) {
|
29
|
-
|
30
|
-
headers,
|
31
|
-
signal,
|
32
|
-
});
|
33
|
-
if (!allowedStatuses.includes(status)) {
|
34
|
-
throw new errors_js_1.FailedRequestError(status,
|
35
|
-
// Return error message from server if available
|
36
|
-
typeof data === 'string' ? data : statusText);
|
37
|
-
}
|
38
|
-
return data;
|
45
|
+
return this.tryRequest(() => this.axios.get(endpoint, { headers, signal }), allowedStatuses);
|
39
46
|
}
|
40
47
|
async post({ endpoint, signal, allowedStatuses = [200, 202], headers, data, }) {
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
48
|
+
return this.tryRequest(() => this.axios.post(endpoint, data, { headers, signal }), allowedStatuses);
|
49
|
+
}
|
50
|
+
async tryRequest(request, allowedStatuses) {
|
51
|
+
try {
|
52
|
+
const { status, data, statusText } = await request();
|
53
|
+
if (!allowedStatuses.includes(status)) {
|
54
|
+
throw new errors_js_1.FailedRequestError(
|
55
|
+
// Return error message from server if available
|
56
|
+
typeof data === 'string' ? data : statusText, status);
|
57
|
+
}
|
58
|
+
return data;
|
59
|
+
}
|
60
|
+
catch (error) {
|
61
|
+
if (error instanceof axios_1.CanceledError) {
|
62
|
+
throw error;
|
63
|
+
}
|
64
|
+
if (error instanceof axios_1.AxiosError) {
|
65
|
+
throw new errors_js_1.FailedRequestError(error.code ?? error.message, error.status);
|
66
|
+
}
|
67
|
+
throw error;
|
49
68
|
}
|
50
|
-
return response;
|
51
69
|
}
|
52
70
|
}
|
53
71
|
exports.TurboHTTPService = TurboHTTPService;
|
package/lib/cjs/common/upload.js
CHANGED
@@ -16,8 +16,12 @@ exports.TurboAuthenticatedBaseUploadService = exports.TurboUnauthenticatedUpload
|
|
16
16
|
* See the License for the specific language governing permissions and
|
17
17
|
* limitations under the License.
|
18
18
|
*/
|
19
|
+
const axios_1 = require("axios");
|
19
20
|
const node_buffer_1 = require("node:buffer");
|
20
21
|
const plimit_lit_1 = require("plimit-lit");
|
22
|
+
const axiosClient_js_1 = require("../utils/axiosClient.js");
|
23
|
+
const common_js_1 = require("../utils/common.js");
|
24
|
+
const errors_js_1 = require("../utils/errors.js");
|
21
25
|
const http_js_1 = require("./http.js");
|
22
26
|
const logger_js_1 = require("./logger.js");
|
23
27
|
exports.creditSharingTagNames = {
|
@@ -29,7 +33,7 @@ exports.creditSharingTagNames = {
|
|
29
33
|
exports.developmentUploadServiceURL = 'https://upload.ardrive.dev';
|
30
34
|
exports.defaultUploadServiceURL = 'https://upload.ardrive.io';
|
31
35
|
class TurboUnauthenticatedUploadService {
|
32
|
-
constructor({ url = exports.defaultUploadServiceURL,
|
36
|
+
constructor({ url = exports.defaultUploadServiceURL, logger = logger_js_1.TurboWinstonLogger.default, retryConfig = (0, axiosClient_js_1.defaultRetryConfig)(logger), token = 'arweave', }) {
|
33
37
|
this.token = token;
|
34
38
|
this.logger = logger;
|
35
39
|
this.httpService = new http_js_1.TurboHTTPService({
|
@@ -37,6 +41,7 @@ class TurboUnauthenticatedUploadService {
|
|
37
41
|
retryConfig,
|
38
42
|
logger: this.logger,
|
39
43
|
});
|
44
|
+
this.retryConfig = retryConfig;
|
40
45
|
}
|
41
46
|
async uploadSignedDataItem({ dataItemStreamFactory, dataItemSizeFactory, signal, }) {
|
42
47
|
const fileSize = dataItemSizeFactory();
|
@@ -61,32 +66,74 @@ class TurboAuthenticatedBaseUploadService extends TurboUnauthenticatedUploadServ
|
|
61
66
|
this.signer = signer;
|
62
67
|
}
|
63
68
|
async uploadFile({ fileStreamFactory, fileSizeFactory, signal, dataItemOpts, }) {
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
69
|
+
let retries = 0;
|
70
|
+
const maxRetries = this.retryConfig.retries ?? 3;
|
71
|
+
const retryDelay = this.retryConfig.retryDelay ??
|
72
|
+
((retryNumber) => retryNumber * 1000);
|
73
|
+
let lastError = undefined; // Store the last error for throwing
|
74
|
+
let lastStatusCode = undefined; // Store the last status code for throwing
|
75
|
+
while (retries < maxRetries) {
|
76
|
+
if (signal?.aborted) {
|
77
|
+
throw new axios_1.CanceledError();
|
78
|
+
}
|
79
|
+
const { dataItemStreamFactory, dataItemSizeFactory } = await this.signer.signDataItem({
|
80
|
+
fileStreamFactory,
|
81
|
+
fileSizeFactory,
|
82
|
+
dataItemOpts,
|
83
|
+
});
|
84
|
+
try {
|
85
|
+
this.logger.debug('Uploading signed data item...');
|
86
|
+
// TODO: add p-limit constraint or replace with separate upload class
|
87
|
+
const headers = {
|
88
|
+
'content-type': 'application/octet-stream',
|
89
|
+
'content-length': `${dataItemSizeFactory()}`,
|
90
|
+
};
|
91
|
+
if (dataItemOpts !== undefined && dataItemOpts.paidBy !== undefined) {
|
92
|
+
const paidBy = Array.isArray(dataItemOpts.paidBy)
|
93
|
+
? dataItemOpts.paidBy
|
94
|
+
: [dataItemOpts.paidBy];
|
95
|
+
if (dataItemOpts.paidBy.length > 0) {
|
96
|
+
headers['x-paid-by'] = paidBy;
|
97
|
+
}
|
98
|
+
}
|
99
|
+
const data = await this.httpService.post({
|
100
|
+
endpoint: `/tx/${this.token}`,
|
101
|
+
signal,
|
102
|
+
data: dataItemStreamFactory(),
|
103
|
+
headers,
|
104
|
+
});
|
105
|
+
return data;
|
106
|
+
}
|
107
|
+
catch (error) {
|
108
|
+
if (error instanceof errors_js_1.FailedRequestError) {
|
109
|
+
throw error; // Rethrow if it's already a failed request error from HTTP service
|
110
|
+
}
|
111
|
+
// Store the last encountered error and status for re-throwing after retries
|
112
|
+
if (error instanceof axios_1.AxiosError) {
|
113
|
+
lastStatusCode = error.response?.status;
|
114
|
+
lastError = error.code ?? error.message;
|
115
|
+
}
|
116
|
+
else {
|
117
|
+
lastError =
|
118
|
+
error instanceof Error && error.message !== undefined
|
119
|
+
? error.message
|
120
|
+
: `${error}`; // Stringify the whole error if it's not a known Error instance
|
121
|
+
}
|
122
|
+
this.logger.debug(`Upload failed on attempt ${retries + 1}/${maxRetries + 1}`, { message: lastError }, error);
|
123
|
+
retries++;
|
124
|
+
const abortEventPromise = new Promise((resolve) => {
|
125
|
+
signal?.addEventListener('abort', () => {
|
126
|
+
resolve();
|
127
|
+
});
|
128
|
+
});
|
129
|
+
await Promise.race([
|
130
|
+
(0, common_js_1.sleep)(retryDelay(retries, error)),
|
131
|
+
abortEventPromise,
|
132
|
+
]);
|
82
133
|
}
|
83
134
|
}
|
84
|
-
|
85
|
-
|
86
|
-
signal,
|
87
|
-
data: signedDataItem,
|
88
|
-
headers,
|
89
|
-
});
|
135
|
+
// After all retries, throw the last error for catching
|
136
|
+
throw new errors_js_1.FailedRequestError(`Failed to upload file after ${maxRetries} attempts${lastError !== undefined && lastError.length > 0 ? `: ${lastError}` : ''}`, lastStatusCode);
|
90
137
|
}
|
91
138
|
async generateManifest({ paths, indexFile, fallbackFile, }) {
|
92
139
|
const indexPath =
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
27
27
|
};
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
29
|
-
exports.createAxiosInstance = exports.defaultRequestHeaders = void 0;
|
29
|
+
exports.createAxiosInstance = exports.defaultRetryConfig = exports.defaultRequestHeaders = void 0;
|
30
30
|
/**
|
31
31
|
* Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
|
32
32
|
*
|
@@ -50,17 +50,20 @@ exports.defaultRequestHeaders = {
|
|
50
50
|
'x-turbo-source-version': version_js_1.version,
|
51
51
|
'x-turbo-source-identifier': 'turbo-sdk',
|
52
52
|
};
|
53
|
-
const
|
53
|
+
const defaultRetryConfig = (logger = logger_js_1.TurboWinstonLogger.default) => ({
|
54
54
|
retryDelay: axios_retry_1.default.exponentialDelay,
|
55
|
-
retries:
|
55
|
+
retries: 5,
|
56
56
|
retryCondition: (error) => {
|
57
57
|
return (!(error instanceof axios_1.CanceledError) &&
|
58
|
-
axios_retry_1.default.
|
58
|
+
axios_retry_1.default.isIdempotentRequestError(error) &&
|
59
|
+
axios_retry_1.default.isNetworkError(error));
|
59
60
|
},
|
60
61
|
onRetry: (retryCount, error) => {
|
61
62
|
logger.debug(`Request failed, ${error}. Retry attempt #${retryCount}...`);
|
62
63
|
},
|
63
|
-
}
|
64
|
+
});
|
65
|
+
exports.defaultRetryConfig = defaultRetryConfig;
|
66
|
+
const createAxiosInstance = ({ logger = logger_js_1.TurboWinstonLogger.default, axiosConfig = {}, retryConfig = (0, exports.defaultRetryConfig)(logger), } = {}) => {
|
64
67
|
const axiosInstance = axios_1.default.create({
|
65
68
|
...axiosConfig,
|
66
69
|
headers: {
|
@@ -69,8 +72,7 @@ const createAxiosInstance = ({ logger = logger_js_1.TurboWinstonLogger.default,
|
|
69
72
|
},
|
70
73
|
validateStatus: () => true, // don't throw on non-200 status codes
|
71
74
|
});
|
72
|
-
|
73
|
-
if (retryConfig.retries && retryConfig.retries > 0) {
|
75
|
+
if (retryConfig.retries !== undefined && retryConfig.retries > 0) {
|
74
76
|
(0, axios_retry_1.default)(axiosInstance, retryConfig);
|
75
77
|
}
|
76
78
|
return axiosInstance;
|
package/lib/cjs/utils/errors.js
CHANGED
@@ -30,8 +30,8 @@ class UnauthenticatedRequestError extends BaseError {
|
|
30
30
|
}
|
31
31
|
exports.UnauthenticatedRequestError = UnauthenticatedRequestError;
|
32
32
|
class FailedRequestError extends BaseError {
|
33
|
-
constructor(
|
34
|
-
super(`Failed request
|
33
|
+
constructor(message, status) {
|
34
|
+
super(`Failed request:${status !== undefined ? ` ${status}:` : ''} ${message}`);
|
35
35
|
}
|
36
36
|
}
|
37
37
|
exports.FailedRequestError = FailedRequestError;
|
package/lib/cjs/version.js
CHANGED
package/lib/esm/common/http.js
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
|
3
|
+
*
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
* you may not use this file except in compliance with the License.
|
6
|
+
* You may obtain a copy of the License at
|
7
|
+
*
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
*
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
* See the License for the specific language governing permissions and
|
14
|
+
* limitations under the License.
|
15
|
+
*/
|
16
|
+
import { AxiosError, CanceledError } from 'axios';
|
1
17
|
import { createAxiosInstance } from '../utils/axiosClient.js';
|
2
18
|
import { FailedRequestError } from '../utils/errors.js';
|
3
19
|
export class TurboHTTPService {
|
@@ -23,27 +39,29 @@ export class TurboHTTPService {
|
|
23
39
|
});
|
24
40
|
}
|
25
41
|
async get({ endpoint, signal, allowedStatuses = [200, 202], headers, }) {
|
26
|
-
|
27
|
-
headers,
|
28
|
-
signal,
|
29
|
-
});
|
30
|
-
if (!allowedStatuses.includes(status)) {
|
31
|
-
throw new FailedRequestError(status,
|
32
|
-
// Return error message from server if available
|
33
|
-
typeof data === 'string' ? data : statusText);
|
34
|
-
}
|
35
|
-
return data;
|
42
|
+
return this.tryRequest(() => this.axios.get(endpoint, { headers, signal }), allowedStatuses);
|
36
43
|
}
|
37
44
|
async post({ endpoint, signal, allowedStatuses = [200, 202], headers, data, }) {
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
45
|
+
return this.tryRequest(() => this.axios.post(endpoint, data, { headers, signal }), allowedStatuses);
|
46
|
+
}
|
47
|
+
async tryRequest(request, allowedStatuses) {
|
48
|
+
try {
|
49
|
+
const { status, data, statusText } = await request();
|
50
|
+
if (!allowedStatuses.includes(status)) {
|
51
|
+
throw new FailedRequestError(
|
52
|
+
// Return error message from server if available
|
53
|
+
typeof data === 'string' ? data : statusText, status);
|
54
|
+
}
|
55
|
+
return data;
|
56
|
+
}
|
57
|
+
catch (error) {
|
58
|
+
if (error instanceof CanceledError) {
|
59
|
+
throw error;
|
60
|
+
}
|
61
|
+
if (error instanceof AxiosError) {
|
62
|
+
throw new FailedRequestError(error.code ?? error.message, error.status);
|
63
|
+
}
|
64
|
+
throw error;
|
46
65
|
}
|
47
|
-
return response;
|
48
66
|
}
|
49
67
|
}
|
package/lib/esm/common/upload.js
CHANGED
@@ -13,8 +13,12 @@
|
|
13
13
|
* See the License for the specific language governing permissions and
|
14
14
|
* limitations under the License.
|
15
15
|
*/
|
16
|
+
import { AxiosError, CanceledError } from 'axios';
|
16
17
|
import { Buffer } from 'node:buffer';
|
17
18
|
import { pLimit } from 'plimit-lit';
|
19
|
+
import { defaultRetryConfig } from '../utils/axiosClient.js';
|
20
|
+
import { sleep } from '../utils/common.js';
|
21
|
+
import { FailedRequestError } from '../utils/errors.js';
|
18
22
|
import { TurboHTTPService } from './http.js';
|
19
23
|
import { TurboWinstonLogger } from './logger.js';
|
20
24
|
export const creditSharingTagNames = {
|
@@ -26,7 +30,7 @@ export const creditSharingTagNames = {
|
|
26
30
|
export const developmentUploadServiceURL = 'https://upload.ardrive.dev';
|
27
31
|
export const defaultUploadServiceURL = 'https://upload.ardrive.io';
|
28
32
|
export class TurboUnauthenticatedUploadService {
|
29
|
-
constructor({ url = defaultUploadServiceURL,
|
33
|
+
constructor({ url = defaultUploadServiceURL, logger = TurboWinstonLogger.default, retryConfig = defaultRetryConfig(logger), token = 'arweave', }) {
|
30
34
|
this.token = token;
|
31
35
|
this.logger = logger;
|
32
36
|
this.httpService = new TurboHTTPService({
|
@@ -34,6 +38,7 @@ export class TurboUnauthenticatedUploadService {
|
|
34
38
|
retryConfig,
|
35
39
|
logger: this.logger,
|
36
40
|
});
|
41
|
+
this.retryConfig = retryConfig;
|
37
42
|
}
|
38
43
|
async uploadSignedDataItem({ dataItemStreamFactory, dataItemSizeFactory, signal, }) {
|
39
44
|
const fileSize = dataItemSizeFactory();
|
@@ -57,32 +62,74 @@ export class TurboAuthenticatedBaseUploadService extends TurboUnauthenticatedUpl
|
|
57
62
|
this.signer = signer;
|
58
63
|
}
|
59
64
|
async uploadFile({ fileStreamFactory, fileSizeFactory, signal, dataItemOpts, }) {
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
65
|
+
let retries = 0;
|
66
|
+
const maxRetries = this.retryConfig.retries ?? 3;
|
67
|
+
const retryDelay = this.retryConfig.retryDelay ??
|
68
|
+
((retryNumber) => retryNumber * 1000);
|
69
|
+
let lastError = undefined; // Store the last error for throwing
|
70
|
+
let lastStatusCode = undefined; // Store the last status code for throwing
|
71
|
+
while (retries < maxRetries) {
|
72
|
+
if (signal?.aborted) {
|
73
|
+
throw new CanceledError();
|
74
|
+
}
|
75
|
+
const { dataItemStreamFactory, dataItemSizeFactory } = await this.signer.signDataItem({
|
76
|
+
fileStreamFactory,
|
77
|
+
fileSizeFactory,
|
78
|
+
dataItemOpts,
|
79
|
+
});
|
80
|
+
try {
|
81
|
+
this.logger.debug('Uploading signed data item...');
|
82
|
+
// TODO: add p-limit constraint or replace with separate upload class
|
83
|
+
const headers = {
|
84
|
+
'content-type': 'application/octet-stream',
|
85
|
+
'content-length': `${dataItemSizeFactory()}`,
|
86
|
+
};
|
87
|
+
if (dataItemOpts !== undefined && dataItemOpts.paidBy !== undefined) {
|
88
|
+
const paidBy = Array.isArray(dataItemOpts.paidBy)
|
89
|
+
? dataItemOpts.paidBy
|
90
|
+
: [dataItemOpts.paidBy];
|
91
|
+
if (dataItemOpts.paidBy.length > 0) {
|
92
|
+
headers['x-paid-by'] = paidBy;
|
93
|
+
}
|
94
|
+
}
|
95
|
+
const data = await this.httpService.post({
|
96
|
+
endpoint: `/tx/${this.token}`,
|
97
|
+
signal,
|
98
|
+
data: dataItemStreamFactory(),
|
99
|
+
headers,
|
100
|
+
});
|
101
|
+
return data;
|
102
|
+
}
|
103
|
+
catch (error) {
|
104
|
+
if (error instanceof FailedRequestError) {
|
105
|
+
throw error; // Rethrow if it's already a failed request error from HTTP service
|
106
|
+
}
|
107
|
+
// Store the last encountered error and status for re-throwing after retries
|
108
|
+
if (error instanceof AxiosError) {
|
109
|
+
lastStatusCode = error.response?.status;
|
110
|
+
lastError = error.code ?? error.message;
|
111
|
+
}
|
112
|
+
else {
|
113
|
+
lastError =
|
114
|
+
error instanceof Error && error.message !== undefined
|
115
|
+
? error.message
|
116
|
+
: `${error}`; // Stringify the whole error if it's not a known Error instance
|
117
|
+
}
|
118
|
+
this.logger.debug(`Upload failed on attempt ${retries + 1}/${maxRetries + 1}`, { message: lastError }, error);
|
119
|
+
retries++;
|
120
|
+
const abortEventPromise = new Promise((resolve) => {
|
121
|
+
signal?.addEventListener('abort', () => {
|
122
|
+
resolve();
|
123
|
+
});
|
124
|
+
});
|
125
|
+
await Promise.race([
|
126
|
+
sleep(retryDelay(retries, error)),
|
127
|
+
abortEventPromise,
|
128
|
+
]);
|
78
129
|
}
|
79
130
|
}
|
80
|
-
|
81
|
-
|
82
|
-
signal,
|
83
|
-
data: signedDataItem,
|
84
|
-
headers,
|
85
|
-
});
|
131
|
+
// After all retries, throw the last error for catching
|
132
|
+
throw new FailedRequestError(`Failed to upload file after ${maxRetries} attempts${lastError !== undefined && lastError.length > 0 ? `: ${lastError}` : ''}`, lastStatusCode);
|
86
133
|
}
|
87
134
|
async generateManifest({ paths, indexFile, fallbackFile, }) {
|
88
135
|
const indexPath =
|
@@ -21,17 +21,19 @@ export const defaultRequestHeaders = {
|
|
21
21
|
'x-turbo-source-version': version,
|
22
22
|
'x-turbo-source-identifier': 'turbo-sdk',
|
23
23
|
};
|
24
|
-
export const
|
24
|
+
export const defaultRetryConfig = (logger = TurboWinstonLogger.default) => ({
|
25
25
|
retryDelay: axiosRetry.exponentialDelay,
|
26
|
-
retries:
|
26
|
+
retries: 5,
|
27
27
|
retryCondition: (error) => {
|
28
28
|
return (!(error instanceof CanceledError) &&
|
29
|
-
axiosRetry.
|
29
|
+
axiosRetry.isIdempotentRequestError(error) &&
|
30
|
+
axiosRetry.isNetworkError(error));
|
30
31
|
},
|
31
32
|
onRetry: (retryCount, error) => {
|
32
33
|
logger.debug(`Request failed, ${error}. Retry attempt #${retryCount}...`);
|
33
34
|
},
|
34
|
-
}
|
35
|
+
});
|
36
|
+
export const createAxiosInstance = ({ logger = TurboWinstonLogger.default, axiosConfig = {}, retryConfig = defaultRetryConfig(logger), } = {}) => {
|
35
37
|
const axiosInstance = axios.create({
|
36
38
|
...axiosConfig,
|
37
39
|
headers: {
|
@@ -40,8 +42,7 @@ export const createAxiosInstance = ({ logger = TurboWinstonLogger.default, axios
|
|
40
42
|
},
|
41
43
|
validateStatus: () => true, // don't throw on non-200 status codes
|
42
44
|
});
|
43
|
-
|
44
|
-
if (retryConfig.retries && retryConfig.retries > 0) {
|
45
|
+
if (retryConfig.retries !== undefined && retryConfig.retries > 0) {
|
45
46
|
axiosRetry(axiosInstance, retryConfig);
|
46
47
|
}
|
47
48
|
return axiosInstance;
|
package/lib/esm/utils/errors.js
CHANGED
@@ -25,8 +25,8 @@ export class UnauthenticatedRequestError extends BaseError {
|
|
25
25
|
}
|
26
26
|
}
|
27
27
|
export class FailedRequestError extends BaseError {
|
28
|
-
constructor(
|
29
|
-
super(`Failed request
|
28
|
+
constructor(message, status) {
|
29
|
+
super(`Failed request:${status !== undefined ? ` ${status}:` : ''} ${message}`);
|
30
30
|
}
|
31
31
|
}
|
32
32
|
export class ProvidedInputError extends BaseError {
|
package/lib/esm/version.js
CHANGED
@@ -40,5 +40,6 @@ export declare class TurboHTTPService implements TurboHTTPServiceInterface {
|
|
40
40
|
headers?: Partial<TurboSignedRequestHeaders> & Record<string, string>;
|
41
41
|
data: Readable | Buffer | ReadableStream;
|
42
42
|
}): Promise<T>;
|
43
|
+
private tryRequest;
|
43
44
|
}
|
44
45
|
//# sourceMappingURL=http.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/common/http.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/common/http.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAc,aAAa,EAAgC,MAAM,OAAO,CAAC;AAChF,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,EACL,yBAAyB,EACzB,WAAW,EACX,yBAAyB,EAC1B,MAAM,aAAa,CAAC;AAIrB,qBAAa,gBAAiB,YAAW,yBAAyB;IAChE,SAAS,CAAC,KAAK,EAAE,aAAa,CAAC;IAC/B,SAAS,CAAC,MAAM,EAAE,WAAW,CAAC;gBAElB,EACV,GAAG,EACH,WAAW,EACX,MAAM,GACP,EAAE;QACD,GAAG,EAAE,MAAM,CAAC;QACZ,WAAW,CAAC,EAAE,iBAAiB,CAAC;QAChC,MAAM,EAAE,WAAW,CAAC;KACrB;IAsBK,GAAG,CAAC,CAAC,EAAE,EACX,QAAQ,EACR,MAAM,EACN,eAA4B,EAC5B,OAAO,GACR,EAAE;QACD,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,CAAC,EAAE,WAAW,CAAC;QACrB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;QAC3B,OAAO,CAAC,EAAE,OAAO,CAAC,yBAAyB,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACvE,GAAG,OAAO,CAAC,CAAC,CAAC;IAOR,IAAI,CAAC,CAAC,EAAE,EACZ,QAAQ,EACR,MAAM,EACN,eAA4B,EAC5B,OAAO,EACP,IAAI,GACL,EAAE;QACD,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,CAAC,EAAE,WAAW,CAAC;QACrB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;QAC3B,OAAO,CAAC,EAAE,OAAO,CAAC,yBAAyB,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACtE,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,cAAc,CAAC;KAC1C,GAAG,OAAO,CAAC,CAAC,CAAC;YAOA,UAAU;CAwBzB"}
|
@@ -1,18 +1,4 @@
|
|
1
|
-
|
2
|
-
* Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
|
3
|
-
*
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
* you may not use this file except in compliance with the License.
|
6
|
-
* You may obtain a copy of the License at
|
7
|
-
*
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
*
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
* See the License for the specific language governing permissions and
|
14
|
-
* limitations under the License.
|
15
|
-
*/
|
1
|
+
import { IAxiosRetryConfig } from 'axios-retry';
|
16
2
|
import { Buffer } from 'node:buffer';
|
17
3
|
import { Readable } from 'node:stream';
|
18
4
|
import { ArweaveManifest, CreditShareApproval, TokenType, TurboAbortSignal, TurboAuthenticatedUploadServiceConfiguration, TurboAuthenticatedUploadServiceInterface, TurboCreateCreditShareApprovalParams, TurboDataItemSigner, TurboFileFactory, TurboLogger, TurboRevokeCreditsParams, TurboSignedDataItemFactory, TurboUnauthenticatedUploadServiceConfiguration, TurboUnauthenticatedUploadServiceInterface, TurboUploadDataItemResponse, TurboUploadFolderParams, TurboUploadFolderResponse } from '../types.js';
|
@@ -29,7 +15,8 @@ export declare class TurboUnauthenticatedUploadService implements TurboUnauthent
|
|
29
15
|
protected httpService: TurboHTTPService;
|
30
16
|
protected logger: TurboLogger;
|
31
17
|
protected token: TokenType;
|
32
|
-
|
18
|
+
protected retryConfig: IAxiosRetryConfig;
|
19
|
+
constructor({ url, logger, retryConfig, token, }: TurboUnauthenticatedUploadServiceConfiguration);
|
33
20
|
uploadSignedDataItem({ dataItemStreamFactory, dataItemSizeFactory, signal, }: TurboSignedDataItemFactory & TurboAbortSignal): Promise<TurboUploadDataItemResponse>;
|
34
21
|
}
|
35
22
|
export declare abstract class TurboAuthenticatedBaseUploadService extends TurboUnauthenticatedUploadService implements TurboAuthenticatedUploadServiceInterface {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../../src/common/upload.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../../src/common/upload.ts"],"names":[],"mappings":"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"}
|
@@ -25,5 +25,6 @@ export interface AxiosInstanceParameters {
|
|
25
25
|
retryConfig?: IAxiosRetryConfig;
|
26
26
|
logger?: TurboLogger;
|
27
27
|
}
|
28
|
+
export declare const defaultRetryConfig: (logger?: TurboLogger) => IAxiosRetryConfig;
|
28
29
|
export declare const createAxiosInstance: ({ logger, axiosConfig, retryConfig, }?: AxiosInstanceParameters) => AxiosInstance;
|
29
30
|
//# sourceMappingURL=axiosClient.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"axiosClient.d.ts","sourceRoot":"","sources":["../../../src/utils/axiosClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAc,EAAE,aAAa,EAAE,kBAAkB,EAAiB,MAAM,OAAO,CAAC;AAChF,OAAmB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAG5D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1C,eAAO,MAAM,qBAAqB;;;CAGjC,CAAC;AAEF,MAAM,WAAW,uBAAuB;IACtC,WAAW,CAAC,EAAE,IAAI,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAC;IACzD,WAAW,CAAC,EAAE,iBAAiB,CAAC;IAChC,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,eAAO,MAAM,mBAAmB,
|
1
|
+
{"version":3,"file":"axiosClient.d.ts","sourceRoot":"","sources":["../../../src/utils/axiosClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAc,EAAE,aAAa,EAAE,kBAAkB,EAAiB,MAAM,OAAO,CAAC;AAChF,OAAmB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAG5D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1C,eAAO,MAAM,qBAAqB;;;CAGjC,CAAC;AAEF,MAAM,WAAW,uBAAuB;IACtC,WAAW,CAAC,EAAE,IAAI,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAC;IACzD,WAAW,CAAC,EAAE,iBAAiB,CAAC;IAChC,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,eAAO,MAAM,kBAAkB,EAAE,CAAC,MAAM,CAAC,EAAE,WAAW,KAAK,iBAezD,CAAC;AAEH,eAAO,MAAM,mBAAmB,2CAI7B,uBAAuB,KAAQ,aAejC,CAAC"}
|
@@ -20,7 +20,7 @@ export declare class UnauthenticatedRequestError extends BaseError {
|
|
20
20
|
constructor();
|
21
21
|
}
|
22
22
|
export declare class FailedRequestError extends BaseError {
|
23
|
-
constructor(
|
23
|
+
constructor(message: string, status?: number);
|
24
24
|
}
|
25
25
|
export declare class ProvidedInputError extends BaseError {
|
26
26
|
constructor(message?: string);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/utils/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,qBAAa,SAAU,SAAQ,KAAK;gBACtB,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,2BAA4B,SAAQ,SAAS;;CAIzD;AAED,qBAAa,kBAAmB,SAAQ,SAAS;gBACnC,
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/utils/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,qBAAa,SAAU,SAAQ,KAAK;gBACtB,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,2BAA4B,SAAQ,SAAS;;CAIzD;AAED,qBAAa,kBAAmB,SAAQ,SAAS;gBACnC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;CAK7C;AAED,qBAAa,kBAAmB,SAAQ,SAAS;gBACnC,OAAO,CAAC,EAAE,MAAM;CAG7B"}
|
package/lib/types/version.d.ts
CHANGED