cloreai 0.1.0 → 0.1.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/build/CloreAI.d.ts +11 -11
- package/build/CloreAI.js +22 -26
- package/build/WebAPI.d.ts +5 -3
- package/build/WebAPI.js +10 -10
- package/build/getErrorMessage.d.ts +1 -0
- package/build/getErrorMessage.js +8 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +1 -0
- package/build/types/webapi/marketplaceOrders.d.ts +34 -0
- package/build/types/webapi/marketplaceOrders.js +1 -0
- package/package.json +1 -1
package/build/CloreAI.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type AxiosInstance } from 'axios';
|
|
1
|
+
import { type AxiosInstance, type AxiosRequestConfig } from 'axios';
|
|
2
2
|
import { type CancelOrderBody, type CancelOrderOutput } from './types/cloreai/cancelOrder.js';
|
|
3
3
|
import { type CreateOrderBody, type CreateOrderOutput } from './types/cloreai/createOrder.js';
|
|
4
4
|
import { type MarketplaceOutput } from './types/cloreai/marketplace.js';
|
|
@@ -13,14 +13,14 @@ import { type Options } from './types/options.js';
|
|
|
13
13
|
export declare class CloreAI {
|
|
14
14
|
readonly api: AxiosInstance;
|
|
15
15
|
constructor(options: Options);
|
|
16
|
-
wallets(): Promise<WalletsOutput>;
|
|
17
|
-
myServers(): Promise<MyServersOutput>;
|
|
18
|
-
serverConfig(body: ServerConfigBody): Promise<ServerConfigOutput>;
|
|
19
|
-
marketplace(): Promise<MarketplaceOutput>;
|
|
20
|
-
myOrders(params?: MyOrdersParams): Promise<MyOrdersOutput>;
|
|
21
|
-
spotMarketplace(params: SpotMarketplaceParams): Promise<SpotMarketplaceOutput>;
|
|
22
|
-
setServerSettings(body: SetServerSettingsBody): Promise<SetServerSettingsOutput>;
|
|
23
|
-
setSpotPrice(body: SetSpotPriceBody): Promise<SetSpotPriceOutput>;
|
|
24
|
-
cancelOrder(body: CancelOrderBody): Promise<CancelOrderOutput>;
|
|
25
|
-
createOrder(body: CreateOrderBody): Promise<CreateOrderOutput>;
|
|
16
|
+
wallets(config?: AxiosRequestConfig): Promise<WalletsOutput>;
|
|
17
|
+
myServers(config?: AxiosRequestConfig): Promise<MyServersOutput>;
|
|
18
|
+
serverConfig(body: ServerConfigBody, config?: AxiosRequestConfig<ServerConfigBody>): Promise<ServerConfigOutput>;
|
|
19
|
+
marketplace(config?: AxiosRequestConfig): Promise<MarketplaceOutput>;
|
|
20
|
+
myOrders(params?: MyOrdersParams, config?: AxiosRequestConfig): Promise<MyOrdersOutput>;
|
|
21
|
+
spotMarketplace(params: SpotMarketplaceParams, config?: AxiosRequestConfig): Promise<SpotMarketplaceOutput>;
|
|
22
|
+
setServerSettings(body: SetServerSettingsBody, config?: AxiosRequestConfig<SetServerSettingsBody>): Promise<SetServerSettingsOutput>;
|
|
23
|
+
setSpotPrice(body: SetSpotPriceBody, config?: AxiosRequestConfig<SetSpotPriceBody>): Promise<SetSpotPriceOutput>;
|
|
24
|
+
cancelOrder(body: CancelOrderBody, config?: AxiosRequestConfig<CancelOrderBody>): Promise<CancelOrderOutput>;
|
|
25
|
+
createOrder(body: CreateOrderBody, config?: AxiosRequestConfig<CreateOrderBody>): Promise<CreateOrderOutput>;
|
|
26
26
|
}
|
package/build/CloreAI.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
import { statusCodes } from './constants.js';
|
|
3
3
|
import { CustomError, DatabaseError, ExceededError, InvalidApiTokenError, InvalidEndpointError, InvalidInputDataError, UnknownError } from './errors.js';
|
|
4
|
+
import { getErrorMessage } from './getErrorMessage.js';
|
|
4
5
|
export class CloreAI {
|
|
5
6
|
api;
|
|
6
7
|
constructor(options) {
|
|
@@ -17,12 +18,7 @@ export class CloreAI {
|
|
|
17
18
|
if (response.data.code === statusCodes['NORMAL']) {
|
|
18
19
|
return response;
|
|
19
20
|
}
|
|
20
|
-
const
|
|
21
|
-
const errorFieldMessage = response.data.error != null ? `Error field "${response.data.error}".` : null;
|
|
22
|
-
const errorMessageArray = [statusCodeMessage, errorFieldMessage].filter((message) => {
|
|
23
|
-
return message != null;
|
|
24
|
-
});
|
|
25
|
-
const errorMessage = errorMessageArray.join(' ');
|
|
21
|
+
const errorMessage = getErrorMessage(response.data.code, response.data.error);
|
|
26
22
|
switch (response.data.code) {
|
|
27
23
|
case statusCodes['DATABASE_ERROR']:
|
|
28
24
|
throw new DatabaseError(errorMessage, undefined, response.config, response.request, response);
|
|
@@ -41,44 +37,44 @@ export class CloreAI {
|
|
|
41
37
|
}
|
|
42
38
|
});
|
|
43
39
|
}
|
|
44
|
-
async wallets() {
|
|
45
|
-
const response = await this.api.get('/wallets');
|
|
40
|
+
async wallets(config) {
|
|
41
|
+
const response = await this.api.get('/wallets', config);
|
|
46
42
|
return response.data;
|
|
47
43
|
}
|
|
48
|
-
async myServers() {
|
|
49
|
-
const response = await this.api.get('/my_servers');
|
|
44
|
+
async myServers(config) {
|
|
45
|
+
const response = await this.api.get('/my_servers', config);
|
|
50
46
|
return response.data;
|
|
51
47
|
}
|
|
52
|
-
async serverConfig(body) {
|
|
53
|
-
const response = await this.api.get('/server_config', { data: body });
|
|
48
|
+
async serverConfig(body, config) {
|
|
49
|
+
const response = await this.api.get('/server_config', { ...config, data: body });
|
|
54
50
|
return response.data;
|
|
55
51
|
}
|
|
56
|
-
async marketplace() {
|
|
57
|
-
const response = await this.api.get('/marketplace');
|
|
52
|
+
async marketplace(config) {
|
|
53
|
+
const response = await this.api.get('/marketplace', config);
|
|
58
54
|
return response.data;
|
|
59
55
|
}
|
|
60
|
-
async myOrders(params) {
|
|
61
|
-
const response = await this.api.get('/my_orders', { params });
|
|
56
|
+
async myOrders(params, config) {
|
|
57
|
+
const response = await this.api.get('/my_orders', { ...config, params });
|
|
62
58
|
return response.data;
|
|
63
59
|
}
|
|
64
|
-
async spotMarketplace(params) {
|
|
65
|
-
const response = await this.api.get('/spot_marketplace', { params });
|
|
60
|
+
async spotMarketplace(params, config) {
|
|
61
|
+
const response = await this.api.get('/spot_marketplace', { ...config, params });
|
|
66
62
|
return response.data;
|
|
67
63
|
}
|
|
68
|
-
async setServerSettings(body) {
|
|
69
|
-
const response = await this.api.post('/set_server_settings', body);
|
|
64
|
+
async setServerSettings(body, config) {
|
|
65
|
+
const response = await this.api.post('/set_server_settings', body, config);
|
|
70
66
|
return response.data;
|
|
71
67
|
}
|
|
72
|
-
async setSpotPrice(body) {
|
|
73
|
-
const response = await this.api.post('/set_spot_price', body);
|
|
68
|
+
async setSpotPrice(body, config) {
|
|
69
|
+
const response = await this.api.post('/set_spot_price', body, config);
|
|
74
70
|
return response.data;
|
|
75
71
|
}
|
|
76
|
-
async cancelOrder(body) {
|
|
77
|
-
const response = await this.api.post('/cancel_order', body);
|
|
72
|
+
async cancelOrder(body, config) {
|
|
73
|
+
const response = await this.api.post('/cancel_order', body, config);
|
|
78
74
|
return response.data;
|
|
79
75
|
}
|
|
80
|
-
async createOrder(body) {
|
|
81
|
-
const response = await this.api.post('/create_order', body);
|
|
76
|
+
async createOrder(body, config) {
|
|
77
|
+
const response = await this.api.post('/create_order', body, config);
|
|
82
78
|
return response.data;
|
|
83
79
|
}
|
|
84
80
|
}
|
package/build/WebAPI.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { type AxiosInstance } from 'axios';
|
|
1
|
+
import { type AxiosInstance, type AxiosRequestConfig } from 'axios';
|
|
2
2
|
import { type WebOptions } from './types/options.js';
|
|
3
3
|
import { type WebCreateOrderBody, type WebCreateOrderOutput } from './types/webapi/createOrder.js';
|
|
4
|
+
import { type WebMarketplaceOrdersBody, type WebMarketplaceOrdersOutput } from './types/webapi/marketplaceOrders.js';
|
|
4
5
|
import { type WebMarketplaceServersOutput } from './types/webapi/marketplaceServers.js';
|
|
5
6
|
export declare class WebAPI {
|
|
6
7
|
readonly api: AxiosInstance;
|
|
7
8
|
constructor(options: WebOptions);
|
|
8
|
-
marketplaceServers(): Promise<WebMarketplaceServersOutput>;
|
|
9
|
-
|
|
9
|
+
marketplaceServers(config?: AxiosRequestConfig): Promise<WebMarketplaceServersOutput>;
|
|
10
|
+
marketplaceOrders(body: WebMarketplaceOrdersBody, config?: AxiosRequestConfig<WebMarketplaceOrdersBody>): Promise<WebMarketplaceOrdersOutput>;
|
|
11
|
+
createOrder(body: WebCreateOrderBody, config?: AxiosRequestConfig<WebCreateOrderBody>): Promise<WebCreateOrderOutput>;
|
|
10
12
|
}
|
package/build/WebAPI.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
import { webStatusCodes } from './constants.js';
|
|
3
3
|
import { UnknownError } from './errors.js';
|
|
4
|
+
import { getErrorMessage } from './getErrorMessage.js';
|
|
4
5
|
export class WebAPI {
|
|
5
6
|
api;
|
|
6
7
|
constructor(options) {
|
|
@@ -20,21 +21,20 @@ export class WebAPI {
|
|
|
20
21
|
if (response.data.status === webStatusCodes['NORMAL']) {
|
|
21
22
|
return response;
|
|
22
23
|
}
|
|
23
|
-
const
|
|
24
|
-
const errorFieldMessage = response.data.error != null ? `Error field "${response.data.error}".` : null;
|
|
25
|
-
const errorMessageArray = [statusCodeMessage, errorFieldMessage].filter((message) => {
|
|
26
|
-
return message != null;
|
|
27
|
-
});
|
|
28
|
-
const errorMessage = errorMessageArray.join(' ');
|
|
24
|
+
const errorMessage = getErrorMessage(response.data.status, response.data.error);
|
|
29
25
|
throw new UnknownError(errorMessage, undefined, response.config, response.request, response);
|
|
30
26
|
});
|
|
31
27
|
}
|
|
32
|
-
async marketplaceServers() {
|
|
33
|
-
const response = await this.api.post('/marketplace/servers');
|
|
28
|
+
async marketplaceServers(config) {
|
|
29
|
+
const response = await this.api.post('/marketplace/servers', null, config);
|
|
34
30
|
return response.data;
|
|
35
31
|
}
|
|
36
|
-
async
|
|
37
|
-
const response = await this.api.post('/
|
|
32
|
+
async marketplaceOrders(body, config) {
|
|
33
|
+
const response = await this.api.post('/marketplace/orders', body, config);
|
|
34
|
+
return response.data;
|
|
35
|
+
}
|
|
36
|
+
async createOrder(body, config) {
|
|
37
|
+
const response = await this.api.post('/create_order', body, config);
|
|
38
38
|
return response.data;
|
|
39
39
|
}
|
|
40
40
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getErrorMessage(statusCode?: number | string, errorField?: string): string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export function getErrorMessage(statusCode, errorField) {
|
|
2
|
+
const statusCodeMessage = statusCode != null ? `Status code "${statusCode}".` : null;
|
|
3
|
+
const errorFieldMessage = errorField != null ? `Error field "${errorField}".` : null;
|
|
4
|
+
const errorMessageArray = [statusCodeMessage, errorFieldMessage].filter((message) => {
|
|
5
|
+
return message != null;
|
|
6
|
+
});
|
|
7
|
+
return errorMessageArray.join(' ');
|
|
8
|
+
}
|
package/build/index.d.ts
CHANGED
|
@@ -15,5 +15,6 @@ export * from './types/common.js';
|
|
|
15
15
|
export * from './types/options.js';
|
|
16
16
|
export * from './types/output.js';
|
|
17
17
|
export * from './types/webapi/createOrder.js';
|
|
18
|
+
export * from './types/webapi/marketplaceOrders.js';
|
|
18
19
|
export * from './types/webapi/marketplaceServers.js';
|
|
19
20
|
export * from './WebAPI.js';
|
package/build/index.js
CHANGED
|
@@ -15,5 +15,6 @@ export * from './types/common.js';
|
|
|
15
15
|
export * from './types/options.js';
|
|
16
16
|
export * from './types/output.js';
|
|
17
17
|
export * from './types/webapi/createOrder.js';
|
|
18
|
+
export * from './types/webapi/marketplaceOrders.js';
|
|
18
19
|
export * from './types/webapi/marketplaceServers.js';
|
|
19
20
|
export * from './WebAPI.js';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type Currency, type Price, type Specs } from '../common.js';
|
|
2
|
+
import { type WebOutput } from '../output.js';
|
|
3
|
+
export interface WebMarketplaceOrdersBody {
|
|
4
|
+
rc: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface WebMarketplaceOrdersOrder {
|
|
7
|
+
id: number;
|
|
8
|
+
fee: number;
|
|
9
|
+
creation_fee: number;
|
|
10
|
+
price: number;
|
|
11
|
+
mrl: number;
|
|
12
|
+
image: string;
|
|
13
|
+
currency: Currency;
|
|
14
|
+
spend: number;
|
|
15
|
+
ct: number;
|
|
16
|
+
p: number;
|
|
17
|
+
specs: Specs;
|
|
18
|
+
si: number;
|
|
19
|
+
mon_container: number;
|
|
20
|
+
online: boolean;
|
|
21
|
+
spot: boolean;
|
|
22
|
+
pub_cluster: string[];
|
|
23
|
+
tcp_ports: string[];
|
|
24
|
+
http_port: string;
|
|
25
|
+
}
|
|
26
|
+
export interface WebMarketplaceOrdersOutput extends WebOutput {
|
|
27
|
+
orders: WebMarketplaceOrdersOrder[];
|
|
28
|
+
ol: number;
|
|
29
|
+
eo: boolean;
|
|
30
|
+
http_endpoint_by_proxy: Record<string, string>;
|
|
31
|
+
PoH_rates: Record<string, Record<string, Price>>;
|
|
32
|
+
PoH_active: boolean;
|
|
33
|
+
allowed_features: string[];
|
|
34
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|