@reyaxyz/api-sdk 0.8.0 → 0.9.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 +34 -9
- package/dist/clients/api-client.js.map +1 -1
- package/dist/clients/helpers/constants.js +3 -9
- package/dist/clients/helpers/constants.js.map +1 -1
- package/dist/types/clients/api-client.d.ts +10 -7
- package/dist/types/clients/api-client.d.ts.map +1 -1
- package/dist/types/clients/helpers/constants.d.ts +5 -4
- package/dist/types/clients/helpers/constants.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/clients/api-client.ts +36 -14
- package/src/clients/helpers/constants.ts +9 -8
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
15
|
};
|
|
@@ -11,13 +22,23 @@ var account_1 = __importDefault(require("./modules/account"));
|
|
|
11
22
|
* @description Client for API
|
|
12
23
|
*/
|
|
13
24
|
var ApiClient = /** @class */ (function () {
|
|
14
|
-
function ApiClient(config
|
|
15
|
-
this.
|
|
16
|
-
|
|
17
|
-
this._markets = new markets_1.default(
|
|
18
|
-
this._account = new account_1.default(
|
|
25
|
+
function ApiClient(config) {
|
|
26
|
+
this.apiEndpoint = config.production ? constants_1.API_PRODUCTION : constants_1.API_TESTNET;
|
|
27
|
+
ApiClient.config = __assign(__assign({}, ApiClient.config), config);
|
|
28
|
+
this._markets = new markets_1.default(this.apiEndpoint);
|
|
29
|
+
this._account = new account_1.default(this.apiEndpoint);
|
|
19
30
|
}
|
|
20
|
-
|
|
31
|
+
ApiClient.configure = function (config) {
|
|
32
|
+
ApiClient.config = config;
|
|
33
|
+
ApiClient.instance = new ApiClient(config);
|
|
34
|
+
};
|
|
35
|
+
ApiClient.getInstance = function () {
|
|
36
|
+
if (!ApiClient.instance) {
|
|
37
|
+
throw new Error('ApiClient is not configured. Please configure it before using.');
|
|
38
|
+
}
|
|
39
|
+
return ApiClient.instance;
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(ApiClient, "markets", {
|
|
21
42
|
/**
|
|
22
43
|
* Provides access to the MarketsClient instance.
|
|
23
44
|
* This getter allows for interacting with market-related API functionalities.
|
|
@@ -26,12 +47,12 @@ var ApiClient = /** @class */ (function () {
|
|
|
26
47
|
* @memberof ApiClient
|
|
27
48
|
*/
|
|
28
49
|
get: function () {
|
|
29
|
-
return
|
|
50
|
+
return ApiClient.getInstance()._markets;
|
|
30
51
|
},
|
|
31
52
|
enumerable: false,
|
|
32
53
|
configurable: true
|
|
33
54
|
});
|
|
34
|
-
Object.defineProperty(ApiClient
|
|
55
|
+
Object.defineProperty(ApiClient, "account", {
|
|
35
56
|
/**
|
|
36
57
|
* Provides access to the AccountClient instance.
|
|
37
58
|
* This getter allows for interacting with account-related API functionalities.
|
|
@@ -40,11 +61,15 @@ var ApiClient = /** @class */ (function () {
|
|
|
40
61
|
* @memberof ApiClient
|
|
41
62
|
*/
|
|
42
63
|
get: function () {
|
|
43
|
-
return
|
|
64
|
+
return ApiClient.getInstance()._account;
|
|
44
65
|
},
|
|
45
66
|
enumerable: false,
|
|
46
67
|
configurable: true
|
|
47
68
|
});
|
|
69
|
+
ApiClient.config = {
|
|
70
|
+
production: true, // default value
|
|
71
|
+
timeout: constants_1.API_TIMEOUT, // default value, e.g., 5000 milliseconds
|
|
72
|
+
};
|
|
48
73
|
return ApiClient;
|
|
49
74
|
}());
|
|
50
75
|
exports.ApiClient = ApiClient;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-client.js","sourceRoot":"/","sources":["clients/api-client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"api-client.js","sourceRoot":"/","sources":["clients/api-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,iDAK6B;AAC7B,8DAA8C;AAC9C,8DAA8C;AAE9C;;GAEG;AACH;IAUE,mBAAoB,MAAqB;QACvC,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,0BAAc,CAAC,CAAC,CAAC,uBAAW,CAAC;QACpE,SAAS,CAAC,MAAM,yBAAQ,SAAS,CAAC,MAAM,GAAK,MAAM,CAAE,CAAC;QACtD,IAAI,CAAC,QAAQ,GAAG,IAAI,iBAAa,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACpD,IAAI,CAAC,QAAQ,GAAG,IAAI,iBAAa,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACtD,CAAC;IAEa,mBAAS,GAAvB,UAAwB,MAAqB;QAC3C,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC;QAC1B,SAAS,CAAC,QAAQ,GAAG,IAAI,SAAS,CAAC,MAAM,CAAC,CAAC;IAC7C,CAAC;IAEc,qBAAW,GAA1B;QACE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CACb,gEAAgE,CACjE,CAAC;QACJ,CAAC;QACD,OAAO,SAAS,CAAC,QAAQ,CAAC;IAC5B,CAAC;IASD,sBAAkB,oBAAO;QAPzB;;;;;;WAMG;aACH;YACE,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC;QAC1C,CAAC;;;OAAA;IASD,sBAAkB,oBAAO;QAPzB;;;;;;WAMG;aACH;YACE,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC;QAC1C,CAAC;;;OAAA;IAjDc,gBAAM,GAAkB;QACrC,UAAU,EAAE,IAAI,EAAE,gBAAgB;QAClC,OAAO,EAAE,uBAAW,EAAE,yCAAyC;KAChE,CAAC;IA+CJ,gBAAC;CAAA,AApDD,IAoDC;AApDY,8BAAS","sourcesContent":["import {\n ServiceConfig,\n API_TIMEOUT,\n API_TESTNET,\n API_PRODUCTION,\n} from './helpers/constants';\nimport MarketsClient from './modules/markets';\nimport AccountClient from './modules/account';\n\n/**\n * @description Client for API\n */\nexport class ApiClient {\n private static instance: ApiClient;\n private static config: ServiceConfig = {\n production: true, // 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\n private constructor(config: ServiceConfig) {\n this.apiEndpoint = config.production ? API_PRODUCTION : API_TESTNET;\n ApiClient.config = { ...ApiClient.config, ...config };\n this._markets = new MarketsClient(this.apiEndpoint);\n this._account = new AccountClient(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"]}
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.API_TESTNET = exports.API_PRODUCTION = exports.API_TIMEOUT = void 0;
|
|
4
4
|
exports.API_TIMEOUT = 2500;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
this.restEndpoint = restEndpoint;
|
|
8
|
-
this.websocketEndpoint = websocketEndpoint;
|
|
9
|
-
}
|
|
10
|
-
return ServiceConfig;
|
|
11
|
-
}());
|
|
12
|
-
exports.ServiceConfig = ServiceConfig;
|
|
5
|
+
exports.API_PRODUCTION = 'https://m8mjgmqmte.eu-central-1.awsapprunner.com';
|
|
6
|
+
exports.API_TESTNET = 'https://m8mjgmqmte.eu-central-1.awsapprunner.com';
|
|
13
7
|
//# 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;AAO3B,QAAA,cAAc,GACzB,kDAAkD,CAAC;AAExC,QAAA,WAAW,GACtB,kDAAkD,CAAC","sourcesContent":["export const API_TIMEOUT: number = 2500;\n\nexport interface ServiceConfig {\n production?: boolean; // Base URL for the REST API\n timeout?: number; // Optional timeout for API requests\n}\n\nexport const API_PRODUCTION: string =\n 'https://m8mjgmqmte.eu-central-1.awsapprunner.com';\n\nexport const API_TESTNET: string =\n 'https://m8mjgmqmte.eu-central-1.awsapprunner.com';\n"]}
|
|
@@ -5,11 +5,14 @@ import AccountClient from './modules/account';
|
|
|
5
5
|
* @description Client for API
|
|
6
6
|
*/
|
|
7
7
|
export declare class ApiClient {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
readonly
|
|
11
|
-
readonly
|
|
12
|
-
|
|
8
|
+
private static instance;
|
|
9
|
+
private static config;
|
|
10
|
+
private readonly apiEndpoint;
|
|
11
|
+
private readonly _markets;
|
|
12
|
+
private readonly _account;
|
|
13
|
+
private constructor();
|
|
14
|
+
static configure(config: ServiceConfig): void;
|
|
15
|
+
private static getInstance;
|
|
13
16
|
/**
|
|
14
17
|
* Provides access to the MarketsClient instance.
|
|
15
18
|
* This getter allows for interacting with market-related API functionalities.
|
|
@@ -17,7 +20,7 @@ export declare class ApiClient {
|
|
|
17
20
|
* @returns {MarketsClient} An instance of MarketsClient for market-related operations.
|
|
18
21
|
* @memberof ApiClient
|
|
19
22
|
*/
|
|
20
|
-
get markets(): MarketsClient;
|
|
23
|
+
static get markets(): MarketsClient;
|
|
21
24
|
/**
|
|
22
25
|
* Provides access to the AccountClient instance.
|
|
23
26
|
* This getter allows for interacting with account-related API functionalities.
|
|
@@ -25,6 +28,6 @@ export declare class ApiClient {
|
|
|
25
28
|
* @returns {AccountClient} An instance of AccountClient for account-related operations.
|
|
26
29
|
* @memberof ApiClient
|
|
27
30
|
*/
|
|
28
|
-
get account(): AccountClient;
|
|
31
|
+
static get account(): AccountClient;
|
|
29
32
|
}
|
|
30
33
|
//# sourceMappingURL=api-client.d.ts.map
|
|
@@ -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,EACL,aAAa,EAId,MAAM,qBAAqB,CAAC;AAC7B,OAAO,aAAa,MAAM,mBAAmB,CAAC;AAC9C,OAAO,aAAa,MAAM,mBAAmB,CAAC;AAE9C;;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;IAEzC,OAAO;WAOO,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;CACF"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export declare const API_TIMEOUT: number;
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
constructor(restEndpoint: string, websocketEndpoint: string);
|
|
2
|
+
export interface ServiceConfig {
|
|
3
|
+
production?: boolean;
|
|
4
|
+
timeout?: number;
|
|
6
5
|
}
|
|
6
|
+
export declare const API_PRODUCTION: string;
|
|
7
|
+
export declare const API_TESTNET: string;
|
|
7
8
|
//# 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,
|
|
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,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,cAAc,EAAE,MACuB,CAAC;AAErD,eAAO,MAAM,WAAW,EAAE,MAC0B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reyaxyz/api-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"axios": "^1.6.2"
|
|
37
37
|
},
|
|
38
38
|
"packageManager": "pnpm@8.10.4",
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "21e2e1bd85d1a87ed212743419f0f3e8785be09a"
|
|
40
40
|
}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
ServiceConfig,
|
|
3
|
+
API_TIMEOUT,
|
|
4
|
+
API_TESTNET,
|
|
5
|
+
API_PRODUCTION,
|
|
6
|
+
} from './helpers/constants';
|
|
2
7
|
import MarketsClient from './modules/markets';
|
|
3
8
|
import AccountClient from './modules/account';
|
|
4
9
|
|
|
@@ -6,17 +11,34 @@ import AccountClient from './modules/account';
|
|
|
6
11
|
* @description Client for API
|
|
7
12
|
*/
|
|
8
13
|
export class ApiClient {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
private static instance: ApiClient;
|
|
15
|
+
private static config: ServiceConfig = {
|
|
16
|
+
production: true, // default value
|
|
17
|
+
timeout: API_TIMEOUT, // default value, e.g., 5000 milliseconds
|
|
18
|
+
};
|
|
19
|
+
private readonly apiEndpoint: string;
|
|
20
|
+
private readonly _markets: MarketsClient;
|
|
21
|
+
private readonly _account: AccountClient;
|
|
13
22
|
|
|
14
|
-
constructor(config: ServiceConfig
|
|
15
|
-
this.
|
|
16
|
-
|
|
23
|
+
private constructor(config: ServiceConfig) {
|
|
24
|
+
this.apiEndpoint = config.production ? API_PRODUCTION : API_TESTNET;
|
|
25
|
+
ApiClient.config = { ...ApiClient.config, ...config };
|
|
26
|
+
this._markets = new MarketsClient(this.apiEndpoint);
|
|
27
|
+
this._account = new AccountClient(this.apiEndpoint);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public static configure(config: ServiceConfig): void {
|
|
31
|
+
ApiClient.config = config;
|
|
32
|
+
ApiClient.instance = new ApiClient(config);
|
|
33
|
+
}
|
|
17
34
|
|
|
18
|
-
|
|
19
|
-
|
|
35
|
+
private static getInstance(): ApiClient {
|
|
36
|
+
if (!ApiClient.instance) {
|
|
37
|
+
throw new Error(
|
|
38
|
+
'ApiClient is not configured. Please configure it before using.',
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
return ApiClient.instance;
|
|
20
42
|
}
|
|
21
43
|
|
|
22
44
|
/**
|
|
@@ -26,8 +48,8 @@ export class ApiClient {
|
|
|
26
48
|
* @returns {MarketsClient} An instance of MarketsClient for market-related operations.
|
|
27
49
|
* @memberof ApiClient
|
|
28
50
|
*/
|
|
29
|
-
get markets(): MarketsClient {
|
|
30
|
-
return
|
|
51
|
+
public static get markets(): MarketsClient {
|
|
52
|
+
return ApiClient.getInstance()._markets;
|
|
31
53
|
}
|
|
32
54
|
|
|
33
55
|
/**
|
|
@@ -37,7 +59,7 @@ export class ApiClient {
|
|
|
37
59
|
* @returns {AccountClient} An instance of AccountClient for account-related operations.
|
|
38
60
|
* @memberof ApiClient
|
|
39
61
|
*/
|
|
40
|
-
get account(): AccountClient {
|
|
41
|
-
return
|
|
62
|
+
public static get account(): AccountClient {
|
|
63
|
+
return ApiClient.getInstance()._account;
|
|
42
64
|
}
|
|
43
65
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
export const API_TIMEOUT: number = 2500;
|
|
2
2
|
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
constructor(restEndpoint: string, websocketEndpoint: string) {
|
|
8
|
-
this.restEndpoint = restEndpoint;
|
|
9
|
-
this.websocketEndpoint = websocketEndpoint;
|
|
10
|
-
}
|
|
3
|
+
export interface ServiceConfig {
|
|
4
|
+
production?: boolean; // Base URL for the REST API
|
|
5
|
+
timeout?: number; // Optional timeout for API requests
|
|
11
6
|
}
|
|
7
|
+
|
|
8
|
+
export const API_PRODUCTION: string =
|
|
9
|
+
'https://m8mjgmqmte.eu-central-1.awsapprunner.com';
|
|
10
|
+
|
|
11
|
+
export const API_TESTNET: string =
|
|
12
|
+
'https://m8mjgmqmte.eu-central-1.awsapprunner.com';
|