pmxtjs 2.46.14 → 2.47.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.
@@ -82,6 +82,14 @@ export interface UnifiedEvent {
82
82
  * @memberof UnifiedEvent
83
83
  */
84
84
  tags?: Array<string>;
85
+ /**
86
+ * Raw venue-specific metadata not captured by first-class fields (e.g. Kalshi series_ticker / series_title, Polymarket series). Passed through verbatim so downstream consumers can recover anything the unified shape omits. Each venue populates what it has.
87
+ * @type {{ [key: string]: any; }}
88
+ * @memberof UnifiedEvent
89
+ */
90
+ sourceMetadata?: {
91
+ [key: string]: any;
92
+ };
85
93
  /**
86
94
  * The exchange/venue this event originates from (e.g. 'polymarket', 'kalshi'). Populated by the Router.
87
95
  * @type {string}
@@ -51,6 +51,7 @@ export function UnifiedEventFromJSONTyped(json, ignoreDiscriminator) {
51
51
  'image': json['image'] == null ? undefined : json['image'],
52
52
  'category': json['category'] == null ? undefined : json['category'],
53
53
  'tags': json['tags'] == null ? undefined : json['tags'],
54
+ 'sourceMetadata': json['sourceMetadata'] == null ? undefined : json['sourceMetadata'],
54
55
  'sourceExchange': json['sourceExchange'] == null ? undefined : json['sourceExchange'],
55
56
  };
56
57
  }
@@ -73,6 +74,7 @@ export function UnifiedEventToJSONTyped(value, ignoreDiscriminator = false) {
73
74
  'image': value['image'],
74
75
  'category': value['category'],
75
76
  'tags': value['tags'],
77
+ 'sourceMetadata': value['sourceMetadata'],
76
78
  'sourceExchange': value['sourceExchange'],
77
79
  };
78
80
  }
@@ -124,6 +124,14 @@ export interface UnifiedMarket {
124
124
  * @memberof UnifiedMarket
125
125
  */
126
126
  contractAddress?: string;
127
+ /**
128
+ * Raw venue-specific metadata not captured by first-class fields (e.g. Kalshi series_ticker / series_title from the parent event, Polymarket series). Passed through verbatim so downstream consumers can recover anything the unified shape omits. Each venue populates what it has.
129
+ * @type {{ [key: string]: any; }}
130
+ * @memberof UnifiedMarket
131
+ */
132
+ sourceMetadata?: {
133
+ [key: string]: any;
134
+ };
127
135
  /**
128
136
  * The exchange/venue this market originates from (e.g. 'polymarket', 'kalshi'). Populated by the Router.
129
137
  * @type {string}
@@ -60,6 +60,7 @@ export function UnifiedMarketFromJSONTyped(json, ignoreDiscriminator) {
60
60
  'tickSize': json['tickSize'] == null ? undefined : json['tickSize'],
61
61
  'status': json['status'] == null ? undefined : json['status'],
62
62
  'contractAddress': json['contractAddress'] == null ? undefined : json['contractAddress'],
63
+ 'sourceMetadata': json['sourceMetadata'] == null ? undefined : json['sourceMetadata'],
63
64
  'sourceExchange': json['sourceExchange'] == null ? undefined : json['sourceExchange'],
64
65
  'yes': json['yes'] == null ? undefined : MarketOutcomeFromJSON(json['yes']),
65
66
  'no': json['no'] == null ? undefined : MarketOutcomeFromJSON(json['no']),
@@ -93,6 +94,7 @@ export function UnifiedMarketToJSONTyped(value, ignoreDiscriminator = false) {
93
94
  'tickSize': value['tickSize'],
94
95
  'status': value['status'],
95
96
  'contractAddress': value['contractAddress'],
97
+ 'sourceMetadata': value['sourceMetadata'],
96
98
  'sourceExchange': value['sourceExchange'],
97
99
  'yes': MarketOutcomeToJSON(value['yes']),
98
100
  'no': MarketOutcomeToJSON(value['no']),
@@ -1067,28 +1067,25 @@ export class Exchange {
1067
1067
  }
1068
1068
  async unwatchOrderBook(outcomeId) {
1069
1069
  await this.initPromise;
1070
- const resolvedOutcomeId = resolveOutcomeId(outcomeId);
1071
- const args = [resolvedOutcomeId];
1072
1070
  try {
1073
- const ws = await this.getOrCreateWs();
1074
- if (!ws) {
1075
- throw this.wsTransportUnavailableError("unwatchOrderBook");
1076
- }
1077
- const requestId = this.getWsSubscriptionId(ws, "watchOrderBook", args)
1078
- ?? `req-${Math.random().toString(36).slice(2, 14)}`;
1079
- await this.sendWsMessage(ws, {
1080
- id: requestId,
1081
- action: "unsubscribe",
1082
- exchange: this.exchangeName,
1083
- method: "unwatchOrderBook",
1084
- args,
1071
+ const args = [];
1072
+ args.push(resolveOutcomeId(outcomeId));
1073
+ const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/unwatchOrderBook`, {
1074
+ method: 'POST',
1075
+ headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
1076
+ body: JSON.stringify({ args, credentials: this.getCredentials() }),
1085
1077
  });
1086
- this.clearWsSubscription(ws, "watchOrderBook", args);
1078
+ if (!response.ok) {
1079
+ const body = await response.json().catch(() => ({}));
1080
+ if (body.error && typeof body.error === "object") {
1081
+ throw fromServerError(body.error);
1082
+ }
1083
+ throw new PmxtError(body.error?.message || response.statusText);
1084
+ }
1085
+ const json = await response.json();
1086
+ this.handleResponse(json);
1087
1087
  }
1088
1088
  catch (error) {
1089
- if (this.isWsTransportUnavailableError(error)) {
1090
- throw this.wsTransportUnavailableError("unwatchOrderBook");
1091
- }
1092
1089
  if (error instanceof PmxtError)
1093
1090
  throw error;
1094
1091
  throw new PmxtError(`Failed to unwatchOrderBook: ${error}`);
@@ -82,6 +82,14 @@ export interface UnifiedEvent {
82
82
  * @memberof UnifiedEvent
83
83
  */
84
84
  tags?: Array<string>;
85
+ /**
86
+ * Raw venue-specific metadata not captured by first-class fields (e.g. Kalshi series_ticker / series_title, Polymarket series). Passed through verbatim so downstream consumers can recover anything the unified shape omits. Each venue populates what it has.
87
+ * @type {{ [key: string]: any; }}
88
+ * @memberof UnifiedEvent
89
+ */
90
+ sourceMetadata?: {
91
+ [key: string]: any;
92
+ };
85
93
  /**
86
94
  * The exchange/venue this event originates from (e.g. 'polymarket', 'kalshi'). Populated by the Router.
87
95
  * @type {string}
@@ -58,6 +58,7 @@ function UnifiedEventFromJSONTyped(json, ignoreDiscriminator) {
58
58
  'image': json['image'] == null ? undefined : json['image'],
59
59
  'category': json['category'] == null ? undefined : json['category'],
60
60
  'tags': json['tags'] == null ? undefined : json['tags'],
61
+ 'sourceMetadata': json['sourceMetadata'] == null ? undefined : json['sourceMetadata'],
61
62
  'sourceExchange': json['sourceExchange'] == null ? undefined : json['sourceExchange'],
62
63
  };
63
64
  }
@@ -80,6 +81,7 @@ function UnifiedEventToJSONTyped(value, ignoreDiscriminator = false) {
80
81
  'image': value['image'],
81
82
  'category': value['category'],
82
83
  'tags': value['tags'],
84
+ 'sourceMetadata': value['sourceMetadata'],
83
85
  'sourceExchange': value['sourceExchange'],
84
86
  };
85
87
  }
@@ -124,6 +124,14 @@ export interface UnifiedMarket {
124
124
  * @memberof UnifiedMarket
125
125
  */
126
126
  contractAddress?: string;
127
+ /**
128
+ * Raw venue-specific metadata not captured by first-class fields (e.g. Kalshi series_ticker / series_title from the parent event, Polymarket series). Passed through verbatim so downstream consumers can recover anything the unified shape omits. Each venue populates what it has.
129
+ * @type {{ [key: string]: any; }}
130
+ * @memberof UnifiedMarket
131
+ */
132
+ sourceMetadata?: {
133
+ [key: string]: any;
134
+ };
127
135
  /**
128
136
  * The exchange/venue this market originates from (e.g. 'polymarket', 'kalshi'). Populated by the Router.
129
137
  * @type {string}
@@ -67,6 +67,7 @@ function UnifiedMarketFromJSONTyped(json, ignoreDiscriminator) {
67
67
  'tickSize': json['tickSize'] == null ? undefined : json['tickSize'],
68
68
  'status': json['status'] == null ? undefined : json['status'],
69
69
  'contractAddress': json['contractAddress'] == null ? undefined : json['contractAddress'],
70
+ 'sourceMetadata': json['sourceMetadata'] == null ? undefined : json['sourceMetadata'],
70
71
  'sourceExchange': json['sourceExchange'] == null ? undefined : json['sourceExchange'],
71
72
  'yes': json['yes'] == null ? undefined : (0, MarketOutcome_1.MarketOutcomeFromJSON)(json['yes']),
72
73
  'no': json['no'] == null ? undefined : (0, MarketOutcome_1.MarketOutcomeFromJSON)(json['no']),
@@ -100,6 +101,7 @@ function UnifiedMarketToJSONTyped(value, ignoreDiscriminator = false) {
100
101
  'tickSize': value['tickSize'],
101
102
  'status': value['status'],
102
103
  'contractAddress': value['contractAddress'],
104
+ 'sourceMetadata': value['sourceMetadata'],
103
105
  'sourceExchange': value['sourceExchange'],
104
106
  'yes': (0, MarketOutcome_1.MarketOutcomeToJSON)(value['yes']),
105
107
  'no': (0, MarketOutcome_1.MarketOutcomeToJSON)(value['no']),
@@ -1070,28 +1070,25 @@ class Exchange {
1070
1070
  }
1071
1071
  async unwatchOrderBook(outcomeId) {
1072
1072
  await this.initPromise;
1073
- const resolvedOutcomeId = resolveOutcomeId(outcomeId);
1074
- const args = [resolvedOutcomeId];
1075
1073
  try {
1076
- const ws = await this.getOrCreateWs();
1077
- if (!ws) {
1078
- throw this.wsTransportUnavailableError("unwatchOrderBook");
1079
- }
1080
- const requestId = this.getWsSubscriptionId(ws, "watchOrderBook", args)
1081
- ?? `req-${Math.random().toString(36).slice(2, 14)}`;
1082
- await this.sendWsMessage(ws, {
1083
- id: requestId,
1084
- action: "unsubscribe",
1085
- exchange: this.exchangeName,
1086
- method: "unwatchOrderBook",
1087
- args,
1074
+ const args = [];
1075
+ args.push(resolveOutcomeId(outcomeId));
1076
+ const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/unwatchOrderBook`, {
1077
+ method: 'POST',
1078
+ headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
1079
+ body: JSON.stringify({ args, credentials: this.getCredentials() }),
1088
1080
  });
1089
- this.clearWsSubscription(ws, "watchOrderBook", args);
1081
+ if (!response.ok) {
1082
+ const body = await response.json().catch(() => ({}));
1083
+ if (body.error && typeof body.error === "object") {
1084
+ throw (0, errors_js_1.fromServerError)(body.error);
1085
+ }
1086
+ throw new errors_js_1.PmxtError(body.error?.message || response.statusText);
1087
+ }
1088
+ const json = await response.json();
1089
+ this.handleResponse(json);
1090
1090
  }
1091
1091
  catch (error) {
1092
- if (this.isWsTransportUnavailableError(error)) {
1093
- throw this.wsTransportUnavailableError("unwatchOrderBook");
1094
- }
1095
1092
  if (error instanceof errors_js_1.PmxtError)
1096
1093
  throw error;
1097
1094
  throw new errors_js_1.PmxtError(`Failed to unwatchOrderBook: ${error}`);
@@ -18,6 +18,7 @@ Name | Type
18
18
  `image` | string
19
19
  `category` | string
20
20
  `tags` | Array&lt;string&gt;
21
+ `sourceMetadata` | { [key: string]: any; }
21
22
  `sourceExchange` | string
22
23
 
23
24
  ## Example
@@ -38,6 +39,7 @@ const example = {
38
39
  "image": null,
39
40
  "category": null,
40
41
  "tags": null,
42
+ "sourceMetadata": null,
41
43
  "sourceExchange": null,
42
44
  } satisfies UnifiedEvent
43
45
 
@@ -24,6 +24,7 @@ Name | Type
24
24
  `tickSize` | number
25
25
  `status` | string
26
26
  `contractAddress` | string
27
+ `sourceMetadata` | { [key: string]: any; }
27
28
  `sourceExchange` | string
28
29
  `yes` | [MarketOutcome](MarketOutcome.md)
29
30
  `no` | [MarketOutcome](MarketOutcome.md)
@@ -55,6 +56,7 @@ const example = {
55
56
  "tickSize": null,
56
57
  "status": null,
57
58
  "contractAddress": null,
59
+ "sourceMetadata": null,
58
60
  "sourceExchange": null,
59
61
  "yes": null,
60
62
  "no": null,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmxtjs",
3
- "version": "2.46.14",
3
+ "version": "2.47.0",
4
4
  "description": "OpenAPI client for pmxtjs",
5
5
  "author": "OpenAPI-Generator",
6
6
  "repository": {
@@ -93,6 +93,12 @@ export interface UnifiedEvent {
93
93
  * @memberof UnifiedEvent
94
94
  */
95
95
  tags?: Array<string>;
96
+ /**
97
+ * Raw venue-specific metadata not captured by first-class fields (e.g. Kalshi series_ticker / series_title, Polymarket series). Passed through verbatim so downstream consumers can recover anything the unified shape omits. Each venue populates what it has.
98
+ * @type {{ [key: string]: any; }}
99
+ * @memberof UnifiedEvent
100
+ */
101
+ sourceMetadata?: { [key: string]: any; };
96
102
  /**
97
103
  * The exchange/venue this event originates from (e.g. 'polymarket', 'kalshi'). Populated by the Router.
98
104
  * @type {string}
@@ -136,6 +142,7 @@ export function UnifiedEventFromJSONTyped(json: any, ignoreDiscriminator: boolea
136
142
  'image': json['image'] == null ? undefined : json['image'],
137
143
  'category': json['category'] == null ? undefined : json['category'],
138
144
  'tags': json['tags'] == null ? undefined : json['tags'],
145
+ 'sourceMetadata': json['sourceMetadata'] == null ? undefined : json['sourceMetadata'],
139
146
  'sourceExchange': json['sourceExchange'] == null ? undefined : json['sourceExchange'],
140
147
  };
141
148
  }
@@ -162,6 +169,7 @@ export function UnifiedEventToJSONTyped(value?: UnifiedEvent | null, ignoreDiscr
162
169
  'image': value['image'],
163
170
  'category': value['category'],
164
171
  'tags': value['tags'],
172
+ 'sourceMetadata': value['sourceMetadata'],
165
173
  'sourceExchange': value['sourceExchange'],
166
174
  };
167
175
  }
@@ -135,6 +135,12 @@ export interface UnifiedMarket {
135
135
  * @memberof UnifiedMarket
136
136
  */
137
137
  contractAddress?: string;
138
+ /**
139
+ * Raw venue-specific metadata not captured by first-class fields (e.g. Kalshi series_ticker / series_title from the parent event, Polymarket series). Passed through verbatim so downstream consumers can recover anything the unified shape omits. Each venue populates what it has.
140
+ * @type {{ [key: string]: any; }}
141
+ * @memberof UnifiedMarket
142
+ */
143
+ sourceMetadata?: { [key: string]: any; };
138
144
  /**
139
145
  * The exchange/venue this market originates from (e.g. 'polymarket', 'kalshi'). Populated by the Router.
140
146
  * @type {string}
@@ -210,6 +216,7 @@ export function UnifiedMarketFromJSONTyped(json: any, ignoreDiscriminator: boole
210
216
  'tickSize': json['tickSize'] == null ? undefined : json['tickSize'],
211
217
  'status': json['status'] == null ? undefined : json['status'],
212
218
  'contractAddress': json['contractAddress'] == null ? undefined : json['contractAddress'],
219
+ 'sourceMetadata': json['sourceMetadata'] == null ? undefined : json['sourceMetadata'],
213
220
  'sourceExchange': json['sourceExchange'] == null ? undefined : json['sourceExchange'],
214
221
  'yes': json['yes'] == null ? undefined : MarketOutcomeFromJSON(json['yes']),
215
222
  'no': json['no'] == null ? undefined : MarketOutcomeFromJSON(json['no']),
@@ -247,6 +254,7 @@ export function UnifiedMarketToJSONTyped(value?: UnifiedMarket | null, ignoreDis
247
254
  'tickSize': value['tickSize'],
248
255
  'status': value['status'],
249
256
  'contractAddress': value['contractAddress'],
257
+ 'sourceMetadata': value['sourceMetadata'],
250
258
  'sourceExchange': value['sourceExchange'],
251
259
  'yes': MarketOutcomeToJSON(value['yes']),
252
260
  'no': MarketOutcomeToJSON(value['no']),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmxtjs",
3
- "version": "2.46.14",
3
+ "version": "2.47.0",
4
4
  "description": "Unified prediction market data API - The ccxt for prediction markets",
5
5
  "author": "PMXT Contributors",
6
6
  "repository": {
@@ -43,7 +43,7 @@
43
43
  "unified"
44
44
  ],
45
45
  "dependencies": {
46
- "pmxt-core": "2.46.14",
46
+ "pmxt-core": "2.47.0",
47
47
  "ws": "^8.18.0"
48
48
  },
49
49
  "devDependencies": {
package/pmxt/client.ts CHANGED
@@ -1215,32 +1215,24 @@ export abstract class Exchange {
1215
1215
 
1216
1216
  async unwatchOrderBook(outcomeId: string | MarketOutcome): Promise<void> {
1217
1217
  await this.initPromise;
1218
- const resolvedOutcomeId = resolveOutcomeId(outcomeId);
1219
- const args: any[] = [resolvedOutcomeId];
1220
1218
  try {
1221
- const ws = await this.getOrCreateWs();
1222
- if (!ws) {
1223
- throw this.wsTransportUnavailableError("unwatchOrderBook");
1219
+ const args: any[] = [];
1220
+ args.push(resolveOutcomeId(outcomeId));
1221
+ const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/unwatchOrderBook`, {
1222
+ method: 'POST',
1223
+ headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
1224
+ body: JSON.stringify({ args, credentials: this.getCredentials() }),
1225
+ });
1226
+ if (!response.ok) {
1227
+ const body = await response.json().catch(() => ({}));
1228
+ if (body.error && typeof body.error === "object") {
1229
+ throw fromServerError(body.error);
1230
+ }
1231
+ throw new PmxtError(body.error?.message || response.statusText);
1224
1232
  }
1225
-
1226
- const requestId = this.getWsSubscriptionId(ws, "watchOrderBook", args)
1227
- ?? `req-${Math.random().toString(36).slice(2, 14)}`;
1228
-
1229
- await this.sendWsMessage(
1230
- ws,
1231
- {
1232
- id: requestId,
1233
- action: "unsubscribe",
1234
- exchange: this.exchangeName,
1235
- method: "unwatchOrderBook",
1236
- args,
1237
- },
1238
- );
1239
- this.clearWsSubscription(ws, "watchOrderBook", args);
1233
+ const json = await response.json();
1234
+ this.handleResponse(json);
1240
1235
  } catch (error) {
1241
- if (this.isWsTransportUnavailableError(error)) {
1242
- throw this.wsTransportUnavailableError("unwatchOrderBook");
1243
- }
1244
1236
  if (error instanceof PmxtError) throw error;
1245
1237
  throw new PmxtError(`Failed to unwatchOrderBook: ${error}`);
1246
1238
  }