@lobehub/market-sdk 0.24.0-beta.1 → 0.24.1-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.d.mts +549 -4
- package/dist/index.mjs +548 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -39,13 +39,18 @@ var BaseSDK = class {
|
|
|
39
39
|
if (this.initialAccessToken) {
|
|
40
40
|
this.headers.Authorization = `Bearer ${this.initialAccessToken}`;
|
|
41
41
|
}
|
|
42
|
+
if (options.trustedClientToken) {
|
|
43
|
+
this.headers["x-lobe-trust-token"] = options.trustedClientToken;
|
|
44
|
+
log("Trusted client token configured");
|
|
45
|
+
}
|
|
42
46
|
log("BaseSDK instance created: %O", {
|
|
43
47
|
baseUrl: this.baseUrl,
|
|
44
48
|
defaultLocale: this.defaultLocale,
|
|
45
49
|
hasApiKey: !!apiKey,
|
|
46
50
|
hasInitialAccessToken: !!this.initialAccessToken,
|
|
47
51
|
hasM2MCredentials: !!this.clientId,
|
|
48
|
-
hasSharedTokenState: !!this.sharedTokenState
|
|
52
|
+
hasSharedTokenState: !!this.sharedTokenState,
|
|
53
|
+
hasTrustedClientToken: !!options.trustedClientToken
|
|
49
54
|
});
|
|
50
55
|
}
|
|
51
56
|
/**
|
|
@@ -1380,7 +1385,7 @@ var MarketAdmin = class extends BaseSDK {
|
|
|
1380
1385
|
};
|
|
1381
1386
|
|
|
1382
1387
|
// src/market/market-sdk.ts
|
|
1383
|
-
import
|
|
1388
|
+
import debug17 from "debug";
|
|
1384
1389
|
|
|
1385
1390
|
// src/market/services/AgentService.ts
|
|
1386
1391
|
import debug9 from "debug";
|
|
@@ -2342,6 +2347,34 @@ var PluginsService = class extends BaseSDK {
|
|
|
2342
2347
|
async grepContent(pattern, directory, context, options) {
|
|
2343
2348
|
return this.runBuildInTool("grepContent", { directory, pattern, ...options }, context);
|
|
2344
2349
|
}
|
|
2350
|
+
/**
|
|
2351
|
+
* Export a file from the Code Interpreter sandbox to a pre-signed URL
|
|
2352
|
+
*
|
|
2353
|
+
* This method uploads a file from the sandbox to an external storage location
|
|
2354
|
+
* via a pre-signed URL (e.g., S3 pre-signed URL). The upload is performed
|
|
2355
|
+
* using Python code execution within the sandbox.
|
|
2356
|
+
*
|
|
2357
|
+
* @param path - File path in sandbox to export
|
|
2358
|
+
* @param uploadUrl - Pre-signed URL to upload the file to
|
|
2359
|
+
* @param context - User and topic context
|
|
2360
|
+
* @returns Promise resolving to export result with success status and file info
|
|
2361
|
+
*
|
|
2362
|
+
* @example
|
|
2363
|
+
* ```typescript
|
|
2364
|
+
* const result = await sdk.plugins.exportFile(
|
|
2365
|
+
* './output/result.csv',
|
|
2366
|
+
* 'https://s3.amazonaws.com/bucket/key?X-Amz-Signature=...',
|
|
2367
|
+
* { userId: 'user-123', topicId: 'topic-456' }
|
|
2368
|
+
* );
|
|
2369
|
+
*
|
|
2370
|
+
* if (result.success && result.data?.result.success) {
|
|
2371
|
+
* console.log('File exported:', result.data.result.size, 'bytes');
|
|
2372
|
+
* }
|
|
2373
|
+
* ```
|
|
2374
|
+
*/
|
|
2375
|
+
async exportFile(path, uploadUrl, context) {
|
|
2376
|
+
return this.runBuildInTool("exportFile", { path, uploadUrl }, context);
|
|
2377
|
+
}
|
|
2345
2378
|
};
|
|
2346
2379
|
|
|
2347
2380
|
// src/market/services/UserService.ts
|
|
@@ -2397,8 +2430,515 @@ var UserService = class extends BaseSDK {
|
|
|
2397
2430
|
}
|
|
2398
2431
|
};
|
|
2399
2432
|
|
|
2433
|
+
// src/market/services/UserFollowService.ts
|
|
2434
|
+
import debug14 from "debug";
|
|
2435
|
+
var log14 = debug14("lobe-market-sdk:user-follow");
|
|
2436
|
+
var UserFollowService = class extends BaseSDK {
|
|
2437
|
+
/**
|
|
2438
|
+
* Follow a user
|
|
2439
|
+
*
|
|
2440
|
+
* Creates a follow relationship where the authenticated user follows the target user.
|
|
2441
|
+
* Requires authentication.
|
|
2442
|
+
*
|
|
2443
|
+
* @param followingId - The ID of the user to follow
|
|
2444
|
+
* @param options - Optional request options
|
|
2445
|
+
* @returns Promise resolving to success response
|
|
2446
|
+
* @throws Error if already following or cannot follow yourself
|
|
2447
|
+
*/
|
|
2448
|
+
async follow(followingId, options) {
|
|
2449
|
+
log14("Following user: %d", followingId);
|
|
2450
|
+
const body = { followingId };
|
|
2451
|
+
const result = await this.request("/v1/user/follows", {
|
|
2452
|
+
body: JSON.stringify(body),
|
|
2453
|
+
headers: {
|
|
2454
|
+
"Content-Type": "application/json"
|
|
2455
|
+
},
|
|
2456
|
+
method: "POST",
|
|
2457
|
+
...options
|
|
2458
|
+
});
|
|
2459
|
+
log14("Successfully followed user: %d", followingId);
|
|
2460
|
+
return result;
|
|
2461
|
+
}
|
|
2462
|
+
/**
|
|
2463
|
+
* Unfollow a user
|
|
2464
|
+
*
|
|
2465
|
+
* Removes the follow relationship where the authenticated user unfollows the target user.
|
|
2466
|
+
* Requires authentication.
|
|
2467
|
+
*
|
|
2468
|
+
* @param followingId - The ID of the user to unfollow
|
|
2469
|
+
* @param options - Optional request options
|
|
2470
|
+
* @returns Promise resolving to success response
|
|
2471
|
+
* @throws Error if follow relationship not found
|
|
2472
|
+
*/
|
|
2473
|
+
async unfollow(followingId, options) {
|
|
2474
|
+
log14("Unfollowing user: %d", followingId);
|
|
2475
|
+
const body = { followingId };
|
|
2476
|
+
const result = await this.request("/v1/user/follows", {
|
|
2477
|
+
body: JSON.stringify(body),
|
|
2478
|
+
headers: {
|
|
2479
|
+
"Content-Type": "application/json"
|
|
2480
|
+
},
|
|
2481
|
+
method: "DELETE",
|
|
2482
|
+
...options
|
|
2483
|
+
});
|
|
2484
|
+
log14("Successfully unfollowed user: %d", followingId);
|
|
2485
|
+
return result;
|
|
2486
|
+
}
|
|
2487
|
+
/**
|
|
2488
|
+
* Check follow status
|
|
2489
|
+
*
|
|
2490
|
+
* Checks if the authenticated user is following the target user and if they follow each other.
|
|
2491
|
+
* Requires authentication.
|
|
2492
|
+
*
|
|
2493
|
+
* @param targetUserId - The ID of the user to check
|
|
2494
|
+
* @param options - Optional request options
|
|
2495
|
+
* @returns Promise resolving to follow status (isFollowing, isMutual)
|
|
2496
|
+
*/
|
|
2497
|
+
async checkFollowStatus(targetUserId, options) {
|
|
2498
|
+
log14("Checking follow status for user: %d", targetUserId);
|
|
2499
|
+
const queryString = this.buildQueryString({ targetUserId: String(targetUserId) });
|
|
2500
|
+
const result = await this.request(
|
|
2501
|
+
`/v1/user/follows/check${queryString}`,
|
|
2502
|
+
options
|
|
2503
|
+
);
|
|
2504
|
+
log14("Follow status retrieved: %O", result);
|
|
2505
|
+
return result;
|
|
2506
|
+
}
|
|
2507
|
+
/**
|
|
2508
|
+
* Get following list
|
|
2509
|
+
*
|
|
2510
|
+
* Retrieves the list of users that a user is following.
|
|
2511
|
+
* This is a public endpoint - no authentication required.
|
|
2512
|
+
*
|
|
2513
|
+
* @param userId - The ID of the user whose following list to retrieve
|
|
2514
|
+
* @param params - Pagination parameters
|
|
2515
|
+
* @param options - Optional request options
|
|
2516
|
+
* @returns Promise resolving to list of following users
|
|
2517
|
+
*/
|
|
2518
|
+
async getFollowing(userId, params = {}, options) {
|
|
2519
|
+
log14("Getting following list for user: %d", userId);
|
|
2520
|
+
const queryParams = {};
|
|
2521
|
+
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
2522
|
+
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
2523
|
+
const queryString = this.buildQueryString(queryParams);
|
|
2524
|
+
const result = await this.request(
|
|
2525
|
+
`/v1/user/follows/${userId}/following${queryString}`,
|
|
2526
|
+
options
|
|
2527
|
+
);
|
|
2528
|
+
log14("Following list retrieved for user: %d", userId);
|
|
2529
|
+
return result;
|
|
2530
|
+
}
|
|
2531
|
+
/**
|
|
2532
|
+
* Get followers list
|
|
2533
|
+
*
|
|
2534
|
+
* Retrieves the list of users who follow a user.
|
|
2535
|
+
* This is a public endpoint - no authentication required.
|
|
2536
|
+
*
|
|
2537
|
+
* @param userId - The ID of the user whose followers list to retrieve
|
|
2538
|
+
* @param params - Pagination parameters
|
|
2539
|
+
* @param options - Optional request options
|
|
2540
|
+
* @returns Promise resolving to list of followers
|
|
2541
|
+
*/
|
|
2542
|
+
async getFollowers(userId, params = {}, options) {
|
|
2543
|
+
log14("Getting followers list for user: %d", userId);
|
|
2544
|
+
const queryParams = {};
|
|
2545
|
+
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
2546
|
+
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
2547
|
+
const queryString = this.buildQueryString(queryParams);
|
|
2548
|
+
const result = await this.request(
|
|
2549
|
+
`/v1/user/follows/${userId}/followers${queryString}`,
|
|
2550
|
+
options
|
|
2551
|
+
);
|
|
2552
|
+
log14("Followers list retrieved for user: %d", userId);
|
|
2553
|
+
return result;
|
|
2554
|
+
}
|
|
2555
|
+
};
|
|
2556
|
+
|
|
2557
|
+
// src/market/services/UserFavoriteService.ts
|
|
2558
|
+
import debug15 from "debug";
|
|
2559
|
+
var log15 = debug15("lobe-market-sdk:user-favorite");
|
|
2560
|
+
var UserFavoriteService = class extends BaseSDK {
|
|
2561
|
+
/**
|
|
2562
|
+
* Add to favorites
|
|
2563
|
+
*
|
|
2564
|
+
* Adds an agent or plugin to the authenticated user's favorites.
|
|
2565
|
+
* Requires authentication.
|
|
2566
|
+
*
|
|
2567
|
+
* @param targetType - The type of target ('agent' or 'plugin')
|
|
2568
|
+
* @param targetId - The ID of the target agent/plugin
|
|
2569
|
+
* @param options - Optional request options
|
|
2570
|
+
* @returns Promise resolving to success response
|
|
2571
|
+
* @throws Error if already in favorites
|
|
2572
|
+
*/
|
|
2573
|
+
async addFavorite(targetType, targetId, options) {
|
|
2574
|
+
log15("Adding favorite: %s %d", targetType, targetId);
|
|
2575
|
+
const body = { targetId, targetType };
|
|
2576
|
+
const result = await this.request("/v1/user/favorites", {
|
|
2577
|
+
body: JSON.stringify(body),
|
|
2578
|
+
headers: {
|
|
2579
|
+
"Content-Type": "application/json"
|
|
2580
|
+
},
|
|
2581
|
+
method: "POST",
|
|
2582
|
+
...options
|
|
2583
|
+
});
|
|
2584
|
+
log15("Successfully added favorite: %s %d", targetType, targetId);
|
|
2585
|
+
return result;
|
|
2586
|
+
}
|
|
2587
|
+
/**
|
|
2588
|
+
* Remove from favorites
|
|
2589
|
+
*
|
|
2590
|
+
* Removes an agent or plugin from the authenticated user's favorites.
|
|
2591
|
+
* Requires authentication.
|
|
2592
|
+
*
|
|
2593
|
+
* @param targetType - The type of target ('agent' or 'plugin')
|
|
2594
|
+
* @param targetId - The ID of the target agent/plugin
|
|
2595
|
+
* @param options - Optional request options
|
|
2596
|
+
* @returns Promise resolving to success response
|
|
2597
|
+
* @throws Error if favorite not found
|
|
2598
|
+
*/
|
|
2599
|
+
async removeFavorite(targetType, targetId, options) {
|
|
2600
|
+
log15("Removing favorite: %s %d", targetType, targetId);
|
|
2601
|
+
const body = { targetId, targetType };
|
|
2602
|
+
const result = await this.request("/v1/user/favorites", {
|
|
2603
|
+
body: JSON.stringify(body),
|
|
2604
|
+
headers: {
|
|
2605
|
+
"Content-Type": "application/json"
|
|
2606
|
+
},
|
|
2607
|
+
method: "DELETE",
|
|
2608
|
+
...options
|
|
2609
|
+
});
|
|
2610
|
+
log15("Successfully removed favorite: %s %d", targetType, targetId);
|
|
2611
|
+
return result;
|
|
2612
|
+
}
|
|
2613
|
+
/**
|
|
2614
|
+
* Check favorite status
|
|
2615
|
+
*
|
|
2616
|
+
* Checks if the authenticated user has favorited a specific agent or plugin.
|
|
2617
|
+
* Requires authentication.
|
|
2618
|
+
*
|
|
2619
|
+
* @param targetType - The type of target ('agent' or 'plugin')
|
|
2620
|
+
* @param targetId - The ID of the target agent/plugin
|
|
2621
|
+
* @param options - Optional request options
|
|
2622
|
+
* @returns Promise resolving to favorite status
|
|
2623
|
+
*/
|
|
2624
|
+
async checkFavorite(targetType, targetId, options) {
|
|
2625
|
+
log15("Checking favorite status: %s %d", targetType, targetId);
|
|
2626
|
+
const queryString = this.buildQueryString({
|
|
2627
|
+
targetId: String(targetId),
|
|
2628
|
+
targetType
|
|
2629
|
+
});
|
|
2630
|
+
const result = await this.request(
|
|
2631
|
+
`/v1/user/favorites/check${queryString}`,
|
|
2632
|
+
options
|
|
2633
|
+
);
|
|
2634
|
+
log15("Favorite status retrieved: %O", result);
|
|
2635
|
+
return result;
|
|
2636
|
+
}
|
|
2637
|
+
/**
|
|
2638
|
+
* Get my favorites
|
|
2639
|
+
*
|
|
2640
|
+
* Retrieves the authenticated user's favorites.
|
|
2641
|
+
* Requires authentication.
|
|
2642
|
+
*
|
|
2643
|
+
* @param params - Query parameters for filtering and pagination
|
|
2644
|
+
* @param options - Optional request options
|
|
2645
|
+
* @returns Promise resolving to list of favorites
|
|
2646
|
+
*/
|
|
2647
|
+
async getMyFavorites(params = {}, options) {
|
|
2648
|
+
log15("Getting my favorites: %O", params);
|
|
2649
|
+
const queryParams = {};
|
|
2650
|
+
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
2651
|
+
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
2652
|
+
if (params.type !== void 0) queryParams.type = params.type;
|
|
2653
|
+
const queryString = this.buildQueryString(queryParams);
|
|
2654
|
+
const result = await this.request(
|
|
2655
|
+
`/v1/user/favorites/me${queryString}`,
|
|
2656
|
+
options
|
|
2657
|
+
);
|
|
2658
|
+
log15("My favorites retrieved");
|
|
2659
|
+
return result;
|
|
2660
|
+
}
|
|
2661
|
+
/**
|
|
2662
|
+
* Get user's favorites
|
|
2663
|
+
*
|
|
2664
|
+
* Retrieves a user's favorites.
|
|
2665
|
+
* This is a public endpoint - no authentication required.
|
|
2666
|
+
*
|
|
2667
|
+
* @param userId - The ID of the user whose favorites to retrieve
|
|
2668
|
+
* @param params - Query parameters for filtering and pagination
|
|
2669
|
+
* @param options - Optional request options
|
|
2670
|
+
* @returns Promise resolving to list of favorites
|
|
2671
|
+
*/
|
|
2672
|
+
async getUserFavorites(userId, params = {}, options) {
|
|
2673
|
+
log15("Getting favorites for user: %d", userId);
|
|
2674
|
+
const queryParams = {};
|
|
2675
|
+
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
2676
|
+
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
2677
|
+
if (params.type !== void 0) queryParams.type = params.type;
|
|
2678
|
+
const queryString = this.buildQueryString(queryParams);
|
|
2679
|
+
const result = await this.request(
|
|
2680
|
+
`/v1/user/favorites/${userId}${queryString}`,
|
|
2681
|
+
options
|
|
2682
|
+
);
|
|
2683
|
+
log15("Favorites retrieved for user: %d", userId);
|
|
2684
|
+
return result;
|
|
2685
|
+
}
|
|
2686
|
+
/**
|
|
2687
|
+
* Get user's favorite agents with details
|
|
2688
|
+
*
|
|
2689
|
+
* Retrieves a user's favorite agents with full details.
|
|
2690
|
+
* This is a public endpoint - no authentication required.
|
|
2691
|
+
*
|
|
2692
|
+
* @param userId - The ID of the user whose favorite agents to retrieve
|
|
2693
|
+
* @param params - Pagination parameters
|
|
2694
|
+
* @param options - Optional request options
|
|
2695
|
+
* @returns Promise resolving to list of favorite agents
|
|
2696
|
+
*/
|
|
2697
|
+
async getUserFavoriteAgents(userId, params = {}, options) {
|
|
2698
|
+
log15("Getting favorite agents for user: %d", userId);
|
|
2699
|
+
const queryParams = {};
|
|
2700
|
+
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
2701
|
+
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
2702
|
+
const queryString = this.buildQueryString(queryParams);
|
|
2703
|
+
const result = await this.request(
|
|
2704
|
+
`/v1/user/favorites/${userId}/agents${queryString}`,
|
|
2705
|
+
options
|
|
2706
|
+
);
|
|
2707
|
+
log15("Favorite agents retrieved for user: %d", userId);
|
|
2708
|
+
return result;
|
|
2709
|
+
}
|
|
2710
|
+
/**
|
|
2711
|
+
* Get user's favorite plugins with details
|
|
2712
|
+
*
|
|
2713
|
+
* Retrieves a user's favorite plugins with full details.
|
|
2714
|
+
* This is a public endpoint - no authentication required.
|
|
2715
|
+
*
|
|
2716
|
+
* @param userId - The ID of the user whose favorite plugins to retrieve
|
|
2717
|
+
* @param params - Pagination parameters
|
|
2718
|
+
* @param options - Optional request options
|
|
2719
|
+
* @returns Promise resolving to list of favorite plugins
|
|
2720
|
+
*/
|
|
2721
|
+
async getUserFavoritePlugins(userId, params = {}, options) {
|
|
2722
|
+
log15("Getting favorite plugins for user: %d", userId);
|
|
2723
|
+
const queryParams = {};
|
|
2724
|
+
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
2725
|
+
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
2726
|
+
const queryString = this.buildQueryString(queryParams);
|
|
2727
|
+
const result = await this.request(
|
|
2728
|
+
`/v1/user/favorites/${userId}/plugins${queryString}`,
|
|
2729
|
+
options
|
|
2730
|
+
);
|
|
2731
|
+
log15("Favorite plugins retrieved for user: %d", userId);
|
|
2732
|
+
return result;
|
|
2733
|
+
}
|
|
2734
|
+
};
|
|
2735
|
+
|
|
2736
|
+
// src/market/services/UserLikeService.ts
|
|
2737
|
+
import debug16 from "debug";
|
|
2738
|
+
var log16 = debug16("lobe-market-sdk:user-like");
|
|
2739
|
+
var UserLikeService = class extends BaseSDK {
|
|
2740
|
+
/**
|
|
2741
|
+
* Like content
|
|
2742
|
+
*
|
|
2743
|
+
* Likes an agent or plugin for the authenticated user.
|
|
2744
|
+
* Requires authentication.
|
|
2745
|
+
*
|
|
2746
|
+
* @param targetType - The type of target ('agent' or 'plugin')
|
|
2747
|
+
* @param targetId - The ID of the target agent/plugin
|
|
2748
|
+
* @param options - Optional request options
|
|
2749
|
+
* @returns Promise resolving to success response
|
|
2750
|
+
* @throws Error if already liked
|
|
2751
|
+
*/
|
|
2752
|
+
async like(targetType, targetId, options) {
|
|
2753
|
+
log16("Liking: %s %d", targetType, targetId);
|
|
2754
|
+
const body = { targetId, targetType };
|
|
2755
|
+
const result = await this.request("/v1/user/likes", {
|
|
2756
|
+
body: JSON.stringify(body),
|
|
2757
|
+
headers: {
|
|
2758
|
+
"Content-Type": "application/json"
|
|
2759
|
+
},
|
|
2760
|
+
method: "POST",
|
|
2761
|
+
...options
|
|
2762
|
+
});
|
|
2763
|
+
log16("Successfully liked: %s %d", targetType, targetId);
|
|
2764
|
+
return result;
|
|
2765
|
+
}
|
|
2766
|
+
/**
|
|
2767
|
+
* Unlike content
|
|
2768
|
+
*
|
|
2769
|
+
* Unlikes an agent or plugin for the authenticated user.
|
|
2770
|
+
* Requires authentication.
|
|
2771
|
+
*
|
|
2772
|
+
* @param targetType - The type of target ('agent' or 'plugin')
|
|
2773
|
+
* @param targetId - The ID of the target agent/plugin
|
|
2774
|
+
* @param options - Optional request options
|
|
2775
|
+
* @returns Promise resolving to success response
|
|
2776
|
+
* @throws Error if like not found
|
|
2777
|
+
*/
|
|
2778
|
+
async unlike(targetType, targetId, options) {
|
|
2779
|
+
log16("Unliking: %s %d", targetType, targetId);
|
|
2780
|
+
const body = { targetId, targetType };
|
|
2781
|
+
const result = await this.request("/v1/user/likes", {
|
|
2782
|
+
body: JSON.stringify(body),
|
|
2783
|
+
headers: {
|
|
2784
|
+
"Content-Type": "application/json"
|
|
2785
|
+
},
|
|
2786
|
+
method: "DELETE",
|
|
2787
|
+
...options
|
|
2788
|
+
});
|
|
2789
|
+
log16("Successfully unliked: %s %d", targetType, targetId);
|
|
2790
|
+
return result;
|
|
2791
|
+
}
|
|
2792
|
+
/**
|
|
2793
|
+
* Toggle like status
|
|
2794
|
+
*
|
|
2795
|
+
* Toggles the like status - likes if not liked, unlikes if already liked.
|
|
2796
|
+
* Requires authentication.
|
|
2797
|
+
*
|
|
2798
|
+
* @param targetType - The type of target ('agent' or 'plugin')
|
|
2799
|
+
* @param targetId - The ID of the target agent/plugin
|
|
2800
|
+
* @param options - Optional request options
|
|
2801
|
+
* @returns Promise resolving to toggle response with new like status
|
|
2802
|
+
*/
|
|
2803
|
+
async toggleLike(targetType, targetId, options) {
|
|
2804
|
+
log16("Toggling like: %s %d", targetType, targetId);
|
|
2805
|
+
const body = { targetId, targetType };
|
|
2806
|
+
const result = await this.request("/v1/user/likes/toggle", {
|
|
2807
|
+
body: JSON.stringify(body),
|
|
2808
|
+
headers: {
|
|
2809
|
+
"Content-Type": "application/json"
|
|
2810
|
+
},
|
|
2811
|
+
method: "POST",
|
|
2812
|
+
...options
|
|
2813
|
+
});
|
|
2814
|
+
log16("Like toggled, new status: %O", result);
|
|
2815
|
+
return result;
|
|
2816
|
+
}
|
|
2817
|
+
/**
|
|
2818
|
+
* Check like status
|
|
2819
|
+
*
|
|
2820
|
+
* Checks if the authenticated user has liked a specific agent or plugin.
|
|
2821
|
+
* Requires authentication.
|
|
2822
|
+
*
|
|
2823
|
+
* @param targetType - The type of target ('agent' or 'plugin')
|
|
2824
|
+
* @param targetId - The ID of the target agent/plugin
|
|
2825
|
+
* @param options - Optional request options
|
|
2826
|
+
* @returns Promise resolving to like status
|
|
2827
|
+
*/
|
|
2828
|
+
async checkLike(targetType, targetId, options) {
|
|
2829
|
+
log16("Checking like status: %s %d", targetType, targetId);
|
|
2830
|
+
const queryString = this.buildQueryString({
|
|
2831
|
+
targetId: String(targetId),
|
|
2832
|
+
targetType
|
|
2833
|
+
});
|
|
2834
|
+
const result = await this.request(
|
|
2835
|
+
`/v1/user/likes/check${queryString}`,
|
|
2836
|
+
options
|
|
2837
|
+
);
|
|
2838
|
+
log16("Like status retrieved: %O", result);
|
|
2839
|
+
return result;
|
|
2840
|
+
}
|
|
2841
|
+
/**
|
|
2842
|
+
* Get my likes
|
|
2843
|
+
*
|
|
2844
|
+
* Retrieves the authenticated user's likes.
|
|
2845
|
+
* Requires authentication.
|
|
2846
|
+
*
|
|
2847
|
+
* @param params - Query parameters for filtering and pagination
|
|
2848
|
+
* @param options - Optional request options
|
|
2849
|
+
* @returns Promise resolving to list of likes
|
|
2850
|
+
*/
|
|
2851
|
+
async getMyLikes(params = {}, options) {
|
|
2852
|
+
log16("Getting my likes: %O", params);
|
|
2853
|
+
const queryParams = {};
|
|
2854
|
+
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
2855
|
+
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
2856
|
+
if (params.type !== void 0) queryParams.type = params.type;
|
|
2857
|
+
const queryString = this.buildQueryString(queryParams);
|
|
2858
|
+
const result = await this.request(
|
|
2859
|
+
`/v1/user/likes/me${queryString}`,
|
|
2860
|
+
options
|
|
2861
|
+
);
|
|
2862
|
+
log16("My likes retrieved");
|
|
2863
|
+
return result;
|
|
2864
|
+
}
|
|
2865
|
+
/**
|
|
2866
|
+
* Get user's likes
|
|
2867
|
+
*
|
|
2868
|
+
* Retrieves a user's likes.
|
|
2869
|
+
* This is a public endpoint - no authentication required.
|
|
2870
|
+
*
|
|
2871
|
+
* @param userId - The ID of the user whose likes to retrieve
|
|
2872
|
+
* @param params - Query parameters for filtering and pagination
|
|
2873
|
+
* @param options - Optional request options
|
|
2874
|
+
* @returns Promise resolving to list of likes
|
|
2875
|
+
*/
|
|
2876
|
+
async getUserLikes(userId, params = {}, options) {
|
|
2877
|
+
log16("Getting likes for user: %d", userId);
|
|
2878
|
+
const queryParams = {};
|
|
2879
|
+
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
2880
|
+
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
2881
|
+
if (params.type !== void 0) queryParams.type = params.type;
|
|
2882
|
+
const queryString = this.buildQueryString(queryParams);
|
|
2883
|
+
const result = await this.request(
|
|
2884
|
+
`/v1/user/likes/${userId}${queryString}`,
|
|
2885
|
+
options
|
|
2886
|
+
);
|
|
2887
|
+
log16("Likes retrieved for user: %d", userId);
|
|
2888
|
+
return result;
|
|
2889
|
+
}
|
|
2890
|
+
/**
|
|
2891
|
+
* Get user's liked agents with details
|
|
2892
|
+
*
|
|
2893
|
+
* Retrieves a user's liked agents with full details.
|
|
2894
|
+
* This is a public endpoint - no authentication required.
|
|
2895
|
+
*
|
|
2896
|
+
* @param userId - The ID of the user whose liked agents to retrieve
|
|
2897
|
+
* @param params - Pagination parameters
|
|
2898
|
+
* @param options - Optional request options
|
|
2899
|
+
* @returns Promise resolving to list of liked agents
|
|
2900
|
+
*/
|
|
2901
|
+
async getUserLikedAgents(userId, params = {}, options) {
|
|
2902
|
+
log16("Getting liked agents for user: %d", userId);
|
|
2903
|
+
const queryParams = {};
|
|
2904
|
+
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
2905
|
+
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
2906
|
+
const queryString = this.buildQueryString(queryParams);
|
|
2907
|
+
const result = await this.request(
|
|
2908
|
+
`/v1/user/likes/${userId}/agents${queryString}`,
|
|
2909
|
+
options
|
|
2910
|
+
);
|
|
2911
|
+
log16("Liked agents retrieved for user: %d", userId);
|
|
2912
|
+
return result;
|
|
2913
|
+
}
|
|
2914
|
+
/**
|
|
2915
|
+
* Get user's liked plugins with details
|
|
2916
|
+
*
|
|
2917
|
+
* Retrieves a user's liked plugins with full details.
|
|
2918
|
+
* This is a public endpoint - no authentication required.
|
|
2919
|
+
*
|
|
2920
|
+
* @param userId - The ID of the user whose liked plugins to retrieve
|
|
2921
|
+
* @param params - Pagination parameters
|
|
2922
|
+
* @param options - Optional request options
|
|
2923
|
+
* @returns Promise resolving to list of liked plugins
|
|
2924
|
+
*/
|
|
2925
|
+
async getUserLikedPlugins(userId, params = {}, options) {
|
|
2926
|
+
log16("Getting liked plugins for user: %d", userId);
|
|
2927
|
+
const queryParams = {};
|
|
2928
|
+
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
2929
|
+
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
2930
|
+
const queryString = this.buildQueryString(queryParams);
|
|
2931
|
+
const result = await this.request(
|
|
2932
|
+
`/v1/user/likes/${userId}/plugins${queryString}`,
|
|
2933
|
+
options
|
|
2934
|
+
);
|
|
2935
|
+
log16("Liked plugins retrieved for user: %d", userId);
|
|
2936
|
+
return result;
|
|
2937
|
+
}
|
|
2938
|
+
};
|
|
2939
|
+
|
|
2400
2940
|
// src/market/market-sdk.ts
|
|
2401
|
-
var
|
|
2941
|
+
var log17 = debug17("lobe-market-sdk");
|
|
2402
2942
|
var MarketSDK = class extends BaseSDK {
|
|
2403
2943
|
/**
|
|
2404
2944
|
* Creates a new MarketSDK instance
|
|
@@ -2411,11 +2951,14 @@ var MarketSDK = class extends BaseSDK {
|
|
|
2411
2951
|
tokenExpiry: void 0
|
|
2412
2952
|
};
|
|
2413
2953
|
super(options, void 0, sharedTokenState);
|
|
2414
|
-
|
|
2954
|
+
log17("MarketSDK instance created");
|
|
2415
2955
|
this.agents = new AgentService(options, this.headers, sharedTokenState);
|
|
2416
2956
|
this.auth = new AuthService(options, this.headers, sharedTokenState);
|
|
2417
2957
|
this.plugins = new PluginsService(options, this.headers, sharedTokenState);
|
|
2418
2958
|
this.user = new UserService(options, this.headers, sharedTokenState);
|
|
2959
|
+
this.follows = new UserFollowService(options, this.headers, sharedTokenState);
|
|
2960
|
+
this.favorites = new UserFavoriteService(options, this.headers, sharedTokenState);
|
|
2961
|
+
this.likes = new UserLikeService(options, this.headers, sharedTokenState);
|
|
2419
2962
|
this.discovery = new DiscoveryService(options, this.headers, sharedTokenState);
|
|
2420
2963
|
}
|
|
2421
2964
|
/**
|
|
@@ -2442,7 +2985,7 @@ var MarketSDK = class extends BaseSDK {
|
|
|
2442
2985
|
* @deprecated Use auth.registerClient() instead
|
|
2443
2986
|
*/
|
|
2444
2987
|
async registerClient(request) {
|
|
2445
|
-
|
|
2988
|
+
log17("Registering client (deprecated method, use auth.registerClient): %s", request.clientName);
|
|
2446
2989
|
return this.auth.registerClient(request);
|
|
2447
2990
|
}
|
|
2448
2991
|
};
|