@reyaxyz/api-sdk 0.28.0 → 0.29.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.
- package/dist/clients/api-client.js +4 -2
- package/dist/clients/api-client.js.map +1 -1
- package/dist/clients/helpers/constants.js +6 -3
- package/dist/clients/helpers/constants.js.map +1 -1
- package/dist/types/clients/api-client.d.ts.map +1 -1
- package/dist/types/clients/helpers/constants.d.ts +4 -3
- package/dist/types/clients/helpers/constants.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/clients/api-client.ts +5 -8
- package/src/clients/helpers/constants.ts +7 -6
|
@@ -26,7 +26,9 @@ var tokens_1 = __importDefault(require("./modules/tokens"));
|
|
|
26
26
|
*/
|
|
27
27
|
var ApiClient = /** @class */ (function () {
|
|
28
28
|
function ApiClient(config) {
|
|
29
|
-
this.apiEndpoint = config.
|
|
29
|
+
this.apiEndpoint = config.environment
|
|
30
|
+
? constants_1.API_URLS[config.environment]
|
|
31
|
+
: constants_1.API_URLS['test'];
|
|
30
32
|
ApiClient.config = __assign(__assign({}, ApiClient.config), config);
|
|
31
33
|
this._markets = new markets_1.default(this.apiEndpoint);
|
|
32
34
|
this._account = new account_1.default(this.apiEndpoint);
|
|
@@ -127,7 +129,7 @@ var ApiClient = /** @class */ (function () {
|
|
|
127
129
|
configurable: true
|
|
128
130
|
});
|
|
129
131
|
ApiClient.config = {
|
|
130
|
-
|
|
132
|
+
environment: 'test', // default value
|
|
131
133
|
timeout: constants_1.API_TIMEOUT, // default value, e.g., 5000 milliseconds
|
|
132
134
|
};
|
|
133
135
|
return ApiClient;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-client.js","sourceRoot":"/","sources":["clients/api-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"api-client.js","sourceRoot":"/","sources":["clients/api-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,i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;IASD,sBAAkB,oBAAO;QAPzB;;;;;;WAMG;aACH;YACE,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC;QAC1C,CAAC;;;OAAA;IAgBD,sBAAkB,4BAAe;QAdjC;;;;;;;;;;;;WAYG;aAEH;YACE,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC,iBAAiB,CAAC;QACnD,CAAC;;;OAAA;IAYD,sBAAkB,eAAE;QAVpB;;;;;;;;;WASG;aACH;YACE,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC;QACrC,CAAC;;;OAAA;IAYD,sBAAkB,mBAAM;QAVxB;;;;;;;;;WASG;aACH;YACE,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC;QACzC,CAAC;;;OAAA;IAvGc,gBAAM,GAAkB;QACrC,WAAW,EAAE,MAAM,EAAE,gBAAgB;QACrC,OAAO,EAAE,uBAAW,EAAE,yCAAyC;KAChE,CAAC;IAqGJ,gBAAC;CAAA,AA1GD,IA0GC;AA1GY,8BAAS","sourcesContent":["import { ServiceConfig, API_TIMEOUT, API_URLS } from './helpers/constants';\nimport MarketsClient from './modules/markets';\nimport AccountClient from './modules/account';\nimport TradeSimulationClient from './modules/trade.simulation';\nimport LpClient from './modules/lp';\nimport TokensClient from './modules/tokens';\n\n/**\n * @description Client for API\n */\nexport class ApiClient {\n private static instance: ApiClient;\n private static config: ServiceConfig = {\n environment: 'test', // default value\n timeout: API_TIMEOUT, // default value, e.g., 5000 milliseconds\n };\n private readonly apiEndpoint: string;\n private readonly _markets: MarketsClient;\n private readonly _account: AccountClient;\n private readonly _lp: LpClient;\n private readonly _trade_simulation: TradeSimulationClient;\n private readonly _tokens: TokensClient;\n\n private constructor(config: ServiceConfig) {\n this.apiEndpoint = config.environment\n ? API_URLS[config.environment]\n : API_URLS['test'];\n ApiClient.config = { ...ApiClient.config, ...config };\n this._markets = new MarketsClient(this.apiEndpoint);\n this._account = new AccountClient(this.apiEndpoint);\n this._lp = new LpClient(this.apiEndpoint);\n this._trade_simulation = new TradeSimulationClient(this._account);\n this._tokens = new TokensClient(this.apiEndpoint);\n }\n\n public static configure(config: ServiceConfig): void {\n ApiClient.config = config;\n ApiClient.instance = new ApiClient(config);\n }\n\n private static getInstance(): ApiClient {\n if (!ApiClient.instance) {\n throw new Error(\n 'ApiClient is not configured. Please configure it before using.',\n );\n }\n return ApiClient.instance;\n }\n\n /**\n * Provides access to the MarketsClient instance.\n * This getter allows for interacting with market-related API functionalities.\n *\n * @returns {MarketsClient} An instance of MarketsClient for market-related operations.\n * @memberof ApiClient\n */\n public static get markets(): MarketsClient {\n return ApiClient.getInstance()._markets;\n }\n\n /**\n * Provides access to the AccountClient instance.\n * This getter allows for interacting with account-related API functionalities.\n *\n * @returns {AccountClient} An instance of AccountClient for account-related operations.\n * @memberof ApiClient\n */\n public static get account(): AccountClient {\n return ApiClient.getInstance()._account;\n }\n\n /**\n * Provides access to the TradeSimulationClient instance.\n * This getter allows for interacting with trade simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_trade_simulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {TradeSimulationClient} An instance of TradeSimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the trade simulation client from the ApiClient\n * const tradeSimulationClient = ApiClient.tradeSimulation;\n */\n\n public static get tradeSimulation(): TradeSimulationClient {\n return ApiClient.getInstance()._trade_simulation;\n }\n\n /**\n * Gets the current instance of the LpClient from the ApiClient.\n *\n * This static getter allows access to the LpClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the LpClient directly, bypassing the need to manually access the internal `_lp` property of the ApiClient instance.\n *\n * @returns {LpClient} The LpClient instance currently held by the ApiClient.\n * @example\n * // Assuming ApiClient and LpClient are properly set up\n * const lpClient = ApiClient.lp;\n */\n public static get lp(): LpClient {\n return ApiClient.getInstance()._lp;\n }\n\n /**\n * Gets the current instance of the TokensClient from the ApiClient.\n *\n * This static getter allows access to the Tokensclient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the TokensClient directly, bypassing the need to manually access the internal `_tokens` property of the ApiClient instance.\n *\n * @returns {TokensClient} The TokensClient instance currently held by the ApiClient.\n * @example\n * // Assuming ApiClient and TokensClient are properly set up\n * const tokensClient = ApiClient.tokens;\n */\n public static get tokens(): TokensClient {\n return ApiClient.getInstance()._tokens;\n }\n}\n"]}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.API_URLS = exports.API_TIMEOUT = void 0;
|
|
4
4
|
exports.API_TIMEOUT = 2500;
|
|
5
|
-
exports.
|
|
6
|
-
|
|
5
|
+
exports.API_URLS = {
|
|
6
|
+
production: 'https://m8mjgmqmte.eu-central-1.awsapprunner.com',
|
|
7
|
+
test: 'https://m8mjgmqmte.eu-central-1.awsapprunner.com',
|
|
8
|
+
local: 'http://localhost:3000',
|
|
9
|
+
};
|
|
7
10
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"/","sources":["clients/helpers/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,WAAW,GAAW,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"/","sources":["clients/helpers/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,WAAW,GAAW,IAAI,CAAC;AAQ3B,QAAA,QAAQ,GAAuC;IAC1D,UAAU,EAAE,kDAAkD;IAC9D,IAAI,EAAE,kDAAkD;IACxD,KAAK,EAAE,uBAAuB;CAC/B,CAAC","sourcesContent":["export const API_TIMEOUT: number = 2500;\n\ntype ServiceEnvironment = 'production' | 'test' | 'local';\nexport interface ServiceConfig {\n environment?: ServiceEnvironment; // Configuration for SDK, such as base URL for the REST API\n timeout?: number; // Optional timeout for API requests\n}\n\nexport const API_URLS: Record<ServiceEnvironment, string> = {\n production: 'https://m8mjgmqmte.eu-central-1.awsapprunner.com',\n test: 'https://m8mjgmqmte.eu-central-1.awsapprunner.com',\n local: 'http://localhost:3000',\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-client.d.ts","sourceRoot":"/","sources":["clients/api-client.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"api-client.d.ts","sourceRoot":"/","sources":["clients/api-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAyB,MAAM,qBAAqB,CAAC;AAC3E,OAAO,aAAa,MAAM,mBAAmB,CAAC;AAC9C,OAAO,aAAa,MAAM,mBAAmB,CAAC;AAC9C,OAAO,qBAAqB,MAAM,4BAA4B,CAAC;AAC/D,OAAO,QAAQ,MAAM,cAAc,CAAC;AACpC,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAE5C;;GAEG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAY;IACnC,OAAO,CAAC,MAAM,CAAC,MAAM,CAGnB;IACF,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAgB;IACzC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAgB;IACzC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAW;IAC/B,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAwB;IAC1D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAe;IAEvC,OAAO;WAYO,SAAS,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI;IAKpD,OAAO,CAAC,MAAM,CAAC,WAAW;IAS1B;;;;;;OAMG;IACH,WAAkB,OAAO,IAAI,aAAa,CAEzC;IAED;;;;;;OAMG;IACH,WAAkB,OAAO,IAAI,aAAa,CAEzC;IAED;;;;;;;;;;;;OAYG;IAEH,WAAkB,eAAe,IAAI,qBAAqB,CAEzD;IAED;;;;;;;;;OASG;IACH,WAAkB,EAAE,IAAI,QAAQ,CAE/B;IAED;;;;;;;;;OASG;IACH,WAAkB,MAAM,IAAI,YAAY,CAEvC;CACF"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export declare const API_TIMEOUT: number;
|
|
2
|
+
type ServiceEnvironment = 'production' | 'test' | 'local';
|
|
2
3
|
export interface ServiceConfig {
|
|
3
|
-
|
|
4
|
+
environment?: ServiceEnvironment;
|
|
4
5
|
timeout?: number;
|
|
5
6
|
}
|
|
6
|
-
export declare const
|
|
7
|
-
export
|
|
7
|
+
export declare const API_URLS: Record<ServiceEnvironment, string>;
|
|
8
|
+
export {};
|
|
8
9
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"/","sources":["clients/helpers/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,EAAE,MAAa,CAAC;AAExC,MAAM,WAAW,aAAa;IAC5B,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"/","sources":["clients/helpers/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,EAAE,MAAa,CAAC;AAExC,KAAK,kBAAkB,GAAG,YAAY,GAAG,MAAM,GAAG,OAAO,CAAC;AAC1D,MAAM,WAAW,aAAa;IAC5B,WAAW,CAAC,EAAE,kBAAkB,CAAC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,kBAAkB,EAAE,MAAM,CAIvD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reyaxyz/api-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"bignumber.js": "^9.1.2"
|
|
39
39
|
},
|
|
40
40
|
"packageManager": "pnpm@8.10.4",
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "5019db70f29333faa41f046769a55f9d320b5f7f"
|
|
42
42
|
}
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ServiceConfig,
|
|
3
|
-
API_TIMEOUT,
|
|
4
|
-
API_TESTNET,
|
|
5
|
-
API_PRODUCTION,
|
|
6
|
-
} from './helpers/constants';
|
|
1
|
+
import { ServiceConfig, API_TIMEOUT, API_URLS } from './helpers/constants';
|
|
7
2
|
import MarketsClient from './modules/markets';
|
|
8
3
|
import AccountClient from './modules/account';
|
|
9
4
|
import TradeSimulationClient from './modules/trade.simulation';
|
|
@@ -16,7 +11,7 @@ import TokensClient from './modules/tokens';
|
|
|
16
11
|
export class ApiClient {
|
|
17
12
|
private static instance: ApiClient;
|
|
18
13
|
private static config: ServiceConfig = {
|
|
19
|
-
|
|
14
|
+
environment: 'test', // default value
|
|
20
15
|
timeout: API_TIMEOUT, // default value, e.g., 5000 milliseconds
|
|
21
16
|
};
|
|
22
17
|
private readonly apiEndpoint: string;
|
|
@@ -27,7 +22,9 @@ export class ApiClient {
|
|
|
27
22
|
private readonly _tokens: TokensClient;
|
|
28
23
|
|
|
29
24
|
private constructor(config: ServiceConfig) {
|
|
30
|
-
this.apiEndpoint = config.
|
|
25
|
+
this.apiEndpoint = config.environment
|
|
26
|
+
? API_URLS[config.environment]
|
|
27
|
+
: API_URLS['test'];
|
|
31
28
|
ApiClient.config = { ...ApiClient.config, ...config };
|
|
32
29
|
this._markets = new MarketsClient(this.apiEndpoint);
|
|
33
30
|
this._account = new AccountClient(this.apiEndpoint);
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
export const API_TIMEOUT: number = 2500;
|
|
2
2
|
|
|
3
|
+
type ServiceEnvironment = 'production' | 'test' | 'local';
|
|
3
4
|
export interface ServiceConfig {
|
|
4
|
-
|
|
5
|
+
environment?: ServiceEnvironment; // Configuration for SDK, such as base URL for the REST API
|
|
5
6
|
timeout?: number; // Optional timeout for API requests
|
|
6
7
|
}
|
|
7
8
|
|
|
8
|
-
export const
|
|
9
|
-
'https://m8mjgmqmte.eu-central-1.awsapprunner.com'
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
export const API_URLS: Record<ServiceEnvironment, string> = {
|
|
10
|
+
production: 'https://m8mjgmqmte.eu-central-1.awsapprunner.com',
|
|
11
|
+
test: 'https://m8mjgmqmte.eu-central-1.awsapprunner.com',
|
|
12
|
+
local: 'http://localhost:3000',
|
|
13
|
+
};
|