cloreai 2.0.0 → 3.0.0

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 (35) hide show
  1. package/README.md +57 -43
  2. package/build/{CloreAI.d.ts → Cloreai.d.ts} +25 -17
  3. package/build/{CloreAI.js → Cloreai.js} +37 -45
  4. package/build/CloreaiError.d.ts +12 -0
  5. package/build/CloreaiError.js +16 -0
  6. package/build/Gigaspot.d.ts +6 -6
  7. package/build/Gigaspot.js +9 -9
  8. package/build/constants.d.ts +20 -20
  9. package/build/constants.js +9 -9
  10. package/build/getQueueOptions.d.ts +2 -4
  11. package/build/getQueueOptions.js +3 -10
  12. package/build/index.d.ts +22 -20
  13. package/build/index.js +5 -4
  14. package/build/resources/cancelOrder.d.ts +1 -1
  15. package/build/resources/cancelOrders.d.ts +1 -1
  16. package/build/resources/createGigaspotOrders.d.ts +4 -11
  17. package/build/resources/createOrder.d.ts +5 -5
  18. package/build/resources/editGigaspotOrders.d.ts +4 -11
  19. package/build/resources/getGigaspot.d.ts +8 -8
  20. package/build/resources/marketplace.d.ts +3 -4
  21. package/build/resources/myOrders.d.ts +3 -4
  22. package/build/resources/myServers.d.ts +6 -5
  23. package/build/resources/pohBalance.d.ts +7 -7
  24. package/build/resources/renterFees.d.ts +22 -0
  25. package/build/resources/renterFees.js +1 -0
  26. package/build/resources/serverConfig.d.ts +8 -5
  27. package/build/resources/setServerSettings.d.ts +12 -5
  28. package/build/resources/setSpotPrice.d.ts +5 -7
  29. package/build/resources/setSpotPrice.js +0 -1
  30. package/build/resources/spotMarketplace.d.ts +10 -10
  31. package/build/resources/wallets.d.ts +3 -3
  32. package/build/types.d.ts +18 -22
  33. package/package.json +20 -19
  34. package/build/errors.d.ts +0 -22
  35. package/build/errors.js +0 -43
package/README.md CHANGED
@@ -7,7 +7,8 @@ Features:
7
7
  - Based on [axios](https://github.com/axios/axios)
8
8
  - Protects from rate limit exceeded (429 errors) via
9
9
  [p-queue](https://github.com/sindresorhus/p-queue)
10
- - Error handling via try...catch and instanceof
10
+ - User-friendly error handling
11
+ - Full typing
11
12
  - Supports GigaSPOT
12
13
 
13
14
  Official documentation: [clore.ai/api-docs](https://clore.ai/api-docs)
@@ -26,13 +27,13 @@ npm install cloreai
26
27
  ### Creating an instance
27
28
 
28
29
  ```typescript
29
- import CloreAI from 'cloreai'
30
+ import Cloreai from 'cloreai'
30
31
 
31
- const cloreai = new CloreAI('<API_KEY>', {
32
+ const cloreai = new Cloreai('API_KEY', {
32
33
  axiosOptions: {}, // (optional) Axios instance options https://github.com/axios/axios
33
34
  queueOptions: {}, // (optional) Queue instance options https://github.com/sindresorhus/p-queue
34
- queueOptionsCreateOrder: {}, // (optional) Create order queue instance options https://github.com/sindresorhus/p-queue
35
- queueOptionsGigaspot: {}, // (optional) Gigaspot queue instance options https://github.com/sindresorhus/p-queue
35
+ queueCreateOrderOptions: {}, // (optional) Create order queue instance options https://github.com/sindresorhus/p-queue
36
+ queueGigaspotOptions: {}, // (optional) Gigaspot queue instance options https://github.com/sindresorhus/p-queue
36
37
  })
37
38
  ```
38
39
 
@@ -52,7 +53,7 @@ const myServers = await cloreai.myServers()
52
53
 
53
54
  ```typescript
54
55
  const serverConfig = await cloreai.serverConfig({
55
- server_name: 'server_name',
56
+ server_name: 'SERVER_NAME',
56
57
  })
57
58
  ```
58
59
 
@@ -81,13 +82,28 @@ const spotMarketplace = await cloreai.spotMarketplace({
81
82
 
82
83
  ```typescript
83
84
  await cloreai.setServerSettings({
84
- 'name': 'name', // Server name
85
+ 'name': 'NAME', // Server name
85
86
  'availability': true,
86
87
  'mrl': 24,
87
- 'on_demand': 50,
88
- 'spot': 50,
89
- 'CLORE-Blockchain_on_demand': 50,
90
- 'CLORE-Blockchain_spot': 50,
88
+ 'bitcoin_on_demand': 1,
89
+ 'bitcoin_spot': 1,
90
+ 'CLORE-Blockchain_on_demand': 1,
91
+ 'CLORE-Blockchain_spot': 1,
92
+ 'USD-Blockchain_on_demand': 1,
93
+ 'USD-Blockchain_spot': 1,
94
+ 'enabled-USD-Blockchain': true,
95
+ 'enabled-CLORE-Blockchain': true,
96
+ 'enabled-bitcoin': true,
97
+ 'autoprice': {
98
+ 'CLORE-Blockchain': 'usd',
99
+ 'USD-Blockchain': 'usd',
100
+ 'bitcoin': 'usd',
101
+ },
102
+ 'usd_pricing': {
103
+ 'CLORE-Blockchain': { on_demand: 1, spot: 1 },
104
+ 'USD-Blockchain': { on_demand: 1, spot: 1 },
105
+ 'bitcoin': { on_demand: 1, spot: 1 },
106
+ },
91
107
  })
92
108
  ```
93
109
 
@@ -119,8 +135,8 @@ await cloreai.createOrder({
119
135
  renting_server: 5738,
120
136
  ports: { 22: 'tcp', 8888: 'http' },
121
137
  env: { SSH_PASSWORD: 'SSH_PASSWORD', JUPYTER_TOKEN: 'JUPYTER_TOKEN' },
122
- jupyter_token: 'jupyter_token',
123
- ssh_password: 'ssh_password',
138
+ jupyter_token: 'JUPYTER_TOKEN',
139
+ ssh_password: 'SSH_PASSWORD',
124
140
  required_price: 50,
125
141
  remember_password: true,
126
142
  })
@@ -132,6 +148,12 @@ await cloreai.createOrder({
132
148
  const pohBalance = await cloreai.pohBalance()
133
149
  ```
134
150
 
151
+ ### 12. renter_fees
152
+
153
+ ```typescript
154
+ const renterFees = await cloreai.renterFees()
155
+ ```
156
+
135
157
  ### GigaSPOT
136
158
 
137
159
  #### getGigaspot
@@ -205,51 +227,43 @@ Refer to the documentation [axios](https://github.com/axios/axios).
205
227
 
206
228
  Use the fields:
207
229
 
208
- - `cloreai.queue` - for main request queue
209
- - `cloreai.queueCreateOrder` - for createOrder request queue
210
- - `cloreai.gigaspot.queue` - for gigaspot request queue
230
+ - `cloreai.queue` - for the main request queue
231
+ - `cloreai.queueCreateOrder` - for the createOrder request queue
232
+ - `cloreai.gigaspot.queue` - for the gigaspot request queue
211
233
 
212
234
  Refer to the documentation [p-queue](https://github.com/sindresorhus/p-queue).
213
235
 
214
236
  ### Error Handling
215
237
 
216
- The library exports the following error types:
217
-
218
- - `DatabaseError`
219
- - `InvalidInputDataError`
220
- - `InvalidApiTokenError`
221
- - `InvalidEndpointError`
222
- - `ExceededError`
223
- - `OtherError`
224
- - `UnknownError`
238
+ Use the `CloreaiError` class for error handling.
225
239
 
226
- All these errors inherit from `AxiosError`.
240
+ This class inherits from `AxiosError` and has additional fields with error
241
+ information `error.code` and `error.error`.
227
242
 
228
- Check the error type via the `instanceof` operator:
243
+ To check the error type use the constant `statusCodes`.
229
244
 
230
245
  ```typescript
231
- import { AxiosError } from 'axios'
232
- import { ExceededError } from 'cloreai'
246
+ import { CloreaiError, statusCodes } from 'cloreai'
233
247
 
234
248
  try {
235
249
  const marketplace = await cloreai.marketplace()
236
250
  } catch (error) {
237
- if (error instanceof AxiosError) {
238
- console.log('AxiosError')
251
+ if (error instanceof CloreaiError) {
252
+ console.log(error.code, error.error)
253
+
254
+ if (error.code === statusCodes.EXCEEDED) {
255
+ console.log('Rate limit exceeded error')
256
+ }
257
+ } else {
258
+ throw error
239
259
  }
240
-
241
- if (error instanceof ExceededError) {
242
- console.log('ExceededError')
243
- }
244
-
245
- throw error
246
260
  }
247
261
  ```
248
262
 
249
263
  ### Rate limit
250
264
 
251
265
  All methods are protected from rate limit exceeded via
252
- [p-queue](https://github.com/sindresorhus/p-queue), they automatically pause for
266
+ [p-queue](https://github.com/sindresorhus/p-queue), they automatically delay for
253
267
  the required time to avoid exceeding the limit.
254
268
 
255
269
  Default rate limit values are available as constants:
@@ -266,19 +280,19 @@ console.log(RATE_LIMIT_CREATE_ORDER)
266
280
  console.log(RATE_LIMIT_GIGASPOT)
267
281
  ```
268
282
 
269
- You can set your own rate limit values for each request queue:
283
+ You can set custom rate limit values for each request queue:
270
284
 
271
285
  ```typescript
272
- import CloreAI from 'cloreai'
286
+ import Cloreai from 'cloreai'
273
287
 
274
- const cloreai = new CloreAI('<API_KEY>', {
288
+ const cloreai = new Cloreai('API_KEY', {
275
289
  queueOptions: {
276
290
  interval: 2000, // For example 2 seconds
277
291
  },
278
- queueOptionsCreateOrder: {
292
+ queueCreateOrderOptions: {
279
293
  interval: 6000, // For example 6 seconds
280
294
  },
281
- queueOptionsGigaspot: {
295
+ queueGigaspotOptions: {
282
296
  interval: 2000, // For example 2 seconds
283
297
  },
284
298
  })
@@ -1,19 +1,26 @@
1
- import { type AxiosInstance, type AxiosRequestConfig } from 'axios';
2
- import PQueue from 'p-queue';
3
- import type { CancelOrderRequestData, CancelOrderResponseData } from './resources/cancelOrder.js';
4
- import type { CreateOrderRequestData, CreateOrderResponseData } from './resources/createOrder.js';
5
- import type { MarketplaceResponseData } from './resources/marketplace.js';
6
- import type { MyOrdersRequestParams, MyOrdersResponseData } from './resources/myOrders.js';
7
- import type { MyServersResponseData } from './resources/myServers.js';
8
- import type { PohBalanceResponseData } from './resources/pohBalance.js';
9
- import type { ServerConfigRequestData, ServerConfigResponseData } from './resources/serverConfig.js';
10
- import type { SetServerSettingsRequestData, SetServerSettingsResponseData } from './resources/setServerSettings.js';
11
- import type { SetSpotPriceRequestData, SetSpotPriceResponseData } from './resources/setSpotPrice.js';
12
- import type { SpotMarketplaceRequestParams, SpotMarketplaceResponseData } from './resources/spotMarketplace.js';
13
- import type { WalletsResponseData } from './resources/wallets.js';
14
- import type { Options } from './types.js';
15
- import Gigaspot from './Gigaspot.js';
16
- declare class CloreAI {
1
+ import { type AxiosInstance, type AxiosRequestConfig, type CreateAxiosDefaults } from 'axios';
2
+ import PQueue, { type Options as PQueueOptions, type Queue, type QueueAddOptions } from 'p-queue';
3
+ import type { CancelOrderRequestData, CancelOrderResponseData } from './resources/cancelOrder.ts';
4
+ import type { CreateOrderRequestData, CreateOrderResponseData } from './resources/createOrder.ts';
5
+ import type { MarketplaceResponseData } from './resources/marketplace.ts';
6
+ import type { MyOrdersRequestParams, MyOrdersResponseData } from './resources/myOrders.ts';
7
+ import type { MyServersResponseData } from './resources/myServers.ts';
8
+ import type { PohBalanceResponseData } from './resources/pohBalance.ts';
9
+ import type { RenterFeesResponseData } from './resources/renterFees.ts';
10
+ import type { ServerConfigRequestData, ServerConfigResponseData } from './resources/serverConfig.ts';
11
+ import type { SetServerSettingsRequestData, SetServerSettingsResponseData } from './resources/setServerSettings.ts';
12
+ import type { SetSpotPriceRequestData, SetSpotPriceResponseData } from './resources/setSpotPrice.ts';
13
+ import type { SpotMarketplaceRequestParams, SpotMarketplaceResponseData } from './resources/spotMarketplace.ts';
14
+ import type { WalletsResponseData } from './resources/wallets.ts';
15
+ import Gigaspot from './Gigaspot.ts';
16
+ export type QueueOptions = PQueueOptions<Queue<() => Promise<unknown>, QueueAddOptions>, QueueAddOptions>;
17
+ export interface Options {
18
+ axiosOptions?: CreateAxiosDefaults;
19
+ queueOptions?: QueueOptions;
20
+ queueCreateOrderOptions?: QueueOptions;
21
+ queueGigaspotOptions?: QueueOptions;
22
+ }
23
+ declare class Cloreai {
17
24
  axios: AxiosInstance;
18
25
  queue: PQueue;
19
26
  queueCreateOrder: PQueue;
@@ -30,5 +37,6 @@ declare class CloreAI {
30
37
  cancelOrder(data: CancelOrderRequestData, config?: AxiosRequestConfig): Promise<CancelOrderResponseData>;
31
38
  createOrder(data: CreateOrderRequestData, config?: AxiosRequestConfig): Promise<CreateOrderResponseData>;
32
39
  pohBalance(config?: AxiosRequestConfig): Promise<PohBalanceResponseData>;
40
+ renterFees(config?: AxiosRequestConfig): Promise<RenterFeesResponseData>;
33
41
  }
34
- export default CloreAI;
42
+ export default Cloreai;
@@ -1,10 +1,10 @@
1
- import axios from 'axios';
2
- import PQueue from 'p-queue';
3
- import { priorityLevels, RATE_LIMIT, RATE_LIMIT_CREATE_ORDER, statusCodes } from './constants.js';
4
- import { DatabaseError, ExceededError, InvalidApiTokenError, InvalidEndpointError, InvalidInputDataError, OtherError, UnknownError } from './errors.js';
5
- import { getQueueOptions } from './getQueueOptions.js';
6
- import Gigaspot from './Gigaspot.js';
7
- class CloreAI {
1
+ import axios, {} from 'axios';
2
+ import PQueue, {} from 'p-queue';
3
+ import { CloreaiError } from "./CloreaiError.js";
4
+ import { priorityLevels, RATE_LIMIT, RATE_LIMIT_CREATE_ORDER, statusCodes } from "./constants.js";
5
+ import { getQueueOptions } from "./getQueueOptions.js";
6
+ import Gigaspot from "./Gigaspot.js";
7
+ class Cloreai {
8
8
  axios;
9
9
  queue;
10
10
  queueCreateOrder;
@@ -20,11 +20,11 @@ class CloreAI {
20
20
  interval: RATE_LIMIT_CREATE_ORDER,
21
21
  intervalCap: 1,
22
22
  concurrency: 1,
23
- ...options.queueOptionsCreateOrder,
23
+ ...options.queueCreateOrderOptions,
24
24
  });
25
25
  this.axios = axios.create({
26
- ...options.axiosOptions,
27
26
  baseURL: 'https://api.clore.ai/v1',
27
+ ...options.axiosOptions,
28
28
  });
29
29
  this.axios.interceptors.request.use((request) => {
30
30
  request.headers.set('auth', apiKey);
@@ -34,100 +34,92 @@ class CloreAI {
34
34
  if (response.data.code === statusCodes.NORMAL) {
35
35
  return response;
36
36
  }
37
- const errorMessage = response.data.error != null
38
- ? `Code "${response.data.code}", error "${response.data.error}"`
39
- : `Code "${response.data.code}"`;
40
- const axiosErrorParameters = [
41
- errorMessage,
42
- undefined,
43
- response.config,
44
- response.request,
37
+ const errorMessage = `Code "${response.data.code}"`;
38
+ const error = new CloreaiError(errorMessage, {
39
+ code: String(response.data.code),
40
+ config: response.config,
41
+ request: response.request,
45
42
  response,
46
- ];
47
- switch (response.data.code) {
48
- case statusCodes.DATABASE_ERROR:
49
- throw new DatabaseError(...axiosErrorParameters);
50
- case statusCodes.INVALID_INPUT_DATA:
51
- throw new InvalidInputDataError(...axiosErrorParameters);
52
- case statusCodes.INVALID_API_TOKEN:
53
- throw new InvalidApiTokenError(...axiosErrorParameters);
54
- case statusCodes.INVALID_ENDPOINT:
55
- throw new InvalidEndpointError(...axiosErrorParameters);
56
- case statusCodes.EXCEEDED:
57
- throw new ExceededError(...axiosErrorParameters);
58
- case statusCodes.OTHER:
59
- throw new OtherError(...axiosErrorParameters);
60
- default:
61
- throw new UnknownError(...axiosErrorParameters);
43
+ });
44
+ if (response.data.error != null) {
45
+ error.message += `, error "${response.data.error}"`;
46
+ error.error = response.data.error;
62
47
  }
48
+ throw error;
63
49
  });
64
50
  this.gigaspot = new Gigaspot(options, this.axios);
65
51
  }
66
52
  async wallets(config) {
67
53
  const response = await this.queue.add(async () => {
68
54
  return await this.axios.get('/wallets', config);
69
- }, getQueueOptions(priorityLevels.NORMAL, config));
55
+ }, getQueueOptions(priorityLevels.NORMAL, this.axios, config));
70
56
  return response.data;
71
57
  }
72
58
  async myServers(config) {
73
59
  const response = await this.queue.add(async () => {
74
60
  return await this.axios.get('/my_servers', config);
75
- }, getQueueOptions(priorityLevels.NORMAL, config));
61
+ }, getQueueOptions(priorityLevels.NORMAL, this.axios, config));
76
62
  return response.data;
77
63
  }
78
64
  async serverConfig(data, config) {
79
65
  const response = await this.queue.add(async () => {
80
66
  return await this.axios.get('/server_config', { ...config, data });
81
- }, getQueueOptions(priorityLevels.NORMAL, config));
67
+ }, getQueueOptions(priorityLevels.NORMAL, this.axios, config));
82
68
  return response.data;
83
69
  }
84
70
  async marketplace(config) {
85
71
  const response = await this.queue.add(async () => {
86
72
  return await this.axios.get('/marketplace', config);
87
- }, getQueueOptions(priorityLevels.NORMAL, config));
73
+ }, getQueueOptions(priorityLevels.NORMAL, this.axios, config));
88
74
  return response.data;
89
75
  }
90
76
  async myOrders(params, config) {
91
77
  const response = await this.queue.add(async () => {
92
78
  return await this.axios.get('/my_orders', { ...config, params });
93
- }, getQueueOptions(priorityLevels.NORMAL, config));
79
+ }, getQueueOptions(priorityLevels.NORMAL, this.axios, config));
94
80
  return response.data;
95
81
  }
96
82
  async spotMarketplace(params, config) {
97
83
  const response = await this.queue.add(async () => {
98
84
  return await this.axios.get('/spot_marketplace', { ...config, params });
99
- }, getQueueOptions(priorityLevels.NORMAL, config));
85
+ }, getQueueOptions(priorityLevels.NORMAL, this.axios, config));
100
86
  return response.data;
101
87
  }
102
88
  async setServerSettings(data, config) {
103
89
  const response = await this.queue.add(async () => {
104
90
  return await this.axios.post('/set_server_settings', data, config);
105
- }, getQueueOptions(priorityLevels.HIGH, config));
91
+ }, getQueueOptions(priorityLevels.HIGH, this.axios, config));
106
92
  return response.data;
107
93
  }
108
94
  async setSpotPrice(data, config) {
109
95
  const response = await this.queue.add(async () => {
110
96
  return await this.axios.post('/set_spot_price', data, config);
111
- }, getQueueOptions(priorityLevels.HIGH, config));
97
+ }, getQueueOptions(priorityLevels.HIGH, this.axios, config));
112
98
  return response.data;
113
99
  }
114
100
  async cancelOrder(data, config) {
115
101
  const response = await this.queue.add(async () => {
116
102
  return await this.axios.post('/cancel_order', data, config);
117
- }, getQueueOptions(priorityLevels.HIGH, config));
103
+ }, getQueueOptions(priorityLevels.HIGH, this.axios, config));
118
104
  return response.data;
119
105
  }
120
106
  async createOrder(data, config) {
121
107
  const response = await this.queueCreateOrder.add(async () => {
122
108
  return await this.axios.post('/create_order', data, config);
123
- }, getQueueOptions(priorityLevels.HIGHEST, config));
109
+ }, getQueueOptions(priorityLevels.HIGHEST, this.axios, config));
124
110
  return response.data;
125
111
  }
126
112
  async pohBalance(config) {
127
113
  const response = await this.queue.add(async () => {
128
114
  return await this.axios.get('/poh_balance', config);
129
- }, getQueueOptions(priorityLevels.NORMAL, config));
115
+ }, getQueueOptions(priorityLevels.NORMAL, this.axios, config));
116
+ return response.data;
117
+ }
118
+ async renterFees(config) {
119
+ const response = await this.queue.add(async () => {
120
+ return await this.axios.get('/renter_fees', config);
121
+ }, getQueueOptions(priorityLevels.NORMAL, this.axios, config));
130
122
  return response.data;
131
123
  }
132
124
  }
133
- export default CloreAI;
125
+ export default Cloreai;
@@ -0,0 +1,12 @@
1
+ import { AxiosError, type AxiosResponse, type InternalAxiosRequestConfig } from 'axios';
2
+ export interface CloreaiErrorOptions<T = unknown, D = unknown> extends ErrorOptions {
3
+ code?: string;
4
+ config?: InternalAxiosRequestConfig<D>;
5
+ request?: unknown;
6
+ response?: AxiosResponse<T, D>;
7
+ error?: string;
8
+ }
9
+ export declare class CloreaiError<T = unknown, D = unknown> extends AxiosError<T, D> {
10
+ error?: string;
11
+ constructor(message?: string, options?: CloreaiErrorOptions<T, D>);
12
+ }
@@ -0,0 +1,16 @@
1
+ import { AxiosError } from 'axios';
2
+ export class CloreaiError extends AxiosError {
3
+ error;
4
+ constructor(message, options = {}) {
5
+ super(message, options.code, options.config, options.request, options.response);
6
+ this.name = 'CloreaiError';
7
+ if (options.cause != null) {
8
+ this.cause = (options.cause instanceof Error)
9
+ ? options.cause
10
+ : new Error(String(options.cause));
11
+ }
12
+ if (options.error != null) {
13
+ this.error = options.error;
14
+ }
15
+ }
16
+ }
@@ -1,13 +1,13 @@
1
1
  import { type AxiosInstance, type AxiosRequestConfig } from 'axios';
2
2
  import PQueue from 'p-queue';
3
- import type { CancelOrdersRequestData, CancelOrdersResponseData } from './resources/cancelOrders.js';
4
- import type { CreateGigaspotOrdersRequestData, CreateGigaspotOrdersResponseData } from './resources/createGigaspotOrders.js';
5
- import type { EditGigaspotOrdersRequestData, EditGigaspotOrdersResponseData } from './resources/editGigaspotOrders.js';
6
- import type { GetGigaspotResponseData } from './resources/getGigaspot.js';
7
- import type { Options } from './types.js';
3
+ import type { Options } from './Cloreai.ts';
4
+ import type { CancelOrdersRequestData, CancelOrdersResponseData } from './resources/cancelOrders.ts';
5
+ import type { CreateGigaspotOrdersRequestData, CreateGigaspotOrdersResponseData } from './resources/createGigaspotOrders.ts';
6
+ import type { EditGigaspotOrdersRequestData, EditGigaspotOrdersResponseData } from './resources/editGigaspotOrders.ts';
7
+ import type { GetGigaspotResponseData } from './resources/getGigaspot.ts';
8
8
  declare class Gigaspot {
9
+ axios: AxiosInstance;
9
10
  queue: PQueue;
10
- private axios;
11
11
  constructor(options: Options, axios: AxiosInstance);
12
12
  getGigaspot(config?: AxiosRequestConfig): Promise<GetGigaspotResponseData>;
13
13
  createGigaspotOrders(data: CreateGigaspotOrdersRequestData, config?: AxiosRequestConfig): Promise<CreateGigaspotOrdersResponseData>;
package/build/Gigaspot.js CHANGED
@@ -1,16 +1,16 @@
1
- import axios from 'axios';
1
+ import axios, {} from 'axios';
2
2
  import PQueue from 'p-queue';
3
- import { priorityLevels, RATE_LIMIT_GIGASPOT } from './constants.js';
4
- import { getQueueOptions } from './getQueueOptions.js';
3
+ import { priorityLevels, RATE_LIMIT_GIGASPOT } from "./constants.js";
4
+ import { getQueueOptions } from "./getQueueOptions.js";
5
5
  class Gigaspot {
6
- queue;
7
6
  axios;
7
+ queue;
8
8
  constructor(options, axios) {
9
9
  this.queue = new PQueue({
10
10
  interval: RATE_LIMIT_GIGASPOT,
11
11
  intervalCap: 1,
12
12
  concurrency: 1,
13
- ...options.queueOptionsGigaspot,
13
+ ...options.queueGigaspotOptions,
14
14
  });
15
15
  this.axios = axios;
16
16
  }
@@ -22,24 +22,24 @@ class Gigaspot {
22
22
  ...response.data,
23
23
  snapshot: snapshot.data,
24
24
  };
25
- }, getQueueOptions(priorityLevels.NORMAL, config));
25
+ }, getQueueOptions(priorityLevels.NORMAL, this.axios, config));
26
26
  }
27
27
  async createGigaspotOrders(data, config) {
28
28
  const response = await this.queue.add(async () => {
29
29
  return await this.axios.post('/create_gigaspot_orders', data, config);
30
- }, getQueueOptions(priorityLevels.HIGH, config));
30
+ }, getQueueOptions(priorityLevels.HIGH, this.axios, config));
31
31
  return response.data;
32
32
  }
33
33
  async editGigaspotOrders(data, config) {
34
34
  const response = await this.queue.add(async () => {
35
35
  return await this.axios.post('/edit_gigaspot_orders', data, config);
36
- }, getQueueOptions(priorityLevels.HIGH, config));
36
+ }, getQueueOptions(priorityLevels.HIGH, this.axios, config));
37
37
  return response.data;
38
38
  }
39
39
  async cancelOrders(data, config) {
40
40
  const response = await this.queue.add(async () => {
41
41
  return await this.axios.post('/cancel_orders', data, config);
42
- }, getQueueOptions(priorityLevels.HIGH, config));
42
+ }, getQueueOptions(priorityLevels.HIGH, this.axios, config));
43
43
  return response.data;
44
44
  }
45
45
  }
@@ -1,21 +1,21 @@
1
- export declare const RATE_LIMIT = 1800;
1
+ export declare const RATE_LIMIT = 1000;
2
2
  export declare const RATE_LIMIT_CREATE_ORDER = 5000;
3
- export declare const RATE_LIMIT_GIGASPOT = 1800;
4
- export declare const gigaspotBaseImages: {
5
- UBUNTU: string;
6
- HIVEOS: string;
7
- };
8
- export declare const statusCodes: {
9
- NORMAL: number;
10
- DATABASE_ERROR: number;
11
- INVALID_INPUT_DATA: number;
12
- INVALID_API_TOKEN: number;
13
- INVALID_ENDPOINT: number;
14
- EXCEEDED: number;
15
- OTHER: number;
16
- };
17
- export declare const priorityLevels: {
18
- NORMAL: number;
19
- HIGH: number;
20
- HIGHEST: number;
21
- };
3
+ export declare const RATE_LIMIT_GIGASPOT = 1000;
4
+ export declare const gigaspotBaseImages: Readonly<{
5
+ UBUNTU: "a3f9c4d7e5b088d8a0bff880";
6
+ HIVEOS: "c9a4e2f6b7d488d8f0bab0ff";
7
+ }>;
8
+ export declare const statusCodes: Readonly<{
9
+ NORMAL: 0;
10
+ DATABASE_ERROR: 1;
11
+ INVALID_INPUT_DATA: 2;
12
+ INVALID_API_TOKEN: 3;
13
+ INVALID_ENDPOINT: 4;
14
+ EXCEEDED: 5;
15
+ CUSTOM: 6;
16
+ }>;
17
+ export declare const priorityLevels: Readonly<{
18
+ NORMAL: 0;
19
+ HIGH: 1;
20
+ HIGHEST: 2;
21
+ }>;
@@ -1,21 +1,21 @@
1
- export const RATE_LIMIT = 1800;
1
+ export const RATE_LIMIT = 1000;
2
2
  export const RATE_LIMIT_CREATE_ORDER = 5000;
3
- export const RATE_LIMIT_GIGASPOT = 1800;
4
- export const gigaspotBaseImages = {
3
+ export const RATE_LIMIT_GIGASPOT = 1000;
4
+ export const gigaspotBaseImages = Object.freeze({
5
5
  UBUNTU: 'a3f9c4d7e5b088d8a0bff880',
6
6
  HIVEOS: 'c9a4e2f6b7d488d8f0bab0ff',
7
- };
8
- export const statusCodes = {
7
+ });
8
+ export const statusCodes = Object.freeze({
9
9
  NORMAL: 0,
10
10
  DATABASE_ERROR: 1,
11
11
  INVALID_INPUT_DATA: 2,
12
12
  INVALID_API_TOKEN: 3,
13
13
  INVALID_ENDPOINT: 4,
14
14
  EXCEEDED: 5,
15
- OTHER: 6,
16
- };
17
- export const priorityLevels = {
15
+ CUSTOM: 6,
16
+ });
17
+ export const priorityLevels = Object.freeze({
18
18
  NORMAL: 0,
19
19
  HIGH: 1,
20
20
  HIGHEST: 2,
21
- };
21
+ });
@@ -1,5 +1,3 @@
1
- import type { AxiosRequestConfig } from 'axios';
1
+ import type { AxiosInstance, AxiosRequestConfig } from 'axios';
2
2
  import type { QueueAddOptions } from 'p-queue';
3
- export declare function getQueueOptions(priority: number, config?: AxiosRequestConfig): QueueAddOptions & {
4
- throwOnTimeout: true;
5
- };
3
+ export declare function getQueueOptions(priority: number, axios: AxiosInstance, config?: AxiosRequestConfig): QueueAddOptions;
@@ -1,15 +1,8 @@
1
- export function getQueueOptions(priority, config) {
2
- const defaultQueueOptions = {
3
- throwOnTimeout: true,
4
- priority,
5
- };
1
+ export function getQueueOptions(priority, axios, config = {}) {
6
2
  // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
7
- const signal = config?.signal;
8
- if (signal == null) {
9
- return defaultQueueOptions;
10
- }
3
+ const signal = (config.signal ?? axios.defaults.signal);
11
4
  return {
12
- ...defaultQueueOptions,
5
+ priority,
13
6
  signal,
14
7
  };
15
8
  }
package/build/index.d.ts CHANGED
@@ -1,20 +1,22 @@
1
- import CloreAI from './CloreAI.js';
2
- export * from './constants.js';
3
- export * from './errors.js';
4
- export type * from './resources/cancelOrder.js';
5
- export type * from './resources/cancelOrders.js';
6
- export type * from './resources/createGigaspotOrders.js';
7
- export type * from './resources/createOrder.js';
8
- export type * from './resources/editGigaspotOrders.js';
9
- export type * from './resources/getGigaspot.js';
10
- export type * from './resources/marketplace.js';
11
- export type * from './resources/myOrders.js';
12
- export type * from './resources/myServers.js';
13
- export type * from './resources/pohBalance.js';
14
- export type * from './resources/serverConfig.js';
15
- export type * from './resources/setServerSettings.js';
16
- export type * from './resources/setSpotPrice.js';
17
- export type * from './resources/spotMarketplace.js';
18
- export type * from './resources/wallets.js';
19
- export type * from './types.js';
20
- export default CloreAI;
1
+ import Cloreai from './Cloreai.ts';
2
+ export * from './Cloreai.ts';
3
+ export * from './CloreaiError.ts';
4
+ export * from './constants.ts';
5
+ export type * from './resources/cancelOrder.ts';
6
+ export type * from './resources/cancelOrders.ts';
7
+ export type * from './resources/createGigaspotOrders.ts';
8
+ export type * from './resources/createOrder.ts';
9
+ export type * from './resources/editGigaspotOrders.ts';
10
+ export type * from './resources/getGigaspot.ts';
11
+ export type * from './resources/marketplace.ts';
12
+ export type * from './resources/myOrders.ts';
13
+ export type * from './resources/myServers.ts';
14
+ export type * from './resources/pohBalance.ts';
15
+ export type * from './resources/renterFees.ts';
16
+ export type * from './resources/serverConfig.ts';
17
+ export type * from './resources/setServerSettings.ts';
18
+ export type * from './resources/setSpotPrice.ts';
19
+ export type * from './resources/spotMarketplace.ts';
20
+ export type * from './resources/wallets.ts';
21
+ export type * from './types.ts';
22
+ export default Cloreai;
package/build/index.js CHANGED
@@ -1,4 +1,5 @@
1
- import CloreAI from './CloreAI.js';
2
- export * from './constants.js';
3
- export * from './errors.js';
4
- export default CloreAI;
1
+ import Cloreai from "./Cloreai.js";
2
+ export * from "./Cloreai.js";
3
+ export * from "./CloreaiError.js";
4
+ export * from "./constants.js";
5
+ export default Cloreai;
@@ -1,4 +1,4 @@
1
- import type { ResponseData } from '../types.js';
1
+ import type { ResponseData } from '../types.ts';
2
2
  export interface CancelOrderRequestData {
3
3
  id: number;
4
4
  issue?: string;
@@ -1,4 +1,4 @@
1
- import type { ResponseData } from '../types.js';
1
+ import type { ResponseData } from '../types.ts';
2
2
  export interface CancelOrdersRequestData {
3
3
  order_ids: number[];
4
4
  }
@@ -1,20 +1,13 @@
1
- import type { Currency, ResponseData } from '../types.js';
2
- export interface CreateGigaspotOrdersRequestDataOrderOverclock {
3
- pl: number;
4
- core_offset?: number;
5
- mem_offset?: number;
6
- core_lock?: number;
7
- mem_lock?: number;
8
- }
9
- export interface CreateGigaspotOrdersRequestDataOrder {
1
+ import type { Currency, GigaspotOverclock, ResponseData } from '../types.ts';
2
+ export interface CreateGigaspotOrdersOrder {
10
3
  currency: Currency;
11
4
  image: string;
12
5
  renting_server: number;
13
6
  price: number;
14
- oc: CreateGigaspotOrdersRequestDataOrderOverclock[];
7
+ oc: GigaspotOverclock[];
15
8
  env?: Record<string, string>;
16
9
  }
17
- export type CreateGigaspotOrdersRequestData = CreateGigaspotOrdersRequestDataOrder[];
10
+ export type CreateGigaspotOrdersRequestData = CreateGigaspotOrdersOrder[];
18
11
  export interface CreateGigaspotOrdersResponseData extends ResponseData {
19
12
  failed_to_oc_servers: number[];
20
13
  failed_to_rent_servers: number[];
@@ -1,5 +1,5 @@
1
- import type { Currency, OrderType, ResponseData } from '../types.js';
2
- export interface CreateOrderRequestDataBase {
1
+ import type { Currency, OrderType, ResponseData } from '../types.ts';
2
+ export interface CreateOrderBase {
3
3
  type: OrderType;
4
4
  currency: Currency;
5
5
  image: string;
@@ -15,12 +15,12 @@ export interface CreateOrderRequestDataBase {
15
15
  remember_password?: boolean;
16
16
  dockerhub_auth?: string;
17
17
  }
18
- export interface CreateOrderRequestDataOnDemand extends CreateOrderRequestDataBase {
18
+ export interface CreateOrderOnDemand extends CreateOrderBase {
19
19
  type: 'on-demand';
20
20
  }
21
- export interface CreateOrderRequestDataSpot extends CreateOrderRequestDataBase {
21
+ export interface CreateOrderSpot extends CreateOrderBase {
22
22
  type: 'spot';
23
23
  spotprice: number;
24
24
  }
25
- export type CreateOrderRequestData = CreateOrderRequestDataOnDemand | CreateOrderRequestDataSpot;
25
+ export type CreateOrderRequestData = CreateOrderOnDemand | CreateOrderSpot;
26
26
  export type CreateOrderResponseData = ResponseData;
@@ -1,17 +1,10 @@
1
- import type { ResponseData } from '../types.js';
2
- export interface EditGigaspotOrdersRequestDataOrderOverclock {
3
- pl: number;
4
- core_offset?: number;
5
- mem_offset?: number;
6
- core_lock?: number;
7
- mem_lock?: number;
8
- }
9
- export interface EditGigaspotOrdersRequestDataOrder {
1
+ import type { GigaspotOverclock, ResponseData } from '../types.ts';
2
+ export interface EditGigaspotOrdersOrder {
10
3
  order_id: number;
11
4
  price: number;
12
- oc: EditGigaspotOrdersRequestDataOrderOverclock[];
5
+ oc: GigaspotOverclock[];
13
6
  }
14
- export type EditGigaspotOrdersRequestData = EditGigaspotOrdersRequestDataOrder[];
7
+ export type EditGigaspotOrdersRequestData = EditGigaspotOrdersOrder[];
15
8
  export interface EditGigaspotOrdersResponseData extends ResponseData {
16
9
  success_to_update_ids: number[];
17
10
  failed_to_update_ids: number[];
@@ -1,5 +1,5 @@
1
- import type { Currency, Pricing, ResponseData } from '../types.js';
2
- export interface GetGigaspotResponseDataSnapshotServerBid {
1
+ import type { Currency, Pricing, ResponseData } from '../types.ts';
2
+ export interface GetGigaspotSnapshotServerBid {
3
3
  owner: number;
4
4
  id: number;
5
5
  active: boolean;
@@ -9,7 +9,7 @@ export interface GetGigaspotResponseDataSnapshotServerBid {
9
9
  currency: Currency;
10
10
  pl: number;
11
11
  }
12
- export interface GetGigaspotResponseDataSnapshotServerGpu {
12
+ export interface GetGigaspotSnapshotServerGpu {
13
13
  pl: [number, number];
14
14
  mem_lock: [number, number];
15
15
  core_lock: [number, number];
@@ -17,15 +17,15 @@ export interface GetGigaspotResponseDataSnapshotServerGpu {
17
17
  core_offset: [number, number];
18
18
  model: string;
19
19
  }
20
- export interface GetGigaspotResponseDataSnapshotServer {
21
- bids: GetGigaspotResponseDataSnapshotServerBid[];
20
+ export interface GetGigaspotSnapshotServer {
21
+ bids: GetGigaspotSnapshotServerBid[];
22
22
  on_demand_rented: boolean;
23
23
  online: boolean;
24
24
  cpu: string;
25
25
  cores: number;
26
26
  threads: number;
27
27
  ram: number;
28
- gpus: GetGigaspotResponseDataSnapshotServerGpu[];
28
+ gpus: GetGigaspotSnapshotServerGpu[];
29
29
  working_properly: boolean;
30
30
  cuda: string;
31
31
  max_rental_length: number;
@@ -35,12 +35,12 @@ export interface GetGigaspotResponseDataSnapshotServer {
35
35
  min_bid: number;
36
36
  energy_price: number;
37
37
  }
38
- export type GetGigaspotResponseDataSnapshot = Record<string, GetGigaspotResponseDataSnapshotServer>;
38
+ export type GetGigaspotSnapshot = Record<string, GetGigaspotSnapshotServer>;
39
39
  export interface GetGigaspotResponseDataBase extends ResponseData {
40
40
  my_user_id: number;
41
41
  v1_snapshot_url: string;
42
42
  creation_fees: Pricing;
43
43
  }
44
44
  export interface GetGigaspotResponseData extends GetGigaspotResponseDataBase {
45
- snapshot: GetGigaspotResponseDataSnapshot;
45
+ snapshot: GetGigaspotSnapshot;
46
46
  }
@@ -1,5 +1,5 @@
1
- import type { Currency, Price, Rating, ResponseData, Specs } from '../types.js';
2
- export interface MarketplaceResponseDataServer {
1
+ import type { Currency, Price, Rating, ResponseData, Specs } from '../types.ts';
2
+ export interface MarketplaceServer {
3
3
  id: number;
4
4
  owner: number;
5
5
  autoprice?: string;
@@ -16,6 +16,5 @@ export interface MarketplaceResponseDataServer {
16
16
  cuda_version: string;
17
17
  }
18
18
  export interface MarketplaceResponseData extends ResponseData {
19
- servers: MarketplaceResponseDataServer[];
20
- my_servers: number[];
19
+ servers: MarketplaceServer[];
21
20
  }
@@ -1,10 +1,9 @@
1
- import type { Currency, Rating, ResponseData, Specs } from '../types.js';
1
+ import type { Currency, Rating, ResponseData, Specs } from '../types.ts';
2
2
  export interface MyOrdersRequestParams {
3
3
  return_completed?: boolean;
4
4
  }
5
- export interface MyOrdersResponseDataOrder {
5
+ export interface MyOrdersOrder {
6
6
  id: number;
7
- fee: number;
8
7
  creation_fee: number;
9
8
  price: number;
10
9
  mrl: number;
@@ -32,6 +31,6 @@ export interface MyOrdersResponseDataOrder {
32
31
  expired?: boolean;
33
32
  }
34
33
  export interface MyOrdersResponseData extends ResponseData {
35
- orders: MyOrdersResponseDataOrder[];
34
+ orders: MyOrdersOrder[];
36
35
  limit: number;
37
36
  }
@@ -1,15 +1,16 @@
1
- import type { Pricing, ResponseData, Specs, Visibility } from '../types.js';
2
- export interface MyServersResponseDataServer {
1
+ import type { Currency, Pricing, ResponseData, Specs, Visibility } from '../types.ts';
2
+ export interface MyServersServer {
3
3
  name: string;
4
4
  connected: boolean;
5
5
  visibility: Visibility;
6
6
  pricing: Pricing;
7
7
  online: boolean;
8
8
  min_spot_pricing: Pricing;
9
- init_token: string;
10
- specs: Specs;
9
+ allowed_currencies: Currency[];
10
+ init_token?: string;
11
+ specs?: Specs;
11
12
  }
12
13
  export interface MyServersResponseData extends ResponseData {
13
- servers: MyServersResponseDataServer[];
14
+ servers: MyServersServer[];
14
15
  limit: number;
15
16
  }
@@ -1,18 +1,18 @@
1
- import type { ResponseData } from '../types.js';
2
- export interface PohBalanceResponseDataBalanceOffers {
1
+ import type { ResponseData } from '../types.ts';
2
+ export interface PohBalanceOffers {
3
3
  rented_amount: number;
4
4
  rented_on_marketplace_amount: number;
5
5
  rented_finished_amount: number;
6
6
  leased_amount: number;
7
7
  leased_finished_amount: number;
8
8
  }
9
- export interface PohBalanceResponseDataBalance {
9
+ export interface PohBalance {
10
10
  total: number;
11
11
  free_amount: number;
12
12
  reward_amount: number;
13
- offers: PohBalanceResponseDataBalanceOffers;
13
+ offers: PohBalanceOffers;
14
14
  }
15
- export interface PohBalanceResponseDataItem {
15
+ export interface PohBalanceItem {
16
16
  user: number;
17
17
  address: string;
18
18
  signature: string;
@@ -25,7 +25,7 @@ export interface PohBalanceResponseDataItem {
25
25
  last_check: number;
26
26
  }
27
27
  export interface PohBalanceResponseData extends ResponseData {
28
- items: PohBalanceResponseDataItem[];
29
- balance: PohBalanceResponseDataBalance;
28
+ items: PohBalanceItem[];
29
+ balance: PohBalance;
30
30
  count: number;
31
31
  }
@@ -0,0 +1,22 @@
1
+ import type { Pricing, ResponseData } from '../types.ts';
2
+ export interface RenterFeesPohConfig {
3
+ max_reduction_percent: number;
4
+ max_poh_amount: number;
5
+ }
6
+ export interface RenterFeesCreationFees {
7
+ on_demand: Pricing;
8
+ spot: Pricing;
9
+ }
10
+ export interface RenterFees {
11
+ on_demand: RenterFee;
12
+ spot: RenterFee;
13
+ }
14
+ export interface RenterFee {
15
+ base: Pricing;
16
+ }
17
+ export interface RenterFeesResponseData extends ResponseData {
18
+ renter_fees: RenterFees;
19
+ poh_config: RenterFeesPohConfig;
20
+ creation_fees: RenterFeesCreationFees;
21
+ poh_balance: number;
22
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,14 +1,14 @@
1
- import type { Pricing, ResponseData, Specs, Visibility } from '../types.js';
1
+ import type { AutoPrice, Currency, Pricing, PricingInOriginalUsd, ResponseData, Specs, Visibility } from '../types.ts';
2
2
  export interface ServerConfigRequestData {
3
3
  server_name: string;
4
4
  }
5
- export interface ServerConfigResponseDataConfigBackgroundJob {
5
+ export interface ServerConfigBackgroundJob {
6
6
  times_updated: number;
7
7
  image: string;
8
8
  command: string;
9
9
  env: Record<string, string>;
10
10
  }
11
- export interface ServerConfigResponseDataConfig {
11
+ export interface ServerConfig {
12
12
  name: string;
13
13
  connected: boolean;
14
14
  visibility: Visibility;
@@ -20,9 +20,12 @@ export interface ServerConfigResponseDataConfig {
20
20
  id: number;
21
21
  rental_status: number;
22
22
  specs: Specs;
23
- background_job: ServerConfigResponseDataConfigBackgroundJob;
23
+ background_job: ServerConfigBackgroundJob;
24
+ allowed_coins: Currency[];
25
+ autoprice: AutoPrice;
26
+ usd_pricing: PricingInOriginalUsd;
24
27
  }
25
28
  export interface ServerConfigResponseData extends ResponseData {
26
- config: ServerConfigResponseDataConfig;
29
+ config: ServerConfig;
27
30
  creation_completed: boolean;
28
31
  }
@@ -1,11 +1,18 @@
1
- import type { ResponseData } from '../types.js';
1
+ import type { AutoPrice, PricingInOriginalUsd, ResponseData } from '../types.ts';
2
2
  export interface SetServerSettingsRequestData {
3
3
  'name': string;
4
4
  'availability': boolean;
5
5
  'mrl': number;
6
- 'on_demand': number;
7
- 'spot': number;
8
- 'CLORE-Blockchain_on_demand': number;
9
- 'CLORE-Blockchain_spot': number;
6
+ 'bitcoin_on_demand': number;
7
+ 'bitcoin_spot': number;
8
+ 'CLORE-Blockchain_on_demand'?: number;
9
+ 'CLORE-Blockchain_spot'?: number;
10
+ 'USD-Blockchain_on_demand'?: number;
11
+ 'USD-Blockchain_spot'?: number;
12
+ 'enabled-USD-Blockchain'?: boolean;
13
+ 'enabled-CLORE-Blockchain'?: boolean;
14
+ 'enabled-bitcoin'?: boolean;
15
+ 'autoprice'?: AutoPrice;
16
+ 'usd_pricing'?: PricingInOriginalUsd;
10
17
  }
11
18
  export type SetServerSettingsResponseData = ResponseData;
@@ -1,17 +1,15 @@
1
- import type { ResponseData } from '../types.js';
1
+ import type { ResponseData } from '../types.ts';
2
2
  export interface SetSpotPriceRequestData {
3
3
  order_id: number;
4
4
  desired_price: number;
5
5
  }
6
- export interface SetSpotPriceResponseDataMaxStep extends ResponseData {
6
+ export interface SetSpotPriceMaxStep extends ResponseData {
7
7
  error: 'exceeded_max_step';
8
8
  max_step: number;
9
9
  }
10
- export interface SetSpotPriceResponseDataTimeToLowering extends ResponseData {
10
+ export interface SetSpotPriceTimeToLowering extends ResponseData {
11
11
  error: 'can_lower_every_600_seconds';
12
12
  time_to_lowering: number;
13
13
  }
14
- export interface SetSpotPriceResponseDataNormal extends ResponseData {
15
- error: null;
16
- }
17
- export type SetSpotPriceResponseData = SetSpotPriceResponseDataMaxStep | SetSpotPriceResponseDataTimeToLowering | SetSpotPriceResponseDataNormal;
14
+ export type SetSpotPriceNormal = Omit<ResponseData, 'error'>;
15
+ export type SetSpotPriceResponseData = SetSpotPriceMaxStep | SetSpotPriceTimeToLowering | SetSpotPriceNormal;
@@ -1,2 +1 @@
1
- /* RequestData */
2
1
  export {};
@@ -1,26 +1,26 @@
1
- import type { Currency, Pricing, ResponseData, Visibility } from '../types.js';
1
+ import type { Currency, Pricing, ResponseData, Visibility } from '../types.ts';
2
2
  export interface SpotMarketplaceRequestParams {
3
3
  market: number;
4
4
  }
5
- export interface SpotMarketplaceResponseDataOffer {
6
- active: boolean;
5
+ export interface SpotMarketplaceMarketOffer {
6
+ offer_id: number;
7
7
  bid: number;
8
- currency: Currency;
8
+ active: boolean;
9
9
  my: boolean;
10
- offer_id: number;
10
+ currency: Currency;
11
11
  }
12
- export interface SpotMarketplaceResponseDataServer {
12
+ export interface SpotMarketplaceMarketServer {
13
13
  min_pricing: Pricing;
14
14
  mrl: number;
15
15
  online: boolean;
16
16
  visibility: Visibility;
17
17
  }
18
- export interface SpotMarketplaceResponseDataMarket {
18
+ export interface SpotMarketplaceMarket {
19
19
  currency_rates_in_usd: Pricing;
20
- offers: SpotMarketplaceResponseDataOffer[];
21
- server: SpotMarketplaceResponseDataServer;
20
+ offers: SpotMarketplaceMarketOffer[];
21
+ server: SpotMarketplaceMarketServer;
22
22
  }
23
23
  export interface SpotMarketplaceResponseData extends ResponseData {
24
- market: SpotMarketplaceResponseDataMarket;
24
+ market: SpotMarketplaceMarket;
25
25
  exists: boolean;
26
26
  }
@@ -1,10 +1,10 @@
1
- import type { Currency, ResponseData } from '../types.js';
2
- export interface WalletsResponseDataWallet {
1
+ import type { Currency, ResponseData } from '../types.ts';
2
+ export interface Wallet {
3
3
  name: Currency;
4
4
  deposit: string;
5
5
  balance: number;
6
6
  withdrawal_fee: number;
7
7
  }
8
8
  export interface WalletsResponseData extends ResponseData {
9
- wallets: WalletsResponseDataWallet[];
9
+ wallets: Wallet[];
10
10
  }
package/build/types.d.ts CHANGED
@@ -1,37 +1,26 @@
1
- import type { CreateAxiosDefaults } from 'axios';
2
- import type { Options as PQueueOptions, Queue, QueueAddOptions } from 'p-queue';
3
- export type QueueOptions = PQueueOptions<Queue<() => Promise<unknown>, QueueAddOptions>, QueueAddOptions>;
4
- export interface Options {
5
- axiosOptions?: CreateAxiosDefaults;
6
- queueOptions?: QueueOptions;
7
- queueOptionsCreateOrder?: QueueOptions;
8
- queueOptionsGigaspot?: QueueOptions;
9
- }
10
1
  export interface ResponseData {
11
2
  code: number;
12
- error?: string | null;
3
+ error?: string;
13
4
  }
14
5
  export type OrderType = 'on-demand' | 'spot';
15
6
  export type Visibility = 'public' | 'hidden';
16
- export type Currency = 'CLORE-Blockchain' | 'bitcoin';
17
- export interface Pricing {
18
- 'CLORE-Blockchain': number;
19
- 'bitcoin': number;
20
- 'usd'?: number;
21
- }
7
+ export type Currency = 'CLORE-Blockchain' | 'USD-Blockchain' | 'bitcoin';
8
+ export type Pricing = Partial<Record<Currency, number>>;
9
+ export type AutoPrice = Partial<Record<Currency, 'usd' | false>>;
10
+ export type PricingInOriginalUsd = Partial<Record<Currency, {
11
+ on_demand: number;
12
+ spot: number;
13
+ }>>;
22
14
  export interface PricingInUsd {
23
- on_demand_btc: number;
24
15
  on_demand_clore: number;
25
- spot: number;
26
- }
27
- export interface PricingInOriginalUsd {
28
- on_demand: number;
16
+ on_demand_usd: number;
17
+ on_demand_btc: number;
29
18
  spot: number;
30
19
  }
31
20
  export interface Price {
32
21
  on_demand: Pricing;
33
22
  spot: Pricing;
34
- usd?: PricingInUsd;
23
+ usd: PricingInUsd;
35
24
  original_usd?: PricingInOriginalUsd;
36
25
  }
37
26
  export interface Net {
@@ -77,3 +66,10 @@ export interface Rating {
77
66
  avg: number;
78
67
  cnt: number;
79
68
  }
69
+ export interface GigaspotOverclock {
70
+ pl: number;
71
+ core_offset?: number;
72
+ mem_offset?: number;
73
+ core_lock?: number;
74
+ mem_lock?: number;
75
+ }
package/package.json CHANGED
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "name": "cloreai",
3
- "version": "2.0.0",
4
- "type": "module",
3
+ "version": "3.0.0",
5
4
  "description": "CLORE.AI API client",
5
+ "keywords": [
6
+ "cloreai",
7
+ "clore",
8
+ "api"
9
+ ],
6
10
  "repository": {
7
11
  "type": "git",
8
12
  "url": "git+https://github.com/vladpuz/cloreai.git"
9
13
  },
10
- "author": "Vladislav Puzyrev",
11
14
  "license": "MIT",
15
+ "author": "Vladislav Puzyrev",
16
+ "type": "module",
12
17
  "main": "build/index.js",
13
18
  "types": "build/index.d.ts",
14
- "keywords": [
15
- "cloreai",
16
- "clore",
17
- "api"
18
- ],
19
19
  "scripts": {
20
20
  "build": "tsc --project tsconfig.build.json",
21
21
  "check": "npm run typecheck && npm run lint && npm run format",
@@ -27,19 +27,20 @@
27
27
  "typecheck": "tsc --noEmit"
28
28
  },
29
29
  "dependencies": {
30
- "axios": "^1.10.0",
31
- "p-queue": "^8.1.0"
30
+ "axios": "^1.13.5",
31
+ "p-queue": "^9.1.0"
32
32
  },
33
33
  "devDependencies": {
34
- "@tsconfig/node-lts": "^22.0.2",
35
- "@tsconfig/strictest": "^2.0.5",
36
- "@types/node": "^24.0.12",
37
- "eslint": "^9.30.1",
38
- "eslint-config-vladpuz": "^2.0.2",
34
+ "@tsconfig/node-lts": "^24.0.0",
35
+ "@tsconfig/node-ts": "^23.6.4",
36
+ "@tsconfig/strictest": "^2.0.8",
37
+ "@types/node": "^25.3.0",
38
+ "eslint": "^9.39.3",
39
+ "eslint-config-vladpuz": "^2.5.1",
39
40
  "husky": "^9.1.7",
40
- "prettier": "^3.6.2",
41
- "prettier-config-vladpuz": "^1.0.2",
42
- "rimraf": "^6.0.1",
43
- "typescript": "^5.8.3"
41
+ "prettier": "^3.8.1",
42
+ "prettier-config-vladpuz": "^2.0.0",
43
+ "rimraf": "^6.1.3",
44
+ "typescript": "^5.9.3"
44
45
  }
45
46
  }
package/build/errors.d.ts DELETED
@@ -1,22 +0,0 @@
1
- import { AxiosError } from 'axios';
2
- export declare class DatabaseError extends AxiosError {
3
- constructor(...args: ConstructorParameters<typeof AxiosError>);
4
- }
5
- export declare class InvalidInputDataError extends AxiosError {
6
- constructor(...args: ConstructorParameters<typeof AxiosError>);
7
- }
8
- export declare class InvalidApiTokenError extends AxiosError {
9
- constructor(...args: ConstructorParameters<typeof AxiosError>);
10
- }
11
- export declare class InvalidEndpointError extends AxiosError {
12
- constructor(...args: ConstructorParameters<typeof AxiosError>);
13
- }
14
- export declare class ExceededError extends AxiosError {
15
- constructor(...args: ConstructorParameters<typeof AxiosError>);
16
- }
17
- export declare class OtherError extends AxiosError {
18
- constructor(...args: ConstructorParameters<typeof AxiosError>);
19
- }
20
- export declare class UnknownError extends AxiosError {
21
- constructor(...args: ConstructorParameters<typeof AxiosError>);
22
- }
package/build/errors.js DELETED
@@ -1,43 +0,0 @@
1
- import { AxiosError } from 'axios';
2
- export class DatabaseError extends AxiosError {
3
- constructor(...args) {
4
- super(...args);
5
- this.name = 'DatabaseError';
6
- }
7
- }
8
- export class InvalidInputDataError extends AxiosError {
9
- constructor(...args) {
10
- super(...args);
11
- this.name = 'InvalidInputDataError';
12
- }
13
- }
14
- export class InvalidApiTokenError extends AxiosError {
15
- constructor(...args) {
16
- super(...args);
17
- this.name = 'InvalidApiTokenError';
18
- }
19
- }
20
- export class InvalidEndpointError extends AxiosError {
21
- constructor(...args) {
22
- super(...args);
23
- this.name = 'InvalidEndpointError';
24
- }
25
- }
26
- export class ExceededError extends AxiosError {
27
- constructor(...args) {
28
- super(...args);
29
- this.name = 'ExceededError';
30
- }
31
- }
32
- export class OtherError extends AxiosError {
33
- constructor(...args) {
34
- super(...args);
35
- this.name = 'OtherError';
36
- }
37
- }
38
- export class UnknownError extends AxiosError {
39
- constructor(...args) {
40
- super(...args);
41
- this.name = 'UnknownError';
42
- }
43
- }