@ar.io/sdk 3.22.0-alpha.4 → 3.22.0-alpha.6
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/README.md +0 -47
- package/bundles/web.bundle.min.js +70 -75
- package/lib/cjs/common/hyperbeam/hb.js +2 -2
- package/lib/cjs/common/io.js +64 -0
- package/lib/cjs/common/turbo.js +24 -14
- package/lib/cjs/utils/processes.js +8 -9
- package/lib/cjs/version.js +1 -1
- package/lib/esm/common/hyperbeam/hb.js +2 -2
- package/lib/esm/common/io.js +64 -0
- package/lib/esm/common/turbo.js +23 -13
- package/lib/esm/utils/processes.js +8 -9
- package/lib/esm/version.js +1 -1
- package/lib/types/common/turbo.d.ts +5 -7
- package/lib/types/utils/processes.d.ts +4 -3
- package/lib/types/version.d.ts +1 -1
- package/package.json +4 -16
- package/lib/cjs/common/http.js +0 -40
- package/lib/cjs/utils/http-client.js +0 -48
- package/lib/esm/common/http.js +0 -36
- package/lib/esm/utils/http-client.js +0 -41
- package/lib/types/common/http.d.ts +0 -17
- package/lib/types/utils/http-client.d.ts +0 -24
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createAxiosInstance = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
|
|
9
|
-
*
|
|
10
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
11
|
-
* you may not use this file except in compliance with the License.
|
|
12
|
-
* You may obtain a copy of the License at
|
|
13
|
-
*
|
|
14
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
-
*
|
|
16
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
-
* See the License for the specific language governing permissions and
|
|
20
|
-
* limitations under the License.
|
|
21
|
-
*/
|
|
22
|
-
const axios_1 = __importDefault(require("axios"));
|
|
23
|
-
const axios_retry_1 = __importDefault(require("axios-retry"));
|
|
24
|
-
const logger_js_1 = require("../common/logger.js");
|
|
25
|
-
const version_js_1 = require("../version.js");
|
|
26
|
-
const createAxiosInstance = ({ axiosConfig = {}, logger = logger_js_1.Logger.default, retryConfig = {
|
|
27
|
-
retries: 5,
|
|
28
|
-
retryDelay: axios_retry_1.default.exponentialDelay,
|
|
29
|
-
retryCondition: (error) => axios_retry_1.default.isRetryableError(error),
|
|
30
|
-
onRetry(retryCount, error, requestConfig) {
|
|
31
|
-
logger.error(`Retrying request ${requestConfig.url} attempt ${retryCount}`, error);
|
|
32
|
-
},
|
|
33
|
-
}, } = {}) => {
|
|
34
|
-
const axiosInstance = axios_1.default.create({
|
|
35
|
-
...axiosConfig,
|
|
36
|
-
maxRedirects: 0,
|
|
37
|
-
headers: {
|
|
38
|
-
...axiosConfig.headers,
|
|
39
|
-
'x-source-version': `${version_js_1.version}`,
|
|
40
|
-
'x-source-identifier': 'ar-io-sdk',
|
|
41
|
-
},
|
|
42
|
-
validateStatus: () => true, // don't throw on non-200 status codes
|
|
43
|
-
});
|
|
44
|
-
// add retries
|
|
45
|
-
(0, axios_retry_1.default)(axiosInstance, retryConfig);
|
|
46
|
-
return axiosInstance;
|
|
47
|
-
};
|
|
48
|
-
exports.createAxiosInstance = createAxiosInstance;
|
package/lib/esm/common/http.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { createAxiosInstance } from '../utils/http-client.js';
|
|
2
|
-
import { FailedRequestError, NotFound, UnknownError } from './error.js';
|
|
3
|
-
import { Logger } from './logger.js';
|
|
4
|
-
export class AxiosHTTPService {
|
|
5
|
-
axios;
|
|
6
|
-
logger;
|
|
7
|
-
constructor({ url, logger = Logger.default, }) {
|
|
8
|
-
this.logger = logger;
|
|
9
|
-
this.axios = createAxiosInstance({
|
|
10
|
-
axiosConfig: {
|
|
11
|
-
baseURL: url,
|
|
12
|
-
},
|
|
13
|
-
logger: this.logger,
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
async get({ endpoint, signal, allowedStatuses = [200, 202], headers, params, }) {
|
|
17
|
-
this.logger.debug(`Get request to endpoint: ${endpoint} with params ${JSON.stringify(params, undefined, 2)}`);
|
|
18
|
-
const { status, statusText, data } = await this.axios.get(endpoint, {
|
|
19
|
-
headers,
|
|
20
|
-
signal,
|
|
21
|
-
params,
|
|
22
|
-
});
|
|
23
|
-
this.logger.debug(`Response status: ${status} ${statusText}`);
|
|
24
|
-
if (!allowedStatuses.includes(status)) {
|
|
25
|
-
switch (status) {
|
|
26
|
-
case 404:
|
|
27
|
-
throw new NotFound(statusText);
|
|
28
|
-
case 400:
|
|
29
|
-
throw new FailedRequestError(status, statusText);
|
|
30
|
-
default:
|
|
31
|
-
throw new UnknownError(statusText);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return data;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
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 axios from 'axios';
|
|
17
|
-
import axiosRetry from 'axios-retry';
|
|
18
|
-
import { Logger } from '../common/logger.js';
|
|
19
|
-
import { version } from '../version.js';
|
|
20
|
-
export const createAxiosInstance = ({ axiosConfig = {}, logger = Logger.default, retryConfig = {
|
|
21
|
-
retries: 5,
|
|
22
|
-
retryDelay: axiosRetry.exponentialDelay,
|
|
23
|
-
retryCondition: (error) => axiosRetry.isRetryableError(error),
|
|
24
|
-
onRetry(retryCount, error, requestConfig) {
|
|
25
|
-
logger.error(`Retrying request ${requestConfig.url} attempt ${retryCount}`, error);
|
|
26
|
-
},
|
|
27
|
-
}, } = {}) => {
|
|
28
|
-
const axiosInstance = axios.create({
|
|
29
|
-
...axiosConfig,
|
|
30
|
-
maxRedirects: 0,
|
|
31
|
-
headers: {
|
|
32
|
-
...axiosConfig.headers,
|
|
33
|
-
'x-source-version': `${version}`,
|
|
34
|
-
'x-source-identifier': 'ar-io-sdk',
|
|
35
|
-
},
|
|
36
|
-
validateStatus: () => true, // don't throw on non-200 status codes
|
|
37
|
-
});
|
|
38
|
-
// add retries
|
|
39
|
-
axiosRetry(axiosInstance, retryConfig);
|
|
40
|
-
return axiosInstance;
|
|
41
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { HTTPClient } from '../types/index.js';
|
|
2
|
-
import { ILogger } from './logger.js';
|
|
3
|
-
export declare class AxiosHTTPService implements HTTPClient {
|
|
4
|
-
private axios;
|
|
5
|
-
private logger;
|
|
6
|
-
constructor({ url, logger, }: {
|
|
7
|
-
url: string;
|
|
8
|
-
logger?: ILogger;
|
|
9
|
-
});
|
|
10
|
-
get<I, K>({ endpoint, signal, allowedStatuses, headers, params, }: {
|
|
11
|
-
endpoint: string;
|
|
12
|
-
signal?: AbortSignal;
|
|
13
|
-
allowedStatuses?: number[];
|
|
14
|
-
headers?: Record<string, string>;
|
|
15
|
-
params?: I;
|
|
16
|
-
}): Promise<K>;
|
|
17
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
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 { AxiosInstance, AxiosRequestConfig } from 'axios';
|
|
17
|
-
import { IAxiosRetryConfig } from 'axios-retry';
|
|
18
|
-
import { ILogger } from '../common/logger.js';
|
|
19
|
-
export interface AxiosInstanceParameters {
|
|
20
|
-
axiosConfig?: Omit<AxiosRequestConfig, 'validateStatus'>;
|
|
21
|
-
retryConfig?: IAxiosRetryConfig;
|
|
22
|
-
logger?: ILogger;
|
|
23
|
-
}
|
|
24
|
-
export declare const createAxiosInstance: ({ axiosConfig, logger, retryConfig, }?: AxiosInstanceParameters) => AxiosInstance;
|