@bookitive/js 0.1.4 → 0.1.5

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/index.js CHANGED
@@ -133,10 +133,11 @@ var BookitiveClient = class {
133
133
  }
134
134
  throw new BookitiveError(res.status, body, fallback);
135
135
  }
136
- if (res.status === 204 || res.headers.get("content-length") === "0") {
136
+ if (res.status === 204 || res.status === 205) {
137
137
  return void 0;
138
138
  }
139
- return await res.json();
139
+ const text = await res.text();
140
+ return text ? JSON.parse(text) : void 0;
140
141
  }
141
142
  };
142
143
  export {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/generated/api.ts","../src/live.ts","../src/client.ts"],"sourcesContent":["/* eslint-disable */\n/* tslint:disable */\n// @ts-nocheck\n/*\n * ---------------------------------------------------------------\n * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##\n * ## ##\n * ## AUTHOR: acacode ##\n * ## SOURCE: https://github.com/acacode/swagger-typescript-api ##\n * ---------------------------------------------------------------\n */\n\n/**\n * Type is the stable, machine-readable error code.\n * @example \"CONFLICT\"\n */\nexport enum DtoErrorCode {\n\tErrInvalidPayload = 'INVALID_PAYLOAD',\n\tErrValidationFailed = 'VALIDATION_FAILED',\n\tErrNotFound = 'NOT_FOUND',\n\tErrConflict = 'CONFLICT',\n\tErrForbidden = 'FORBIDDEN',\n\tErrInternal = 'INTERNAL_ERROR',\n}\n\nexport interface DtoAPIError {\n\t/** Data carries optional structured context for the error. */\n\tdata?: any;\n\t/** Fields maps a request field to a validation message, when applicable. */\n\tfields?: Record<string, string>;\n\t/**\n\t * Msg is a human-readable description of what went wrong.\n\t * @example \"seat is no longer available\"\n\t */\n\tmsg?: string;\n\t/**\n\t * Timestamp is when the error was produced (RFC 3339).\n\t * @example \"2026-06-20T18:00:00Z\"\n\t */\n\ttimestamp?: string;\n\t/**\n\t * TraceID identifies this request in our logs; include it in support asks.\n\t * @example \"01JABCDoftraceZ\"\n\t */\n\ttraceId?: string;\n\t/** Type is the stable, machine-readable error code. */\n\ttype?: DtoErrorCode;\n}\n\nexport interface DtoPublicAvailability {\n\t/** GARemaining maps a standing area id to its remaining capacity. */\n\tgaRemaining?: Record<string, number>;\n\t/**\n\t * ReservedSeats marks which unavailable seats are merely reserved and may\n\t * free up again — present only when the event shares reserved status.\n\t * @uniqueItems false\n\t * @example [\"1810000000000000502\"]\n\t */\n\treservedSeats?: string[];\n\t/** TicketTypeRemaining maps a ticket type id to its remaining capacity. */\n\tticketTypeRemaining?: Record<string, number>;\n\t/**\n\t * UnavailableSeats lists the ids of seats that cannot currently be bought.\n\t * @uniqueItems false\n\t * @example [\"1810000000000000501\",\"1810000000000000502\"]\n\t */\n\tunavailableSeats?: string[];\n}\n\nexport interface DtoPublicEvent {\n\t/** Event is the event's public identity: name, times, venue, currency. */\n\tevent?: DtoPublicEventInfo;\n\t/**\n\t * Floors lets a host page render its floor tabs without loading the full\n\t * seating payload; ids match the seating endpoint's floors.\n\t * @uniqueItems false\n\t */\n\tfloors?: DtoPublicFloorInfo[];\n\t/** Org is the organizer's public branding (name, logo, accent colour). */\n\torg?: DtoPublicOrg;\n\t/**\n\t * TicketTypes are the sellable ticket categories with prices and limits.\n\t * @uniqueItems false\n\t */\n\tticketTypes?: DtoPublicTicketType[];\n}\n\n/** Event is the event's public identity: name, times, venue, currency. */\nexport interface DtoPublicEventInfo {\n\t/**\n\t * Currency is the ISO 4217 code all prices are quoted in.\n\t * @example \"CZK\"\n\t */\n\tcurrency?: string;\n\t/**\n\t * EndTime is when the event ends (RFC 3339), when known.\n\t * @example \"2026-06-20T23:00:00Z\"\n\t */\n\tendTime?: string;\n\t/**\n\t * HoldTTLSeconds is how long a checkout holds selected seats before expiry.\n\t * @example 900\n\t */\n\tholdTtlSeconds?: number;\n\t/**\n\t * LocationName is the venue's display name, when set.\n\t * @example \"Výstaviště Praha\"\n\t */\n\tlocationName?: string;\n\t/**\n\t * Name is the event's public display name.\n\t * @example \"Rockfest 2026\"\n\t */\n\tname?: string;\n\t/**\n\t * Slug is the event's URL identifier (the {eventSlug} path parameter).\n\t * @example \"rockfest-2026\"\n\t */\n\tslug?: string;\n\t/**\n\t * StartTime is when doors/the event begins (RFC 3339).\n\t * @example \"2026-06-20T18:00:00Z\"\n\t */\n\tstartTime?: string;\n}\n\nexport interface DtoPublicFloor {\n\t/**\n\t * Cons are short caveats for this floor, shown alongside the pros.\n\t * @uniqueItems false\n\t * @example [\"Standing only\"]\n\t */\n\tcons?: string[];\n\t/**\n\t * Description is optional customer-facing copy shown on the floor's tab.\n\t * @example \"Standing area in front of the main stage\"\n\t */\n\tdescription?: string;\n\t/**\n\t * ID is the floor's stable id; it matches PublicFloorInfo.id.\n\t * @example \"1810000000000000101\"\n\t */\n\tid?: string;\n\t/**\n\t * Mode is \"single\" (one open space) or \"sections\" (subdivided blocks).\n\t * @example \"sections\"\n\t */\n\tmode?: 'single' | 'sections';\n\t/**\n\t * Name is the floor's display label.\n\t * @example \"Ground floor\"\n\t */\n\tname?: string;\n\t/**\n\t * Position is the 1-based tab order among the event's floors.\n\t * @example 1\n\t */\n\tposition?: number;\n\t/**\n\t * Pros are short selling points for this floor, shown as a checklist.\n\t * @uniqueItems false\n\t * @example [\"Closest to the stage\",\"Great atmosphere\"]\n\t */\n\tpros?: string[];\n\t/**\n\t * Sections are the floor's blocks; a single-mode floor has exactly one.\n\t * @uniqueItems false\n\t */\n\tsections?: DtoPublicSection[];\n}\n\nexport interface DtoPublicFloorInfo {\n\t/**\n\t * Cons are short caveats for this floor, shown alongside the pros.\n\t * @uniqueItems false\n\t * @example [\"Standing only\"]\n\t */\n\tcons?: string[];\n\t/**\n\t * Description is optional customer-facing copy shown on the floor's tab.\n\t * @example \"Standing area in front of the main stage\"\n\t */\n\tdescription?: string;\n\t/**\n\t * ID is the floor's stable id; it matches a floor in the seating endpoint.\n\t * @example \"1810000000000000101\"\n\t */\n\tid?: string;\n\t/**\n\t * Mode is \"single\" (one open space) or \"sections\" (subdivided blocks).\n\t * @example \"sections\"\n\t */\n\tmode?: 'single' | 'sections';\n\t/**\n\t * Name is the floor's display label.\n\t * @example \"Ground floor\"\n\t */\n\tname?: string;\n\t/**\n\t * Position is the 1-based tab order among the event's floors.\n\t * @example 1\n\t */\n\tposition?: number;\n\t/**\n\t * Pros are short selling points for this floor, shown as a checklist.\n\t * @uniqueItems false\n\t * @example [\"Closest to the stage\",\"Great atmosphere\"]\n\t */\n\tpros?: string[];\n}\n\nexport interface DtoPublicGAArea {\n\t/**\n\t * Capacity is the total number of standing tickets this area can sell.\n\t * @example 500\n\t */\n\tcapacity?: number;\n\t/**\n\t * H is the area's height on the floor canvas.\n\t * @example 200\n\t */\n\th?: number;\n\t/**\n\t * ID is the standing area's stable id, referenced by availability/orders.\n\t * @example \"1810000000000000601\"\n\t */\n\tid?: string;\n\t/**\n\t * Label is the standing area's display name.\n\t * @example \"Pit\"\n\t */\n\tlabel?: string;\n\t/**\n\t * Rotation is the area's rotation in degrees.\n\t * @example 0\n\t */\n\trotation?: number;\n\t/**\n\t * TicketTypeID is the standing ticket type mapped to this area, when priced.\n\t * @example \"1810000000000000201\"\n\t */\n\tticketTypeId?: string;\n\t/**\n\t * W is the area's width on the floor canvas.\n\t * @example 600\n\t */\n\tw?: number;\n\t/**\n\t * X is the area's left offset on the floor canvas.\n\t * @example 100\n\t */\n\tx?: number;\n\t/**\n\t * Y is the area's top offset on the floor canvas.\n\t * @example 400\n\t */\n\ty?: number;\n}\n\nexport interface DtoPublicOrder {\n\t/**\n\t * Currency is the ISO 4217 code the total is quoted in.\n\t * @example \"CZK\"\n\t */\n\tcurrency?: string;\n\t/**\n\t * ExpiresAt is when the held seats and this order expire (RFC 3339).\n\t * @example \"2026-06-20T18:15:00Z\"\n\t */\n\texpiresAt?: string;\n\t/** Payment carries the bank-transfer instructions for pending orders. */\n\tpayment?: DtoPublicPaymentDetail;\n\t/**\n\t * Reference is the order's human-facing reference (also the payment symbol).\n\t * @example \"RF26-000142\"\n\t */\n\treference?: string;\n\t/**\n\t * Status is the order lifecycle state at creation time.\n\t * @example \"pending\"\n\t */\n\tstatus?: 'pending' | 'paid' | 'cancelled' | 'expired';\n\t/**\n\t * TotalCents is the amount due in the event currency's minor units.\n\t * @example 149000\n\t */\n\ttotalCents?: number;\n}\n\n/** Customer is the buyer's contact details. */\nexport interface DtoPublicOrderCustomer {\n\t/**\n\t * Email is where the payment instructions and tickets are sent.\n\t * @example \"jana@example.com\"\n\t */\n\temail: string;\n\t/**\n\t * Name is the buyer's full name.\n\t * @maxLength 200\n\t * @example \"Jana Nováková\"\n\t */\n\tname: string;\n\t/**\n\t * Phone is an optional contact number.\n\t * @maxLength 50\n\t * @example \"+420123456789\"\n\t */\n\tphone?: string;\n}\n\nexport interface DtoPublicOrderItem {\n\t/**\n\t * GAAreaID is the standing area's id for standing ticket types.\n\t * @example \"1810000000000000601\"\n\t */\n\tgaAreaId?: string;\n\t/**\n\t * Quantity is how many to buy — always 1 for a seat, 1+ for standing.\n\t * @min 1\n\t * @example 1\n\t */\n\tquantity: number;\n\t/**\n\t * SeatID is the chosen seat's id for seated ticket types.\n\t * @example \"1810000000000000501\"\n\t */\n\tseatId?: string;\n\t/**\n\t * TicketTypeID is the ticket type being bought (from the event endpoint).\n\t * @example \"1810000000000000201\"\n\t */\n\tticketTypeId: string;\n}\n\nexport interface DtoPublicOrderRequest {\n\t/**\n\t * CaptchaToken is the client-side captcha solution, verified server-side.\n\t * @example \"03AGdBq26…\"\n\t */\n\tcaptchaToken?: string;\n\t/** Customer is the buyer's contact details. */\n\tcustomer: DtoPublicOrderCustomer;\n\t/**\n\t * Items are the order lines; at least one is required.\n\t * @minItems 1\n\t * @uniqueItems false\n\t */\n\titems: DtoPublicOrderItem[];\n}\n\n/** Org is the organizer's public branding (name, logo, accent colour). */\nexport interface DtoPublicOrg {\n\t/**\n\t * AccentColor is the organizer's brand colour as a hex string, if set.\n\t * @example \"#E5482F\"\n\t */\n\taccentColor?: string;\n\t/**\n\t * LogoURL is an absolute URL to the organizer's logo, if set.\n\t * @example \"https://cdn.bookitive.com/orgs/rockfest/logo.png\"\n\t */\n\tlogoUrl?: string;\n\t/**\n\t * Name is the organizer's public display name.\n\t * @example \"Rockfest Productions\"\n\t */\n\tname?: string;\n\t/**\n\t * Slug is the organizer's URL identifier (the {orgSlug} path parameter).\n\t * @example \"rockfest\"\n\t */\n\tslug?: string;\n}\n\n/** Payment carries the bank-transfer instructions for pending orders. */\nexport interface DtoPublicPaymentDetail {\n\t/**\n\t * BankAccount is the organizer's free-form payment destination.\n\t * @example \"123456789/0100\"\n\t */\n\tbankAccount?: string;\n\t/**\n\t * VariableSymbol identifies the payment — it equals the order reference.\n\t * @example \"26000142\"\n\t */\n\tvariableSymbol?: string;\n}\n\nexport interface DtoPublicSeat {\n\t/**\n\t * Code is the human-facing seat label (section prefix + table + seat).\n\t * @example \"L12-3\"\n\t */\n\tcode?: string;\n\t/**\n\t * ID is the seat's stable id; availability and orders reference it.\n\t * @example \"1810000000000000501\"\n\t */\n\tid?: string;\n\t/**\n\t * TableID is the owning table's id, when the seat belongs to a table.\n\t * @example \"1810000000000000401\"\n\t */\n\ttableId?: string;\n\t/**\n\t * TicketTypeID is the ticket type mapped to this seat, when priced.\n\t * @example \"1810000000000000201\"\n\t */\n\tticketTypeId?: string;\n\t/**\n\t * X is the seat centre's x on the floor canvas.\n\t * @example 245\n\t */\n\tx?: number;\n\t/**\n\t * Y is the seat centre's y on the floor canvas.\n\t * @example 158\n\t */\n\ty?: number;\n}\n\nexport interface DtoPublicSeating {\n\t/**\n\t * Floors are the chart's floors in tab order, each with its geometry.\n\t * @uniqueItems false\n\t */\n\tfloors?: DtoPublicFloor[];\n}\n\nexport interface DtoPublicSection {\n\t/** Decorations is opaque visual scenery (stage, walls, doors) — never sold. */\n\tdecorations?: object;\n\t/**\n\t * GAAreas are the standing areas (sold by quantity) in this section.\n\t * @uniqueItems false\n\t */\n\tgaAreas?: DtoPublicGAArea[];\n\t/**\n\t * H is the section's height on the floor canvas, if sized.\n\t * @example 300\n\t */\n\th?: number;\n\t/**\n\t * ID is the section's stable id.\n\t * @example \"1810000000000000301\"\n\t */\n\tid?: string;\n\t/**\n\t * Name is the section's display label.\n\t * @example \"Left block\"\n\t */\n\tname?: string;\n\t/** Polygon is the section's outline as an array of {x,y} points, if shaped. */\n\tpolygon?: object;\n\t/**\n\t * Prefix is prepended to seat codes in this section (e.g. \"L\" → \"L12-3\").\n\t * @example \"L\"\n\t */\n\tprefix?: string;\n\t/**\n\t * Seats are the individually sellable seats in this section.\n\t * @uniqueItems false\n\t */\n\tseats?: DtoPublicSeat[];\n\t/** Settings is opaque render config (chair gap/size, label typography). */\n\tsettings?: object;\n\t/**\n\t * Tables are the seated tables in this section.\n\t * @uniqueItems false\n\t */\n\ttables?: DtoPublicTable[];\n\t/**\n\t * W is the section's width on the floor canvas, if sized.\n\t * @example 400\n\t */\n\tw?: number;\n\t/**\n\t * X is the section's left offset on the floor canvas, if positioned.\n\t * @example 120\n\t */\n\tx?: number;\n\t/**\n\t * Y is the section's top offset on the floor canvas, if positioned.\n\t * @example 80\n\t */\n\ty?: number;\n}\n\nexport interface DtoPublicTable {\n\t/**\n\t * Curve is the arc for row tables, in degrees (0 = straight row).\n\t * @example 0\n\t */\n\tcurve?: number;\n\t/**\n\t * H is the height for rect tables, in canvas units.\n\t * @example 60\n\t */\n\th?: number;\n\t/**\n\t * ID is the table's stable id, referenced by PublicSeat.tableId.\n\t * @example \"1810000000000000401\"\n\t */\n\tid?: string;\n\t/**\n\t * Number is the table's display number within its section.\n\t * @example 12\n\t */\n\tnumber?: number;\n\t/**\n\t * Radius is the radius for round tables, in canvas units.\n\t * @example 45\n\t */\n\tradius?: number;\n\t/**\n\t * Rotation is the table's rotation in degrees.\n\t * @example 0\n\t */\n\trotation?: number;\n\t/**\n\t * Shape is the table outline: \"round\", \"rect\", or \"row\".\n\t * @example \"round\"\n\t */\n\tshape?: 'round' | 'rect' | 'row';\n\t/**\n\t * Sides is the seat count per edge for rect tables [top,right,bottom,left].\n\t * @uniqueItems false\n\t */\n\tsides?: number[];\n\t/**\n\t * Spacing is the gap between seats on a row table, in canvas units.\n\t * @example 24\n\t */\n\tspacing?: number;\n\t/**\n\t * W is the width for rect tables, in canvas units.\n\t * @example 120\n\t */\n\tw?: number;\n\t/**\n\t * X is the table centre's x on the floor canvas.\n\t * @example 240.5\n\t */\n\tx?: number;\n\t/**\n\t * Y is the table centre's y on the floor canvas.\n\t * @example 160\n\t */\n\ty?: number;\n}\n\nexport interface DtoPublicTicketType {\n\t/**\n\t * Color is the swatch used to tint seats/areas of this type, as hex.\n\t * @example \"#E5482F\"\n\t */\n\tcolor?: string;\n\t/**\n\t * Cons are short caveats for this ticket type, shown alongside the pros.\n\t * @uniqueItems false\n\t * @example [\"No seating\"]\n\t */\n\tcons?: string[];\n\t/**\n\t * Description is optional customer-facing copy for this ticket type.\n\t * @example \"Front-stage standing with a dedicated bar\"\n\t */\n\tdescription?: string;\n\t/**\n\t * ID is the ticket type's stable id, referenced by order items and seats.\n\t * @example \"1810000000000000201\"\n\t */\n\tid?: string;\n\t/**\n\t * Kind is \"seated\" (maps to a seat) or \"standing\" (sold by quantity).\n\t * @example \"standing\"\n\t */\n\tkind?: 'seated' | 'standing';\n\t/**\n\t * MaxPerOrder caps how many of this type a single order may contain.\n\t * @example 6\n\t */\n\tmaxPerOrder?: number;\n\t/**\n\t * MinPerOrder appears only when it is a real constraint (> 1) — the\n\t * limit applies to orders that include this type at all.\n\t * @example 1\n\t */\n\tminPerOrder?: number;\n\t/**\n\t * Name is the ticket type's display label.\n\t * @example \"VIP\"\n\t */\n\tname?: string;\n\t/**\n\t * PriceCents is the unit price in the event's currency's minor units.\n\t * @example 149000\n\t */\n\tpriceCents?: number;\n\t/**\n\t * Pros are short selling points for this ticket type, shown as a checklist.\n\t * @uniqueItems false\n\t * @example [\"Best view\",\"Dedicated bar\",\"Fast-track entry\"]\n\t */\n\tpros?: string[];\n\t/**\n\t * SaleEndTime is when this type stops selling (RFC 3339), if scheduled.\n\t * @example \"2026-06-20T16:00:00Z\"\n\t */\n\tsaleEndTime?: string;\n\t/**\n\t * SaleStartTime is when this type goes on sale (RFC 3339), if scheduled.\n\t * @example \"2026-01-15T10:00:00Z\"\n\t */\n\tsaleStartTime?: string;\n}\n","// Live availability over websocket: {\"event\":\"startstate\"|\"seat\", data}.\n// Startstate re-fires on every reconnect, so consumers treat it as the\n// resync point and apply deltas on top.\nimport type { DtoPublicAvailability } from './generated/api.js';\n\n/** One seat changing state. \"reserved\" appears only when the event shares\n * reserved status publicly — a reserved seat may free up again. */\nexport interface SeatDelta {\n\tseatId: string;\n\ttaken: boolean;\n\tstatus: 'free' | 'reserved' | 'taken';\n}\n\nexport interface LiveHandlers {\n\t/** Full snapshot — on connect and on every reconnect. */\n\tonStartstate?: (availability: DtoPublicAvailability) => void;\n\t/** One seat changed. */\n\tonSeat?: (delta: SeatDelta) => void;\n\t/** Connection state changes (drive a \"live\" indicator if you like). */\n\tonConnectionChange?: (connected: boolean) => void;\n}\n\nconst INITIAL_BACKOFF_MS = 1000;\nconst MAX_BACKOFF_MS = 15000;\n\nexport class LiveSubscription {\n\t#url: string;\n\t#handlers: LiveHandlers;\n\t#ws: WebSocket | null = null;\n\t#backoff = INITIAL_BACKOFF_MS;\n\t#retry: ReturnType<typeof setTimeout> | null = null;\n\t#closed = false;\n\n\tconstructor(url: string, handlers: LiveHandlers) {\n\t\tthis.#url = url.replace(/^http/, 'ws');\n\t\tthis.#handlers = handlers;\n\t\tthis.#connect();\n\t}\n\n\tclose(): void {\n\t\tthis.#closed = true;\n\t\tif (this.#retry) clearTimeout(this.#retry);\n\t\tthis.#ws?.close();\n\t}\n\n\t#connect(): void {\n\t\tif (this.#closed) return;\n\t\tconst ws = new WebSocket(this.#url);\n\t\tthis.#ws = ws;\n\t\tws.onopen = () => {\n\t\t\tthis.#backoff = INITIAL_BACKOFF_MS;\n\t\t\tthis.#handlers.onConnectionChange?.(true);\n\t\t};\n\t\tws.onmessage = (event) => {\n\t\t\tlet message: { event?: string; data?: unknown };\n\t\t\ttry {\n\t\t\t\tmessage = JSON.parse(event.data as string);\n\t\t\t} catch {\n\t\t\t\treturn; // ignore malformed / non-JSON frames rather than throwing\n\t\t\t}\n\t\t\tif (message.event === 'startstate') {\n\t\t\t\tthis.#handlers.onStartstate?.(message.data as DtoPublicAvailability);\n\t\t\t} else if (message.event === 'seat') {\n\t\t\t\tthis.#handlers.onSeat?.(message.data as SeatDelta);\n\t\t\t}\n\t\t};\n\t\tws.onclose = () => {\n\t\t\tthis.#handlers.onConnectionChange?.(false);\n\t\t\tif (this.#closed) return;\n\t\t\t// Equal-jitter backoff: reconnect somewhere in [backoff/2, backoff) so a\n\t\t\t// mass disconnect doesn't produce a synchronized reconnect thundering herd.\n\t\t\tconst delay = this.#backoff / 2 + Math.random() * (this.#backoff / 2);\n\t\t\tthis.#retry = setTimeout(() => this.#connect(), delay);\n\t\t\tthis.#backoff = Math.min(this.#backoff * 2, MAX_BACKOFF_MS);\n\t\t};\n\t}\n}\n","// The typed core of @bookitive/js: a thin fetch wrapper over the public\n// checkout API, addressed by org + event slug. All response and payload types\n// are generated from the backend's public swagger — they cannot drift.\nimport { DtoErrorCode } from './generated/api.js';\nimport type {\n\tDtoAPIError,\n\tDtoPublicAvailability,\n\tDtoPublicEvent,\n\tDtoPublicOrder,\n\tDtoPublicOrderRequest,\n\tDtoPublicSeating,\n} from './generated/api.js';\nimport { LiveSubscription, type LiveHandlers } from './live.js';\n\nexport interface BookitiveClientOptions {\n\t/** API origin, e.g. \"https://api.bookitive.com\" (no trailing slash). */\n\tbaseUrl: string;\n\t/** Organization slug — the {org} in events.bookitive.com/{org}/{event}. */\n\torg: string;\n\t/** Event slug. */\n\tevent: string;\n\t/** Custom fetch (SSR frameworks pass their own). Defaults to global fetch. */\n\tfetch?: typeof fetch;\n}\n\n/** API failure with the backend's error envelope attached. */\nexport class BookitiveError extends Error {\n\treadonly status: number;\n\t/** The backend error code (e.g. DtoErrorCode.ErrConflict), or \"UNKNOWN\" when\n\t * the response carried no JSON envelope. */\n\treadonly type: DtoErrorCode | 'UNKNOWN';\n\n\tconstructor(status: number, body: DtoAPIError | undefined, fallback: string) {\n\t\tsuper(body?.msg ?? fallback);\n\t\tthis.name = 'BookitiveError';\n\t\tthis.status = status;\n\t\tthis.type = body?.type ?? 'UNKNOWN';\n\t}\n\n\t/** The selection raced another buyer — refresh availability and reselect. */\n\tget isConflict(): boolean {\n\t\treturn this.type === DtoErrorCode.ErrConflict || this.status === 409;\n\t}\n}\n\nexport class BookitiveClient {\n\treadonly #base: string;\n\treadonly #fetch: typeof fetch;\n\n\tconstructor(options: BookitiveClientOptions) {\n\t\tthis.#base = `${options.baseUrl.replace(/\\/$/, '')}/public/v1/orgs/${encodeURIComponent(\n\t\t\toptions.org\n\t\t)}/events/${encodeURIComponent(options.event)}`;\n\t\t// bind, or a browser's fetch throws \"Illegal invocation\" when called\n\t\t// detached from window\n\t\tthis.#fetch = options.fetch ?? ((...args) => fetch(...args));\n\t}\n\n\t/** Event identity, org branding, priced ticket types, and floor tabs. */\n\tevent(): Promise<DtoPublicEvent> {\n\t\treturn this.#get<DtoPublicEvent>('');\n\t}\n\n\t/** Static chart geometry: floors → sections → tables, seats, GA areas. */\n\tseating(): Promise<DtoPublicSeating> {\n\t\treturn this.#get<DtoPublicSeating>('/seating');\n\t}\n\n\t/** Live sellability snapshot (poll it, or use live() for push updates). */\n\tavailability(): Promise<DtoPublicAvailability> {\n\t\treturn this.#get<DtoPublicAvailability>('/availability');\n\t}\n\n\t/**\n\t * Places a bank-transfer reservation: seats are held atomically for the\n\t * event's hold TTL and payment instructions are emailed (and returned).\n\t * A 409 (error.isConflict) means a seat was just taken — refresh and\n\t * reselect.\n\t */\n\tasync checkout(order: DtoPublicOrderRequest): Promise<DtoPublicOrder> {\n\t\tconst res = await this.#fetch(`${this.#base}/orders`, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: { 'Content-Type': 'application/json' },\n\t\t\tbody: JSON.stringify(order),\n\t\t});\n\t\treturn this.#parse<DtoPublicOrder>(res, 'checkout failed');\n\t}\n\n\t/**\n\t * Subscribes to live availability over websocket: `startstate` fires with\n\t * the full snapshot on every (re)connect, then `seat` deltas stream in.\n\t * Reconnects automatically with backoff; call close() when done.\n\t */\n\tlive(handlers: LiveHandlers): LiveSubscription {\n\t\treturn new LiveSubscription(`${this.#base}/live`, handlers);\n\t}\n\n\tasync #get<T>(path: string): Promise<T> {\n\t\tconst res = await this.#fetch(`${this.#base}${path}`);\n\t\treturn this.#parse<T>(res, `request failed: ${path || '/'}`);\n\t}\n\n\tasync #parse<T>(res: Response, fallback: string): Promise<T> {\n\t\tif (!res.ok) {\n\t\t\tlet body: DtoAPIError | undefined;\n\t\t\ttry {\n\t\t\t\tbody = (await res.json()) as DtoAPIError;\n\t\t\t} catch {\n\t\t\t\t// non-JSON error body — the fallback message covers it\n\t\t\t}\n\t\t\tthrow new BookitiveError(res.status, body, fallback);\n\t\t}\n\t\t// No content (204) or an explicitly empty body — don't call res.json(),\n\t\t// which would throw on an empty stream.\n\t\tif (res.status === 204 || res.headers.get('content-length') === '0') {\n\t\t\treturn undefined as T;\n\t\t}\n\t\treturn (await res.json()) as T;\n\t}\n}\n"],"mappings":";AAgBO,IAAK,eAAL,kBAAKA,kBAAL;AACN,EAAAA,cAAA,uBAAoB;AACpB,EAAAA,cAAA,yBAAsB;AACtB,EAAAA,cAAA,iBAAc;AACd,EAAAA,cAAA,iBAAc;AACd,EAAAA,cAAA,kBAAe;AACf,EAAAA,cAAA,iBAAc;AANH,SAAAA;AAAA,GAAA;;;ACMZ,IAAM,qBAAqB;AAC3B,IAAM,iBAAiB;AAEhB,IAAM,mBAAN,MAAuB;AAAA,EAC7B;AAAA,EACA;AAAA,EACA,MAAwB;AAAA,EACxB,WAAW;AAAA,EACX,SAA+C;AAAA,EAC/C,UAAU;AAAA,EAEV,YAAY,K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,UAAI;AACJ,UAAI;AACH,eAAQ,MAAM,IAAI,KAAK;AAAA,MACxB,QAAQ;AAAA,MAER;AACA,YAAM,IAAI,eAAe,IAAI,QAAQ,MAAM,QAAQ;AAAA,IACpD;AAGA,QAAI,IAAI,WAAW,OAAO,IAAI,QAAQ,IAAI,gBAAgB,MAAM,KAAK;AACpE,aAAO;AAAA,IACR;AACA,WAAQ,MAAM,IAAI,KAAK;AAAA,EACxB;AACD;","names":["DtoErrorCode"]}
1
+ {"version":3,"sources":["../src/generated/api.ts","../src/live.ts","../src/client.ts"],"sourcesContent":["/* eslint-disable */\n/* tslint:disable */\n// @ts-nocheck\n/*\n * ---------------------------------------------------------------\n * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##\n * ## ##\n * ## AUTHOR: acacode ##\n * ## SOURCE: https://github.com/acacode/swagger-typescript-api ##\n * ---------------------------------------------------------------\n */\n\n/**\n * Type is the stable, machine-readable error code.\n * @example \"CONFLICT\"\n */\nexport enum DtoErrorCode {\n\tErrInvalidPayload = 'INVALID_PAYLOAD',\n\tErrValidationFailed = 'VALIDATION_FAILED',\n\tErrNotFound = 'NOT_FOUND',\n\tErrConflict = 'CONFLICT',\n\tErrForbidden = 'FORBIDDEN',\n\tErrInternal = 'INTERNAL_ERROR',\n}\n\nexport interface DtoAPIError {\n\t/** Data carries optional structured context for the error. */\n\tdata?: any;\n\t/** Fields maps a request field to a validation message, when applicable. */\n\tfields?: Record<string, string>;\n\t/**\n\t * Msg is a human-readable description of what went wrong.\n\t * @example \"seat is no longer available\"\n\t */\n\tmsg?: string;\n\t/**\n\t * Timestamp is when the error was produced (RFC 3339).\n\t * @example \"2026-06-20T18:00:00Z\"\n\t */\n\ttimestamp?: string;\n\t/**\n\t * TraceID identifies this request in our logs; include it in support asks.\n\t * @example \"01JABCDoftraceZ\"\n\t */\n\ttraceId?: string;\n\t/** Type is the stable, machine-readable error code. */\n\ttype?: DtoErrorCode;\n}\n\nexport interface DtoPublicAvailability {\n\t/** GARemaining maps a standing area id to its remaining capacity. */\n\tgaRemaining?: Record<string, number>;\n\t/**\n\t * ReservedSeats marks which unavailable seats are merely reserved and may\n\t * free up again — present only when the event shares reserved status.\n\t * @uniqueItems false\n\t * @example [\"1810000000000000502\"]\n\t */\n\treservedSeats?: string[];\n\t/** TicketTypeRemaining maps a ticket type id to its remaining capacity. */\n\tticketTypeRemaining?: Record<string, number>;\n\t/**\n\t * UnavailableSeats lists the ids of seats that cannot currently be bought.\n\t * @uniqueItems false\n\t * @example [\"1810000000000000501\",\"1810000000000000502\"]\n\t */\n\tunavailableSeats?: string[];\n}\n\nexport interface DtoPublicEvent {\n\t/** Event is the event's public identity: name, times, venue, currency. */\n\tevent?: DtoPublicEventInfo;\n\t/**\n\t * Floors lets a host page render its floor tabs without loading the full\n\t * seating payload; ids match the seating endpoint's floors.\n\t * @uniqueItems false\n\t */\n\tfloors?: DtoPublicFloorInfo[];\n\t/** Org is the organizer's public branding (name, logo, accent colour). */\n\torg?: DtoPublicOrg;\n\t/**\n\t * TicketTypes are the sellable ticket categories with prices and limits.\n\t * @uniqueItems false\n\t */\n\tticketTypes?: DtoPublicTicketType[];\n}\n\n/** Event is the event's public identity: name, times, venue, currency. */\nexport interface DtoPublicEventInfo {\n\t/**\n\t * Currency is the ISO 4217 code all prices are quoted in.\n\t * @example \"CZK\"\n\t */\n\tcurrency?: string;\n\t/**\n\t * EndTime is when the event ends (RFC 3339), when known.\n\t * @example \"2026-06-20T23:00:00Z\"\n\t */\n\tendTime?: string;\n\t/**\n\t * HoldTTLSeconds is how long a checkout holds selected seats before expiry.\n\t * @example 900\n\t */\n\tholdTtlSeconds?: number;\n\t/**\n\t * LocationName is the venue's display name, when set.\n\t * @example \"Výstaviště Praha\"\n\t */\n\tlocationName?: string;\n\t/**\n\t * Name is the event's public display name.\n\t * @example \"Rockfest 2026\"\n\t */\n\tname?: string;\n\t/**\n\t * Slug is the event's URL identifier (the {eventSlug} path parameter).\n\t * @example \"rockfest-2026\"\n\t */\n\tslug?: string;\n\t/**\n\t * StartTime is when doors/the event begins (RFC 3339).\n\t * @example \"2026-06-20T18:00:00Z\"\n\t */\n\tstartTime?: string;\n}\n\nexport interface DtoPublicFloor {\n\t/**\n\t * Cons are short caveats for this floor, shown alongside the pros.\n\t * @uniqueItems false\n\t * @example [\"Standing only\"]\n\t */\n\tcons?: string[];\n\t/**\n\t * Description is optional customer-facing copy shown on the floor's tab.\n\t * @example \"Standing area in front of the main stage\"\n\t */\n\tdescription?: string;\n\t/**\n\t * ID is the floor's stable id; it matches PublicFloorInfo.id.\n\t * @example \"1810000000000000101\"\n\t */\n\tid?: string;\n\t/**\n\t * Mode is \"single\" (one open space) or \"sections\" (subdivided blocks).\n\t * @example \"sections\"\n\t */\n\tmode?: 'single' | 'sections';\n\t/**\n\t * Name is the floor's display label.\n\t * @example \"Ground floor\"\n\t */\n\tname?: string;\n\t/**\n\t * Position is the 1-based tab order among the event's floors.\n\t * @example 1\n\t */\n\tposition?: number;\n\t/**\n\t * Pros are short selling points for this floor, shown as a checklist.\n\t * @uniqueItems false\n\t * @example [\"Closest to the stage\",\"Great atmosphere\"]\n\t */\n\tpros?: string[];\n\t/**\n\t * Sections are the floor's blocks; a single-mode floor has exactly one.\n\t * @uniqueItems false\n\t */\n\tsections?: DtoPublicSection[];\n}\n\nexport interface DtoPublicFloorInfo {\n\t/**\n\t * Cons are short caveats for this floor, shown alongside the pros.\n\t * @uniqueItems false\n\t * @example [\"Standing only\"]\n\t */\n\tcons?: string[];\n\t/**\n\t * Description is optional customer-facing copy shown on the floor's tab.\n\t * @example \"Standing area in front of the main stage\"\n\t */\n\tdescription?: string;\n\t/**\n\t * ID is the floor's stable id; it matches a floor in the seating endpoint.\n\t * @example \"1810000000000000101\"\n\t */\n\tid?: string;\n\t/**\n\t * Mode is \"single\" (one open space) or \"sections\" (subdivided blocks).\n\t * @example \"sections\"\n\t */\n\tmode?: 'single' | 'sections';\n\t/**\n\t * Name is the floor's display label.\n\t * @example \"Ground floor\"\n\t */\n\tname?: string;\n\t/**\n\t * Position is the 1-based tab order among the event's floors.\n\t * @example 1\n\t */\n\tposition?: number;\n\t/**\n\t * Pros are short selling points for this floor, shown as a checklist.\n\t * @uniqueItems false\n\t * @example [\"Closest to the stage\",\"Great atmosphere\"]\n\t */\n\tpros?: string[];\n}\n\nexport interface DtoPublicGAArea {\n\t/**\n\t * Capacity is the total number of standing tickets this area can sell.\n\t * @example 500\n\t */\n\tcapacity?: number;\n\t/**\n\t * H is the area's height on the floor canvas.\n\t * @example 200\n\t */\n\th?: number;\n\t/**\n\t * ID is the standing area's stable id, referenced by availability/orders.\n\t * @example \"1810000000000000601\"\n\t */\n\tid?: string;\n\t/**\n\t * Label is the standing area's display name.\n\t * @example \"Pit\"\n\t */\n\tlabel?: string;\n\t/**\n\t * Rotation is the area's rotation in degrees.\n\t * @example 0\n\t */\n\trotation?: number;\n\t/**\n\t * TicketTypeID is the standing ticket type mapped to this area, when priced.\n\t * @example \"1810000000000000201\"\n\t */\n\tticketTypeId?: string;\n\t/**\n\t * W is the area's width on the floor canvas.\n\t * @example 600\n\t */\n\tw?: number;\n\t/**\n\t * X is the area's left offset on the floor canvas.\n\t * @example 100\n\t */\n\tx?: number;\n\t/**\n\t * Y is the area's top offset on the floor canvas.\n\t * @example 400\n\t */\n\ty?: number;\n}\n\nexport interface DtoPublicOrder {\n\t/**\n\t * Currency is the ISO 4217 code the total is quoted in.\n\t * @example \"CZK\"\n\t */\n\tcurrency?: string;\n\t/**\n\t * ExpiresAt is when the held seats and this order expire (RFC 3339).\n\t * @example \"2026-06-20T18:15:00Z\"\n\t */\n\texpiresAt?: string;\n\t/** Payment carries the bank-transfer instructions for pending orders. */\n\tpayment?: DtoPublicPaymentDetail;\n\t/**\n\t * Reference is the order's human-facing reference (also the payment symbol).\n\t * @example \"RF26-000142\"\n\t */\n\treference?: string;\n\t/**\n\t * Status is the order lifecycle state at creation time.\n\t * @example \"pending\"\n\t */\n\tstatus?: 'pending' | 'paid' | 'cancelled' | 'expired';\n\t/**\n\t * TotalCents is the amount due in the event currency's minor units.\n\t * @example 149000\n\t */\n\ttotalCents?: number;\n}\n\n/** Customer is the buyer's contact details. */\nexport interface DtoPublicOrderCustomer {\n\t/**\n\t * Email is where the payment instructions and tickets are sent.\n\t * @example \"jana@example.com\"\n\t */\n\temail: string;\n\t/**\n\t * Name is the buyer's full name.\n\t * @maxLength 200\n\t * @example \"Jana Nováková\"\n\t */\n\tname: string;\n\t/**\n\t * Phone is an optional contact number.\n\t * @maxLength 50\n\t * @example \"+420123456789\"\n\t */\n\tphone?: string;\n}\n\nexport interface DtoPublicOrderItem {\n\t/**\n\t * GAAreaID is the standing area's id for standing ticket types.\n\t * @example \"1810000000000000601\"\n\t */\n\tgaAreaId?: string;\n\t/**\n\t * Quantity is how many to buy — always 1 for a seat, 1+ for standing.\n\t * @min 1\n\t * @example 1\n\t */\n\tquantity: number;\n\t/**\n\t * SeatID is the chosen seat's id for seated ticket types.\n\t * @example \"1810000000000000501\"\n\t */\n\tseatId?: string;\n\t/**\n\t * TicketTypeID is the ticket type being bought (from the event endpoint).\n\t * @example \"1810000000000000201\"\n\t */\n\tticketTypeId: string;\n}\n\nexport interface DtoPublicOrderRequest {\n\t/**\n\t * CaptchaToken is the client-side captcha solution, verified server-side.\n\t * @example \"03AGdBq26…\"\n\t */\n\tcaptchaToken?: string;\n\t/** Customer is the buyer's contact details. */\n\tcustomer: DtoPublicOrderCustomer;\n\t/**\n\t * Items are the order lines; at least one is required.\n\t * @minItems 1\n\t * @uniqueItems false\n\t */\n\titems: DtoPublicOrderItem[];\n}\n\n/** Org is the organizer's public branding (name, logo, accent colour). */\nexport interface DtoPublicOrg {\n\t/**\n\t * AccentColor is the organizer's brand colour as a hex string, if set.\n\t * @example \"#E5482F\"\n\t */\n\taccentColor?: string;\n\t/**\n\t * LogoURL is an absolute URL to the organizer's logo, if set.\n\t * @example \"https://cdn.bookitive.com/orgs/rockfest/logo.png\"\n\t */\n\tlogoUrl?: string;\n\t/**\n\t * Name is the organizer's public display name.\n\t * @example \"Rockfest Productions\"\n\t */\n\tname?: string;\n\t/**\n\t * Slug is the organizer's URL identifier (the {orgSlug} path parameter).\n\t * @example \"rockfest\"\n\t */\n\tslug?: string;\n}\n\n/** Payment carries the bank-transfer instructions for pending orders. */\nexport interface DtoPublicPaymentDetail {\n\t/**\n\t * BankAccount is the organizer's free-form payment destination.\n\t * @example \"123456789/0100\"\n\t */\n\tbankAccount?: string;\n\t/**\n\t * VariableSymbol identifies the payment — it equals the order reference.\n\t * @example \"26000142\"\n\t */\n\tvariableSymbol?: string;\n}\n\nexport interface DtoPublicSeat {\n\t/**\n\t * Code is the human-facing seat label (section prefix + table + seat).\n\t * @example \"L12-3\"\n\t */\n\tcode?: string;\n\t/**\n\t * ID is the seat's stable id; availability and orders reference it.\n\t * @example \"1810000000000000501\"\n\t */\n\tid?: string;\n\t/**\n\t * TableID is the owning table's id, when the seat belongs to a table.\n\t * @example \"1810000000000000401\"\n\t */\n\ttableId?: string;\n\t/**\n\t * TicketTypeID is the ticket type mapped to this seat, when priced.\n\t * @example \"1810000000000000201\"\n\t */\n\tticketTypeId?: string;\n\t/**\n\t * X is the seat centre's x on the floor canvas.\n\t * @example 245\n\t */\n\tx?: number;\n\t/**\n\t * Y is the seat centre's y on the floor canvas.\n\t * @example 158\n\t */\n\ty?: number;\n}\n\nexport interface DtoPublicSeating {\n\t/**\n\t * Floors are the chart's floors in tab order, each with its geometry.\n\t * @uniqueItems false\n\t */\n\tfloors?: DtoPublicFloor[];\n}\n\nexport interface DtoPublicSection {\n\t/** Decorations is opaque visual scenery (stage, walls, doors) — never sold. */\n\tdecorations?: object;\n\t/**\n\t * GAAreas are the standing areas (sold by quantity) in this section.\n\t * @uniqueItems false\n\t */\n\tgaAreas?: DtoPublicGAArea[];\n\t/**\n\t * H is the section's height on the floor canvas, if sized.\n\t * @example 300\n\t */\n\th?: number;\n\t/**\n\t * ID is the section's stable id.\n\t * @example \"1810000000000000301\"\n\t */\n\tid?: string;\n\t/**\n\t * Name is the section's display label.\n\t * @example \"Left block\"\n\t */\n\tname?: string;\n\t/** Polygon is the section's outline as an array of {x,y} points, if shaped. */\n\tpolygon?: object;\n\t/**\n\t * Prefix is prepended to seat codes in this section (e.g. \"L\" → \"L12-3\").\n\t * @example \"L\"\n\t */\n\tprefix?: string;\n\t/**\n\t * Seats are the individually sellable seats in this section.\n\t * @uniqueItems false\n\t */\n\tseats?: DtoPublicSeat[];\n\t/** Settings is opaque render config (chair gap/size, label typography). */\n\tsettings?: object;\n\t/**\n\t * Tables are the seated tables in this section.\n\t * @uniqueItems false\n\t */\n\ttables?: DtoPublicTable[];\n\t/**\n\t * W is the section's width on the floor canvas, if sized.\n\t * @example 400\n\t */\n\tw?: number;\n\t/**\n\t * X is the section's left offset on the floor canvas, if positioned.\n\t * @example 120\n\t */\n\tx?: number;\n\t/**\n\t * Y is the section's top offset on the floor canvas, if positioned.\n\t * @example 80\n\t */\n\ty?: number;\n}\n\nexport interface DtoPublicTable {\n\t/**\n\t * Curve is the arc for row tables, in degrees (0 = straight row).\n\t * @example 0\n\t */\n\tcurve?: number;\n\t/**\n\t * H is the height for rect tables, in canvas units.\n\t * @example 60\n\t */\n\th?: number;\n\t/**\n\t * ID is the table's stable id, referenced by PublicSeat.tableId.\n\t * @example \"1810000000000000401\"\n\t */\n\tid?: string;\n\t/**\n\t * Number is the table's display number within its section.\n\t * @example 12\n\t */\n\tnumber?: number;\n\t/**\n\t * Radius is the radius for round tables, in canvas units.\n\t * @example 45\n\t */\n\tradius?: number;\n\t/**\n\t * Rotation is the table's rotation in degrees.\n\t * @example 0\n\t */\n\trotation?: number;\n\t/**\n\t * Shape is the table outline: \"round\", \"rect\", or \"row\".\n\t * @example \"round\"\n\t */\n\tshape?: 'round' | 'rect' | 'row';\n\t/**\n\t * Sides is the seat count per edge for rect tables [top,right,bottom,left].\n\t * @uniqueItems false\n\t */\n\tsides?: number[];\n\t/**\n\t * Spacing is the gap between seats on a row table, in canvas units.\n\t * @example 24\n\t */\n\tspacing?: number;\n\t/**\n\t * W is the width for rect tables, in canvas units.\n\t * @example 120\n\t */\n\tw?: number;\n\t/**\n\t * X is the table centre's x on the floor canvas.\n\t * @example 240.5\n\t */\n\tx?: number;\n\t/**\n\t * Y is the table centre's y on the floor canvas.\n\t * @example 160\n\t */\n\ty?: number;\n}\n\nexport interface DtoPublicTicketType {\n\t/**\n\t * Color is the swatch used to tint seats/areas of this type, as hex.\n\t * @example \"#E5482F\"\n\t */\n\tcolor?: string;\n\t/**\n\t * Cons are short caveats for this ticket type, shown alongside the pros.\n\t * @uniqueItems false\n\t * @example [\"No seating\"]\n\t */\n\tcons?: string[];\n\t/**\n\t * Description is optional customer-facing copy for this ticket type.\n\t * @example \"Front-stage standing with a dedicated bar\"\n\t */\n\tdescription?: string;\n\t/**\n\t * ID is the ticket type's stable id, referenced by order items and seats.\n\t * @example \"1810000000000000201\"\n\t */\n\tid?: string;\n\t/**\n\t * Kind is \"seated\" (maps to a seat) or \"standing\" (sold by quantity).\n\t * @example \"standing\"\n\t */\n\tkind?: 'seated' | 'standing';\n\t/**\n\t * MaxPerOrder caps how many of this type a single order may contain.\n\t * @example 6\n\t */\n\tmaxPerOrder?: number;\n\t/**\n\t * MinPerOrder appears only when it is a real constraint (> 1) — the\n\t * limit applies to orders that include this type at all.\n\t * @example 1\n\t */\n\tminPerOrder?: number;\n\t/**\n\t * Name is the ticket type's display label.\n\t * @example \"VIP\"\n\t */\n\tname?: string;\n\t/**\n\t * PriceCents is the unit price in the event's currency's minor units.\n\t * @example 149000\n\t */\n\tpriceCents?: number;\n\t/**\n\t * Pros are short selling points for this ticket type, shown as a checklist.\n\t * @uniqueItems false\n\t * @example [\"Best view\",\"Dedicated bar\",\"Fast-track entry\"]\n\t */\n\tpros?: string[];\n\t/**\n\t * SaleEndTime is when this type stops selling (RFC 3339), if scheduled.\n\t * @example \"2026-06-20T16:00:00Z\"\n\t */\n\tsaleEndTime?: string;\n\t/**\n\t * SaleStartTime is when this type goes on sale (RFC 3339), if scheduled.\n\t * @example \"2026-01-15T10:00:00Z\"\n\t */\n\tsaleStartTime?: string;\n}\n","// Live availability over websocket: {\"event\":\"startstate\"|\"seat\", data}.\n// Startstate re-fires on every reconnect, so consumers treat it as the\n// resync point and apply deltas on top.\nimport type { DtoPublicAvailability } from './generated/api.js';\n\n/** One seat changing state. \"reserved\" appears only when the event shares\n * reserved status publicly — a reserved seat may free up again. */\nexport interface SeatDelta {\n\tseatId: string;\n\ttaken: boolean;\n\tstatus: 'free' | 'reserved' | 'taken';\n}\n\nexport interface LiveHandlers {\n\t/** Full snapshot — on connect and on every reconnect. */\n\tonStartstate?: (availability: DtoPublicAvailability) => void;\n\t/** One seat changed. */\n\tonSeat?: (delta: SeatDelta) => void;\n\t/** Connection state changes (drive a \"live\" indicator if you like). */\n\tonConnectionChange?: (connected: boolean) => void;\n}\n\nconst INITIAL_BACKOFF_MS = 1000;\nconst MAX_BACKOFF_MS = 15000;\n\nexport class LiveSubscription {\n\t#url: string;\n\t#handlers: LiveHandlers;\n\t#ws: WebSocket | null = null;\n\t#backoff = INITIAL_BACKOFF_MS;\n\t#retry: ReturnType<typeof setTimeout> | null = null;\n\t#closed = false;\n\n\tconstructor(url: string, handlers: LiveHandlers) {\n\t\tthis.#url = url.replace(/^http/, 'ws');\n\t\tthis.#handlers = handlers;\n\t\tthis.#connect();\n\t}\n\n\tclose(): void {\n\t\tthis.#closed = true;\n\t\tif (this.#retry) clearTimeout(this.#retry);\n\t\tthis.#ws?.close();\n\t}\n\n\t#connect(): void {\n\t\tif (this.#closed) return;\n\t\tconst ws = new WebSocket(this.#url);\n\t\tthis.#ws = ws;\n\t\tws.onopen = () => {\n\t\t\tthis.#backoff = INITIAL_BACKOFF_MS;\n\t\t\tthis.#handlers.onConnectionChange?.(true);\n\t\t};\n\t\tws.onmessage = (event) => {\n\t\t\tlet message: { event?: string; data?: unknown };\n\t\t\ttry {\n\t\t\t\tmessage = JSON.parse(event.data as string);\n\t\t\t} catch {\n\t\t\t\treturn; // ignore malformed / non-JSON frames rather than throwing\n\t\t\t}\n\t\t\tif (message.event === 'startstate') {\n\t\t\t\tthis.#handlers.onStartstate?.(message.data as DtoPublicAvailability);\n\t\t\t} else if (message.event === 'seat') {\n\t\t\t\tthis.#handlers.onSeat?.(message.data as SeatDelta);\n\t\t\t}\n\t\t};\n\t\tws.onclose = () => {\n\t\t\tthis.#handlers.onConnectionChange?.(false);\n\t\t\tif (this.#closed) return;\n\t\t\t// Equal-jitter backoff: reconnect somewhere in [backoff/2, backoff) so a\n\t\t\t// mass disconnect doesn't produce a synchronized reconnect thundering herd.\n\t\t\tconst delay = this.#backoff / 2 + Math.random() * (this.#backoff / 2);\n\t\t\tthis.#retry = setTimeout(() => this.#connect(), delay);\n\t\t\tthis.#backoff = Math.min(this.#backoff * 2, MAX_BACKOFF_MS);\n\t\t};\n\t}\n}\n","// The typed core of @bookitive/js: a thin fetch wrapper over the public\n// checkout API, addressed by org + event slug. All response and payload types\n// are generated from the backend's public swagger — they cannot drift.\nimport { DtoErrorCode } from './generated/api.js';\nimport type {\n\tDtoAPIError,\n\tDtoPublicAvailability,\n\tDtoPublicEvent,\n\tDtoPublicOrder,\n\tDtoPublicOrderRequest,\n\tDtoPublicSeating,\n} from './generated/api.js';\nimport { LiveSubscription, type LiveHandlers } from './live.js';\n\nexport interface BookitiveClientOptions {\n\t/** API origin, e.g. \"https://api.bookitive.com\" (no trailing slash). */\n\tbaseUrl: string;\n\t/** Organization slug — the {org} in events.bookitive.com/{org}/{event}. */\n\torg: string;\n\t/** Event slug. */\n\tevent: string;\n\t/** Custom fetch (SSR frameworks pass their own). Defaults to global fetch. */\n\tfetch?: typeof fetch;\n}\n\n/** API failure with the backend's error envelope attached. */\nexport class BookitiveError extends Error {\n\treadonly status: number;\n\t/** The backend error code (e.g. DtoErrorCode.ErrConflict), or \"UNKNOWN\" when\n\t * the response carried no JSON envelope. */\n\treadonly type: DtoErrorCode | 'UNKNOWN';\n\n\tconstructor(status: number, body: DtoAPIError | undefined, fallback: string) {\n\t\tsuper(body?.msg ?? fallback);\n\t\tthis.name = 'BookitiveError';\n\t\tthis.status = status;\n\t\tthis.type = body?.type ?? 'UNKNOWN';\n\t}\n\n\t/** The selection raced another buyer — refresh availability and reselect. */\n\tget isConflict(): boolean {\n\t\treturn this.type === DtoErrorCode.ErrConflict || this.status === 409;\n\t}\n}\n\nexport class BookitiveClient {\n\treadonly #base: string;\n\treadonly #fetch: typeof fetch;\n\n\tconstructor(options: BookitiveClientOptions) {\n\t\tthis.#base = `${options.baseUrl.replace(/\\/$/, '')}/public/v1/orgs/${encodeURIComponent(\n\t\t\toptions.org\n\t\t)}/events/${encodeURIComponent(options.event)}`;\n\t\t// bind, or a browser's fetch throws \"Illegal invocation\" when called\n\t\t// detached from window\n\t\tthis.#fetch = options.fetch ?? ((...args) => fetch(...args));\n\t}\n\n\t/** Event identity, org branding, priced ticket types, and floor tabs. */\n\tevent(): Promise<DtoPublicEvent> {\n\t\treturn this.#get<DtoPublicEvent>('');\n\t}\n\n\t/** Static chart geometry: floors → sections → tables, seats, GA areas. */\n\tseating(): Promise<DtoPublicSeating> {\n\t\treturn this.#get<DtoPublicSeating>('/seating');\n\t}\n\n\t/** Live sellability snapshot (poll it, or use live() for push updates). */\n\tavailability(): Promise<DtoPublicAvailability> {\n\t\treturn this.#get<DtoPublicAvailability>('/availability');\n\t}\n\n\t/**\n\t * Places a bank-transfer reservation: seats are held atomically for the\n\t * event's hold TTL and payment instructions are emailed (and returned).\n\t * A 409 (error.isConflict) means a seat was just taken — refresh and\n\t * reselect.\n\t */\n\tasync checkout(order: DtoPublicOrderRequest): Promise<DtoPublicOrder> {\n\t\tconst res = await this.#fetch(`${this.#base}/orders`, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: { 'Content-Type': 'application/json' },\n\t\t\tbody: JSON.stringify(order),\n\t\t});\n\t\treturn this.#parse<DtoPublicOrder>(res, 'checkout failed');\n\t}\n\n\t/**\n\t * Subscribes to live availability over websocket: `startstate` fires with\n\t * the full snapshot on every (re)connect, then `seat` deltas stream in.\n\t * Reconnects automatically with backoff; call close() when done.\n\t */\n\tlive(handlers: LiveHandlers): LiveSubscription {\n\t\treturn new LiveSubscription(`${this.#base}/live`, handlers);\n\t}\n\n\tasync #get<T>(path: string): Promise<T> {\n\t\tconst res = await this.#fetch(`${this.#base}${path}`);\n\t\treturn this.#parse<T>(res, `request failed: ${path || '/'}`);\n\t}\n\n\tasync #parse<T>(res: Response, fallback: string): Promise<T> {\n\t\tif (!res.ok) {\n\t\t\tlet body: DtoAPIError | undefined;\n\t\t\ttry {\n\t\t\t\tbody = (await res.json()) as DtoAPIError;\n\t\t\t} catch {\n\t\t\t\t// non-JSON error body — the fallback message covers it\n\t\t\t}\n\t\t\tthrow new BookitiveError(res.status, body, fallback);\n\t\t}\n\t\t// 204/205 never carry a body. Otherwise read the text and parse only\n\t\t// when it's non-empty — this avoids res.headers.get('content-length'),\n\t\t// which throws under SvelteKit's SSR fetch (response headers aren't\n\t\t// serialized by default) and would otherwise 500 any server-side load.\n\t\tif (res.status === 204 || res.status === 205) {\n\t\t\treturn undefined as T;\n\t\t}\n\t\tconst text = await res.text();\n\t\treturn (text ? JSON.parse(text) : undefined) as T;\n\t}\n}\n"],"mappings":";AAgBO,IAAK,eAAL,kBAAKA,kBAAL;AACN,EAAAA,cAAA,uBAAoB;AACpB,EAAAA,cAAA,yBAAsB;AACtB,EAAAA,cAAA,iBAAc;AACd,EAAAA,cAAA,iBAAc;AACd,EAAAA,cAAA,kBAAe;AACf,EAAAA,cAAA,iBAAc;AANH,SAAAA;AAAA,GAAA;;;ACMZ,IAAM,qBAAqB;AAC3B,IAAM,iBAAiB;AAEhB,IAAM,mBAAN,MAAuB;AAAA,EAC7B;AAAA,EACA;AAAA,EACA,MAAwB;AAAA,EACxB,WAAW;AAAA,EACX,SAA+C;AAAA,EAC/C,UAAU;AAAA,EAEV,YAAY,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Z,UAAI;AACJ,UAAI;AACH,eAAQ,MAAM,IAAI,KAAK;AAAA,MACxB,QAAQ;AAAA,MAER;AACA,YAAM,IAAI,eAAe,IAAI,QAAQ,MAAM,QAAQ;AAAA,IACpD;AAKA,QAAI,IAAI,WAAW,OAAO,IAAI,WAAW,KAAK;AAC7C,aAAO;AAAA,IACR;AACA,UAAM,OAAO,MAAM,IAAI,KAAK;AAC5B,WAAQ,OAAO,KAAK,MAAM,IAAI,IAAI;AAAA,EACnC;AACD;","names":["DtoErrorCode"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bookitive/js",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Typed client for the Bookitive public checkout API — event info, seating, live availability, and orders.",
5
5
  "license": "MIT",
6
6
  "type": "module",