@lobehub/market-sdk 0.46.1 → 0.47.0
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 +127 -6
- package/dist/index.mjs +608 -423
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -9,10 +9,14 @@ import urlJoin from "url-join";
|
|
|
9
9
|
|
|
10
10
|
// src/core/MarketAPIError.ts
|
|
11
11
|
var normalizeErrorDetails = (errorBody) => {
|
|
12
|
+
var _a;
|
|
12
13
|
if (!errorBody) return void 0;
|
|
13
14
|
if (typeof errorBody.error === "object" && errorBody.error !== null) {
|
|
14
15
|
return errorBody.error;
|
|
15
16
|
}
|
|
17
|
+
if (typeof errorBody.error === "string" && typeof errorBody.error_description === "string") {
|
|
18
|
+
return { code: (_a = errorBody.code) != null ? _a : errorBody.error, message: errorBody.error_description };
|
|
19
|
+
}
|
|
16
20
|
if (typeof errorBody.error === "string") {
|
|
17
21
|
return {
|
|
18
22
|
...errorBody.code ? { code: errorBody.code } : {},
|
|
@@ -1216,6 +1220,41 @@ var PluginService = class extends BaseSDK {
|
|
|
1216
1220
|
log5("Version set as latest successfully");
|
|
1217
1221
|
return result;
|
|
1218
1222
|
}
|
|
1223
|
+
/**
|
|
1224
|
+
* Takes a plugin down for support.
|
|
1225
|
+
*
|
|
1226
|
+
* `unpublish` hides the plugin and keeps it (undo with `restorePlugin`);
|
|
1227
|
+
* `purge` (GDPR erasure) deletes everything about it except a suppression
|
|
1228
|
+
* record. Either way crawls, imports and owner publishes skip its source.
|
|
1229
|
+
*
|
|
1230
|
+
* @param idOrIdentifier - Plugin ID or identifier
|
|
1231
|
+
* @param data - Mode, reason and optional reference / operator / scope
|
|
1232
|
+
* @returns The takedown marker and, for `purge`, the rows removed per table
|
|
1233
|
+
*/
|
|
1234
|
+
async takedownPlugin(idOrIdentifier, data) {
|
|
1235
|
+
log5("Taking down plugin: %s (%s)", idOrIdentifier, data.mode);
|
|
1236
|
+
const result = await this.request(
|
|
1237
|
+
`/admin/plugins/${encodeURIComponent(String(idOrIdentifier))}/takedown`,
|
|
1238
|
+
{ body: JSON.stringify(data), method: "POST" }
|
|
1239
|
+
);
|
|
1240
|
+
log5("Plugin taken down: %s", result.identifier);
|
|
1241
|
+
return result;
|
|
1242
|
+
}
|
|
1243
|
+
/**
|
|
1244
|
+
* Restores a plugin taken down with `unpublish`. A purged plugin cannot be restored (409).
|
|
1245
|
+
*
|
|
1246
|
+
* @param idOrIdentifier - Plugin ID or identifier
|
|
1247
|
+
* @returns The restored status and visibility
|
|
1248
|
+
*/
|
|
1249
|
+
async restorePlugin(idOrIdentifier) {
|
|
1250
|
+
log5("Restoring plugin: %s", idOrIdentifier);
|
|
1251
|
+
const result = await this.request(
|
|
1252
|
+
`/admin/plugins/${encodeURIComponent(String(idOrIdentifier))}/restore`,
|
|
1253
|
+
{ method: "POST" }
|
|
1254
|
+
);
|
|
1255
|
+
log5("Plugin restored: %s", result.identifier);
|
|
1256
|
+
return result;
|
|
1257
|
+
}
|
|
1219
1258
|
/**
|
|
1220
1259
|
* Updates plugin visibility
|
|
1221
1260
|
*
|
|
@@ -1789,6 +1828,40 @@ var SkillService = class extends BaseSDK {
|
|
|
1789
1828
|
log10("Updated skill: %d", id);
|
|
1790
1829
|
return result;
|
|
1791
1830
|
}
|
|
1831
|
+
/**
|
|
1832
|
+
* Takes a skill down for support.
|
|
1833
|
+
*
|
|
1834
|
+
* `unpublish` hides the skill and keeps it (undo with `restoreSkill`);
|
|
1835
|
+
* `purge` (GDPR erasure) deletes everything about it except a suppression
|
|
1836
|
+
* record. Either way imports skip its source.
|
|
1837
|
+
*
|
|
1838
|
+
* @param id - Skill database ID
|
|
1839
|
+
* @param data - Mode, reason and optional reference / operator / scope
|
|
1840
|
+
* @returns The takedown marker and, for `purge`, the rows removed per table
|
|
1841
|
+
*/
|
|
1842
|
+
async takedownSkill(id, data) {
|
|
1843
|
+
log10("Taking down skill: %d (%s)", id, data.mode);
|
|
1844
|
+
const result = await this.request(`/admin/skills/${id}/takedown`, {
|
|
1845
|
+
body: JSON.stringify(data),
|
|
1846
|
+
method: "POST"
|
|
1847
|
+
});
|
|
1848
|
+
log10("Skill taken down: %s", result.identifier);
|
|
1849
|
+
return result;
|
|
1850
|
+
}
|
|
1851
|
+
/**
|
|
1852
|
+
* Restores a skill taken down with `unpublish`. A purged skill cannot be restored (409).
|
|
1853
|
+
*
|
|
1854
|
+
* @param id - Skill database ID
|
|
1855
|
+
* @returns The restored status and visibility
|
|
1856
|
+
*/
|
|
1857
|
+
async restoreSkill(id) {
|
|
1858
|
+
log10("Restoring skill: %d", id);
|
|
1859
|
+
const result = await this.request(`/admin/skills/${id}/restore`, {
|
|
1860
|
+
method: "POST"
|
|
1861
|
+
});
|
|
1862
|
+
log10("Skill restored: %s", result.identifier);
|
|
1863
|
+
return result;
|
|
1864
|
+
}
|
|
1792
1865
|
/**
|
|
1793
1866
|
* Retrieve Skills with Admin API status and visibility fields.
|
|
1794
1867
|
*
|
|
@@ -2106,11 +2179,27 @@ var MarketAdmin = class extends BaseSDK {
|
|
|
2106
2179
|
|
|
2107
2180
|
// src/market/market-sdk.ts
|
|
2108
2181
|
import { getAssetImagePath, getAssetInitialPath } from "@lobehub/market-types";
|
|
2109
|
-
import
|
|
2182
|
+
import debug40 from "debug";
|
|
2110
2183
|
|
|
2111
|
-
// src/market/services/
|
|
2184
|
+
// src/market/services/AccessService.ts
|
|
2112
2185
|
import debug15 from "debug";
|
|
2113
|
-
var log15 = debug15("lobe-market-sdk:
|
|
2186
|
+
var log15 = debug15("lobe-market-sdk:market:access");
|
|
2187
|
+
var AccessService = class extends BaseSDK {
|
|
2188
|
+
/** Returns the subset of `items` the member can use; requires a trusted-client token. */
|
|
2189
|
+
async check(items, options) {
|
|
2190
|
+
log15("Checking availability of %d assets", items.length);
|
|
2191
|
+
return this.request("/v1/access/check", {
|
|
2192
|
+
body: JSON.stringify({ items }),
|
|
2193
|
+
headers: { "Content-Type": "application/json" },
|
|
2194
|
+
method: "POST",
|
|
2195
|
+
...options
|
|
2196
|
+
});
|
|
2197
|
+
}
|
|
2198
|
+
};
|
|
2199
|
+
|
|
2200
|
+
// src/market/services/AgentProfileService.ts
|
|
2201
|
+
import debug16 from "debug";
|
|
2202
|
+
var log16 = debug16("lobe-market-sdk:agent-profile");
|
|
2114
2203
|
var AgentProfileService = class extends BaseSDK {
|
|
2115
2204
|
/**
|
|
2116
2205
|
* Retrieves the current agent's profile
|
|
@@ -2122,9 +2211,9 @@ var AgentProfileService = class extends BaseSDK {
|
|
|
2122
2211
|
* @returns Promise resolving to the agent profile response
|
|
2123
2212
|
*/
|
|
2124
2213
|
async getProfile(options) {
|
|
2125
|
-
|
|
2214
|
+
log16("Getting agent profile");
|
|
2126
2215
|
const result = await this.request("/v1/agent/profile", options);
|
|
2127
|
-
|
|
2216
|
+
log16("Agent profile retrieved: id=%d, identifier=%s", result.agent.id, result.agent.identifier);
|
|
2128
2217
|
return result;
|
|
2129
2218
|
}
|
|
2130
2219
|
/**
|
|
@@ -2138,7 +2227,7 @@ var AgentProfileService = class extends BaseSDK {
|
|
|
2138
2227
|
* @returns Promise resolving to the updated agent profile response
|
|
2139
2228
|
*/
|
|
2140
2229
|
async updateProfile(data, options) {
|
|
2141
|
-
|
|
2230
|
+
log16("Updating agent profile: %O", data);
|
|
2142
2231
|
const result = await this.request("/v1/agent/profile", {
|
|
2143
2232
|
body: JSON.stringify(data),
|
|
2144
2233
|
headers: {
|
|
@@ -2147,14 +2236,14 @@ var AgentProfileService = class extends BaseSDK {
|
|
|
2147
2236
|
method: "PATCH",
|
|
2148
2237
|
...options
|
|
2149
2238
|
});
|
|
2150
|
-
|
|
2239
|
+
log16("Agent profile updated: id=%d, name=%s", result.agent.id, result.agent.name);
|
|
2151
2240
|
return result;
|
|
2152
2241
|
}
|
|
2153
2242
|
};
|
|
2154
2243
|
|
|
2155
2244
|
// src/market/services/AgentService.ts
|
|
2156
|
-
import
|
|
2157
|
-
var
|
|
2245
|
+
import debug17 from "debug";
|
|
2246
|
+
var log17 = debug17("lobe-market-sdk:agents");
|
|
2158
2247
|
var AgentService2 = class extends BaseSDK {
|
|
2159
2248
|
/**
|
|
2160
2249
|
* Retrieves a list of agents from the marketplace
|
|
@@ -2171,9 +2260,9 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2171
2260
|
const locale = params.locale || this.defaultLocale;
|
|
2172
2261
|
const queryParams = { ...params, locale };
|
|
2173
2262
|
const queryString = this.buildQueryString(queryParams);
|
|
2174
|
-
|
|
2263
|
+
log17("Getting agent list: %O", queryParams);
|
|
2175
2264
|
const result = await this.request(`/v1/agents${queryString}`, options);
|
|
2176
|
-
|
|
2265
|
+
log17("Retrieved %d agents", result.items.length);
|
|
2177
2266
|
return result;
|
|
2178
2267
|
}
|
|
2179
2268
|
/**
|
|
@@ -2190,9 +2279,9 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2190
2279
|
const locale = params.locale || this.defaultLocale;
|
|
2191
2280
|
const queryParams = { ...params, locale };
|
|
2192
2281
|
const queryString = this.buildQueryString(queryParams);
|
|
2193
|
-
|
|
2282
|
+
log17("Getting own agent list: %O", queryParams);
|
|
2194
2283
|
const result = await this.request(`/v1/agents/own${queryString}`, options);
|
|
2195
|
-
|
|
2284
|
+
log17("Retrieved %d own agents", result.items.length);
|
|
2196
2285
|
return result;
|
|
2197
2286
|
}
|
|
2198
2287
|
/**
|
|
@@ -2213,12 +2302,12 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2213
2302
|
queryParams.version = params.version.toString();
|
|
2214
2303
|
}
|
|
2215
2304
|
const queryString = this.buildQueryString(queryParams);
|
|
2216
|
-
|
|
2305
|
+
log17("Getting agent detail: %O", { id, ...params });
|
|
2217
2306
|
const result = await this.request(
|
|
2218
2307
|
`/v1/agents/detail/${id}${queryString}`,
|
|
2219
2308
|
options
|
|
2220
2309
|
);
|
|
2221
|
-
|
|
2310
|
+
log17("Agent detail successfully retrieved: %s", id);
|
|
2222
2311
|
return result;
|
|
2223
2312
|
}
|
|
2224
2313
|
/**
|
|
@@ -2234,12 +2323,12 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2234
2323
|
* @returns Promise resolving to an array containing identifiers array and last modified time
|
|
2235
2324
|
*/
|
|
2236
2325
|
async getPublishedIdentifiers(options) {
|
|
2237
|
-
|
|
2326
|
+
log17("Getting published agent identifiers");
|
|
2238
2327
|
const result = await this.request(
|
|
2239
2328
|
"/v1/agents/identifiers",
|
|
2240
2329
|
options
|
|
2241
2330
|
);
|
|
2242
|
-
|
|
2331
|
+
log17("Retrieved %d published agent identifiers", result.length);
|
|
2243
2332
|
return result;
|
|
2244
2333
|
}
|
|
2245
2334
|
/**
|
|
@@ -2250,9 +2339,9 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2250
2339
|
*/
|
|
2251
2340
|
async getSitemap(params = {}, options) {
|
|
2252
2341
|
const queryString = this.buildQueryString(params);
|
|
2253
|
-
|
|
2342
|
+
log17("Getting agent sitemap%s", queryString);
|
|
2254
2343
|
const result = await this.request(`/v1/agents/sitemap${queryString}`, options);
|
|
2255
|
-
|
|
2344
|
+
log17(
|
|
2256
2345
|
"Retrieved agent sitemap page %d/%d (%d items)",
|
|
2257
2346
|
result.currentPage,
|
|
2258
2347
|
result.totalPages,
|
|
@@ -2275,12 +2364,12 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2275
2364
|
const locale = params.locale || this.defaultLocale;
|
|
2276
2365
|
const queryParams = { ...params, locale };
|
|
2277
2366
|
const queryString = this.buildQueryString(queryParams);
|
|
2278
|
-
|
|
2367
|
+
log17("Getting agent categories: %O", queryParams);
|
|
2279
2368
|
const result = await this.request(
|
|
2280
2369
|
`/v1/agents/categories${queryString}`,
|
|
2281
2370
|
options
|
|
2282
2371
|
);
|
|
2283
|
-
|
|
2372
|
+
log17("Retrieved %d categories", result.length);
|
|
2284
2373
|
return result;
|
|
2285
2374
|
}
|
|
2286
2375
|
/**
|
|
@@ -2294,7 +2383,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2294
2383
|
* @returns Promise resolving to the upload response
|
|
2295
2384
|
*/
|
|
2296
2385
|
async uploadAgent(agentData, options) {
|
|
2297
|
-
|
|
2386
|
+
log17("Uploading agent: %s@%s", agentData.agentIdentifier, agentData.version.version);
|
|
2298
2387
|
const result = await this.request("/v1/agents/upload", {
|
|
2299
2388
|
body: JSON.stringify(agentData),
|
|
2300
2389
|
headers: {
|
|
@@ -2303,7 +2392,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2303
2392
|
method: "POST",
|
|
2304
2393
|
...options
|
|
2305
2394
|
});
|
|
2306
|
-
|
|
2395
|
+
log17("Agent uploaded successfully: %O", result);
|
|
2307
2396
|
return result;
|
|
2308
2397
|
}
|
|
2309
2398
|
/**
|
|
@@ -2314,7 +2403,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2314
2403
|
* @returns Promise resolving to the created agent response
|
|
2315
2404
|
*/
|
|
2316
2405
|
async createAgent(agentData, options) {
|
|
2317
|
-
|
|
2406
|
+
log17("Creating agent: %s", agentData.identifier);
|
|
2318
2407
|
const result = await this.request("/v1/agents/create", {
|
|
2319
2408
|
body: JSON.stringify(agentData),
|
|
2320
2409
|
headers: {
|
|
@@ -2323,7 +2412,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2323
2412
|
method: "POST",
|
|
2324
2413
|
...options
|
|
2325
2414
|
});
|
|
2326
|
-
|
|
2415
|
+
log17("Agent created successfully: %O", result);
|
|
2327
2416
|
return result;
|
|
2328
2417
|
}
|
|
2329
2418
|
/**
|
|
@@ -2334,7 +2423,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2334
2423
|
* @returns Promise resolving to the created version response
|
|
2335
2424
|
*/
|
|
2336
2425
|
async createAgentVersion(versionData, options) {
|
|
2337
|
-
|
|
2426
|
+
log17("Creating agent version: %s", versionData.identifier);
|
|
2338
2427
|
const result = await this.request("/v1/agents/version/create", {
|
|
2339
2428
|
body: JSON.stringify(versionData),
|
|
2340
2429
|
headers: {
|
|
@@ -2343,7 +2432,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2343
2432
|
method: "POST",
|
|
2344
2433
|
...options
|
|
2345
2434
|
});
|
|
2346
|
-
|
|
2435
|
+
log17("Agent version created successfully: %O", result);
|
|
2347
2436
|
return result;
|
|
2348
2437
|
}
|
|
2349
2438
|
/**
|
|
@@ -2354,7 +2443,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2354
2443
|
* @returns Promise resolving to the modified agent response
|
|
2355
2444
|
*/
|
|
2356
2445
|
async modifyAgent(agentData, options) {
|
|
2357
|
-
|
|
2446
|
+
log17("Modifying agent: %s", agentData.identifier);
|
|
2358
2447
|
const result = await this.request("/v1/agents/modify", {
|
|
2359
2448
|
body: JSON.stringify(agentData),
|
|
2360
2449
|
headers: {
|
|
@@ -2363,7 +2452,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2363
2452
|
method: "POST",
|
|
2364
2453
|
...options
|
|
2365
2454
|
});
|
|
2366
|
-
|
|
2455
|
+
log17("Agent modified successfully: %O", result);
|
|
2367
2456
|
return result;
|
|
2368
2457
|
}
|
|
2369
2458
|
/**
|
|
@@ -2374,7 +2463,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2374
2463
|
* @returns Promise resolving to the modified version response
|
|
2375
2464
|
*/
|
|
2376
2465
|
async modifyAgentVersion(versionData, options) {
|
|
2377
|
-
|
|
2466
|
+
log17("Modifying agent version: %s@%s", versionData.identifier, versionData.version);
|
|
2378
2467
|
const result = await this.request("/v1/agents/version/modify", {
|
|
2379
2468
|
body: JSON.stringify(versionData),
|
|
2380
2469
|
headers: {
|
|
@@ -2383,7 +2472,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2383
2472
|
method: "POST",
|
|
2384
2473
|
...options
|
|
2385
2474
|
});
|
|
2386
|
-
|
|
2475
|
+
log17("Agent version modified successfully: %O", result);
|
|
2387
2476
|
return result;
|
|
2388
2477
|
}
|
|
2389
2478
|
/**
|
|
@@ -2394,13 +2483,13 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2394
2483
|
* @returns Promise resolving to true if agent exists, false otherwise
|
|
2395
2484
|
*/
|
|
2396
2485
|
async checkAgentExists(identifier, options) {
|
|
2397
|
-
|
|
2486
|
+
log17("Checking if agent exists: %s", identifier);
|
|
2398
2487
|
try {
|
|
2399
2488
|
await this.getAgentDetail(identifier, {}, options);
|
|
2400
|
-
|
|
2489
|
+
log17("Agent exists: %s", identifier);
|
|
2401
2490
|
return true;
|
|
2402
2491
|
} catch (e) {
|
|
2403
|
-
|
|
2492
|
+
log17("Agent does not exist: %s", identifier);
|
|
2404
2493
|
return false;
|
|
2405
2494
|
}
|
|
2406
2495
|
}
|
|
@@ -2413,7 +2502,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2413
2502
|
* @param options - Optional request init overrides
|
|
2414
2503
|
*/
|
|
2415
2504
|
async createEvent(eventData, options) {
|
|
2416
|
-
|
|
2505
|
+
log17("Recording agent event: %s for %s", eventData.event, eventData.identifier);
|
|
2417
2506
|
await this.request("/v1/agents/events", {
|
|
2418
2507
|
body: JSON.stringify(eventData),
|
|
2419
2508
|
headers: {
|
|
@@ -2434,7 +2523,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2434
2523
|
* @returns Promise resolving to the updated install count response
|
|
2435
2524
|
*/
|
|
2436
2525
|
async increaseInstallCount(identifier, options) {
|
|
2437
|
-
|
|
2526
|
+
log17("Increasing install count for agent: %s", identifier);
|
|
2438
2527
|
const result = await this.request("/v1/agents/install-count", {
|
|
2439
2528
|
body: JSON.stringify({ identifier }),
|
|
2440
2529
|
headers: {
|
|
@@ -2443,7 +2532,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2443
2532
|
method: "POST",
|
|
2444
2533
|
...options
|
|
2445
2534
|
});
|
|
2446
|
-
|
|
2535
|
+
log17("Install count increased for agent %s: %d", identifier, result.installCount);
|
|
2447
2536
|
return result;
|
|
2448
2537
|
}
|
|
2449
2538
|
/**
|
|
@@ -2458,9 +2547,9 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2458
2547
|
* @returns Promise resolving to the status change response
|
|
2459
2548
|
*/
|
|
2460
2549
|
async changeStatus(identifier, status, options) {
|
|
2461
|
-
|
|
2550
|
+
log17("Changing agent status: %s -> %s", identifier, status);
|
|
2462
2551
|
const result = await this.modifyAgent({ identifier, status }, options);
|
|
2463
|
-
|
|
2552
|
+
log17("Agent status changed: %s -> %s", identifier, result.status);
|
|
2464
2553
|
return {
|
|
2465
2554
|
identifier: result.identifier,
|
|
2466
2555
|
status: result.status,
|
|
@@ -2478,7 +2567,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2478
2567
|
* @returns Promise resolving to the status change response
|
|
2479
2568
|
*/
|
|
2480
2569
|
async publish(identifier, options) {
|
|
2481
|
-
|
|
2570
|
+
log17("Publishing agent: %s", identifier);
|
|
2482
2571
|
return this.changeStatus(identifier, "published", options);
|
|
2483
2572
|
}
|
|
2484
2573
|
/**
|
|
@@ -2493,7 +2582,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2493
2582
|
* @returns Promise resolving to the status change response
|
|
2494
2583
|
*/
|
|
2495
2584
|
async unpublish(identifier, options) {
|
|
2496
|
-
|
|
2585
|
+
log17("Unpublishing agent: %s", identifier);
|
|
2497
2586
|
return this.changeStatus(identifier, "unpublished", options);
|
|
2498
2587
|
}
|
|
2499
2588
|
/**
|
|
@@ -2508,7 +2597,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2508
2597
|
* @returns Promise resolving to the status change response
|
|
2509
2598
|
*/
|
|
2510
2599
|
async archive(identifier, options) {
|
|
2511
|
-
|
|
2600
|
+
log17("Archiving agent: %s", identifier);
|
|
2512
2601
|
return this.changeStatus(identifier, "archived", options);
|
|
2513
2602
|
}
|
|
2514
2603
|
/**
|
|
@@ -2523,7 +2612,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2523
2612
|
* @returns Promise resolving to the status change response
|
|
2524
2613
|
*/
|
|
2525
2614
|
async deprecate(identifier, options) {
|
|
2526
|
-
|
|
2615
|
+
log17("Deprecating agent: %s", identifier);
|
|
2527
2616
|
return this.changeStatus(identifier, "deprecated", options);
|
|
2528
2617
|
}
|
|
2529
2618
|
/**
|
|
@@ -2541,12 +2630,12 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2541
2630
|
const locale = params.locale || this.defaultLocale;
|
|
2542
2631
|
const queryParams = { ...params, locale };
|
|
2543
2632
|
const queryString = this.buildQueryString(queryParams);
|
|
2544
|
-
|
|
2633
|
+
log17("Getting agents by plugin: %s", params.pluginId);
|
|
2545
2634
|
const result = await this.request(
|
|
2546
2635
|
`/v1/agents/by-plugin${queryString}`,
|
|
2547
2636
|
options
|
|
2548
2637
|
);
|
|
2549
|
-
|
|
2638
|
+
log17("Retrieved %d agents for plugin %s", result.items.length, params.pluginId);
|
|
2550
2639
|
return result;
|
|
2551
2640
|
}
|
|
2552
2641
|
/**
|
|
@@ -2562,7 +2651,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2562
2651
|
* @returns Promise resolving to the fork response with new agent details
|
|
2563
2652
|
*/
|
|
2564
2653
|
async forkAgent(sourceIdentifier, forkData, options) {
|
|
2565
|
-
|
|
2654
|
+
log17("Forking agent: %s -> %s", sourceIdentifier, forkData.identifier);
|
|
2566
2655
|
const result = await this.request(`/v1/agents/${sourceIdentifier}/fork`, {
|
|
2567
2656
|
body: JSON.stringify(forkData),
|
|
2568
2657
|
headers: {
|
|
@@ -2571,7 +2660,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2571
2660
|
method: "POST",
|
|
2572
2661
|
...options
|
|
2573
2662
|
});
|
|
2574
|
-
|
|
2663
|
+
log17("Agent forked successfully: %s (id: %d)", result.agent.identifier, result.agent.id);
|
|
2575
2664
|
return result;
|
|
2576
2665
|
}
|
|
2577
2666
|
/**
|
|
@@ -2585,12 +2674,12 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2585
2674
|
* @returns Promise resolving to the forks list response
|
|
2586
2675
|
*/
|
|
2587
2676
|
async getAgentForks(identifier, options) {
|
|
2588
|
-
|
|
2677
|
+
log17("Getting forks for agent: %s", identifier);
|
|
2589
2678
|
const result = await this.request(
|
|
2590
2679
|
`/v1/agents/${identifier}/forks`,
|
|
2591
2680
|
options
|
|
2592
2681
|
);
|
|
2593
|
-
|
|
2682
|
+
log17("Retrieved %d forks for agent: %s", result.totalCount, identifier);
|
|
2594
2683
|
return result;
|
|
2595
2684
|
}
|
|
2596
2685
|
/**
|
|
@@ -2603,23 +2692,23 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2603
2692
|
* @returns Promise resolving to the fork source response
|
|
2604
2693
|
*/
|
|
2605
2694
|
async getAgentForkSource(identifier, options) {
|
|
2606
|
-
|
|
2695
|
+
log17("Getting fork source for agent: %s", identifier);
|
|
2607
2696
|
const result = await this.request(
|
|
2608
2697
|
`/v1/agents/${identifier}/fork-source`,
|
|
2609
2698
|
options
|
|
2610
2699
|
);
|
|
2611
2700
|
if (result.source) {
|
|
2612
|
-
|
|
2701
|
+
log17("Agent %s was forked from: %s", identifier, result.source.identifier);
|
|
2613
2702
|
} else {
|
|
2614
|
-
|
|
2703
|
+
log17("Agent %s is not a fork (original agent)", identifier);
|
|
2615
2704
|
}
|
|
2616
2705
|
return result;
|
|
2617
2706
|
}
|
|
2618
2707
|
};
|
|
2619
2708
|
|
|
2620
2709
|
// src/market/services/AgentGroupService.ts
|
|
2621
|
-
import
|
|
2622
|
-
var
|
|
2710
|
+
import debug18 from "debug";
|
|
2711
|
+
var log18 = debug18("lobe-market-sdk:agent-groups");
|
|
2623
2712
|
var AgentGroupService = class extends BaseSDK {
|
|
2624
2713
|
/**
|
|
2625
2714
|
* Retrieves a list of agent groups from the marketplace
|
|
@@ -2634,12 +2723,12 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2634
2723
|
const locale = params.locale || this.defaultLocale;
|
|
2635
2724
|
const queryParams = { ...params, locale };
|
|
2636
2725
|
const queryString = this.buildQueryString(queryParams);
|
|
2637
|
-
|
|
2726
|
+
log18("Getting agent group list: %O", queryParams);
|
|
2638
2727
|
const result = await this.request(
|
|
2639
2728
|
`/v1/agent-groups${queryString}`,
|
|
2640
2729
|
options
|
|
2641
2730
|
);
|
|
2642
|
-
|
|
2731
|
+
log18("Retrieved %d agent groups", result.items.length);
|
|
2643
2732
|
return result;
|
|
2644
2733
|
}
|
|
2645
2734
|
/**
|
|
@@ -2656,12 +2745,12 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2656
2745
|
const locale = params.locale || this.defaultLocale;
|
|
2657
2746
|
const queryParams = { ...params, locale };
|
|
2658
2747
|
const queryString = this.buildQueryString(queryParams);
|
|
2659
|
-
|
|
2748
|
+
log18("Getting own agent group list: %O", queryParams);
|
|
2660
2749
|
const result = await this.request(
|
|
2661
2750
|
`/v1/agent-groups/own${queryString}`,
|
|
2662
2751
|
options
|
|
2663
2752
|
);
|
|
2664
|
-
|
|
2753
|
+
log18("Retrieved %d own agent groups", result.items.length);
|
|
2665
2754
|
return result;
|
|
2666
2755
|
}
|
|
2667
2756
|
/**
|
|
@@ -2682,12 +2771,12 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2682
2771
|
queryParams.version = params.version.toString();
|
|
2683
2772
|
}
|
|
2684
2773
|
const queryString = this.buildQueryString(queryParams);
|
|
2685
|
-
|
|
2774
|
+
log18("Getting agent group detail: %O", { identifier, ...params });
|
|
2686
2775
|
const result = await this.request(
|
|
2687
2776
|
`/v1/agent-groups/detail${queryString}`,
|
|
2688
2777
|
options
|
|
2689
2778
|
);
|
|
2690
|
-
|
|
2779
|
+
log18("Agent group detail successfully retrieved: %s", identifier);
|
|
2691
2780
|
return result;
|
|
2692
2781
|
}
|
|
2693
2782
|
/**
|
|
@@ -2701,7 +2790,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2701
2790
|
* @returns Promise resolving to the created agent group response
|
|
2702
2791
|
*/
|
|
2703
2792
|
async createAgentGroup(groupData, options) {
|
|
2704
|
-
|
|
2793
|
+
log18("Creating agent group: %s", groupData.identifier);
|
|
2705
2794
|
const result = await this.request("/v1/agent-groups/create", {
|
|
2706
2795
|
body: JSON.stringify(groupData),
|
|
2707
2796
|
headers: {
|
|
@@ -2710,7 +2799,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2710
2799
|
method: "POST",
|
|
2711
2800
|
...options
|
|
2712
2801
|
});
|
|
2713
|
-
|
|
2802
|
+
log18("Agent group created successfully: %O", result);
|
|
2714
2803
|
return result;
|
|
2715
2804
|
}
|
|
2716
2805
|
/**
|
|
@@ -2724,7 +2813,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2724
2813
|
* @returns Promise resolving to the created version response
|
|
2725
2814
|
*/
|
|
2726
2815
|
async createAgentGroupVersion(versionData, options) {
|
|
2727
|
-
|
|
2816
|
+
log18("Creating agent group version: %s", versionData.identifier);
|
|
2728
2817
|
const result = await this.request(
|
|
2729
2818
|
"/v1/agent-groups/version-create",
|
|
2730
2819
|
{
|
|
@@ -2736,7 +2825,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2736
2825
|
...options
|
|
2737
2826
|
}
|
|
2738
2827
|
);
|
|
2739
|
-
|
|
2828
|
+
log18("Agent group version created successfully: %O", result);
|
|
2740
2829
|
return result;
|
|
2741
2830
|
}
|
|
2742
2831
|
/**
|
|
@@ -2750,7 +2839,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2750
2839
|
* @returns Promise resolving to the modified agent group response
|
|
2751
2840
|
*/
|
|
2752
2841
|
async modifyAgentGroup(groupData, options) {
|
|
2753
|
-
|
|
2842
|
+
log18("Modifying agent group: %s", groupData.identifier);
|
|
2754
2843
|
const result = await this.request("/v1/agent-groups/modify", {
|
|
2755
2844
|
body: JSON.stringify(groupData),
|
|
2756
2845
|
headers: {
|
|
@@ -2759,7 +2848,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2759
2848
|
method: "POST",
|
|
2760
2849
|
...options
|
|
2761
2850
|
});
|
|
2762
|
-
|
|
2851
|
+
log18("Agent group modified successfully: %O", result);
|
|
2763
2852
|
return result;
|
|
2764
2853
|
}
|
|
2765
2854
|
/**
|
|
@@ -2770,13 +2859,13 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2770
2859
|
* @returns Promise resolving to true if agent group exists, false otherwise
|
|
2771
2860
|
*/
|
|
2772
2861
|
async checkAgentGroupExists(identifier, options) {
|
|
2773
|
-
|
|
2862
|
+
log18("Checking if agent group exists: %s", identifier);
|
|
2774
2863
|
try {
|
|
2775
2864
|
await this.getAgentGroupDetail(identifier, {}, options);
|
|
2776
|
-
|
|
2865
|
+
log18("Agent group exists: %s", identifier);
|
|
2777
2866
|
return true;
|
|
2778
2867
|
} catch (e) {
|
|
2779
|
-
|
|
2868
|
+
log18("Agent group does not exist: %s", identifier);
|
|
2780
2869
|
return false;
|
|
2781
2870
|
}
|
|
2782
2871
|
}
|
|
@@ -2792,9 +2881,9 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2792
2881
|
* @returns Promise resolving to the status change response
|
|
2793
2882
|
*/
|
|
2794
2883
|
async changeStatus(identifier, status, options) {
|
|
2795
|
-
|
|
2884
|
+
log18("Changing agent group status: %s -> %s", identifier, status);
|
|
2796
2885
|
const result = await this.modifyAgentGroup({ identifier, status }, options);
|
|
2797
|
-
|
|
2886
|
+
log18("Agent group status changed: %s -> %s", identifier, result.status);
|
|
2798
2887
|
return {
|
|
2799
2888
|
identifier: result.identifier,
|
|
2800
2889
|
status: result.status,
|
|
@@ -2813,7 +2902,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2813
2902
|
* @returns Promise resolving to the status change response
|
|
2814
2903
|
*/
|
|
2815
2904
|
async publish(identifier, options) {
|
|
2816
|
-
|
|
2905
|
+
log18("Publishing agent group: %s", identifier);
|
|
2817
2906
|
return this.changeStatus(identifier, "published", options);
|
|
2818
2907
|
}
|
|
2819
2908
|
/**
|
|
@@ -2828,7 +2917,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2828
2917
|
* @returns Promise resolving to the status change response
|
|
2829
2918
|
*/
|
|
2830
2919
|
async unpublish(identifier, options) {
|
|
2831
|
-
|
|
2920
|
+
log18("Unpublishing agent group: %s", identifier);
|
|
2832
2921
|
return this.changeStatus(identifier, "unpublished", options);
|
|
2833
2922
|
}
|
|
2834
2923
|
/**
|
|
@@ -2843,7 +2932,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2843
2932
|
* @returns Promise resolving to the status change response
|
|
2844
2933
|
*/
|
|
2845
2934
|
async archive(identifier, options) {
|
|
2846
|
-
|
|
2935
|
+
log18("Archiving agent group: %s", identifier);
|
|
2847
2936
|
return this.changeStatus(identifier, "archived", options);
|
|
2848
2937
|
}
|
|
2849
2938
|
/**
|
|
@@ -2858,7 +2947,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2858
2947
|
* @returns Promise resolving to the status change response
|
|
2859
2948
|
*/
|
|
2860
2949
|
async deprecate(identifier, options) {
|
|
2861
|
-
|
|
2950
|
+
log18("Deprecating agent group: %s", identifier);
|
|
2862
2951
|
return this.changeStatus(identifier, "deprecated", options);
|
|
2863
2952
|
}
|
|
2864
2953
|
/**
|
|
@@ -2874,7 +2963,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2874
2963
|
* @returns Promise resolving to the fork response with new group details
|
|
2875
2964
|
*/
|
|
2876
2965
|
async forkAgentGroup(sourceIdentifier, forkData, options) {
|
|
2877
|
-
|
|
2966
|
+
log18("Forking agent group: %s -> %s", sourceIdentifier, forkData.identifier);
|
|
2878
2967
|
const result = await this.request(
|
|
2879
2968
|
`/v1/agent-groups/${sourceIdentifier}/fork`,
|
|
2880
2969
|
{
|
|
@@ -2886,7 +2975,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2886
2975
|
...options
|
|
2887
2976
|
}
|
|
2888
2977
|
);
|
|
2889
|
-
|
|
2978
|
+
log18(
|
|
2890
2979
|
"Agent group forked successfully: %s (id: %d, members: %d)",
|
|
2891
2980
|
result.group.identifier,
|
|
2892
2981
|
result.group.id,
|
|
@@ -2905,12 +2994,12 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2905
2994
|
* @returns Promise resolving to the forks list response
|
|
2906
2995
|
*/
|
|
2907
2996
|
async getAgentGroupForks(identifier, options) {
|
|
2908
|
-
|
|
2997
|
+
log18("Getting forks for agent group: %s", identifier);
|
|
2909
2998
|
const result = await this.request(
|
|
2910
2999
|
`/v1/agent-groups/${identifier}/forks`,
|
|
2911
3000
|
options
|
|
2912
3001
|
);
|
|
2913
|
-
|
|
3002
|
+
log18("Retrieved %d forks for agent group: %s", result.totalCount, identifier);
|
|
2914
3003
|
return result;
|
|
2915
3004
|
}
|
|
2916
3005
|
/**
|
|
@@ -2923,24 +3012,24 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2923
3012
|
* @returns Promise resolving to the fork source response
|
|
2924
3013
|
*/
|
|
2925
3014
|
async getAgentGroupForkSource(identifier, options) {
|
|
2926
|
-
|
|
3015
|
+
log18("Getting fork source for agent group: %s", identifier);
|
|
2927
3016
|
const result = await this.request(
|
|
2928
3017
|
`/v1/agent-groups/${identifier}/fork-source`,
|
|
2929
3018
|
options
|
|
2930
3019
|
);
|
|
2931
3020
|
if (result.source) {
|
|
2932
|
-
|
|
3021
|
+
log18("Agent group %s was forked from: %s", identifier, result.source.identifier);
|
|
2933
3022
|
} else {
|
|
2934
|
-
|
|
3023
|
+
log18("Agent group %s is not a fork (original group)", identifier);
|
|
2935
3024
|
}
|
|
2936
3025
|
return result;
|
|
2937
3026
|
}
|
|
2938
3027
|
};
|
|
2939
3028
|
|
|
2940
3029
|
// src/market/services/AuthService.ts
|
|
2941
|
-
import
|
|
3030
|
+
import debug19 from "debug";
|
|
2942
3031
|
import urlJoin2 from "url-join";
|
|
2943
|
-
var
|
|
3032
|
+
var log19 = debug19("lobe-market-sdk:auth");
|
|
2944
3033
|
var _AuthService = class _AuthService extends BaseSDK {
|
|
2945
3034
|
/** Normalize token response from snake_case to camelCase fields */
|
|
2946
3035
|
static normalizeTokenResponse(data) {
|
|
@@ -2972,7 +3061,7 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2972
3061
|
if (grantType !== "authorization_code" && grantType !== "refresh_token") {
|
|
2973
3062
|
throw new Error(`Unsupported grant type: ${grantType}`);
|
|
2974
3063
|
}
|
|
2975
|
-
|
|
3064
|
+
log19("Exchanging OAuth token using grant_type=%s", grantType);
|
|
2976
3065
|
const tokenUrl = urlJoin2(this.baseUrl, "lobehub-oidc/token");
|
|
2977
3066
|
const params = new URLSearchParams();
|
|
2978
3067
|
params.set("grant_type", grantType);
|
|
@@ -3014,16 +3103,16 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
3014
3103
|
try {
|
|
3015
3104
|
payload = await response.json();
|
|
3016
3105
|
} catch (error) {
|
|
3017
|
-
|
|
3106
|
+
log19("Failed to parse token response: %O", error);
|
|
3018
3107
|
throw new Error(`Failed to parse token response: ${response.status} ${response.statusText}`);
|
|
3019
3108
|
}
|
|
3020
3109
|
if (!response.ok) {
|
|
3021
3110
|
const errorDescription = (payload == null ? void 0 : payload.error_description) || (payload == null ? void 0 : payload.error) || response.statusText;
|
|
3022
3111
|
const errorMsg = `Token exchange failed: ${response.status} ${errorDescription}`;
|
|
3023
|
-
|
|
3112
|
+
log19("Error: %s", errorMsg);
|
|
3024
3113
|
throw new Error(errorMsg);
|
|
3025
3114
|
}
|
|
3026
|
-
|
|
3115
|
+
log19("Token exchange successful");
|
|
3027
3116
|
return _AuthService.normalizeTokenResponse(payload);
|
|
3028
3117
|
}
|
|
3029
3118
|
/**
|
|
@@ -3041,7 +3130,7 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
3041
3130
|
if (!clientId || !token) {
|
|
3042
3131
|
throw new Error("clientId and token are required for token revocation");
|
|
3043
3132
|
}
|
|
3044
|
-
|
|
3133
|
+
log19("Revoking OAuth token (hint=%s)", tokenTypeHint != null ? tokenTypeHint : "none");
|
|
3045
3134
|
const revocationUrl = urlJoin2(this.baseUrl, "lobehub-oidc/token/revocation");
|
|
3046
3135
|
const params = new URLSearchParams();
|
|
3047
3136
|
params.set("client_id", clientId);
|
|
@@ -3069,10 +3158,10 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
3069
3158
|
} catch (e) {
|
|
3070
3159
|
}
|
|
3071
3160
|
const errorMsg = `Token revocation failed: ${response.status} ${errorDescription}`;
|
|
3072
|
-
|
|
3161
|
+
log19("Error: %s", errorMsg);
|
|
3073
3162
|
throw new Error(errorMsg);
|
|
3074
3163
|
}
|
|
3075
|
-
|
|
3164
|
+
log19("Token revocation successful");
|
|
3076
3165
|
}
|
|
3077
3166
|
/**
|
|
3078
3167
|
* Retrieves user information from the OIDC userinfo endpoint
|
|
@@ -3084,7 +3173,7 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
3084
3173
|
* @returns Promise resolving to the user information
|
|
3085
3174
|
*/
|
|
3086
3175
|
async getUserInfo(accessToken, options) {
|
|
3087
|
-
|
|
3176
|
+
log19("Getting user info");
|
|
3088
3177
|
const userInfoUrl = urlJoin2(this.baseUrl, "lobehub-oidc/userinfo");
|
|
3089
3178
|
const response = await fetch(userInfoUrl, {
|
|
3090
3179
|
headers: {
|
|
@@ -3096,11 +3185,11 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
3096
3185
|
});
|
|
3097
3186
|
if (!response.ok) {
|
|
3098
3187
|
const errorMsg = `Failed to fetch user info: ${response.status} ${response.statusText}`;
|
|
3099
|
-
|
|
3188
|
+
log19("Error: %s", errorMsg);
|
|
3100
3189
|
throw new Error(errorMsg);
|
|
3101
3190
|
}
|
|
3102
3191
|
const userInfo = await response.json();
|
|
3103
|
-
|
|
3192
|
+
log19("User info retrieved successfully");
|
|
3104
3193
|
return userInfo;
|
|
3105
3194
|
}
|
|
3106
3195
|
/**
|
|
@@ -3114,7 +3203,7 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
3114
3203
|
* @returns Promise resolving to the client credentials
|
|
3115
3204
|
*/
|
|
3116
3205
|
async registerClient(clientData, options) {
|
|
3117
|
-
|
|
3206
|
+
log19("Registering client: %s (%s)", clientData.clientName, clientData.clientType);
|
|
3118
3207
|
const result = await this.request("/v1/clients/register", {
|
|
3119
3208
|
body: JSON.stringify(clientData),
|
|
3120
3209
|
headers: {
|
|
@@ -3123,7 +3212,7 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
3123
3212
|
method: "POST",
|
|
3124
3213
|
...options
|
|
3125
3214
|
});
|
|
3126
|
-
|
|
3215
|
+
log19("Client registered successfully: %s", result.client_id);
|
|
3127
3216
|
return result;
|
|
3128
3217
|
}
|
|
3129
3218
|
/**
|
|
@@ -3135,9 +3224,9 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
3135
3224
|
* @returns Promise resolving to the access token and expiration time
|
|
3136
3225
|
*/
|
|
3137
3226
|
async getM2MToken() {
|
|
3138
|
-
|
|
3227
|
+
log19("Fetching M2M token");
|
|
3139
3228
|
const tokenInfo = await this.fetchM2MToken();
|
|
3140
|
-
|
|
3229
|
+
log19("M2M token fetched successfully");
|
|
3141
3230
|
return tokenInfo;
|
|
3142
3231
|
}
|
|
3143
3232
|
/** OAuth handoff response shapes */
|
|
@@ -3163,7 +3252,7 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
3163
3252
|
async getOAuthHandoff(id, options) {
|
|
3164
3253
|
var _a, _b;
|
|
3165
3254
|
if (!id) throw new Error("id is required");
|
|
3166
|
-
|
|
3255
|
+
log19("Getting OAuth handoff: %s", id);
|
|
3167
3256
|
const handoffUrl = `${urlJoin2(this.baseUrl, "lobehub-oidc/handoff")}?id=${encodeURIComponent(id)}`;
|
|
3168
3257
|
const response = await fetch(handoffUrl, {
|
|
3169
3258
|
headers: {
|
|
@@ -3179,19 +3268,19 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
3179
3268
|
code: json.code,
|
|
3180
3269
|
redirectUri: json.redirectUri
|
|
3181
3270
|
});
|
|
3182
|
-
|
|
3271
|
+
log19("OAuth handoff success for id: %s", id);
|
|
3183
3272
|
return result;
|
|
3184
3273
|
}
|
|
3185
3274
|
if (response.status === 202) {
|
|
3186
|
-
|
|
3275
|
+
log19("OAuth handoff pending for id: %s", id);
|
|
3187
3276
|
return { status: _AuthService.HANDOFF_PENDING_STATUS };
|
|
3188
3277
|
}
|
|
3189
3278
|
if (response.status === 404) {
|
|
3190
|
-
|
|
3279
|
+
log19("OAuth handoff consumed for id: %s", id);
|
|
3191
3280
|
return { status: _AuthService.HANDOFF_CONSUMED_STATUS };
|
|
3192
3281
|
}
|
|
3193
3282
|
if (response.status === 410) {
|
|
3194
|
-
|
|
3283
|
+
log19("OAuth handoff expired for id: %s", id);
|
|
3195
3284
|
return { status: _AuthService.HANDOFF_EXPIRED_STATUS };
|
|
3196
3285
|
}
|
|
3197
3286
|
let errorMessage = `Failed to fetch OAuth handoff (status ${response.status} ${response.statusText})`;
|
|
@@ -3202,7 +3291,7 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
3202
3291
|
}
|
|
3203
3292
|
} catch (e) {
|
|
3204
3293
|
}
|
|
3205
|
-
|
|
3294
|
+
log19("Error: %s", errorMessage);
|
|
3206
3295
|
throw new Error(errorMessage);
|
|
3207
3296
|
}
|
|
3208
3297
|
/**
|
|
@@ -3216,21 +3305,21 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
3216
3305
|
const timeoutMs = (_b = params.timeoutMs) != null ? _b : 6e4;
|
|
3217
3306
|
const startedAt = Date.now();
|
|
3218
3307
|
const { signal, requestInit } = params;
|
|
3219
|
-
|
|
3308
|
+
log19("Start polling OAuth handoff: %s", id);
|
|
3220
3309
|
while (true) {
|
|
3221
3310
|
if (signal == null ? void 0 : signal.aborted) {
|
|
3222
3311
|
const err = new Error("Polling aborted");
|
|
3223
|
-
|
|
3312
|
+
log19("Error: %s", err.message);
|
|
3224
3313
|
throw err;
|
|
3225
3314
|
}
|
|
3226
3315
|
if (Date.now() - startedAt > timeoutMs) {
|
|
3227
3316
|
const err = new Error("Polling timeout");
|
|
3228
|
-
|
|
3317
|
+
log19("Error: %s", err.message);
|
|
3229
3318
|
throw err;
|
|
3230
3319
|
}
|
|
3231
3320
|
const result = await this.getOAuthHandoff(id, requestInit);
|
|
3232
3321
|
if (result.status === "success" || result.status === "expired" || result.status === "consumed") {
|
|
3233
|
-
|
|
3322
|
+
log19("Stop polling OAuth handoff (terminal): %s -> %s", id, result.status);
|
|
3234
3323
|
return result;
|
|
3235
3324
|
}
|
|
3236
3325
|
await new Promise((resolve) => {
|
|
@@ -3251,9 +3340,9 @@ _AuthService.HANDOFF_EXPIRED_STATUS = "expired";
|
|
|
3251
3340
|
var AuthService = _AuthService;
|
|
3252
3341
|
|
|
3253
3342
|
// src/market/services/ConnectService.ts
|
|
3254
|
-
import
|
|
3343
|
+
import debug20 from "debug";
|
|
3255
3344
|
import urlJoin3 from "url-join";
|
|
3256
|
-
var
|
|
3345
|
+
var log20 = debug20("lobe-market-sdk:connect");
|
|
3257
3346
|
var CIMD_CLIENT_METADATA_VERSION = "v1";
|
|
3258
3347
|
var CIMD_CLIENT_METADATA_VERSION_BY_PROVIDER = {
|
|
3259
3348
|
posthog: "v2"
|
|
@@ -3277,9 +3366,9 @@ var ConnectService = class extends BaseSDK {
|
|
|
3277
3366
|
*/
|
|
3278
3367
|
async listProviders(options) {
|
|
3279
3368
|
var _a;
|
|
3280
|
-
|
|
3369
|
+
log20("Listing connect providers");
|
|
3281
3370
|
const result = await this.request("/connect/providers", options);
|
|
3282
|
-
|
|
3371
|
+
log20("Found %d connect providers", ((_a = result.providers) == null ? void 0 : _a.length) || 0);
|
|
3283
3372
|
return result;
|
|
3284
3373
|
}
|
|
3285
3374
|
/**
|
|
@@ -3293,12 +3382,12 @@ var ConnectService = class extends BaseSDK {
|
|
|
3293
3382
|
*/
|
|
3294
3383
|
async getProvider(provider, options) {
|
|
3295
3384
|
var _a;
|
|
3296
|
-
|
|
3385
|
+
log20("Getting provider details: %s", provider);
|
|
3297
3386
|
const result = await this.request(
|
|
3298
3387
|
`/connect/providers/${encodeURIComponent(provider)}`,
|
|
3299
3388
|
options
|
|
3300
3389
|
);
|
|
3301
|
-
|
|
3390
|
+
log20("Retrieved provider: %s", (_a = result.provider) == null ? void 0 : _a.name);
|
|
3302
3391
|
return result;
|
|
3303
3392
|
}
|
|
3304
3393
|
/**
|
|
@@ -3317,12 +3406,12 @@ var ConnectService = class extends BaseSDK {
|
|
|
3317
3406
|
const metadataParams = hasParams ? params : void 0;
|
|
3318
3407
|
const requestOptions = hasParams ? options : params;
|
|
3319
3408
|
const version = getCimdClientMetadataVersion(provider, metadataParams == null ? void 0 : metadataParams.version);
|
|
3320
|
-
|
|
3409
|
+
log20("Getting CIMD client metadata for provider: %s version: %s", provider, version);
|
|
3321
3410
|
const result = await this.request(
|
|
3322
3411
|
`/connect/${encodeURIComponent(provider)}/oauth/client-metadata/${encodeURIComponent(version)}.json`,
|
|
3323
3412
|
requestOptions
|
|
3324
3413
|
);
|
|
3325
|
-
|
|
3414
|
+
log20("Retrieved CIMD client metadata: %s", result.client_id);
|
|
3326
3415
|
return result;
|
|
3327
3416
|
}
|
|
3328
3417
|
/**
|
|
@@ -3362,7 +3451,7 @@ var ConnectService = class extends BaseSDK {
|
|
|
3362
3451
|
* ```
|
|
3363
3452
|
*/
|
|
3364
3453
|
async authorize(provider, params, options) {
|
|
3365
|
-
|
|
3454
|
+
log20("Requesting authorization code for provider: %s", provider);
|
|
3366
3455
|
const result = await this.request(
|
|
3367
3456
|
`/connect/${encodeURIComponent(provider)}/authorize`,
|
|
3368
3457
|
{
|
|
@@ -3374,7 +3463,7 @@ var ConnectService = class extends BaseSDK {
|
|
|
3374
3463
|
...options
|
|
3375
3464
|
}
|
|
3376
3465
|
);
|
|
3377
|
-
|
|
3466
|
+
log20("Authorization code obtained, expires in %d seconds", result.expires_in);
|
|
3378
3467
|
return result;
|
|
3379
3468
|
}
|
|
3380
3469
|
/**
|
|
@@ -3400,7 +3489,7 @@ var ConnectService = class extends BaseSDK {
|
|
|
3400
3489
|
* ```
|
|
3401
3490
|
*/
|
|
3402
3491
|
getAuthorizeUrl(provider, params) {
|
|
3403
|
-
|
|
3492
|
+
log20(
|
|
3404
3493
|
"Generating authorize URL for provider: %s (deprecated, use authorize() instead)",
|
|
3405
3494
|
provider
|
|
3406
3495
|
);
|
|
@@ -3414,7 +3503,7 @@ var ConnectService = class extends BaseSDK {
|
|
|
3414
3503
|
const queryString = queryParams.toString();
|
|
3415
3504
|
const path = `/connect/${encodeURIComponent(provider)}/start${queryString ? `?${queryString}` : ""}`;
|
|
3416
3505
|
const url = urlJoin3(this.baseUrl, "api", path);
|
|
3417
|
-
|
|
3506
|
+
log20("Generated authorize URL: %s", url);
|
|
3418
3507
|
return url;
|
|
3419
3508
|
}
|
|
3420
3509
|
/**
|
|
@@ -3428,12 +3517,12 @@ var ConnectService = class extends BaseSDK {
|
|
|
3428
3517
|
* @returns Promise resolving to the connection status
|
|
3429
3518
|
*/
|
|
3430
3519
|
async getStatus(provider, options) {
|
|
3431
|
-
|
|
3520
|
+
log20("Getting connection status for provider: %s", provider);
|
|
3432
3521
|
const result = await this.request(
|
|
3433
3522
|
`/connect/${encodeURIComponent(provider)}/status`,
|
|
3434
3523
|
options
|
|
3435
3524
|
);
|
|
3436
|
-
|
|
3525
|
+
log20("Provider %s connection status: connected=%s", provider, result.connected);
|
|
3437
3526
|
return result;
|
|
3438
3527
|
}
|
|
3439
3528
|
/**
|
|
@@ -3446,9 +3535,9 @@ var ConnectService = class extends BaseSDK {
|
|
|
3446
3535
|
*/
|
|
3447
3536
|
async listConnections(options) {
|
|
3448
3537
|
var _a;
|
|
3449
|
-
|
|
3538
|
+
log20("Listing user connections");
|
|
3450
3539
|
const result = await this.request("/connect/connections", options);
|
|
3451
|
-
|
|
3540
|
+
log20("Found %d connections", ((_a = result.connections) == null ? void 0 : _a.length) || 0);
|
|
3452
3541
|
return result;
|
|
3453
3542
|
}
|
|
3454
3543
|
/**
|
|
@@ -3462,12 +3551,12 @@ var ConnectService = class extends BaseSDK {
|
|
|
3462
3551
|
* @returns Promise resolving to the connection health status
|
|
3463
3552
|
*/
|
|
3464
3553
|
async getHealth(provider, options) {
|
|
3465
|
-
|
|
3554
|
+
log20("Checking health for provider: %s", provider);
|
|
3466
3555
|
const result = await this.request(
|
|
3467
3556
|
`/connect/${encodeURIComponent(provider)}/health`,
|
|
3468
3557
|
options
|
|
3469
3558
|
);
|
|
3470
|
-
|
|
3559
|
+
log20("Provider %s health: healthy=%s, status=%s", provider, result.healthy, result.tokenStatus);
|
|
3471
3560
|
return result;
|
|
3472
3561
|
}
|
|
3473
3562
|
/**
|
|
@@ -3480,9 +3569,9 @@ var ConnectService = class extends BaseSDK {
|
|
|
3480
3569
|
*/
|
|
3481
3570
|
async getAllHealth(options) {
|
|
3482
3571
|
var _a, _b, _c;
|
|
3483
|
-
|
|
3572
|
+
log20("Checking health for all connections");
|
|
3484
3573
|
const result = await this.request("/connect/health", options);
|
|
3485
|
-
|
|
3574
|
+
log20(
|
|
3486
3575
|
"Health check complete: total=%d, healthy=%d, unhealthy=%d",
|
|
3487
3576
|
((_a = result.summary) == null ? void 0 : _a.total) || 0,
|
|
3488
3577
|
((_b = result.summary) == null ? void 0 : _b.healthy) || 0,
|
|
@@ -3501,7 +3590,7 @@ var ConnectService = class extends BaseSDK {
|
|
|
3501
3590
|
* @returns Promise resolving to the refresh result
|
|
3502
3591
|
*/
|
|
3503
3592
|
async refresh(provider, options) {
|
|
3504
|
-
|
|
3593
|
+
log20("Refreshing token for provider: %s", provider);
|
|
3505
3594
|
const result = await this.request(
|
|
3506
3595
|
`/connect/${encodeURIComponent(provider)}/refresh`,
|
|
3507
3596
|
{
|
|
@@ -3509,7 +3598,7 @@ var ConnectService = class extends BaseSDK {
|
|
|
3509
3598
|
...options
|
|
3510
3599
|
}
|
|
3511
3600
|
);
|
|
3512
|
-
|
|
3601
|
+
log20("Token refresh for %s: refreshed=%s", provider, result.refreshed);
|
|
3513
3602
|
return result;
|
|
3514
3603
|
}
|
|
3515
3604
|
/**
|
|
@@ -3523,7 +3612,7 @@ var ConnectService = class extends BaseSDK {
|
|
|
3523
3612
|
* @returns Promise resolving to the revoke result
|
|
3524
3613
|
*/
|
|
3525
3614
|
async revoke(provider, options) {
|
|
3526
|
-
|
|
3615
|
+
log20("Revoking connection for provider: %s", provider);
|
|
3527
3616
|
const result = await this.request(
|
|
3528
3617
|
`/connect/${encodeURIComponent(provider)}`,
|
|
3529
3618
|
{
|
|
@@ -3531,14 +3620,14 @@ var ConnectService = class extends BaseSDK {
|
|
|
3531
3620
|
...options
|
|
3532
3621
|
}
|
|
3533
3622
|
);
|
|
3534
|
-
|
|
3623
|
+
log20("Connection revoked for %s: success=%s", provider, result.success);
|
|
3535
3624
|
return result;
|
|
3536
3625
|
}
|
|
3537
3626
|
};
|
|
3538
3627
|
|
|
3539
3628
|
// src/market/services/CredService.ts
|
|
3540
|
-
import
|
|
3541
|
-
var
|
|
3629
|
+
import debug21 from "debug";
|
|
3630
|
+
var log21 = debug21("lobe-market-sdk:creds");
|
|
3542
3631
|
var CredService = class extends BaseSDK {
|
|
3543
3632
|
// ===========================================================================
|
|
3544
3633
|
// List & Get Operations
|
|
@@ -3554,9 +3643,9 @@ var CredService = class extends BaseSDK {
|
|
|
3554
3643
|
*/
|
|
3555
3644
|
async list(options) {
|
|
3556
3645
|
var _a;
|
|
3557
|
-
|
|
3646
|
+
log21("Listing user credentials");
|
|
3558
3647
|
const result = await this.request("/v1/user/creds", options);
|
|
3559
|
-
|
|
3648
|
+
log21("Found %d credentials", ((_a = result.data) == null ? void 0 : _a.length) || 0);
|
|
3560
3649
|
return result;
|
|
3561
3650
|
}
|
|
3562
3651
|
/**
|
|
@@ -3571,7 +3660,7 @@ var CredService = class extends BaseSDK {
|
|
|
3571
3660
|
* @returns Promise resolving to the credential details
|
|
3572
3661
|
*/
|
|
3573
3662
|
async get(id, getOptions, options) {
|
|
3574
|
-
|
|
3663
|
+
log21("Getting credential: %d (decrypt=%s)", id, getOptions == null ? void 0 : getOptions.decrypt);
|
|
3575
3664
|
const queryParams = {};
|
|
3576
3665
|
if (getOptions == null ? void 0 : getOptions.decrypt) {
|
|
3577
3666
|
queryParams.decrypt = "true";
|
|
@@ -3581,7 +3670,7 @@ var CredService = class extends BaseSDK {
|
|
|
3581
3670
|
`/v1/user/creds/${id}${queryString}`,
|
|
3582
3671
|
options
|
|
3583
3672
|
);
|
|
3584
|
-
|
|
3673
|
+
log21("Retrieved credential: %s", result.key);
|
|
3585
3674
|
return result;
|
|
3586
3675
|
}
|
|
3587
3676
|
// ===========================================================================
|
|
@@ -3600,7 +3689,7 @@ var CredService = class extends BaseSDK {
|
|
|
3600
3689
|
* @returns Promise resolving to the created credential
|
|
3601
3690
|
*/
|
|
3602
3691
|
async createKV(data, options) {
|
|
3603
|
-
|
|
3692
|
+
log21("Creating KV credential: %s (type=%s)", data.key, data.type);
|
|
3604
3693
|
const result = await this.request("/v1/user/creds/kv", {
|
|
3605
3694
|
body: JSON.stringify(data),
|
|
3606
3695
|
headers: {
|
|
@@ -3609,7 +3698,7 @@ var CredService = class extends BaseSDK {
|
|
|
3609
3698
|
method: "POST",
|
|
3610
3699
|
...options
|
|
3611
3700
|
});
|
|
3612
|
-
|
|
3701
|
+
log21("Created KV credential: %d", result.id);
|
|
3613
3702
|
return result;
|
|
3614
3703
|
}
|
|
3615
3704
|
/**
|
|
@@ -3623,7 +3712,7 @@ var CredService = class extends BaseSDK {
|
|
|
3623
3712
|
* @returns Promise resolving to the created credential
|
|
3624
3713
|
*/
|
|
3625
3714
|
async createOAuth(data, options) {
|
|
3626
|
-
|
|
3715
|
+
log21("Creating OAuth credential: %s (connectionId=%d)", data.key, data.oauthConnectionId);
|
|
3627
3716
|
const result = await this.request("/v1/user/creds/oauth", {
|
|
3628
3717
|
body: JSON.stringify(data),
|
|
3629
3718
|
headers: {
|
|
@@ -3632,7 +3721,7 @@ var CredService = class extends BaseSDK {
|
|
|
3632
3721
|
method: "POST",
|
|
3633
3722
|
...options
|
|
3634
3723
|
});
|
|
3635
|
-
|
|
3724
|
+
log21("Created OAuth credential: %d", result.id);
|
|
3636
3725
|
return result;
|
|
3637
3726
|
}
|
|
3638
3727
|
/**
|
|
@@ -3646,7 +3735,7 @@ var CredService = class extends BaseSDK {
|
|
|
3646
3735
|
* @returns Promise resolving to the created credential
|
|
3647
3736
|
*/
|
|
3648
3737
|
async createFile(data, options) {
|
|
3649
|
-
|
|
3738
|
+
log21("Creating file credential: %s (fileName=%s)", data.key, data.fileName);
|
|
3650
3739
|
const result = await this.request("/v1/user/creds/file", {
|
|
3651
3740
|
body: JSON.stringify(data),
|
|
3652
3741
|
headers: {
|
|
@@ -3655,7 +3744,7 @@ var CredService = class extends BaseSDK {
|
|
|
3655
3744
|
method: "POST",
|
|
3656
3745
|
...options
|
|
3657
3746
|
});
|
|
3658
|
-
|
|
3747
|
+
log21("Created file credential: %d", result.id);
|
|
3659
3748
|
return result;
|
|
3660
3749
|
}
|
|
3661
3750
|
// ===========================================================================
|
|
@@ -3673,7 +3762,7 @@ var CredService = class extends BaseSDK {
|
|
|
3673
3762
|
* @returns Promise resolving to the updated credential
|
|
3674
3763
|
*/
|
|
3675
3764
|
async update(id, data, options) {
|
|
3676
|
-
|
|
3765
|
+
log21("Updating credential: %d", id);
|
|
3677
3766
|
const result = await this.request(`/v1/user/creds/${id}`, {
|
|
3678
3767
|
body: JSON.stringify(data),
|
|
3679
3768
|
headers: {
|
|
@@ -3682,7 +3771,7 @@ var CredService = class extends BaseSDK {
|
|
|
3682
3771
|
method: "PATCH",
|
|
3683
3772
|
...options
|
|
3684
3773
|
});
|
|
3685
|
-
|
|
3774
|
+
log21("Updated credential: %d", result.id);
|
|
3686
3775
|
return result;
|
|
3687
3776
|
}
|
|
3688
3777
|
// ===========================================================================
|
|
@@ -3705,7 +3794,7 @@ var CredService = class extends BaseSDK {
|
|
|
3705
3794
|
* @returns Promise resolving to the updated credential
|
|
3706
3795
|
*/
|
|
3707
3796
|
async share(id, data, options) {
|
|
3708
|
-
|
|
3797
|
+
log21("Sharing credential %d with org %s", id, data.orgId);
|
|
3709
3798
|
const result = await this.request(`/v1/user/creds/${id}/share`, {
|
|
3710
3799
|
body: JSON.stringify(data),
|
|
3711
3800
|
headers: {
|
|
@@ -3714,7 +3803,7 @@ var CredService = class extends BaseSDK {
|
|
|
3714
3803
|
method: "POST",
|
|
3715
3804
|
...options
|
|
3716
3805
|
});
|
|
3717
|
-
|
|
3806
|
+
log21("Shared credential: %d", result.id);
|
|
3718
3807
|
return result;
|
|
3719
3808
|
}
|
|
3720
3809
|
/**
|
|
@@ -3731,7 +3820,7 @@ var CredService = class extends BaseSDK {
|
|
|
3731
3820
|
* @returns Promise resolving to the updated credential
|
|
3732
3821
|
*/
|
|
3733
3822
|
async publish(id, options, target = {}) {
|
|
3734
|
-
|
|
3823
|
+
log21("Publishing credential %d (org=%s)", id, target.orgId);
|
|
3735
3824
|
const result = await this.request(`/v1/user/creds/${id}/publish`, {
|
|
3736
3825
|
body: JSON.stringify(target),
|
|
3737
3826
|
headers: {
|
|
@@ -3740,7 +3829,7 @@ var CredService = class extends BaseSDK {
|
|
|
3740
3829
|
method: "POST",
|
|
3741
3830
|
...options
|
|
3742
3831
|
});
|
|
3743
|
-
|
|
3832
|
+
log21("Published credential: %d", result.id);
|
|
3744
3833
|
return result;
|
|
3745
3834
|
}
|
|
3746
3835
|
/**
|
|
@@ -3756,7 +3845,7 @@ var CredService = class extends BaseSDK {
|
|
|
3756
3845
|
* @returns Promise resolving to the updated credential
|
|
3757
3846
|
*/
|
|
3758
3847
|
async unshare(id, options, target = {}) {
|
|
3759
|
-
|
|
3848
|
+
log21("Unsharing credential %d (org=%s)", id, target.orgId);
|
|
3760
3849
|
const result = await this.request(`/v1/user/creds/${id}/unshare`, {
|
|
3761
3850
|
body: JSON.stringify(target),
|
|
3762
3851
|
headers: {
|
|
@@ -3765,7 +3854,7 @@ var CredService = class extends BaseSDK {
|
|
|
3765
3854
|
method: "POST",
|
|
3766
3855
|
...options
|
|
3767
3856
|
});
|
|
3768
|
-
|
|
3857
|
+
log21("Unshared credential: %d", result.id);
|
|
3769
3858
|
return result;
|
|
3770
3859
|
}
|
|
3771
3860
|
// ===========================================================================
|
|
@@ -3781,12 +3870,12 @@ var CredService = class extends BaseSDK {
|
|
|
3781
3870
|
* @returns Promise resolving to the delete result
|
|
3782
3871
|
*/
|
|
3783
3872
|
async delete(id, options) {
|
|
3784
|
-
|
|
3873
|
+
log21("Deleting credential by ID: %d", id);
|
|
3785
3874
|
const result = await this.request(`/v1/user/creds/${id}`, {
|
|
3786
3875
|
method: "DELETE",
|
|
3787
3876
|
...options
|
|
3788
3877
|
});
|
|
3789
|
-
|
|
3878
|
+
log21("Deleted credential: %d, success=%s", id, result.success);
|
|
3790
3879
|
return result;
|
|
3791
3880
|
}
|
|
3792
3881
|
/**
|
|
@@ -3800,7 +3889,7 @@ var CredService = class extends BaseSDK {
|
|
|
3800
3889
|
* @returns Promise resolving to the delete result
|
|
3801
3890
|
*/
|
|
3802
3891
|
async deleteByKey(key, options) {
|
|
3803
|
-
|
|
3892
|
+
log21("Deleting credential by key: %s", key);
|
|
3804
3893
|
const result = await this.request(
|
|
3805
3894
|
`/v1/user/creds/key/${encodeURIComponent(key)}`,
|
|
3806
3895
|
{
|
|
@@ -3808,7 +3897,7 @@ var CredService = class extends BaseSDK {
|
|
|
3808
3897
|
...options
|
|
3809
3898
|
}
|
|
3810
3899
|
);
|
|
3811
|
-
|
|
3900
|
+
log21("Deleted credential by key: %s, success=%s", key, result.success);
|
|
3812
3901
|
return result;
|
|
3813
3902
|
}
|
|
3814
3903
|
// ===========================================================================
|
|
@@ -3827,12 +3916,12 @@ var CredService = class extends BaseSDK {
|
|
|
3827
3916
|
* @returns Promise resolving to the credential status list
|
|
3828
3917
|
*/
|
|
3829
3918
|
async getSkillCredStatus(skillIdentifier, options) {
|
|
3830
|
-
|
|
3919
|
+
log21("Getting skill cred status: %s", skillIdentifier);
|
|
3831
3920
|
const result = await this.request(
|
|
3832
3921
|
`/v1/skills/${encodeURIComponent(skillIdentifier)}/creds/status`,
|
|
3833
3922
|
options
|
|
3834
3923
|
);
|
|
3835
|
-
|
|
3924
|
+
log21("Skill %s has %d credential requirements", skillIdentifier, result.length);
|
|
3836
3925
|
return result;
|
|
3837
3926
|
}
|
|
3838
3927
|
// ===========================================================================
|
|
@@ -3871,7 +3960,7 @@ var CredService = class extends BaseSDK {
|
|
|
3871
3960
|
*/
|
|
3872
3961
|
async inject(request, options) {
|
|
3873
3962
|
var _a, _b, _c, _d;
|
|
3874
|
-
|
|
3963
|
+
log21("Injecting credentials by keys: %O (sandbox=%s)", request.keys, request.sandbox);
|
|
3875
3964
|
const result = await this.request(
|
|
3876
3965
|
"/v1/plugins/run-buildin-tools/inject-creds",
|
|
3877
3966
|
{
|
|
@@ -3883,7 +3972,7 @@ var CredService = class extends BaseSDK {
|
|
|
3883
3972
|
...options
|
|
3884
3973
|
}
|
|
3885
3974
|
);
|
|
3886
|
-
|
|
3975
|
+
log21(
|
|
3887
3976
|
"Inject result: success=%s, env=%d, files=%d, notFound=%d",
|
|
3888
3977
|
result.success,
|
|
3889
3978
|
Object.keys(((_a = result.credentials) == null ? void 0 : _a.env) || {}).length,
|
|
@@ -3925,7 +4014,7 @@ var CredService = class extends BaseSDK {
|
|
|
3925
4014
|
*/
|
|
3926
4015
|
async injectForSkill(request, options) {
|
|
3927
4016
|
var _a, _b, _c, _d;
|
|
3928
|
-
|
|
4017
|
+
log21(
|
|
3929
4018
|
"Injecting credentials for skill: %s (sandbox=%s)",
|
|
3930
4019
|
request.skillIdentifier,
|
|
3931
4020
|
request.sandbox
|
|
@@ -3941,7 +4030,7 @@ var CredService = class extends BaseSDK {
|
|
|
3941
4030
|
...options
|
|
3942
4031
|
}
|
|
3943
4032
|
);
|
|
3944
|
-
|
|
4033
|
+
log21(
|
|
3945
4034
|
"Inject result: success=%s, env=%d, files=%d, missing=%d",
|
|
3946
4035
|
result.success,
|
|
3947
4036
|
Object.keys(((_a = result.credentials) == null ? void 0 : _a.env) || {}).length,
|
|
@@ -3953,11 +4042,11 @@ var CredService = class extends BaseSDK {
|
|
|
3953
4042
|
};
|
|
3954
4043
|
|
|
3955
4044
|
// src/market/services/DeploymentService.ts
|
|
3956
|
-
import
|
|
3957
|
-
var
|
|
4045
|
+
import debug22 from "debug";
|
|
4046
|
+
var log22 = debug22("lobe-market-sdk:deployments");
|
|
3958
4047
|
var DeploymentService = class extends BaseSDK {
|
|
3959
4048
|
async prepareUpload(data, options) {
|
|
3960
|
-
|
|
4049
|
+
log22("Preparing deployment upload with %d files", data.files.length);
|
|
3961
4050
|
const result = await this.request(
|
|
3962
4051
|
"/v1/deployments/uploads/prepare",
|
|
3963
4052
|
{
|
|
@@ -3969,7 +4058,7 @@ var DeploymentService = class extends BaseSDK {
|
|
|
3969
4058
|
return result.data;
|
|
3970
4059
|
}
|
|
3971
4060
|
async ingestUpload(uploadId, options) {
|
|
3972
|
-
|
|
4061
|
+
log22("Ingesting deployment upload: %s", uploadId);
|
|
3973
4062
|
const result = await this.request(
|
|
3974
4063
|
`/v1/deployments/uploads/${encodeURIComponent(uploadId)}/ingest`,
|
|
3975
4064
|
{ ...options, method: "POST" }
|
|
@@ -3977,7 +4066,7 @@ var DeploymentService = class extends BaseSDK {
|
|
|
3977
4066
|
return result.data;
|
|
3978
4067
|
}
|
|
3979
4068
|
async finalizeUpload(uploadId, options) {
|
|
3980
|
-
|
|
4069
|
+
log22("Finalizing deployment upload: %s", uploadId);
|
|
3981
4070
|
const result = await this.request(
|
|
3982
4071
|
`/v1/deployments/uploads/${encodeURIComponent(uploadId)}/finalize`,
|
|
3983
4072
|
{ ...options, method: "POST" }
|
|
@@ -3987,9 +4076,9 @@ var DeploymentService = class extends BaseSDK {
|
|
|
3987
4076
|
};
|
|
3988
4077
|
|
|
3989
4078
|
// src/market/services/DiscoveryService.ts
|
|
3990
|
-
import
|
|
4079
|
+
import debug23 from "debug";
|
|
3991
4080
|
import urlJoin4 from "url-join";
|
|
3992
|
-
var
|
|
4081
|
+
var log23 = debug23("lobe-market-sdk:discovery");
|
|
3993
4082
|
var DiscoveryService = class extends BaseSDK {
|
|
3994
4083
|
/**
|
|
3995
4084
|
* Retrieves the service discovery document
|
|
@@ -4001,9 +4090,9 @@ var DiscoveryService = class extends BaseSDK {
|
|
|
4001
4090
|
* @returns Promise resolving to the service discovery document
|
|
4002
4091
|
*/
|
|
4003
4092
|
async getDiscoveryDocument() {
|
|
4004
|
-
|
|
4093
|
+
log23("Fetching discovery document");
|
|
4005
4094
|
if (this.discoveryDoc) {
|
|
4006
|
-
|
|
4095
|
+
log23("Returning cached discovery document");
|
|
4007
4096
|
return this.discoveryDoc;
|
|
4008
4097
|
}
|
|
4009
4098
|
const res = await fetch(urlJoin4(this.baseUrl, "/.well-known/discovery"));
|
|
@@ -4011,14 +4100,14 @@ var DiscoveryService = class extends BaseSDK {
|
|
|
4011
4100
|
throw new Error(await res.text());
|
|
4012
4101
|
}
|
|
4013
4102
|
this.discoveryDoc = await res.json();
|
|
4014
|
-
|
|
4103
|
+
log23("Discovery document successfully fetched");
|
|
4015
4104
|
return this.discoveryDoc;
|
|
4016
4105
|
}
|
|
4017
4106
|
};
|
|
4018
4107
|
|
|
4019
4108
|
// src/market/services/FeedbackService.ts
|
|
4020
|
-
import
|
|
4021
|
-
var
|
|
4109
|
+
import debug24 from "debug";
|
|
4110
|
+
var log24 = debug24("lobe-market-sdk:feedback");
|
|
4022
4111
|
var FeedbackService = class extends BaseSDK {
|
|
4023
4112
|
/**
|
|
4024
4113
|
* Submits user feedback
|
|
@@ -4048,7 +4137,7 @@ var FeedbackService = class extends BaseSDK {
|
|
|
4048
4137
|
* ```
|
|
4049
4138
|
*/
|
|
4050
4139
|
async submitFeedback(data, options) {
|
|
4051
|
-
|
|
4140
|
+
log24("Submitting feedback: %s", data.title);
|
|
4052
4141
|
const result = await this.request("/v1/user/feedback", {
|
|
4053
4142
|
body: JSON.stringify(data),
|
|
4054
4143
|
headers: {
|
|
@@ -4057,14 +4146,14 @@ var FeedbackService = class extends BaseSDK {
|
|
|
4057
4146
|
method: "POST",
|
|
4058
4147
|
...options
|
|
4059
4148
|
});
|
|
4060
|
-
|
|
4149
|
+
log24("Feedback submitted successfully: %s", result.issueId);
|
|
4061
4150
|
return result;
|
|
4062
4151
|
}
|
|
4063
4152
|
};
|
|
4064
4153
|
|
|
4065
4154
|
// src/market/services/PluginsService.ts
|
|
4066
|
-
import
|
|
4067
|
-
var
|
|
4155
|
+
import debug25 from "debug";
|
|
4156
|
+
var log25 = debug25("lobe-market-sdk:plugins");
|
|
4068
4157
|
function encodeBase64(input) {
|
|
4069
4158
|
if (typeof Buffer !== "undefined") {
|
|
4070
4159
|
return Buffer.from(input, "utf8").toString("base64");
|
|
@@ -4090,9 +4179,9 @@ var PluginsService = class extends BaseSDK {
|
|
|
4090
4179
|
const locale = params.locale || this.defaultLocale;
|
|
4091
4180
|
const queryParams = { ...params, locale };
|
|
4092
4181
|
const queryString = this.buildQueryString(queryParams);
|
|
4093
|
-
|
|
4182
|
+
log25("Getting plugin list: %O", queryParams);
|
|
4094
4183
|
const result = await this.request(`/v1/plugins${queryString}`, options);
|
|
4095
|
-
|
|
4184
|
+
log25("Retrieved %d plugins", result.items.length);
|
|
4096
4185
|
return result;
|
|
4097
4186
|
}
|
|
4098
4187
|
/**
|
|
@@ -4110,12 +4199,12 @@ var PluginsService = class extends BaseSDK {
|
|
|
4110
4199
|
const locale = params.locale || this.defaultLocale;
|
|
4111
4200
|
const queryParams = { ...params, locale };
|
|
4112
4201
|
const queryString = this.buildQueryString(queryParams);
|
|
4113
|
-
|
|
4202
|
+
log25("Getting plugin categories: %O", queryParams);
|
|
4114
4203
|
const result = await this.request(
|
|
4115
4204
|
`/v1/plugins/categories${queryString}`,
|
|
4116
4205
|
options
|
|
4117
4206
|
);
|
|
4118
|
-
|
|
4207
|
+
log25("Retrieved %d categories", result.length);
|
|
4119
4208
|
return result;
|
|
4120
4209
|
}
|
|
4121
4210
|
/**
|
|
@@ -4129,12 +4218,12 @@ var PluginsService = class extends BaseSDK {
|
|
|
4129
4218
|
* @returns Promise resolving to an array containing identifiers array and last modified time
|
|
4130
4219
|
*/
|
|
4131
4220
|
async getPublishedIdentifiers(options) {
|
|
4132
|
-
|
|
4221
|
+
log25("Getting published plugin identifiers");
|
|
4133
4222
|
const result = await this.request(
|
|
4134
4223
|
"/v1/plugins/identifiers",
|
|
4135
4224
|
options
|
|
4136
4225
|
);
|
|
4137
|
-
|
|
4226
|
+
log25("Retrieved %d published plugin identifiers", result.length);
|
|
4138
4227
|
return result;
|
|
4139
4228
|
}
|
|
4140
4229
|
/**
|
|
@@ -4145,12 +4234,12 @@ var PluginsService = class extends BaseSDK {
|
|
|
4145
4234
|
*/
|
|
4146
4235
|
async getSitemap(params = {}, options) {
|
|
4147
4236
|
const queryString = this.buildQueryString(params);
|
|
4148
|
-
|
|
4237
|
+
log25("Getting plugin sitemap%s", queryString);
|
|
4149
4238
|
const result = await this.request(
|
|
4150
4239
|
`/v1/plugins/sitemap${queryString}`,
|
|
4151
4240
|
options
|
|
4152
4241
|
);
|
|
4153
|
-
|
|
4242
|
+
log25(
|
|
4154
4243
|
"Retrieved plugin sitemap page %d/%d (%d items)",
|
|
4155
4244
|
result.currentPage,
|
|
4156
4245
|
result.totalPages,
|
|
@@ -4175,7 +4264,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4175
4264
|
version,
|
|
4176
4265
|
identifier
|
|
4177
4266
|
}, options) {
|
|
4178
|
-
|
|
4267
|
+
log25("Getting plugin manifest: %O", { identifier, locale, version });
|
|
4179
4268
|
const localeParam = locale || this.defaultLocale;
|
|
4180
4269
|
const params = { locale: localeParam };
|
|
4181
4270
|
if (version) {
|
|
@@ -4186,7 +4275,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4186
4275
|
`/v1/plugins/${identifier}/manifest${queryString}`,
|
|
4187
4276
|
options
|
|
4188
4277
|
);
|
|
4189
|
-
|
|
4278
|
+
log25("Plugin manifest successfully retrieved: %s", identifier);
|
|
4190
4279
|
return manifest;
|
|
4191
4280
|
}
|
|
4192
4281
|
/**
|
|
@@ -4203,7 +4292,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4203
4292
|
version,
|
|
4204
4293
|
identifier
|
|
4205
4294
|
}, options) {
|
|
4206
|
-
|
|
4295
|
+
log25("Getting plugin detail: %O", { identifier, locale, version });
|
|
4207
4296
|
const localeParam = locale || this.defaultLocale;
|
|
4208
4297
|
const params = { locale: localeParam };
|
|
4209
4298
|
if (version) {
|
|
@@ -4214,7 +4303,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4214
4303
|
`/v1/plugins/${identifier}${queryString}`,
|
|
4215
4304
|
options
|
|
4216
4305
|
);
|
|
4217
|
-
|
|
4306
|
+
log25("Plugin manifest successfully retrieved: %s", identifier);
|
|
4218
4307
|
return manifest;
|
|
4219
4308
|
}
|
|
4220
4309
|
/**
|
|
@@ -4229,7 +4318,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4229
4318
|
*
|
|
4230
4319
|
*/
|
|
4231
4320
|
async reportInstallation(reportData) {
|
|
4232
|
-
|
|
4321
|
+
log25("Reporting installation for %s@%s", reportData.identifier, reportData.version);
|
|
4233
4322
|
const result = await this.request("/v1/plugins/report/installation", {
|
|
4234
4323
|
body: JSON.stringify(reportData),
|
|
4235
4324
|
headers: {
|
|
@@ -4237,7 +4326,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4237
4326
|
},
|
|
4238
4327
|
method: "POST"
|
|
4239
4328
|
});
|
|
4240
|
-
|
|
4329
|
+
log25("Installation report submitted successfully: %O", result);
|
|
4241
4330
|
return result;
|
|
4242
4331
|
}
|
|
4243
4332
|
/**
|
|
@@ -4251,7 +4340,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4251
4340
|
* @returns Promise resolving to the report submission response
|
|
4252
4341
|
*/
|
|
4253
4342
|
async reportCall(reportData) {
|
|
4254
|
-
|
|
4343
|
+
log25(
|
|
4255
4344
|
"Reporting call for %s@%s - %s:%s",
|
|
4256
4345
|
reportData.identifier,
|
|
4257
4346
|
reportData.version,
|
|
@@ -4265,7 +4354,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4265
4354
|
},
|
|
4266
4355
|
method: "POST"
|
|
4267
4356
|
});
|
|
4268
|
-
|
|
4357
|
+
log25("Call report submitted successfully: %O", result);
|
|
4269
4358
|
return result;
|
|
4270
4359
|
}
|
|
4271
4360
|
/**
|
|
@@ -4277,7 +4366,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4277
4366
|
* @param options - Optional request init overrides
|
|
4278
4367
|
*/
|
|
4279
4368
|
async createEvent(eventData, options) {
|
|
4280
|
-
|
|
4369
|
+
log25("Recording plugin event: %s for %s", eventData.event, eventData.identifier);
|
|
4281
4370
|
await this.request("/v1/plugins/events", {
|
|
4282
4371
|
body: JSON.stringify(eventData),
|
|
4283
4372
|
headers: {
|
|
@@ -4307,7 +4396,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4307
4396
|
* ```
|
|
4308
4397
|
*/
|
|
4309
4398
|
async callCloudGateway(request, options) {
|
|
4310
|
-
|
|
4399
|
+
log25("Calling cloud gateway for plugin %s, tool %s", request.identifier, request.toolName);
|
|
4311
4400
|
const result = await this.request("/v1/plugins/cloud-gateway", {
|
|
4312
4401
|
body: JSON.stringify(request),
|
|
4313
4402
|
headers: {
|
|
@@ -4316,7 +4405,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4316
4405
|
method: "POST",
|
|
4317
4406
|
...options
|
|
4318
4407
|
});
|
|
4319
|
-
|
|
4408
|
+
log25("Cloud gateway call completed: %O", {
|
|
4320
4409
|
identifier: request.identifier,
|
|
4321
4410
|
isError: result.isError,
|
|
4322
4411
|
toolName: request.toolName
|
|
@@ -4357,7 +4446,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4357
4446
|
* ```
|
|
4358
4447
|
*/
|
|
4359
4448
|
async runBuildInTool(toolName, params, context2, options) {
|
|
4360
|
-
|
|
4449
|
+
log25(
|
|
4361
4450
|
"Running built-in tool: %s for user %s, topic %s",
|
|
4362
4451
|
toolName,
|
|
4363
4452
|
context2.userId,
|
|
@@ -4384,7 +4473,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4384
4473
|
method: "POST",
|
|
4385
4474
|
...options
|
|
4386
4475
|
});
|
|
4387
|
-
|
|
4476
|
+
log25("Built-in tool execution completed: %O", {
|
|
4388
4477
|
success: result.success,
|
|
4389
4478
|
toolName
|
|
4390
4479
|
});
|
|
@@ -4497,7 +4586,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4497
4586
|
* @returns Promise resolving to the submitted score
|
|
4498
4587
|
*/
|
|
4499
4588
|
async submitRating(identifier, score, options) {
|
|
4500
|
-
|
|
4589
|
+
log25("Submitting rating for plugin %s: %d", identifier, score);
|
|
4501
4590
|
const result = await this.request(
|
|
4502
4591
|
`/v1/plugins/${encodeURIComponent(identifier)}/ratings`,
|
|
4503
4592
|
{
|
|
@@ -4506,7 +4595,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4506
4595
|
method: "POST"
|
|
4507
4596
|
}
|
|
4508
4597
|
);
|
|
4509
|
-
|
|
4598
|
+
log25("Rating submitted for plugin %s: %d", identifier, result.score);
|
|
4510
4599
|
return result;
|
|
4511
4600
|
}
|
|
4512
4601
|
/**
|
|
@@ -4517,7 +4606,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4517
4606
|
* @returns Promise resolving to success status
|
|
4518
4607
|
*/
|
|
4519
4608
|
async deleteRating(identifier, options) {
|
|
4520
|
-
|
|
4609
|
+
log25("Deleting rating for plugin %s", identifier);
|
|
4521
4610
|
const result = await this.request(
|
|
4522
4611
|
`/v1/plugins/${encodeURIComponent(identifier)}/ratings`,
|
|
4523
4612
|
{
|
|
@@ -4525,7 +4614,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4525
4614
|
method: "DELETE"
|
|
4526
4615
|
}
|
|
4527
4616
|
);
|
|
4528
|
-
|
|
4617
|
+
log25("Rating deleted for plugin %s", identifier);
|
|
4529
4618
|
return result;
|
|
4530
4619
|
}
|
|
4531
4620
|
/**
|
|
@@ -4536,12 +4625,12 @@ var PluginsService = class extends BaseSDK {
|
|
|
4536
4625
|
* @returns Promise resolving to the rating distribution
|
|
4537
4626
|
*/
|
|
4538
4627
|
async getRatingDistribution(identifier, options) {
|
|
4539
|
-
|
|
4628
|
+
log25("Getting rating distribution for plugin: %s", identifier);
|
|
4540
4629
|
const result = await this.request(
|
|
4541
4630
|
`/v1/plugins/${encodeURIComponent(identifier)}/ratings/distribution`,
|
|
4542
4631
|
options
|
|
4543
4632
|
);
|
|
4544
|
-
|
|
4633
|
+
log25("Rating distribution retrieved for plugin %s: %d total", identifier, result.totalCount);
|
|
4545
4634
|
return result;
|
|
4546
4635
|
}
|
|
4547
4636
|
// ============================================================================
|
|
@@ -4557,12 +4646,12 @@ var PluginsService = class extends BaseSDK {
|
|
|
4557
4646
|
*/
|
|
4558
4647
|
async getComments(identifier, params = {}, options) {
|
|
4559
4648
|
const queryString = this.buildQueryString(params);
|
|
4560
|
-
|
|
4649
|
+
log25("Getting comments for plugin %s: %O", identifier, params);
|
|
4561
4650
|
const result = await this.request(
|
|
4562
4651
|
`/v1/plugins/${encodeURIComponent(identifier)}/comments${queryString}`,
|
|
4563
4652
|
options
|
|
4564
4653
|
);
|
|
4565
|
-
|
|
4654
|
+
log25(
|
|
4566
4655
|
"Retrieved %d comments for plugin %s (page %d/%d)",
|
|
4567
4656
|
result.items.length,
|
|
4568
4657
|
identifier,
|
|
@@ -4579,15 +4668,15 @@ var PluginsService = class extends BaseSDK {
|
|
|
4579
4668
|
* @returns Promise resolving to the latest own comment or null when none exists
|
|
4580
4669
|
*/
|
|
4581
4670
|
async getLatestOwnComment(identifier, options) {
|
|
4582
|
-
|
|
4671
|
+
log25("Getting latest own comment for plugin %s", identifier);
|
|
4583
4672
|
const result = await this.request(
|
|
4584
4673
|
`/v1/plugins/${encodeURIComponent(identifier)}/comments/latest`,
|
|
4585
4674
|
options
|
|
4586
4675
|
);
|
|
4587
4676
|
if (result) {
|
|
4588
|
-
|
|
4677
|
+
log25("Retrieved latest own comment for plugin %s: id=%d", identifier, result.id);
|
|
4589
4678
|
} else {
|
|
4590
|
-
|
|
4679
|
+
log25("No own comments found for plugin %s", identifier);
|
|
4591
4680
|
}
|
|
4592
4681
|
return result;
|
|
4593
4682
|
}
|
|
@@ -4600,7 +4689,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4600
4689
|
* @returns Promise resolving to the created comment (with optional rating field)
|
|
4601
4690
|
*/
|
|
4602
4691
|
async createComment(identifier, data, options) {
|
|
4603
|
-
|
|
4692
|
+
log25("Creating comment on plugin %s", identifier);
|
|
4604
4693
|
const result = await this.request(
|
|
4605
4694
|
`/v1/plugins/${encodeURIComponent(identifier)}/comments`,
|
|
4606
4695
|
{
|
|
@@ -4609,7 +4698,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4609
4698
|
method: "POST"
|
|
4610
4699
|
}
|
|
4611
4700
|
);
|
|
4612
|
-
|
|
4701
|
+
log25("Comment created on plugin %s: id=%d", identifier, result.id);
|
|
4613
4702
|
return result;
|
|
4614
4703
|
}
|
|
4615
4704
|
/**
|
|
@@ -4621,7 +4710,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4621
4710
|
* @returns Promise resolving to success status
|
|
4622
4711
|
*/
|
|
4623
4712
|
async deleteComment(identifier, commentId, options) {
|
|
4624
|
-
|
|
4713
|
+
log25("Deleting comment %d from plugin %s", commentId, identifier);
|
|
4625
4714
|
const result = await this.request(
|
|
4626
4715
|
`/v1/plugins/${encodeURIComponent(identifier)}/comments/${commentId}`,
|
|
4627
4716
|
{
|
|
@@ -4629,7 +4718,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4629
4718
|
method: "DELETE"
|
|
4630
4719
|
}
|
|
4631
4720
|
);
|
|
4632
|
-
|
|
4721
|
+
log25("Comment %d deleted from plugin %s", commentId, identifier);
|
|
4633
4722
|
return result;
|
|
4634
4723
|
}
|
|
4635
4724
|
// ============================================================================
|
|
@@ -4644,7 +4733,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4644
4733
|
* @returns Promise resolving to the created reaction
|
|
4645
4734
|
*/
|
|
4646
4735
|
async addReaction(commentId, type, options) {
|
|
4647
|
-
|
|
4736
|
+
log25("Adding %s reaction to comment %d", type, commentId);
|
|
4648
4737
|
const result = await this.request(
|
|
4649
4738
|
`/v1/plugins/comments/${commentId}/reactions`,
|
|
4650
4739
|
{
|
|
@@ -4653,7 +4742,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4653
4742
|
method: "POST"
|
|
4654
4743
|
}
|
|
4655
4744
|
);
|
|
4656
|
-
|
|
4745
|
+
log25("Reaction added to comment %d: %s (id=%d)", commentId, result.type, result.id);
|
|
4657
4746
|
return result;
|
|
4658
4747
|
}
|
|
4659
4748
|
/**
|
|
@@ -4664,7 +4753,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4664
4753
|
* @returns Promise resolving to success status
|
|
4665
4754
|
*/
|
|
4666
4755
|
async removeReaction(commentId, options) {
|
|
4667
|
-
|
|
4756
|
+
log25("Removing reaction from comment %d", commentId);
|
|
4668
4757
|
const result = await this.request(
|
|
4669
4758
|
`/v1/plugins/comments/${commentId}/reactions`,
|
|
4670
4759
|
{
|
|
@@ -4672,14 +4761,14 @@ var PluginsService = class extends BaseSDK {
|
|
|
4672
4761
|
method: "DELETE"
|
|
4673
4762
|
}
|
|
4674
4763
|
);
|
|
4675
|
-
|
|
4764
|
+
log25("Reaction removed from comment %d", commentId);
|
|
4676
4765
|
return result;
|
|
4677
4766
|
}
|
|
4678
4767
|
};
|
|
4679
4768
|
|
|
4680
4769
|
// src/market/services/SandboxService.ts
|
|
4681
|
-
import
|
|
4682
|
-
var
|
|
4770
|
+
import debug26 from "debug";
|
|
4771
|
+
var log26 = debug26("lobe-market-sdk:sandbox");
|
|
4683
4772
|
function encodeBase642(input) {
|
|
4684
4773
|
if (typeof Buffer !== "undefined") {
|
|
4685
4774
|
return Buffer.from(input, "utf8").toString("base64");
|
|
@@ -4713,7 +4802,7 @@ var SandboxService = class extends BaseSDK {
|
|
|
4713
4802
|
*/
|
|
4714
4803
|
async run(params, options) {
|
|
4715
4804
|
const { script, ...rest } = params;
|
|
4716
|
-
|
|
4805
|
+
log26(
|
|
4717
4806
|
"Running %s sandbox script for %s %s",
|
|
4718
4807
|
params.runtime,
|
|
4719
4808
|
params.subject.kind,
|
|
@@ -4729,8 +4818,8 @@ var SandboxService = class extends BaseSDK {
|
|
|
4729
4818
|
};
|
|
4730
4819
|
|
|
4731
4820
|
// src/market/services/SandboxStorageService.ts
|
|
4732
|
-
import
|
|
4733
|
-
var
|
|
4821
|
+
import debug27 from "debug";
|
|
4822
|
+
var log27 = debug27("lobe-market-sdk:sandbox-storage");
|
|
4734
4823
|
var SandboxStorageService2 = class extends BaseSDK {
|
|
4735
4824
|
/**
|
|
4736
4825
|
* Storage directory, quota and the last measured usage.
|
|
@@ -4739,7 +4828,7 @@ var SandboxStorageService2 = class extends BaseSDK {
|
|
|
4739
4828
|
* with its stored figure (`workspaceDrives`), in this one read.
|
|
4740
4829
|
*/
|
|
4741
4830
|
async getStorage(key = "current", options, query) {
|
|
4742
|
-
|
|
4831
|
+
log27("Getting sandbox storage: %s", key);
|
|
4743
4832
|
const suffix = (query == null ? void 0 : query.drives) ? "?drives=true" : "";
|
|
4744
4833
|
const result = await this.request(
|
|
4745
4834
|
`/v1/sandbox/storages/${encodeURIComponent(key)}${suffix}`,
|
|
@@ -4752,7 +4841,7 @@ var SandboxStorageService2 = class extends BaseSDK {
|
|
|
4752
4841
|
* whole directory, so call it on demand rather than on every render.
|
|
4753
4842
|
*/
|
|
4754
4843
|
async refreshUsage(key = "current", context2 = {}, options) {
|
|
4755
|
-
|
|
4844
|
+
log27("Refreshing sandbox storage usage: %s", key);
|
|
4756
4845
|
const result = await this.request(
|
|
4757
4846
|
`/v1/sandbox/storages/${encodeURIComponent(key)}/usage`,
|
|
4758
4847
|
{ ...options, body: JSON.stringify(context2), method: "POST" }
|
|
@@ -4761,7 +4850,7 @@ var SandboxStorageService2 = class extends BaseSDK {
|
|
|
4761
4850
|
}
|
|
4762
4851
|
async listFiles(params = {}, options) {
|
|
4763
4852
|
const { key = "current", path, recursive, topicId } = params;
|
|
4764
|
-
|
|
4853
|
+
log27("Listing sandbox storage files: %s/%s", key, path != null ? path : "");
|
|
4765
4854
|
const query = new URLSearchParams();
|
|
4766
4855
|
if (path) query.set("path", path);
|
|
4767
4856
|
if (recursive) query.set("recursive", "true");
|
|
@@ -4774,7 +4863,7 @@ var SandboxStorageService2 = class extends BaseSDK {
|
|
|
4774
4863
|
}
|
|
4775
4864
|
async readFile(params, options) {
|
|
4776
4865
|
const { key = "current", path, topicId } = params;
|
|
4777
|
-
|
|
4866
|
+
log27("Reading sandbox storage file: %s/%s", key, path);
|
|
4778
4867
|
const query = new URLSearchParams({ path });
|
|
4779
4868
|
if (topicId) query.set("topicId", topicId);
|
|
4780
4869
|
const result = await this.request(
|
|
@@ -4785,7 +4874,7 @@ var SandboxStorageService2 = class extends BaseSDK {
|
|
|
4785
4874
|
}
|
|
4786
4875
|
async writeFile(params, options) {
|
|
4787
4876
|
const { content, key = "current", path, topicId } = params;
|
|
4788
|
-
|
|
4877
|
+
log27("Writing sandbox storage file: %s/%s (%d bytes)", key, path, content.length);
|
|
4789
4878
|
const result = await this.request(
|
|
4790
4879
|
`/v1/sandbox/storages/${encodeURIComponent(key)}/file`,
|
|
4791
4880
|
{
|
|
@@ -4796,6 +4885,58 @@ var SandboxStorageService2 = class extends BaseSDK {
|
|
|
4796
4885
|
);
|
|
4797
4886
|
return result.data;
|
|
4798
4887
|
}
|
|
4888
|
+
/**
|
|
4889
|
+
* Copy one file as it is, or one folder as a zip, to a presigned upload URL
|
|
4890
|
+
* — read off the volume without a sandbox session, which is what lets it
|
|
4891
|
+
* serve a shared storage at its root. Refusals carry `EXPORT_*` codes; a
|
|
4892
|
+
* deployment that cannot export answers 501 `EXPORT_UNAVAILABLE`.
|
|
4893
|
+
*/
|
|
4894
|
+
async exportFile(params, options) {
|
|
4895
|
+
const { key = "current", ...body } = params;
|
|
4896
|
+
log27("Exporting sandbox storage path: %s/%s", key, body.path);
|
|
4897
|
+
const result = await this.request(
|
|
4898
|
+
`/v1/sandbox/storages/${encodeURIComponent(key)}/export`,
|
|
4899
|
+
{
|
|
4900
|
+
...options,
|
|
4901
|
+
body: JSON.stringify(body),
|
|
4902
|
+
method: "POST"
|
|
4903
|
+
}
|
|
4904
|
+
);
|
|
4905
|
+
return result.data;
|
|
4906
|
+
}
|
|
4907
|
+
/**
|
|
4908
|
+
* What takes the space: bytes per category, the largest items of each, and
|
|
4909
|
+
* the largest files and directories. Each call advances the walk by at most
|
|
4910
|
+
* one step; call again while `status` is `scanning` or `running`. A finished
|
|
4911
|
+
* analysis is reused for 15 minutes unless `restart` is set. Served off the
|
|
4912
|
+
* volume and allowed over quota; a deployment that cannot analyse answers
|
|
4913
|
+
* 409 `storage_analysis_unavailable`.
|
|
4914
|
+
*/
|
|
4915
|
+
async analyzeStorage(params = {}, options) {
|
|
4916
|
+
const { key = "current", ...body } = params;
|
|
4917
|
+
log27("Analysing sandbox storage: %s", key);
|
|
4918
|
+
const result = await this.request(
|
|
4919
|
+
`/v1/sandbox/storages/${encodeURIComponent(key)}/analysis`,
|
|
4920
|
+
{ ...options, body: JSON.stringify(body), method: "POST" }
|
|
4921
|
+
);
|
|
4922
|
+
return result.data;
|
|
4923
|
+
}
|
|
4924
|
+
/**
|
|
4925
|
+
* Irreversibly delete up to 100 storage-relative paths. With
|
|
4926
|
+
* `regenerableOnly`, the whole call is refused (400
|
|
4927
|
+
* `storage_paths_not_regenerable`, offending paths in `details.paths`)
|
|
4928
|
+
* unless every path is dependencies, a cache or build output. `done: false`
|
|
4929
|
+
* means time ran out: call again with `pending`.
|
|
4930
|
+
*/
|
|
4931
|
+
async deleteFiles(params, options) {
|
|
4932
|
+
const { key = "current", ...body } = params;
|
|
4933
|
+
log27("Deleting %d sandbox storage paths: %s", body.paths.length, key);
|
|
4934
|
+
const result = await this.request(
|
|
4935
|
+
`/v1/sandbox/storages/${encodeURIComponent(key)}/files/delete`,
|
|
4936
|
+
{ ...options, body: JSON.stringify(body), method: "POST" }
|
|
4937
|
+
);
|
|
4938
|
+
return result.data;
|
|
4939
|
+
}
|
|
4799
4940
|
/**
|
|
4800
4941
|
* The storage's instances, newest first.
|
|
4801
4942
|
*
|
|
@@ -4879,7 +5020,7 @@ var SandboxStorageService2 = class extends BaseSDK {
|
|
|
4879
5020
|
*/
|
|
4880
5021
|
async createDirectory(params, options) {
|
|
4881
5022
|
const { key = "current", path, topicId } = params;
|
|
4882
|
-
|
|
5023
|
+
log27("Creating sandbox storage directory: %s/%s", key, path);
|
|
4883
5024
|
const result = await this.request(
|
|
4884
5025
|
`/v1/sandbox/storages/${encodeURIComponent(key)}/directory`,
|
|
4885
5026
|
{
|
|
@@ -4892,7 +5033,7 @@ var SandboxStorageService2 = class extends BaseSDK {
|
|
|
4892
5033
|
}
|
|
4893
5034
|
async deleteFile(params, options) {
|
|
4894
5035
|
const { key = "current", path, recursive, topicId } = params;
|
|
4895
|
-
|
|
5036
|
+
log27("Deleting sandbox storage path: %s/%s", key, path);
|
|
4896
5037
|
const query = new URLSearchParams({ path });
|
|
4897
5038
|
if (recursive) query.set("recursive", "true");
|
|
4898
5039
|
if (topicId) query.set("topicId", topicId);
|
|
@@ -4912,7 +5053,7 @@ var SandboxStorageService2 = class extends BaseSDK {
|
|
|
4912
5053
|
*/
|
|
4913
5054
|
async renameFile(params, options) {
|
|
4914
5055
|
const { key = "current", newPath, path, topicId } = params;
|
|
4915
|
-
|
|
5056
|
+
log27("Renaming sandbox storage path: %s/%s -> %s", key, path, newPath);
|
|
4916
5057
|
const result = await this.request(
|
|
4917
5058
|
`/v1/sandbox/storages/${encodeURIComponent(key)}/rename`,
|
|
4918
5059
|
{
|
|
@@ -4926,8 +5067,8 @@ var SandboxStorageService2 = class extends BaseSDK {
|
|
|
4926
5067
|
};
|
|
4927
5068
|
|
|
4928
5069
|
// src/market/services/SkillService.ts
|
|
4929
|
-
import
|
|
4930
|
-
var
|
|
5070
|
+
import debug28 from "debug";
|
|
5071
|
+
var log28 = debug28("lobe-market-sdk:skill");
|
|
4931
5072
|
var SkillService2 = class extends BaseSDK {
|
|
4932
5073
|
/**
|
|
4933
5074
|
* Lists all available skill providers
|
|
@@ -4940,9 +5081,9 @@ var SkillService2 = class extends BaseSDK {
|
|
|
4940
5081
|
*/
|
|
4941
5082
|
async listProviders(options) {
|
|
4942
5083
|
var _a;
|
|
4943
|
-
|
|
5084
|
+
log28("Listing skill providers");
|
|
4944
5085
|
const result = await this.request("/v1/skill/providers", options);
|
|
4945
|
-
|
|
5086
|
+
log28("Found %d skill providers", ((_a = result.providers) == null ? void 0 : _a.length) || 0);
|
|
4946
5087
|
return result;
|
|
4947
5088
|
}
|
|
4948
5089
|
/**
|
|
@@ -4957,12 +5098,12 @@ var SkillService2 = class extends BaseSDK {
|
|
|
4957
5098
|
*/
|
|
4958
5099
|
async listTools(provider, options) {
|
|
4959
5100
|
var _a;
|
|
4960
|
-
|
|
5101
|
+
log28("Listing tools for provider: %s", provider);
|
|
4961
5102
|
const result = await this.request(
|
|
4962
5103
|
`/v1/skill/${encodeURIComponent(provider)}/tools`,
|
|
4963
5104
|
options
|
|
4964
5105
|
);
|
|
4965
|
-
|
|
5106
|
+
log28("Found %d tools for provider %s", ((_a = result.tools) == null ? void 0 : _a.length) || 0, provider);
|
|
4966
5107
|
return result;
|
|
4967
5108
|
}
|
|
4968
5109
|
/**
|
|
@@ -4979,12 +5120,12 @@ var SkillService2 = class extends BaseSDK {
|
|
|
4979
5120
|
*/
|
|
4980
5121
|
async listLiveTools(provider, options) {
|
|
4981
5122
|
var _a;
|
|
4982
|
-
|
|
5123
|
+
log28("Listing live tools for provider: %s", provider);
|
|
4983
5124
|
const result = await this.request(
|
|
4984
5125
|
`/v1/skill/${encodeURIComponent(provider)}/tools/live`,
|
|
4985
5126
|
options
|
|
4986
5127
|
);
|
|
4987
|
-
|
|
5128
|
+
log28("Found %d live tools for provider %s", ((_a = result.tools) == null ? void 0 : _a.length) || 0, provider);
|
|
4988
5129
|
return result;
|
|
4989
5130
|
}
|
|
4990
5131
|
/**
|
|
@@ -5000,12 +5141,12 @@ var SkillService2 = class extends BaseSDK {
|
|
|
5000
5141
|
*/
|
|
5001
5142
|
async getTool(provider, toolName, options) {
|
|
5002
5143
|
var _a;
|
|
5003
|
-
|
|
5144
|
+
log28("Getting tool %s from provider %s", toolName, provider);
|
|
5004
5145
|
const result = await this.request(
|
|
5005
5146
|
`/v1/skill/${encodeURIComponent(provider)}/tool/${encodeURIComponent(toolName)}`,
|
|
5006
5147
|
options
|
|
5007
5148
|
);
|
|
5008
|
-
|
|
5149
|
+
log28("Retrieved tool: %s", (_a = result.tool) == null ? void 0 : _a.name);
|
|
5009
5150
|
return result;
|
|
5010
5151
|
}
|
|
5011
5152
|
/**
|
|
@@ -5019,12 +5160,12 @@ var SkillService2 = class extends BaseSDK {
|
|
|
5019
5160
|
* @returns Promise resolving to the connection status
|
|
5020
5161
|
*/
|
|
5021
5162
|
async getStatus(provider, options) {
|
|
5022
|
-
|
|
5163
|
+
log28("Getting status for provider: %s", provider);
|
|
5023
5164
|
const result = await this.request(
|
|
5024
5165
|
`/v1/skill/${encodeURIComponent(provider)}/status`,
|
|
5025
5166
|
options
|
|
5026
5167
|
);
|
|
5027
|
-
|
|
5168
|
+
log28("Provider %s status: connected=%s", provider, result.connected);
|
|
5028
5169
|
return result;
|
|
5029
5170
|
}
|
|
5030
5171
|
/**
|
|
@@ -5052,7 +5193,7 @@ var SkillService2 = class extends BaseSDK {
|
|
|
5052
5193
|
* ```
|
|
5053
5194
|
*/
|
|
5054
5195
|
async callTool(provider, params, options) {
|
|
5055
|
-
|
|
5196
|
+
log28("Calling tool %s on provider %s", params.tool, provider);
|
|
5056
5197
|
const { args, tool, ...rest } = params;
|
|
5057
5198
|
const result = await this.request(
|
|
5058
5199
|
`/v1/skill/${encodeURIComponent(provider)}/call`,
|
|
@@ -5069,14 +5210,14 @@ var SkillService2 = class extends BaseSDK {
|
|
|
5069
5210
|
...options
|
|
5070
5211
|
}
|
|
5071
5212
|
);
|
|
5072
|
-
|
|
5213
|
+
log28("Tool %s call completed: success=%s", params.tool, result.success);
|
|
5073
5214
|
return result;
|
|
5074
5215
|
}
|
|
5075
5216
|
};
|
|
5076
5217
|
|
|
5077
5218
|
// src/market/services/MarketTaskTemplateService.ts
|
|
5078
|
-
import
|
|
5079
|
-
var
|
|
5219
|
+
import debug29 from "debug";
|
|
5220
|
+
var log29 = debug29("lobe-market-sdk:task-templates");
|
|
5080
5221
|
var MarketTaskTemplateService = class extends BaseSDK {
|
|
5081
5222
|
/**
|
|
5082
5223
|
* Retrieves personalized task template recommendations.
|
|
@@ -5099,7 +5240,7 @@ var MarketTaskTemplateService = class extends BaseSDK {
|
|
|
5099
5240
|
refreshSeed: params.refreshSeed,
|
|
5100
5241
|
seedKey: params.seedKey
|
|
5101
5242
|
};
|
|
5102
|
-
|
|
5243
|
+
log29("Getting task template recommendations: %O", body);
|
|
5103
5244
|
const result = await this.request(
|
|
5104
5245
|
"/v1/task-templates/recommendations",
|
|
5105
5246
|
{
|
|
@@ -5108,14 +5249,14 @@ var MarketTaskTemplateService = class extends BaseSDK {
|
|
|
5108
5249
|
method: "POST"
|
|
5109
5250
|
}
|
|
5110
5251
|
);
|
|
5111
|
-
|
|
5252
|
+
log29("Retrieved %d task template recommendations", result.items.length);
|
|
5112
5253
|
return result;
|
|
5113
5254
|
}
|
|
5114
5255
|
};
|
|
5115
5256
|
|
|
5116
5257
|
// src/market/services/MarketSkillCollectionService.ts
|
|
5117
|
-
import
|
|
5118
|
-
var
|
|
5258
|
+
import debug30 from "debug";
|
|
5259
|
+
var log30 = debug30("lobe-market-sdk:skill-collections");
|
|
5119
5260
|
var MarketSkillCollectionService = class extends BaseSDK {
|
|
5120
5261
|
async getSkillCollectionDetail(slug, params = {}, options) {
|
|
5121
5262
|
const locale = params.locale || this.defaultLocale;
|
|
@@ -5124,12 +5265,12 @@ var MarketSkillCollectionService = class extends BaseSDK {
|
|
|
5124
5265
|
locale
|
|
5125
5266
|
};
|
|
5126
5267
|
const queryString = this.buildQueryString(queryParams);
|
|
5127
|
-
|
|
5268
|
+
log30("Getting skill collection detail: %s %O", slug, queryParams);
|
|
5128
5269
|
const result = await this.request(
|
|
5129
5270
|
`/v1/skills/collections/${encodeURIComponent(slug)}${queryString}`,
|
|
5130
5271
|
options
|
|
5131
5272
|
);
|
|
5132
|
-
|
|
5273
|
+
log30("Skill collection detail retrieved: %s (%d items)", slug, result.items.length);
|
|
5133
5274
|
return result;
|
|
5134
5275
|
}
|
|
5135
5276
|
async getSkillCollections(params = {}, options) {
|
|
@@ -5139,19 +5280,19 @@ var MarketSkillCollectionService = class extends BaseSDK {
|
|
|
5139
5280
|
locale
|
|
5140
5281
|
};
|
|
5141
5282
|
const queryString = this.buildQueryString(queryParams);
|
|
5142
|
-
|
|
5283
|
+
log30("Getting skill collections: %O", queryParams);
|
|
5143
5284
|
const result = await this.request(
|
|
5144
5285
|
`/v1/skills/collections${queryString}`,
|
|
5145
5286
|
options
|
|
5146
5287
|
);
|
|
5147
|
-
|
|
5288
|
+
log30("Retrieved %d skill collections", result.length);
|
|
5148
5289
|
return result;
|
|
5149
5290
|
}
|
|
5150
5291
|
};
|
|
5151
5292
|
|
|
5152
5293
|
// src/market/services/MarketSkillService.ts
|
|
5153
|
-
import
|
|
5154
|
-
var
|
|
5294
|
+
import debug31 from "debug";
|
|
5295
|
+
var log31 = debug31("lobe-market-sdk:market-skills");
|
|
5155
5296
|
var MarketSkillService = class extends BaseSDK {
|
|
5156
5297
|
/**
|
|
5157
5298
|
* Retrieves a list of skills from the marketplace
|
|
@@ -5186,9 +5327,9 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5186
5327
|
const locale = params.locale || this.defaultLocale;
|
|
5187
5328
|
const queryParams = { ...params, locale };
|
|
5188
5329
|
const queryString = this.buildQueryString(queryParams);
|
|
5189
|
-
|
|
5330
|
+
log31("Getting skill list: %O", queryParams);
|
|
5190
5331
|
const result = await this.request(`/v1/skills${queryString}`, options);
|
|
5191
|
-
|
|
5332
|
+
log31(
|
|
5192
5333
|
"Retrieved %d skills (page %d/%d)",
|
|
5193
5334
|
result.items.length,
|
|
5194
5335
|
result.currentPage,
|
|
@@ -5227,12 +5368,12 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5227
5368
|
queryParams.version = params.version;
|
|
5228
5369
|
}
|
|
5229
5370
|
const queryString = this.buildQueryString(queryParams);
|
|
5230
|
-
|
|
5371
|
+
log31("Getting skill detail: %s %O", identifier, params);
|
|
5231
5372
|
const result = await this.request(
|
|
5232
5373
|
`/v1/skills/${encodeURIComponent(identifier)}${queryString}`,
|
|
5233
5374
|
options
|
|
5234
5375
|
);
|
|
5235
|
-
|
|
5376
|
+
log31("Skill detail retrieved: %s (v%s)", identifier, result.version);
|
|
5236
5377
|
return result;
|
|
5237
5378
|
}
|
|
5238
5379
|
/**
|
|
@@ -5263,7 +5404,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5263
5404
|
if (version) {
|
|
5264
5405
|
url += `?version=${encodeURIComponent(version)}`;
|
|
5265
5406
|
}
|
|
5266
|
-
|
|
5407
|
+
log31("Generated download URL: %s", url);
|
|
5267
5408
|
return url;
|
|
5268
5409
|
}
|
|
5269
5410
|
/**
|
|
@@ -5287,7 +5428,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5287
5428
|
* ```
|
|
5288
5429
|
*/
|
|
5289
5430
|
async downloadSkill(identifier, version, options) {
|
|
5290
|
-
|
|
5431
|
+
log31("Downloading skill: %s (version: %s)", identifier, version || "latest");
|
|
5291
5432
|
const queryParams = {};
|
|
5292
5433
|
if (version) {
|
|
5293
5434
|
queryParams.version = version;
|
|
@@ -5303,7 +5444,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5303
5444
|
});
|
|
5304
5445
|
if (!response.ok) {
|
|
5305
5446
|
const errorText = await response.text();
|
|
5306
|
-
|
|
5447
|
+
log31("Download failed: %s %s", response.status, errorText);
|
|
5307
5448
|
throw new Error(`Failed to download skill: ${response.statusText}`);
|
|
5308
5449
|
}
|
|
5309
5450
|
const contentDisposition = response.headers.get("content-disposition");
|
|
@@ -5315,7 +5456,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5315
5456
|
}
|
|
5316
5457
|
}
|
|
5317
5458
|
const buffer = await response.arrayBuffer();
|
|
5318
|
-
|
|
5459
|
+
log31("Downloaded skill: %s (%d bytes)", filename, buffer.byteLength);
|
|
5319
5460
|
return { buffer, filename };
|
|
5320
5461
|
}
|
|
5321
5462
|
/**
|
|
@@ -5343,12 +5484,12 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5343
5484
|
const locale = params.locale || this.defaultLocale;
|
|
5344
5485
|
const queryParams = { ...params, locale };
|
|
5345
5486
|
const queryString = this.buildQueryString(queryParams);
|
|
5346
|
-
|
|
5487
|
+
log31("Getting skill categories: %O", queryParams);
|
|
5347
5488
|
const result = await this.request(
|
|
5348
5489
|
`/v1/skills/categories${queryString}`,
|
|
5349
5490
|
options
|
|
5350
5491
|
);
|
|
5351
|
-
|
|
5492
|
+
log31("Retrieved %d categories", result.length);
|
|
5352
5493
|
return result;
|
|
5353
5494
|
}
|
|
5354
5495
|
/**
|
|
@@ -5363,12 +5504,12 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5363
5504
|
* @returns Promise resolving to an array of identifiers with last modified times
|
|
5364
5505
|
*/
|
|
5365
5506
|
async getPublishedIdentifiers(options) {
|
|
5366
|
-
|
|
5507
|
+
log31("Getting published skill identifiers");
|
|
5367
5508
|
const result = await this.request(
|
|
5368
5509
|
"/v1/skills/identifiers",
|
|
5369
5510
|
options
|
|
5370
5511
|
);
|
|
5371
|
-
|
|
5512
|
+
log31("Retrieved %d published skill identifiers", result.length);
|
|
5372
5513
|
return result;
|
|
5373
5514
|
}
|
|
5374
5515
|
/**
|
|
@@ -5379,9 +5520,9 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5379
5520
|
*/
|
|
5380
5521
|
async getSitemap(params = {}, options) {
|
|
5381
5522
|
const queryString = this.buildQueryString(params);
|
|
5382
|
-
|
|
5523
|
+
log31("Getting skill sitemap%s", queryString);
|
|
5383
5524
|
const result = await this.request(`/v1/skills/sitemap${queryString}`, options);
|
|
5384
|
-
|
|
5525
|
+
log31(
|
|
5385
5526
|
"Retrieved skill sitemap page %d/%d (%d items)",
|
|
5386
5527
|
result.currentPage,
|
|
5387
5528
|
result.totalPages,
|
|
@@ -5397,13 +5538,13 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5397
5538
|
* @returns Promise resolving to true if skill exists, false otherwise
|
|
5398
5539
|
*/
|
|
5399
5540
|
async checkSkillExists(identifier, options) {
|
|
5400
|
-
|
|
5541
|
+
log31("Checking if skill exists: %s", identifier);
|
|
5401
5542
|
try {
|
|
5402
5543
|
await this.getSkillDetail(identifier, {}, options);
|
|
5403
|
-
|
|
5544
|
+
log31("Skill exists: %s", identifier);
|
|
5404
5545
|
return true;
|
|
5405
5546
|
} catch (e) {
|
|
5406
|
-
|
|
5547
|
+
log31("Skill does not exist: %s", identifier);
|
|
5407
5548
|
return false;
|
|
5408
5549
|
}
|
|
5409
5550
|
}
|
|
@@ -5424,12 +5565,12 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5424
5565
|
* ```
|
|
5425
5566
|
*/
|
|
5426
5567
|
async getSkillVersions(identifier, options) {
|
|
5427
|
-
|
|
5568
|
+
log31("Getting skill versions: %s", identifier);
|
|
5428
5569
|
const result = await this.request(
|
|
5429
5570
|
`/v1/skills/${encodeURIComponent(identifier)}/versions`,
|
|
5430
5571
|
options
|
|
5431
5572
|
);
|
|
5432
|
-
|
|
5573
|
+
log31("Retrieved %d versions for skill %s", result.data.length, identifier);
|
|
5433
5574
|
return result.data;
|
|
5434
5575
|
}
|
|
5435
5576
|
/**
|
|
@@ -5453,12 +5594,12 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5453
5594
|
const locale = params.locale || this.defaultLocale;
|
|
5454
5595
|
const queryParams = { locale };
|
|
5455
5596
|
const queryString = this.buildQueryString(queryParams);
|
|
5456
|
-
|
|
5597
|
+
log31("Getting skill version: %s@%s", identifier, version);
|
|
5457
5598
|
const result = await this.request(
|
|
5458
5599
|
`/v1/skills/${encodeURIComponent(identifier)}/versions/${encodeURIComponent(version)}${queryString}`,
|
|
5459
5600
|
options
|
|
5460
5601
|
);
|
|
5461
|
-
|
|
5602
|
+
log31("Skill version detail retrieved: %s@%s", identifier, version);
|
|
5462
5603
|
return result;
|
|
5463
5604
|
}
|
|
5464
5605
|
/**
|
|
@@ -5487,13 +5628,13 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5487
5628
|
* ```
|
|
5488
5629
|
*/
|
|
5489
5630
|
async reportGitHubSkill(params, options) {
|
|
5490
|
-
|
|
5631
|
+
log31("Reporting GitHub skill: %s", params.gitUrl);
|
|
5491
5632
|
const result = await this.request("/v1/skills/report/github", {
|
|
5492
5633
|
...options,
|
|
5493
5634
|
body: JSON.stringify(params),
|
|
5494
5635
|
method: "POST"
|
|
5495
5636
|
});
|
|
5496
|
-
|
|
5637
|
+
log31("GitHub skill reported: %s (status: %s)", result.identifier, result.status);
|
|
5497
5638
|
return result;
|
|
5498
5639
|
}
|
|
5499
5640
|
/**
|
|
@@ -5518,7 +5659,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5518
5659
|
* ```
|
|
5519
5660
|
*/
|
|
5520
5661
|
async reportSkillInstall(params, options) {
|
|
5521
|
-
|
|
5662
|
+
log31("Reporting skill install: %s (success: %s)", params.identifier, params.success);
|
|
5522
5663
|
const result = await this.request(
|
|
5523
5664
|
"/v1/skills/report/installation",
|
|
5524
5665
|
{
|
|
@@ -5527,7 +5668,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5527
5668
|
method: "POST"
|
|
5528
5669
|
}
|
|
5529
5670
|
);
|
|
5530
|
-
|
|
5671
|
+
log31("Skill install reported: %s", result.message);
|
|
5531
5672
|
return result;
|
|
5532
5673
|
}
|
|
5533
5674
|
/**
|
|
@@ -5539,7 +5680,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5539
5680
|
* @returns Promise resolving to the submitted score
|
|
5540
5681
|
*/
|
|
5541
5682
|
async submitRating(identifier, score, options) {
|
|
5542
|
-
|
|
5683
|
+
log31("Submitting rating for skill %s: %d", identifier, score);
|
|
5543
5684
|
const result = await this.request(
|
|
5544
5685
|
`/v1/skills/${encodeURIComponent(identifier)}/ratings`,
|
|
5545
5686
|
{
|
|
@@ -5548,7 +5689,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5548
5689
|
method: "POST"
|
|
5549
5690
|
}
|
|
5550
5691
|
);
|
|
5551
|
-
|
|
5692
|
+
log31("Rating submitted for skill %s: %d", identifier, result.score);
|
|
5552
5693
|
return result;
|
|
5553
5694
|
}
|
|
5554
5695
|
/**
|
|
@@ -5559,12 +5700,12 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5559
5700
|
* @returns Promise resolving to the rating distribution
|
|
5560
5701
|
*/
|
|
5561
5702
|
async getRatingDistribution(identifier, options) {
|
|
5562
|
-
|
|
5703
|
+
log31("Getting rating distribution for skill: %s", identifier);
|
|
5563
5704
|
const result = await this.request(
|
|
5564
5705
|
`/v1/skills/${encodeURIComponent(identifier)}/ratings/distribution`,
|
|
5565
5706
|
options
|
|
5566
5707
|
);
|
|
5567
|
-
|
|
5708
|
+
log31("Rating distribution retrieved for skill %s: %d total", identifier, result.totalCount);
|
|
5568
5709
|
return result;
|
|
5569
5710
|
}
|
|
5570
5711
|
/**
|
|
@@ -5577,12 +5718,12 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5577
5718
|
*/
|
|
5578
5719
|
async getComments(identifier, params = {}, options) {
|
|
5579
5720
|
const queryString = this.buildQueryString(params);
|
|
5580
|
-
|
|
5721
|
+
log31("Getting comments for skill %s: %O", identifier, params);
|
|
5581
5722
|
const result = await this.request(
|
|
5582
5723
|
`/v1/skills/${encodeURIComponent(identifier)}/comments${queryString}`,
|
|
5583
5724
|
options
|
|
5584
5725
|
);
|
|
5585
|
-
|
|
5726
|
+
log31(
|
|
5586
5727
|
"Retrieved %d comments for skill %s (page %d/%d)",
|
|
5587
5728
|
result.items.length,
|
|
5588
5729
|
identifier,
|
|
@@ -5599,15 +5740,15 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5599
5740
|
* @returns Promise resolving to the latest own comment or null when none exists
|
|
5600
5741
|
*/
|
|
5601
5742
|
async getLatestOwnComment(identifier, options) {
|
|
5602
|
-
|
|
5743
|
+
log31("Getting latest own comment for skill %s", identifier);
|
|
5603
5744
|
const result = await this.request(
|
|
5604
5745
|
`/v1/skills/${encodeURIComponent(identifier)}/comments/latest`,
|
|
5605
5746
|
options
|
|
5606
5747
|
);
|
|
5607
5748
|
if (result) {
|
|
5608
|
-
|
|
5749
|
+
log31("Retrieved latest own comment for skill %s: id=%d", identifier, result.id);
|
|
5609
5750
|
} else {
|
|
5610
|
-
|
|
5751
|
+
log31("No own comments found for skill %s", identifier);
|
|
5611
5752
|
}
|
|
5612
5753
|
return result;
|
|
5613
5754
|
}
|
|
@@ -5620,7 +5761,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5620
5761
|
* @returns Promise resolving to the created comment (with optional rating field)
|
|
5621
5762
|
*/
|
|
5622
5763
|
async createComment(identifier, data, options) {
|
|
5623
|
-
|
|
5764
|
+
log31("Creating comment on skill %s", identifier);
|
|
5624
5765
|
const result = await this.request(
|
|
5625
5766
|
`/v1/skills/${encodeURIComponent(identifier)}/comments`,
|
|
5626
5767
|
{
|
|
@@ -5629,7 +5770,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5629
5770
|
method: "POST"
|
|
5630
5771
|
}
|
|
5631
5772
|
);
|
|
5632
|
-
|
|
5773
|
+
log31("Comment created on skill %s: id=%d", identifier, result.id);
|
|
5633
5774
|
return result;
|
|
5634
5775
|
}
|
|
5635
5776
|
/**
|
|
@@ -5641,7 +5782,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5641
5782
|
* @returns Promise resolving to success status
|
|
5642
5783
|
*/
|
|
5643
5784
|
async deleteComment(identifier, commentId, options) {
|
|
5644
|
-
|
|
5785
|
+
log31("Deleting comment %d from skill %s", commentId, identifier);
|
|
5645
5786
|
const result = await this.request(
|
|
5646
5787
|
`/v1/skills/${encodeURIComponent(identifier)}/comments/${commentId}`,
|
|
5647
5788
|
{
|
|
@@ -5649,7 +5790,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5649
5790
|
method: "DELETE"
|
|
5650
5791
|
}
|
|
5651
5792
|
);
|
|
5652
|
-
|
|
5793
|
+
log31("Comment %d deleted from skill %s", commentId, identifier);
|
|
5653
5794
|
return result;
|
|
5654
5795
|
}
|
|
5655
5796
|
/**
|
|
@@ -5661,7 +5802,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5661
5802
|
* @returns Promise resolving to the created reaction
|
|
5662
5803
|
*/
|
|
5663
5804
|
async addReaction(commentId, type, options) {
|
|
5664
|
-
|
|
5805
|
+
log31("Adding %s reaction to comment %d", type, commentId);
|
|
5665
5806
|
const result = await this.request(
|
|
5666
5807
|
`/v1/skills/comments/${commentId}/reactions`,
|
|
5667
5808
|
{
|
|
@@ -5670,7 +5811,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5670
5811
|
method: "POST"
|
|
5671
5812
|
}
|
|
5672
5813
|
);
|
|
5673
|
-
|
|
5814
|
+
log31("Reaction added to comment %d: %s (id=%d)", commentId, result.type, result.id);
|
|
5674
5815
|
return result;
|
|
5675
5816
|
}
|
|
5676
5817
|
/**
|
|
@@ -5681,7 +5822,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5681
5822
|
* @returns Promise resolving to success status
|
|
5682
5823
|
*/
|
|
5683
5824
|
async removeReaction(commentId, options) {
|
|
5684
|
-
|
|
5825
|
+
log31("Removing reaction from comment %d", commentId);
|
|
5685
5826
|
const result = await this.request(
|
|
5686
5827
|
`/v1/skills/comments/${commentId}/reactions`,
|
|
5687
5828
|
{
|
|
@@ -5689,19 +5830,19 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5689
5830
|
method: "DELETE"
|
|
5690
5831
|
}
|
|
5691
5832
|
);
|
|
5692
|
-
|
|
5833
|
+
log31("Reaction removed from comment %d", commentId);
|
|
5693
5834
|
return result;
|
|
5694
5835
|
}
|
|
5695
5836
|
};
|
|
5696
5837
|
|
|
5697
5838
|
// src/market/services/OrganizationCredsService.ts
|
|
5698
|
-
import
|
|
5839
|
+
import debug32 from "debug";
|
|
5699
5840
|
|
|
5700
5841
|
// src/utils/orgRef.ts
|
|
5701
5842
|
var orgRefToPathSegment = (ref) => typeof ref === "number" ? String(ref) : `workspace:${encodeURIComponent(ref.workspaceId)}`;
|
|
5702
5843
|
|
|
5703
5844
|
// src/market/services/OrganizationCredsService.ts
|
|
5704
|
-
var
|
|
5845
|
+
var log32 = debug32("lobe-market-sdk:org-creds");
|
|
5705
5846
|
var OrganizationCredsService = class extends BaseSDK {
|
|
5706
5847
|
constructor(orgId, options = {}, sharedHeaders, sharedTokenState) {
|
|
5707
5848
|
super(options, sharedHeaders, sharedTokenState);
|
|
@@ -5734,9 +5875,9 @@ var OrganizationCredsService = class extends BaseSDK {
|
|
|
5734
5875
|
*/
|
|
5735
5876
|
async list(options) {
|
|
5736
5877
|
var _a;
|
|
5737
|
-
|
|
5878
|
+
log32("Listing org %s credentials", this.orgSegment);
|
|
5738
5879
|
const result = await this.request(this.base(), options);
|
|
5739
|
-
|
|
5880
|
+
log32("Found %d credentials for org %s", ((_a = result.data) == null ? void 0 : _a.length) || 0, this.orgSegment);
|
|
5740
5881
|
return result;
|
|
5741
5882
|
}
|
|
5742
5883
|
/**
|
|
@@ -5745,20 +5886,20 @@ var OrganizationCredsService = class extends BaseSDK {
|
|
|
5745
5886
|
* owner via `CredService.get(id, { decrypt: true })`.
|
|
5746
5887
|
*/
|
|
5747
5888
|
async get(id, getOptions, options) {
|
|
5748
|
-
|
|
5889
|
+
log32("Getting org %s credential %d (decrypt=%s)", this.orgSegment, id, getOptions == null ? void 0 : getOptions.decrypt);
|
|
5749
5890
|
const queryString = this.buildQueryString((getOptions == null ? void 0 : getOptions.decrypt) ? { decrypt: "true" } : {});
|
|
5750
5891
|
const result = await this.request(
|
|
5751
5892
|
`${this.base()}/${id}${queryString}`,
|
|
5752
5893
|
options
|
|
5753
5894
|
);
|
|
5754
|
-
|
|
5895
|
+
log32("Retrieved org credential: %s", result.key);
|
|
5755
5896
|
return result;
|
|
5756
5897
|
}
|
|
5757
5898
|
// ===========================================================================
|
|
5758
5899
|
// Create
|
|
5759
5900
|
// ===========================================================================
|
|
5760
5901
|
async createKV(data, options) {
|
|
5761
|
-
|
|
5902
|
+
log32("Creating org %s KV credential: %s (type=%s)", this.orgSegment, data.key, data.type);
|
|
5762
5903
|
return this.request(`${this.base()}/kv`, {
|
|
5763
5904
|
body: JSON.stringify(data),
|
|
5764
5905
|
headers: { "Content-Type": "application/json" },
|
|
@@ -5767,7 +5908,7 @@ var OrganizationCredsService = class extends BaseSDK {
|
|
|
5767
5908
|
});
|
|
5768
5909
|
}
|
|
5769
5910
|
async createOAuth(data, options) {
|
|
5770
|
-
|
|
5911
|
+
log32("Creating org %s OAuth credential: %s", this.orgSegment, data.key);
|
|
5771
5912
|
return this.request(`${this.base()}/oauth`, {
|
|
5772
5913
|
body: JSON.stringify(data),
|
|
5773
5914
|
headers: { "Content-Type": "application/json" },
|
|
@@ -5776,7 +5917,7 @@ var OrganizationCredsService = class extends BaseSDK {
|
|
|
5776
5917
|
});
|
|
5777
5918
|
}
|
|
5778
5919
|
async createFile(data, options) {
|
|
5779
|
-
|
|
5920
|
+
log32("Creating org %s file credential: %s", this.orgSegment, data.key);
|
|
5780
5921
|
return this.request(`${this.base()}/file`, {
|
|
5781
5922
|
body: JSON.stringify(data),
|
|
5782
5923
|
headers: { "Content-Type": "application/json" },
|
|
@@ -5788,7 +5929,7 @@ var OrganizationCredsService = class extends BaseSDK {
|
|
|
5788
5929
|
// Update
|
|
5789
5930
|
// ===========================================================================
|
|
5790
5931
|
async update(id, data, options) {
|
|
5791
|
-
|
|
5932
|
+
log32("Updating org %s credential %d", this.orgSegment, id);
|
|
5792
5933
|
return this.request(`${this.base()}/${id}`, {
|
|
5793
5934
|
body: JSON.stringify(data),
|
|
5794
5935
|
headers: { "Content-Type": "application/json" },
|
|
@@ -5803,7 +5944,7 @@ var OrganizationCredsService = class extends BaseSDK {
|
|
|
5803
5944
|
* the same key (`public_cred_exists` / `private_cred_exists`).
|
|
5804
5945
|
*/
|
|
5805
5946
|
async setVisibility(id, visibility, options) {
|
|
5806
|
-
|
|
5947
|
+
log32("Setting org %s credential %d visibility=%s", this.orgSegment, id, visibility);
|
|
5807
5948
|
return this.request(`${this.base()}/${id}/visibility`, {
|
|
5808
5949
|
body: JSON.stringify({ visibility }),
|
|
5809
5950
|
headers: { "Content-Type": "application/json" },
|
|
@@ -5815,14 +5956,14 @@ var OrganizationCredsService = class extends BaseSDK {
|
|
|
5815
5956
|
// Delete
|
|
5816
5957
|
// ===========================================================================
|
|
5817
5958
|
async delete(id, options) {
|
|
5818
|
-
|
|
5959
|
+
log32("Deleting org %s credential %d", this.orgSegment, id);
|
|
5819
5960
|
return this.request(`${this.base()}/${id}`, {
|
|
5820
5961
|
method: "DELETE",
|
|
5821
5962
|
...options
|
|
5822
5963
|
});
|
|
5823
5964
|
}
|
|
5824
5965
|
async deleteByKey(key, options) {
|
|
5825
|
-
|
|
5966
|
+
log32("Deleting org %s credential by key: %s", this.orgSegment, key);
|
|
5826
5967
|
return this.request(`${this.base()}/key/${encodeURIComponent(key)}`, {
|
|
5827
5968
|
method: "DELETE",
|
|
5828
5969
|
...options
|
|
@@ -5836,7 +5977,7 @@ var OrganizationCredsService = class extends BaseSDK {
|
|
|
5836
5977
|
* the org has bound vs. is missing. Reads only; any org member may call.
|
|
5837
5978
|
*/
|
|
5838
5979
|
async getSkillCredStatus(skillIdentifier, options) {
|
|
5839
|
-
|
|
5980
|
+
log32("Getting org %s skill cred status: %s", this.orgSegment, skillIdentifier);
|
|
5840
5981
|
const path = `/v1/organizations/${this.orgSegment}/skills/${encodeURIComponent(skillIdentifier)}/creds/status`;
|
|
5841
5982
|
const result = await this.request(
|
|
5842
5983
|
path,
|
|
@@ -5847,8 +5988,8 @@ var OrganizationCredsService = class extends BaseSDK {
|
|
|
5847
5988
|
};
|
|
5848
5989
|
|
|
5849
5990
|
// src/market/services/OrganizationService.ts
|
|
5850
|
-
import
|
|
5851
|
-
var
|
|
5991
|
+
import debug33 from "debug";
|
|
5992
|
+
var log33 = debug33("lobe-market-sdk:organization");
|
|
5852
5993
|
var OrganizationService2 = class extends BaseSDK {
|
|
5853
5994
|
constructor(options = {}, sharedHeaders, sharedTokenState) {
|
|
5854
5995
|
super(options, sharedHeaders, sharedTokenState);
|
|
@@ -5896,12 +6037,12 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5896
6037
|
async getOrganizationInfo(idOrNamespace, params = {}, options) {
|
|
5897
6038
|
const locale = params.locale || this.defaultLocale;
|
|
5898
6039
|
const queryString = this.buildQueryString({ locale });
|
|
5899
|
-
|
|
6040
|
+
log33("Getting organization info: %O", { idOrNamespace, ...params });
|
|
5900
6041
|
const result = await this.request(
|
|
5901
6042
|
`/v1/organizations/info/${idOrNamespace}${queryString}`,
|
|
5902
6043
|
options
|
|
5903
6044
|
);
|
|
5904
|
-
|
|
6045
|
+
log33("Organization info retrieved for: %s", idOrNamespace);
|
|
5905
6046
|
return result;
|
|
5906
6047
|
}
|
|
5907
6048
|
/**
|
|
@@ -5911,7 +6052,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5911
6052
|
* @returns Promise resolving to the user's organizations
|
|
5912
6053
|
*/
|
|
5913
6054
|
async listMyOrganizations(options) {
|
|
5914
|
-
|
|
6055
|
+
log33("Listing organizations for current user");
|
|
5915
6056
|
const result = await this.request(
|
|
5916
6057
|
"/v1/organizations/me",
|
|
5917
6058
|
options
|
|
@@ -5929,7 +6070,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5929
6070
|
* @returns The created/existing organization and whether it was newly created
|
|
5930
6071
|
*/
|
|
5931
6072
|
async createOrganization(data, options) {
|
|
5932
|
-
|
|
6073
|
+
log33("Creating organization: %s", data.clerkId);
|
|
5933
6074
|
return this.request("/v1/organizations", {
|
|
5934
6075
|
...options,
|
|
5935
6076
|
body: JSON.stringify(data),
|
|
@@ -5944,7 +6085,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5944
6085
|
* @returns The updated organization
|
|
5945
6086
|
*/
|
|
5946
6087
|
async updateOrganization(orgId, data, options) {
|
|
5947
|
-
|
|
6088
|
+
log33("Updating organization %d: %O", orgId, data);
|
|
5948
6089
|
const result = await this.request(
|
|
5949
6090
|
`/v1/organizations/${orgRefToPathSegment(orgId)}`,
|
|
5950
6091
|
{
|
|
@@ -5963,7 +6104,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5963
6104
|
* @returns The archived organization
|
|
5964
6105
|
*/
|
|
5965
6106
|
async archiveOrganization(orgId, options) {
|
|
5966
|
-
|
|
6107
|
+
log33("Archiving organization %d", orgId);
|
|
5967
6108
|
const result = await this.request(
|
|
5968
6109
|
`/v1/organizations/${orgRefToPathSegment(orgId)}/archive`,
|
|
5969
6110
|
{ ...options, method: "POST" }
|
|
@@ -5977,7 +6118,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5977
6118
|
* @returns The reactivated organization
|
|
5978
6119
|
*/
|
|
5979
6120
|
async unarchiveOrganization(orgId, options) {
|
|
5980
|
-
|
|
6121
|
+
log33("Unarchiving organization %d", orgId);
|
|
5981
6122
|
const result = await this.request(
|
|
5982
6123
|
`/v1/organizations/${orgRefToPathSegment(orgId)}/unarchive`,
|
|
5983
6124
|
{ ...options, method: "POST" }
|
|
@@ -5991,7 +6132,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5991
6132
|
* @returns Hydrated member rows
|
|
5992
6133
|
*/
|
|
5993
6134
|
async listMembers(orgId, options) {
|
|
5994
|
-
|
|
6135
|
+
log33("Listing members of organization %d", orgId);
|
|
5995
6136
|
const result = await this.request(
|
|
5996
6137
|
`/v1/organizations/${orgRefToPathSegment(orgId)}/members`,
|
|
5997
6138
|
options
|
|
@@ -6008,7 +6149,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
6008
6149
|
* @returns Whether the member was newly added and their effective role
|
|
6009
6150
|
*/
|
|
6010
6151
|
async addMember(orgId, userAccountId, role, options) {
|
|
6011
|
-
|
|
6152
|
+
log33("Adding member %d to organization %d (role=%s)", userAccountId, orgId, role);
|
|
6012
6153
|
return this.request(
|
|
6013
6154
|
`/v1/organizations/${orgRefToPathSegment(orgId)}/members`,
|
|
6014
6155
|
{
|
|
@@ -6027,7 +6168,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
6027
6168
|
* @returns Whether a membership row was removed
|
|
6028
6169
|
*/
|
|
6029
6170
|
async removeMember(orgId, userAccountId, options) {
|
|
6030
|
-
|
|
6171
|
+
log33("Removing member %d from organization %d", userAccountId, orgId);
|
|
6031
6172
|
return this.request(
|
|
6032
6173
|
`/v1/organizations/${orgRefToPathSegment(orgId)}/members/${userAccountId}`,
|
|
6033
6174
|
{ ...options, method: "DELETE" }
|
|
@@ -6043,7 +6184,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
6043
6184
|
* @returns The effective role and whether it changed
|
|
6044
6185
|
*/
|
|
6045
6186
|
async updateMemberRole(orgId, userAccountId, role, options) {
|
|
6046
|
-
|
|
6187
|
+
log33("Updating member %d role to %s in organization %d", userAccountId, role, orgId);
|
|
6047
6188
|
return this.request(
|
|
6048
6189
|
`/v1/organizations/${orgRefToPathSegment(orgId)}/members/${userAccountId}`,
|
|
6049
6190
|
{ ...options, body: JSON.stringify({ role }), method: "PATCH" }
|
|
@@ -6061,7 +6202,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
6061
6202
|
* @returns Counts of added / removed / updated members and skipped ids
|
|
6062
6203
|
*/
|
|
6063
6204
|
async reconcileMembers(orgId, members, options) {
|
|
6064
|
-
|
|
6205
|
+
log33("Reconciling %d members for organization %d", members.length, orgId);
|
|
6065
6206
|
return this.request(
|
|
6066
6207
|
`/v1/organizations/${orgRefToPathSegment(orgId)}/members`,
|
|
6067
6208
|
{
|
|
@@ -6074,8 +6215,8 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
6074
6215
|
};
|
|
6075
6216
|
|
|
6076
6217
|
// src/market/services/UserService.ts
|
|
6077
|
-
import
|
|
6078
|
-
var
|
|
6218
|
+
import debug34 from "debug";
|
|
6219
|
+
var log34 = debug34("lobe-market-sdk:user");
|
|
6079
6220
|
var UserService = class extends BaseSDK {
|
|
6080
6221
|
/**
|
|
6081
6222
|
* Retrieves user information by account ID or userName
|
|
@@ -6092,12 +6233,12 @@ var UserService = class extends BaseSDK {
|
|
|
6092
6233
|
const locale = params.locale || this.defaultLocale;
|
|
6093
6234
|
const queryParams = { locale };
|
|
6094
6235
|
const queryString = this.buildQueryString(queryParams);
|
|
6095
|
-
|
|
6236
|
+
log34("Getting user info: %O", { idOrUserName, ...params });
|
|
6096
6237
|
const result = await this.request(
|
|
6097
6238
|
`/v1/user/info/${idOrUserName}${queryString}`,
|
|
6098
6239
|
options
|
|
6099
6240
|
);
|
|
6100
|
-
|
|
6241
|
+
log34("User info successfully retrieved for: %s", idOrUserName);
|
|
6101
6242
|
return result;
|
|
6102
6243
|
}
|
|
6103
6244
|
/**
|
|
@@ -6112,7 +6253,7 @@ var UserService = class extends BaseSDK {
|
|
|
6112
6253
|
* @throws Error if userName is already taken or update fails
|
|
6113
6254
|
*/
|
|
6114
6255
|
async updateUserInfo(data, options) {
|
|
6115
|
-
|
|
6256
|
+
log34("Updating user info: %O", data);
|
|
6116
6257
|
const result = await this.request("/v1/user/update", {
|
|
6117
6258
|
body: JSON.stringify(data),
|
|
6118
6259
|
headers: {
|
|
@@ -6121,7 +6262,7 @@ var UserService = class extends BaseSDK {
|
|
|
6121
6262
|
method: "POST",
|
|
6122
6263
|
...options
|
|
6123
6264
|
});
|
|
6124
|
-
|
|
6265
|
+
log34("User info updated successfully");
|
|
6125
6266
|
return result;
|
|
6126
6267
|
}
|
|
6127
6268
|
/**
|
|
@@ -6151,7 +6292,7 @@ var UserService = class extends BaseSDK {
|
|
|
6151
6292
|
* ```
|
|
6152
6293
|
*/
|
|
6153
6294
|
async register(data, options) {
|
|
6154
|
-
|
|
6295
|
+
log34("Registering user: %O", {
|
|
6155
6296
|
followUserId: data.followUserId,
|
|
6156
6297
|
registerUserId: data.registerUserId
|
|
6157
6298
|
});
|
|
@@ -6163,14 +6304,14 @@ var UserService = class extends BaseSDK {
|
|
|
6163
6304
|
method: "POST",
|
|
6164
6305
|
...options
|
|
6165
6306
|
});
|
|
6166
|
-
|
|
6307
|
+
log34("User registered successfully: created=%s, userId=%s", result.created, result.user.clerkId);
|
|
6167
6308
|
return result;
|
|
6168
6309
|
}
|
|
6169
6310
|
};
|
|
6170
6311
|
|
|
6171
6312
|
// src/market/services/UserFollowService.ts
|
|
6172
|
-
import
|
|
6173
|
-
var
|
|
6313
|
+
import debug35 from "debug";
|
|
6314
|
+
var log35 = debug35("lobe-market-sdk:user-follow");
|
|
6174
6315
|
var UserFollowService = class extends BaseSDK {
|
|
6175
6316
|
/**
|
|
6176
6317
|
* Follow a user
|
|
@@ -6184,7 +6325,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
6184
6325
|
* @throws Error if already following or cannot follow yourself
|
|
6185
6326
|
*/
|
|
6186
6327
|
async follow(followingId, options) {
|
|
6187
|
-
|
|
6328
|
+
log35("Following user: %d", followingId);
|
|
6188
6329
|
const body = { followingId };
|
|
6189
6330
|
const result = await this.request("/v1/user/follows", {
|
|
6190
6331
|
body: JSON.stringify(body),
|
|
@@ -6194,7 +6335,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
6194
6335
|
method: "POST",
|
|
6195
6336
|
...options
|
|
6196
6337
|
});
|
|
6197
|
-
|
|
6338
|
+
log35("Successfully followed user: %d", followingId);
|
|
6198
6339
|
return result;
|
|
6199
6340
|
}
|
|
6200
6341
|
/**
|
|
@@ -6209,7 +6350,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
6209
6350
|
* @throws Error if follow relationship not found
|
|
6210
6351
|
*/
|
|
6211
6352
|
async unfollow(followingId, options) {
|
|
6212
|
-
|
|
6353
|
+
log35("Unfollowing user: %d", followingId);
|
|
6213
6354
|
const body = { followingId };
|
|
6214
6355
|
const result = await this.request("/v1/user/follows", {
|
|
6215
6356
|
body: JSON.stringify(body),
|
|
@@ -6219,7 +6360,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
6219
6360
|
method: "DELETE",
|
|
6220
6361
|
...options
|
|
6221
6362
|
});
|
|
6222
|
-
|
|
6363
|
+
log35("Successfully unfollowed user: %d", followingId);
|
|
6223
6364
|
return result;
|
|
6224
6365
|
}
|
|
6225
6366
|
/**
|
|
@@ -6233,13 +6374,13 @@ var UserFollowService = class extends BaseSDK {
|
|
|
6233
6374
|
* @returns Promise resolving to follow status (isFollowing, isMutual)
|
|
6234
6375
|
*/
|
|
6235
6376
|
async checkFollowStatus(targetUserId, options) {
|
|
6236
|
-
|
|
6377
|
+
log35("Checking follow status for user: %d", targetUserId);
|
|
6237
6378
|
const queryString = this.buildQueryString({ targetUserId: String(targetUserId) });
|
|
6238
6379
|
const result = await this.request(
|
|
6239
6380
|
`/v1/user/follows/check${queryString}`,
|
|
6240
6381
|
options
|
|
6241
6382
|
);
|
|
6242
|
-
|
|
6383
|
+
log35("Follow status retrieved: %O", result);
|
|
6243
6384
|
return result;
|
|
6244
6385
|
}
|
|
6245
6386
|
/**
|
|
@@ -6254,7 +6395,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
6254
6395
|
* @returns Promise resolving to list of following users
|
|
6255
6396
|
*/
|
|
6256
6397
|
async getFollowing(userId, params = {}, options) {
|
|
6257
|
-
|
|
6398
|
+
log35("Getting following list for user: %d", userId);
|
|
6258
6399
|
const queryParams = {};
|
|
6259
6400
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
6260
6401
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -6263,7 +6404,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
6263
6404
|
`/v1/user/follows/${userId}/following${queryString}`,
|
|
6264
6405
|
options
|
|
6265
6406
|
);
|
|
6266
|
-
|
|
6407
|
+
log35("Following list retrieved for user: %d", userId);
|
|
6267
6408
|
return result;
|
|
6268
6409
|
}
|
|
6269
6410
|
/**
|
|
@@ -6278,7 +6419,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
6278
6419
|
* @returns Promise resolving to list of followers
|
|
6279
6420
|
*/
|
|
6280
6421
|
async getFollowers(userId, params = {}, options) {
|
|
6281
|
-
|
|
6422
|
+
log35("Getting followers list for user: %d", userId);
|
|
6282
6423
|
const queryParams = {};
|
|
6283
6424
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
6284
6425
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -6287,14 +6428,14 @@ var UserFollowService = class extends BaseSDK {
|
|
|
6287
6428
|
`/v1/user/follows/${userId}/followers${queryString}`,
|
|
6288
6429
|
options
|
|
6289
6430
|
);
|
|
6290
|
-
|
|
6431
|
+
log35("Followers list retrieved for user: %d", userId);
|
|
6291
6432
|
return result;
|
|
6292
6433
|
}
|
|
6293
6434
|
};
|
|
6294
6435
|
|
|
6295
6436
|
// src/market/services/UserFavoriteService.ts
|
|
6296
|
-
import
|
|
6297
|
-
var
|
|
6437
|
+
import debug36 from "debug";
|
|
6438
|
+
var log36 = debug36("lobe-market-sdk:user-favorite");
|
|
6298
6439
|
var UserFavoriteService = class extends BaseSDK {
|
|
6299
6440
|
/**
|
|
6300
6441
|
* Add to favorites
|
|
@@ -6309,7 +6450,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
6309
6450
|
* @throws Error if already in favorites
|
|
6310
6451
|
*/
|
|
6311
6452
|
async addFavorite(targetType, targetId, options) {
|
|
6312
|
-
|
|
6453
|
+
log36("Adding favorite: %s %d", targetType, targetId);
|
|
6313
6454
|
const body = { targetId, targetType };
|
|
6314
6455
|
const result = await this.request("/v1/user/favorites", {
|
|
6315
6456
|
body: JSON.stringify(body),
|
|
@@ -6319,7 +6460,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
6319
6460
|
method: "POST",
|
|
6320
6461
|
...options
|
|
6321
6462
|
});
|
|
6322
|
-
|
|
6463
|
+
log36("Successfully added favorite: %s %d", targetType, targetId);
|
|
6323
6464
|
return result;
|
|
6324
6465
|
}
|
|
6325
6466
|
/**
|
|
@@ -6335,7 +6476,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
6335
6476
|
* @throws Error if favorite not found
|
|
6336
6477
|
*/
|
|
6337
6478
|
async removeFavorite(targetType, targetId, options) {
|
|
6338
|
-
|
|
6479
|
+
log36("Removing favorite: %s %d", targetType, targetId);
|
|
6339
6480
|
const body = { targetId, targetType };
|
|
6340
6481
|
const result = await this.request("/v1/user/favorites", {
|
|
6341
6482
|
body: JSON.stringify(body),
|
|
@@ -6345,7 +6486,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
6345
6486
|
method: "DELETE",
|
|
6346
6487
|
...options
|
|
6347
6488
|
});
|
|
6348
|
-
|
|
6489
|
+
log36("Successfully removed favorite: %s %d", targetType, targetId);
|
|
6349
6490
|
return result;
|
|
6350
6491
|
}
|
|
6351
6492
|
/**
|
|
@@ -6360,7 +6501,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
6360
6501
|
* @returns Promise resolving to favorite status
|
|
6361
6502
|
*/
|
|
6362
6503
|
async checkFavorite(targetType, targetId, options) {
|
|
6363
|
-
|
|
6504
|
+
log36("Checking favorite status: %s %d", targetType, targetId);
|
|
6364
6505
|
const queryString = this.buildQueryString({
|
|
6365
6506
|
targetId: String(targetId),
|
|
6366
6507
|
targetType
|
|
@@ -6369,7 +6510,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
6369
6510
|
`/v1/user/favorites/check${queryString}`,
|
|
6370
6511
|
options
|
|
6371
6512
|
);
|
|
6372
|
-
|
|
6513
|
+
log36("Favorite status retrieved: %O", result);
|
|
6373
6514
|
return result;
|
|
6374
6515
|
}
|
|
6375
6516
|
/**
|
|
@@ -6383,7 +6524,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
6383
6524
|
* @returns Promise resolving to list of favorites
|
|
6384
6525
|
*/
|
|
6385
6526
|
async getMyFavorites(params = {}, options) {
|
|
6386
|
-
|
|
6527
|
+
log36("Getting my favorites: %O", params);
|
|
6387
6528
|
const queryParams = {};
|
|
6388
6529
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
6389
6530
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -6393,7 +6534,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
6393
6534
|
`/v1/user/favorites/me${queryString}`,
|
|
6394
6535
|
options
|
|
6395
6536
|
);
|
|
6396
|
-
|
|
6537
|
+
log36("My favorites retrieved");
|
|
6397
6538
|
return result;
|
|
6398
6539
|
}
|
|
6399
6540
|
/**
|
|
@@ -6408,7 +6549,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
6408
6549
|
* @returns Promise resolving to list of favorites
|
|
6409
6550
|
*/
|
|
6410
6551
|
async getUserFavorites(userId, params = {}, options) {
|
|
6411
|
-
|
|
6552
|
+
log36("Getting favorites for user: %d", userId);
|
|
6412
6553
|
const queryParams = {};
|
|
6413
6554
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
6414
6555
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -6418,7 +6559,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
6418
6559
|
`/v1/user/favorites/${userId}${queryString}`,
|
|
6419
6560
|
options
|
|
6420
6561
|
);
|
|
6421
|
-
|
|
6562
|
+
log36("Favorites retrieved for user: %d", userId);
|
|
6422
6563
|
return result;
|
|
6423
6564
|
}
|
|
6424
6565
|
/**
|
|
@@ -6433,7 +6574,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
6433
6574
|
* @returns Promise resolving to list of favorite agents
|
|
6434
6575
|
*/
|
|
6435
6576
|
async getUserFavoriteAgents(userId, params = {}, options) {
|
|
6436
|
-
|
|
6577
|
+
log36("Getting favorite agents for user: %d", userId);
|
|
6437
6578
|
const queryParams = {};
|
|
6438
6579
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
6439
6580
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -6442,7 +6583,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
6442
6583
|
`/v1/user/favorites/${userId}/agents${queryString}`,
|
|
6443
6584
|
options
|
|
6444
6585
|
);
|
|
6445
|
-
|
|
6586
|
+
log36("Favorite agents retrieved for user: %d", userId);
|
|
6446
6587
|
return result;
|
|
6447
6588
|
}
|
|
6448
6589
|
/**
|
|
@@ -6457,7 +6598,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
6457
6598
|
* @returns Promise resolving to list of favorite plugins
|
|
6458
6599
|
*/
|
|
6459
6600
|
async getUserFavoritePlugins(userId, params = {}, options) {
|
|
6460
|
-
|
|
6601
|
+
log36("Getting favorite plugins for user: %d", userId);
|
|
6461
6602
|
const queryParams = {};
|
|
6462
6603
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
6463
6604
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -6466,14 +6607,14 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
6466
6607
|
`/v1/user/favorites/${userId}/plugins${queryString}`,
|
|
6467
6608
|
options
|
|
6468
6609
|
);
|
|
6469
|
-
|
|
6610
|
+
log36("Favorite plugins retrieved for user: %d", userId);
|
|
6470
6611
|
return result;
|
|
6471
6612
|
}
|
|
6472
6613
|
};
|
|
6473
6614
|
|
|
6474
6615
|
// src/market/services/UserLikeService.ts
|
|
6475
|
-
import
|
|
6476
|
-
var
|
|
6616
|
+
import debug37 from "debug";
|
|
6617
|
+
var log37 = debug37("lobe-market-sdk:user-like");
|
|
6477
6618
|
var UserLikeService = class extends BaseSDK {
|
|
6478
6619
|
/**
|
|
6479
6620
|
* Like content
|
|
@@ -6488,7 +6629,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6488
6629
|
* @throws Error if already liked
|
|
6489
6630
|
*/
|
|
6490
6631
|
async like(targetType, targetId, options) {
|
|
6491
|
-
|
|
6632
|
+
log37("Liking: %s %d", targetType, targetId);
|
|
6492
6633
|
const body = { targetId, targetType };
|
|
6493
6634
|
const result = await this.request("/v1/user/likes", {
|
|
6494
6635
|
body: JSON.stringify(body),
|
|
@@ -6498,7 +6639,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6498
6639
|
method: "POST",
|
|
6499
6640
|
...options
|
|
6500
6641
|
});
|
|
6501
|
-
|
|
6642
|
+
log37("Successfully liked: %s %d", targetType, targetId);
|
|
6502
6643
|
return result;
|
|
6503
6644
|
}
|
|
6504
6645
|
/**
|
|
@@ -6514,7 +6655,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6514
6655
|
* @throws Error if like not found
|
|
6515
6656
|
*/
|
|
6516
6657
|
async unlike(targetType, targetId, options) {
|
|
6517
|
-
|
|
6658
|
+
log37("Unliking: %s %d", targetType, targetId);
|
|
6518
6659
|
const body = { targetId, targetType };
|
|
6519
6660
|
const result = await this.request("/v1/user/likes", {
|
|
6520
6661
|
body: JSON.stringify(body),
|
|
@@ -6524,7 +6665,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6524
6665
|
method: "DELETE",
|
|
6525
6666
|
...options
|
|
6526
6667
|
});
|
|
6527
|
-
|
|
6668
|
+
log37("Successfully unliked: %s %d", targetType, targetId);
|
|
6528
6669
|
return result;
|
|
6529
6670
|
}
|
|
6530
6671
|
/**
|
|
@@ -6539,7 +6680,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6539
6680
|
* @returns Promise resolving to toggle response with new like status
|
|
6540
6681
|
*/
|
|
6541
6682
|
async toggleLike(targetType, targetId, options) {
|
|
6542
|
-
|
|
6683
|
+
log37("Toggling like: %s %d", targetType, targetId);
|
|
6543
6684
|
const body = { targetId, targetType };
|
|
6544
6685
|
const result = await this.request("/v1/user/likes/toggle", {
|
|
6545
6686
|
body: JSON.stringify(body),
|
|
@@ -6549,7 +6690,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6549
6690
|
method: "POST",
|
|
6550
6691
|
...options
|
|
6551
6692
|
});
|
|
6552
|
-
|
|
6693
|
+
log37("Like toggled, new status: %O", result);
|
|
6553
6694
|
return result;
|
|
6554
6695
|
}
|
|
6555
6696
|
/**
|
|
@@ -6564,7 +6705,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6564
6705
|
* @returns Promise resolving to like status
|
|
6565
6706
|
*/
|
|
6566
6707
|
async checkLike(targetType, targetId, options) {
|
|
6567
|
-
|
|
6708
|
+
log37("Checking like status: %s %d", targetType, targetId);
|
|
6568
6709
|
const queryString = this.buildQueryString({
|
|
6569
6710
|
targetId: String(targetId),
|
|
6570
6711
|
targetType
|
|
@@ -6573,7 +6714,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6573
6714
|
`/v1/user/likes/check${queryString}`,
|
|
6574
6715
|
options
|
|
6575
6716
|
);
|
|
6576
|
-
|
|
6717
|
+
log37("Like status retrieved: %O", result);
|
|
6577
6718
|
return result;
|
|
6578
6719
|
}
|
|
6579
6720
|
/**
|
|
@@ -6587,7 +6728,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6587
6728
|
* @returns Promise resolving to list of likes
|
|
6588
6729
|
*/
|
|
6589
6730
|
async getMyLikes(params = {}, options) {
|
|
6590
|
-
|
|
6731
|
+
log37("Getting my likes: %O", params);
|
|
6591
6732
|
const queryParams = {};
|
|
6592
6733
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
6593
6734
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -6597,7 +6738,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6597
6738
|
`/v1/user/likes/me${queryString}`,
|
|
6598
6739
|
options
|
|
6599
6740
|
);
|
|
6600
|
-
|
|
6741
|
+
log37("My likes retrieved");
|
|
6601
6742
|
return result;
|
|
6602
6743
|
}
|
|
6603
6744
|
/**
|
|
@@ -6612,7 +6753,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6612
6753
|
* @returns Promise resolving to list of likes
|
|
6613
6754
|
*/
|
|
6614
6755
|
async getUserLikes(userId, params = {}, options) {
|
|
6615
|
-
|
|
6756
|
+
log37("Getting likes for user: %d", userId);
|
|
6616
6757
|
const queryParams = {};
|
|
6617
6758
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
6618
6759
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -6622,7 +6763,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6622
6763
|
`/v1/user/likes/${userId}${queryString}`,
|
|
6623
6764
|
options
|
|
6624
6765
|
);
|
|
6625
|
-
|
|
6766
|
+
log37("Likes retrieved for user: %d", userId);
|
|
6626
6767
|
return result;
|
|
6627
6768
|
}
|
|
6628
6769
|
/**
|
|
@@ -6637,7 +6778,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6637
6778
|
* @returns Promise resolving to list of liked agents
|
|
6638
6779
|
*/
|
|
6639
6780
|
async getUserLikedAgents(userId, params = {}, options) {
|
|
6640
|
-
|
|
6781
|
+
log37("Getting liked agents for user: %d", userId);
|
|
6641
6782
|
const queryParams = {};
|
|
6642
6783
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
6643
6784
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -6646,7 +6787,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6646
6787
|
`/v1/user/likes/${userId}/agents${queryString}`,
|
|
6647
6788
|
options
|
|
6648
6789
|
);
|
|
6649
|
-
|
|
6790
|
+
log37("Liked agents retrieved for user: %d", userId);
|
|
6650
6791
|
return result;
|
|
6651
6792
|
}
|
|
6652
6793
|
/**
|
|
@@ -6661,7 +6802,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6661
6802
|
* @returns Promise resolving to list of liked plugins
|
|
6662
6803
|
*/
|
|
6663
6804
|
async getUserLikedPlugins(userId, params = {}, options) {
|
|
6664
|
-
|
|
6805
|
+
log37("Getting liked plugins for user: %d", userId);
|
|
6665
6806
|
const queryParams = {};
|
|
6666
6807
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
6667
6808
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -6670,14 +6811,14 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6670
6811
|
`/v1/user/likes/${userId}/plugins${queryString}`,
|
|
6671
6812
|
options
|
|
6672
6813
|
);
|
|
6673
|
-
|
|
6814
|
+
log37("Liked plugins retrieved for user: %d", userId);
|
|
6674
6815
|
return result;
|
|
6675
6816
|
}
|
|
6676
6817
|
};
|
|
6677
6818
|
|
|
6678
6819
|
// src/market/services/UserPublishService.ts
|
|
6679
|
-
import
|
|
6680
|
-
var
|
|
6820
|
+
import debug38 from "debug";
|
|
6821
|
+
var log38 = debug38("lobe-market-sdk:user-publish");
|
|
6681
6822
|
var UserPublishService = class extends BaseSDK {
|
|
6682
6823
|
/**
|
|
6683
6824
|
* Lists all plugins owned by the authenticated user
|
|
@@ -6687,9 +6828,9 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6687
6828
|
*/
|
|
6688
6829
|
async listPlugins(options) {
|
|
6689
6830
|
var _a;
|
|
6690
|
-
|
|
6831
|
+
log38("Listing user plugins");
|
|
6691
6832
|
const result = await this.request("/v1/user/plugins", options);
|
|
6692
|
-
|
|
6833
|
+
log38("Found %d user plugins", ((_a = result.data) == null ? void 0 : _a.length) || 0);
|
|
6693
6834
|
return result;
|
|
6694
6835
|
}
|
|
6695
6836
|
/**
|
|
@@ -6700,9 +6841,9 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6700
6841
|
*/
|
|
6701
6842
|
async listSkills(options) {
|
|
6702
6843
|
var _a;
|
|
6703
|
-
|
|
6844
|
+
log38("Listing user skills");
|
|
6704
6845
|
const result = await this.request("/v1/user/skills", options);
|
|
6705
|
-
|
|
6846
|
+
log38("Found %d user skills", ((_a = result.data) == null ? void 0 : _a.length) || 0);
|
|
6706
6847
|
return result;
|
|
6707
6848
|
}
|
|
6708
6849
|
/**
|
|
@@ -6714,7 +6855,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6714
6855
|
* @returns Promise resolving to the publish result
|
|
6715
6856
|
*/
|
|
6716
6857
|
async publishSkillVersion(identifier, zipBuffer, options) {
|
|
6717
|
-
|
|
6858
|
+
log38("Publishing skill version for: %s", identifier);
|
|
6718
6859
|
const formData = new FormData();
|
|
6719
6860
|
const arrayBuffer = zipBuffer instanceof ArrayBuffer ? zipBuffer : zipBuffer.buffer.slice(
|
|
6720
6861
|
zipBuffer.byteOffset,
|
|
@@ -6730,7 +6871,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6730
6871
|
...options
|
|
6731
6872
|
}
|
|
6732
6873
|
);
|
|
6733
|
-
|
|
6874
|
+
log38("Published skill version: %s@%s", identifier, result.version);
|
|
6734
6875
|
return result;
|
|
6735
6876
|
}
|
|
6736
6877
|
/**
|
|
@@ -6741,11 +6882,11 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6741
6882
|
*/
|
|
6742
6883
|
async scanClaimableAssets(assetType) {
|
|
6743
6884
|
var _a;
|
|
6744
|
-
|
|
6885
|
+
log38("Scanning claimable %s", assetType);
|
|
6745
6886
|
const result = await this.request(
|
|
6746
6887
|
`/v1/user/claims/scan/${assetType}`
|
|
6747
6888
|
);
|
|
6748
|
-
|
|
6889
|
+
log38("Found %d claimable %s", ((_a = result.data) == null ? void 0 : _a.length) || 0, assetType);
|
|
6749
6890
|
return result;
|
|
6750
6891
|
}
|
|
6751
6892
|
/**
|
|
@@ -6756,13 +6897,13 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6756
6897
|
* @returns Promise resolving to the claim result
|
|
6757
6898
|
*/
|
|
6758
6899
|
async claimAsset(assetId, assetType) {
|
|
6759
|
-
|
|
6900
|
+
log38("Claiming %s with id: %d", assetType, assetId);
|
|
6760
6901
|
const result = await this.request("/v1/user/claims", {
|
|
6761
6902
|
body: JSON.stringify({ assetId, assetType }),
|
|
6762
6903
|
headers: { "Content-Type": "application/json" },
|
|
6763
6904
|
method: "POST"
|
|
6764
6905
|
});
|
|
6765
|
-
|
|
6906
|
+
log38("Claim result for %s %d: %s", assetType, assetId, result.success);
|
|
6766
6907
|
return result;
|
|
6767
6908
|
}
|
|
6768
6909
|
/**
|
|
@@ -6773,16 +6914,18 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6773
6914
|
*
|
|
6774
6915
|
* @param identifier - The public asset identifier
|
|
6775
6916
|
* @param assetType - 'plugin' or 'skill'
|
|
6917
|
+
* @param options - `repositoryUrl`: new repository of a plugin whose listed
|
|
6918
|
+
* repository was deleted; the claim repoints the listing to it
|
|
6776
6919
|
* @returns Promise resolving to the claim result
|
|
6777
6920
|
*/
|
|
6778
|
-
async claimAssetByIdentifier(identifier, assetType) {
|
|
6779
|
-
|
|
6921
|
+
async claimAssetByIdentifier(identifier, assetType, options) {
|
|
6922
|
+
log38("Claiming %s with identifier: %s", assetType, identifier);
|
|
6780
6923
|
const result = await this.request("/v1/user/claims", {
|
|
6781
|
-
body: JSON.stringify({ assetType, identifier }),
|
|
6924
|
+
body: JSON.stringify({ assetType, identifier, repositoryUrl: options == null ? void 0 : options.repositoryUrl }),
|
|
6782
6925
|
headers: { "Content-Type": "application/json" },
|
|
6783
6926
|
method: "POST"
|
|
6784
6927
|
});
|
|
6785
|
-
|
|
6928
|
+
log38("Claim result for %s %s: %s", assetType, identifier, result.success);
|
|
6786
6929
|
return result;
|
|
6787
6930
|
}
|
|
6788
6931
|
/**
|
|
@@ -6797,14 +6940,14 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6797
6940
|
* @returns Promise resolving to the submission result
|
|
6798
6941
|
*/
|
|
6799
6942
|
async submitRepo(params, options) {
|
|
6800
|
-
|
|
6943
|
+
log38("Submitting repository for import: %s (%s)", params.gitUrl, params.type);
|
|
6801
6944
|
const result = await this.request("/v1/user/claims/submit-repo", {
|
|
6802
6945
|
body: JSON.stringify(params),
|
|
6803
6946
|
headers: { "Content-Type": "application/json" },
|
|
6804
6947
|
method: "POST",
|
|
6805
6948
|
...options
|
|
6806
6949
|
});
|
|
6807
|
-
|
|
6950
|
+
log38("Submit result for %s: %s", params.gitUrl, result.success);
|
|
6808
6951
|
return result;
|
|
6809
6952
|
}
|
|
6810
6953
|
/**
|
|
@@ -6815,14 +6958,14 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6815
6958
|
* @returns Promise resolving immediately with the plugin identifier and version
|
|
6816
6959
|
*/
|
|
6817
6960
|
async publishPlugin(params, options) {
|
|
6818
|
-
|
|
6961
|
+
log38("Publishing plugin: %s@%s", params.identifier, params.version);
|
|
6819
6962
|
const result = await this.request("/v1/user/plugins", {
|
|
6820
6963
|
body: JSON.stringify(params),
|
|
6821
6964
|
headers: { "Content-Type": "application/json" },
|
|
6822
6965
|
method: "POST",
|
|
6823
6966
|
...options
|
|
6824
6967
|
});
|
|
6825
|
-
|
|
6968
|
+
log38("Published plugin: %s@%s (%s)", result.identifier, result.version, result.status);
|
|
6826
6969
|
return result;
|
|
6827
6970
|
}
|
|
6828
6971
|
/**
|
|
@@ -6833,12 +6976,12 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6833
6976
|
* @returns Promise resolving to the delete result
|
|
6834
6977
|
*/
|
|
6835
6978
|
async deleteSkill(identifier, options) {
|
|
6836
|
-
|
|
6979
|
+
log38("Deleting skill: %s", identifier);
|
|
6837
6980
|
const result = await this.request(
|
|
6838
6981
|
`/v1/user/skills/${encodeURIComponent(identifier)}`,
|
|
6839
6982
|
{ method: "DELETE", ...options }
|
|
6840
6983
|
);
|
|
6841
|
-
|
|
6984
|
+
log38("Deleted skill: %s", identifier);
|
|
6842
6985
|
return result;
|
|
6843
6986
|
}
|
|
6844
6987
|
/**
|
|
@@ -6850,7 +6993,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6850
6993
|
* @returns Promise resolving to the updated status
|
|
6851
6994
|
*/
|
|
6852
6995
|
async updateSkillStatus(identifier, status, options) {
|
|
6853
|
-
|
|
6996
|
+
log38("Updating skill status: %s \u2192 %s", identifier, status);
|
|
6854
6997
|
const result = await this.request(
|
|
6855
6998
|
`/v1/user/skills/${encodeURIComponent(identifier)}/status`,
|
|
6856
6999
|
{
|
|
@@ -6860,7 +7003,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6860
7003
|
...options
|
|
6861
7004
|
}
|
|
6862
7005
|
);
|
|
6863
|
-
|
|
7006
|
+
log38("Updated skill status: %s \u2192 %s", identifier, result.status);
|
|
6864
7007
|
return result;
|
|
6865
7008
|
}
|
|
6866
7009
|
/**
|
|
@@ -6871,12 +7014,12 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6871
7014
|
* @returns Promise resolving to the delete result
|
|
6872
7015
|
*/
|
|
6873
7016
|
async deletePlugin(identifier, options) {
|
|
6874
|
-
|
|
7017
|
+
log38("Deleting plugin: %s", identifier);
|
|
6875
7018
|
const result = await this.request(
|
|
6876
7019
|
`/v1/user/plugins/${encodeURIComponent(identifier)}`,
|
|
6877
7020
|
{ method: "DELETE", ...options }
|
|
6878
7021
|
);
|
|
6879
|
-
|
|
7022
|
+
log38("Deleted plugin: %s", identifier);
|
|
6880
7023
|
return result;
|
|
6881
7024
|
}
|
|
6882
7025
|
/**
|
|
@@ -6888,7 +7031,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6888
7031
|
* @returns Promise resolving to the updated status
|
|
6889
7032
|
*/
|
|
6890
7033
|
async updatePluginStatus(identifier, status, options) {
|
|
6891
|
-
|
|
7034
|
+
log38("Updating plugin status: %s \u2192 %s", identifier, status);
|
|
6892
7035
|
const result = await this.request(
|
|
6893
7036
|
`/v1/user/plugins/${encodeURIComponent(identifier)}/status`,
|
|
6894
7037
|
{
|
|
@@ -6898,7 +7041,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6898
7041
|
...options
|
|
6899
7042
|
}
|
|
6900
7043
|
);
|
|
6901
|
-
|
|
7044
|
+
log38("Updated plugin status: %s \u2192 %s", identifier, result.status);
|
|
6902
7045
|
return result;
|
|
6903
7046
|
}
|
|
6904
7047
|
/**
|
|
@@ -6910,7 +7053,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6910
7053
|
* @returns Promise resolving to the publish result
|
|
6911
7054
|
*/
|
|
6912
7055
|
async publishPluginVersion(identifier, data, options) {
|
|
6913
|
-
|
|
7056
|
+
log38("Publishing plugin version for: %s", identifier);
|
|
6914
7057
|
const result = await this.request(
|
|
6915
7058
|
`/v1/user/plugins/${encodeURIComponent(identifier)}/versions`,
|
|
6916
7059
|
{
|
|
@@ -6920,7 +7063,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6920
7063
|
...options
|
|
6921
7064
|
}
|
|
6922
7065
|
);
|
|
6923
|
-
|
|
7066
|
+
log38("Published plugin version: %s@%s", identifier, result.version);
|
|
6924
7067
|
return result;
|
|
6925
7068
|
}
|
|
6926
7069
|
/**
|
|
@@ -6933,13 +7076,13 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6933
7076
|
*/
|
|
6934
7077
|
async getPluginLocalizations(identifier, version, options) {
|
|
6935
7078
|
var _a;
|
|
6936
|
-
|
|
7079
|
+
log38("Listing localizations for plugin: %s", identifier);
|
|
6937
7080
|
const query = version ? `?version=${encodeURIComponent(version)}` : "";
|
|
6938
7081
|
const result = await this.request(
|
|
6939
7082
|
`/v1/user/plugins/${encodeURIComponent(identifier)}/localizations${query}`,
|
|
6940
7083
|
options
|
|
6941
7084
|
);
|
|
6942
|
-
|
|
7085
|
+
log38("Found %d localizations for %s", ((_a = result.localizations) == null ? void 0 : _a.length) || 0, identifier);
|
|
6943
7086
|
return result;
|
|
6944
7087
|
}
|
|
6945
7088
|
/**
|
|
@@ -6956,7 +7099,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6956
7099
|
* @returns Promise resolving to the upsert result
|
|
6957
7100
|
*/
|
|
6958
7101
|
async updatePluginLocalizations(identifier, localizations, version, options) {
|
|
6959
|
-
|
|
7102
|
+
log38("Upserting %d localization(s) for plugin: %s", localizations.length, identifier);
|
|
6960
7103
|
const result = await this.request(
|
|
6961
7104
|
`/v1/user/plugins/${encodeURIComponent(identifier)}/localizations`,
|
|
6962
7105
|
{
|
|
@@ -6966,7 +7109,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6966
7109
|
...options
|
|
6967
7110
|
}
|
|
6968
7111
|
);
|
|
6969
|
-
|
|
7112
|
+
log38("Upserted localizations for %s@%s", identifier, result.version);
|
|
6970
7113
|
return result;
|
|
6971
7114
|
}
|
|
6972
7115
|
/**
|
|
@@ -6980,31 +7123,31 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6980
7123
|
* @returns Promise resolving to the delete result
|
|
6981
7124
|
*/
|
|
6982
7125
|
async deletePluginLocalization(identifier, locale, version, options) {
|
|
6983
|
-
|
|
7126
|
+
log38("Deleting localization %s for plugin: %s", locale, identifier);
|
|
6984
7127
|
const query = version ? `?version=${encodeURIComponent(version)}` : "";
|
|
6985
7128
|
const result = await this.request(
|
|
6986
7129
|
`/v1/user/plugins/${encodeURIComponent(identifier)}/localizations/${encodeURIComponent(locale)}${query}`,
|
|
6987
7130
|
{ method: "DELETE", ...options }
|
|
6988
7131
|
);
|
|
6989
|
-
|
|
7132
|
+
log38("Deleted localization %s for %s", locale, identifier);
|
|
6990
7133
|
return result;
|
|
6991
7134
|
}
|
|
6992
7135
|
};
|
|
6993
7136
|
|
|
6994
7137
|
// src/market/services/CategoryService.ts
|
|
6995
|
-
import
|
|
6996
|
-
var
|
|
7138
|
+
import debug39 from "debug";
|
|
7139
|
+
var log39 = debug39("lobe-market-sdk:market:categories");
|
|
6997
7140
|
var CategoryService2 = class extends BaseSDK {
|
|
6998
7141
|
/** Lists configured categories with nullable HTTP(S) image URLs or lucide:<name> icons and public asset counts, including empty categories. */
|
|
6999
7142
|
async list(assetType, locale) {
|
|
7000
|
-
|
|
7143
|
+
log39("Listing categories for %s", assetType);
|
|
7001
7144
|
const query = this.buildQueryString({ assetType, locale });
|
|
7002
7145
|
return this.request(`/v1/categories${query}`);
|
|
7003
7146
|
}
|
|
7004
7147
|
};
|
|
7005
7148
|
|
|
7006
7149
|
// src/market/market-sdk.ts
|
|
7007
|
-
var
|
|
7150
|
+
var log40 = debug40("lobe-market-sdk");
|
|
7008
7151
|
var MarketSDK = class extends BaseSDK {
|
|
7009
7152
|
/** Anonymous WebP byte URL. No signed token or public bucket is required. */
|
|
7010
7153
|
getAssetImageUrl(id) {
|
|
@@ -7025,8 +7168,9 @@ var MarketSDK = class extends BaseSDK {
|
|
|
7025
7168
|
tokenExpiry: void 0
|
|
7026
7169
|
};
|
|
7027
7170
|
super(options, void 0, sharedTokenState);
|
|
7028
|
-
|
|
7171
|
+
log40("MarketSDK instance created");
|
|
7029
7172
|
this.agentProfile = new AgentProfileService(options, this.headers, sharedTokenState);
|
|
7173
|
+
this.access = new AccessService(options, this.headers, sharedTokenState);
|
|
7030
7174
|
this.categories = new CategoryService2(options, this.headers, sharedTokenState);
|
|
7031
7175
|
this.agents = new AgentService2(options, this.headers, sharedTokenState);
|
|
7032
7176
|
this.agentGroups = new AgentGroupService(options, this.headers, sharedTokenState);
|
|
@@ -7078,11 +7222,51 @@ var MarketSDK = class extends BaseSDK {
|
|
|
7078
7222
|
* @deprecated Use auth.registerClient() instead
|
|
7079
7223
|
*/
|
|
7080
7224
|
async registerClient(request) {
|
|
7081
|
-
|
|
7225
|
+
log40("Registering client (deprecated method, use auth.registerClient): %s", request.clientName);
|
|
7082
7226
|
return this.auth.registerClient(request);
|
|
7083
7227
|
}
|
|
7084
7228
|
};
|
|
7085
7229
|
|
|
7230
|
+
// src/core/errorKind.ts
|
|
7231
|
+
var STATUS_KINDS = {
|
|
7232
|
+
400: "invalid_input",
|
|
7233
|
+
401: "unauthenticated",
|
|
7234
|
+
403: "forbidden",
|
|
7235
|
+
404: "not_found",
|
|
7236
|
+
409: "conflict",
|
|
7237
|
+
422: "invalid_input",
|
|
7238
|
+
429: "rate_limited"
|
|
7239
|
+
};
|
|
7240
|
+
var NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
7241
|
+
"EAI_AGAIN",
|
|
7242
|
+
"ECONNABORTED",
|
|
7243
|
+
"ECONNREFUSED",
|
|
7244
|
+
"ECONNRESET",
|
|
7245
|
+
"EHOSTUNREACH",
|
|
7246
|
+
"ENETUNREACH",
|
|
7247
|
+
"ENOTFOUND",
|
|
7248
|
+
"EPIPE",
|
|
7249
|
+
"ETIMEDOUT"
|
|
7250
|
+
]);
|
|
7251
|
+
var FETCH_FAILURE_MESSAGE = /^(fetch failed|failed to fetch|load failed|networkerror\b)/i;
|
|
7252
|
+
var isNetworkError = (error) => {
|
|
7253
|
+
var _a;
|
|
7254
|
+
const code = (_a = error.cause) == null ? void 0 : _a.code;
|
|
7255
|
+
if (typeof code === "string" && (NETWORK_ERROR_CODES.has(code) || code.startsWith("UND_ERR_")))
|
|
7256
|
+
return true;
|
|
7257
|
+
return error instanceof TypeError && FETCH_FAILURE_MESSAGE.test(error.message);
|
|
7258
|
+
};
|
|
7259
|
+
var getMarketErrorKind = (error) => {
|
|
7260
|
+
var _a;
|
|
7261
|
+
if (error instanceof MarketAPIError) {
|
|
7262
|
+
if (error.status >= 500) return "unavailable";
|
|
7263
|
+
return (_a = STATUS_KINDS[error.status]) != null ? _a : "unknown";
|
|
7264
|
+
}
|
|
7265
|
+
if (!(error instanceof Error)) return "unknown";
|
|
7266
|
+
if (error.name === "AbortError" || error.name === "TimeoutError") return "unavailable";
|
|
7267
|
+
return isNetworkError(error) ? "unavailable" : "unknown";
|
|
7268
|
+
};
|
|
7269
|
+
|
|
7086
7270
|
// src/types/admin.ts
|
|
7087
7271
|
import { z } from "zod";
|
|
7088
7272
|
var VisibilityEnumSchema = z.enum(["public", "private", "internal"]);
|
|
@@ -7145,6 +7329,7 @@ export {
|
|
|
7145
7329
|
buildTrustedClientPayload,
|
|
7146
7330
|
createTrustedClientToken,
|
|
7147
7331
|
generateNonce,
|
|
7332
|
+
getMarketErrorKind,
|
|
7148
7333
|
orgRefToPathSegment
|
|
7149
7334
|
};
|
|
7150
7335
|
//# sourceMappingURL=index.mjs.map
|