@cohostvip/cohost-node 0.1.14 → 0.1.15

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
@@ -492,24 +492,401 @@ interface Ticket extends Omit<Offering, "hidden" | "constraints" | "type"> {
492
492
  refId?: string;
493
493
  }
494
494
  /**
495
- * Person interface
496
- */
495
+ * Represents a physical address with comprehensive localization support.
496
+ *
497
+ * @interface Address
498
+ * @example
499
+ * ```typescript
500
+ * // Basic US address
501
+ * const usAddress: Address = {
502
+ * address_1: "123 Main Street",
503
+ * address_2: "Apt 4B",
504
+ * city: "New York",
505
+ * country: "US",
506
+ * postal_code: "10001",
507
+ * region: "NY"
508
+ * };
509
+ *
510
+ * // US address with premise
511
+ * const businessAddress: Address = {
512
+ * address_1: "1600 Pennsylvania Avenue NW",
513
+ * city: "Washington",
514
+ * country: "US",
515
+ * premise: "West Wing",
516
+ * postal_code: "20500",
517
+ * region: "DC"
518
+ * };
519
+ *
520
+ * // US address with formatting
521
+ * const formattedAddress: Address = {
522
+ * address_1: "350 Fifth Avenue",
523
+ * city: "New York",
524
+ * country: "US",
525
+ * postal_code: "10118",
526
+ * region: "NY",
527
+ * formattedAddress: "350 Fifth Avenue, New York, NY 10118, US",
528
+ * localized_multi_line_address_display: [
529
+ * "350 Fifth Avenue",
530
+ * "New York, NY 10118"
531
+ * ]
532
+ * };
533
+ * ```
534
+ */
535
+ interface Address {
536
+ /**
537
+ * Primary street address line.
538
+ *
539
+ * @example "123 Main Street"
540
+ * @example "1600 Pennsylvania Avenue NW"
541
+ */
542
+ address_1: string;
543
+ /**
544
+ * Secondary address line for apartment, suite, or unit numbers.
545
+ *
546
+ * @example "Apt 4B"
547
+ * @example "Suite 100"
548
+ * @example "Unit 12"
549
+ */
550
+ address_2?: string;
551
+ /**
552
+ * City or locality name.
553
+ *
554
+ * @example "New York"
555
+ * @example "San Francisco"
556
+ * @example "Chicago"
557
+ */
558
+ city: string;
559
+ /**
560
+ * ISO 3166-1 alpha-2 country code.
561
+ *
562
+ * @example "US" // United States
563
+ */
564
+ country: string;
565
+ /**
566
+ * Building or premise identifier (building name, floor, etc.).
567
+ *
568
+ * @example "Building A"
569
+ * @example "3rd Floor"
570
+ * @example "West Wing"
571
+ */
572
+ premise?: string;
573
+ /**
574
+ * Complete formatted address as a single string.
575
+ * Useful for display purposes or geocoding services.
576
+ *
577
+ * @example "123 Main Street, Apt 4B, New York, NY 10001, US"
578
+ * @example "1600 Pennsylvania Avenue NW, Washington, DC 20500, US"
579
+ */
580
+ formattedAddress?: string;
581
+ /**
582
+ * Localized version of the complete address.
583
+ * For US addresses, typically the same as the standard format.
584
+ *
585
+ * @example "123 Main Street, New York, NY 10001"
586
+ */
587
+ localized_address_display?: string;
588
+ /**
589
+ * Localized area/region display combining city and state.
590
+ *
591
+ * @example "Brooklyn, NY"
592
+ * @example "Los Angeles, CA"
593
+ * @example "Miami, FL"
594
+ */
595
+ localized_area_display?: string;
596
+ /**
597
+ * Multi-line address display as an array of strings.
598
+ * Each element represents a line for proper address formatting on labels or forms.
599
+ *
600
+ * @example
601
+ * [
602
+ * "123 Main Street",
603
+ * "Apt 4B",
604
+ * "New York, NY 10001"
605
+ * ]
606
+ *
607
+ * @example
608
+ * [
609
+ * "350 Fifth Avenue",
610
+ * "New York, NY 10118"
611
+ * ]
612
+ */
613
+ localized_multi_line_address_display?: string[];
614
+ /**
615
+ * US ZIP code or ZIP+4 format.
616
+ *
617
+ * @example "10001" // Standard ZIP
618
+ * @example "10001-1234" // ZIP+4 format
619
+ * @example "90210" // Beverly Hills ZIP
620
+ */
621
+ postal_code: string;
622
+ /**
623
+ * US state or territory 2-letter abbreviation.
624
+ *
625
+ * @example "NY" // New York
626
+ * @example "CA" // California
627
+ * @example "TX" // Texas
628
+ * @example "DC" // District of Columbia
629
+ */
630
+ region: string;
631
+ }
632
+ /**
633
+ * Represents a person with basic identity information.
634
+ *
635
+ * @interface Person
636
+ * @example
637
+ * ```typescript
638
+ * const person: Person = {
639
+ * name: "John Michael Smith",
640
+ * displayName: "John Smith",
641
+ * first: "John",
642
+ * last: "Smith",
643
+ * gender: "male",
644
+ * birthdate: "1990-05-15",
645
+ * age: 33,
646
+ * photoURL: "https://example.com/photos/john-smith.jpg"
647
+ * };
648
+ * ```
649
+ */
497
650
  interface Person {
651
+ /**
652
+ * Full name of the person.
653
+ *
654
+ * @example "John Michael Smith"
655
+ * @example "Sarah Johnson"
656
+ */
498
657
  name: string;
658
+ /**
659
+ * URL to the person's profile photo or avatar.
660
+ * Can be null if no photo is available.
661
+ *
662
+ * @example "https://example.com/photos/john-smith.jpg"
663
+ * @example "https://cdn.example.com/avatars/user123.png"
664
+ * @example null
665
+ */
499
666
  photoURL?: string | null;
667
+ /**
668
+ * Preferred display name for the person.
669
+ * Often a shortened or preferred version of their full name.
670
+ *
671
+ * @example "John Smith"
672
+ * @example "Mike"
673
+ * @example "Dr. Johnson"
674
+ */
500
675
  displayName: string;
676
+ /**
677
+ * First name or given name.
678
+ *
679
+ * @example "John"
680
+ * @example "Sarah"
681
+ * @example "Michael"
682
+ */
501
683
  first: string;
684
+ /**
685
+ * Last name or family name.
686
+ *
687
+ * @example "Smith"
688
+ * @example "Johnson"
689
+ * @example "Williams"
690
+ */
502
691
  last: string;
692
+ /**
693
+ * Gender identity of the person.
694
+ * Can be null if not specified or prefer not to answer.
695
+ *
696
+ * @example "male"
697
+ * @example "female"
698
+ * @example "other"
699
+ * @example null
700
+ */
503
701
  gender: null | string | "male" | "female" | "other";
702
+ /**
703
+ * Date of birth in ISO 8601 format (YYYY-MM-DD).
704
+ * Can be null if not provided.
705
+ *
706
+ * @example "1990-05-15"
707
+ * @example "1985-12-25"
708
+ * @example null
709
+ */
504
710
  birthdate?: string | null;
711
+ /**
712
+ * Current age in years.
713
+ * Typically calculated from birthdate.
714
+ *
715
+ * @example 33
716
+ * @example 28
717
+ * @example 45
718
+ */
505
719
  age?: number;
506
720
  }
721
+ /**
722
+ * Contact information for a person.
723
+ *
724
+ * @interface PersonContact
725
+ * @example
726
+ * ```typescript
727
+ * const contact: PersonContact = {
728
+ * email: "john.smith@example.com",
729
+ * phone: "+1-555-123-4567"
730
+ * };
731
+ *
732
+ * // Minimal contact with only email
733
+ * const emailOnly: PersonContact = {
734
+ * email: "sarah@example.com",
735
+ * phone: null
736
+ * };
737
+ * ```
738
+ */
507
739
  interface PersonContact {
740
+ /**
741
+ * Primary email address.
742
+ * Can be null if no email is provided.
743
+ *
744
+ * @example "john.smith@example.com"
745
+ * @example "user123@gmail.com"
746
+ * @example null
747
+ */
508
748
  email: string | null;
749
+ /**
750
+ * Primary phone number.
751
+ * Can be null if no phone number is provided.
752
+ * Format may vary (with/without country code, formatting).
753
+ *
754
+ * @example "+1-555-123-4567"
755
+ * @example "(555) 123-4567"
756
+ * @example "5551234567"
757
+ * @example null
758
+ */
509
759
  phone: string | null;
510
760
  }
761
+ /**
762
+ * Address information with associated person's name.
763
+ * Extends the base Address interface with first and last name fields.
764
+ * Useful for shipping/billing addresses where the recipient name may differ from the customer.
765
+ *
766
+ * @interface PersonAddress
767
+ * @extends Address
768
+ * @example
769
+ * ```typescript
770
+ * const shippingAddress: PersonAddress = {
771
+ * first: "John",
772
+ * last: "Smith",
773
+ * address_1: "123 Main Street",
774
+ * address_2: "Apt 4B",
775
+ * city: "New York",
776
+ * country: "US",
777
+ * postal_code: "10001",
778
+ * region: "NY"
779
+ * };
780
+ *
781
+ * // Gift shipping to different recipient
782
+ * const giftAddress: PersonAddress = {
783
+ * first: "Jane",
784
+ * last: "Doe",
785
+ * address_1: "456 Oak Avenue",
786
+ * city: "Los Angeles",
787
+ * country: "US",
788
+ * postal_code: "90210",
789
+ * region: "CA"
790
+ * };
791
+ * ```
792
+ */
793
+ interface PersonAddress extends Address {
794
+ /**
795
+ * First name of the person at this address.
796
+ * May differ from the customer's name for gift deliveries.
797
+ *
798
+ * @example "John"
799
+ * @example "Jane"
800
+ */
801
+ first: string;
802
+ /**
803
+ * Last name of the person at this address.
804
+ * May differ from the customer's name for gift deliveries.
805
+ *
806
+ * @example "Smith"
807
+ * @example "Doe"
808
+ */
809
+ last: string;
810
+ }
811
+ /**
812
+ * Complete customer information combining personal details, contact info, and addresses.
813
+ * Represents a customer in an e-commerce or service system.
814
+ *
815
+ * @type Customer
816
+ * @example
817
+ * ```typescript
818
+ * const customer: Customer = {
819
+ * uid: "user_abc123",
820
+ * name: "John Michael Smith",
821
+ * displayName: "John Smith",
822
+ * first: "John",
823
+ * last: "Smith",
824
+ * gender: "male",
825
+ * birthdate: "1990-05-15",
826
+ * age: 33,
827
+ * email: "john.smith@example.com",
828
+ * phone: "+1-555-123-4567",
829
+ * billingAddress: {
830
+ * first: "John",
831
+ * last: "Smith",
832
+ * address_1: "123 Main Street",
833
+ * city: "New York",
834
+ * country: "US",
835
+ * postal_code: "10001",
836
+ * region: "NY"
837
+ * },
838
+ * shippingAddress: {
839
+ * first: "John",
840
+ * last: "Smith",
841
+ * address_1: "456 Work Plaza",
842
+ * address_2: "Suite 100",
843
+ * city: "New York",
844
+ * country: "US",
845
+ * postal_code: "10005",
846
+ * region: "NY"
847
+ * }
848
+ * };
849
+ *
850
+ * // Guest customer (no account)
851
+ * const guestCustomer: Customer = {
852
+ * uid: null,
853
+ * name: "Jane Doe",
854
+ * displayName: "Jane Doe",
855
+ * first: "Jane",
856
+ * last: "Doe",
857
+ * gender: null,
858
+ * email: "jane@example.com",
859
+ * phone: null
860
+ * };
861
+ * ```
862
+ */
511
863
  type Customer = Person & PersonContact & {
864
+ /**
865
+ * Unique identifier for the customer account.
866
+ * Can be null for guest customers who haven't created an account.
867
+ *
868
+ * @example "user_abc123"
869
+ * @example "cust_def456"
870
+ * @example null // Guest customer
871
+ */
512
872
  uid: string | null;
873
+ /**
874
+ * Billing address for payment and invoicing.
875
+ * Can be null if not yet provided.
876
+ *
877
+ * @example PersonAddress object with billing details
878
+ * @example null
879
+ */
880
+ billingAddress?: PersonAddress | null;
881
+ /**
882
+ * Shipping address for order delivery.
883
+ * Can be null for digital products or if not yet provided.
884
+ * May differ from billing address.
885
+ *
886
+ * @example PersonAddress object with shipping details
887
+ * @example null
888
+ */
889
+ shippingAddress?: PersonAddress | null;
513
890
  };
514
891
  type AttendeeStatus = "attending" | "checkedIn" | "cancelled" | "refunded" | "noShow" | "unknown" | string;
515
892
  interface Attendee extends DataRecord {
@@ -557,19 +934,6 @@ interface EventFeature {
557
934
  meta?: any;
558
935
  data: any;
559
936
  }
560
- interface Address {
561
- address_1: string;
562
- address_2?: string;
563
- city: string;
564
- country: string;
565
- premise?: string;
566
- formattedAddress?: string;
567
- localized_address_display?: string;
568
- localized_area_display?: string;
569
- localized_multi_line_address_display?: string[];
570
- postal_code: string;
571
- region: string;
572
- }
573
937
  /**
574
938
  * A simple point geometry consisting of latitude and longitude.
575
939
  *
@@ -1235,7 +1599,7 @@ type CartSessionItem = Pick<OrderItem, "id" | "details" | "offeringId" | "quanti
1235
1599
  *
1236
1600
  * @export
1237
1601
  */
1238
- interface CartSession extends DataRecord, Pick<Order, "currency" | "contextId" | "version" | "coupons" | "companyId" | "organizerId" | "meta"> {
1602
+ interface CartSession extends DataRecord, Pick<Order, "currency" | "contextId" | "version" | "coupons" | "companyId" | "organizerId"> {
1239
1603
  orderId?: string;
1240
1604
  /**
1241
1605
  * Authenticated user ID, if available.
@@ -1290,8 +1654,36 @@ interface CartSession extends DataRecord, Pick<Order, "currency" | "contextId" |
1290
1654
  * Customer answers
1291
1655
  */
1292
1656
  customerAnswers?: any;
1293
- status: "started" | "completed" | "abandoned" | "cancelled";
1657
+ status: "started" | "completed" | "stale" | "abandoned" | "cancelled";
1658
+ meta: CartSessionMeta;
1294
1659
  }
1660
+ type StaleMeta = {
1661
+ /**
1662
+ * Hard stale time in milliseconds.
1663
+ * After this time, the cart is considered abandoned.
1664
+ */
1665
+ hard: number;
1666
+ /**
1667
+ * Soft stale time in milliseconds.
1668
+ * After this time, the cart is considered abandoned.
1669
+ * This is the last change+idle, no later than hard time.
1670
+ */
1671
+ soft: number;
1672
+ /**
1673
+ * Idle time in milliseconds.s
1674
+ */
1675
+ idle: number;
1676
+ };
1677
+ type CartSessionMeta = Partial<Pick<Order, "meta">> & {
1678
+ paymentIntent?: any;
1679
+ /** policy for cart to become abandon */
1680
+ stale: StaleMeta;
1681
+ /**
1682
+ * Any additional internal system flags, A/B test conditions, or
1683
+ * non-critical partner payloads.
1684
+ */
1685
+ [key: string]: any;
1686
+ };
1295
1687
  type UpdatableCartSession = Pick<CartSession, "customer" | "items" | "customerAnswers" | "forwarded">;
1296
1688
 
1297
1689
  /**
@@ -1616,4 +2008,4 @@ declare class CohostClient {
1616
2008
  */
1617
2009
  declare function createCohostClient(options: CohostClientOptions): CohostClient;
1618
2010
 
1619
- export { type ActiveOfferingStatus, type Address, type ApiVersion, type Attendee, type AttendeeStatus, type BuzzBuilder, type CalculatedCostComponent, type CartSession, type CartSessionItem, type CartSessionItemOffering, CohostClient, type CohostClientSettings, type ContextId, type CostBase, type CostBucket, type CostComponent, type CostComponentCap, type CostComponentRule, type CostComponentRuleCondition, type CostOp, type Coupon, type CouponSummary, type CurrencyAmount, type Customer, type DataRecord, type EqualOperator, type EventBase, type EventFeature, type EventProfile, type EventStatus, type GeometryPoint, type Location, type LocationGeometry, type MultipartText, type Offering, type OfferingCosts, type OfferingOption, type OfferingOptionsGroup, type OfferingStatus, type OfferingType, type Order, type OrderContext, type OrderCosts, type OrderItem, type OrderItemCosts, type OrderItemOffering, type OrderStatus, type PackageInclude, type PaginatedRequest, type PaginatedResponse, type Pagination$1 as Pagination, type PaginationResponse, type Person, type PersonContact, type Photo, type PriceCategory, type ResolvedCartContext, type ResolvedCartContextOffering, type Schedule, type StartCartSessionInput, type StructuredCost, type StructuredDate, type Ticket, type TimeOrOffset, type UpdatableCartSession, type VCDataRecord, type Venue, type VenueBase, type VersionedDataRecord, createCohostClient };
2011
+ export { type ActiveOfferingStatus, type Address, type ApiVersion, type Attendee, type AttendeeStatus, type BuzzBuilder, type CalculatedCostComponent, type CartSession, type CartSessionItem, type CartSessionItemOffering, type CartSessionMeta, CohostClient, type CohostClientSettings, type ContextId, type CostBase, type CostBucket, type CostComponent, type CostComponentCap, type CostComponentRule, type CostComponentRuleCondition, type CostOp, type Coupon, type CouponSummary, type CurrencyAmount, type Customer, type DataRecord, type EqualOperator, type EventBase, type EventFeature, type EventProfile, type EventStatus, type GeometryPoint, type Location, type LocationGeometry, type MultipartText, type Offering, type OfferingCosts, type OfferingOption, type OfferingOptionsGroup, type OfferingStatus, type OfferingType, type Order, type OrderContext, type OrderCosts, type OrderItem, type OrderItemCosts, type OrderItemOffering, type OrderStatus, type PackageInclude, type PaginatedRequest, type PaginatedResponse, type Pagination$1 as Pagination, type PaginationResponse, type Person, type PersonAddress, type PersonContact, type Photo, type PriceCategory, type ResolvedCartContext, type ResolvedCartContextOffering, type Schedule, type StaleMeta, type StartCartSessionInput, type StructuredCost, type StructuredDate, type Ticket, type TimeOrOffset, type UpdatableCartSession, type VCDataRecord, type Venue, type VenueBase, type VersionedDataRecord, createCohostClient };
package/dist/index.d.ts CHANGED
@@ -492,24 +492,401 @@ interface Ticket extends Omit<Offering, "hidden" | "constraints" | "type"> {
492
492
  refId?: string;
493
493
  }
494
494
  /**
495
- * Person interface
496
- */
495
+ * Represents a physical address with comprehensive localization support.
496
+ *
497
+ * @interface Address
498
+ * @example
499
+ * ```typescript
500
+ * // Basic US address
501
+ * const usAddress: Address = {
502
+ * address_1: "123 Main Street",
503
+ * address_2: "Apt 4B",
504
+ * city: "New York",
505
+ * country: "US",
506
+ * postal_code: "10001",
507
+ * region: "NY"
508
+ * };
509
+ *
510
+ * // US address with premise
511
+ * const businessAddress: Address = {
512
+ * address_1: "1600 Pennsylvania Avenue NW",
513
+ * city: "Washington",
514
+ * country: "US",
515
+ * premise: "West Wing",
516
+ * postal_code: "20500",
517
+ * region: "DC"
518
+ * };
519
+ *
520
+ * // US address with formatting
521
+ * const formattedAddress: Address = {
522
+ * address_1: "350 Fifth Avenue",
523
+ * city: "New York",
524
+ * country: "US",
525
+ * postal_code: "10118",
526
+ * region: "NY",
527
+ * formattedAddress: "350 Fifth Avenue, New York, NY 10118, US",
528
+ * localized_multi_line_address_display: [
529
+ * "350 Fifth Avenue",
530
+ * "New York, NY 10118"
531
+ * ]
532
+ * };
533
+ * ```
534
+ */
535
+ interface Address {
536
+ /**
537
+ * Primary street address line.
538
+ *
539
+ * @example "123 Main Street"
540
+ * @example "1600 Pennsylvania Avenue NW"
541
+ */
542
+ address_1: string;
543
+ /**
544
+ * Secondary address line for apartment, suite, or unit numbers.
545
+ *
546
+ * @example "Apt 4B"
547
+ * @example "Suite 100"
548
+ * @example "Unit 12"
549
+ */
550
+ address_2?: string;
551
+ /**
552
+ * City or locality name.
553
+ *
554
+ * @example "New York"
555
+ * @example "San Francisco"
556
+ * @example "Chicago"
557
+ */
558
+ city: string;
559
+ /**
560
+ * ISO 3166-1 alpha-2 country code.
561
+ *
562
+ * @example "US" // United States
563
+ */
564
+ country: string;
565
+ /**
566
+ * Building or premise identifier (building name, floor, etc.).
567
+ *
568
+ * @example "Building A"
569
+ * @example "3rd Floor"
570
+ * @example "West Wing"
571
+ */
572
+ premise?: string;
573
+ /**
574
+ * Complete formatted address as a single string.
575
+ * Useful for display purposes or geocoding services.
576
+ *
577
+ * @example "123 Main Street, Apt 4B, New York, NY 10001, US"
578
+ * @example "1600 Pennsylvania Avenue NW, Washington, DC 20500, US"
579
+ */
580
+ formattedAddress?: string;
581
+ /**
582
+ * Localized version of the complete address.
583
+ * For US addresses, typically the same as the standard format.
584
+ *
585
+ * @example "123 Main Street, New York, NY 10001"
586
+ */
587
+ localized_address_display?: string;
588
+ /**
589
+ * Localized area/region display combining city and state.
590
+ *
591
+ * @example "Brooklyn, NY"
592
+ * @example "Los Angeles, CA"
593
+ * @example "Miami, FL"
594
+ */
595
+ localized_area_display?: string;
596
+ /**
597
+ * Multi-line address display as an array of strings.
598
+ * Each element represents a line for proper address formatting on labels or forms.
599
+ *
600
+ * @example
601
+ * [
602
+ * "123 Main Street",
603
+ * "Apt 4B",
604
+ * "New York, NY 10001"
605
+ * ]
606
+ *
607
+ * @example
608
+ * [
609
+ * "350 Fifth Avenue",
610
+ * "New York, NY 10118"
611
+ * ]
612
+ */
613
+ localized_multi_line_address_display?: string[];
614
+ /**
615
+ * US ZIP code or ZIP+4 format.
616
+ *
617
+ * @example "10001" // Standard ZIP
618
+ * @example "10001-1234" // ZIP+4 format
619
+ * @example "90210" // Beverly Hills ZIP
620
+ */
621
+ postal_code: string;
622
+ /**
623
+ * US state or territory 2-letter abbreviation.
624
+ *
625
+ * @example "NY" // New York
626
+ * @example "CA" // California
627
+ * @example "TX" // Texas
628
+ * @example "DC" // District of Columbia
629
+ */
630
+ region: string;
631
+ }
632
+ /**
633
+ * Represents a person with basic identity information.
634
+ *
635
+ * @interface Person
636
+ * @example
637
+ * ```typescript
638
+ * const person: Person = {
639
+ * name: "John Michael Smith",
640
+ * displayName: "John Smith",
641
+ * first: "John",
642
+ * last: "Smith",
643
+ * gender: "male",
644
+ * birthdate: "1990-05-15",
645
+ * age: 33,
646
+ * photoURL: "https://example.com/photos/john-smith.jpg"
647
+ * };
648
+ * ```
649
+ */
497
650
  interface Person {
651
+ /**
652
+ * Full name of the person.
653
+ *
654
+ * @example "John Michael Smith"
655
+ * @example "Sarah Johnson"
656
+ */
498
657
  name: string;
658
+ /**
659
+ * URL to the person's profile photo or avatar.
660
+ * Can be null if no photo is available.
661
+ *
662
+ * @example "https://example.com/photos/john-smith.jpg"
663
+ * @example "https://cdn.example.com/avatars/user123.png"
664
+ * @example null
665
+ */
499
666
  photoURL?: string | null;
667
+ /**
668
+ * Preferred display name for the person.
669
+ * Often a shortened or preferred version of their full name.
670
+ *
671
+ * @example "John Smith"
672
+ * @example "Mike"
673
+ * @example "Dr. Johnson"
674
+ */
500
675
  displayName: string;
676
+ /**
677
+ * First name or given name.
678
+ *
679
+ * @example "John"
680
+ * @example "Sarah"
681
+ * @example "Michael"
682
+ */
501
683
  first: string;
684
+ /**
685
+ * Last name or family name.
686
+ *
687
+ * @example "Smith"
688
+ * @example "Johnson"
689
+ * @example "Williams"
690
+ */
502
691
  last: string;
692
+ /**
693
+ * Gender identity of the person.
694
+ * Can be null if not specified or prefer not to answer.
695
+ *
696
+ * @example "male"
697
+ * @example "female"
698
+ * @example "other"
699
+ * @example null
700
+ */
503
701
  gender: null | string | "male" | "female" | "other";
702
+ /**
703
+ * Date of birth in ISO 8601 format (YYYY-MM-DD).
704
+ * Can be null if not provided.
705
+ *
706
+ * @example "1990-05-15"
707
+ * @example "1985-12-25"
708
+ * @example null
709
+ */
504
710
  birthdate?: string | null;
711
+ /**
712
+ * Current age in years.
713
+ * Typically calculated from birthdate.
714
+ *
715
+ * @example 33
716
+ * @example 28
717
+ * @example 45
718
+ */
505
719
  age?: number;
506
720
  }
721
+ /**
722
+ * Contact information for a person.
723
+ *
724
+ * @interface PersonContact
725
+ * @example
726
+ * ```typescript
727
+ * const contact: PersonContact = {
728
+ * email: "john.smith@example.com",
729
+ * phone: "+1-555-123-4567"
730
+ * };
731
+ *
732
+ * // Minimal contact with only email
733
+ * const emailOnly: PersonContact = {
734
+ * email: "sarah@example.com",
735
+ * phone: null
736
+ * };
737
+ * ```
738
+ */
507
739
  interface PersonContact {
740
+ /**
741
+ * Primary email address.
742
+ * Can be null if no email is provided.
743
+ *
744
+ * @example "john.smith@example.com"
745
+ * @example "user123@gmail.com"
746
+ * @example null
747
+ */
508
748
  email: string | null;
749
+ /**
750
+ * Primary phone number.
751
+ * Can be null if no phone number is provided.
752
+ * Format may vary (with/without country code, formatting).
753
+ *
754
+ * @example "+1-555-123-4567"
755
+ * @example "(555) 123-4567"
756
+ * @example "5551234567"
757
+ * @example null
758
+ */
509
759
  phone: string | null;
510
760
  }
761
+ /**
762
+ * Address information with associated person's name.
763
+ * Extends the base Address interface with first and last name fields.
764
+ * Useful for shipping/billing addresses where the recipient name may differ from the customer.
765
+ *
766
+ * @interface PersonAddress
767
+ * @extends Address
768
+ * @example
769
+ * ```typescript
770
+ * const shippingAddress: PersonAddress = {
771
+ * first: "John",
772
+ * last: "Smith",
773
+ * address_1: "123 Main Street",
774
+ * address_2: "Apt 4B",
775
+ * city: "New York",
776
+ * country: "US",
777
+ * postal_code: "10001",
778
+ * region: "NY"
779
+ * };
780
+ *
781
+ * // Gift shipping to different recipient
782
+ * const giftAddress: PersonAddress = {
783
+ * first: "Jane",
784
+ * last: "Doe",
785
+ * address_1: "456 Oak Avenue",
786
+ * city: "Los Angeles",
787
+ * country: "US",
788
+ * postal_code: "90210",
789
+ * region: "CA"
790
+ * };
791
+ * ```
792
+ */
793
+ interface PersonAddress extends Address {
794
+ /**
795
+ * First name of the person at this address.
796
+ * May differ from the customer's name for gift deliveries.
797
+ *
798
+ * @example "John"
799
+ * @example "Jane"
800
+ */
801
+ first: string;
802
+ /**
803
+ * Last name of the person at this address.
804
+ * May differ from the customer's name for gift deliveries.
805
+ *
806
+ * @example "Smith"
807
+ * @example "Doe"
808
+ */
809
+ last: string;
810
+ }
811
+ /**
812
+ * Complete customer information combining personal details, contact info, and addresses.
813
+ * Represents a customer in an e-commerce or service system.
814
+ *
815
+ * @type Customer
816
+ * @example
817
+ * ```typescript
818
+ * const customer: Customer = {
819
+ * uid: "user_abc123",
820
+ * name: "John Michael Smith",
821
+ * displayName: "John Smith",
822
+ * first: "John",
823
+ * last: "Smith",
824
+ * gender: "male",
825
+ * birthdate: "1990-05-15",
826
+ * age: 33,
827
+ * email: "john.smith@example.com",
828
+ * phone: "+1-555-123-4567",
829
+ * billingAddress: {
830
+ * first: "John",
831
+ * last: "Smith",
832
+ * address_1: "123 Main Street",
833
+ * city: "New York",
834
+ * country: "US",
835
+ * postal_code: "10001",
836
+ * region: "NY"
837
+ * },
838
+ * shippingAddress: {
839
+ * first: "John",
840
+ * last: "Smith",
841
+ * address_1: "456 Work Plaza",
842
+ * address_2: "Suite 100",
843
+ * city: "New York",
844
+ * country: "US",
845
+ * postal_code: "10005",
846
+ * region: "NY"
847
+ * }
848
+ * };
849
+ *
850
+ * // Guest customer (no account)
851
+ * const guestCustomer: Customer = {
852
+ * uid: null,
853
+ * name: "Jane Doe",
854
+ * displayName: "Jane Doe",
855
+ * first: "Jane",
856
+ * last: "Doe",
857
+ * gender: null,
858
+ * email: "jane@example.com",
859
+ * phone: null
860
+ * };
861
+ * ```
862
+ */
511
863
  type Customer = Person & PersonContact & {
864
+ /**
865
+ * Unique identifier for the customer account.
866
+ * Can be null for guest customers who haven't created an account.
867
+ *
868
+ * @example "user_abc123"
869
+ * @example "cust_def456"
870
+ * @example null // Guest customer
871
+ */
512
872
  uid: string | null;
873
+ /**
874
+ * Billing address for payment and invoicing.
875
+ * Can be null if not yet provided.
876
+ *
877
+ * @example PersonAddress object with billing details
878
+ * @example null
879
+ */
880
+ billingAddress?: PersonAddress | null;
881
+ /**
882
+ * Shipping address for order delivery.
883
+ * Can be null for digital products or if not yet provided.
884
+ * May differ from billing address.
885
+ *
886
+ * @example PersonAddress object with shipping details
887
+ * @example null
888
+ */
889
+ shippingAddress?: PersonAddress | null;
513
890
  };
514
891
  type AttendeeStatus = "attending" | "checkedIn" | "cancelled" | "refunded" | "noShow" | "unknown" | string;
515
892
  interface Attendee extends DataRecord {
@@ -557,19 +934,6 @@ interface EventFeature {
557
934
  meta?: any;
558
935
  data: any;
559
936
  }
560
- interface Address {
561
- address_1: string;
562
- address_2?: string;
563
- city: string;
564
- country: string;
565
- premise?: string;
566
- formattedAddress?: string;
567
- localized_address_display?: string;
568
- localized_area_display?: string;
569
- localized_multi_line_address_display?: string[];
570
- postal_code: string;
571
- region: string;
572
- }
573
937
  /**
574
938
  * A simple point geometry consisting of latitude and longitude.
575
939
  *
@@ -1235,7 +1599,7 @@ type CartSessionItem = Pick<OrderItem, "id" | "details" | "offeringId" | "quanti
1235
1599
  *
1236
1600
  * @export
1237
1601
  */
1238
- interface CartSession extends DataRecord, Pick<Order, "currency" | "contextId" | "version" | "coupons" | "companyId" | "organizerId" | "meta"> {
1602
+ interface CartSession extends DataRecord, Pick<Order, "currency" | "contextId" | "version" | "coupons" | "companyId" | "organizerId"> {
1239
1603
  orderId?: string;
1240
1604
  /**
1241
1605
  * Authenticated user ID, if available.
@@ -1290,8 +1654,36 @@ interface CartSession extends DataRecord, Pick<Order, "currency" | "contextId" |
1290
1654
  * Customer answers
1291
1655
  */
1292
1656
  customerAnswers?: any;
1293
- status: "started" | "completed" | "abandoned" | "cancelled";
1657
+ status: "started" | "completed" | "stale" | "abandoned" | "cancelled";
1658
+ meta: CartSessionMeta;
1294
1659
  }
1660
+ type StaleMeta = {
1661
+ /**
1662
+ * Hard stale time in milliseconds.
1663
+ * After this time, the cart is considered abandoned.
1664
+ */
1665
+ hard: number;
1666
+ /**
1667
+ * Soft stale time in milliseconds.
1668
+ * After this time, the cart is considered abandoned.
1669
+ * This is the last change+idle, no later than hard time.
1670
+ */
1671
+ soft: number;
1672
+ /**
1673
+ * Idle time in milliseconds.s
1674
+ */
1675
+ idle: number;
1676
+ };
1677
+ type CartSessionMeta = Partial<Pick<Order, "meta">> & {
1678
+ paymentIntent?: any;
1679
+ /** policy for cart to become abandon */
1680
+ stale: StaleMeta;
1681
+ /**
1682
+ * Any additional internal system flags, A/B test conditions, or
1683
+ * non-critical partner payloads.
1684
+ */
1685
+ [key: string]: any;
1686
+ };
1295
1687
  type UpdatableCartSession = Pick<CartSession, "customer" | "items" | "customerAnswers" | "forwarded">;
1296
1688
 
1297
1689
  /**
@@ -1616,4 +2008,4 @@ declare class CohostClient {
1616
2008
  */
1617
2009
  declare function createCohostClient(options: CohostClientOptions): CohostClient;
1618
2010
 
1619
- export { type ActiveOfferingStatus, type Address, type ApiVersion, type Attendee, type AttendeeStatus, type BuzzBuilder, type CalculatedCostComponent, type CartSession, type CartSessionItem, type CartSessionItemOffering, CohostClient, type CohostClientSettings, type ContextId, type CostBase, type CostBucket, type CostComponent, type CostComponentCap, type CostComponentRule, type CostComponentRuleCondition, type CostOp, type Coupon, type CouponSummary, type CurrencyAmount, type Customer, type DataRecord, type EqualOperator, type EventBase, type EventFeature, type EventProfile, type EventStatus, type GeometryPoint, type Location, type LocationGeometry, type MultipartText, type Offering, type OfferingCosts, type OfferingOption, type OfferingOptionsGroup, type OfferingStatus, type OfferingType, type Order, type OrderContext, type OrderCosts, type OrderItem, type OrderItemCosts, type OrderItemOffering, type OrderStatus, type PackageInclude, type PaginatedRequest, type PaginatedResponse, type Pagination$1 as Pagination, type PaginationResponse, type Person, type PersonContact, type Photo, type PriceCategory, type ResolvedCartContext, type ResolvedCartContextOffering, type Schedule, type StartCartSessionInput, type StructuredCost, type StructuredDate, type Ticket, type TimeOrOffset, type UpdatableCartSession, type VCDataRecord, type Venue, type VenueBase, type VersionedDataRecord, createCohostClient };
2011
+ export { type ActiveOfferingStatus, type Address, type ApiVersion, type Attendee, type AttendeeStatus, type BuzzBuilder, type CalculatedCostComponent, type CartSession, type CartSessionItem, type CartSessionItemOffering, type CartSessionMeta, CohostClient, type CohostClientSettings, type ContextId, type CostBase, type CostBucket, type CostComponent, type CostComponentCap, type CostComponentRule, type CostComponentRuleCondition, type CostOp, type Coupon, type CouponSummary, type CurrencyAmount, type Customer, type DataRecord, type EqualOperator, type EventBase, type EventFeature, type EventProfile, type EventStatus, type GeometryPoint, type Location, type LocationGeometry, type MultipartText, type Offering, type OfferingCosts, type OfferingOption, type OfferingOptionsGroup, type OfferingStatus, type OfferingType, type Order, type OrderContext, type OrderCosts, type OrderItem, type OrderItemCosts, type OrderItemOffering, type OrderStatus, type PackageInclude, type PaginatedRequest, type PaginatedResponse, type Pagination$1 as Pagination, type PaginationResponse, type Person, type PersonAddress, type PersonContact, type Photo, type PriceCategory, type ResolvedCartContext, type ResolvedCartContextOffering, type Schedule, type StaleMeta, type StartCartSessionInput, type StructuredCost, type StructuredDate, type Ticket, type TimeOrOffset, type UpdatableCartSession, type VCDataRecord, type Venue, type VenueBase, type VersionedDataRecord, createCohostClient };
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var m=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var z=Object.prototype.hasOwnProperty;var B=(r,e,t)=>e in r?m(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var V=(r,e)=>{for(var t in e)m(r,t,{get:e[t],enumerable:!0})},L=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of D(e))!z.call(r,s)&&s!==t&&m(r,s,{get:()=>e[s],enumerable:!(n=U(e,s))||n.enumerable});return r};var _=r=>L(m({},"__esModule",{value:!0}),r);var o=(r,e,t)=>B(r,typeof e!="symbol"?e+"":e,t);var G={};V(G,{CohostClient:()=>l,createCohostClient:()=>F});module.exports=_(G);var d=class{constructor(e,t){o(this,"request");o(this,"settings");this.request=e,this.settings=t}};var p="https://api.cohost.com/v1";var f=class r extends Error{constructor(t,n){super(t);o(this,"errorCode");o(this,"statusCode");this.name="CohostError",this.errorCode=n?.errorCode,this.statusCode=n?.statusCode}static fromError(t,n){return new r(t.message,{...n,errorCode:n?.errorCode||t.name})}};var I={baseUrl:"https://api.cohost.vip",headers:{"Content-Type":"application/json"}},v={};var k=(r,e)=>{let{pagination:t,...n}=r;return{query:n,pagination:t,...e}},M=r=>{if(!r)return"";let e=new URLSearchParams;for(let[t,n]of Object.entries(r))n!==void 0&&(Array.isArray(n)?n.forEach(s=>e.append(t,String(s))):e.set(t,String(n)));return e.toString()?`?${e.toString()}`:""},R=({token:r,baseUrl:e=p,debug:t=!1})=>async function(n,s={}){let{method:i="GET",data:g,query:A,pagination:T,headers:E={}}=s,$={...A,...T},w=M($),h=`${v.baseUrl??e}${n}${w}`,b={...I.headers,...v.headers,...E};r&&(b.Authorization=`Bearer ${r}`);let O=g&&i!=="GET"?JSON.stringify(g):void 0;if(t){console.log(`[Cohost SDK] Request: ${i} ${h}`),O&&console.log("[Cohost SDK] Body:",O);let c={};for(let[S,q]of Object.entries(b))if(S.toLowerCase()==="authorization"){let P=q?.split(" ")[1];c[S]="Bearer <token-"+(P?`${P[0]}...${P.slice(-4)}>`:"")}else c[S]=q;console.log("[Cohost SDK] Headers:",c)}let u=await fetch(h,{method:i,headers:b,body:O}),a=u.headers.get("content-type")?.includes("application/json")?await u.json():await u.text();if(!u.ok){let c=typeof a=="string"?a:JSON.stringify(a);throw console.error(`[Cohost SDK] Error(${u.status}): ${c}`,{url:h}),new f(c||u.statusText,{errorCode:u.statusText||"API_ERROR",statusCode:u.status})}return typeof a=="object"&&a!==null&&a.status==="ok"&&"data"in a?a.data:a};var y=class extends d{async list(){return this.request("/events")}async fetch(e){return this.request(`/events/${e}`)}async tickets(e){return this.request(`/events/${e}/tickets`)}async attendees(e,t){return this.request(`/events/${e}/attendees`,k(t))}};var C=class extends d{async fetch(e,t){return this.request(`/orders/${e}?uid=${t}`)}async attendees(e,t){return this.request(`/orders/${e}/attendees?uid=${t}`)}async list(e){let t=new URLSearchParams(e).toString();return this.request(`/orders${t?`?${t}`:""}`)}};var x=class extends d{async start(e){return this.request("/cart/sessions",{method:"POST",data:e})}async get(e){return this.request(`/cart/sessions/${e}`)}async update(e,t){return this.request(`/cart/sessions/${e}`,{method:"PATCH",data:t})}async cancel(e){return this.request(`/cart/sessions/${e}`,{method:"DELETE"})}async updateItem(e,t){return this.request(`/cart/sessions/${e}/item`,{method:"POST",data:t})}async preValidate(e,t){return this.request(`/cart/sessions/${e}/payment/pre-validate`,{method:"POST",data:t})}async processPayment(e,t){return this.request(`/cart/sessions/${e}/payment/process`,{method:"POST",data:t})}async placeOrder(e,t){return this.request(`/cart/sessions/${e}/place-order`,{method:"POST",data:t})}async deleteItem(e,t){return this.updateItem(e,{itemId:t,quantity:0})}async joinTableCommitment(e,t){return this.request(`/cart/sessions/${e}/join-table`,{method:"POST",data:{tableCommitmentId:t}})}async applyCoupon(e,t){return this.request(`/cart/sessions/${e}/coupons`,{method:"POST",data:{code:t}})}async deleteCoupon(e,t){return this.request(`/cart/sessions/${e}/coupons/${t}`,{method:"DELETE"})}};var l=class r{constructor(e,t){o(this,"events");o(this,"orders");o(this,"cart");o(this,"baseOptions");this.baseOptions=e;let{token:n,settings:s={}}=e,i=t??R({token:n,baseUrl:s.apiUrl||p,debug:s.debug});this.events=new y(i,s),this.orders=new C(i,s),this.cart=new x(i,s)}requestWithOverrides(e){let{token:t,settings:n={}}=this.baseOptions,s=(i,g={})=>R({token:e.token??t,baseUrl:e.baseUrl??n.apiUrl??p,debug:n.debug})(i,{...g,headers:{...e.headers||{},...g.headers||{}}});return new r({token:e.token??t,settings:{...n,apiUrl:e.baseUrl??n.apiUrl}},s)}};function F(r){return new l(r)}0&&(module.exports={CohostClient,createCohostClient});
1
+ "use strict";var m=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var z=Object.prototype.hasOwnProperty;var B=(r,e,t)=>e in r?m(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var V=(r,e)=>{for(var t in e)m(r,t,{get:e[t],enumerable:!0})},L=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of D(e))!z.call(r,s)&&s!==t&&m(r,s,{get:()=>e[s],enumerable:!(n=U(e,s))||n.enumerable});return r};var M=r=>L(m({},"__esModule",{value:!0}),r);var o=(r,e,t)=>B(r,typeof e!="symbol"?e+"":e,t);var G={};V(G,{CohostClient:()=>l,createCohostClient:()=>F});module.exports=M(G);var u=class{constructor(e,t){o(this,"request");o(this,"settings");this.request=e,this.settings=t}};var p="https://api.cohost.com/v1";var f=class r extends Error{constructor(t,n){super(t);o(this,"errorCode");o(this,"statusCode");this.name="CohostError",this.errorCode=n?.errorCode,this.statusCode=n?.statusCode}static fromError(t,n){return new r(t.message,{...n,errorCode:n?.errorCode||t.name})}};var q={baseUrl:"https://api.cohost.vip",headers:{"Content-Type":"application/json"}},v={};var A=(r,e)=>{let{pagination:t,...n}=r;return{query:n,pagination:t,...e}},_=r=>{if(!r)return"";let e=new URLSearchParams;for(let[t,n]of Object.entries(r))n!==void 0&&(Array.isArray(n)?n.forEach(s=>e.append(t,String(s))):e.set(t,String(n)));return e.toString()?`?${e.toString()}`:""},R=({token:r,baseUrl:e=p,debug:t=!1})=>async function(n,s={}){let{method:i="GET",data:g,query:k,pagination:T,headers:E={}}=s,$={...k,...T},w=_($),h=`${v.baseUrl??e}${n}${w}`,b={...q.headers,...v.headers,...E};r&&(b.Authorization=`Bearer ${r}`);let O=g&&i!=="GET"?JSON.stringify(g):void 0;if(t){console.log(`[Cohost SDK] Request: ${i} ${h}`),O&&console.log("[Cohost SDK] Body:",O);let c={};for(let[S,I]of Object.entries(b))if(S.toLowerCase()==="authorization"){let P=I?.split(" ")[1];c[S]="Bearer <token-"+(P?`${P[0]}...${P.slice(-4)}>`:"")}else c[S]=I;console.log("[Cohost SDK] Headers:",c)}let d=await fetch(h,{method:i,headers:b,body:O}),a=d.headers.get("content-type")?.includes("application/json")?await d.json():await d.text();if(!d.ok){let c=typeof a=="string"?a:JSON.stringify(a);throw console.error(`[Cohost SDK] Error(${d.status}): ${c}`,{url:h}),new f(c||d.statusText,{errorCode:d.statusText||"API_ERROR",statusCode:d.status})}return typeof a=="object"&&a!==null&&a.status==="ok"&&"data"in a?a.data:a};var y=class extends u{async list(){return this.request("/events")}async fetch(e){return this.request(`/events/${e}`)}async tickets(e){return this.request(`/events/${e}/tickets`)}async attendees(e,t){return this.request(`/events/${e}/attendees`,A(t))}};var C=class extends u{async fetch(e,t){return this.request(`/orders/${e}?uid=${t}`)}async attendees(e,t){return this.request(`/orders/${e}/attendees?uid=${t}`)}async list(e){let t=new URLSearchParams(e).toString();return this.request(`/orders${t?`?${t}`:""}`)}};var x=class extends u{async start(e){return this.request("/cart/sessions",{method:"POST",data:e})}async get(e){return this.request(`/cart/sessions/${e}`)}async update(e,t){return this.request(`/cart/sessions/${e}`,{method:"PATCH",data:t})}async cancel(e){return this.request(`/cart/sessions/${e}`,{method:"DELETE"})}async updateItem(e,t){return this.request(`/cart/sessions/${e}/item`,{method:"POST",data:t})}async preValidate(e,t){return this.request(`/cart/sessions/${e}/payment/pre-validate`,{method:"POST",data:t})}async processPayment(e,t){return this.request(`/cart/sessions/${e}/payment/process`,{method:"POST",data:t})}async placeOrder(e,t){return this.request(`/cart/sessions/${e}/place-order`,{method:"POST",data:t})}async deleteItem(e,t){return this.updateItem(e,{itemId:t,quantity:0})}async joinTableCommitment(e,t){return this.request(`/cart/sessions/${e}/join-table`,{method:"POST",data:{tableCommitmentId:t}})}async applyCoupon(e,t){return this.request(`/cart/sessions/${e}/coupons`,{method:"POST",data:{code:t}})}async deleteCoupon(e,t){return this.request(`/cart/sessions/${e}/coupons/${t}`,{method:"DELETE"})}};var l=class r{constructor(e,t){o(this,"events");o(this,"orders");o(this,"cart");o(this,"baseOptions");this.baseOptions=e;let{token:n,settings:s={}}=e,i=t??R({token:n,baseUrl:s.apiUrl||p,debug:s.debug});this.events=new y(i,s),this.orders=new C(i,s),this.cart=new x(i,s)}requestWithOverrides(e){let{token:t,settings:n={}}=this.baseOptions,s=(i,g={})=>R({token:e.token??t,baseUrl:e.baseUrl??n.apiUrl??p,debug:n.debug})(i,{...g,headers:{...e.headers||{},...g.headers||{}}});return new r({token:e.token??t,settings:{...n,apiUrl:e.baseUrl??n.apiUrl}},s)}};function F(r){return new l(r)}0&&(module.exports={CohostClient,createCohostClient});
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- var w=Object.defineProperty;var U=(r,e,t)=>e in r?w(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var o=(r,e,t)=>U(r,typeof e!="symbol"?e+"":e,t);var d=class{constructor(e,t){o(this,"request");o(this,"settings");this.request=e,this.settings=t}};var p="https://api.cohost.com/v1";var l=class r extends Error{constructor(t,n){super(t);o(this,"errorCode");o(this,"statusCode");this.name="CohostError",this.errorCode=n?.errorCode,this.statusCode=n?.statusCode}static fromError(t,n){return new r(t.message,{...n,errorCode:n?.errorCode||t.name})}};var q={baseUrl:"https://api.cohost.vip",headers:{"Content-Type":"application/json"}},P={};var I=(r,e)=>{let{pagination:t,...n}=r;return{query:n,pagination:t,...e}},D=r=>{if(!r)return"";let e=new URLSearchParams;for(let[t,n]of Object.entries(r))n!==void 0&&(Array.isArray(n)?n.forEach(s=>e.append(t,String(s))):e.set(t,String(n)));return e.toString()?`?${e.toString()}`:""},v=({token:r,baseUrl:e=p,debug:t=!1})=>async function(n,s={}){let{method:i="GET",data:g,query:k,pagination:A,headers:T={}}=s,E={...k,...A},$=D(E),x=`${P.baseUrl??e}${n}${$}`,h={...q.headers,...P.headers,...T};r&&(h.Authorization=`Bearer ${r}`);let b=g&&i!=="GET"?JSON.stringify(g):void 0;if(t){console.log(`[Cohost SDK] Request: ${i} ${x}`),b&&console.log("[Cohost SDK] Body:",b);let c={};for(let[O,R]of Object.entries(h))if(O.toLowerCase()==="authorization"){let S=R?.split(" ")[1];c[O]="Bearer <token-"+(S?`${S[0]}...${S.slice(-4)}>`:"")}else c[O]=R;console.log("[Cohost SDK] Headers:",c)}let u=await fetch(x,{method:i,headers:h,body:b}),a=u.headers.get("content-type")?.includes("application/json")?await u.json():await u.text();if(!u.ok){let c=typeof a=="string"?a:JSON.stringify(a);throw console.error(`[Cohost SDK] Error(${u.status}): ${c}`,{url:x}),new l(c||u.statusText,{errorCode:u.statusText||"API_ERROR",statusCode:u.status})}return typeof a=="object"&&a!==null&&a.status==="ok"&&"data"in a?a.data:a};var m=class extends d{async list(){return this.request("/events")}async fetch(e){return this.request(`/events/${e}`)}async tickets(e){return this.request(`/events/${e}/tickets`)}async attendees(e,t){return this.request(`/events/${e}/attendees`,I(t))}};var f=class extends d{async fetch(e,t){return this.request(`/orders/${e}?uid=${t}`)}async attendees(e,t){return this.request(`/orders/${e}/attendees?uid=${t}`)}async list(e){let t=new URLSearchParams(e).toString();return this.request(`/orders${t?`?${t}`:""}`)}};var y=class extends d{async start(e){return this.request("/cart/sessions",{method:"POST",data:e})}async get(e){return this.request(`/cart/sessions/${e}`)}async update(e,t){return this.request(`/cart/sessions/${e}`,{method:"PATCH",data:t})}async cancel(e){return this.request(`/cart/sessions/${e}`,{method:"DELETE"})}async updateItem(e,t){return this.request(`/cart/sessions/${e}/item`,{method:"POST",data:t})}async preValidate(e,t){return this.request(`/cart/sessions/${e}/payment/pre-validate`,{method:"POST",data:t})}async processPayment(e,t){return this.request(`/cart/sessions/${e}/payment/process`,{method:"POST",data:t})}async placeOrder(e,t){return this.request(`/cart/sessions/${e}/place-order`,{method:"POST",data:t})}async deleteItem(e,t){return this.updateItem(e,{itemId:t,quantity:0})}async joinTableCommitment(e,t){return this.request(`/cart/sessions/${e}/join-table`,{method:"POST",data:{tableCommitmentId:t}})}async applyCoupon(e,t){return this.request(`/cart/sessions/${e}/coupons`,{method:"POST",data:{code:t}})}async deleteCoupon(e,t){return this.request(`/cart/sessions/${e}/coupons/${t}`,{method:"DELETE"})}};var C=class r{constructor(e,t){o(this,"events");o(this,"orders");o(this,"cart");o(this,"baseOptions");this.baseOptions=e;let{token:n,settings:s={}}=e,i=t??v({token:n,baseUrl:s.apiUrl||p,debug:s.debug});this.events=new m(i,s),this.orders=new f(i,s),this.cart=new y(i,s)}requestWithOverrides(e){let{token:t,settings:n={}}=this.baseOptions,s=(i,g={})=>v({token:e.token??t,baseUrl:e.baseUrl??n.apiUrl??p,debug:n.debug})(i,{...g,headers:{...e.headers||{},...g.headers||{}}});return new r({token:e.token??t,settings:{...n,apiUrl:e.baseUrl??n.apiUrl}},s)}};function pe(r){return new C(r)}export{C as CohostClient,pe as createCohostClient};
1
+ var w=Object.defineProperty;var U=(r,e,t)=>e in r?w(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var o=(r,e,t)=>U(r,typeof e!="symbol"?e+"":e,t);var u=class{constructor(e,t){o(this,"request");o(this,"settings");this.request=e,this.settings=t}};var p="https://api.cohost.com/v1";var l=class r extends Error{constructor(t,n){super(t);o(this,"errorCode");o(this,"statusCode");this.name="CohostError",this.errorCode=n?.errorCode,this.statusCode=n?.statusCode}static fromError(t,n){return new r(t.message,{...n,errorCode:n?.errorCode||t.name})}};var I={baseUrl:"https://api.cohost.vip",headers:{"Content-Type":"application/json"}},P={};var q=(r,e)=>{let{pagination:t,...n}=r;return{query:n,pagination:t,...e}},D=r=>{if(!r)return"";let e=new URLSearchParams;for(let[t,n]of Object.entries(r))n!==void 0&&(Array.isArray(n)?n.forEach(s=>e.append(t,String(s))):e.set(t,String(n)));return e.toString()?`?${e.toString()}`:""},v=({token:r,baseUrl:e=p,debug:t=!1})=>async function(n,s={}){let{method:i="GET",data:g,query:A,pagination:k,headers:T={}}=s,E={...A,...k},$=D(E),x=`${P.baseUrl??e}${n}${$}`,h={...I.headers,...P.headers,...T};r&&(h.Authorization=`Bearer ${r}`);let b=g&&i!=="GET"?JSON.stringify(g):void 0;if(t){console.log(`[Cohost SDK] Request: ${i} ${x}`),b&&console.log("[Cohost SDK] Body:",b);let c={};for(let[O,R]of Object.entries(h))if(O.toLowerCase()==="authorization"){let S=R?.split(" ")[1];c[O]="Bearer <token-"+(S?`${S[0]}...${S.slice(-4)}>`:"")}else c[O]=R;console.log("[Cohost SDK] Headers:",c)}let d=await fetch(x,{method:i,headers:h,body:b}),a=d.headers.get("content-type")?.includes("application/json")?await d.json():await d.text();if(!d.ok){let c=typeof a=="string"?a:JSON.stringify(a);throw console.error(`[Cohost SDK] Error(${d.status}): ${c}`,{url:x}),new l(c||d.statusText,{errorCode:d.statusText||"API_ERROR",statusCode:d.status})}return typeof a=="object"&&a!==null&&a.status==="ok"&&"data"in a?a.data:a};var m=class extends u{async list(){return this.request("/events")}async fetch(e){return this.request(`/events/${e}`)}async tickets(e){return this.request(`/events/${e}/tickets`)}async attendees(e,t){return this.request(`/events/${e}/attendees`,q(t))}};var f=class extends u{async fetch(e,t){return this.request(`/orders/${e}?uid=${t}`)}async attendees(e,t){return this.request(`/orders/${e}/attendees?uid=${t}`)}async list(e){let t=new URLSearchParams(e).toString();return this.request(`/orders${t?`?${t}`:""}`)}};var y=class extends u{async start(e){return this.request("/cart/sessions",{method:"POST",data:e})}async get(e){return this.request(`/cart/sessions/${e}`)}async update(e,t){return this.request(`/cart/sessions/${e}`,{method:"PATCH",data:t})}async cancel(e){return this.request(`/cart/sessions/${e}`,{method:"DELETE"})}async updateItem(e,t){return this.request(`/cart/sessions/${e}/item`,{method:"POST",data:t})}async preValidate(e,t){return this.request(`/cart/sessions/${e}/payment/pre-validate`,{method:"POST",data:t})}async processPayment(e,t){return this.request(`/cart/sessions/${e}/payment/process`,{method:"POST",data:t})}async placeOrder(e,t){return this.request(`/cart/sessions/${e}/place-order`,{method:"POST",data:t})}async deleteItem(e,t){return this.updateItem(e,{itemId:t,quantity:0})}async joinTableCommitment(e,t){return this.request(`/cart/sessions/${e}/join-table`,{method:"POST",data:{tableCommitmentId:t}})}async applyCoupon(e,t){return this.request(`/cart/sessions/${e}/coupons`,{method:"POST",data:{code:t}})}async deleteCoupon(e,t){return this.request(`/cart/sessions/${e}/coupons/${t}`,{method:"DELETE"})}};var C=class r{constructor(e,t){o(this,"events");o(this,"orders");o(this,"cart");o(this,"baseOptions");this.baseOptions=e;let{token:n,settings:s={}}=e,i=t??v({token:n,baseUrl:s.apiUrl||p,debug:s.debug});this.events=new m(i,s),this.orders=new f(i,s),this.cart=new y(i,s)}requestWithOverrides(e){let{token:t,settings:n={}}=this.baseOptions,s=(i,g={})=>v({token:e.token??t,baseUrl:e.baseUrl??n.apiUrl??p,debug:n.debug})(i,{...g,headers:{...e.headers||{},...g.headers||{}}});return new r({token:e.token??t,settings:{...n,apiUrl:e.baseUrl??n.apiUrl}},s)}};function pe(r){return new C(r)}export{C as CohostClient,pe as createCohostClient};
2
2
  //# sourceMappingURL=index.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cohostvip/cohost-node",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "description": "Cohost API wrapper",
5
5
  "main": "dist/index.mjs",
6
6
  "module": "dist/index.mjs",