@cohostvip/cohost-node 0.0.3 → 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
@@ -71,6 +71,405 @@ declare enum CostBucket {
71
71
  TAX = "tax"
72
72
  }
73
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
+
74
473
  type CostComponentCap = {
75
474
  op: string;
76
475
  type: CostComponentCap.type;
@@ -143,7 +542,7 @@ type CostComponent = {
143
542
  cap?: CostComponentCap;
144
543
  currency: string;
145
544
  details?: any;
146
- id?: string;
545
+ id: string;
147
546
  name: string;
148
547
  payer: CostComponent.payer;
149
548
  recipient: string;
@@ -338,52 +737,6 @@ type EventProfile = {
338
737
  widgets: Array<EventFeature>;
339
738
  };
340
739
 
341
- /**
342
- * Represents the costs associated with an offering.
343
- */
344
- type OfferingCosts = {
345
- /**
346
- * A string representing a currency amount in the format `"USD,1000"` where:
347
- * - `"USD"` is the 3-letter ISO currency code.
348
- * - The number after the comma represents the value in **minor units** (e.g., cents for USD).
349
- *
350
- * For example, `"USD,1000"` equals $10.00 (i.e., 1000 cents).
351
- */
352
- cost: string;
353
- /**
354
- * A string representing a currency amount in the format `"USD,1000"` where:
355
- * - `"USD"` is the 3-letter ISO currency code.
356
- * - The number after the comma represents the value in **minor units** (e.g., cents for USD).
357
- *
358
- * For example, `"USD,1000"` equals $10.00 (i.e., 1000 cents).
359
- */
360
- delivery: string;
361
- /**
362
- * A string representing a currency amount in the format `"USD,1000"` where:
363
- * - `"USD"` is the 3-letter ISO currency code.
364
- * - The number after the comma represents the value in **minor units** (e.g., cents for USD).
365
- *
366
- * For example, `"USD,1000"` equals $10.00 (i.e., 1000 cents).
367
- */
368
- fee: string;
369
- /**
370
- * cost + fee - discount , not including tax
371
- */
372
- gross: string;
373
- /**
374
- * A string representing a currency amount in the format `"USD,1000"` where:
375
- * - `"USD"` is the 3-letter ISO currency code.
376
- * - The number after the comma represents the value in **minor units** (e.g., cents for USD).
377
- *
378
- * For example, `"USD,1000"` equals $10.00 (i.e., 1000 cents).
379
- */
380
- tax: string;
381
- /**
382
- * total cost including tax
383
- */
384
- total: string;
385
- };
386
-
387
740
  declare enum OfferingStatus {
388
741
  DELETED = "deleted",
389
742
  DRAFT = "draft",
@@ -393,21 +746,6 @@ declare enum OfferingStatus {
393
746
  UNAVAILABLE = "unavailable"
394
747
  }
395
748
 
396
- declare enum OfferingType {
397
- ADMISSION = "admission",
398
- DONATION = "donation",
399
- DRINK = "drink",
400
- MEMBERSHIP = "membership",
401
- MERCH = "merch",
402
- OTHER = "other",
403
- PACKAGE = "package",
404
- SERVICE = "service",
405
- SKIP = "skip",
406
- TC_TICKET = "tc-ticket",
407
- TICKET = "ticket",
408
- VOUCHER = "voucher"
409
- }
410
-
411
749
  type PackageInclude = {
412
750
  description: string;
413
751
  id: string;
@@ -452,16 +790,27 @@ type Schedule = {
452
790
  type Ticket = {
453
791
  capacity: number;
454
792
  category: string;
793
+ /**
794
+ * ISO 8601 timestamp indicating when the record was last updated, if applicable.
795
+ */
455
796
  changed?: string;
456
797
  /**
457
798
  * Describe fees and other costs associated with purchasing tickets
458
799
  * to this offering
800
+ *
801
+ * --@schema array(z.any()).optional()
459
802
  */
460
803
  costComponents?: Array<CostComponent>;
461
804
  costs: OfferingCosts;
805
+ /**
806
+ * ISO 8601 timestamp indicating when the record was created.
807
+ */
462
808
  created: string;
463
809
  description?: string;
464
810
  display_name?: string;
811
+ /**
812
+ * Unique identifier for the record.
813
+ */
465
814
  id: string;
466
815
  included?: Array<PackageInclude>;
467
816
  instructions?: string;
@@ -489,21 +838,40 @@ type Ticket = {
489
838
  declare namespace Ticket {
490
839
  enum type {
491
840
  ADMISSION = "admission",
841
+ ADMISSION_TABLE_COMMITMENT = "admission.tableCommitment",
492
842
  PACKAGE = "package"
493
843
  }
494
844
  }
495
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
+
496
854
  /**
497
855
  * Provides methods to interact with the Cohost Events API.
498
856
  *
499
857
  * Usage:
500
858
  * ```ts
501
859
  * const client = new CohostClient({ token: 'your-token' });
860
+ * const list = await client.events.list();
502
861
  * const event = await client.events.fetch('event-id');
503
862
  * const tickets = await client.events.tickets('event-id');
504
863
  * ```
505
864
  */
506
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[]>;
507
875
  /**
508
876
  * Fetch a single event by ID.
509
877
  *
@@ -543,6 +911,58 @@ declare class OrdersAPI extends CohostEndpoint {
543
911
  fetch(id: string, uid: string): Promise<any>;
544
912
  }
545
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
+
546
966
  /**
547
967
  * Configuration options for instantiating a CohostClient.
548
968
  */
@@ -558,6 +978,7 @@ interface CohostClientOptions {
558
978
  declare class CohostClient {
559
979
  readonly events: EventsAPI;
560
980
  readonly orders: OrdersAPI;
981
+ readonly cart: SessionsAPI;
561
982
  private readonly baseOptions;
562
983
  constructor(options: CohostClientOptions, customRequestFn?: RequestFn);
563
984
  /**