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
@@ -0,0 +1,16 @@
1
+ export interface SetSpotPriceRequestDataCommon {
2
+ order_id: number;
3
+ desired_price: number;
4
+ }
5
+ export interface SetSpotPriceResponseDataMaxStep {
6
+ error: 'exceeded_max_step';
7
+ max_step: number;
8
+ }
9
+ export interface SetSpotPriceResponseDataTimeToLowering {
10
+ error: 'can_lower_every_600_seconds';
11
+ time_to_lowering: number;
12
+ }
13
+ export interface SetSpotPriceResponseDataNormal {
14
+ error: undefined;
15
+ }
16
+ export type SetSpotPriceResponseDataCommon = SetSpotPriceResponseDataMaxStep | SetSpotPriceResponseDataTimeToLowering | SetSpotPriceResponseDataNormal;
@@ -0,0 +1,2 @@
1
+ /* RequestData */
2
+ export {};
@@ -0,0 +1,19 @@
1
+ import type { Currency, Pricing, Visibility } from '../../common/types.js';
2
+ export interface SpotMarketplaceResponseDataOfferCommon {
3
+ active: boolean;
4
+ bid: number;
5
+ currency: Currency;
6
+ my: boolean;
7
+ offer_id: number;
8
+ }
9
+ export interface SpotMarketplaceResponseDataServerCommon {
10
+ min_pricing: Pricing;
11
+ mrl: number;
12
+ online: boolean;
13
+ visibility: Visibility;
14
+ }
15
+ export interface SpotMarketplaceResponseDataCommon {
16
+ currency_rates_in_usd: Pricing;
17
+ offers: SpotMarketplaceResponseDataOfferCommon[];
18
+ server: SpotMarketplaceResponseDataServerCommon;
19
+ }
@@ -1,5 +1,5 @@
1
1
  import { AxiosError } from 'axios';
2
- import type { AxiosErrorParameters } from './types.js';
2
+ export type AxiosErrorParameters = ConstructorParameters<typeof AxiosError>;
3
3
  export declare class DatabaseError extends AxiosError {
4
4
  constructor(...args: AxiosErrorParameters);
5
5
  }
@@ -15,7 +15,7 @@ export declare class InvalidEndpointError extends AxiosError {
15
15
  export declare class ExceededError extends AxiosError {
16
16
  constructor(...args: AxiosErrorParameters);
17
17
  }
18
- export declare class CustomError extends AxiosError {
18
+ export declare class OtherError extends AxiosError {
19
19
  constructor(...args: AxiosErrorParameters);
20
20
  }
21
21
  export declare class UnknownError extends AxiosError {
@@ -29,10 +29,10 @@ export class ExceededError extends AxiosError {
29
29
  this.name = 'ExceededError';
30
30
  }
31
31
  }
32
- export class CustomError extends AxiosError {
32
+ export class OtherError extends AxiosError {
33
33
  constructor(...args) {
34
34
  super(...args);
35
- this.name = 'CustomError';
35
+ this.name = 'OtherError';
36
36
  }
37
37
  }
38
38
  export class UnknownError extends AxiosError {
@@ -0,0 +1,6 @@
1
+ import type { AxiosRequestConfig } from 'axios';
2
+ import type { QueueAddOptions } from 'p-queue';
3
+ export declare function getErrorMessage(statusCode?: number | string, errorField?: string): string;
4
+ export declare function getQueueOptions(priority: number, config?: AxiosRequestConfig): QueueAddOptions & {
5
+ throwOnTimeout: true;
6
+ };
@@ -0,0 +1,25 @@
1
+ export function getErrorMessage(statusCode, errorField) {
2
+ const messages = [];
3
+ if (statusCode != null) {
4
+ messages.push(`Status code "${statusCode}".`);
5
+ }
6
+ if (errorField != null) {
7
+ messages.push(`Error field "${errorField}".`);
8
+ }
9
+ return messages.join(' ');
10
+ }
11
+ export function getQueueOptions(priority, config) {
12
+ const defaultQueueOptions = {
13
+ throwOnTimeout: true,
14
+ priority,
15
+ };
16
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- GenericAbortSignal
17
+ const signal = config?.signal;
18
+ if (signal == null) {
19
+ return defaultQueueOptions;
20
+ }
21
+ return {
22
+ ...defaultQueueOptions,
23
+ signal,
24
+ };
25
+ }
@@ -1,5 +1,10 @@
1
- export * from './api.js';
2
1
  export * from './constants.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/setSpotPrice.js';
7
+ export type * from './endpoints/spotMarketplace.js';
3
8
  export * from './errors.js';
4
- export * from './getErrorMessage.js';
5
- export * from './types.js';
9
+ export * from './helpers.js';
10
+ export type * from './types.js';
@@ -1,5 +1,3 @@
1
- export * from './api.js';
2
1
  export * from './constants.js';
3
2
  export * from './errors.js';
4
- export * from './getErrorMessage.js';
5
- export * from './types.js';
3
+ export * from './helpers.js';
@@ -1,8 +1,61 @@
1
- import type { AxiosError, CreateAxiosDefaults } from 'axios';
2
- export type AxiosErrorParameters = ConstructorParameters<typeof AxiosError>;
1
+ import type { CreateAxiosDefaults } from 'axios';
2
+ import type { Options, Queue, QueueAddOptions } from 'p-queue';
3
+ export type PQueueOptions = Options<Queue<() => Promise<unknown>, QueueAddOptions>, QueueAddOptions>;
3
4
  export interface CommonConfig {
4
5
  axiosConfig?: CreateAxiosDefaults;
6
+ rateLimitQueueOptions?: PQueueOptions;
7
+ rateLimitQueueOptionsCreateOrder?: PQueueOptions;
5
8
  }
6
- export interface CommonOutput<T = string> {
7
- error?: T | undefined;
9
+ export interface CommonResponseData {
10
+ error?: string;
11
+ }
12
+ export type OrderType = 'on-demand' | 'spot';
13
+ export type Visibility = 'public' | 'hidden';
14
+ export type Currency = 'CLORE-Blockchain' | 'bitcoin' | 'usd';
15
+ export interface Pricing {
16
+ 'CLORE-Blockchain': number;
17
+ 'bitcoin': number;
18
+ 'usd'?: number;
19
+ }
20
+ export interface PricingInUSD {
21
+ on_demand_btc: number;
22
+ on_demand_clore: number;
23
+ spot: number;
24
+ }
25
+ export interface Price {
26
+ on_demand: Pricing;
27
+ spot: Pricing;
28
+ usd?: PricingInUSD;
29
+ }
30
+ export interface Net {
31
+ cc: string;
32
+ down: number;
33
+ up: number;
34
+ test_history: string[];
35
+ }
36
+ export interface Overclock {
37
+ model: string;
38
+ core_offset: number | null;
39
+ mem_offset: number | null;
40
+ core_lock: number | null;
41
+ mem_lock: number | null;
42
+ }
43
+ export interface Specs {
44
+ backend_version: number;
45
+ cpu: string;
46
+ cpus: string;
47
+ disk: string;
48
+ disk_speed: number;
49
+ gpu: string;
50
+ gpuram: number;
51
+ mb: string;
52
+ net: Net;
53
+ pcie_rev: number;
54
+ pcie_width: number;
55
+ pl: number[];
56
+ ram: number;
57
+ stock_oc: Overclock[] | 'default';
58
+ stock_oc_override: boolean;
59
+ stock_pl: number[];
60
+ xfs: number;
8
61
  }
@@ -1,22 +1,22 @@
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 { GetSpotBody, GetSpotOutput } from './endpoints/getSpot.js';
6
- import type { OrdersBody, OrdersOutput } from './endpoints/orders.js';
7
- import type { ServersOutput } from './endpoints/servers.js';
8
- import type { SetSpotPriceBody, SetSpotPriceOutput } from './endpoints/setSpotPrice.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 { MyOrdersRequestData, MyOrdersResponseData } from './endpoints/myOrders.js';
7
+ import type { SetSpotPriceRequestData, SetSpotPriceResponseData } from './endpoints/setSpotPrice.js';
8
+ import type { SpotMarketplaceRequestData, SpotMarketplaceResponseData } from './endpoints/spotMarketplace.js';
9
9
  import type { Config } from './types.js';
10
10
  declare class WebAPI {
11
- readonly axios: AxiosInstance;
12
- readonly rateLimitQueue: PQueue;
13
- readonly rateLimitCreateOrderQueue: PQueue;
11
+ axios: AxiosInstance;
12
+ rateLimitQueue: PQueue;
13
+ rateLimitQueueCreateOrder: PQueue;
14
14
  constructor(config: Config);
15
- servers(axiosConfig?: AxiosRequestConfig, queueOptions?: QueueAddOptions): Promise<ServersOutput>;
16
- orders(body: OrdersBody, axiosConfig?: AxiosRequestConfig<OrdersBody>, queueOptions?: QueueAddOptions): Promise<OrdersOutput>;
17
- getSpot(body: GetSpotBody, axiosConfig?: AxiosRequestConfig<GetSpotBody>, queueOptions?: QueueAddOptions): Promise<GetSpotOutput>;
18
- setSpotPrice(body: SetSpotPriceBody, axiosConfig?: AxiosRequestConfig<SetSpotPriceBody>, queueOptions?: QueueAddOptions): Promise<SetSpotPriceOutput>;
19
- cancelOrder(body: CancelOrderBody, axiosConfig?: AxiosRequestConfig<CancelOrderBody>, queueOptions?: QueueAddOptions): Promise<CancelOrderOutput>;
20
- createOrder(body: CreateOrderBody, axiosConfig?: AxiosRequestConfig<CreateOrderBody>, queueOptions?: QueueAddOptions): Promise<CreateOrderOutput>;
15
+ marketplace(config?: AxiosRequestConfig): Promise<MarketplaceResponseData>;
16
+ myOrders(data: MyOrdersRequestData, config?: AxiosRequestConfig): Promise<MyOrdersResponseData>;
17
+ spotMarketplace(data: SpotMarketplaceRequestData, config?: AxiosRequestConfig): Promise<SpotMarketplaceResponseData>;
18
+ setSpotPrice(data: SetSpotPriceRequestData, config?: AxiosRequestConfig): Promise<SetSpotPriceResponseData>;
19
+ cancelOrder(data: CancelOrderRequestData, config?: AxiosRequestConfig): Promise<CancelOrderResponseData>;
20
+ createOrder(data: CreateOrderRequestData, config?: AxiosRequestConfig): Promise<CreateOrderResponseData>;
21
21
  }
22
22
  export default WebAPI;
@@ -1,29 +1,33 @@
1
1
  import axios from 'axios';
2
2
  import PQueue from 'p-queue';
3
+ import { priorityLevels, RATE_LIMIT, RATE_LIMIT_CREATE_ORDER } from '../common/constants.js';
3
4
  import { UnknownError } from '../common/errors.js';
4
- import { getErrorMessage, RATE_LIMIT, RATE_LIMIT_CREATE_ORDER } from '../common/index.js';
5
+ import { getErrorMessage, getQueueOptions } from '../common/helpers.js';
5
6
  class WebAPI {
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 { token, 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://clore.ai/webapi',
22
26
  });
23
27
  this.axios.interceptors.request.use((request) => {
24
28
  request.data = {
25
29
  ...request.data,
26
- token,
30
+ token: config.token,
27
31
  };
28
32
  return request;
29
33
  });
@@ -36,50 +40,40 @@ class WebAPI {
36
40
  throw new UnknownError(errorMessage, undefined, response.config, response.request, response);
37
41
  });
38
42
  }
39
- async servers(axiosConfig, queueOptions) {
43
+ async marketplace(config) {
40
44
  const response = await this.rateLimitQueue.add(async () => {
41
- return await this.axios.post('/marketplace/servers', null, axiosConfig);
42
- }, { ...queueOptions, throwOnTimeout: true });
45
+ return await this.axios.post('/marketplace/servers', null, config);
46
+ }, getQueueOptions(priorityLevels.NORMAL, config));
43
47
  return response.data;
44
48
  }
45
- async orders(body, axiosConfig, queueOptions) {
49
+ async myOrders(data, config) {
46
50
  const response = await this.rateLimitQueue.add(async () => {
47
- return await this.axios.post('/marketplace/orders', body, axiosConfig);
48
- }, { ...queueOptions, throwOnTimeout: true });
51
+ return await this.axios.post('/marketplace/orders', data, config);
52
+ }, getQueueOptions(priorityLevels.NORMAL, config));
49
53
  return response.data;
50
54
  }
51
- async getSpot(body, axiosConfig, queueOptions) {
55
+ async spotMarketplace(data, config) {
52
56
  const response = await this.rateLimitQueue.add(async () => {
53
- return await this.axios.post('/marketplace/get_spot', body, axiosConfig);
54
- }, { ...queueOptions, throwOnTimeout: true });
57
+ return await this.axios.post('/marketplace/get_spot', data, config);
58
+ }, getQueueOptions(priorityLevels.NORMAL, config));
55
59
  return response.data;
56
60
  }
57
- async setSpotPrice(body, axiosConfig, queueOptions) {
61
+ async setSpotPrice(data, config) {
58
62
  const response = await this.rateLimitQueue.add(async () => {
59
- return await this.axios.post('/marketplace/set_spot_price', body, axiosConfig);
60
- }, { ...queueOptions, throwOnTimeout: true });
63
+ return await this.axios.post('/marketplace/set_spot_price', data, config);
64
+ }, getQueueOptions(priorityLevels.HIGH, config));
61
65
  return response.data;
62
66
  }
63
- async cancelOrder(body, axiosConfig, queueOptions) {
67
+ async cancelOrder(data, config) {
64
68
  const response = await this.rateLimitQueue.add(async () => {
65
- return await this.axios.post('/marketplace/cancel_order', body, axiosConfig);
66
- }, { ...queueOptions, throwOnTimeout: true });
69
+ return await this.axios.post('/marketplace/cancel_order', data, config);
70
+ }, getQueueOptions(priorityLevels.HIGH, config));
67
71
  return response.data;
68
72
  }
69
- async createOrder(body, axiosConfig, queueOptions) {
70
- const response = await this.rateLimitQueue.add(async () => {
71
- this.rateLimitQueue.pause();
72
- try {
73
- return await this.rateLimitCreateOrderQueue.add(async () => {
74
- return await this.axios.post('/create_order', body, axiosConfig);
75
- }, { ...queueOptions, throwOnTimeout: true });
76
- }
77
- finally {
78
- setTimeout(() => {
79
- this.rateLimitQueue.start();
80
- }, RATE_LIMIT);
81
- }
82
- }, { ...queueOptions, throwOnTimeout: true });
73
+ async createOrder(data, config) {
74
+ const response = await this.rateLimitQueueCreateOrder.add(async () => {
75
+ return await this.axios.post('/create_order', data, config);
76
+ }, getQueueOptions(priorityLevels.HIGHEST, config));
83
77
  return response.data;
84
78
  }
85
79
  }
@@ -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
  rating: number;
5
5
  }
6
- export interface CancelOrderOutput extends Output {
7
- }
6
+ export type CancelOrderResponseData = ResponseData;
@@ -1,27 +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
- remember_password?: boolean;
17
- }
18
- export interface CreateOrderOnDemand extends CreateOrderCommon {
19
- type: 'on-demand';
20
- }
21
- export interface CreateOrderSpot extends CreateOrderCommon {
22
- type: 'spot';
23
- spotprice: number;
24
- }
25
- export type CreateOrderBody = CreateOrderOnDemand | CreateOrderSpot;
26
- export interface CreateOrderOutput extends Output {
27
- }
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;
@@ -0,0 +1,10 @@
1
+ import type { MarketplaceResponseDataServerCommon } from '../../common/endpoints/marketplace.js';
2
+ import type { Price } from '../../common/types.js';
3
+ import type { ResponseData } from '../types.js';
4
+ export interface MarketplaceResponseData extends ResponseData {
5
+ all_servers: MarketplaceResponseDataServerCommon[];
6
+ creation_fees: Price;
7
+ disable_usd: boolean;
8
+ my_servers: MarketplaceResponseDataServerCommon[];
9
+ not_rented_available_servers: MarketplaceResponseDataServerCommon[];
10
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,15 @@
1
+ import type { MyOrdersResponseDataOrderCommon } from '../../common/endpoints/myOrders.js';
2
+ import type { Currency, Price } from '../../common/types.js';
3
+ import type { ResponseData } from '../types.js';
4
+ export interface MyOrdersRequestData {
5
+ rc: boolean;
6
+ }
7
+ export interface MyOrdersResponseData extends ResponseData {
8
+ PoH_active: boolean;
9
+ PoH_rates: Record<Currency, Record<string, Price>>;
10
+ allowed_features: string[];
11
+ eo: boolean;
12
+ http_endpoint_by_proxy: Record<string, string>;
13
+ ol: number;
14
+ orders: MyOrdersResponseDataOrderCommon[];
15
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,17 +1,4 @@
1
- import type { Output } from '../types.js';
2
- export interface SetSpotPriceBody {
3
- desired_price: number;
4
- order_id: 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;
@@ -0,0 +1,8 @@
1
+ import type { SpotMarketplaceResponseDataCommon } from '../../common/endpoints/spotMarketplace.js';
2
+ import type { ResponseData } from '../types.js';
3
+ export interface SpotMarketplaceRequestData {
4
+ id: number;
5
+ }
6
+ export interface SpotMarketplaceResponseData extends ResponseData {
7
+ data: SpotMarketplaceResponseDataCommon;
8
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,9 +1,9 @@
1
1
  import WebAPI from './WebAPI.js';
2
- export * from './endpoints/cancelOrder.js';
3
- export * from './endpoints/createOrder.js';
4
- export * from './endpoints/getSpot.js';
5
- export * from './endpoints/orders.js';
6
- export * from './endpoints/servers.js';
7
- export * from './endpoints/setSpotPrice.js';
8
- 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/setSpotPrice.js';
7
+ export type * from './endpoints/spotMarketplace.js';
8
+ export type * from './types.js';
9
9
  export default WebAPI;
@@ -1,9 +1,2 @@
1
1
  import WebAPI from './WebAPI.js';
2
- export * from './endpoints/cancelOrder.js';
3
- export * from './endpoints/createOrder.js';
4
- export * from './endpoints/getSpot.js';
5
- export * from './endpoints/orders.js';
6
- export * from './endpoints/servers.js';
7
- export * from './endpoints/setSpotPrice.js';
8
- export * from './types.js';
9
2
  export default WebAPI;
@@ -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
  token: string;
4
4
  }
5
- export interface Output extends CommonOutput {
5
+ export interface ResponseData extends CommonResponseData {
6
6
  status: string;
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloreai",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "type": "module",
5
5
  "description": "CLORE.AI API client",
6
6
  "repository": {
@@ -34,22 +34,22 @@
34
34
  "prepack": "npm run clean && npm run build && npm run check",
35
35
  "prepare": "husky",
36
36
  "typecheck": "tsc --noEmit",
37
- "update-latest": "npm-check-updates --peer --upgrade && npm update"
37
+ "upgrade": "npm-check-updates --peer --upgrade && npm update"
38
38
  },
39
39
  "dependencies": {
40
- "axios": "^1.7.7",
40
+ "axios": "^1.7.9",
41
41
  "p-queue": "^8.0.1"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@tsconfig/strictest": "^2.0.5",
45
- "eslint": "^8.57.0",
46
- "eslint-config-vladpuz": "^0.15.0",
47
- "husky": "^9.1.6",
48
- "jiti": "^1.21.6",
49
- "npm-check-updates": "^17.1.1",
50
- "prettier": "^3.3.3",
51
- "prettier-config-vladpuz": "^0.8.0",
45
+ "eslint": "^9.17.0",
46
+ "eslint-config-vladpuz": "^0.20.0",
47
+ "husky": "^9.1.7",
48
+ "jiti": "^2.4.1",
49
+ "npm-check-updates": "^17.1.11",
50
+ "prettier": "^3.4.2",
51
+ "prettier-config-vladpuz": "^0.9.0",
52
52
  "rimraf": "^6.0.1",
53
- "typescript": "^5.6.2"
53
+ "typescript": "^5.7.2"
54
54
  }
55
55
  }
@@ -1,30 +0,0 @@
1
- export type OrderType = 'on-demand' | 'spot';
2
- export type Visibility = 'public' | 'hidden';
3
- export type Currency = 'CLORE-Blockchain' | 'bitcoin';
4
- export type Pricing = Record<Currency, number>;
5
- export interface Price {
6
- on_demand: Pricing;
7
- spot: Pricing;
8
- }
9
- export interface Net {
10
- cc: string;
11
- down: number;
12
- up: number;
13
- }
14
- export interface Specs {
15
- mb: string;
16
- cpu: string;
17
- cpus: string;
18
- ram: number;
19
- disk: string;
20
- disk_speed: number;
21
- gpu: string;
22
- gpuram: number;
23
- net: Net;
24
- backend_version: number;
25
- pcie_rev: number;
26
- pcie_width: number;
27
- pl: number[];
28
- stock_oc_override: boolean;
29
- stock_pl: number[];
30
- }
@@ -1 +0,0 @@
1
- export declare function getErrorMessage(statusCode?: number | string, errorField?: string): string;
@@ -1,11 +0,0 @@
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 = [
5
- statusCodeMessage,
6
- errorFieldMessage,
7
- ].filter((message) => {
8
- return message != null;
9
- });
10
- return errorMessageArray.join(' ');
11
- }
@@ -1,26 +0,0 @@
1
- import type { Currency, Pricing, Visibility } from '../../common/index.js';
2
- import type { Output } from '../types.js';
3
- export interface GetSpotBody {
4
- id: number;
5
- }
6
- export interface GetSpotDataOffer {
7
- offer_id: number;
8
- bid: number;
9
- active: boolean;
10
- my: boolean;
11
- currency: Currency;
12
- }
13
- export interface GetSpotDataServer {
14
- min_pricing: Pricing;
15
- mrl: number;
16
- visibility: Visibility;
17
- online: boolean;
18
- }
19
- export interface GetSpotData {
20
- currency_rates_in_usd: Pricing;
21
- offers: GetSpotDataOffer[];
22
- server: GetSpotDataServer;
23
- }
24
- export interface GetSpotOutput extends Output {
25
- data: GetSpotData;
26
- }