@lobehub/market-sdk 0.23.8 → 0.23.9-beta.1

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.mjs CHANGED
@@ -1380,7 +1380,7 @@ var MarketAdmin = class extends BaseSDK {
1380
1380
  };
1381
1381
 
1382
1382
  // src/market/market-sdk.ts
1383
- import debug14 from "debug";
1383
+ import debug17 from "debug";
1384
1384
 
1385
1385
  // src/market/services/AgentService.ts
1386
1386
  import debug9 from "debug";
@@ -2425,8 +2425,515 @@ var UserService = class extends BaseSDK {
2425
2425
  }
2426
2426
  };
2427
2427
 
2428
+ // src/market/services/UserFollowService.ts
2429
+ import debug14 from "debug";
2430
+ var log14 = debug14("lobe-market-sdk:user-follow");
2431
+ var UserFollowService = class extends BaseSDK {
2432
+ /**
2433
+ * Follow a user
2434
+ *
2435
+ * Creates a follow relationship where the authenticated user follows the target user.
2436
+ * Requires authentication.
2437
+ *
2438
+ * @param followingId - The ID of the user to follow
2439
+ * @param options - Optional request options
2440
+ * @returns Promise resolving to success response
2441
+ * @throws Error if already following or cannot follow yourself
2442
+ */
2443
+ async follow(followingId, options) {
2444
+ log14("Following user: %d", followingId);
2445
+ const body = { followingId };
2446
+ const result = await this.request("/v1/user/follows", {
2447
+ body: JSON.stringify(body),
2448
+ headers: {
2449
+ "Content-Type": "application/json"
2450
+ },
2451
+ method: "POST",
2452
+ ...options
2453
+ });
2454
+ log14("Successfully followed user: %d", followingId);
2455
+ return result;
2456
+ }
2457
+ /**
2458
+ * Unfollow a user
2459
+ *
2460
+ * Removes the follow relationship where the authenticated user unfollows the target user.
2461
+ * Requires authentication.
2462
+ *
2463
+ * @param followingId - The ID of the user to unfollow
2464
+ * @param options - Optional request options
2465
+ * @returns Promise resolving to success response
2466
+ * @throws Error if follow relationship not found
2467
+ */
2468
+ async unfollow(followingId, options) {
2469
+ log14("Unfollowing user: %d", followingId);
2470
+ const body = { followingId };
2471
+ const result = await this.request("/v1/user/follows", {
2472
+ body: JSON.stringify(body),
2473
+ headers: {
2474
+ "Content-Type": "application/json"
2475
+ },
2476
+ method: "DELETE",
2477
+ ...options
2478
+ });
2479
+ log14("Successfully unfollowed user: %d", followingId);
2480
+ return result;
2481
+ }
2482
+ /**
2483
+ * Check follow status
2484
+ *
2485
+ * Checks if the authenticated user is following the target user and if they follow each other.
2486
+ * Requires authentication.
2487
+ *
2488
+ * @param targetUserId - The ID of the user to check
2489
+ * @param options - Optional request options
2490
+ * @returns Promise resolving to follow status (isFollowing, isMutual)
2491
+ */
2492
+ async checkFollowStatus(targetUserId, options) {
2493
+ log14("Checking follow status for user: %d", targetUserId);
2494
+ const queryString = this.buildQueryString({ targetUserId: String(targetUserId) });
2495
+ const result = await this.request(
2496
+ `/v1/user/follows/check${queryString}`,
2497
+ options
2498
+ );
2499
+ log14("Follow status retrieved: %O", result);
2500
+ return result;
2501
+ }
2502
+ /**
2503
+ * Get following list
2504
+ *
2505
+ * Retrieves the list of users that a user is following.
2506
+ * This is a public endpoint - no authentication required.
2507
+ *
2508
+ * @param userId - The ID of the user whose following list to retrieve
2509
+ * @param params - Pagination parameters
2510
+ * @param options - Optional request options
2511
+ * @returns Promise resolving to list of following users
2512
+ */
2513
+ async getFollowing(userId, params = {}, options) {
2514
+ log14("Getting following list for user: %d", userId);
2515
+ const queryParams = {};
2516
+ if (params.limit !== void 0) queryParams.limit = String(params.limit);
2517
+ if (params.offset !== void 0) queryParams.offset = String(params.offset);
2518
+ const queryString = this.buildQueryString(queryParams);
2519
+ const result = await this.request(
2520
+ `/v1/user/follows/${userId}/following${queryString}`,
2521
+ options
2522
+ );
2523
+ log14("Following list retrieved for user: %d", userId);
2524
+ return result;
2525
+ }
2526
+ /**
2527
+ * Get followers list
2528
+ *
2529
+ * Retrieves the list of users who follow a user.
2530
+ * This is a public endpoint - no authentication required.
2531
+ *
2532
+ * @param userId - The ID of the user whose followers list to retrieve
2533
+ * @param params - Pagination parameters
2534
+ * @param options - Optional request options
2535
+ * @returns Promise resolving to list of followers
2536
+ */
2537
+ async getFollowers(userId, params = {}, options) {
2538
+ log14("Getting followers list for user: %d", userId);
2539
+ const queryParams = {};
2540
+ if (params.limit !== void 0) queryParams.limit = String(params.limit);
2541
+ if (params.offset !== void 0) queryParams.offset = String(params.offset);
2542
+ const queryString = this.buildQueryString(queryParams);
2543
+ const result = await this.request(
2544
+ `/v1/user/follows/${userId}/followers${queryString}`,
2545
+ options
2546
+ );
2547
+ log14("Followers list retrieved for user: %d", userId);
2548
+ return result;
2549
+ }
2550
+ };
2551
+
2552
+ // src/market/services/UserFavoriteService.ts
2553
+ import debug15 from "debug";
2554
+ var log15 = debug15("lobe-market-sdk:user-favorite");
2555
+ var UserFavoriteService = class extends BaseSDK {
2556
+ /**
2557
+ * Add to favorites
2558
+ *
2559
+ * Adds an agent or plugin to the authenticated user's favorites.
2560
+ * Requires authentication.
2561
+ *
2562
+ * @param targetType - The type of target ('agent' or 'plugin')
2563
+ * @param targetId - The ID of the target agent/plugin
2564
+ * @param options - Optional request options
2565
+ * @returns Promise resolving to success response
2566
+ * @throws Error if already in favorites
2567
+ */
2568
+ async addFavorite(targetType, targetId, options) {
2569
+ log15("Adding favorite: %s %d", targetType, targetId);
2570
+ const body = { targetId, targetType };
2571
+ const result = await this.request("/v1/user/favorites", {
2572
+ body: JSON.stringify(body),
2573
+ headers: {
2574
+ "Content-Type": "application/json"
2575
+ },
2576
+ method: "POST",
2577
+ ...options
2578
+ });
2579
+ log15("Successfully added favorite: %s %d", targetType, targetId);
2580
+ return result;
2581
+ }
2582
+ /**
2583
+ * Remove from favorites
2584
+ *
2585
+ * Removes an agent or plugin from the authenticated user's favorites.
2586
+ * Requires authentication.
2587
+ *
2588
+ * @param targetType - The type of target ('agent' or 'plugin')
2589
+ * @param targetId - The ID of the target agent/plugin
2590
+ * @param options - Optional request options
2591
+ * @returns Promise resolving to success response
2592
+ * @throws Error if favorite not found
2593
+ */
2594
+ async removeFavorite(targetType, targetId, options) {
2595
+ log15("Removing favorite: %s %d", targetType, targetId);
2596
+ const body = { targetId, targetType };
2597
+ const result = await this.request("/v1/user/favorites", {
2598
+ body: JSON.stringify(body),
2599
+ headers: {
2600
+ "Content-Type": "application/json"
2601
+ },
2602
+ method: "DELETE",
2603
+ ...options
2604
+ });
2605
+ log15("Successfully removed favorite: %s %d", targetType, targetId);
2606
+ return result;
2607
+ }
2608
+ /**
2609
+ * Check favorite status
2610
+ *
2611
+ * Checks if the authenticated user has favorited a specific agent or plugin.
2612
+ * Requires authentication.
2613
+ *
2614
+ * @param targetType - The type of target ('agent' or 'plugin')
2615
+ * @param targetId - The ID of the target agent/plugin
2616
+ * @param options - Optional request options
2617
+ * @returns Promise resolving to favorite status
2618
+ */
2619
+ async checkFavorite(targetType, targetId, options) {
2620
+ log15("Checking favorite status: %s %d", targetType, targetId);
2621
+ const queryString = this.buildQueryString({
2622
+ targetId: String(targetId),
2623
+ targetType
2624
+ });
2625
+ const result = await this.request(
2626
+ `/v1/user/favorites/check${queryString}`,
2627
+ options
2628
+ );
2629
+ log15("Favorite status retrieved: %O", result);
2630
+ return result;
2631
+ }
2632
+ /**
2633
+ * Get my favorites
2634
+ *
2635
+ * Retrieves the authenticated user's favorites.
2636
+ * Requires authentication.
2637
+ *
2638
+ * @param params - Query parameters for filtering and pagination
2639
+ * @param options - Optional request options
2640
+ * @returns Promise resolving to list of favorites
2641
+ */
2642
+ async getMyFavorites(params = {}, options) {
2643
+ log15("Getting my favorites: %O", params);
2644
+ const queryParams = {};
2645
+ if (params.limit !== void 0) queryParams.limit = String(params.limit);
2646
+ if (params.offset !== void 0) queryParams.offset = String(params.offset);
2647
+ if (params.type !== void 0) queryParams.type = params.type;
2648
+ const queryString = this.buildQueryString(queryParams);
2649
+ const result = await this.request(
2650
+ `/v1/user/favorites/me${queryString}`,
2651
+ options
2652
+ );
2653
+ log15("My favorites retrieved");
2654
+ return result;
2655
+ }
2656
+ /**
2657
+ * Get user's favorites
2658
+ *
2659
+ * Retrieves a user's favorites.
2660
+ * This is a public endpoint - no authentication required.
2661
+ *
2662
+ * @param userId - The ID of the user whose favorites to retrieve
2663
+ * @param params - Query parameters for filtering and pagination
2664
+ * @param options - Optional request options
2665
+ * @returns Promise resolving to list of favorites
2666
+ */
2667
+ async getUserFavorites(userId, params = {}, options) {
2668
+ log15("Getting favorites for user: %d", userId);
2669
+ const queryParams = {};
2670
+ if (params.limit !== void 0) queryParams.limit = String(params.limit);
2671
+ if (params.offset !== void 0) queryParams.offset = String(params.offset);
2672
+ if (params.type !== void 0) queryParams.type = params.type;
2673
+ const queryString = this.buildQueryString(queryParams);
2674
+ const result = await this.request(
2675
+ `/v1/user/favorites/${userId}${queryString}`,
2676
+ options
2677
+ );
2678
+ log15("Favorites retrieved for user: %d", userId);
2679
+ return result;
2680
+ }
2681
+ /**
2682
+ * Get user's favorite agents with details
2683
+ *
2684
+ * Retrieves a user's favorite agents with full details.
2685
+ * This is a public endpoint - no authentication required.
2686
+ *
2687
+ * @param userId - The ID of the user whose favorite agents to retrieve
2688
+ * @param params - Pagination parameters
2689
+ * @param options - Optional request options
2690
+ * @returns Promise resolving to list of favorite agents
2691
+ */
2692
+ async getUserFavoriteAgents(userId, params = {}, options) {
2693
+ log15("Getting favorite agents for user: %d", userId);
2694
+ const queryParams = {};
2695
+ if (params.limit !== void 0) queryParams.limit = String(params.limit);
2696
+ if (params.offset !== void 0) queryParams.offset = String(params.offset);
2697
+ const queryString = this.buildQueryString(queryParams);
2698
+ const result = await this.request(
2699
+ `/v1/user/favorites/${userId}/agents${queryString}`,
2700
+ options
2701
+ );
2702
+ log15("Favorite agents retrieved for user: %d", userId);
2703
+ return result;
2704
+ }
2705
+ /**
2706
+ * Get user's favorite plugins with details
2707
+ *
2708
+ * Retrieves a user's favorite plugins with full details.
2709
+ * This is a public endpoint - no authentication required.
2710
+ *
2711
+ * @param userId - The ID of the user whose favorite plugins to retrieve
2712
+ * @param params - Pagination parameters
2713
+ * @param options - Optional request options
2714
+ * @returns Promise resolving to list of favorite plugins
2715
+ */
2716
+ async getUserFavoritePlugins(userId, params = {}, options) {
2717
+ log15("Getting favorite plugins for user: %d", userId);
2718
+ const queryParams = {};
2719
+ if (params.limit !== void 0) queryParams.limit = String(params.limit);
2720
+ if (params.offset !== void 0) queryParams.offset = String(params.offset);
2721
+ const queryString = this.buildQueryString(queryParams);
2722
+ const result = await this.request(
2723
+ `/v1/user/favorites/${userId}/plugins${queryString}`,
2724
+ options
2725
+ );
2726
+ log15("Favorite plugins retrieved for user: %d", userId);
2727
+ return result;
2728
+ }
2729
+ };
2730
+
2731
+ // src/market/services/UserLikeService.ts
2732
+ import debug16 from "debug";
2733
+ var log16 = debug16("lobe-market-sdk:user-like");
2734
+ var UserLikeService = class extends BaseSDK {
2735
+ /**
2736
+ * Like content
2737
+ *
2738
+ * Likes an agent or plugin for the authenticated user.
2739
+ * Requires authentication.
2740
+ *
2741
+ * @param targetType - The type of target ('agent' or 'plugin')
2742
+ * @param targetId - The ID of the target agent/plugin
2743
+ * @param options - Optional request options
2744
+ * @returns Promise resolving to success response
2745
+ * @throws Error if already liked
2746
+ */
2747
+ async like(targetType, targetId, options) {
2748
+ log16("Liking: %s %d", targetType, targetId);
2749
+ const body = { targetId, targetType };
2750
+ const result = await this.request("/v1/user/likes", {
2751
+ body: JSON.stringify(body),
2752
+ headers: {
2753
+ "Content-Type": "application/json"
2754
+ },
2755
+ method: "POST",
2756
+ ...options
2757
+ });
2758
+ log16("Successfully liked: %s %d", targetType, targetId);
2759
+ return result;
2760
+ }
2761
+ /**
2762
+ * Unlike content
2763
+ *
2764
+ * Unlikes an agent or plugin for the authenticated user.
2765
+ * Requires authentication.
2766
+ *
2767
+ * @param targetType - The type of target ('agent' or 'plugin')
2768
+ * @param targetId - The ID of the target agent/plugin
2769
+ * @param options - Optional request options
2770
+ * @returns Promise resolving to success response
2771
+ * @throws Error if like not found
2772
+ */
2773
+ async unlike(targetType, targetId, options) {
2774
+ log16("Unliking: %s %d", targetType, targetId);
2775
+ const body = { targetId, targetType };
2776
+ const result = await this.request("/v1/user/likes", {
2777
+ body: JSON.stringify(body),
2778
+ headers: {
2779
+ "Content-Type": "application/json"
2780
+ },
2781
+ method: "DELETE",
2782
+ ...options
2783
+ });
2784
+ log16("Successfully unliked: %s %d", targetType, targetId);
2785
+ return result;
2786
+ }
2787
+ /**
2788
+ * Toggle like status
2789
+ *
2790
+ * Toggles the like status - likes if not liked, unlikes if already liked.
2791
+ * Requires authentication.
2792
+ *
2793
+ * @param targetType - The type of target ('agent' or 'plugin')
2794
+ * @param targetId - The ID of the target agent/plugin
2795
+ * @param options - Optional request options
2796
+ * @returns Promise resolving to toggle response with new like status
2797
+ */
2798
+ async toggleLike(targetType, targetId, options) {
2799
+ log16("Toggling like: %s %d", targetType, targetId);
2800
+ const body = { targetId, targetType };
2801
+ const result = await this.request("/v1/user/likes/toggle", {
2802
+ body: JSON.stringify(body),
2803
+ headers: {
2804
+ "Content-Type": "application/json"
2805
+ },
2806
+ method: "POST",
2807
+ ...options
2808
+ });
2809
+ log16("Like toggled, new status: %O", result);
2810
+ return result;
2811
+ }
2812
+ /**
2813
+ * Check like status
2814
+ *
2815
+ * Checks if the authenticated user has liked a specific agent or plugin.
2816
+ * Requires authentication.
2817
+ *
2818
+ * @param targetType - The type of target ('agent' or 'plugin')
2819
+ * @param targetId - The ID of the target agent/plugin
2820
+ * @param options - Optional request options
2821
+ * @returns Promise resolving to like status
2822
+ */
2823
+ async checkLike(targetType, targetId, options) {
2824
+ log16("Checking like status: %s %d", targetType, targetId);
2825
+ const queryString = this.buildQueryString({
2826
+ targetId: String(targetId),
2827
+ targetType
2828
+ });
2829
+ const result = await this.request(
2830
+ `/v1/user/likes/check${queryString}`,
2831
+ options
2832
+ );
2833
+ log16("Like status retrieved: %O", result);
2834
+ return result;
2835
+ }
2836
+ /**
2837
+ * Get my likes
2838
+ *
2839
+ * Retrieves the authenticated user's likes.
2840
+ * Requires authentication.
2841
+ *
2842
+ * @param params - Query parameters for filtering and pagination
2843
+ * @param options - Optional request options
2844
+ * @returns Promise resolving to list of likes
2845
+ */
2846
+ async getMyLikes(params = {}, options) {
2847
+ log16("Getting my likes: %O", params);
2848
+ const queryParams = {};
2849
+ if (params.limit !== void 0) queryParams.limit = String(params.limit);
2850
+ if (params.offset !== void 0) queryParams.offset = String(params.offset);
2851
+ if (params.type !== void 0) queryParams.type = params.type;
2852
+ const queryString = this.buildQueryString(queryParams);
2853
+ const result = await this.request(
2854
+ `/v1/user/likes/me${queryString}`,
2855
+ options
2856
+ );
2857
+ log16("My likes retrieved");
2858
+ return result;
2859
+ }
2860
+ /**
2861
+ * Get user's likes
2862
+ *
2863
+ * Retrieves a user's likes.
2864
+ * This is a public endpoint - no authentication required.
2865
+ *
2866
+ * @param userId - The ID of the user whose likes to retrieve
2867
+ * @param params - Query parameters for filtering and pagination
2868
+ * @param options - Optional request options
2869
+ * @returns Promise resolving to list of likes
2870
+ */
2871
+ async getUserLikes(userId, params = {}, options) {
2872
+ log16("Getting likes for user: %d", userId);
2873
+ const queryParams = {};
2874
+ if (params.limit !== void 0) queryParams.limit = String(params.limit);
2875
+ if (params.offset !== void 0) queryParams.offset = String(params.offset);
2876
+ if (params.type !== void 0) queryParams.type = params.type;
2877
+ const queryString = this.buildQueryString(queryParams);
2878
+ const result = await this.request(
2879
+ `/v1/user/likes/${userId}${queryString}`,
2880
+ options
2881
+ );
2882
+ log16("Likes retrieved for user: %d", userId);
2883
+ return result;
2884
+ }
2885
+ /**
2886
+ * Get user's liked agents with details
2887
+ *
2888
+ * Retrieves a user's liked agents with full details.
2889
+ * This is a public endpoint - no authentication required.
2890
+ *
2891
+ * @param userId - The ID of the user whose liked agents to retrieve
2892
+ * @param params - Pagination parameters
2893
+ * @param options - Optional request options
2894
+ * @returns Promise resolving to list of liked agents
2895
+ */
2896
+ async getUserLikedAgents(userId, params = {}, options) {
2897
+ log16("Getting liked agents for user: %d", userId);
2898
+ const queryParams = {};
2899
+ if (params.limit !== void 0) queryParams.limit = String(params.limit);
2900
+ if (params.offset !== void 0) queryParams.offset = String(params.offset);
2901
+ const queryString = this.buildQueryString(queryParams);
2902
+ const result = await this.request(
2903
+ `/v1/user/likes/${userId}/agents${queryString}`,
2904
+ options
2905
+ );
2906
+ log16("Liked agents retrieved for user: %d", userId);
2907
+ return result;
2908
+ }
2909
+ /**
2910
+ * Get user's liked plugins with details
2911
+ *
2912
+ * Retrieves a user's liked plugins with full details.
2913
+ * This is a public endpoint - no authentication required.
2914
+ *
2915
+ * @param userId - The ID of the user whose liked plugins to retrieve
2916
+ * @param params - Pagination parameters
2917
+ * @param options - Optional request options
2918
+ * @returns Promise resolving to list of liked plugins
2919
+ */
2920
+ async getUserLikedPlugins(userId, params = {}, options) {
2921
+ log16("Getting liked plugins for user: %d", userId);
2922
+ const queryParams = {};
2923
+ if (params.limit !== void 0) queryParams.limit = String(params.limit);
2924
+ if (params.offset !== void 0) queryParams.offset = String(params.offset);
2925
+ const queryString = this.buildQueryString(queryParams);
2926
+ const result = await this.request(
2927
+ `/v1/user/likes/${userId}/plugins${queryString}`,
2928
+ options
2929
+ );
2930
+ log16("Liked plugins retrieved for user: %d", userId);
2931
+ return result;
2932
+ }
2933
+ };
2934
+
2428
2935
  // src/market/market-sdk.ts
2429
- var log14 = debug14("lobe-market-sdk");
2936
+ var log17 = debug17("lobe-market-sdk");
2430
2937
  var MarketSDK = class extends BaseSDK {
2431
2938
  /**
2432
2939
  * Creates a new MarketSDK instance
@@ -2439,11 +2946,14 @@ var MarketSDK = class extends BaseSDK {
2439
2946
  tokenExpiry: void 0
2440
2947
  };
2441
2948
  super(options, void 0, sharedTokenState);
2442
- log14("MarketSDK instance created");
2949
+ log17("MarketSDK instance created");
2443
2950
  this.agents = new AgentService(options, this.headers, sharedTokenState);
2444
2951
  this.auth = new AuthService(options, this.headers, sharedTokenState);
2445
2952
  this.plugins = new PluginsService(options, this.headers, sharedTokenState);
2446
2953
  this.user = new UserService(options, this.headers, sharedTokenState);
2954
+ this.follows = new UserFollowService(options, this.headers, sharedTokenState);
2955
+ this.favorites = new UserFavoriteService(options, this.headers, sharedTokenState);
2956
+ this.likes = new UserLikeService(options, this.headers, sharedTokenState);
2447
2957
  this.discovery = new DiscoveryService(options, this.headers, sharedTokenState);
2448
2958
  }
2449
2959
  /**
@@ -2470,7 +2980,7 @@ var MarketSDK = class extends BaseSDK {
2470
2980
  * @deprecated Use auth.registerClient() instead
2471
2981
  */
2472
2982
  async registerClient(request) {
2473
- log14("Registering client (deprecated method, use auth.registerClient): %s", request.clientName);
2983
+ log17("Registering client (deprecated method, use auth.registerClient): %s", request.clientName);
2474
2984
  return this.auth.registerClient(request);
2475
2985
  }
2476
2986
  };