cloreai 0.1.3 → 0.1.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.
- package/build/CloreAI.d.ts +2 -2
- package/build/CloreAI.js +2 -2
- package/build/WebAPI.d.ts +10 -6
- package/build/WebAPI.js +14 -6
- package/build/constants.d.ts +0 -1
- package/build/constants.js +0 -3
- package/build/index.d.ts +5 -3
- package/build/index.js +5 -3
- package/build/types/{options.d.ts → config.d.ts} +3 -3
- package/build/types/webapi/createOrder.d.ts +22 -2
- package/build/types/webapi/getSpot.d.ts +26 -0
- package/build/types/webapi/{marketplaceOrders.d.ts → orders.d.ts} +4 -4
- package/build/types/webapi/{marketplaceServers.d.ts → servers.d.ts} +5 -5
- package/build/types/webapi/servers.js +1 -0
- package/build/types/webapi/setSpotPrice.d.ts +17 -0
- package/build/types/webapi/setSpotPrice.js +1 -0
- package/package.json +1 -1
- /package/build/types/{options.js → config.js} +0 -0
- /package/build/types/webapi/{marketplaceOrders.js → getSpot.js} +0 -0
- /package/build/types/webapi/{marketplaceServers.js → orders.js} +0 -0
package/build/CloreAI.d.ts
CHANGED
|
@@ -9,10 +9,10 @@ import { type SetServerSettingsBody, type SetServerSettingsOutput } from './type
|
|
|
9
9
|
import { type SetSpotPriceBody, type SetSpotPriceOutput } from './types/cloreai/setSpotPrice.js';
|
|
10
10
|
import { type SpotMarketplaceOutput, type SpotMarketplaceParams } from './types/cloreai/spotMarketplace.js';
|
|
11
11
|
import { type WalletsOutput } from './types/cloreai/wallets.js';
|
|
12
|
-
import { type
|
|
12
|
+
import { type Config } from './types/config.js';
|
|
13
13
|
export declare class CloreAI {
|
|
14
14
|
readonly api: AxiosInstance;
|
|
15
|
-
constructor(
|
|
15
|
+
constructor(config: Config);
|
|
16
16
|
wallets(config?: AxiosRequestConfig): Promise<WalletsOutput>;
|
|
17
17
|
myServers(config?: AxiosRequestConfig): Promise<MyServersOutput>;
|
|
18
18
|
serverConfig(body: ServerConfigBody, config?: AxiosRequestConfig<ServerConfigBody>): Promise<ServerConfigOutput>;
|
package/build/CloreAI.js
CHANGED
|
@@ -4,8 +4,8 @@ import { CustomError, DatabaseError, ExceededError, InvalidApiTokenError, Invali
|
|
|
4
4
|
import { getErrorMessage } from './getErrorMessage.js';
|
|
5
5
|
export class CloreAI {
|
|
6
6
|
api;
|
|
7
|
-
constructor(
|
|
8
|
-
const { apiKey, axiosConfig = {} } =
|
|
7
|
+
constructor(config) {
|
|
8
|
+
const { apiKey, axiosConfig = {} } = config;
|
|
9
9
|
this.api = axios.create({
|
|
10
10
|
...axiosConfig,
|
|
11
11
|
baseURL: 'https://api.clore.ai/v1',
|
package/build/WebAPI.d.ts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { type AxiosInstance, type AxiosRequestConfig } from 'axios';
|
|
2
|
-
import { type
|
|
2
|
+
import { type WebConfig } from './types/config.js';
|
|
3
3
|
import { type WebCancelOrderBody, type WebCancelOrderOutput } from './types/webapi/cancelOrder.js';
|
|
4
4
|
import { type WebCreateOrderBody, type WebCreateOrderOutput } from './types/webapi/createOrder.js';
|
|
5
|
-
import { type
|
|
6
|
-
import { type
|
|
5
|
+
import { type WebGetSpotBody, type WebGetSpotOutput } from './types/webapi/getSpot.js';
|
|
6
|
+
import { type WebOrdersBody } from './types/webapi/orders.js';
|
|
7
|
+
import { type WebServersOutput } from './types/webapi/servers.js';
|
|
8
|
+
import { type WebSetSpotPriceBody, type WebSetSpotPriceOutput } from './types/webapi/setSpotPrice.js';
|
|
7
9
|
export declare class WebAPI {
|
|
8
10
|
readonly api: AxiosInstance;
|
|
9
|
-
constructor(
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
constructor(config: WebConfig);
|
|
12
|
+
servers(config?: AxiosRequestConfig): Promise<WebServersOutput>;
|
|
13
|
+
orders(body: WebOrdersBody, config?: AxiosRequestConfig<WebOrdersBody>): Promise<WebServersOutput>;
|
|
14
|
+
getSpot(body: WebGetSpotBody, config?: AxiosRequestConfig<WebGetSpotBody>): Promise<WebGetSpotOutput>;
|
|
15
|
+
setSpotPrice(body: WebSetSpotPriceBody, config?: AxiosRequestConfig<WebSetSpotPriceBody>): Promise<WebSetSpotPriceOutput>;
|
|
12
16
|
cancelOrder(body: WebCancelOrderBody, config?: AxiosRequestConfig<WebCancelOrderBody>): Promise<WebCancelOrderOutput>;
|
|
13
17
|
createOrder(body: WebCreateOrderBody, config?: AxiosRequestConfig<WebCreateOrderBody>): Promise<WebCreateOrderOutput>;
|
|
14
18
|
}
|
package/build/WebAPI.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
|
-
import { webStatusCodes } from './constants.js';
|
|
3
2
|
import { UnknownError } from './errors.js';
|
|
4
3
|
import { getErrorMessage } from './getErrorMessage.js';
|
|
5
4
|
export class WebAPI {
|
|
6
5
|
api;
|
|
7
|
-
constructor(
|
|
8
|
-
const { token, axiosConfig = {} } =
|
|
6
|
+
constructor(config) {
|
|
7
|
+
const { token, axiosConfig = {} } = config;
|
|
9
8
|
this.api = axios.create({
|
|
10
9
|
...axiosConfig,
|
|
11
10
|
baseURL: 'https://clore.ai/webapi',
|
|
@@ -18,21 +17,30 @@ export class WebAPI {
|
|
|
18
17
|
return request;
|
|
19
18
|
});
|
|
20
19
|
this.api.interceptors.response.use((response) => {
|
|
21
|
-
|
|
20
|
+
const hasError = Boolean(response.data.error);
|
|
21
|
+
if (!hasError) {
|
|
22
22
|
return response;
|
|
23
23
|
}
|
|
24
24
|
const errorMessage = getErrorMessage(response.data.status, response.data.error);
|
|
25
25
|
throw new UnknownError(errorMessage, undefined, response.config, response.request, response);
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
|
-
async
|
|
28
|
+
async servers(config) {
|
|
29
29
|
const response = await this.api.post('/marketplace/servers', null, config);
|
|
30
30
|
return response.data;
|
|
31
31
|
}
|
|
32
|
-
async
|
|
32
|
+
async orders(body, config) {
|
|
33
33
|
const response = await this.api.post('/marketplace/orders', body, config);
|
|
34
34
|
return response.data;
|
|
35
35
|
}
|
|
36
|
+
async getSpot(body, config) {
|
|
37
|
+
const response = await this.api.post('/marketplace/get_spot', body, config);
|
|
38
|
+
return response.data;
|
|
39
|
+
}
|
|
40
|
+
async setSpotPrice(body, config) {
|
|
41
|
+
const response = await this.api.post('/marketplace/set_spot_price', body, config);
|
|
42
|
+
return response.data;
|
|
43
|
+
}
|
|
36
44
|
async cancelOrder(body, config) {
|
|
37
45
|
const response = await this.api.post('/marketplace/cancel_order', body, config);
|
|
38
46
|
return response.data;
|
package/build/constants.d.ts
CHANGED
package/build/constants.js
CHANGED
package/build/index.d.ts
CHANGED
|
@@ -12,10 +12,12 @@ export * from './types/cloreai/setSpotPrice.js';
|
|
|
12
12
|
export * from './types/cloreai/spotMarketplace.js';
|
|
13
13
|
export * from './types/cloreai/wallets.js';
|
|
14
14
|
export * from './types/common.js';
|
|
15
|
-
export * from './types/
|
|
15
|
+
export * from './types/config.js';
|
|
16
16
|
export * from './types/output.js';
|
|
17
17
|
export * from './types/webapi/cancelOrder.js';
|
|
18
18
|
export * from './types/webapi/createOrder.js';
|
|
19
|
-
export * from './types/webapi/
|
|
20
|
-
export * from './types/webapi/
|
|
19
|
+
export * from './types/webapi/getSpot.js';
|
|
20
|
+
export * from './types/webapi/orders.js';
|
|
21
|
+
export * from './types/webapi/servers.js';
|
|
22
|
+
export * from './types/webapi/setSpotPrice.js';
|
|
21
23
|
export * from './WebAPI.js';
|
package/build/index.js
CHANGED
|
@@ -12,10 +12,12 @@ export * from './types/cloreai/setSpotPrice.js';
|
|
|
12
12
|
export * from './types/cloreai/spotMarketplace.js';
|
|
13
13
|
export * from './types/cloreai/wallets.js';
|
|
14
14
|
export * from './types/common.js';
|
|
15
|
-
export * from './types/
|
|
15
|
+
export * from './types/config.js';
|
|
16
16
|
export * from './types/output.js';
|
|
17
17
|
export * from './types/webapi/cancelOrder.js';
|
|
18
18
|
export * from './types/webapi/createOrder.js';
|
|
19
|
-
export * from './types/webapi/
|
|
20
|
-
export * from './types/webapi/
|
|
19
|
+
export * from './types/webapi/getSpot.js';
|
|
20
|
+
export * from './types/webapi/orders.js';
|
|
21
|
+
export * from './types/webapi/servers.js';
|
|
22
|
+
export * from './types/webapi/setSpotPrice.js';
|
|
21
23
|
export * from './WebAPI.js';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { type CreateAxiosDefaults } from 'axios';
|
|
2
|
-
export interface
|
|
2
|
+
export interface CommonConfig {
|
|
3
3
|
axiosConfig?: CreateAxiosDefaults;
|
|
4
4
|
}
|
|
5
|
-
export interface
|
|
5
|
+
export interface Config extends CommonConfig {
|
|
6
6
|
apiKey: string;
|
|
7
7
|
}
|
|
8
|
-
export interface
|
|
8
|
+
export interface WebConfig extends CommonConfig {
|
|
9
9
|
token: string;
|
|
10
10
|
}
|
|
@@ -1,5 +1,25 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type Currency } from '../common.js';
|
|
2
2
|
import { type WebOutput } from '../output.js';
|
|
3
|
-
export
|
|
3
|
+
export interface WebCreateOrderCommon {
|
|
4
|
+
currency: Currency;
|
|
5
|
+
image: string;
|
|
6
|
+
renting_server: number;
|
|
7
|
+
ports?: Record<string, string>;
|
|
8
|
+
env?: Record<string, string>;
|
|
9
|
+
jupyter_token?: string;
|
|
10
|
+
ssh_key?: string;
|
|
11
|
+
ssh_password?: string;
|
|
12
|
+
command?: string;
|
|
13
|
+
required_price?: number;
|
|
14
|
+
autossh_entrypoint?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface WebCreateOrderOnDemand extends WebCreateOrderCommon {
|
|
17
|
+
type: 'on-demand';
|
|
18
|
+
}
|
|
19
|
+
export interface WebCreateOrderSpot extends WebCreateOrderCommon {
|
|
20
|
+
type: 'spot';
|
|
21
|
+
spotprice: number;
|
|
22
|
+
}
|
|
23
|
+
export type WebCreateOrderBody = WebCreateOrderOnDemand | WebCreateOrderSpot;
|
|
4
24
|
export interface WebCreateOrderOutput extends WebOutput {
|
|
5
25
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type Currency, type Pricing, type Visibility } from '../common.js';
|
|
2
|
+
import { type WebOutput } from '../output.js';
|
|
3
|
+
export interface WebGetSpotBody {
|
|
4
|
+
id: number;
|
|
5
|
+
}
|
|
6
|
+
export interface WebGetSpotDataOffer {
|
|
7
|
+
offer_id: number;
|
|
8
|
+
bid: number;
|
|
9
|
+
active: boolean;
|
|
10
|
+
my: boolean;
|
|
11
|
+
currency: Currency;
|
|
12
|
+
}
|
|
13
|
+
export interface WebGetSpotDataServer {
|
|
14
|
+
min_pricing: Pricing;
|
|
15
|
+
mrl: number;
|
|
16
|
+
visibility: Visibility;
|
|
17
|
+
online: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface WebGetSpotData {
|
|
20
|
+
currency_rates_in_usd: Pricing;
|
|
21
|
+
offers: WebGetSpotDataOffer[];
|
|
22
|
+
server: WebGetSpotDataServer;
|
|
23
|
+
}
|
|
24
|
+
export interface WebGetSpotOutput extends WebOutput {
|
|
25
|
+
data: WebGetSpotData;
|
|
26
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type Currency, type Price, type Specs } from '../common.js';
|
|
2
2
|
import { type WebOutput } from '../output.js';
|
|
3
|
-
export interface
|
|
3
|
+
export interface WebOrdersBody {
|
|
4
4
|
rc: boolean;
|
|
5
5
|
}
|
|
6
|
-
export interface
|
|
6
|
+
export interface WebOrdersOrder {
|
|
7
7
|
id: number;
|
|
8
8
|
fee: number;
|
|
9
9
|
creation_fee: number;
|
|
@@ -23,8 +23,8 @@ export interface WebMarketplaceOrdersOrder {
|
|
|
23
23
|
tcp_ports: string[];
|
|
24
24
|
http_port: string;
|
|
25
25
|
}
|
|
26
|
-
export interface
|
|
27
|
-
orders:
|
|
26
|
+
export interface WebOrdersOutput extends WebOutput {
|
|
27
|
+
orders: WebOrdersOrder[];
|
|
28
28
|
ol: number;
|
|
29
29
|
eo: boolean;
|
|
30
30
|
http_endpoint_by_proxy: Record<string, string>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { type Currency, type Price, type Specs } from '../common.js';
|
|
2
2
|
import { type WebOutput } from '../output.js';
|
|
3
|
-
export interface
|
|
3
|
+
export interface WebServersServerRating {
|
|
4
4
|
avg: number;
|
|
5
5
|
cnt: number;
|
|
6
6
|
}
|
|
7
|
-
export interface
|
|
7
|
+
export interface WebServersServer {
|
|
8
8
|
id: number;
|
|
9
9
|
owner: number;
|
|
10
10
|
mrl: number;
|
|
@@ -13,11 +13,11 @@ export interface WebMarketplaceServersServer {
|
|
|
13
13
|
specs: Specs;
|
|
14
14
|
reliability: number;
|
|
15
15
|
allowed_coins: Currency[];
|
|
16
|
-
rating:
|
|
16
|
+
rating: WebServersServerRating;
|
|
17
17
|
cuda_version: string;
|
|
18
18
|
}
|
|
19
|
-
export interface
|
|
20
|
-
all_servers:
|
|
19
|
+
export interface WebServersOutput extends WebOutput {
|
|
20
|
+
all_servers: WebServersServer[];
|
|
21
21
|
creation_fees: number;
|
|
22
22
|
disable_usd: number;
|
|
23
23
|
my_servers: number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type WebOutput } from '../output.js';
|
|
2
|
+
export interface WebSetSpotPriceBody {
|
|
3
|
+
desired_price: number;
|
|
4
|
+
order_id: number;
|
|
5
|
+
}
|
|
6
|
+
export interface WebSetSpotPriceMaxStep extends WebOutput {
|
|
7
|
+
error: 'exceeded_max_step';
|
|
8
|
+
max_step: number;
|
|
9
|
+
}
|
|
10
|
+
export interface WebSetSpotPriceTimeToLowering extends WebOutput {
|
|
11
|
+
error: 'can_lower_every_600_seconds';
|
|
12
|
+
time_to_lowering: number;
|
|
13
|
+
}
|
|
14
|
+
export interface WebSetSpotPriceSuccess extends WebOutput {
|
|
15
|
+
error: undefined;
|
|
16
|
+
}
|
|
17
|
+
export type WebSetSpotPriceOutput = WebSetSpotPriceMaxStep | WebSetSpotPriceTimeToLowering | WebSetSpotPriceSuccess;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|