pmxt-core 2.20.0 → 2.20.1
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/exchanges/kalshi/api.d.ts +1 -1
- package/dist/exchanges/kalshi/api.js +1 -1
- package/dist/exchanges/limitless/api.d.ts +1 -1
- package/dist/exchanges/limitless/api.js +1 -1
- package/dist/exchanges/myriad/api.d.ts +1 -1
- package/dist/exchanges/myriad/api.js +1 -1
- package/dist/exchanges/polymarket/api-clob.d.ts +1 -1
- package/dist/exchanges/polymarket/api-clob.js +1 -1
- package/dist/exchanges/polymarket/api-data.d.ts +1 -1
- package/dist/exchanges/polymarket/api-data.js +1 -1
- package/dist/exchanges/polymarket/api-gamma.d.ts +1 -1
- package/dist/exchanges/polymarket/api-gamma.js +1 -1
- package/dist/exchanges/probable/api.d.ts +1 -1
- package/dist/exchanges/probable/api.js +1 -1
- package/dist/utils/error-mapper.d.ts +8 -0
- package/dist/utils/error-mapper.js +58 -26
- package/package.json +3 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/kalshi/Kalshi.yaml
|
|
3
|
-
* Generated at: 2026-03-14T16:
|
|
3
|
+
* Generated at: 2026-03-14T16:40:09.213Z
|
|
4
4
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
5
5
|
*/
|
|
6
6
|
export declare const kalshiApiSpec: {
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.kalshiApiSpec = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/kalshi/Kalshi.yaml
|
|
6
|
-
* Generated at: 2026-03-14T16:
|
|
6
|
+
* Generated at: 2026-03-14T16:40:09.213Z
|
|
7
7
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
8
8
|
*/
|
|
9
9
|
exports.kalshiApiSpec = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/limitless/Limitless.yaml
|
|
3
|
-
* Generated at: 2026-03-14T16:
|
|
3
|
+
* Generated at: 2026-03-14T16:40:09.266Z
|
|
4
4
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
5
5
|
*/
|
|
6
6
|
export declare const limitlessApiSpec: {
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.limitlessApiSpec = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/limitless/Limitless.yaml
|
|
6
|
-
* Generated at: 2026-03-14T16:
|
|
6
|
+
* Generated at: 2026-03-14T16:40:09.266Z
|
|
7
7
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
8
8
|
*/
|
|
9
9
|
exports.limitlessApiSpec = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/myriad/myriad.yaml
|
|
3
|
-
* Generated at: 2026-03-14T16:
|
|
3
|
+
* Generated at: 2026-03-14T16:40:09.282Z
|
|
4
4
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
5
5
|
*/
|
|
6
6
|
export declare const myriadApiSpec: {
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.myriadApiSpec = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/myriad/myriad.yaml
|
|
6
|
-
* Generated at: 2026-03-14T16:
|
|
6
|
+
* Generated at: 2026-03-14T16:40:09.282Z
|
|
7
7
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
8
8
|
*/
|
|
9
9
|
exports.myriadApiSpec = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/polymarket/PolymarketClobAPI.yaml
|
|
3
|
-
* Generated at: 2026-03-14T16:
|
|
3
|
+
* Generated at: 2026-03-14T16:40:09.222Z
|
|
4
4
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
5
5
|
*/
|
|
6
6
|
export declare const polymarketClobSpec: {
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.polymarketClobSpec = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/polymarket/PolymarketClobAPI.yaml
|
|
6
|
-
* Generated at: 2026-03-14T16:
|
|
6
|
+
* Generated at: 2026-03-14T16:40:09.222Z
|
|
7
7
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
8
8
|
*/
|
|
9
9
|
exports.polymarketClobSpec = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/polymarket/Polymarket_Data_API.yaml
|
|
3
|
-
* Generated at: 2026-03-14T16:
|
|
3
|
+
* Generated at: 2026-03-14T16:40:09.240Z
|
|
4
4
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
5
5
|
*/
|
|
6
6
|
export declare const polymarketDataSpec: {
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.polymarketDataSpec = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/polymarket/Polymarket_Data_API.yaml
|
|
6
|
-
* Generated at: 2026-03-14T16:
|
|
6
|
+
* Generated at: 2026-03-14T16:40:09.240Z
|
|
7
7
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
8
8
|
*/
|
|
9
9
|
exports.polymarketDataSpec = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/polymarket/PolymarketGammaAPI.yaml
|
|
3
|
-
* Generated at: 2026-03-14T16:
|
|
3
|
+
* Generated at: 2026-03-14T16:40:09.236Z
|
|
4
4
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
5
5
|
*/
|
|
6
6
|
export declare const polymarketGammaSpec: {
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.polymarketGammaSpec = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/polymarket/PolymarketGammaAPI.yaml
|
|
6
|
-
* Generated at: 2026-03-14T16:
|
|
6
|
+
* Generated at: 2026-03-14T16:40:09.236Z
|
|
7
7
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
8
8
|
*/
|
|
9
9
|
exports.polymarketGammaSpec = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/probable/probable.yaml
|
|
3
|
-
* Generated at: 2026-03-14T16:
|
|
3
|
+
* Generated at: 2026-03-14T16:40:09.276Z
|
|
4
4
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
5
5
|
*/
|
|
6
6
|
export declare const probableApiSpec: {
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.probableApiSpec = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/probable/probable.yaml
|
|
6
|
-
* Generated at: 2026-03-14T16:
|
|
6
|
+
* Generated at: 2026-03-14T16:40:09.276Z
|
|
7
7
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
8
8
|
*/
|
|
9
9
|
exports.probableApiSpec = {
|
|
@@ -17,6 +17,10 @@ export declare class ErrorMapper {
|
|
|
17
17
|
* Maps axios HTTP errors to appropriate error classes
|
|
18
18
|
*/
|
|
19
19
|
protected mapAxiosError(error: AxiosError): BaseError;
|
|
20
|
+
/**
|
|
21
|
+
* Maps an HTTP status code to the appropriate error class
|
|
22
|
+
*/
|
|
23
|
+
protected mapByStatusCode(status: number, message: string, data: any, response?: any): BaseError;
|
|
20
24
|
/**
|
|
21
25
|
* Maps 400 errors to specific bad request subtypes
|
|
22
26
|
*/
|
|
@@ -33,4 +37,8 @@ export declare class ErrorMapper {
|
|
|
33
37
|
* Extracts error message from various error formats
|
|
34
38
|
*/
|
|
35
39
|
protected extractErrorMessage(error: any): string;
|
|
40
|
+
/**
|
|
41
|
+
* Extracts a message string from a response data payload
|
|
42
|
+
*/
|
|
43
|
+
protected extractFromData(data: any): string | undefined;
|
|
36
44
|
}
|
|
@@ -35,36 +35,24 @@ class ErrorMapper {
|
|
|
35
35
|
// Handle plain objects with status/data (e.g., Polymarket clob-client)
|
|
36
36
|
if (error && typeof error === 'object' && !Array.isArray(error) && !(error instanceof Error)) {
|
|
37
37
|
if (error.status && typeof error.status === 'number') {
|
|
38
|
-
// Treat as axios-like error
|
|
39
38
|
const message = this.extractErrorMessage(error);
|
|
40
|
-
|
|
41
|
-
const data = error.data;
|
|
42
|
-
// Map by HTTP status code (same logic as mapAxiosError)
|
|
43
|
-
switch (status) {
|
|
44
|
-
case 400:
|
|
45
|
-
return this.mapBadRequestError(message, data);
|
|
46
|
-
case 401:
|
|
47
|
-
return new errors_1.AuthenticationError(message, this.exchangeName);
|
|
48
|
-
case 403:
|
|
49
|
-
return new errors_1.PermissionDenied(message, this.exchangeName);
|
|
50
|
-
case 404:
|
|
51
|
-
return this.mapNotFoundError(message, data);
|
|
52
|
-
case 429:
|
|
53
|
-
return this.mapRateLimitError(message, error);
|
|
54
|
-
case 500:
|
|
55
|
-
case 502:
|
|
56
|
-
case 503:
|
|
57
|
-
case 504:
|
|
58
|
-
return new errors_1.ExchangeNotAvailable(`Exchange error (${status}): ${message}`, this.exchangeName);
|
|
59
|
-
default:
|
|
60
|
-
return new errors_1.BadRequest(`HTTP ${status}: ${message}`, this.exchangeName);
|
|
61
|
-
}
|
|
39
|
+
return this.mapByStatusCode(error.status, message, error.data, error);
|
|
62
40
|
}
|
|
63
41
|
}
|
|
64
42
|
// Handle network errors
|
|
65
43
|
if (error.code === 'ECONNREFUSED' || error.code === 'ENOTFOUND' || error.code === 'ETIMEDOUT') {
|
|
66
44
|
return new errors_1.NetworkError(`Network error: ${error.message}`, this.exchangeName);
|
|
67
45
|
}
|
|
46
|
+
// Handle Error instances with attached HTTP metadata (common in third-party SDKs)
|
|
47
|
+
if (error instanceof Error) {
|
|
48
|
+
const err = error;
|
|
49
|
+
const status = err.status ?? err.statusCode ?? err.response?.status ?? err.response?.statusCode;
|
|
50
|
+
if (typeof status === 'number') {
|
|
51
|
+
const message = this.extractErrorMessage(error);
|
|
52
|
+
const data = err.data ?? err.response?.data ?? err.response?.body;
|
|
53
|
+
return this.mapByStatusCode(status, message, data, err.response);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
68
56
|
// Generic error fallback
|
|
69
57
|
const message = this.extractErrorMessage(error);
|
|
70
58
|
return new errors_1.BadRequest(message, this.exchangeName);
|
|
@@ -83,7 +71,12 @@ class ErrorMapper {
|
|
|
83
71
|
}
|
|
84
72
|
return new errors_1.ExchangeNotAvailable(`Exchange unreachable: ${message}`, this.exchangeName);
|
|
85
73
|
}
|
|
86
|
-
|
|
74
|
+
return this.mapByStatusCode(status, message, data, error.response);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Maps an HTTP status code to the appropriate error class
|
|
78
|
+
*/
|
|
79
|
+
mapByStatusCode(status, message, data, response) {
|
|
87
80
|
switch (status) {
|
|
88
81
|
case 400:
|
|
89
82
|
return this.mapBadRequestError(message, data);
|
|
@@ -94,7 +87,7 @@ class ErrorMapper {
|
|
|
94
87
|
case 404:
|
|
95
88
|
return this.mapNotFoundError(message, data);
|
|
96
89
|
case 429:
|
|
97
|
-
return this.mapRateLimitError(message,
|
|
90
|
+
return this.mapRateLimitError(message, response);
|
|
98
91
|
case 500:
|
|
99
92
|
case 502:
|
|
100
93
|
case 503:
|
|
@@ -223,8 +216,16 @@ class ErrorMapper {
|
|
|
223
216
|
return error.statusText;
|
|
224
217
|
}
|
|
225
218
|
}
|
|
226
|
-
// Standard Error object
|
|
219
|
+
// Standard Error object - check for attached response data from third-party SDKs
|
|
227
220
|
if (error instanceof Error) {
|
|
221
|
+
const err = error;
|
|
222
|
+
const data = err.response?.data ?? err.data ?? err.body;
|
|
223
|
+
if (data) {
|
|
224
|
+
const extracted = this.extractFromData(data);
|
|
225
|
+
if (extracted) {
|
|
226
|
+
return extracted;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
228
229
|
return error.message;
|
|
229
230
|
}
|
|
230
231
|
// String error
|
|
@@ -242,5 +243,36 @@ class ErrorMapper {
|
|
|
242
243
|
}
|
|
243
244
|
return String(error);
|
|
244
245
|
}
|
|
246
|
+
/**
|
|
247
|
+
* Extracts a message string from a response data payload
|
|
248
|
+
*/
|
|
249
|
+
extractFromData(data) {
|
|
250
|
+
if (typeof data === 'string') {
|
|
251
|
+
return data;
|
|
252
|
+
}
|
|
253
|
+
if (data && typeof data === 'object') {
|
|
254
|
+
if (data.error) {
|
|
255
|
+
if (typeof data.error === 'string') {
|
|
256
|
+
return data.error;
|
|
257
|
+
}
|
|
258
|
+
if (data.error.message) {
|
|
259
|
+
return data.error.message;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
if (data.message) {
|
|
263
|
+
return data.message;
|
|
264
|
+
}
|
|
265
|
+
if (data.errorMsg) {
|
|
266
|
+
return data.errorMsg;
|
|
267
|
+
}
|
|
268
|
+
try {
|
|
269
|
+
return JSON.stringify(data);
|
|
270
|
+
}
|
|
271
|
+
catch {
|
|
272
|
+
return undefined;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
return undefined;
|
|
276
|
+
}
|
|
245
277
|
}
|
|
246
278
|
exports.ErrorMapper = ErrorMapper;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmxt-core",
|
|
3
|
-
"version": "2.20.
|
|
3
|
+
"version": "2.20.1",
|
|
4
4
|
"description": "pmxt is a unified prediction market data API. The ccxt for prediction markets.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"test": "jest -c jest.config.js",
|
|
30
30
|
"server": "tsx watch src/server/index.ts",
|
|
31
31
|
"server:prod": "node dist/server/index.js",
|
|
32
|
-
"generate:sdk:python": "npx @openapitools/openapi-generator-cli generate -i src/server/openapi.yaml -g python -o ../sdks/python/generated --package-name pmxt_internal --additional-properties=projectName=pmxt-internal,packageVersion=2.20.
|
|
33
|
-
"generate:sdk:typescript": "npx @openapitools/openapi-generator-cli generate -i src/server/openapi.yaml -g typescript-fetch -o ../sdks/typescript/generated --additional-properties=npmName=pmxtjs,npmVersion=2.20.
|
|
32
|
+
"generate:sdk:python": "npx @openapitools/openapi-generator-cli generate -i src/server/openapi.yaml -g python -o ../sdks/python/generated --package-name pmxt_internal --additional-properties=projectName=pmxt-internal,packageVersion=2.20.1,library=urllib3",
|
|
33
|
+
"generate:sdk:typescript": "npx @openapitools/openapi-generator-cli generate -i src/server/openapi.yaml -g typescript-fetch -o ../sdks/typescript/generated --additional-properties=npmName=pmxtjs,npmVersion=2.20.1,supportsES6=true,typescriptThreePlus=true && node ../sdks/typescript/scripts/fix-generated.js",
|
|
34
34
|
"fetch:openapi": "node scripts/fetch-openapi-specs.js",
|
|
35
35
|
"extract:jsdoc": "node ../scripts/extract-jsdoc.js",
|
|
36
36
|
"generate:docs": "npm run extract:jsdoc && node ../scripts/generate-api-docs.js",
|