@lobehub/market-sdk 0.26.1 → 0.27.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 +759 -4
- package/dist/index.mjs +467 -86
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -3
package/dist/index.mjs
CHANGED
|
@@ -88,6 +88,9 @@ var BaseSDK = class {
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
log("Request successful: %s", url);
|
|
91
|
+
if (response.status === 204) {
|
|
92
|
+
return void 0;
|
|
93
|
+
}
|
|
91
94
|
return response.json();
|
|
92
95
|
}
|
|
93
96
|
/**
|
|
@@ -1558,7 +1561,7 @@ var MarketAdmin = class extends BaseSDK {
|
|
|
1558
1561
|
};
|
|
1559
1562
|
|
|
1560
1563
|
// src/market/market-sdk.ts
|
|
1561
|
-
import
|
|
1564
|
+
import debug21 from "debug";
|
|
1562
1565
|
|
|
1563
1566
|
// src/market/services/AgentService.ts
|
|
1564
1567
|
import debug10 from "debug";
|
|
@@ -1790,6 +1793,25 @@ var AgentService2 = class extends BaseSDK {
|
|
|
1790
1793
|
return false;
|
|
1791
1794
|
}
|
|
1792
1795
|
}
|
|
1796
|
+
/**
|
|
1797
|
+
* Record an agent event for the authenticated user
|
|
1798
|
+
*
|
|
1799
|
+
* Records agent usage actions (add, chat, click) for analytics.
|
|
1800
|
+
*
|
|
1801
|
+
* @param eventData - The agent event payload
|
|
1802
|
+
* @param options - Optional request init overrides
|
|
1803
|
+
*/
|
|
1804
|
+
async createEvent(eventData, options) {
|
|
1805
|
+
log10("Recording agent event: %s for %s", eventData.event, eventData.identifier);
|
|
1806
|
+
await this.request("/v1/agents/events", {
|
|
1807
|
+
body: JSON.stringify(eventData),
|
|
1808
|
+
headers: {
|
|
1809
|
+
"Content-Type": "application/json"
|
|
1810
|
+
},
|
|
1811
|
+
method: "POST",
|
|
1812
|
+
...options
|
|
1813
|
+
});
|
|
1814
|
+
}
|
|
1793
1815
|
/**
|
|
1794
1816
|
* Increases the install count for an agent
|
|
1795
1817
|
*
|
|
@@ -2160,10 +2182,218 @@ _AuthService.HANDOFF_CONSUMED_STATUS = "consumed";
|
|
|
2160
2182
|
_AuthService.HANDOFF_EXPIRED_STATUS = "expired";
|
|
2161
2183
|
var AuthService = _AuthService;
|
|
2162
2184
|
|
|
2163
|
-
// src/market/services/
|
|
2185
|
+
// src/market/services/ConnectService.ts
|
|
2164
2186
|
import debug12 from "debug";
|
|
2165
2187
|
import urlJoin3 from "url-join";
|
|
2166
|
-
var log12 = debug12("lobe-market-sdk:
|
|
2188
|
+
var log12 = debug12("lobe-market-sdk:connect");
|
|
2189
|
+
var ConnectService = class extends BaseSDK {
|
|
2190
|
+
/**
|
|
2191
|
+
* Lists all available OAuth providers
|
|
2192
|
+
*
|
|
2193
|
+
* Returns providers that have credentials configured on the server.
|
|
2194
|
+
* This is a public endpoint that doesn't require authentication.
|
|
2195
|
+
*
|
|
2196
|
+
* @param options - Optional request options
|
|
2197
|
+
* @returns Promise resolving to the list of available providers
|
|
2198
|
+
*/
|
|
2199
|
+
async listProviders(options) {
|
|
2200
|
+
var _a;
|
|
2201
|
+
log12("Listing connect providers");
|
|
2202
|
+
const result = await this.request(
|
|
2203
|
+
"/connect/providers",
|
|
2204
|
+
options
|
|
2205
|
+
);
|
|
2206
|
+
log12("Found %d connect providers", ((_a = result.providers) == null ? void 0 : _a.length) || 0);
|
|
2207
|
+
return result;
|
|
2208
|
+
}
|
|
2209
|
+
/**
|
|
2210
|
+
* Gets detailed information about a specific provider
|
|
2211
|
+
*
|
|
2212
|
+
* This is a public endpoint that doesn't require authentication.
|
|
2213
|
+
*
|
|
2214
|
+
* @param provider - The provider ID (e.g., 'linear', 'github')
|
|
2215
|
+
* @param options - Optional request options
|
|
2216
|
+
* @returns Promise resolving to the provider details
|
|
2217
|
+
*/
|
|
2218
|
+
async getProvider(provider, options) {
|
|
2219
|
+
var _a;
|
|
2220
|
+
log12("Getting provider details: %s", provider);
|
|
2221
|
+
const result = await this.request(
|
|
2222
|
+
`/connect/providers/${encodeURIComponent(provider)}`,
|
|
2223
|
+
options
|
|
2224
|
+
);
|
|
2225
|
+
log12("Retrieved provider: %s", (_a = result.provider) == null ? void 0 : _a.name);
|
|
2226
|
+
return result;
|
|
2227
|
+
}
|
|
2228
|
+
/**
|
|
2229
|
+
* Generates the OAuth authorization URL for a provider
|
|
2230
|
+
*
|
|
2231
|
+
* This URL should be opened in a browser (popup or redirect) for the user
|
|
2232
|
+
* to authorize the connection. After authorization, the user will be
|
|
2233
|
+
* redirected back to the callback URL.
|
|
2234
|
+
*
|
|
2235
|
+
* Note: This method does NOT make an API request. It constructs the URL
|
|
2236
|
+
* that the user should visit to start the OAuth flow.
|
|
2237
|
+
*
|
|
2238
|
+
* @param provider - The provider ID (e.g., 'linear', 'github')
|
|
2239
|
+
* @param params - Optional parameters for scopes and redirect URI
|
|
2240
|
+
* @returns The authorization URL to redirect the user to
|
|
2241
|
+
*
|
|
2242
|
+
* @example
|
|
2243
|
+
* ```typescript
|
|
2244
|
+
* // Basic usage - opens in popup
|
|
2245
|
+
* const url = sdk.connect.getAuthorizeUrl('linear');
|
|
2246
|
+
* const popup = window.open(url, 'oauth', 'width=600,height=700');
|
|
2247
|
+
*
|
|
2248
|
+
* // With custom scopes
|
|
2249
|
+
* const url = sdk.connect.getAuthorizeUrl('github', {
|
|
2250
|
+
* scopes: ['user', 'repo', 'read:org']
|
|
2251
|
+
* });
|
|
2252
|
+
*
|
|
2253
|
+
* // With redirect URI
|
|
2254
|
+
* const url = sdk.connect.getAuthorizeUrl('linear', {
|
|
2255
|
+
* redirectUri: 'https://myapp.com/oauth/callback'
|
|
2256
|
+
* });
|
|
2257
|
+
* ```
|
|
2258
|
+
*/
|
|
2259
|
+
getAuthorizeUrl(provider, params) {
|
|
2260
|
+
log12("Generating authorize URL for provider: %s", provider);
|
|
2261
|
+
const queryParams = new URLSearchParams();
|
|
2262
|
+
if ((params == null ? void 0 : params.scopes) && params.scopes.length > 0) {
|
|
2263
|
+
queryParams.set("scope", params.scopes.join(","));
|
|
2264
|
+
}
|
|
2265
|
+
if (params == null ? void 0 : params.redirectUri) {
|
|
2266
|
+
queryParams.set("redirect_uri", params.redirectUri);
|
|
2267
|
+
}
|
|
2268
|
+
const queryString = queryParams.toString();
|
|
2269
|
+
const path = `/connect/${encodeURIComponent(provider)}/start${queryString ? `?${queryString}` : ""}`;
|
|
2270
|
+
const url = urlJoin3(this.baseUrl, "api", path);
|
|
2271
|
+
log12("Generated authorize URL: %s", url);
|
|
2272
|
+
return url;
|
|
2273
|
+
}
|
|
2274
|
+
/**
|
|
2275
|
+
* Gets the connection status for a specific provider
|
|
2276
|
+
*
|
|
2277
|
+
* Checks if the authenticated user has an active OAuth connection.
|
|
2278
|
+
* Requires authentication.
|
|
2279
|
+
*
|
|
2280
|
+
* @param provider - The provider ID (e.g., 'linear', 'github')
|
|
2281
|
+
* @param options - Optional request options (must include authentication)
|
|
2282
|
+
* @returns Promise resolving to the connection status
|
|
2283
|
+
*/
|
|
2284
|
+
async getStatus(provider, options) {
|
|
2285
|
+
log12("Getting connection status for provider: %s", provider);
|
|
2286
|
+
const result = await this.request(
|
|
2287
|
+
`/connect/${encodeURIComponent(provider)}/status`,
|
|
2288
|
+
options
|
|
2289
|
+
);
|
|
2290
|
+
log12("Provider %s connection status: connected=%s", provider, result.connected);
|
|
2291
|
+
return result;
|
|
2292
|
+
}
|
|
2293
|
+
/**
|
|
2294
|
+
* Lists all OAuth connections for the authenticated user
|
|
2295
|
+
*
|
|
2296
|
+
* Requires authentication.
|
|
2297
|
+
*
|
|
2298
|
+
* @param options - Optional request options (must include authentication)
|
|
2299
|
+
* @returns Promise resolving to the list of connections
|
|
2300
|
+
*/
|
|
2301
|
+
async listConnections(options) {
|
|
2302
|
+
var _a;
|
|
2303
|
+
log12("Listing user connections");
|
|
2304
|
+
const result = await this.request("/connect/connections", options);
|
|
2305
|
+
log12("Found %d connections", ((_a = result.connections) == null ? void 0 : _a.length) || 0);
|
|
2306
|
+
return result;
|
|
2307
|
+
}
|
|
2308
|
+
/**
|
|
2309
|
+
* Checks the health of a specific provider connection
|
|
2310
|
+
*
|
|
2311
|
+
* Verifies if the token is valid, expiring soon, or expired.
|
|
2312
|
+
* Requires authentication.
|
|
2313
|
+
*
|
|
2314
|
+
* @param provider - The provider ID (e.g., 'linear', 'github')
|
|
2315
|
+
* @param options - Optional request options (must include authentication)
|
|
2316
|
+
* @returns Promise resolving to the connection health status
|
|
2317
|
+
*/
|
|
2318
|
+
async getHealth(provider, options) {
|
|
2319
|
+
log12("Checking health for provider: %s", provider);
|
|
2320
|
+
const result = await this.request(
|
|
2321
|
+
`/connect/${encodeURIComponent(provider)}/health`,
|
|
2322
|
+
options
|
|
2323
|
+
);
|
|
2324
|
+
log12("Provider %s health: healthy=%s, status=%s", provider, result.healthy, result.tokenStatus);
|
|
2325
|
+
return result;
|
|
2326
|
+
}
|
|
2327
|
+
/**
|
|
2328
|
+
* Checks the health of all provider connections
|
|
2329
|
+
*
|
|
2330
|
+
* Requires authentication.
|
|
2331
|
+
*
|
|
2332
|
+
* @param options - Optional request options (must include authentication)
|
|
2333
|
+
* @returns Promise resolving to the health status of all connections
|
|
2334
|
+
*/
|
|
2335
|
+
async getAllHealth(options) {
|
|
2336
|
+
var _a, _b, _c;
|
|
2337
|
+
log12("Checking health for all connections");
|
|
2338
|
+
const result = await this.request("/connect/health", options);
|
|
2339
|
+
log12(
|
|
2340
|
+
"Health check complete: total=%d, healthy=%d, unhealthy=%d",
|
|
2341
|
+
((_a = result.summary) == null ? void 0 : _a.total) || 0,
|
|
2342
|
+
((_b = result.summary) == null ? void 0 : _b.healthy) || 0,
|
|
2343
|
+
((_c = result.summary) == null ? void 0 : _c.unhealthy) || 0
|
|
2344
|
+
);
|
|
2345
|
+
return result;
|
|
2346
|
+
}
|
|
2347
|
+
/**
|
|
2348
|
+
* Manually refreshes the access token for a provider connection
|
|
2349
|
+
*
|
|
2350
|
+
* Only works for providers that support token refresh.
|
|
2351
|
+
* Requires authentication.
|
|
2352
|
+
*
|
|
2353
|
+
* @param provider - The provider ID (e.g., 'linear', 'github')
|
|
2354
|
+
* @param options - Optional request options (must include authentication)
|
|
2355
|
+
* @returns Promise resolving to the refresh result
|
|
2356
|
+
*/
|
|
2357
|
+
async refresh(provider, options) {
|
|
2358
|
+
log12("Refreshing token for provider: %s", provider);
|
|
2359
|
+
const result = await this.request(
|
|
2360
|
+
`/connect/${encodeURIComponent(provider)}/refresh`,
|
|
2361
|
+
{
|
|
2362
|
+
method: "POST",
|
|
2363
|
+
...options
|
|
2364
|
+
}
|
|
2365
|
+
);
|
|
2366
|
+
log12("Token refresh for %s: refreshed=%s", provider, result.refreshed);
|
|
2367
|
+
return result;
|
|
2368
|
+
}
|
|
2369
|
+
/**
|
|
2370
|
+
* Revokes/disconnects a provider connection
|
|
2371
|
+
*
|
|
2372
|
+
* Removes the OAuth connection and deletes stored tokens.
|
|
2373
|
+
* Requires authentication.
|
|
2374
|
+
*
|
|
2375
|
+
* @param provider - The provider ID (e.g., 'linear', 'github')
|
|
2376
|
+
* @param options - Optional request options (must include authentication)
|
|
2377
|
+
* @returns Promise resolving to the revoke result
|
|
2378
|
+
*/
|
|
2379
|
+
async revoke(provider, options) {
|
|
2380
|
+
log12("Revoking connection for provider: %s", provider);
|
|
2381
|
+
const result = await this.request(
|
|
2382
|
+
`/connect/${encodeURIComponent(provider)}`,
|
|
2383
|
+
{
|
|
2384
|
+
method: "DELETE",
|
|
2385
|
+
...options
|
|
2386
|
+
}
|
|
2387
|
+
);
|
|
2388
|
+
log12("Connection revoked for %s: success=%s", provider, result.success);
|
|
2389
|
+
return result;
|
|
2390
|
+
}
|
|
2391
|
+
};
|
|
2392
|
+
|
|
2393
|
+
// src/market/services/DiscoveryService.ts
|
|
2394
|
+
import debug13 from "debug";
|
|
2395
|
+
import urlJoin4 from "url-join";
|
|
2396
|
+
var log13 = debug13("lobe-market-sdk:discovery");
|
|
2167
2397
|
var DiscoveryService = class extends BaseSDK {
|
|
2168
2398
|
/**
|
|
2169
2399
|
* Retrieves the service discovery document
|
|
@@ -2175,24 +2405,24 @@ var DiscoveryService = class extends BaseSDK {
|
|
|
2175
2405
|
* @returns Promise resolving to the service discovery document
|
|
2176
2406
|
*/
|
|
2177
2407
|
async getDiscoveryDocument() {
|
|
2178
|
-
|
|
2408
|
+
log13("Fetching discovery document");
|
|
2179
2409
|
if (this.discoveryDoc) {
|
|
2180
|
-
|
|
2410
|
+
log13("Returning cached discovery document");
|
|
2181
2411
|
return this.discoveryDoc;
|
|
2182
2412
|
}
|
|
2183
|
-
const res = await fetch(
|
|
2413
|
+
const res = await fetch(urlJoin4(this.baseUrl, "/.well-known/discovery"));
|
|
2184
2414
|
if (!res.ok) {
|
|
2185
2415
|
throw new Error(await res.text());
|
|
2186
2416
|
}
|
|
2187
2417
|
this.discoveryDoc = await res.json();
|
|
2188
|
-
|
|
2418
|
+
log13("Discovery document successfully fetched");
|
|
2189
2419
|
return this.discoveryDoc;
|
|
2190
2420
|
}
|
|
2191
2421
|
};
|
|
2192
2422
|
|
|
2193
2423
|
// src/market/services/FeedbackService.ts
|
|
2194
|
-
import
|
|
2195
|
-
var
|
|
2424
|
+
import debug14 from "debug";
|
|
2425
|
+
var log14 = debug14("lobe-market-sdk:feedback");
|
|
2196
2426
|
var FeedbackService = class extends BaseSDK {
|
|
2197
2427
|
/**
|
|
2198
2428
|
* Submits user feedback
|
|
@@ -2222,7 +2452,7 @@ var FeedbackService = class extends BaseSDK {
|
|
|
2222
2452
|
* ```
|
|
2223
2453
|
*/
|
|
2224
2454
|
async submitFeedback(data, options) {
|
|
2225
|
-
|
|
2455
|
+
log14("Submitting feedback: %s", data.title);
|
|
2226
2456
|
const result = await this.request("/v1/user/feedback", {
|
|
2227
2457
|
body: JSON.stringify(data),
|
|
2228
2458
|
headers: {
|
|
@@ -2231,14 +2461,14 @@ var FeedbackService = class extends BaseSDK {
|
|
|
2231
2461
|
method: "POST",
|
|
2232
2462
|
...options
|
|
2233
2463
|
});
|
|
2234
|
-
|
|
2464
|
+
log14("Feedback submitted successfully: %s", result.issueId);
|
|
2235
2465
|
return result;
|
|
2236
2466
|
}
|
|
2237
2467
|
};
|
|
2238
2468
|
|
|
2239
2469
|
// src/market/services/PluginsService.ts
|
|
2240
|
-
import
|
|
2241
|
-
var
|
|
2470
|
+
import debug15 from "debug";
|
|
2471
|
+
var log15 = debug15("lobe-market-sdk:plugins");
|
|
2242
2472
|
var PluginsService = class extends BaseSDK {
|
|
2243
2473
|
/**
|
|
2244
2474
|
* Retrieves a list of plugins from the marketplace
|
|
@@ -2253,9 +2483,9 @@ var PluginsService = class extends BaseSDK {
|
|
|
2253
2483
|
const locale = params.locale || this.defaultLocale;
|
|
2254
2484
|
const queryParams = { ...params, locale };
|
|
2255
2485
|
const queryString = this.buildQueryString(queryParams);
|
|
2256
|
-
|
|
2486
|
+
log15("Getting plugin list: %O", queryParams);
|
|
2257
2487
|
const result = await this.request(`/v1/plugins${queryString}`, options);
|
|
2258
|
-
|
|
2488
|
+
log15("Retrieved %d plugins", result.items.length);
|
|
2259
2489
|
return result;
|
|
2260
2490
|
}
|
|
2261
2491
|
/**
|
|
@@ -2273,12 +2503,12 @@ var PluginsService = class extends BaseSDK {
|
|
|
2273
2503
|
const locale = params.locale || this.defaultLocale;
|
|
2274
2504
|
const queryParams = { ...params, locale };
|
|
2275
2505
|
const queryString = this.buildQueryString(queryParams);
|
|
2276
|
-
|
|
2506
|
+
log15("Getting plugin categories: %O", queryParams);
|
|
2277
2507
|
const result = await this.request(
|
|
2278
2508
|
`/v1/plugins/categories${queryString}`,
|
|
2279
2509
|
options
|
|
2280
2510
|
);
|
|
2281
|
-
|
|
2511
|
+
log15("Retrieved %d categories", result.length);
|
|
2282
2512
|
return result;
|
|
2283
2513
|
}
|
|
2284
2514
|
/**
|
|
@@ -2291,12 +2521,12 @@ var PluginsService = class extends BaseSDK {
|
|
|
2291
2521
|
* @returns Promise resolving to an array containing identifiers array and last modified time
|
|
2292
2522
|
*/
|
|
2293
2523
|
async getPublishedIdentifiers(options) {
|
|
2294
|
-
|
|
2524
|
+
log15("Getting published plugin identifiers");
|
|
2295
2525
|
const result = await this.request(
|
|
2296
2526
|
"/v1/plugins/identifiers",
|
|
2297
2527
|
options
|
|
2298
2528
|
);
|
|
2299
|
-
|
|
2529
|
+
log15("Retrieved %d published plugin identifiers", result.length);
|
|
2300
2530
|
return result;
|
|
2301
2531
|
}
|
|
2302
2532
|
/**
|
|
@@ -2316,7 +2546,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
2316
2546
|
version,
|
|
2317
2547
|
identifier
|
|
2318
2548
|
}, options) {
|
|
2319
|
-
|
|
2549
|
+
log15("Getting plugin manifest: %O", { identifier, locale, version });
|
|
2320
2550
|
const localeParam = locale || this.defaultLocale;
|
|
2321
2551
|
const params = { locale: localeParam };
|
|
2322
2552
|
if (version) {
|
|
@@ -2327,7 +2557,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
2327
2557
|
`/v1/plugins/${identifier}/manifest${queryString}`,
|
|
2328
2558
|
options
|
|
2329
2559
|
);
|
|
2330
|
-
|
|
2560
|
+
log15("Plugin manifest successfully retrieved: %s", identifier);
|
|
2331
2561
|
return manifest;
|
|
2332
2562
|
}
|
|
2333
2563
|
/**
|
|
@@ -2344,7 +2574,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
2344
2574
|
version,
|
|
2345
2575
|
identifier
|
|
2346
2576
|
}, options) {
|
|
2347
|
-
|
|
2577
|
+
log15("Getting plugin detail: %O", { identifier, locale, version });
|
|
2348
2578
|
const localeParam = locale || this.defaultLocale;
|
|
2349
2579
|
const params = { locale: localeParam };
|
|
2350
2580
|
if (version) {
|
|
@@ -2355,7 +2585,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
2355
2585
|
`/v1/plugins/${identifier}${queryString}`,
|
|
2356
2586
|
options
|
|
2357
2587
|
);
|
|
2358
|
-
|
|
2588
|
+
log15("Plugin manifest successfully retrieved: %s", identifier);
|
|
2359
2589
|
return manifest;
|
|
2360
2590
|
}
|
|
2361
2591
|
/**
|
|
@@ -2370,7 +2600,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
2370
2600
|
*
|
|
2371
2601
|
*/
|
|
2372
2602
|
async reportInstallation(reportData) {
|
|
2373
|
-
|
|
2603
|
+
log15("Reporting installation for %s@%s", reportData.identifier, reportData.version);
|
|
2374
2604
|
const result = await this.request("/v1/plugins/report/installation", {
|
|
2375
2605
|
body: JSON.stringify(reportData),
|
|
2376
2606
|
headers: {
|
|
@@ -2378,7 +2608,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
2378
2608
|
},
|
|
2379
2609
|
method: "POST"
|
|
2380
2610
|
});
|
|
2381
|
-
|
|
2611
|
+
log15("Installation report submitted successfully: %O", result);
|
|
2382
2612
|
return result;
|
|
2383
2613
|
}
|
|
2384
2614
|
/**
|
|
@@ -2392,7 +2622,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
2392
2622
|
* @returns Promise resolving to the report submission response
|
|
2393
2623
|
*/
|
|
2394
2624
|
async reportCall(reportData) {
|
|
2395
|
-
|
|
2625
|
+
log15(
|
|
2396
2626
|
"Reporting call for %s@%s - %s:%s",
|
|
2397
2627
|
reportData.identifier,
|
|
2398
2628
|
reportData.version,
|
|
@@ -2406,9 +2636,28 @@ var PluginsService = class extends BaseSDK {
|
|
|
2406
2636
|
},
|
|
2407
2637
|
method: "POST"
|
|
2408
2638
|
});
|
|
2409
|
-
|
|
2639
|
+
log15("Call report submitted successfully: %O", result);
|
|
2410
2640
|
return result;
|
|
2411
2641
|
}
|
|
2642
|
+
/**
|
|
2643
|
+
* Record a plugin event for the authenticated user
|
|
2644
|
+
*
|
|
2645
|
+
* Records plugin usage actions (install, activate, uninstall, click) for analytics.
|
|
2646
|
+
*
|
|
2647
|
+
* @param eventData - The plugin event payload
|
|
2648
|
+
* @param options - Optional request init overrides
|
|
2649
|
+
*/
|
|
2650
|
+
async createEvent(eventData, options) {
|
|
2651
|
+
log15("Recording plugin event: %s for %s", eventData.event, eventData.identifier);
|
|
2652
|
+
await this.request("/v1/plugins/events", {
|
|
2653
|
+
body: JSON.stringify(eventData),
|
|
2654
|
+
headers: {
|
|
2655
|
+
"Content-Type": "application/json"
|
|
2656
|
+
},
|
|
2657
|
+
method: "POST",
|
|
2658
|
+
...options
|
|
2659
|
+
});
|
|
2660
|
+
}
|
|
2412
2661
|
/**
|
|
2413
2662
|
* Call a cloud-hosted plugin tool via the cloud gateway
|
|
2414
2663
|
*
|
|
@@ -2429,7 +2678,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
2429
2678
|
* ```
|
|
2430
2679
|
*/
|
|
2431
2680
|
async callCloudGateway(request, options) {
|
|
2432
|
-
|
|
2681
|
+
log15("Calling cloud gateway for plugin %s, tool %s", request.identifier, request.toolName);
|
|
2433
2682
|
const result = await this.request("/v1/plugins/cloud-gateway", {
|
|
2434
2683
|
body: JSON.stringify(request),
|
|
2435
2684
|
headers: {
|
|
@@ -2438,7 +2687,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
2438
2687
|
method: "POST",
|
|
2439
2688
|
...options
|
|
2440
2689
|
});
|
|
2441
|
-
|
|
2690
|
+
log15("Cloud gateway call completed: %O", {
|
|
2442
2691
|
identifier: request.identifier,
|
|
2443
2692
|
isError: result.isError,
|
|
2444
2693
|
toolName: request.toolName
|
|
@@ -2479,7 +2728,12 @@ var PluginsService = class extends BaseSDK {
|
|
|
2479
2728
|
* ```
|
|
2480
2729
|
*/
|
|
2481
2730
|
async runBuildInTool(toolName, params, context, options) {
|
|
2482
|
-
|
|
2731
|
+
log15(
|
|
2732
|
+
"Running built-in tool: %s for user %s, topic %s",
|
|
2733
|
+
toolName,
|
|
2734
|
+
context.userId,
|
|
2735
|
+
context.topicId
|
|
2736
|
+
);
|
|
2483
2737
|
const result = await this.request("/v1/plugins/run-buildin-tools", {
|
|
2484
2738
|
body: JSON.stringify({
|
|
2485
2739
|
params,
|
|
@@ -2493,7 +2747,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
2493
2747
|
method: "POST",
|
|
2494
2748
|
...options
|
|
2495
2749
|
});
|
|
2496
|
-
|
|
2750
|
+
log15("Built-in tool execution completed: %O", {
|
|
2497
2751
|
success: result.success,
|
|
2498
2752
|
toolName
|
|
2499
2753
|
});
|
|
@@ -2596,9 +2850,134 @@ var PluginsService = class extends BaseSDK {
|
|
|
2596
2850
|
}
|
|
2597
2851
|
};
|
|
2598
2852
|
|
|
2853
|
+
// src/market/services/SkillService.ts
|
|
2854
|
+
import debug16 from "debug";
|
|
2855
|
+
var log16 = debug16("lobe-market-sdk:skill");
|
|
2856
|
+
var SkillService = class extends BaseSDK {
|
|
2857
|
+
/**
|
|
2858
|
+
* Lists all available skill providers
|
|
2859
|
+
*
|
|
2860
|
+
* Returns a list of providers that can be connected via OAuth.
|
|
2861
|
+
* This is a public endpoint that doesn't require authentication.
|
|
2862
|
+
*
|
|
2863
|
+
* @param options - Optional request options
|
|
2864
|
+
* @returns Promise resolving to the list of available providers
|
|
2865
|
+
*/
|
|
2866
|
+
async listProviders(options) {
|
|
2867
|
+
var _a;
|
|
2868
|
+
log16("Listing skill providers");
|
|
2869
|
+
const result = await this.request("/v1/skill/providers", options);
|
|
2870
|
+
log16("Found %d skill providers", ((_a = result.providers) == null ? void 0 : _a.length) || 0);
|
|
2871
|
+
return result;
|
|
2872
|
+
}
|
|
2873
|
+
/**
|
|
2874
|
+
* Lists available tools for a specific provider
|
|
2875
|
+
*
|
|
2876
|
+
* Returns the tools/functions that can be called on the provider.
|
|
2877
|
+
* This is a public endpoint that doesn't require authentication.
|
|
2878
|
+
*
|
|
2879
|
+
* @param provider - The provider ID (e.g., 'linear', 'github')
|
|
2880
|
+
* @param options - Optional request options
|
|
2881
|
+
* @returns Promise resolving to the list of available tools
|
|
2882
|
+
*/
|
|
2883
|
+
async listTools(provider, options) {
|
|
2884
|
+
var _a;
|
|
2885
|
+
log16("Listing tools for provider: %s", provider);
|
|
2886
|
+
const result = await this.request(
|
|
2887
|
+
`/v1/skill/${encodeURIComponent(provider)}/tools`,
|
|
2888
|
+
options
|
|
2889
|
+
);
|
|
2890
|
+
log16("Found %d tools for provider %s", ((_a = result.tools) == null ? void 0 : _a.length) || 0, provider);
|
|
2891
|
+
return result;
|
|
2892
|
+
}
|
|
2893
|
+
/**
|
|
2894
|
+
* Gets details of a specific tool
|
|
2895
|
+
*
|
|
2896
|
+
* Returns detailed information about a tool including its input schema.
|
|
2897
|
+
* This is a public endpoint that doesn't require authentication.
|
|
2898
|
+
*
|
|
2899
|
+
* @param provider - The provider ID (e.g., 'linear', 'github')
|
|
2900
|
+
* @param toolName - The name of the tool
|
|
2901
|
+
* @param options - Optional request options
|
|
2902
|
+
* @returns Promise resolving to the tool details
|
|
2903
|
+
*/
|
|
2904
|
+
async getTool(provider, toolName, options) {
|
|
2905
|
+
var _a;
|
|
2906
|
+
log16("Getting tool %s from provider %s", toolName, provider);
|
|
2907
|
+
const result = await this.request(
|
|
2908
|
+
`/v1/skill/${encodeURIComponent(provider)}/tool/${encodeURIComponent(toolName)}`,
|
|
2909
|
+
options
|
|
2910
|
+
);
|
|
2911
|
+
log16("Retrieved tool: %s", (_a = result.tool) == null ? void 0 : _a.name);
|
|
2912
|
+
return result;
|
|
2913
|
+
}
|
|
2914
|
+
/**
|
|
2915
|
+
* Gets the connection status for a provider
|
|
2916
|
+
*
|
|
2917
|
+
* Checks if the authenticated user has an active OAuth connection to the provider.
|
|
2918
|
+
* Requires authentication.
|
|
2919
|
+
*
|
|
2920
|
+
* @param provider - The provider ID (e.g., 'linear', 'github')
|
|
2921
|
+
* @param options - Optional request options (must include authentication)
|
|
2922
|
+
* @returns Promise resolving to the connection status
|
|
2923
|
+
*/
|
|
2924
|
+
async getStatus(provider, options) {
|
|
2925
|
+
log16("Getting status for provider: %s", provider);
|
|
2926
|
+
const result = await this.request(
|
|
2927
|
+
`/v1/skill/${encodeURIComponent(provider)}/status`,
|
|
2928
|
+
options
|
|
2929
|
+
);
|
|
2930
|
+
log16("Provider %s status: connected=%s", provider, result.connected);
|
|
2931
|
+
return result;
|
|
2932
|
+
}
|
|
2933
|
+
/**
|
|
2934
|
+
* Calls a tool on a connected provider
|
|
2935
|
+
*
|
|
2936
|
+
* Executes a tool/function on the provider using the user's OAuth connection.
|
|
2937
|
+
* Requires authentication and an active OAuth connection to the provider.
|
|
2938
|
+
*
|
|
2939
|
+
* @param provider - The provider ID (e.g., 'linear', 'github')
|
|
2940
|
+
* @param params - The tool call parameters (tool name and arguments)
|
|
2941
|
+
* @param options - Optional request options (must include authentication)
|
|
2942
|
+
* @returns Promise resolving to the tool call result
|
|
2943
|
+
*
|
|
2944
|
+
* @example
|
|
2945
|
+
* ```typescript
|
|
2946
|
+
* // Create a Linear issue
|
|
2947
|
+
* const result = await sdk.skills.callTool('linear', {
|
|
2948
|
+
* tool: 'create_issue',
|
|
2949
|
+
* args: {
|
|
2950
|
+
* title: 'New feature request',
|
|
2951
|
+
* team: 'Engineering',
|
|
2952
|
+
* description: 'We need to implement...'
|
|
2953
|
+
* }
|
|
2954
|
+
* });
|
|
2955
|
+
* ```
|
|
2956
|
+
*/
|
|
2957
|
+
async callTool(provider, params, options) {
|
|
2958
|
+
log16("Calling tool %s on provider %s", params.tool, provider);
|
|
2959
|
+
const result = await this.request(
|
|
2960
|
+
`/v1/skill/${encodeURIComponent(provider)}/call`,
|
|
2961
|
+
{
|
|
2962
|
+
body: JSON.stringify({
|
|
2963
|
+
args: params.args || {},
|
|
2964
|
+
tool: params.tool
|
|
2965
|
+
}),
|
|
2966
|
+
headers: {
|
|
2967
|
+
"Content-Type": "application/json"
|
|
2968
|
+
},
|
|
2969
|
+
method: "POST",
|
|
2970
|
+
...options
|
|
2971
|
+
}
|
|
2972
|
+
);
|
|
2973
|
+
log16("Tool %s call completed: success=%s", params.tool, result.success);
|
|
2974
|
+
return result;
|
|
2975
|
+
}
|
|
2976
|
+
};
|
|
2977
|
+
|
|
2599
2978
|
// src/market/services/UserService.ts
|
|
2600
|
-
import
|
|
2601
|
-
var
|
|
2979
|
+
import debug17 from "debug";
|
|
2980
|
+
var log17 = debug17("lobe-market-sdk:user");
|
|
2602
2981
|
var UserService = class extends BaseSDK {
|
|
2603
2982
|
/**
|
|
2604
2983
|
* Retrieves user information by account ID or userName
|
|
@@ -2615,12 +2994,12 @@ var UserService = class extends BaseSDK {
|
|
|
2615
2994
|
const locale = params.locale || this.defaultLocale;
|
|
2616
2995
|
const queryParams = { locale };
|
|
2617
2996
|
const queryString = this.buildQueryString(queryParams);
|
|
2618
|
-
|
|
2997
|
+
log17("Getting user info: %O", { idOrUserName, ...params });
|
|
2619
2998
|
const result = await this.request(
|
|
2620
2999
|
`/v1/user/info/${idOrUserName}${queryString}`,
|
|
2621
3000
|
options
|
|
2622
3001
|
);
|
|
2623
|
-
|
|
3002
|
+
log17("User info successfully retrieved for: %s", idOrUserName);
|
|
2624
3003
|
return result;
|
|
2625
3004
|
}
|
|
2626
3005
|
/**
|
|
@@ -2635,7 +3014,7 @@ var UserService = class extends BaseSDK {
|
|
|
2635
3014
|
* @throws Error if userName is already taken or update fails
|
|
2636
3015
|
*/
|
|
2637
3016
|
async updateUserInfo(data, options) {
|
|
2638
|
-
|
|
3017
|
+
log17("Updating user info: %O", data);
|
|
2639
3018
|
const result = await this.request("/v1/user/update", {
|
|
2640
3019
|
body: JSON.stringify(data),
|
|
2641
3020
|
headers: {
|
|
@@ -2644,14 +3023,14 @@ var UserService = class extends BaseSDK {
|
|
|
2644
3023
|
method: "POST",
|
|
2645
3024
|
...options
|
|
2646
3025
|
});
|
|
2647
|
-
|
|
3026
|
+
log17("User info updated successfully");
|
|
2648
3027
|
return result;
|
|
2649
3028
|
}
|
|
2650
3029
|
};
|
|
2651
3030
|
|
|
2652
3031
|
// src/market/services/UserFollowService.ts
|
|
2653
|
-
import
|
|
2654
|
-
var
|
|
3032
|
+
import debug18 from "debug";
|
|
3033
|
+
var log18 = debug18("lobe-market-sdk:user-follow");
|
|
2655
3034
|
var UserFollowService = class extends BaseSDK {
|
|
2656
3035
|
/**
|
|
2657
3036
|
* Follow a user
|
|
@@ -2665,7 +3044,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
2665
3044
|
* @throws Error if already following or cannot follow yourself
|
|
2666
3045
|
*/
|
|
2667
3046
|
async follow(followingId, options) {
|
|
2668
|
-
|
|
3047
|
+
log18("Following user: %d", followingId);
|
|
2669
3048
|
const body = { followingId };
|
|
2670
3049
|
const result = await this.request("/v1/user/follows", {
|
|
2671
3050
|
body: JSON.stringify(body),
|
|
@@ -2675,7 +3054,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
2675
3054
|
method: "POST",
|
|
2676
3055
|
...options
|
|
2677
3056
|
});
|
|
2678
|
-
|
|
3057
|
+
log18("Successfully followed user: %d", followingId);
|
|
2679
3058
|
return result;
|
|
2680
3059
|
}
|
|
2681
3060
|
/**
|
|
@@ -2690,7 +3069,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
2690
3069
|
* @throws Error if follow relationship not found
|
|
2691
3070
|
*/
|
|
2692
3071
|
async unfollow(followingId, options) {
|
|
2693
|
-
|
|
3072
|
+
log18("Unfollowing user: %d", followingId);
|
|
2694
3073
|
const body = { followingId };
|
|
2695
3074
|
const result = await this.request("/v1/user/follows", {
|
|
2696
3075
|
body: JSON.stringify(body),
|
|
@@ -2700,7 +3079,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
2700
3079
|
method: "DELETE",
|
|
2701
3080
|
...options
|
|
2702
3081
|
});
|
|
2703
|
-
|
|
3082
|
+
log18("Successfully unfollowed user: %d", followingId);
|
|
2704
3083
|
return result;
|
|
2705
3084
|
}
|
|
2706
3085
|
/**
|
|
@@ -2714,13 +3093,13 @@ var UserFollowService = class extends BaseSDK {
|
|
|
2714
3093
|
* @returns Promise resolving to follow status (isFollowing, isMutual)
|
|
2715
3094
|
*/
|
|
2716
3095
|
async checkFollowStatus(targetUserId, options) {
|
|
2717
|
-
|
|
3096
|
+
log18("Checking follow status for user: %d", targetUserId);
|
|
2718
3097
|
const queryString = this.buildQueryString({ targetUserId: String(targetUserId) });
|
|
2719
3098
|
const result = await this.request(
|
|
2720
3099
|
`/v1/user/follows/check${queryString}`,
|
|
2721
3100
|
options
|
|
2722
3101
|
);
|
|
2723
|
-
|
|
3102
|
+
log18("Follow status retrieved: %O", result);
|
|
2724
3103
|
return result;
|
|
2725
3104
|
}
|
|
2726
3105
|
/**
|
|
@@ -2735,7 +3114,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
2735
3114
|
* @returns Promise resolving to list of following users
|
|
2736
3115
|
*/
|
|
2737
3116
|
async getFollowing(userId, params = {}, options) {
|
|
2738
|
-
|
|
3117
|
+
log18("Getting following list for user: %d", userId);
|
|
2739
3118
|
const queryParams = {};
|
|
2740
3119
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
2741
3120
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -2744,7 +3123,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
2744
3123
|
`/v1/user/follows/${userId}/following${queryString}`,
|
|
2745
3124
|
options
|
|
2746
3125
|
);
|
|
2747
|
-
|
|
3126
|
+
log18("Following list retrieved for user: %d", userId);
|
|
2748
3127
|
return result;
|
|
2749
3128
|
}
|
|
2750
3129
|
/**
|
|
@@ -2759,7 +3138,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
2759
3138
|
* @returns Promise resolving to list of followers
|
|
2760
3139
|
*/
|
|
2761
3140
|
async getFollowers(userId, params = {}, options) {
|
|
2762
|
-
|
|
3141
|
+
log18("Getting followers list for user: %d", userId);
|
|
2763
3142
|
const queryParams = {};
|
|
2764
3143
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
2765
3144
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -2768,14 +3147,14 @@ var UserFollowService = class extends BaseSDK {
|
|
|
2768
3147
|
`/v1/user/follows/${userId}/followers${queryString}`,
|
|
2769
3148
|
options
|
|
2770
3149
|
);
|
|
2771
|
-
|
|
3150
|
+
log18("Followers list retrieved for user: %d", userId);
|
|
2772
3151
|
return result;
|
|
2773
3152
|
}
|
|
2774
3153
|
};
|
|
2775
3154
|
|
|
2776
3155
|
// src/market/services/UserFavoriteService.ts
|
|
2777
|
-
import
|
|
2778
|
-
var
|
|
3156
|
+
import debug19 from "debug";
|
|
3157
|
+
var log19 = debug19("lobe-market-sdk:user-favorite");
|
|
2779
3158
|
var UserFavoriteService = class extends BaseSDK {
|
|
2780
3159
|
/**
|
|
2781
3160
|
* Add to favorites
|
|
@@ -2790,7 +3169,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
2790
3169
|
* @throws Error if already in favorites
|
|
2791
3170
|
*/
|
|
2792
3171
|
async addFavorite(targetType, targetId, options) {
|
|
2793
|
-
|
|
3172
|
+
log19("Adding favorite: %s %d", targetType, targetId);
|
|
2794
3173
|
const body = { targetId, targetType };
|
|
2795
3174
|
const result = await this.request("/v1/user/favorites", {
|
|
2796
3175
|
body: JSON.stringify(body),
|
|
@@ -2800,7 +3179,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
2800
3179
|
method: "POST",
|
|
2801
3180
|
...options
|
|
2802
3181
|
});
|
|
2803
|
-
|
|
3182
|
+
log19("Successfully added favorite: %s %d", targetType, targetId);
|
|
2804
3183
|
return result;
|
|
2805
3184
|
}
|
|
2806
3185
|
/**
|
|
@@ -2816,7 +3195,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
2816
3195
|
* @throws Error if favorite not found
|
|
2817
3196
|
*/
|
|
2818
3197
|
async removeFavorite(targetType, targetId, options) {
|
|
2819
|
-
|
|
3198
|
+
log19("Removing favorite: %s %d", targetType, targetId);
|
|
2820
3199
|
const body = { targetId, targetType };
|
|
2821
3200
|
const result = await this.request("/v1/user/favorites", {
|
|
2822
3201
|
body: JSON.stringify(body),
|
|
@@ -2826,7 +3205,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
2826
3205
|
method: "DELETE",
|
|
2827
3206
|
...options
|
|
2828
3207
|
});
|
|
2829
|
-
|
|
3208
|
+
log19("Successfully removed favorite: %s %d", targetType, targetId);
|
|
2830
3209
|
return result;
|
|
2831
3210
|
}
|
|
2832
3211
|
/**
|
|
@@ -2841,7 +3220,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
2841
3220
|
* @returns Promise resolving to favorite status
|
|
2842
3221
|
*/
|
|
2843
3222
|
async checkFavorite(targetType, targetId, options) {
|
|
2844
|
-
|
|
3223
|
+
log19("Checking favorite status: %s %d", targetType, targetId);
|
|
2845
3224
|
const queryString = this.buildQueryString({
|
|
2846
3225
|
targetId: String(targetId),
|
|
2847
3226
|
targetType
|
|
@@ -2850,7 +3229,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
2850
3229
|
`/v1/user/favorites/check${queryString}`,
|
|
2851
3230
|
options
|
|
2852
3231
|
);
|
|
2853
|
-
|
|
3232
|
+
log19("Favorite status retrieved: %O", result);
|
|
2854
3233
|
return result;
|
|
2855
3234
|
}
|
|
2856
3235
|
/**
|
|
@@ -2864,7 +3243,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
2864
3243
|
* @returns Promise resolving to list of favorites
|
|
2865
3244
|
*/
|
|
2866
3245
|
async getMyFavorites(params = {}, options) {
|
|
2867
|
-
|
|
3246
|
+
log19("Getting my favorites: %O", params);
|
|
2868
3247
|
const queryParams = {};
|
|
2869
3248
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
2870
3249
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -2874,7 +3253,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
2874
3253
|
`/v1/user/favorites/me${queryString}`,
|
|
2875
3254
|
options
|
|
2876
3255
|
);
|
|
2877
|
-
|
|
3256
|
+
log19("My favorites retrieved");
|
|
2878
3257
|
return result;
|
|
2879
3258
|
}
|
|
2880
3259
|
/**
|
|
@@ -2889,7 +3268,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
2889
3268
|
* @returns Promise resolving to list of favorites
|
|
2890
3269
|
*/
|
|
2891
3270
|
async getUserFavorites(userId, params = {}, options) {
|
|
2892
|
-
|
|
3271
|
+
log19("Getting favorites for user: %d", userId);
|
|
2893
3272
|
const queryParams = {};
|
|
2894
3273
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
2895
3274
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -2899,7 +3278,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
2899
3278
|
`/v1/user/favorites/${userId}${queryString}`,
|
|
2900
3279
|
options
|
|
2901
3280
|
);
|
|
2902
|
-
|
|
3281
|
+
log19("Favorites retrieved for user: %d", userId);
|
|
2903
3282
|
return result;
|
|
2904
3283
|
}
|
|
2905
3284
|
/**
|
|
@@ -2914,7 +3293,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
2914
3293
|
* @returns Promise resolving to list of favorite agents
|
|
2915
3294
|
*/
|
|
2916
3295
|
async getUserFavoriteAgents(userId, params = {}, options) {
|
|
2917
|
-
|
|
3296
|
+
log19("Getting favorite agents for user: %d", userId);
|
|
2918
3297
|
const queryParams = {};
|
|
2919
3298
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
2920
3299
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -2923,7 +3302,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
2923
3302
|
`/v1/user/favorites/${userId}/agents${queryString}`,
|
|
2924
3303
|
options
|
|
2925
3304
|
);
|
|
2926
|
-
|
|
3305
|
+
log19("Favorite agents retrieved for user: %d", userId);
|
|
2927
3306
|
return result;
|
|
2928
3307
|
}
|
|
2929
3308
|
/**
|
|
@@ -2938,7 +3317,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
2938
3317
|
* @returns Promise resolving to list of favorite plugins
|
|
2939
3318
|
*/
|
|
2940
3319
|
async getUserFavoritePlugins(userId, params = {}, options) {
|
|
2941
|
-
|
|
3320
|
+
log19("Getting favorite plugins for user: %d", userId);
|
|
2942
3321
|
const queryParams = {};
|
|
2943
3322
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
2944
3323
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -2947,14 +3326,14 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
2947
3326
|
`/v1/user/favorites/${userId}/plugins${queryString}`,
|
|
2948
3327
|
options
|
|
2949
3328
|
);
|
|
2950
|
-
|
|
3329
|
+
log19("Favorite plugins retrieved for user: %d", userId);
|
|
2951
3330
|
return result;
|
|
2952
3331
|
}
|
|
2953
3332
|
};
|
|
2954
3333
|
|
|
2955
3334
|
// src/market/services/UserLikeService.ts
|
|
2956
|
-
import
|
|
2957
|
-
var
|
|
3335
|
+
import debug20 from "debug";
|
|
3336
|
+
var log20 = debug20("lobe-market-sdk:user-like");
|
|
2958
3337
|
var UserLikeService = class extends BaseSDK {
|
|
2959
3338
|
/**
|
|
2960
3339
|
* Like content
|
|
@@ -2969,7 +3348,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
2969
3348
|
* @throws Error if already liked
|
|
2970
3349
|
*/
|
|
2971
3350
|
async like(targetType, targetId, options) {
|
|
2972
|
-
|
|
3351
|
+
log20("Liking: %s %d", targetType, targetId);
|
|
2973
3352
|
const body = { targetId, targetType };
|
|
2974
3353
|
const result = await this.request("/v1/user/likes", {
|
|
2975
3354
|
body: JSON.stringify(body),
|
|
@@ -2979,7 +3358,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
2979
3358
|
method: "POST",
|
|
2980
3359
|
...options
|
|
2981
3360
|
});
|
|
2982
|
-
|
|
3361
|
+
log20("Successfully liked: %s %d", targetType, targetId);
|
|
2983
3362
|
return result;
|
|
2984
3363
|
}
|
|
2985
3364
|
/**
|
|
@@ -2995,7 +3374,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
2995
3374
|
* @throws Error if like not found
|
|
2996
3375
|
*/
|
|
2997
3376
|
async unlike(targetType, targetId, options) {
|
|
2998
|
-
|
|
3377
|
+
log20("Unliking: %s %d", targetType, targetId);
|
|
2999
3378
|
const body = { targetId, targetType };
|
|
3000
3379
|
const result = await this.request("/v1/user/likes", {
|
|
3001
3380
|
body: JSON.stringify(body),
|
|
@@ -3005,7 +3384,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
3005
3384
|
method: "DELETE",
|
|
3006
3385
|
...options
|
|
3007
3386
|
});
|
|
3008
|
-
|
|
3387
|
+
log20("Successfully unliked: %s %d", targetType, targetId);
|
|
3009
3388
|
return result;
|
|
3010
3389
|
}
|
|
3011
3390
|
/**
|
|
@@ -3020,7 +3399,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
3020
3399
|
* @returns Promise resolving to toggle response with new like status
|
|
3021
3400
|
*/
|
|
3022
3401
|
async toggleLike(targetType, targetId, options) {
|
|
3023
|
-
|
|
3402
|
+
log20("Toggling like: %s %d", targetType, targetId);
|
|
3024
3403
|
const body = { targetId, targetType };
|
|
3025
3404
|
const result = await this.request("/v1/user/likes/toggle", {
|
|
3026
3405
|
body: JSON.stringify(body),
|
|
@@ -3030,7 +3409,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
3030
3409
|
method: "POST",
|
|
3031
3410
|
...options
|
|
3032
3411
|
});
|
|
3033
|
-
|
|
3412
|
+
log20("Like toggled, new status: %O", result);
|
|
3034
3413
|
return result;
|
|
3035
3414
|
}
|
|
3036
3415
|
/**
|
|
@@ -3045,7 +3424,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
3045
3424
|
* @returns Promise resolving to like status
|
|
3046
3425
|
*/
|
|
3047
3426
|
async checkLike(targetType, targetId, options) {
|
|
3048
|
-
|
|
3427
|
+
log20("Checking like status: %s %d", targetType, targetId);
|
|
3049
3428
|
const queryString = this.buildQueryString({
|
|
3050
3429
|
targetId: String(targetId),
|
|
3051
3430
|
targetType
|
|
@@ -3054,7 +3433,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
3054
3433
|
`/v1/user/likes/check${queryString}`,
|
|
3055
3434
|
options
|
|
3056
3435
|
);
|
|
3057
|
-
|
|
3436
|
+
log20("Like status retrieved: %O", result);
|
|
3058
3437
|
return result;
|
|
3059
3438
|
}
|
|
3060
3439
|
/**
|
|
@@ -3068,7 +3447,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
3068
3447
|
* @returns Promise resolving to list of likes
|
|
3069
3448
|
*/
|
|
3070
3449
|
async getMyLikes(params = {}, options) {
|
|
3071
|
-
|
|
3450
|
+
log20("Getting my likes: %O", params);
|
|
3072
3451
|
const queryParams = {};
|
|
3073
3452
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
3074
3453
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -3078,7 +3457,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
3078
3457
|
`/v1/user/likes/me${queryString}`,
|
|
3079
3458
|
options
|
|
3080
3459
|
);
|
|
3081
|
-
|
|
3460
|
+
log20("My likes retrieved");
|
|
3082
3461
|
return result;
|
|
3083
3462
|
}
|
|
3084
3463
|
/**
|
|
@@ -3093,7 +3472,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
3093
3472
|
* @returns Promise resolving to list of likes
|
|
3094
3473
|
*/
|
|
3095
3474
|
async getUserLikes(userId, params = {}, options) {
|
|
3096
|
-
|
|
3475
|
+
log20("Getting likes for user: %d", userId);
|
|
3097
3476
|
const queryParams = {};
|
|
3098
3477
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
3099
3478
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -3103,7 +3482,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
3103
3482
|
`/v1/user/likes/${userId}${queryString}`,
|
|
3104
3483
|
options
|
|
3105
3484
|
);
|
|
3106
|
-
|
|
3485
|
+
log20("Likes retrieved for user: %d", userId);
|
|
3107
3486
|
return result;
|
|
3108
3487
|
}
|
|
3109
3488
|
/**
|
|
@@ -3118,7 +3497,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
3118
3497
|
* @returns Promise resolving to list of liked agents
|
|
3119
3498
|
*/
|
|
3120
3499
|
async getUserLikedAgents(userId, params = {}, options) {
|
|
3121
|
-
|
|
3500
|
+
log20("Getting liked agents for user: %d", userId);
|
|
3122
3501
|
const queryParams = {};
|
|
3123
3502
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
3124
3503
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -3127,7 +3506,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
3127
3506
|
`/v1/user/likes/${userId}/agents${queryString}`,
|
|
3128
3507
|
options
|
|
3129
3508
|
);
|
|
3130
|
-
|
|
3509
|
+
log20("Liked agents retrieved for user: %d", userId);
|
|
3131
3510
|
return result;
|
|
3132
3511
|
}
|
|
3133
3512
|
/**
|
|
@@ -3142,7 +3521,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
3142
3521
|
* @returns Promise resolving to list of liked plugins
|
|
3143
3522
|
*/
|
|
3144
3523
|
async getUserLikedPlugins(userId, params = {}, options) {
|
|
3145
|
-
|
|
3524
|
+
log20("Getting liked plugins for user: %d", userId);
|
|
3146
3525
|
const queryParams = {};
|
|
3147
3526
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
3148
3527
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -3151,13 +3530,13 @@ var UserLikeService = class extends BaseSDK {
|
|
|
3151
3530
|
`/v1/user/likes/${userId}/plugins${queryString}`,
|
|
3152
3531
|
options
|
|
3153
3532
|
);
|
|
3154
|
-
|
|
3533
|
+
log20("Liked plugins retrieved for user: %d", userId);
|
|
3155
3534
|
return result;
|
|
3156
3535
|
}
|
|
3157
3536
|
};
|
|
3158
3537
|
|
|
3159
3538
|
// src/market/market-sdk.ts
|
|
3160
|
-
var
|
|
3539
|
+
var log21 = debug21("lobe-market-sdk");
|
|
3161
3540
|
var MarketSDK = class extends BaseSDK {
|
|
3162
3541
|
/**
|
|
3163
3542
|
* Creates a new MarketSDK instance
|
|
@@ -3170,15 +3549,17 @@ var MarketSDK = class extends BaseSDK {
|
|
|
3170
3549
|
tokenExpiry: void 0
|
|
3171
3550
|
};
|
|
3172
3551
|
super(options, void 0, sharedTokenState);
|
|
3173
|
-
|
|
3552
|
+
log21("MarketSDK instance created");
|
|
3174
3553
|
this.agents = new AgentService2(options, this.headers, sharedTokenState);
|
|
3175
3554
|
this.auth = new AuthService(options, this.headers, sharedTokenState);
|
|
3555
|
+
this.connect = new ConnectService(options, this.headers, sharedTokenState);
|
|
3176
3556
|
this.plugins = new PluginsService(options, this.headers, sharedTokenState);
|
|
3177
3557
|
this.user = new UserService(options, this.headers, sharedTokenState);
|
|
3178
3558
|
this.follows = new UserFollowService(options, this.headers, sharedTokenState);
|
|
3179
3559
|
this.favorites = new UserFavoriteService(options, this.headers, sharedTokenState);
|
|
3180
3560
|
this.likes = new UserLikeService(options, this.headers, sharedTokenState);
|
|
3181
3561
|
this.feedback = new FeedbackService(options, this.headers, sharedTokenState);
|
|
3562
|
+
this.skills = new SkillService(options, this.headers, sharedTokenState);
|
|
3182
3563
|
this.discovery = new DiscoveryService(options, this.headers, sharedTokenState);
|
|
3183
3564
|
}
|
|
3184
3565
|
/**
|
|
@@ -3205,7 +3586,7 @@ var MarketSDK = class extends BaseSDK {
|
|
|
3205
3586
|
* @deprecated Use auth.registerClient() instead
|
|
3206
3587
|
*/
|
|
3207
3588
|
async registerClient(request) {
|
|
3208
|
-
|
|
3589
|
+
log21("Registering client (deprecated method, use auth.registerClient): %s", request.clientName);
|
|
3209
3590
|
return this.auth.registerClient(request);
|
|
3210
3591
|
}
|
|
3211
3592
|
};
|