tixbit 0.1.0 → 0.1.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/README.md CHANGED
@@ -90,6 +90,8 @@ tixbit seatmap 4BKJMDZ --section 214
90
90
 
91
91
  Every command supports `--json` for machine-readable output:
92
92
 
93
+ > Event IDs are normalized to public external IDs (e.g. `36PB9ZN`) — internal provider prefixes are stripped from SDK/CLI results.
94
+
93
95
  ```sh
94
96
  tixbit search "concert" --state NY --json
95
97
  tixbit listings 4BKJMDZ --json
@@ -215,7 +217,7 @@ Returns `{ url, listingId, quantity }`.
215
217
  |---|---|---|
216
218
  | `eventId` | `string` | External event ID |
217
219
 
218
- Returns venue info, section list, zone groupings, and background image URL.
220
+ Returns venue info, section list, zone groupings, absolute asset URLs (`background_image`, `coordinates_url`), and per-section `shape_path` data for overlay rendering.
219
221
 
220
222
  ### `eventUrl(slugOrId)`
221
223
 
package/dist/cli.js CHANGED
@@ -7,6 +7,22 @@ import { Command } from "commander";
7
7
  var DEFAULT_BASE_URL = "https://tixbit.com";
8
8
  var DEFAULT_TIMEOUT_MS = 15e3;
9
9
  var USER_AGENT = "@tixbit/sdk";
10
+ function normalizeExternalEventId(eventId) {
11
+ if (!eventId) return eventId;
12
+ const trimmed = eventId.trim();
13
+ const providerPrefixedId = trimmed.match(/^([a-z]{5,})-([A-Z0-9]{6,})$/i);
14
+ if (providerPrefixedId?.[2]) {
15
+ return providerPrefixedId[2];
16
+ }
17
+ return trimmed;
18
+ }
19
+ function toAbsoluteUrl(baseUrl, value) {
20
+ if (!value) return null;
21
+ if (value.startsWith("http://") || value.startsWith("https://")) {
22
+ return value;
23
+ }
24
+ return `${baseUrl}${value.startsWith("/") ? "" : "/"}${value}`;
25
+ }
10
26
  var TixBitClient = class {
11
27
  baseUrl;
12
28
  timeoutMs;
@@ -116,7 +132,8 @@ var TixBitClient = class {
116
132
  page: params.page ?? 1,
117
133
  order_by_direction: params.orderByDirection ?? "asc"
118
134
  });
119
- const data = await this.request(`/api/events/${encodeURIComponent(params.eventId)}/listings${query}`);
135
+ const normalizedEventId = normalizeExternalEventId(params.eventId);
136
+ const data = await this.request(`/api/events/${encodeURIComponent(normalizedEventId)}/listings${query}`);
120
137
  const listings = (data.data ?? []).map(normalizeListing);
121
138
  return {
122
139
  listings,
@@ -160,7 +177,11 @@ var TixBitClient = class {
160
177
  * Build the direct URL to an event page on tixbit.com.
161
178
  */
162
179
  eventUrl(slugOrId) {
163
- return `${this.baseUrl}/events/${slugOrId}`;
180
+ if (slugOrId.includes("/")) {
181
+ return `${this.baseUrl}/events/${slugOrId}`;
182
+ }
183
+ const normalized = normalizeExternalEventId(slugOrId);
184
+ return `${this.baseUrl}/events/${normalized}`;
164
185
  }
165
186
  // ── Seatmap ───────────────────────────────────────────────────────────────
166
187
  /**
@@ -178,27 +199,27 @@ var TixBitClient = class {
178
199
  * ```
179
200
  */
180
201
  async getSeatmap(params) {
181
- const data = await this.request(`/api/events/${encodeURIComponent(params.eventId)}/seating-chart`);
202
+ const normalizedEventId = normalizeExternalEventId(params.eventId);
203
+ const data = await this.request(`/api/events/${encodeURIComponent(normalizedEventId)}/seating-chart`);
182
204
  let zones = [];
183
205
  let sectionNames = [];
184
- if (data.has_coordinates && data.coordinates) {
206
+ const coordinatesUrl = data.coordinates_url ?? data.coordinates ?? null;
207
+ if (data.has_coordinates && coordinatesUrl) {
185
208
  try {
186
- zones = await this.fetchAndParseCoordinates(data.coordinates);
187
- sectionNames = zones.flatMap(
188
- (z) => z.sections.map((s) => s.name)
189
- );
209
+ zones = await this.fetchAndParseCoordinates(coordinatesUrl);
210
+ sectionNames = zones.flatMap((z) => z.sections.map((s) => s.name));
190
211
  } catch {
191
212
  }
192
213
  }
193
214
  return {
194
215
  success: data.success,
195
- event_id: data.event_id,
216
+ event_id: normalizeExternalEventId(data.event_id),
196
217
  venue_id: data.venue_id,
197
218
  venue_name: data.venue_name,
198
219
  configuration_id: data.configuration_id,
199
220
  configuration_name: data.configuration_name,
200
- background_image: data.background_image ?? null,
201
- coordinates_url: data.coordinates ?? null,
221
+ background_image: toAbsoluteUrl(this.baseUrl, data.background_image ?? null),
222
+ coordinates_url: toAbsoluteUrl(this.baseUrl, coordinatesUrl),
202
223
  has_coordinates: data.has_coordinates,
203
224
  capacity: data.capacity ?? null,
204
225
  venue: data.venue_data,
@@ -228,12 +249,22 @@ var TixBitClient = class {
228
249
  id: zone.id,
229
250
  name: zone.name,
230
251
  sections: (zone.sections ?? []).map((section) => {
231
- const label = section.labels?.[0];
252
+ const labels = Array.isArray(section.labels) ? section.labels.filter((label) => label && typeof label.text === "string").map((label) => ({
253
+ text: label.text,
254
+ x: typeof label.x === "number" ? label.x : 0,
255
+ y: typeof label.y === "number" ? label.y : 0,
256
+ size: typeof label.size === "number" ? label.size : void 0,
257
+ angle: typeof label.angle === "number" ? label.angle : void 0
258
+ })) : [];
259
+ const primaryLabel = labels.find((label) => label.text.toUpperCase() === section.name.toUpperCase()) ?? labels[0];
260
+ const shapePath = section.shape && typeof section.shape.path === "string" ? section.shape.path : null;
232
261
  return {
233
262
  id: section.id,
234
263
  name: section.name,
235
- x: label?.x ?? 0,
236
- y: label?.y ?? 0
264
+ x: primaryLabel?.x ?? 0,
265
+ y: primaryLabel?.y ?? 0,
266
+ labels,
267
+ shape_path: shapePath
237
268
  };
238
269
  })
239
270
  }));
@@ -244,10 +275,12 @@ var TixBitClient = class {
244
275
  };
245
276
  function normalizeEvent(raw) {
246
277
  const e = raw;
278
+ const rawId = str(e.external_event_id) ?? str(e.externalEventId) ?? str(e.id) ?? "";
279
+ const externalEventId = normalizeExternalEventId(rawId);
247
280
  return {
248
- id: str(e.id) ?? str(e.external_event_id) ?? "",
249
- external_event_id: str(e.external_event_id) ?? str(e.externalEventId) ?? str(e.id) ?? "",
250
- slug: str(e.slug) ?? str(e.external_event_id) ?? "",
281
+ id: externalEventId,
282
+ external_event_id: externalEventId,
283
+ slug: str(e.slug) ?? externalEventId,
251
284
  name: str(e.name) ?? str(e.performer) ?? "",
252
285
  date: resolveDate(e),
253
286
  venue_name: str(e.venue_name) ?? str(e.venueName) ?? null,
package/dist/index.d.ts CHANGED
@@ -133,6 +133,13 @@ interface GetSeatmapParams {
133
133
  /** External event ID (from search results). */
134
134
  eventId: string;
135
135
  }
136
+ interface SeatmapLabel {
137
+ text: string;
138
+ x: number;
139
+ y: number;
140
+ size?: number;
141
+ angle?: number;
142
+ }
136
143
  /** A single section in the venue's seating chart. */
137
144
  interface SeatmapSection {
138
145
  /** Section ID (e.g. "80841"). */
@@ -140,11 +147,18 @@ interface SeatmapSection {
140
147
  /** Human-readable section name (e.g. "101", "FLOOR3", "201"). */
141
148
  name: string;
142
149
  /**
143
- * Center coordinates of the section label on the map.
144
- * Useful for understanding relative position.
150
+ * Primary label anchor for simple renderers and relative position helpers.
145
151
  */
146
152
  x: number;
147
153
  y: number;
154
+ /**
155
+ * All labels from the seatmap payload (useful for richer rendering).
156
+ */
157
+ labels: SeatmapLabel[];
158
+ /**
159
+ * SVG path for drawing the section shape overlay.
160
+ */
161
+ shape_path: string | null;
148
162
  }
149
163
  /** A zone grouping sections (e.g. "Section", "Floor", "Suite"). */
150
164
  interface SeatmapZone {
@@ -264,4 +278,4 @@ declare class TixBitApiError extends Error {
264
278
  constructor(message: string, status: number, url: string);
265
279
  }
266
280
 
267
- export { type BrowseEventsParams, type BrowseEventsResult, type CheckoutLink, type CheckoutParams, type GetListingsParams, type GetListingsResult, type GetSeatmapParams, type SearchEventsParams, type SearchEventsResult, type SeatmapResult, type SeatmapSection, type SeatmapVenue, type SeatmapZone, TixBitApiError, TixBitClient, type TixBitConfig, type TixBitEvent, type TixBitListing };
281
+ export { type BrowseEventsParams, type BrowseEventsResult, type CheckoutLink, type CheckoutParams, type GetListingsParams, type GetListingsResult, type GetSeatmapParams, type SearchEventsParams, type SearchEventsResult, type SeatmapLabel, type SeatmapResult, type SeatmapSection, type SeatmapVenue, type SeatmapZone, TixBitApiError, TixBitClient, type TixBitConfig, type TixBitEvent, type TixBitListing };
package/dist/index.js CHANGED
@@ -2,6 +2,22 @@
2
2
  var DEFAULT_BASE_URL = "https://tixbit.com";
3
3
  var DEFAULT_TIMEOUT_MS = 15e3;
4
4
  var USER_AGENT = "@tixbit/sdk";
5
+ function normalizeExternalEventId(eventId) {
6
+ if (!eventId) return eventId;
7
+ const trimmed = eventId.trim();
8
+ const providerPrefixedId = trimmed.match(/^([a-z]{5,})-([A-Z0-9]{6,})$/i);
9
+ if (providerPrefixedId?.[2]) {
10
+ return providerPrefixedId[2];
11
+ }
12
+ return trimmed;
13
+ }
14
+ function toAbsoluteUrl(baseUrl, value) {
15
+ if (!value) return null;
16
+ if (value.startsWith("http://") || value.startsWith("https://")) {
17
+ return value;
18
+ }
19
+ return `${baseUrl}${value.startsWith("/") ? "" : "/"}${value}`;
20
+ }
5
21
  var TixBitClient = class {
6
22
  baseUrl;
7
23
  timeoutMs;
@@ -111,7 +127,8 @@ var TixBitClient = class {
111
127
  page: params.page ?? 1,
112
128
  order_by_direction: params.orderByDirection ?? "asc"
113
129
  });
114
- const data = await this.request(`/api/events/${encodeURIComponent(params.eventId)}/listings${query}`);
130
+ const normalizedEventId = normalizeExternalEventId(params.eventId);
131
+ const data = await this.request(`/api/events/${encodeURIComponent(normalizedEventId)}/listings${query}`);
115
132
  const listings = (data.data ?? []).map(normalizeListing);
116
133
  return {
117
134
  listings,
@@ -155,7 +172,11 @@ var TixBitClient = class {
155
172
  * Build the direct URL to an event page on tixbit.com.
156
173
  */
157
174
  eventUrl(slugOrId) {
158
- return `${this.baseUrl}/events/${slugOrId}`;
175
+ if (slugOrId.includes("/")) {
176
+ return `${this.baseUrl}/events/${slugOrId}`;
177
+ }
178
+ const normalized = normalizeExternalEventId(slugOrId);
179
+ return `${this.baseUrl}/events/${normalized}`;
159
180
  }
160
181
  // ── Seatmap ───────────────────────────────────────────────────────────────
161
182
  /**
@@ -173,27 +194,27 @@ var TixBitClient = class {
173
194
  * ```
174
195
  */
175
196
  async getSeatmap(params) {
176
- const data = await this.request(`/api/events/${encodeURIComponent(params.eventId)}/seating-chart`);
197
+ const normalizedEventId = normalizeExternalEventId(params.eventId);
198
+ const data = await this.request(`/api/events/${encodeURIComponent(normalizedEventId)}/seating-chart`);
177
199
  let zones = [];
178
200
  let sectionNames = [];
179
- if (data.has_coordinates && data.coordinates) {
201
+ const coordinatesUrl = data.coordinates_url ?? data.coordinates ?? null;
202
+ if (data.has_coordinates && coordinatesUrl) {
180
203
  try {
181
- zones = await this.fetchAndParseCoordinates(data.coordinates);
182
- sectionNames = zones.flatMap(
183
- (z) => z.sections.map((s) => s.name)
184
- );
204
+ zones = await this.fetchAndParseCoordinates(coordinatesUrl);
205
+ sectionNames = zones.flatMap((z) => z.sections.map((s) => s.name));
185
206
  } catch {
186
207
  }
187
208
  }
188
209
  return {
189
210
  success: data.success,
190
- event_id: data.event_id,
211
+ event_id: normalizeExternalEventId(data.event_id),
191
212
  venue_id: data.venue_id,
192
213
  venue_name: data.venue_name,
193
214
  configuration_id: data.configuration_id,
194
215
  configuration_name: data.configuration_name,
195
- background_image: data.background_image ?? null,
196
- coordinates_url: data.coordinates ?? null,
216
+ background_image: toAbsoluteUrl(this.baseUrl, data.background_image ?? null),
217
+ coordinates_url: toAbsoluteUrl(this.baseUrl, coordinatesUrl),
197
218
  has_coordinates: data.has_coordinates,
198
219
  capacity: data.capacity ?? null,
199
220
  venue: data.venue_data,
@@ -223,12 +244,22 @@ var TixBitClient = class {
223
244
  id: zone.id,
224
245
  name: zone.name,
225
246
  sections: (zone.sections ?? []).map((section) => {
226
- const label = section.labels?.[0];
247
+ const labels = Array.isArray(section.labels) ? section.labels.filter((label) => label && typeof label.text === "string").map((label) => ({
248
+ text: label.text,
249
+ x: typeof label.x === "number" ? label.x : 0,
250
+ y: typeof label.y === "number" ? label.y : 0,
251
+ size: typeof label.size === "number" ? label.size : void 0,
252
+ angle: typeof label.angle === "number" ? label.angle : void 0
253
+ })) : [];
254
+ const primaryLabel = labels.find((label) => label.text.toUpperCase() === section.name.toUpperCase()) ?? labels[0];
255
+ const shapePath = section.shape && typeof section.shape.path === "string" ? section.shape.path : null;
227
256
  return {
228
257
  id: section.id,
229
258
  name: section.name,
230
- x: label?.x ?? 0,
231
- y: label?.y ?? 0
259
+ x: primaryLabel?.x ?? 0,
260
+ y: primaryLabel?.y ?? 0,
261
+ labels,
262
+ shape_path: shapePath
232
263
  };
233
264
  })
234
265
  }));
@@ -239,10 +270,12 @@ var TixBitClient = class {
239
270
  };
240
271
  function normalizeEvent(raw) {
241
272
  const e = raw;
273
+ const rawId = str(e.external_event_id) ?? str(e.externalEventId) ?? str(e.id) ?? "";
274
+ const externalEventId = normalizeExternalEventId(rawId);
242
275
  return {
243
- id: str(e.id) ?? str(e.external_event_id) ?? "",
244
- external_event_id: str(e.external_event_id) ?? str(e.externalEventId) ?? str(e.id) ?? "",
245
- slug: str(e.slug) ?? str(e.external_event_id) ?? "",
276
+ id: externalEventId,
277
+ external_event_id: externalEventId,
278
+ slug: str(e.slug) ?? externalEventId,
246
279
  name: str(e.name) ?? str(e.performer) ?? "",
247
280
  date: resolveDate(e),
248
281
  venue_name: str(e.venue_name) ?? str(e.venueName) ?? null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tixbit",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Search events, view seatmaps, browse listings, and buy tickets on TixBit",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",