cloreai 0.1.11 → 0.1.13

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.
Files changed (57) hide show
  1. package/build/cloreai/CloreAI.d.ts +24 -24
  2. package/build/cloreai/CloreAI.js +55 -61
  3. package/build/cloreai/endpoints/cancelOrder.d.ts +4 -5
  4. package/build/cloreai/endpoints/createOrder.d.ts +4 -26
  5. package/build/cloreai/endpoints/marketplace.d.ts +4 -12
  6. package/build/cloreai/endpoints/myOrders.d.ts +5 -24
  7. package/build/cloreai/endpoints/myServers.d.ts +5 -5
  8. package/build/cloreai/endpoints/serverConfig.d.ts +8 -8
  9. package/build/cloreai/endpoints/setServerSettings.d.ts +3 -4
  10. package/build/cloreai/endpoints/setSpotPrice.d.ts +4 -17
  11. package/build/cloreai/endpoints/spotMarketplace.d.ts +5 -21
  12. package/build/cloreai/endpoints/wallets.d.ts +5 -5
  13. package/build/cloreai/index.d.ts +11 -11
  14. package/build/cloreai/index.js +0 -11
  15. package/build/cloreai/types.d.ts +2 -2
  16. package/build/common/constants.d.ts +7 -2
  17. package/build/common/constants.js +7 -2
  18. package/build/common/endpoints/cancelOrder.d.ts +3 -0
  19. package/build/common/endpoints/cancelOrder.js +2 -0
  20. package/build/common/endpoints/createOrder.d.ts +25 -0
  21. package/build/common/endpoints/marketplace.d.ts +19 -0
  22. package/build/common/endpoints/myOrders.d.ts +23 -0
  23. package/build/common/endpoints/setSpotPrice.d.ts +16 -0
  24. package/build/common/endpoints/setSpotPrice.js +2 -0
  25. package/build/common/endpoints/spotMarketplace.d.ts +19 -0
  26. package/build/common/errors.d.ts +2 -2
  27. package/build/common/errors.js +2 -2
  28. package/build/common/helpers.d.ts +6 -0
  29. package/build/common/helpers.js +25 -0
  30. package/build/common/index.d.ts +8 -3
  31. package/build/common/index.js +1 -3
  32. package/build/common/types.d.ts +57 -4
  33. package/build/webapi/WebAPI.d.ts +16 -16
  34. package/build/webapi/WebAPI.js +37 -43
  35. package/build/webapi/endpoints/cancelOrder.d.ts +4 -5
  36. package/build/webapi/endpoints/createOrder.d.ts +4 -27
  37. package/build/webapi/endpoints/marketplace.d.ts +10 -0
  38. package/build/webapi/endpoints/marketplace.js +1 -0
  39. package/build/webapi/endpoints/myOrders.d.ts +15 -0
  40. package/build/webapi/endpoints/myOrders.js +1 -0
  41. package/build/webapi/endpoints/setSpotPrice.d.ts +4 -17
  42. package/build/webapi/endpoints/spotMarketplace.d.ts +8 -0
  43. package/build/webapi/endpoints/spotMarketplace.js +1 -0
  44. package/build/webapi/index.d.ts +7 -7
  45. package/build/webapi/index.js +0 -7
  46. package/build/webapi/types.d.ts +2 -2
  47. package/package.json +11 -11
  48. package/build/common/api.d.ts +0 -30
  49. package/build/common/getErrorMessage.d.ts +0 -1
  50. package/build/common/getErrorMessage.js +0 -11
  51. package/build/webapi/endpoints/getSpot.d.ts +0 -26
  52. package/build/webapi/endpoints/orders.d.ts +0 -34
  53. package/build/webapi/endpoints/servers.d.ts +0 -25
  54. /package/build/common/{api.js → endpoints/createOrder.js} +0 -0
  55. /package/build/{webapi/endpoints/getSpot.js → common/endpoints/marketplace.js} +0 -0
  56. /package/build/{webapi/endpoints/orders.js → common/endpoints/myOrders.js} +0 -0
  57. /package/build/{webapi/endpoints/servers.js → common/endpoints/spotMarketplace.js} +0 -0
@@ -1,30 +1,30 @@
1
1
  import { type AxiosInstance, type AxiosRequestConfig } from 'axios';
2
- import PQueue, { type QueueAddOptions } from 'p-queue';
3
- import type { CancelOrderBody, CancelOrderOutput } from './endpoints/cancelOrder.js';
4
- import type { CreateOrderBody, CreateOrderOutput } from './endpoints/createOrder.js';
5
- import type { MarketplaceOutput } from './endpoints/marketplace.js';
6
- import type { MyOrdersOutput, MyOrdersParams } from './endpoints/myOrders.js';
7
- import type { MyServersOutput } from './endpoints/myServers.js';
8
- import type { ServerConfigBody, ServerConfigOutput } from './endpoints/serverConfig.js';
9
- import type { SetServerSettingsBody, SetServerSettingsOutput } from './endpoints/setServerSettings.js';
10
- import type { SetSpotPriceBody, SetSpotPriceOutput } from './endpoints/setSpotPrice.js';
11
- import type { SpotMarketplaceOutput, SpotMarketplaceParams } from './endpoints/spotMarketplace.js';
12
- import type { WalletsOutput } from './endpoints/wallets.js';
2
+ import PQueue from 'p-queue';
3
+ import type { CancelOrderRequestData, CancelOrderResponseData } from './endpoints/cancelOrder.js';
4
+ import type { CreateOrderRequestData, CreateOrderResponseData } from './endpoints/createOrder.js';
5
+ import type { MarketplaceResponseData } from './endpoints/marketplace.js';
6
+ import type { MyOrdersRequestParams, MyOrdersResponseData } from './endpoints/myOrders.js';
7
+ import type { MyServersResponseData } from './endpoints/myServers.js';
8
+ import type { ServerConfigRequestData, ServerConfigResponseData } from './endpoints/serverConfig.js';
9
+ import type { SetServerSettingsRequestData, SetServerSettingsResponseData } from './endpoints/setServerSettings.js';
10
+ import type { SetSpotPriceRequestData, SetSpotPriceResponseData } from './endpoints/setSpotPrice.js';
11
+ import type { SpotMarketplaceRequestParams, SpotMarketplaceResponseData } from './endpoints/spotMarketplace.js';
12
+ import type { WalletsResponseData } from './endpoints/wallets.js';
13
13
  import type { Config } from './types.js';
14
14
  declare class CloreAI {
15
- readonly axios: AxiosInstance;
16
- readonly rateLimitQueue: PQueue;
17
- readonly rateLimitCreateOrderQueue: PQueue;
15
+ axios: AxiosInstance;
16
+ rateLimitQueue: PQueue;
17
+ rateLimitQueueCreateOrder: PQueue;
18
18
  constructor(config: Config);
19
- wallets(axiosConfig?: AxiosRequestConfig, queueOptions?: QueueAddOptions): Promise<WalletsOutput>;
20
- myServers(axiosConfig?: AxiosRequestConfig, queueOptions?: QueueAddOptions): Promise<MyServersOutput>;
21
- serverConfig(body: ServerConfigBody, axiosConfig?: AxiosRequestConfig<ServerConfigBody>, queueOptions?: QueueAddOptions): Promise<ServerConfigOutput>;
22
- marketplace(axiosConfig?: AxiosRequestConfig, queueOptions?: QueueAddOptions): Promise<MarketplaceOutput>;
23
- myOrders(params?: MyOrdersParams, axiosConfig?: AxiosRequestConfig, queueOptions?: QueueAddOptions): Promise<MyOrdersOutput>;
24
- spotMarketplace(params: SpotMarketplaceParams, axiosConfig?: AxiosRequestConfig, queueOptions?: QueueAddOptions): Promise<SpotMarketplaceOutput>;
25
- setServerSettings(body: SetServerSettingsBody, axiosConfig?: AxiosRequestConfig<SetServerSettingsBody>, queueOptions?: QueueAddOptions): Promise<SetServerSettingsOutput>;
26
- setSpotPrice(body: SetSpotPriceBody, axiosConfig?: AxiosRequestConfig<SetSpotPriceBody>, queueOptions?: QueueAddOptions): Promise<SetSpotPriceOutput>;
27
- cancelOrder(body: CancelOrderBody, axiosConfig?: AxiosRequestConfig<CancelOrderBody>, queueOptions?: QueueAddOptions): Promise<CancelOrderOutput>;
28
- createOrder(body: CreateOrderBody, axiosConfig?: AxiosRequestConfig<CreateOrderBody>, queueOptions?: QueueAddOptions): Promise<CreateOrderOutput>;
19
+ wallets(config?: AxiosRequestConfig): Promise<WalletsResponseData>;
20
+ myServers(config?: AxiosRequestConfig): Promise<MyServersResponseData>;
21
+ serverConfig(data: ServerConfigRequestData, config?: AxiosRequestConfig): Promise<ServerConfigResponseData>;
22
+ marketplace(config?: AxiosRequestConfig): Promise<MarketplaceResponseData>;
23
+ myOrders(params: MyOrdersRequestParams, config?: AxiosRequestConfig): Promise<MyOrdersResponseData>;
24
+ spotMarketplace(params: SpotMarketplaceRequestParams, config?: AxiosRequestConfig): Promise<SpotMarketplaceResponseData>;
25
+ setServerSettings(data: SetServerSettingsRequestData, config?: AxiosRequestConfig): Promise<SetServerSettingsResponseData>;
26
+ setSpotPrice(data: SetSpotPriceRequestData, config?: AxiosRequestConfig): Promise<SetSpotPriceResponseData>;
27
+ cancelOrder(data: CancelOrderRequestData, config?: AxiosRequestConfig): Promise<CancelOrderResponseData>;
28
+ createOrder(data: CreateOrderRequestData, config?: AxiosRequestConfig): Promise<CreateOrderResponseData>;
29
29
  }
30
30
  export default CloreAI;
@@ -1,28 +1,32 @@
1
1
  import axios from 'axios';
2
2
  import PQueue from 'p-queue';
3
- import { CustomError, DatabaseError, ExceededError, InvalidApiTokenError, InvalidEndpointError, InvalidInputDataError, UnknownError } from '../common/errors.js';
4
- import { getErrorMessage, RATE_LIMIT, RATE_LIMIT_CREATE_ORDER, statusCodes } from '../common/index.js';
3
+ import { priorityLevels, RATE_LIMIT, RATE_LIMIT_CREATE_ORDER, statusCodes } from '../common/constants.js';
4
+ import { DatabaseError, ExceededError, InvalidApiTokenError, InvalidEndpointError, InvalidInputDataError, OtherError, UnknownError } from '../common/errors.js';
5
+ import { getErrorMessage, getQueueOptions } from '../common/helpers.js';
5
6
  class CloreAI {
6
7
  axios;
7
- rateLimitQueue = new PQueue({
8
- interval: RATE_LIMIT,
9
- intervalCap: 1,
10
- concurrency: 1,
11
- });
12
- rateLimitCreateOrderQueue = new PQueue({
13
- interval: RATE_LIMIT_CREATE_ORDER,
14
- intervalCap: 1,
15
- concurrency: 1,
16
- });
8
+ rateLimitQueue;
9
+ rateLimitQueueCreateOrder;
17
10
  constructor(config) {
18
- const { apiKey, axiosConfig = {} } = config;
11
+ this.rateLimitQueue = new PQueue({
12
+ interval: RATE_LIMIT,
13
+ intervalCap: 1,
14
+ concurrency: 1,
15
+ ...config.rateLimitQueueOptions,
16
+ });
17
+ this.rateLimitQueueCreateOrder = new PQueue({
18
+ interval: RATE_LIMIT_CREATE_ORDER,
19
+ intervalCap: 1,
20
+ concurrency: 1,
21
+ ...config.rateLimitQueueOptionsCreateOrder,
22
+ });
19
23
  this.axios = axios.create({
20
- ...axiosConfig,
24
+ ...config.axiosConfig,
21
25
  baseURL: 'https://api.clore.ai/v1',
22
- headers: {
23
- ...axiosConfig.headers,
24
- auth: apiKey,
25
- },
26
+ });
27
+ this.axios.interceptors.request.use((request) => {
28
+ request.headers.set('auth', config.apiKey);
29
+ return request;
26
30
  });
27
31
  this.axios.interceptors.response.use((response) => {
28
32
  if (response.data.code === statusCodes.NORMAL) {
@@ -47,81 +51,71 @@ class CloreAI {
47
51
  throw new InvalidEndpointError(...axiosErrorParameters);
48
52
  case statusCodes.EXCEEDED:
49
53
  throw new ExceededError(...axiosErrorParameters);
50
- case statusCodes.ERROR:
51
- throw new CustomError(...axiosErrorParameters);
54
+ case statusCodes.OTHER:
55
+ throw new OtherError(...axiosErrorParameters);
52
56
  default:
53
57
  throw new UnknownError(...axiosErrorParameters);
54
58
  }
55
59
  });
56
60
  }
57
- async wallets(axiosConfig, queueOptions) {
61
+ async wallets(config) {
58
62
  const response = await this.rateLimitQueue.add(async () => {
59
- return await this.axios.get('/wallets', axiosConfig);
60
- }, { ...queueOptions, throwOnTimeout: true });
63
+ return await this.axios.get('/wallets', config);
64
+ }, getQueueOptions(priorityLevels.NORMAL, config));
61
65
  return response.data;
62
66
  }
63
- async myServers(axiosConfig, queueOptions) {
67
+ async myServers(config) {
64
68
  const response = await this.rateLimitQueue.add(async () => {
65
- return await this.axios.get('/my_servers', axiosConfig);
66
- }, { ...queueOptions, throwOnTimeout: true });
69
+ return await this.axios.get('/my_servers', config);
70
+ }, getQueueOptions(priorityLevels.NORMAL, config));
67
71
  return response.data;
68
72
  }
69
- async serverConfig(body, axiosConfig, queueOptions) {
73
+ async serverConfig(data, config) {
70
74
  const response = await this.rateLimitQueue.add(async () => {
71
- return await this.axios.get('/server_config', { ...axiosConfig, data: body });
72
- }, { ...queueOptions, throwOnTimeout: true });
75
+ return await this.axios.get('/server_config', { ...config, data });
76
+ }, getQueueOptions(priorityLevels.NORMAL, config));
73
77
  return response.data;
74
78
  }
75
- async marketplace(axiosConfig, queueOptions) {
79
+ async marketplace(config) {
76
80
  const response = await this.rateLimitQueue.add(async () => {
77
- return await this.axios.get('/marketplace', axiosConfig);
78
- }, { ...queueOptions, throwOnTimeout: true });
81
+ return await this.axios.get('/marketplace', config);
82
+ }, getQueueOptions(priorityLevels.NORMAL, config));
79
83
  return response.data;
80
84
  }
81
- async myOrders(params, axiosConfig, queueOptions) {
85
+ async myOrders(params, config) {
82
86
  const response = await this.rateLimitQueue.add(async () => {
83
- return await this.axios.get('/my_orders', { ...axiosConfig, params });
84
- }, { ...queueOptions, throwOnTimeout: true });
87
+ return await this.axios.get('/my_orders', { ...config, params });
88
+ }, getQueueOptions(priorityLevels.NORMAL, config));
85
89
  return response.data;
86
90
  }
87
- async spotMarketplace(params, axiosConfig, queueOptions) {
91
+ async spotMarketplace(params, config) {
88
92
  const response = await this.rateLimitQueue.add(async () => {
89
- return await this.axios.get('/spot_marketplace', { ...axiosConfig, params });
90
- }, { ...queueOptions, throwOnTimeout: true });
93
+ return await this.axios.get('/spot_marketplace', { ...config, params });
94
+ }, getQueueOptions(priorityLevels.NORMAL, config));
91
95
  return response.data;
92
96
  }
93
- async setServerSettings(body, axiosConfig, queueOptions) {
97
+ async setServerSettings(data, config) {
94
98
  const response = await this.rateLimitQueue.add(async () => {
95
- return await this.axios.post('/set_server_settings', body, axiosConfig);
96
- }, { ...queueOptions, throwOnTimeout: true });
99
+ return await this.axios.post('/set_server_settings', data, config);
100
+ }, getQueueOptions(priorityLevels.HIGH, config));
97
101
  return response.data;
98
102
  }
99
- async setSpotPrice(body, axiosConfig, queueOptions) {
103
+ async setSpotPrice(data, config) {
100
104
  const response = await this.rateLimitQueue.add(async () => {
101
- return await this.axios.post('/set_spot_price', body, axiosConfig);
102
- }, { ...queueOptions, throwOnTimeout: true });
105
+ return await this.axios.post('/set_spot_price', data, config);
106
+ }, getQueueOptions(priorityLevels.HIGH, config));
103
107
  return response.data;
104
108
  }
105
- async cancelOrder(body, axiosConfig, queueOptions) {
109
+ async cancelOrder(data, config) {
106
110
  const response = await this.rateLimitQueue.add(async () => {
107
- return await this.axios.post('/cancel_order', body, axiosConfig);
108
- }, { ...queueOptions, throwOnTimeout: true });
111
+ return await this.axios.post('/cancel_order', data, config);
112
+ }, getQueueOptions(priorityLevels.HIGH, config));
109
113
  return response.data;
110
114
  }
111
- async createOrder(body, axiosConfig, queueOptions) {
112
- const response = await this.rateLimitQueue.add(async () => {
113
- this.rateLimitQueue.pause();
114
- try {
115
- return await this.rateLimitCreateOrderQueue.add(async () => {
116
- return await this.axios.post('/create_order', body, axiosConfig);
117
- }, { ...queueOptions, throwOnTimeout: true });
118
- }
119
- finally {
120
- setTimeout(() => {
121
- this.rateLimitQueue.start();
122
- }, RATE_LIMIT);
123
- }
124
- }, { ...queueOptions, throwOnTimeout: true });
115
+ async createOrder(data, config) {
116
+ const response = await this.rateLimitQueueCreateOrder.add(async () => {
117
+ return await this.axios.post('/create_order', data, config);
118
+ }, getQueueOptions(priorityLevels.HIGHEST, config));
125
119
  return response.data;
126
120
  }
127
121
  }
@@ -1,7 +1,6 @@
1
- import type { Output } from '../types.js';
2
- export interface CancelOrderBody {
3
- id: number;
1
+ import type { CancelOrderRequestDataCommon } from '../../common/endpoints/cancelOrder.js';
2
+ import type { ResponseData } from '../types.js';
3
+ export interface CancelOrderRequestData extends CancelOrderRequestDataCommon {
4
4
  issue?: string;
5
5
  }
6
- export interface CancelOrderOutput extends Output {
7
- }
6
+ export type CancelOrderResponseData = ResponseData;
@@ -1,26 +1,4 @@
1
- import type { Currency, OrderType } from '../../common/index.js';
2
- import type { Output } from '../types.js';
3
- export interface CreateOrderCommon {
4
- type: OrderType;
5
- currency: Currency;
6
- image: string;
7
- renting_server: number;
8
- ports?: Record<string, string>;
9
- env?: Record<string, string>;
10
- jupyter_token?: string;
11
- ssh_key?: string;
12
- ssh_password?: string;
13
- command?: string;
14
- required_price?: number;
15
- autossh_entrypoint?: boolean;
16
- }
17
- export interface CreateOrderOnDemand extends CreateOrderCommon {
18
- type: 'on-demand';
19
- }
20
- export interface CreateOrderSpot extends CreateOrderCommon {
21
- type: 'spot';
22
- spotprice: number;
23
- }
24
- export type CreateOrderBody = CreateOrderOnDemand | CreateOrderSpot;
25
- export interface CreateOrderOutput extends Output {
26
- }
1
+ import type { CreateOrderRequestDataCommon } from '../../common/endpoints/createOrder.js';
2
+ import type { ResponseData } from '../types.js';
3
+ export type CreateOrderRequestData = CreateOrderRequestDataCommon;
4
+ export type CreateOrderResponseData = ResponseData;
@@ -1,14 +1,6 @@
1
- import type { Price, Specs } from '../../common/index.js';
2
- import type { Output } from '../types.js';
3
- export interface MarketplaceServer {
4
- id: number;
5
- owner: number;
6
- mrl: number;
7
- price: Price;
8
- rented: boolean;
9
- specs: Specs;
10
- }
11
- export interface MarketplaceOutput extends Output {
12
- servers: MarketplaceServer[];
1
+ import type { MarketplaceResponseDataServerCommon } from '../../common/endpoints/marketplace.js';
2
+ import type { ResponseData } from '../types.js';
3
+ export interface MarketplaceResponseData extends ResponseData {
4
+ servers: MarketplaceResponseDataServerCommon[];
13
5
  my_servers: number[];
14
6
  }
@@ -1,28 +1,9 @@
1
- import type { Currency, Specs } from '../../common/index.js';
2
- import type { Output } from '../types.js';
3
- export interface MyOrdersParams {
1
+ import type { MyOrdersResponseDataOrderCommon } from '../../common/endpoints/myOrders.js';
2
+ import type { ResponseData } from '../types.js';
3
+ export interface MyOrdersRequestParams {
4
4
  return_completed?: boolean;
5
5
  }
6
- export interface MyOrdersOrder {
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
- pub_cluster: string[];
20
- tcp_ports: string[];
21
- http_port: string;
22
- spot: boolean;
23
- expired: boolean;
24
- }
25
- export interface MyOrdersOutput extends Output {
26
- orders: MyOrdersOrder[];
6
+ export interface MyOrdersResponseData extends ResponseData {
7
+ orders: MyOrdersResponseDataOrderCommon[];
27
8
  limit: number;
28
9
  }
@@ -1,6 +1,6 @@
1
- import type { Pricing, Specs, Visibility } from '../../common/index.js';
2
- import type { Output } from '../types.js';
3
- export interface MyServersServer {
1
+ import type { Pricing, Specs, Visibility } from '../../common/types.js';
2
+ import type { ResponseData } from '../types.js';
3
+ export interface MyServersResponseDataServer {
4
4
  name: string;
5
5
  connected: boolean;
6
6
  visibility: Visibility;
@@ -10,7 +10,7 @@ export interface MyServersServer {
10
10
  init_token: string;
11
11
  specs: Specs;
12
12
  }
13
- export interface MyServersOutput extends Output {
14
- servers: MyServersServer[];
13
+ export interface MyServersResponseData extends ResponseData {
14
+ servers: MyServersResponseDataServer[];
15
15
  limit: number;
16
16
  }
@@ -1,15 +1,15 @@
1
- import type { Pricing, Specs, Visibility } from '../../common/index.js';
2
- import type { Output } from '../types.js';
3
- export interface ServerConfigBody {
1
+ import type { Pricing, Specs, Visibility } from '../../common/types.js';
2
+ import type { ResponseData } from '../types.js';
3
+ export interface ServerConfigRequestData {
4
4
  server_name: string;
5
5
  }
6
- export interface ServerConfigConfigBackgroundJob {
6
+ export interface ServerConfigResponseDataConfigBackgroundJob {
7
7
  times_updated: number;
8
8
  image: string;
9
9
  command: string;
10
10
  env: Record<string, string>;
11
11
  }
12
- export interface ServerConfigConfig {
12
+ export interface ServerConfigResponseDataConfig {
13
13
  name: string;
14
14
  connected: boolean;
15
15
  visibility: Visibility;
@@ -21,9 +21,9 @@ export interface ServerConfigConfig {
21
21
  id: number;
22
22
  rental_status: number;
23
23
  specs: Specs;
24
- background_job: ServerConfigConfigBackgroundJob;
24
+ background_job: ServerConfigResponseDataConfigBackgroundJob;
25
25
  }
26
- export interface ServerConfigOutput extends Output {
27
- config: ServerConfigConfig;
26
+ export interface ServerConfigResponseData extends ResponseData {
27
+ config: ServerConfigResponseDataConfig;
28
28
  creation_completed: boolean;
29
29
  }
@@ -1,10 +1,9 @@
1
- import type { Output } from '../types.js';
2
- export interface SetServerSettingsBody {
1
+ import type { ResponseData } from '../types.js';
2
+ export interface SetServerSettingsRequestData {
3
3
  name: string;
4
4
  availability: boolean;
5
5
  mrl: number;
6
6
  on_demand: number;
7
7
  spot: number;
8
8
  }
9
- export interface SetServerSettingsOutput extends Output {
10
- }
9
+ export type SetServerSettingsResponseData = ResponseData;
@@ -1,17 +1,4 @@
1
- import type { Output } from '../types.js';
2
- export interface SetSpotPriceBody {
3
- order_id: number;
4
- desired_price: number;
5
- }
6
- export interface SetSpotPriceMaxStep extends Output {
7
- error: 'exceeded_max_step';
8
- max_step: number;
9
- }
10
- export interface SetSpotPriceTimeToLowering extends Output {
11
- error: 'can_lower_every_600_seconds';
12
- time_to_lowering: number;
13
- }
14
- export interface SetSpotPriceSuccess extends Output {
15
- error: undefined;
16
- }
17
- export type SetSpotPriceOutput = SetSpotPriceMaxStep | SetSpotPriceTimeToLowering | SetSpotPriceSuccess;
1
+ import type { SetSpotPriceRequestDataCommon, SetSpotPriceResponseDataCommon } from '../../common/endpoints/setSpotPrice.js';
2
+ import type { ResponseData } from '../types.js';
3
+ export type SetSpotPriceRequestData = SetSpotPriceRequestDataCommon;
4
+ export type SetSpotPriceResponseData = SetSpotPriceResponseDataCommon & ResponseData;
@@ -1,25 +1,9 @@
1
- import type { Pricing, Visibility } from '../../common/index.js';
2
- import type { Output } from '../types.js';
3
- export interface SpotMarketplaceParams {
1
+ import type { SpotMarketplaceResponseDataCommon } from '../../common/endpoints/spotMarketplace.js';
2
+ import type { ResponseData } from '../types.js';
3
+ export interface SpotMarketplaceRequestParams {
4
4
  market: number;
5
5
  }
6
- export interface SpotMarketplaceMarketOffer {
7
- offer_id: number;
8
- bid: number;
9
- active: boolean;
10
- my: boolean;
11
- }
12
- export interface SpotMarketplaceMarketServer {
13
- min_pricing: Pricing;
14
- mrl: number;
15
- visibility: Visibility;
16
- online: boolean;
17
- }
18
- export interface SpotMarketplaceMarket {
19
- offers: SpotMarketplaceMarketOffer[];
20
- server: SpotMarketplaceMarketServer;
21
- }
22
- export interface SpotMarketplaceOutput extends Output {
23
- market: SpotMarketplaceMarket;
6
+ export interface SpotMarketplaceResponseData extends ResponseData {
7
+ market: SpotMarketplaceResponseDataCommon;
24
8
  exists: boolean;
25
9
  }
@@ -1,11 +1,11 @@
1
- import type { Currency } from '../../common/index.js';
2
- import type { Output } from '../types.js';
3
- export interface WalletsWallet {
1
+ import type { Currency } from '../../common/types.js';
2
+ import type { ResponseData } from '../types.js';
3
+ export interface WalletsResponseDataWallet {
4
4
  name: Currency;
5
5
  deposit: string;
6
6
  balance: number;
7
7
  withdrawal_fee: number;
8
8
  }
9
- export interface WalletsOutput extends Output {
10
- wallets: WalletsWallet[];
9
+ export interface WalletsResponseData extends ResponseData {
10
+ wallets: WalletsResponseDataWallet[];
11
11
  }
@@ -1,13 +1,13 @@
1
1
  import CloreAI from './CloreAI.js';
2
- export * from './endpoints/cancelOrder.js';
3
- export * from './endpoints/createOrder.js';
4
- export * from './endpoints/marketplace.js';
5
- export * from './endpoints/myOrders.js';
6
- export * from './endpoints/myServers.js';
7
- export * from './endpoints/serverConfig.js';
8
- export * from './endpoints/setServerSettings.js';
9
- export * from './endpoints/setSpotPrice.js';
10
- export * from './endpoints/spotMarketplace.js';
11
- export * from './endpoints/wallets.js';
12
- export * from './types.js';
2
+ export type * from './endpoints/cancelOrder.js';
3
+ export type * from './endpoints/createOrder.js';
4
+ export type * from './endpoints/marketplace.js';
5
+ export type * from './endpoints/myOrders.js';
6
+ export type * from './endpoints/myServers.js';
7
+ export type * from './endpoints/serverConfig.js';
8
+ export type * from './endpoints/setServerSettings.js';
9
+ export type * from './endpoints/setSpotPrice.js';
10
+ export type * from './endpoints/spotMarketplace.js';
11
+ export type * from './endpoints/wallets.js';
12
+ export type * from './types.js';
13
13
  export default CloreAI;
@@ -1,13 +1,2 @@
1
1
  import CloreAI from './CloreAI.js';
2
- export * from './endpoints/cancelOrder.js';
3
- export * from './endpoints/createOrder.js';
4
- export * from './endpoints/marketplace.js';
5
- export * from './endpoints/myOrders.js';
6
- export * from './endpoints/myServers.js';
7
- export * from './endpoints/serverConfig.js';
8
- export * from './endpoints/setServerSettings.js';
9
- export * from './endpoints/setSpotPrice.js';
10
- export * from './endpoints/spotMarketplace.js';
11
- export * from './endpoints/wallets.js';
12
- export * from './types.js';
13
2
  export default CloreAI;
@@ -1,7 +1,7 @@
1
- import type { CommonConfig, CommonOutput } from '../common/types.js';
1
+ import type { CommonConfig, CommonResponseData } from '../common/types.js';
2
2
  export interface Config extends CommonConfig {
3
3
  apiKey: string;
4
4
  }
5
- export interface Output extends CommonOutput {
5
+ export interface ResponseData extends CommonResponseData {
6
6
  code: number;
7
7
  }
@@ -1,4 +1,4 @@
1
- export declare const RATE_LIMIT = 1000;
1
+ export declare const RATE_LIMIT = 1800;
2
2
  export declare const RATE_LIMIT_CREATE_ORDER = 5000;
3
3
  export declare const statusCodes: {
4
4
  NORMAL: number;
@@ -7,5 +7,10 @@ export declare const statusCodes: {
7
7
  INVALID_API_TOKEN: number;
8
8
  INVALID_ENDPOINT: number;
9
9
  EXCEEDED: number;
10
- ERROR: number;
10
+ OTHER: number;
11
+ };
12
+ export declare const priorityLevels: {
13
+ NORMAL: number;
14
+ HIGH: number;
15
+ HIGHEST: number;
11
16
  };
@@ -1,4 +1,4 @@
1
- export const RATE_LIMIT = 1_000;
1
+ export const RATE_LIMIT = 1_800;
2
2
  export const RATE_LIMIT_CREATE_ORDER = 5_000;
3
3
  export const statusCodes = {
4
4
  NORMAL: 0,
@@ -7,5 +7,10 @@ export const statusCodes = {
7
7
  INVALID_API_TOKEN: 3,
8
8
  INVALID_ENDPOINT: 4,
9
9
  EXCEEDED: 5,
10
- ERROR: 6,
10
+ OTHER: 6,
11
+ };
12
+ export const priorityLevels = {
13
+ NORMAL: 0,
14
+ HIGH: 1,
15
+ HIGHEST: 2,
11
16
  };
@@ -0,0 +1,3 @@
1
+ export interface CancelOrderRequestDataCommon {
2
+ id: number;
3
+ }
@@ -0,0 +1,2 @@
1
+ /* RequestData */
2
+ export {};
@@ -0,0 +1,25 @@
1
+ import type { Currency, OrderType } from '../types.js';
2
+ export interface CreateOrderRequestDataBase {
3
+ type: OrderType;
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
+ remember_password?: boolean;
16
+ dockerhub_auth?: string;
17
+ }
18
+ export interface CreateOrderRequestDataOnDemand extends CreateOrderRequestDataBase {
19
+ type: 'on-demand';
20
+ }
21
+ export interface CreateOrderRequestDataSpot extends CreateOrderRequestDataBase {
22
+ type: 'spot';
23
+ spotprice: number;
24
+ }
25
+ export type CreateOrderRequestDataCommon = CreateOrderRequestDataOnDemand | CreateOrderRequestDataSpot;
@@ -0,0 +1,19 @@
1
+ import type { Currency, Price, Specs } from '../types.js';
2
+ export interface MarketplaceResponseDataServerRatingCommon {
3
+ avg: number;
4
+ cnt: number;
5
+ }
6
+ export interface MarketplaceResponseDataServerCommon {
7
+ allowed_coins: Currency[];
8
+ cuda_version: string;
9
+ gpu_array: string[];
10
+ id: number;
11
+ mrl: number;
12
+ oc: boolean;
13
+ owner: number;
14
+ price: Price;
15
+ rating: MarketplaceResponseDataServerRatingCommon;
16
+ reliability: number;
17
+ rented: boolean;
18
+ specs: Specs;
19
+ }
@@ -0,0 +1,23 @@
1
+ import type { Currency, Specs } from '../../common/types.js';
2
+ export interface MyOrdersResponseDataOrderCommon {
3
+ auto_login: string;
4
+ id: number;
5
+ fee: number;
6
+ creation_fee: number;
7
+ price: number;
8
+ mrl: number;
9
+ online: boolean;
10
+ image: string;
11
+ mon_container: number;
12
+ currency: Currency;
13
+ spend: number;
14
+ ct: number;
15
+ p: number;
16
+ specs: Specs;
17
+ si: number;
18
+ spot: boolean;
19
+ expired: boolean;
20
+ pub_cluster: string[];
21
+ tcp_ports: string[];
22
+ http_port: string;
23
+ }