@basedone/core 0.2.0 → 0.2.2

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.
@@ -717,6 +717,224 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
717
717
  async trackBanner(bannerId, request) {
718
718
  return this.post(`/api/marketplace/banners/${bannerId}/track`, request);
719
719
  }
720
+ // ============================================================================
721
+ // Messages API
722
+ // ============================================================================
723
+ /**
724
+ * List messages for customer
725
+ *
726
+ * Returns all conversations grouped by order, where each order represents
727
+ * a conversation with a merchant.
728
+ *
729
+ * @returns List of conversations with messages and stats
730
+ *
731
+ * @example
732
+ * ```typescript
733
+ * const result = await client.listMessages();
734
+ * console.log("Unread:", result.stats.unread);
735
+ * result.conversations.forEach(conv => {
736
+ * console.log(`Order ${conv.orderNumber}: ${conv.unreadCount} unread`);
737
+ * });
738
+ * ```
739
+ */
740
+ async listMessages() {
741
+ return this.get("/api/marketplace/messages");
742
+ }
743
+ /**
744
+ * Get message stats (unread count)
745
+ *
746
+ * Lightweight endpoint for notification badges.
747
+ *
748
+ * @returns Unread message count
749
+ *
750
+ * @example
751
+ * ```typescript
752
+ * const stats = await client.getMessageStats();
753
+ * console.log("Unread messages:", stats.unread);
754
+ * ```
755
+ */
756
+ async getMessageStats() {
757
+ return this.get("/api/marketplace/messages/stats");
758
+ }
759
+ /**
760
+ * Send a message to a merchant about an order
761
+ *
762
+ * @param request - Message data including orderId, recipientId (merchant user ID), and message
763
+ * @returns Sent message
764
+ *
765
+ * @example
766
+ * ```typescript
767
+ * await client.sendMessage({
768
+ * orderId: "ord_123",
769
+ * recipientId: "user_merchant_456",
770
+ * message: "When will my order ship?"
771
+ * });
772
+ * ```
773
+ */
774
+ async sendMessage(request) {
775
+ return this.post("/api/marketplace/messages/send", request);
776
+ }
777
+ /**
778
+ * Mark a message as read
779
+ *
780
+ * @param messageId - Message ID
781
+ * @returns Updated message
782
+ *
783
+ * @example
784
+ * ```typescript
785
+ * await client.markMessageAsRead("msg_123");
786
+ * ```
787
+ */
788
+ async markMessageAsRead(messageId) {
789
+ return this.patch(`/api/marketplace/messages/${messageId}/read`, {});
790
+ }
791
+ // ============================================================================
792
+ // Flash Sales API
793
+ // ============================================================================
794
+ /**
795
+ * Get active flash sales
796
+ *
797
+ * Returns currently running flash sales with their discounted products.
798
+ * Includes countdown timer information for UI display.
799
+ *
800
+ * @param params - Query parameters
801
+ * @returns List of active flash sales with time remaining
802
+ *
803
+ * @example
804
+ * ```typescript
805
+ * const result = await client.getActiveFlashSales({ limit: 5 });
806
+ *
807
+ * result.flashSales.forEach(sale => {
808
+ * console.log(`${sale.name} - ends at ${sale.endsAt}`);
809
+ * sale.items.forEach(item => {
810
+ * console.log(` ${item.product.title}: $${item.salePrice} (${item.discountPercent}% off)`);
811
+ * });
812
+ * });
813
+ *
814
+ * // Use timeRemaining for countdown UI
815
+ * if (result.timeRemaining) {
816
+ * console.log(`Featured sale ends in ${result.timeRemaining.remainingSeconds} seconds`);
817
+ * }
818
+ * ```
819
+ */
820
+ async getActiveFlashSales(params) {
821
+ const queryString = params ? buildQueryString(params) : "";
822
+ return this.get(`/api/marketplace/flash-sales/active${queryString}`);
823
+ }
824
+ // ============================================================================
825
+ // Merchant Storefront API
826
+ // ============================================================================
827
+ /**
828
+ * Get public merchant profile
829
+ *
830
+ * Fetches public information about a merchant for the storefront page.
831
+ *
832
+ * @param merchantId - Merchant ID
833
+ * @returns Public merchant profile with stats
834
+ *
835
+ * @example
836
+ * ```typescript
837
+ * const result = await client.getMerchantProfile("merchant_123");
838
+ * console.log(result.merchant.name, result.merchant.productCount);
839
+ * ```
840
+ */
841
+ async getMerchantProfile(merchantId) {
842
+ return this.get(`/api/marketplace/merchants/${merchantId}`);
843
+ }
844
+ /**
845
+ * List merchant products
846
+ *
847
+ * Fetches products for a specific merchant with search, filter, and sort options.
848
+ *
849
+ * @param merchantId - Merchant ID
850
+ * @param params - Query parameters for filtering and pagination
851
+ * @returns Paginated list of products
852
+ *
853
+ * @example
854
+ * ```typescript
855
+ * const result = await client.getMerchantProducts("merchant_123", {
856
+ * search: "laptop",
857
+ * sortBy: "popular",
858
+ * limit: 20,
859
+ * });
860
+ *
861
+ * result.items.forEach(product => {
862
+ * console.log(product.title, product.priceUSDC);
863
+ * });
864
+ * ```
865
+ */
866
+ async getMerchantProducts(merchantId, params) {
867
+ const queryString = params ? buildQueryString(params) : "";
868
+ return this.get(`/api/marketplace/merchants/${merchantId}/products${queryString}`);
869
+ }
870
+ // ============================================================================
871
+ // Shop Following API
872
+ // ============================================================================
873
+ /**
874
+ * Check if following a merchant
875
+ *
876
+ * @param merchantId - Merchant ID
877
+ * @returns Follow status with follow date if applicable
878
+ *
879
+ * @example
880
+ * ```typescript
881
+ * const status = await client.isFollowingMerchant("merchant_123");
882
+ * if (status.isFollowing) {
883
+ * console.log(`Following since ${status.followedAt}`);
884
+ * }
885
+ * ```
886
+ */
887
+ async isFollowingMerchant(merchantId) {
888
+ return this.get(`/api/marketplace/merchants/${merchantId}/follow`);
889
+ }
890
+ /**
891
+ * Follow a merchant
892
+ *
893
+ * @param merchantId - Merchant ID to follow
894
+ * @returns Follow action result
895
+ *
896
+ * @example
897
+ * ```typescript
898
+ * const result = await client.followMerchant("merchant_123");
899
+ * console.log(result.message); // "Now following Awesome Store"
900
+ * ```
901
+ */
902
+ async followMerchant(merchantId) {
903
+ return this.post(`/api/marketplace/merchants/${merchantId}/follow`);
904
+ }
905
+ /**
906
+ * Unfollow a merchant
907
+ *
908
+ * @param merchantId - Merchant ID to unfollow
909
+ * @returns Unfollow action result
910
+ *
911
+ * @example
912
+ * ```typescript
913
+ * const result = await client.unfollowMerchant("merchant_123");
914
+ * console.log(result.message); // "Unfollowed successfully"
915
+ * ```
916
+ */
917
+ async unfollowMerchant(merchantId) {
918
+ return this.delete(`/api/marketplace/merchants/${merchantId}/follow`);
919
+ }
920
+ /**
921
+ * Get list of followed merchants
922
+ *
923
+ * @param params - Query parameters for pagination and sorting
924
+ * @returns Paginated list of followed merchants with their info
925
+ *
926
+ * @example
927
+ * ```typescript
928
+ * const result = await client.getFollowedMerchants({ limit: 20, sortBy: "recent" });
929
+ * result.items.forEach(item => {
930
+ * console.log(`${item.merchant.name} - followed on ${item.followedAt}`);
931
+ * });
932
+ * ```
933
+ */
934
+ async getFollowedMerchants(params) {
935
+ const queryString = params ? buildQueryString(params) : "";
936
+ return this.get(`/api/marketplace/following${queryString}`);
937
+ }
720
938
  };
721
939
 
722
940
  // lib/ecommerce/client/merchant.ts