@cohostvip/cohost-node 0.0.2 → 0.0.4

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.d.mts CHANGED
@@ -1,22 +1,17 @@
1
1
  /**
2
2
  * Supported HTTP methods.
3
3
  */
4
- type RequestMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
4
+ type RequestMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
5
5
  /**
6
6
  * A function that performs a request to the Cohost API.
7
+ * The generic <T> allows you to specify the expected response type.
7
8
  */
8
- type RequestFn = (
9
- /** Path of the request relative to baseUrl */
10
- path: string, options?: {
11
- /** HTTP method (defaults to 'GET') */
9
+ type RequestFn = <T = any>(path: string, options?: {
12
10
  method?: RequestMethod;
13
- /** Request body data (auto-serialized as JSON) */
14
11
  data?: any;
15
- /** Query parameters to be appended to the URL */
16
12
  query?: Record<string, string | number | boolean | undefined>;
17
- /** Additional headers to merge into the request */
18
13
  headers?: Record<string, string>;
19
- }) => Promise<any>;
14
+ }) => Promise<T>;
20
15
 
21
16
  /**
22
17
  * Optional settings for customizing the behavior of the CohostClient.
@@ -46,17 +41,837 @@ declare class CohostEndpoint {
46
41
  constructor(request: RequestFn, settings: CohostClientSettings);
47
42
  }
48
43
 
44
+ type Address = {
45
+ address_1: string;
46
+ address_2?: string;
47
+ city: string;
48
+ country: string;
49
+ formattedAddress?: string;
50
+ localized_address_display?: string;
51
+ localized_area_display?: string;
52
+ localized_multi_line_address_display?: Array<string>;
53
+ postal_code: string;
54
+ premise?: string;
55
+ region: string;
56
+ };
57
+
58
+ type BuzzBuilder = {
59
+ countLabel: string;
60
+ profiles: Array<{
61
+ id: string;
62
+ name: string;
63
+ photoURL: string;
64
+ }>;
65
+ };
66
+
67
+ declare enum CostBucket {
68
+ DELIVERY = "delivery",
69
+ FEE = "fee",
70
+ ITEM = "item",
71
+ TAX = "tax"
72
+ }
73
+
74
+ type CalculatedCostComponent = {
75
+ base: string;
76
+ bucket: CostBucket;
77
+ /**
78
+ * A string representing a currency amount in the format `"USD,1000"` where:
79
+ * - `"USD"` is the 3-letter ISO currency code.
80
+ * - The number after the comma represents the value in **minor units** (e.g., cents for USD).
81
+ *
82
+ * For example, `"USD,1000"` equals $10.00 (i.e., 1000 cents).
83
+ */
84
+ cost: string;
85
+ discount: null;
86
+ id: string;
87
+ name: string;
88
+ payer: CalculatedCostComponent.payer;
89
+ recipient: string;
90
+ value: number;
91
+ version: string;
92
+ };
93
+ declare namespace CalculatedCostComponent {
94
+ enum payer {
95
+ ATTENDEE = "attendee",
96
+ ORGANIZER = "organizer"
97
+ }
98
+ }
99
+
100
+ type CouponSummary = {
101
+ /**
102
+ * Fixed amount to deduct from the order total.
103
+ * This is a currency-less value that matches the event or order currency.
104
+ * Example: `10.00` = $10.00 off.
105
+ */
106
+ amountOff: number;
107
+ /**
108
+ * The code used to redeem this coupon during checkout.
109
+ * For public or coded discounts.
110
+ */
111
+ code: string;
112
+ /**
113
+ * Unique identifier for the record.
114
+ */
115
+ id: string;
116
+ /**
117
+ * List of offering IDs (e.g., ticket classes) this coupon applies to.
118
+ * If empty, the coupon applies to all eligible offerings in its context.
119
+ */
120
+ offeringIds: Array<string>;
121
+ /**
122
+ * Percentage to deduct from the item or order total.
123
+ * Range is 0–100. Use 0 for no percentage-based discount.
124
+ */
125
+ percentOff: number;
126
+ };
127
+
128
+ type Partial_Customer_ = {
129
+ age?: number;
130
+ birthdate?: string;
131
+ displayName?: string;
132
+ email?: string;
133
+ first?: string;
134
+ gender?: string;
135
+ last?: string;
136
+ name?: string;
137
+ phone?: string;
138
+ photoURL?: string;
139
+ uid?: string;
140
+ };
141
+
142
+ type Partial_OrderContext_ = {
143
+ /**
144
+ * The unique cart session ID assigned at the time the cart was created.
145
+ * Helps track cart attribution across systems.
146
+ */
147
+ cartSessionId?: string;
148
+ /**
149
+ * IP addresses associated with the user request.
150
+ * Typically includes forwarded IPs and direct client IP.
151
+ */
152
+ ipAddresses?: Array<string>;
153
+ /**
154
+ * (Optional) Origin domain name if embedded or white-labeled.
155
+ * Can help identify partner portals or iframe referrers.
156
+ */
157
+ originDomain?: string;
158
+ /**
159
+ * The referring URL from which the cart or checkout was initiated.
160
+ * May be a partner site, marketing page, or event listing.
161
+ */
162
+ referrer?: string;
163
+ /**
164
+ * (Optional) Campaign ID, UTM source, or tracking label.
165
+ * Useful for affiliate and analytics systems.
166
+ */
167
+ trackingId?: string;
168
+ /**
169
+ * Authenticated user ID, or null for anonymous guests.
170
+ */
171
+ uid?: string;
172
+ /**
173
+ * Raw User-Agent header from the client request.
174
+ */
175
+ userAgent?: string;
176
+ };
177
+
178
+ declare enum OfferingType {
179
+ ADMISSION = "admission",
180
+ DONATION = "donation",
181
+ DRINK = "drink",
182
+ MEMBERSHIP = "membership",
183
+ MERCH = "merch",
184
+ OTHER = "other",
185
+ PACKAGE = "package",
186
+ SERVICE = "service",
187
+ SKIP = "skip",
188
+ TC_TICKET = "tc-ticket",
189
+ TICKET = "ticket",
190
+ VOUCHER = "voucher"
191
+ }
192
+
193
+ /**
194
+ * Cost breakdown for a specific item in the order.
195
+ * Extends the standard `OfferingCosts` with totals calculated for quantity and discounts.
196
+ */
197
+ type OrderItemCosts = {
198
+ /**
199
+ * A string representing a currency amount in the format `"USD,1000"` where:
200
+ * - `"USD"` is the 3-letter ISO currency code.
201
+ * - The number after the comma represents the value in **minor units** (e.g., cents for USD).
202
+ *
203
+ * For example, `"USD,1000"` equals $10.00 (i.e., 1000 cents).
204
+ */
205
+ cost: string;
206
+ /**
207
+ * A string representing a currency amount in the format `"USD,1000"` where:
208
+ * - `"USD"` is the 3-letter ISO currency code.
209
+ * - The number after the comma represents the value in **minor units** (e.g., cents for USD).
210
+ *
211
+ * For example, `"USD,1000"` equals $10.00 (i.e., 1000 cents).
212
+ */
213
+ delivery: string;
214
+ /**
215
+ * Total discount amount applied to this item.
216
+ */
217
+ discount: string;
218
+ /**
219
+ * A string representing a currency amount in the format `"USD,1000"` where:
220
+ * - `"USD"` is the 3-letter ISO currency code.
221
+ * - The number after the comma represents the value in **minor units** (e.g., cents for USD).
222
+ *
223
+ * For example, `"USD,1000"` equals $10.00 (i.e., 1000 cents).
224
+ */
225
+ fee: string;
226
+ /**
227
+ * cost + fee - discount , not including tax
228
+ */
229
+ gross: string;
230
+ /**
231
+ * Total price before discounts.
232
+ * Equal to subtotal + fee, before subtracting discount.
233
+ */
234
+ preDiscount: string;
235
+ /**
236
+ * Total cost of tickets before taxes, fees, and discounts.
237
+ */
238
+ subtotal: string;
239
+ /**
240
+ * A string representing a currency amount in the format `"USD,1000"` where:
241
+ * - `"USD"` is the 3-letter ISO currency code.
242
+ * - The number after the comma represents the value in **minor units** (e.g., cents for USD).
243
+ *
244
+ * For example, `"USD,1000"` equals $10.00 (i.e., 1000 cents).
245
+ */
246
+ tax: string;
247
+ /**
248
+ * total cost including tax
249
+ */
250
+ total: string;
251
+ };
252
+
253
+ /**
254
+ * Represents the costs associated with an offering.
255
+ */
256
+ type OfferingCosts = {
257
+ /**
258
+ * A string representing a currency amount in the format `"USD,1000"` where:
259
+ * - `"USD"` is the 3-letter ISO currency code.
260
+ * - The number after the comma represents the value in **minor units** (e.g., cents for USD).
261
+ *
262
+ * For example, `"USD,1000"` equals $10.00 (i.e., 1000 cents).
263
+ */
264
+ cost: string;
265
+ /**
266
+ * A string representing a currency amount in the format `"USD,1000"` where:
267
+ * - `"USD"` is the 3-letter ISO currency code.
268
+ * - The number after the comma represents the value in **minor units** (e.g., cents for USD).
269
+ *
270
+ * For example, `"USD,1000"` equals $10.00 (i.e., 1000 cents).
271
+ */
272
+ delivery: string;
273
+ /**
274
+ * A string representing a currency amount in the format `"USD,1000"` where:
275
+ * - `"USD"` is the 3-letter ISO currency code.
276
+ * - The number after the comma represents the value in **minor units** (e.g., cents for USD).
277
+ *
278
+ * For example, `"USD,1000"` equals $10.00 (i.e., 1000 cents).
279
+ */
280
+ fee: string;
281
+ /**
282
+ * cost + fee - discount , not including tax
283
+ */
284
+ gross: string;
285
+ /**
286
+ * A string representing a currency amount in the format `"USD,1000"` where:
287
+ * - `"USD"` is the 3-letter ISO currency code.
288
+ * - The number after the comma represents the value in **minor units** (e.g., cents for USD).
289
+ *
290
+ * For example, `"USD,1000"` equals $10.00 (i.e., 1000 cents).
291
+ */
292
+ tax: string;
293
+ /**
294
+ * total cost including tax
295
+ */
296
+ total: string;
297
+ };
298
+
299
+ type OrderItemOffering = {
300
+ costs: OfferingCosts;
301
+ /**
302
+ * doc assicated with this offering in the DB.
303
+ */
304
+ docPath: string;
305
+ /**
306
+ * Offering name, can be ticket name, vaucher name, etc...
307
+ */
308
+ name: string;
309
+ type: OfferingType;
310
+ };
311
+
312
+ type Partial_OrderItem_ = {
313
+ /**
314
+ * Breakdown of cost components (e.g., base, service fee, delivery).
315
+ */
316
+ costComponents?: Array<CalculatedCostComponent>;
317
+ costs?: OrderItemCosts;
318
+ /**
319
+ * Unique ID for this order item.
320
+ */
321
+ id?: string;
322
+ /**
323
+ * If this item is included as part of a package, this is the ID of the parent item.
324
+ * Otherwise, null.
325
+ */
326
+ includedWithItemId?: string;
327
+ /**
328
+ * Any relevant metadata associated with this item.
329
+ * This can include custom fields or additional information.
330
+ */
331
+ meta?: any;
332
+ offering?: OrderItemOffering;
333
+ /**
334
+ * ID of the offering purchased.
335
+ */
336
+ offeringId?: string;
337
+ offeringType?: OfferingType;
338
+ /**
339
+ * Quantity purchased of this item.
340
+ */
341
+ quantity?: number;
342
+ };
343
+
344
+ /**
345
+ * Represents a temporary or persisted cart before order placement.
346
+ * Focuses on user intent and checkout prep, not post-purchase records.
347
+ */
348
+ type CartSession = {
349
+ /**
350
+ * ISO 8601 timestamp indicating when the record was last updated, if applicable.
351
+ */
352
+ changed?: string;
353
+ context: Partial_OrderContext_;
354
+ /**
355
+ * Namespaced identifier indicating what the order is associated with.
356
+ * Format: "{type}_{id}", where type is "evt", "ven", or "org".
357
+ */
358
+ contextId: string;
359
+ /**
360
+ * Estimated totals based on current cart state.
361
+ * These values are subject to recalculation before checkout.
362
+ */
363
+ costs?: {
364
+ /**
365
+ * A string representing a currency amount in the format `"USD,1000"` where:
366
+ * - `"USD"` is the 3-letter ISO currency code.
367
+ * - The number after the comma represents the value in **minor units** (e.g., cents for USD).
368
+ *
369
+ * For example, `"USD,1000"` equals $10.00 (i.e., 1000 cents).
370
+ */
371
+ delivery: string;
372
+ /**
373
+ * A string representing a currency amount in the format `"USD,1000"` where:
374
+ * - `"USD"` is the 3-letter ISO currency code.
375
+ * - The number after the comma represents the value in **minor units** (e.g., cents for USD).
376
+ *
377
+ * For example, `"USD,1000"` equals $10.00 (i.e., 1000 cents).
378
+ */
379
+ discount: string;
380
+ /**
381
+ * A string representing a currency amount in the format `"USD,1000"` where:
382
+ * - `"USD"` is the 3-letter ISO currency code.
383
+ * - The number after the comma represents the value in **minor units** (e.g., cents for USD).
384
+ *
385
+ * For example, `"USD,1000"` equals $10.00 (i.e., 1000 cents).
386
+ */
387
+ fee: string;
388
+ /**
389
+ * A string representing a currency amount in the format `"USD,1000"` where:
390
+ * - `"USD"` is the 3-letter ISO currency code.
391
+ * - The number after the comma represents the value in **minor units** (e.g., cents for USD).
392
+ *
393
+ * For example, `"USD,1000"` equals $10.00 (i.e., 1000 cents).
394
+ */
395
+ subtotal: string;
396
+ /**
397
+ * A string representing a currency amount in the format `"USD,1000"` where:
398
+ * - `"USD"` is the 3-letter ISO currency code.
399
+ * - The number after the comma represents the value in **minor units** (e.g., cents for USD).
400
+ *
401
+ * For example, `"USD,1000"` equals $10.00 (i.e., 1000 cents).
402
+ */
403
+ tax: string;
404
+ /**
405
+ * A string representing a currency amount in the format `"USD,1000"` where:
406
+ * - `"USD"` is the 3-letter ISO currency code.
407
+ * - The number after the comma represents the value in **minor units** (e.g., cents for USD).
408
+ *
409
+ * For example, `"USD,1000"` equals $10.00 (i.e., 1000 cents).
410
+ */
411
+ total: string;
412
+ };
413
+ /**
414
+ * List of applied coupons used in the order.
415
+ * Supports multiple entries based on organizer preferences.
416
+ */
417
+ coupons?: Array<CouponSummary>;
418
+ /**
419
+ * ISO 8601 timestamp indicating when the record was created.
420
+ */
421
+ created: string;
422
+ /**
423
+ * The currency code used for this order in ISO 4217 format.
424
+ */
425
+ currency: string;
426
+ customer?: Partial_Customer_;
427
+ /**
428
+ * Partner-forwarded data (e.g. utm, session metadata).
429
+ */
430
+ forwarded?: any;
431
+ /**
432
+ * Unique identifier for the record.
433
+ */
434
+ id: string;
435
+ /**
436
+ * Items the user has added to their cart.
437
+ */
438
+ items: Array<Partial_OrderItem_>;
439
+ /**
440
+ * Internal metadata, flags, debug hints, or experimental context.
441
+ */
442
+ meta: Record<string, any>;
443
+ /**
444
+ * Stripe PaymentIntent client secret, used by frontend (e.g. Stripe.js).
445
+ * Required for completing the payment flow.
446
+ */
447
+ paymentIntentClientSecret?: string;
448
+ /**
449
+ * Stripe PaymentIntent ID linked to this cart, if created.
450
+ * Used for confirming payment on the backend.
451
+ */
452
+ paymentIntentId?: string;
453
+ status: CartSession.status;
454
+ /**
455
+ * Authenticated user ID, if available.
456
+ */
457
+ uid: string;
458
+ /**
459
+ * Schema version identifier for this record.
460
+ * Helps manage compatibility across client-server contracts.
461
+ */
462
+ version: string;
463
+ };
464
+ declare namespace CartSession {
465
+ enum status {
466
+ ABANDONED = "abandoned",
467
+ CANCELLED = "cancelled",
468
+ COMPLETED = "completed",
469
+ STARTED = "started"
470
+ }
471
+ }
472
+
473
+ type CostComponentCap = {
474
+ op: string;
475
+ type: CostComponentCap.type;
476
+ /**
477
+ * The value of the cap. If type is percentage, it is a percentage of the base value.
478
+ * If type is absolute, it is an absolute value.
479
+ *
480
+ * Absolute value is represented in the same denomination as the cost.
481
+ * i.e. if the cost is in cents, the absolute value should be in cents.
482
+ *
483
+ * percentage value is represented as a decimal.
484
+ * For example, 10% is represented as 0.1.
485
+ */
486
+ value: number;
487
+ };
488
+ declare namespace CostComponentCap {
489
+ enum type {
490
+ ABSOLUTE = "absolute",
491
+ PERCENTAGE = "percentage"
492
+ }
493
+ }
494
+
495
+ /**
496
+ * A set of comparison operators used for evaluating conditional expressions.
497
+ *
498
+ * Supported operators:
499
+ * - '==' (equal to)
500
+ * - '!=' (not equal to)
501
+ * - '<' (less than)
502
+ * - '<=' (less than or equal to)
503
+ * - '>' (greater than)
504
+ * - '>=' (greater than or equal to)
505
+ */
506
+ declare enum EqualOperator {
507
+ _ = "!="
508
+ }
509
+
510
+ type CostComponentRuleCondition = {
511
+ /**
512
+ * evaluator, will define a function or endpoint to evaluate the condition.
513
+ */
514
+ eval?: string;
515
+ /**
516
+ * The field to evaluate the condition against.
517
+ * For example, "item.price" or "order.total".
518
+ * The field should be a valid path to the field in the cost component base.
519
+ */
520
+ field: string;
521
+ operator: EqualOperator;
522
+ /**
523
+ * Can be a value such as number, currencyAmount, an ISO date string, etc...
524
+ */
525
+ value: any;
526
+ };
527
+
528
+ type CostComponentRule = {
529
+ /**
530
+ * The rule will be applied to the cost component if the conditions are met.
531
+ */
532
+ conditions: Array<CostComponentRuleCondition>;
533
+ /**
534
+ * Friendly name of the rule.
535
+ */
536
+ name: string;
537
+ };
538
+
539
+ type CostComponent = {
540
+ base: string;
541
+ bucket: CostBucket;
542
+ cap?: CostComponentCap;
543
+ currency: string;
544
+ details?: any;
545
+ id: string;
546
+ name: string;
547
+ payer: CostComponent.payer;
548
+ recipient: string;
549
+ rules: Array<CostComponentRule>;
550
+ version: string;
551
+ };
552
+ declare namespace CostComponent {
553
+ enum payer {
554
+ ATTENDEE = "attendee",
555
+ ORGANIZER = "organizer"
556
+ }
557
+ }
558
+
559
+ /**
560
+ * Status of the event lifecycle.
561
+ *
562
+ * - `archived`: The event is archived and no longer visible in listings.
563
+ * - `draft`: The event is still being edited and not yet published.
564
+ * - `live`: The event is published and accepting actions (e.g., ticket sales).
565
+ * - `started`: The event has begun.
566
+ * - `ended`: The event has ended.
567
+ * - `completed`: The event has concluded successfully and is finalized.
568
+ * - `canceled`: The event was canceled and is no longer active.
569
+ */
570
+ declare enum EventStatus {
571
+ ARCHIVED = "archived",
572
+ CANCELED = "canceled",
573
+ COMPLETED = "completed",
574
+ DRAFT = "draft",
575
+ ENDED = "ended",
576
+ LIVE = "live",
577
+ STARTED = "started"
578
+ }
579
+
580
+ type GeometryPoint = {
581
+ lat: number;
582
+ lng: number;
583
+ };
584
+
585
+ type LocationGeometry = {
586
+ geoHash?: string;
587
+ lat: number;
588
+ lng: number;
589
+ locality?: string;
590
+ region?: string;
591
+ vicinity?: string;
592
+ viewport?: {
593
+ northeast: GeometryPoint;
594
+ southwest: GeometryPoint;
595
+ };
596
+ zoom?: number;
597
+ };
598
+
599
+ type Location = {
600
+ address: Address;
601
+ geometry: LocationGeometry;
602
+ name: string;
603
+ placeId: string;
604
+ timezone?: string;
605
+ venueId: string;
606
+ };
607
+
608
+ /**
609
+ * A photo object with resolution options and optional metadata.
610
+ */
611
+ type Photo = {
612
+ /**
613
+ * High-resolution (2x) image URL.
614
+ */
615
+ '2x'?: string;
616
+ /**
617
+ * Optional caption for the image.
618
+ */
619
+ caption?: string;
620
+ /**
621
+ * Height of the image in pixels.
622
+ */
623
+ height?: number;
624
+ /**
625
+ * Internal photo ID, if stored in a media system.
626
+ */
627
+ id?: string;
628
+ /**
629
+ * Primary image URL.
630
+ * This is the default image URL to be used when no other resolution is specified.
631
+ */
632
+ url: string;
633
+ /**
634
+ * Width of the image in pixels.
635
+ */
636
+ width?: number;
637
+ };
638
+
639
+ type VenueBase = {
640
+ address: Address;
641
+ formattedAddress: string;
642
+ id: string;
643
+ logo: Photo;
644
+ name: string;
645
+ placeId?: string;
646
+ public: boolean;
647
+ slug: string;
648
+ tz: string;
649
+ };
650
+
651
+ type EventFeature = {
652
+ data: any;
653
+ description: string;
654
+ enabled: boolean;
655
+ iconName?: string;
656
+ id: string;
657
+ key: string;
658
+ logoUri?: string;
659
+ meta?: any;
660
+ order: number;
661
+ title: string;
662
+ type: string;
663
+ version?: string;
664
+ widgetUri: string;
665
+ };
666
+
667
+ /**
668
+ * A rich content object that supports multiple representations of text.
669
+ */
670
+ type MultipartText = {
671
+ /**
672
+ * Optional rich editor blocks (if structured editing is supported).
673
+ */
674
+ blocks?: Array<any>;
675
+ /**
676
+ * HTML version of the content.
677
+ */
678
+ html?: string;
679
+ /**
680
+ * Markdown version of the content.
681
+ */
682
+ md?: string;
683
+ /**
684
+ * Plain text version of the content.
685
+ */
686
+ text?: string;
687
+ };
688
+
689
+ /**
690
+ * EventProfile respresent a public view of an event
691
+ */
692
+ type EventProfile = {
693
+ buzzBuilder?: BuzzBuilder;
694
+ channels: Array<string>;
695
+ companyId: string;
696
+ /**
697
+ * Curerncy used for the event.
698
+ */
699
+ currency: string;
700
+ description: MultipartText;
701
+ /**
702
+ * The end date and time of the event in ISO 8601 format.
703
+ */
704
+ end: string;
705
+ flyer?: Photo;
706
+ id: string;
707
+ isSeries?: boolean;
708
+ location?: Location;
709
+ meta?: any;
710
+ name: string;
711
+ organizer: any;
712
+ priceRange?: {
713
+ max?: string;
714
+ min?: string;
715
+ };
716
+ /**
717
+ * Is the event public?
718
+ */
719
+ public: boolean;
720
+ searchTags: Array<string>;
721
+ sections: Array<string>;
722
+ slug: string;
723
+ /**
724
+ * The start date and time of the event in ISO 8601 format.
725
+ */
726
+ start: string;
727
+ status: EventStatus;
728
+ summary: string;
729
+ tags: Array<string>;
730
+ ticketPrices: Array<string>;
731
+ /**
732
+ * The timezone in which the event is taking place.
733
+ */
734
+ tz: string;
735
+ url?: string;
736
+ venue?: VenueBase;
737
+ widgets: Array<EventFeature>;
738
+ };
739
+
740
+ declare enum OfferingStatus {
741
+ DELETED = "deleted",
742
+ DRAFT = "draft",
743
+ HIDDEN = "hidden",
744
+ LIVE = "live",
745
+ SOLD_OUT = "sold-out",
746
+ UNAVAILABLE = "unavailable"
747
+ }
748
+
749
+ type PackageInclude = {
750
+ description: string;
751
+ id: string;
752
+ quantity: number;
753
+ ref?: any;
754
+ type: OfferingType;
755
+ };
756
+
757
+ declare enum PriceCategory {
758
+ DONATION = "donation",
759
+ FREE = "free",
760
+ OTHER = "other",
761
+ PAID = "paid"
762
+ }
763
+
764
+ /**
765
+ * A repeating or structured date schedule for an event or item.
766
+ */
767
+ type Schedule = {
768
+ /**
769
+ * Days of the week (0 = Sunday, 6 = Saturday).
770
+ */
771
+ daysOfWeek?: Array<number>;
772
+ /**
773
+ * ISO-formatted UTC end datetime.
774
+ */
775
+ end: string;
776
+ /**
777
+ * Specific dates to exclude in "YYYY-MM-DD" format.
778
+ */
779
+ excludeDates?: Array<string>;
780
+ /**
781
+ * Specific dates to include in "YYYY-MM-DD" format.
782
+ */
783
+ includeDates?: Array<string>;
784
+ /**
785
+ * ISO-formatted UTC start datetime.
786
+ */
787
+ start: string;
788
+ };
789
+
790
+ type Ticket = {
791
+ capacity: number;
792
+ category: string;
793
+ /**
794
+ * ISO 8601 timestamp indicating when the record was last updated, if applicable.
795
+ */
796
+ changed?: string;
797
+ /**
798
+ * Describe fees and other costs associated with purchasing tickets
799
+ * to this offering
800
+ *
801
+ * --@schema array(z.any()).optional()
802
+ */
803
+ costComponents?: Array<CostComponent>;
804
+ costs: OfferingCosts;
805
+ /**
806
+ * ISO 8601 timestamp indicating when the record was created.
807
+ */
808
+ created: string;
809
+ description?: string;
810
+ display_name?: string;
811
+ /**
812
+ * Unique identifier for the record.
813
+ */
814
+ id: string;
815
+ included?: Array<PackageInclude>;
816
+ instructions?: string;
817
+ maximumQuantity: number;
818
+ minimumQuantity: number;
819
+ /**
820
+ * Offering name, can be ticket name, vaucher name, etc...
821
+ */
822
+ name: string;
823
+ order_confirmation_message?: string;
824
+ package?: boolean;
825
+ parentId?: string;
826
+ priceCategory: PriceCategory;
827
+ quantitySold: number;
828
+ refId?: string;
829
+ salesEnd: string;
830
+ salesStart: string;
831
+ schedule?: Schedule;
832
+ sorting: number;
833
+ source: string;
834
+ status: OfferingStatus;
835
+ ticketParentId?: string;
836
+ type: Ticket.type;
837
+ };
838
+ declare namespace Ticket {
839
+ enum type {
840
+ ADMISSION = "admission",
841
+ ADMISSION_TABLE_COMMITMENT = "admission.tableCommitment",
842
+ PACKAGE = "package"
843
+ }
844
+ }
845
+
846
+ type UpdatableCartSession = {
847
+ customer?: Partial_Customer_;
848
+ /**
849
+ * Items the user has added to their cart.
850
+ */
851
+ items: Array<Partial_OrderItem_>;
852
+ };
853
+
49
854
  /**
50
855
  * Provides methods to interact with the Cohost Events API.
51
856
  *
52
857
  * Usage:
53
858
  * ```ts
54
859
  * const client = new CohostClient({ token: 'your-token' });
860
+ * const list = await client.events.list();
55
861
  * const event = await client.events.fetch('event-id');
56
862
  * const tickets = await client.events.tickets('event-id');
57
863
  * ```
58
864
  */
59
865
  declare class EventsAPI extends CohostEndpoint {
866
+ /**
867
+ * Fetch a list of all events.
868
+ *
869
+ * @returns A Promise resolving to an array of event objects
870
+ * @throws Will throw an error if the request fails
871
+ *
872
+ * @todo Implement pagination and filtering options
873
+ */
874
+ list(): Promise<EventProfile[]>;
60
875
  /**
61
876
  * Fetch a single event by ID.
62
877
  *
@@ -64,7 +879,7 @@ declare class EventsAPI extends CohostEndpoint {
64
879
  * @returns A Promise resolving to the event object
65
880
  * @throws Will throw an error if the request fails or the event is not found
66
881
  */
67
- fetch(id: string): Promise<any>;
882
+ fetch(id: string): Promise<EventProfile>;
68
883
  /**
69
884
  * List all tickets associated with a specific event.
70
885
  *
@@ -72,7 +887,7 @@ declare class EventsAPI extends CohostEndpoint {
72
887
  * @returns A Promise resolving to an array of ticket objects
73
888
  * @throws Will throw an error if the request fails or the event does not exist
74
889
  */
75
- tickets(id: string): Promise<any>;
890
+ tickets(id: string): Promise<Ticket[]>;
76
891
  }
77
892
 
78
893
  /**
@@ -96,6 +911,58 @@ declare class OrdersAPI extends CohostEndpoint {
96
911
  fetch(id: string, uid: string): Promise<any>;
97
912
  }
98
913
 
914
+ interface StartCartSessionInput {
915
+ contextId: string;
916
+ userAgent?: string;
917
+ referrer?: string;
918
+ ipAddresses?: string[];
919
+ }
920
+
921
+ /**
922
+ * Provides methods to interact with cart sessions in the Cohost API.
923
+ *
924
+ * Usage:
925
+ * ```ts
926
+ * const client = new CohostClient({ token: 'your-token' });
927
+ * const session = await client.sessions.start({ contextId: 'evt_abc123' });
928
+ * ```
929
+ */
930
+ declare class SessionsAPI extends CohostEndpoint {
931
+ /**
932
+ * Start a new cart session.
933
+ *
934
+ * @param input - Data to start the session
935
+ * @returns The newly created cart session
936
+ * @throws Will throw an error if the request fails
937
+ */
938
+ start(input: StartCartSessionInput): Promise<CartSession>;
939
+ /**
940
+ * Get a cart session by its ID.
941
+ *
942
+ * @param id - The unique session ID
943
+ * @returns The cart session object
944
+ * @throws Will throw an error if the session is not found or request fails
945
+ */
946
+ get(id: string): Promise<CartSession>;
947
+ /**
948
+ * Update a cart session.
949
+ *
950
+ * @param id - The ID of the session to update
951
+ * @param input - Data to update the session
952
+ * @returns The updated session
953
+ * @throws Will throw an error if the update fails
954
+ */
955
+ update(id: string, input: UpdatableCartSession): Promise<CartSession>;
956
+ /**
957
+ * Cancel (soft delete) a cart session.
958
+ *
959
+ * @param id - The ID of the session to cancel
960
+ * @returns Nothing if successful
961
+ * @throws Will throw an error if the cancel operation fails
962
+ */
963
+ cancel(id: string): Promise<void>;
964
+ }
965
+
99
966
  /**
100
967
  * Configuration options for instantiating a CohostClient.
101
968
  */
@@ -107,20 +974,21 @@ interface CohostClientOptions {
107
974
  }
108
975
  /**
109
976
  * CohostClient provides grouped access to various API modules such as Events and Orders.
110
- *
111
- * Usage:
112
- * ```ts
113
- * const client = new CohostClient({ token: 'your-token' });
114
- * const event = await client.events.fetch('event-id');
115
- * const order = await client.orders.fetch('order-id', 'user-id');
116
- * ```
117
977
  */
118
978
  declare class CohostClient {
119
- /** Access to Event-related endpoints */
120
979
  readonly events: EventsAPI;
121
- /** Access to Order-related endpoints */
122
980
  readonly orders: OrdersAPI;
123
- constructor({ token, settings }: CohostClientOptions);
981
+ readonly cart: SessionsAPI;
982
+ private readonly baseOptions;
983
+ constructor(options: CohostClientOptions, customRequestFn?: RequestFn);
984
+ /**
985
+ * Returns a new CohostClient instance with overridden request behavior
986
+ */
987
+ requestWithOverrides(overrides: {
988
+ token?: string;
989
+ baseUrl?: string;
990
+ headers?: Record<string, string>;
991
+ }): CohostClient;
124
992
  }
125
993
 
126
994
  /**