@lobehub/market-sdk 0.0.28 → 0.0.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,14 +1,15 @@
1
- // src/market/market-sdk.ts
2
- import debug4 from "debug";
1
+ // src/admin/MarketAdmin.ts
2
+ import debug6 from "debug";
3
3
 
4
4
  // src/core/BaseSDK.ts
5
5
  import debug from "debug";
6
6
  var log = debug("lobe-market-sdk:core");
7
7
  var BaseSDK = class {
8
8
  /**
9
- * 创建基础 SDK 实例
10
- * @param options SDK 配置选项
11
- * @param sharedHeaders 共享的 headers 对象(可选)
9
+ * Creates a new BaseSDK instance
10
+ *
11
+ * @param options - Configuration options for the SDK
12
+ * @param sharedHeaders - Optional shared headers object for reuse across services
12
13
  */
13
14
  constructor(options = {}, sharedHeaders) {
14
15
  this.baseUrl = options.baseURL || process.env.MARKET_BASE_URL || "https://market.lobehub.com/api";
@@ -30,11 +31,14 @@ var BaseSDK = class {
30
31
  });
31
32
  }
32
33
  /**
33
- * 发送请求并处理响应
34
- * @param url 请求 URL
35
- * @param options fetch 选项
36
- * @returns 响应数据
34
+ * Sends an HTTP request to the API and handles the response
35
+ *
36
+ * @param url - Request URL path (will be appended to baseUrl)
37
+ * @param options - Fetch API request options
38
+ * @returns Promise resolving to the parsed JSON response
39
+ * @throws Error if the request fails
37
40
  */
41
+ // eslint-disable-next-line no-undef
38
42
  async request(url, options = {}) {
39
43
  log("Sending request: %s", `${this.baseUrl}${url}`);
40
44
  const response = await fetch(`${this.baseUrl}${url}`, {
@@ -53,24 +57,26 @@ var BaseSDK = class {
53
57
  return response.json();
54
58
  }
55
59
  /**
56
- * 构建查询字符串
57
- * @param params 查询参数
58
- * @returns 查询字符串
60
+ * Builds a URL query string from a parameters object
61
+ *
62
+ * @param params - Object containing query parameters
63
+ * @returns Formatted query string (including leading ? if params exist)
59
64
  */
60
65
  buildQueryString(params) {
61
66
  const query = Object.entries(params).filter(([_, value]) => value !== void 0 && value !== null).map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`).join("&");
62
67
  return query ? `?${query}` : "";
63
68
  }
64
69
  /**
65
- * 设置认证令牌
66
- * @param token 认证令牌
70
+ * Sets an authentication token for API requests
71
+ *
72
+ * @param token - API authentication token
67
73
  */
68
74
  setAuthToken(token) {
69
75
  log("Setting authentication token");
70
76
  this.headers.Authorization = `Bearer ${token}`;
71
77
  }
72
78
  /**
73
- * 清除认证令牌
79
+ * Clears the authentication token
74
80
  */
75
81
  clearAuthToken() {
76
82
  log("Clearing authentication token");
@@ -78,368 +84,285 @@ var BaseSDK = class {
78
84
  }
79
85
  };
80
86
 
81
- // src/market/services/PluginsService.ts
82
- import debug2 from "debug";
83
- var log2 = debug2("lobe-market-sdk:plugins");
84
- var PluginsService = class extends BaseSDK {
85
- /**
86
- * 创建插件服务实例
87
- * @param options SDK 配置选项
88
- * @param sharedHeaders 共享的 headers 对象(可选)
89
- */
90
- constructor(options = {}, sharedHeaders) {
91
- super(options, sharedHeaders);
92
- log2("PluginsService instance created");
93
- }
94
- /**
95
- * 获取插件列表
96
- * @param params 查询参数
97
- * @returns 插件列表响应
98
- */
99
- async getPluginList(params = {}) {
100
- const locale = params.locale || this.defaultLocale;
101
- const queryParams = { ...params, locale };
102
- const queryString = this.buildQueryString(queryParams);
103
- log2("Getting plugin list: %O", queryParams);
104
- const result = await this.request(`/v1/plugins${queryString}`);
105
- log2("Retrieved %d plugins", result.items.length);
106
- return result;
107
- }
108
- /**
109
- * 获取插件清单
110
- * @param identifier 插件标识符
111
- * @param locale 语言
112
- * @param version 版本
113
- * @returns 插件清单
114
- */
115
- async getPluginManifest(identifier, locale, version) {
116
- log2("Getting plugin manifest: %O", { identifier, version, locale });
117
- const localeParam = locale || this.defaultLocale;
118
- const params = { locale: localeParam };
119
- if (version) {
120
- params.version = version;
121
- }
122
- const queryString = this.buildQueryString(params);
123
- const manifest = await this.request(
124
- `/v1/plugins/${identifier}/manifest${queryString}`
125
- );
126
- log2("Plugin manifest successfully retrieved: %s", identifier);
127
- return manifest;
128
- }
129
- };
130
-
131
- // src/market/services/DiscoveryService.ts
132
- import debug3 from "debug";
133
- var log3 = debug3("lobe-market-sdk:discovery");
134
- var DiscoveryService = class extends BaseSDK {
135
- /**
136
- * 创建发现服务实例
137
- * @param options SDK 配置选项
138
- * @param sharedHeaders 共享的 headers 对象(可选)
139
- */
140
- constructor(options = {}, sharedHeaders) {
141
- super(options, sharedHeaders);
142
- log3("DiscoveryService instance created");
143
- }
144
- /**
145
- * 获取市场服务发现文档
146
- * @returns 服务发现文档
147
- */
148
- async getDiscoveryDocument() {
149
- log3("Fetching discovery document");
150
- if (this.discoveryDoc) {
151
- log3("Returning cached discovery document");
152
- return this.discoveryDoc;
153
- }
154
- this.discoveryDoc = await this.request("/market/.well-known/discovery");
155
- log3("Discovery document successfully fetched");
156
- return this.discoveryDoc;
157
- }
158
- };
159
-
160
- // src/market/market-sdk.ts
161
- var log4 = debug4("lobe-market-sdk");
162
- var MarketSDK = class extends BaseSDK {
163
- /**
164
- * Create MarketSDK instance
165
- * @param options SDK configuration options
166
- */
167
- constructor(options = {}) {
168
- super(options);
169
- log4("MarketSDK instance created");
170
- this.plugins = new PluginsService(options, this.headers);
171
- this.discovery = new DiscoveryService(options, this.headers);
172
- }
173
- /**
174
- * Get market service discovery document
175
- * @returns Service discovery document
176
- */
177
- async getDiscoveryDocument() {
178
- return this.discovery.getDiscoveryDocument();
179
- }
180
- };
181
-
182
- // src/admin/MarketAdmin.ts
183
- import debug9 from "debug";
184
-
185
87
  // src/admin/services/PluginService.ts
186
- import debug5 from "debug";
187
- var log5 = debug5("lobe-market-sdk:admin:plugin");
88
+ import debug2 from "debug";
89
+ var log2 = debug2("lobe-market-sdk:admin:plugin");
188
90
  var PluginService = class extends BaseSDK {
189
91
  /**
190
- * 创建插件管理服务实例
191
- * @param options SDK 配置选项
192
- * @param sharedHeaders 共享的 headers 对象(可选)
92
+ * Creates a new PluginService instance
93
+ *
94
+ * @param options - Configuration options for the SDK
95
+ * @param sharedHeaders - Optional shared headers object for reuse across services
193
96
  */
194
97
  constructor(options = {}, sharedHeaders) {
195
98
  super(options, sharedHeaders);
196
- log5("PluginService instance created");
99
+ log2("PluginService instance created");
197
100
  }
198
101
  /**
199
- * 导入插件清单(需要管理员权限)
200
- * @param manifests 插件清单数组
201
- * @param ownerId 所有者 ID
202
- * @returns 导入结果
102
+ * Imports plugin manifests (requires admin privileges)
103
+ *
104
+ * Allows batch importing of plugin manifests into the marketplace.
105
+ *
106
+ * @param manifests - Array of plugin manifests to import
107
+ * @param ownerId - Optional owner ID to associate with the imported plugins
108
+ * @returns Promise resolving to the import results with counts of success and failure
203
109
  */
204
110
  async importManifests(manifests, ownerId) {
205
- log5(`Starting batch import of ${manifests.length} manifests`);
111
+ log2(`Starting batch import of ${manifests.length} manifests`);
206
112
  if (ownerId) {
207
- log5(`Using specified owner ID: ${ownerId}`);
113
+ log2(`Using specified owner ID: ${ownerId}`);
208
114
  }
209
115
  const response = await this.request(
210
116
  "/admin/plugins/import",
211
117
  {
212
- method: "POST",
213
118
  body: JSON.stringify({
214
119
  manifests,
215
120
  ownerId
216
- })
121
+ }),
122
+ method: "POST"
217
123
  }
218
124
  );
219
- log5(`Batch import completed: ${response.success} succeeded, ${response.failed} failed`);
125
+ log2(`Batch import completed: ${response.success} succeeded, ${response.failed} failed`);
220
126
  return response;
221
127
  }
222
128
  /**
223
- * 获取插件列表
224
- * @param params 查询参数
225
- * @returns 插件列表响应
129
+ * Retrieves a list of plugins with admin details
130
+ *
131
+ * Supports filtering, pagination, and sorting of results.
132
+ *
133
+ * @param params - Query parameters for filtering and pagination
134
+ * @returns Promise resolving to the plugin list response with admin details
226
135
  */
227
136
  async getPlugins(params = {}) {
228
- log5("Getting plugins with params: %O", params);
137
+ log2("Getting plugins with params: %O", params);
229
138
  const queryString = this.buildQueryString(params);
230
139
  const url = `/admin/plugins${queryString}`;
231
140
  const result = await this.request(url);
232
- log5("Retrieved %d plugins", result.data.length);
141
+ log2("Retrieved %d plugins", result.data.length);
233
142
  return result;
234
143
  }
235
144
  /**
236
- * 获取单个插件
237
- * @param id 插件 ID
238
- * @returns 插件详情
145
+ * Retrieves a single plugin with full admin details
146
+ *
147
+ * @param id - Plugin ID or identifier
148
+ * @returns Promise resolving to the detailed plugin information with version history
239
149
  */
240
150
  async getPlugin(id) {
241
- log5("Getting plugin details (admin): %d", id);
151
+ log2("Getting plugin details (admin): %d", id);
242
152
  const result = await this.request(`/admin/plugins/${id}`);
243
- log5("Retrieved plugin with %d versions", result.versions.length);
153
+ log2("Retrieved plugin with %d versions", result.versions.length);
244
154
  return result;
245
155
  }
246
156
  /**
247
- * 更新插件信息
248
- * @param id 插件 ID
249
- * @param data 插件更新数据
250
- * @returns 更新后的插件
157
+ * Updates plugin information
158
+ *
159
+ * @param id - Plugin ID
160
+ * @param data - Plugin update data containing fields to update
161
+ * @returns Promise resolving to the updated plugin
251
162
  */
252
163
  async updatePlugin(id, data) {
253
- log5("Updating plugin: %d, data: %O", id, data);
164
+ log2("Updating plugin: %d, data: %O", id, data);
254
165
  const result = await this.request(`/admin/plugins/${id}`, {
255
- method: "PUT",
256
- body: JSON.stringify(data)
166
+ body: JSON.stringify(data),
167
+ method: "PUT"
257
168
  });
258
- log5("Plugin updated successfully");
169
+ log2("Plugin updated successfully");
259
170
  return result;
260
171
  }
261
172
  /**
262
- * 更新插件状态
263
- * @param id 插件 ID
264
- * @param status 新状态
265
- * @returns 成功响应
173
+ * Updates plugin publication status
174
+ *
175
+ * @param id - Plugin ID
176
+ * @param status - New status to set
177
+ * @returns Promise resolving to success response
266
178
  */
267
179
  async updatePluginStatus(id, status) {
268
- log5("Updating plugin status: %d to %s", id, status);
180
+ log2("Updating plugin status: %d to %s", id, status);
269
181
  const result = await this.request(
270
182
  `/admin/plugins/${id}/status`,
271
183
  {
272
- method: "PATCH",
273
- body: JSON.stringify({ status })
184
+ body: JSON.stringify({ status }),
185
+ method: "PATCH"
274
186
  }
275
187
  );
276
- log5("Plugin status updated successfully");
188
+ log2("Plugin status updated successfully");
277
189
  return result;
278
190
  }
279
191
  /**
280
- * 删除插件
281
- * @param id 插件 ID
282
- * @returns 成功响应
192
+ * Deletes a plugin
193
+ *
194
+ * @param id - Plugin ID
195
+ * @returns Promise resolving to success response
283
196
  */
284
197
  async deletePlugin(id) {
285
- log5("Deleting plugin: %d", id);
198
+ log2("Deleting plugin: %d", id);
286
199
  const result = await this.request(
287
200
  `/admin/plugins/${id}`,
288
201
  { method: "DELETE" }
289
202
  );
290
- log5("Plugin deleted successfully");
203
+ log2("Plugin deleted successfully");
291
204
  return result;
292
205
  }
293
206
  /**
294
- * 获取插件版本列表
295
- * @param pluginId 插件 ID
296
- * @returns 插件版本列表
207
+ * Retrieves the version history for a plugin
208
+ *
209
+ * @param pluginId - Plugin ID
210
+ * @returns Promise resolving to an array of plugin versions
297
211
  */
298
212
  async getPluginVersions(pluginId) {
299
- log5("Getting plugin versions: pluginId=%d", pluginId);
213
+ log2("Getting plugin versions: pluginId=%d", pluginId);
300
214
  const result = await this.request(`/admin/plugins/${pluginId}/versions`);
301
- log5("Retrieved %d versions", result.length);
215
+ log2("Retrieved %d versions", result.length);
302
216
  return result;
303
217
  }
304
218
  /**
305
- * 获取单个插件版本
306
- * @param pluginId 插件 ID
307
- * @param versionId 版本 ID
308
- * @returns 插件版本
219
+ * Retrieves a specific plugin version
220
+ *
221
+ * @param pluginId - Plugin ID
222
+ * @param versionId - Version ID
223
+ * @returns Promise resolving to the plugin version details
309
224
  */
310
225
  async getPluginVersion(pluginId, versionId) {
311
- log5("Getting version details: pluginId=%d, versionId=%d", pluginId, versionId);
226
+ log2("Getting version details: pluginId=%d, versionId=%d", pluginId, versionId);
312
227
  const result = await this.request(
313
228
  `/admin/plugins/${pluginId}/versions/${versionId}`
314
229
  );
315
- log5("Version details retrieved");
230
+ log2("Version details retrieved");
316
231
  return result;
317
232
  }
318
233
  /**
319
- * 创建插件版本
320
- * @param pluginId 插件 ID
321
- * @param data 版本创建数据
322
- * @returns 创建的版本
234
+ * Creates a new plugin version
235
+ *
236
+ * @param pluginId - Plugin ID
237
+ * @param data - Version creation data including manifest and version string
238
+ * @returns Promise resolving to the created plugin version
323
239
  */
324
240
  async createPluginVersion(pluginId, data) {
325
- log5("Creating new version: pluginId=%d", pluginId);
241
+ log2("Creating new version: pluginId=%d", pluginId);
326
242
  const result = await this.request(`/admin/plugins/${pluginId}/versions`, {
327
- method: "POST",
328
- body: JSON.stringify(data)
243
+ body: JSON.stringify(data),
244
+ method: "POST"
329
245
  });
330
- log5("Plugin version created successfully");
246
+ log2("Plugin version created successfully");
331
247
  return result;
332
248
  }
333
249
  /**
334
- * 更新插件版本
335
- * @param pluginId 插件 ID
336
- * @param versionId 版本 ID
337
- * @param data 版本更新数据
338
- * @returns 更新后的版本
250
+ * Updates a plugin version
251
+ *
252
+ * @param pluginId - Plugin ID
253
+ * @param versionId - Version ID
254
+ * @param data - Version update data
255
+ * @returns Promise resolving to the updated plugin version
339
256
  */
340
257
  async updatePluginVersion(pluginId, versionId, data) {
341
- log5("Updating version: pluginId=%d, versionId=%d", pluginId, versionId);
258
+ log2("Updating version: pluginId=%d, versionId=%d", pluginId, versionId);
342
259
  const result = await this.request(
343
260
  `/admin/plugins/${pluginId}/versions/${versionId}`,
344
261
  {
345
- method: "PUT",
346
- body: JSON.stringify(data)
262
+ body: JSON.stringify(data),
263
+ method: "PUT"
347
264
  }
348
265
  );
349
- log5("Plugin version updated successfully");
266
+ log2("Plugin version updated successfully");
350
267
  return result;
351
268
  }
352
269
  /**
353
- * 删除插件版本
354
- * @param pluginId 插件 ID
355
- * @param versionId 版本 ID
356
- * @returns 成功响应
270
+ * Deletes a plugin version
271
+ *
272
+ * @param pluginId - Plugin ID
273
+ * @param versionId - Version ID
274
+ * @returns Promise resolving to success response
357
275
  */
358
276
  async deletePluginVersion(pluginId, versionId) {
359
- log5("Deleting version: pluginId=%d, versionId=%d", pluginId, versionId);
277
+ log2("Deleting version: pluginId=%d, versionId=%d", pluginId, versionId);
360
278
  const result = await this.request(
361
279
  `/admin/plugins/${pluginId}/versions/${versionId}`,
362
280
  { method: "DELETE" }
363
281
  );
364
- log5("Plugin version deleted successfully");
282
+ log2("Plugin version deleted successfully");
365
283
  return result;
366
284
  }
367
285
  /**
368
- * 设置插件版本为最新版本
369
- * @param pluginId 插件 ID
370
- * @param versionId 版本 ID
371
- * @returns 成功响应
286
+ * Sets a specific version as the latest version of a plugin
287
+ *
288
+ * @param pluginId - Plugin ID
289
+ * @param versionId - Version ID to set as latest
290
+ * @returns Promise resolving to success response
372
291
  */
373
292
  async setPluginVersionAsLatest(pluginId, versionId) {
374
- log5("Setting version as latest: pluginId=%d, versionId=%d", pluginId, versionId);
293
+ log2("Setting version as latest: pluginId=%d, versionId=%d", pluginId, versionId);
375
294
  const result = await this.request(
376
295
  `/admin/plugins/${pluginId}/versions/${versionId}/latest`,
377
296
  { method: "POST" }
378
297
  );
379
- log5("Version set as latest");
298
+ log2("Version set as latest");
380
299
  return result;
381
300
  }
382
301
  /**
383
- * 更新插件可见性
384
- * @param id 插件 ID
385
- * @param visibility 新的可见性状态
386
- * @returns 成功响应
302
+ * Updates plugin visibility
303
+ *
304
+ * @param id - Plugin ID
305
+ * @param visibility - New visibility setting
306
+ * @returns Promise resolving to success response
387
307
  */
388
308
  async updatePluginVisibility(id, visibility) {
389
- log5("Updating plugin visibility: %d to %s", id, visibility);
309
+ log2("Updating plugin visibility: %d to %s", id, visibility);
390
310
  const result = await this.request(
391
311
  `/admin/plugins/${id}/visibility`,
392
312
  {
393
- method: "PATCH",
394
- body: JSON.stringify({ visibility })
313
+ body: JSON.stringify({ visibility }),
314
+ method: "PATCH"
395
315
  }
396
316
  );
397
- log5("Plugin visibility updated successfully");
317
+ log2("Plugin visibility updated successfully");
398
318
  return result;
399
319
  }
400
320
  /**
401
- * 批量更新插件状态
402
- * @param ids 插件 ID 数组
403
- * @param status 新的状态
404
- * @returns 成功响应
321
+ * Updates status for multiple plugins in a single operation
322
+ *
323
+ * @param ids - Array of plugin IDs to update
324
+ * @param status - New status to set for all specified plugins
325
+ * @returns Promise resolving to success response
405
326
  */
406
327
  async batchUpdatePluginStatus(ids, status) {
407
- log5("Batch updating plugin status: %O to %s", ids, status);
328
+ log2("Batch updating plugin status: %O to %s", ids, status);
408
329
  const result = await this.request(
409
330
  "/admin/plugins/batch/status",
410
331
  {
411
- method: "PATCH",
412
- body: JSON.stringify({ ids, status })
332
+ body: JSON.stringify({ ids, status }),
333
+ method: "PATCH"
413
334
  }
414
335
  );
415
- log5("Batch plugin status update completed");
336
+ log2("Batch plugin status update completed");
416
337
  return result;
417
338
  }
418
339
  /**
419
- * 批量删除插件
420
- * @param ids 插件 ID 数组
421
- * @returns 成功响应
340
+ * Deletes multiple plugins in a single operation
341
+ *
342
+ * @param ids - Array of plugin IDs to delete
343
+ * @returns Promise resolving to success response
422
344
  */
423
345
  async batchDeletePlugins(ids) {
424
- log5("Batch deleting plugins: %O", ids);
346
+ log2("Batch deleting plugins: %O", ids);
425
347
  const result = await this.request(
426
348
  "/admin/plugins/batch/delete",
427
349
  {
428
- method: "DELETE",
429
- body: JSON.stringify({ ids })
350
+ body: JSON.stringify({ ids }),
351
+ method: "DELETE"
430
352
  }
431
353
  );
432
- log5("Batch plugin deletion completed");
354
+ log2("Batch plugin deletion completed");
433
355
  return result;
434
356
  }
435
357
  /**
436
- * 获取插件版本详情
437
- * @param pluginId 插件 ID
438
- * @param versionId 版本 ID
439
- * @returns 版本详情
358
+ * Retrieves detailed information about a plugin version including deployment options
359
+ *
360
+ * @param pluginId - Plugin ID
361
+ * @param versionId - Version ID
362
+ * @returns Promise resolving to version details with deployment options
440
363
  */
441
364
  async getPluginVersionDetails(pluginId, versionId) {
442
- log5(
365
+ log2(
443
366
  "Getting version details with deployment options: pluginId=%d, versionId=%d",
444
367
  pluginId,
445
368
  versionId
@@ -447,71 +370,75 @@ var PluginService = class extends BaseSDK {
447
370
  const result = await this.request(
448
371
  `/admin/plugins/${pluginId}/versions/${versionId}`
449
372
  );
450
- log5("Version details with deployment options retrieved");
373
+ log2("Version details with deployment options retrieved");
451
374
  return result;
452
375
  }
453
376
  /**
454
- * 更新插件版本信息
455
- * @param pluginId 插件 ID
456
- * @param versionId 版本 ID
457
- * @param data 版本更新数据
458
- * @returns 更新后的版本
377
+ * Updates detailed information for a plugin version
378
+ *
379
+ * @param pluginId - Plugin ID
380
+ * @param versionId - Version ID
381
+ * @param data - Detailed version update data including metadata and capabilities
382
+ * @returns Promise resolving to the updated plugin version
459
383
  */
460
384
  async updatePluginVersionDetails(pluginId, versionId, data) {
461
- log5("Updating version details: pluginId=%d, versionId=%d", pluginId, versionId);
385
+ log2("Updating version details: pluginId=%d, versionId=%d", pluginId, versionId);
462
386
  const result = await this.request(
463
387
  `/admin/plugins/${pluginId}/versions/${versionId}`,
464
388
  {
465
- method: "PUT",
466
- body: JSON.stringify(data)
389
+ body: JSON.stringify(data),
390
+ method: "PUT"
467
391
  }
468
392
  );
469
- log5("Version details updated successfully");
393
+ log2("Version details updated successfully");
470
394
  return result;
471
395
  }
472
396
  /**
473
- * 获取插件版本的部署选项列表
474
- * @param pluginId 插件 ID
475
- * @param versionId 版本 ID
476
- * @returns 部署选项列表
397
+ * Retrieves deployment options for a specific plugin version
398
+ *
399
+ * @param pluginId - Plugin ID
400
+ * @param versionId - Version ID
401
+ * @returns Promise resolving to an array of deployment options
477
402
  */
478
403
  async getDeploymentOptions(pluginId, versionId) {
479
- log5("Getting deployment options: pluginId=%d, versionId=%d", pluginId, versionId);
404
+ log2("Getting deployment options: pluginId=%d, versionId=%d", pluginId, versionId);
480
405
  const result = await this.request(
481
406
  `/admin/plugins/${pluginId}/versions/${versionId}/deployment-options`
482
407
  );
483
- log5("Retrieved %d deployment options", result.length);
408
+ log2("Retrieved %d deployment options", result.length);
484
409
  return result;
485
410
  }
486
411
  /**
487
- * 创建部署选项
488
- * @param pluginId 插件 ID
489
- * @param versionId 版本 ID
490
- * @param data 部署选项数据
491
- * @returns 创建的部署选项
412
+ * Creates a new deployment option for a plugin version
413
+ *
414
+ * @param pluginId - Plugin ID
415
+ * @param versionId - Version ID
416
+ * @param data - Deployment option configuration data
417
+ * @returns Promise resolving to the created deployment option
492
418
  */
493
419
  async createDeploymentOption(pluginId, versionId, data) {
494
- log5("Creating deployment option: pluginId=%d, versionId=%d", pluginId, versionId);
420
+ log2("Creating deployment option: pluginId=%d, versionId=%d", pluginId, versionId);
495
421
  const result = await this.request(
496
422
  `/admin/plugins/${pluginId}/versions/${versionId}/deployment-options`,
497
423
  {
498
- method: "POST",
499
- body: JSON.stringify(data)
424
+ body: JSON.stringify(data),
425
+ method: "POST"
500
426
  }
501
427
  );
502
- log5("Deployment option created successfully");
428
+ log2("Deployment option created successfully");
503
429
  return result;
504
430
  }
505
431
  /**
506
- * 更新部署选项
507
- * @param pluginId 插件 ID
508
- * @param versionId 版本 ID
509
- * @param optionId 部署选项 ID
510
- * @param data 部署选项更新数据
511
- * @returns 更新后的部署选项
432
+ * Updates an existing deployment option
433
+ *
434
+ * @param pluginId - Plugin ID
435
+ * @param versionId - Version ID
436
+ * @param optionId - Deployment option ID
437
+ * @param data - Updated deployment option configuration
438
+ * @returns Promise resolving to the updated deployment option
512
439
  */
513
440
  async updateDeploymentOption(pluginId, versionId, optionId, data) {
514
- log5(
441
+ log2(
515
442
  "Updating deployment option: pluginId=%d, versionId=%d, optionId=%d",
516
443
  pluginId,
517
444
  versionId,
@@ -520,22 +447,23 @@ var PluginService = class extends BaseSDK {
520
447
  const result = await this.request(
521
448
  `/admin/plugins/${pluginId}/versions/${versionId}/deployment-options/${optionId}`,
522
449
  {
523
- method: "PUT",
524
- body: JSON.stringify(data)
450
+ body: JSON.stringify(data),
451
+ method: "PUT"
525
452
  }
526
453
  );
527
- log5("Deployment option updated successfully");
454
+ log2("Deployment option updated successfully");
528
455
  return result;
529
456
  }
530
457
  /**
531
- * 删除部署选项
532
- * @param pluginId 插件 ID
533
- * @param versionId 版本 ID
534
- * @param optionId 部署选项 ID
535
- * @returns 成功响应
458
+ * Deletes a deployment option
459
+ *
460
+ * @param pluginId - Plugin ID
461
+ * @param versionId - Version ID
462
+ * @param optionId - Deployment option ID
463
+ * @returns Promise resolving to success response
536
464
  */
537
465
  async deleteDeploymentOption(pluginId, versionId, optionId) {
538
- log5(
466
+ log2(
539
467
  "Deleting deployment option: pluginId=%d, versionId=%d, optionId=%d",
540
468
  pluginId,
541
469
  versionId,
@@ -545,18 +473,19 @@ var PluginService = class extends BaseSDK {
545
473
  `/admin/plugins/${pluginId}/versions/${versionId}/deployment-options/${optionId}`,
546
474
  { method: "DELETE" }
547
475
  );
548
- log5("Deployment option deleted successfully");
476
+ log2("Deployment option deleted successfully");
549
477
  return result;
550
478
  }
551
479
  /**
552
- * 获取部署选项的系统依赖
553
- * @param pluginId 插件 ID
554
- * @param versionId 版本 ID
555
- * @param optionId 部署选项 ID
556
- * @returns 系统依赖列表
480
+ * Retrieves system dependencies for a deployment option
481
+ *
482
+ * @param pluginId - Plugin ID
483
+ * @param versionId - Version ID
484
+ * @param optionId - Deployment option ID
485
+ * @returns Promise resolving to an array of system dependencies
557
486
  */
558
487
  async getDeploymentOptionSystemDependencies(pluginId, versionId, optionId) {
559
- log5(
488
+ log2(
560
489
  "Getting system dependencies: pluginId=%d, versionId=%d, optionId=%d",
561
490
  pluginId,
562
491
  versionId,
@@ -565,233 +494,254 @@ var PluginService = class extends BaseSDK {
565
494
  const result = await this.request(
566
495
  `/admin/plugins/${pluginId}/versions/${versionId}/deployment-options/${optionId}/system-dependencies`
567
496
  );
568
- log5("Retrieved %d system dependencies", result.length);
497
+ log2("Retrieved %d system dependencies", result.length);
569
498
  return result;
570
499
  }
571
500
  };
572
501
 
573
502
  // src/admin/services/SystemDependencyService.ts
574
- import debug6 from "debug";
575
- var log6 = debug6("lobe-market-sdk:admin:dependency");
503
+ import debug3 from "debug";
504
+ var log3 = debug3("lobe-market-sdk:admin:dependency");
576
505
  var SystemDependencyService = class extends BaseSDK {
577
506
  /**
578
- * 创建系统依赖管理服务实例
579
- * @param options SDK 配置选项
580
- * @param sharedHeaders 共享的 headers 对象(可选)
507
+ * Creates a new SystemDependencyService instance
508
+ *
509
+ * @param options - Configuration options for the SDK
510
+ * @param sharedHeaders - Optional shared headers object for reuse across services
581
511
  */
582
512
  constructor(options = {}, sharedHeaders) {
583
513
  super(options, sharedHeaders);
584
- log6("SystemDependencyService instance created");
514
+ log3("SystemDependencyService instance created");
585
515
  }
586
516
  /**
587
- * 获取所有系统依赖项
588
- * @returns 系统依赖项列表
517
+ * Retrieves all system dependencies
518
+ *
519
+ * Gets a list of all defined system dependencies that plugins may require.
520
+ *
521
+ * @returns Promise resolving to an array of system dependencies
589
522
  */
590
523
  async getSystemDependencies() {
591
- log6("Getting all system dependencies");
524
+ log3("Getting all system dependencies");
592
525
  const result = await this.request(`/admin/plugins/dependencies`);
593
- log6("Retrieved %d system dependencies", result.length);
526
+ log3("Retrieved %d system dependencies", result.length);
594
527
  return result;
595
528
  }
596
529
  /**
597
- * 获取特定系统依赖项
598
- * @param id 依赖项 ID
599
- * @returns 系统依赖项
530
+ * Retrieves a specific system dependency by ID
531
+ *
532
+ * @param id - System dependency ID
533
+ * @returns Promise resolving to the system dependency details
600
534
  */
601
535
  async getSystemDependency(id) {
602
- log6("Getting system dependency details: %d", id);
536
+ log3("Getting system dependency details: %d", id);
603
537
  const result = await this.request(`/admin/plugins/dependencies/${id}`);
604
- log6("System dependency details retrieved");
538
+ log3("System dependency details retrieved");
605
539
  return result;
606
540
  }
607
541
  /**
608
- * 创建系统依赖项
609
- * @param data 依赖项创建数据
610
- * @returns 创建的依赖项
542
+ * Creates a new system dependency
543
+ *
544
+ * @param data - System dependency creation data
545
+ * @returns Promise resolving to the created system dependency
611
546
  */
612
547
  async createSystemDependency(data) {
613
- log6("Creating system dependency: %O", data);
548
+ log3("Creating system dependency: %O", data);
614
549
  const result = await this.request(`/admin/plugins/dependencies`, {
615
- method: "POST",
616
- body: JSON.stringify(data)
550
+ body: JSON.stringify(data),
551
+ method: "POST"
617
552
  });
618
- log6("System dependency created successfully");
553
+ log3("System dependency created successfully");
619
554
  return result;
620
555
  }
621
556
  /**
622
- * 更新系统依赖项
623
- * @param id 依赖项 ID
624
- * @param data 依赖项更新数据
625
- * @returns 更新后的依赖项
557
+ * Updates an existing system dependency
558
+ *
559
+ * @param id - System dependency ID
560
+ * @param data - System dependency update data
561
+ * @returns Promise resolving to the updated system dependency
626
562
  */
627
563
  async updateSystemDependency(id, data) {
628
- log6("Updating system dependency: %d, data: %O", id, data);
564
+ log3("Updating system dependency: %d, data: %O", id, data);
629
565
  const result = await this.request(`/admin/plugins/dependencies/${id}`, {
630
- method: "PUT",
631
- body: JSON.stringify(data)
566
+ body: JSON.stringify(data),
567
+ method: "PUT"
632
568
  });
633
- log6("System dependency updated successfully");
569
+ log3("System dependency updated successfully");
634
570
  return result;
635
571
  }
636
572
  /**
637
- * 删除系统依赖项
638
- * @param id 依赖项 ID
639
- * @returns 成功响应
573
+ * Deletes a system dependency
574
+ *
575
+ * @param id - System dependency ID
576
+ * @returns Promise resolving to success response
640
577
  */
641
578
  async deleteSystemDependency(id) {
642
- log6("Deleting system dependency: %d", id);
579
+ log3("Deleting system dependency: %d", id);
643
580
  const result = await this.request(
644
581
  `/admin/plugins/dependencies/${id}`,
645
582
  { method: "DELETE" }
646
583
  );
647
- log6("System dependency deleted successfully");
584
+ log3("System dependency deleted successfully");
648
585
  return result;
649
586
  }
650
587
  };
651
588
 
652
589
  // src/admin/services/SettingsService.ts
653
- import debug7 from "debug";
654
- var log7 = debug7("lobe-market-sdk:admin:settings");
590
+ import debug4 from "debug";
591
+ var log4 = debug4("lobe-market-sdk:admin:settings");
655
592
  var SettingsService = class extends BaseSDK {
656
593
  /**
657
- * 获取设置列表
658
- * @param params 查询参数
659
- * @returns 设置键值对对象
594
+ * Retrieves all system settings
595
+ *
596
+ * Returns a consolidated map of all settings with typed values
597
+ * for known setting keys.
598
+ *
599
+ * @returns Promise resolving to the settings map
660
600
  */
661
601
  async getSettings() {
662
602
  return await this.request("/admin/settings");
663
603
  }
664
604
  /**
665
- * 获取单个设置
666
- * @param key 设置键名
667
- * @returns 设置详情
605
+ * Retrieves a specific setting by key
606
+ *
607
+ * @param key - Setting key name
608
+ * @returns Promise resolving to the setting details
668
609
  */
669
610
  async getSettingByKey(key) {
670
- log7("Getting setting: %s", key);
611
+ log4("Getting setting: %s", key);
671
612
  const result = await this.request(`/admin/settings/${key}`);
672
- log7("Setting retrieved");
613
+ log4("Setting retrieved");
673
614
  return result;
674
615
  }
675
616
  /**
676
- * 创建设置
677
- * @param data 设置数据
678
- * @returns 创建的设置
617
+ * Creates a new system setting
618
+ *
619
+ * @param data - Setting creation parameters
620
+ * @returns Promise resolving to the created setting
679
621
  */
680
622
  async createSetting(data) {
681
- log7("Creating setting: %O", data);
623
+ log4("Creating setting: %O", data);
682
624
  const result = await this.request("/admin/settings", {
683
- method: "POST",
684
- body: JSON.stringify(data)
625
+ body: JSON.stringify(data),
626
+ method: "POST"
685
627
  });
686
- log7("Setting created successfully");
628
+ log4("Setting created successfully");
687
629
  return result;
688
630
  }
689
631
  /**
690
- * 更新设置
691
- * @param key 设置键名
692
- * @param data 更新数据
693
- * @returns 更新后的设置
632
+ * Updates an existing setting
633
+ *
634
+ * @param key - Setting key name
635
+ * @param data - Setting update parameters
636
+ * @returns Promise resolving to the updated setting
694
637
  */
695
638
  async updateSetting(key, data) {
696
- log7("Updating setting: %s, data: %O", key, data);
639
+ log4("Updating setting: %s, data: %O", key, data);
697
640
  const result = await this.request(`/admin/settings/${key}`, {
698
- method: "PUT",
699
- body: JSON.stringify(data)
641
+ body: JSON.stringify(data),
642
+ method: "PUT"
700
643
  });
701
- log7("Setting updated successfully");
644
+ log4("Setting updated successfully");
702
645
  return result;
703
646
  }
704
647
  /**
705
- * 删除设置
706
- * @param key 设置键名
707
- * @returns 删除结果
648
+ * Deletes a setting
649
+ *
650
+ * @param key - Setting key name
651
+ * @returns Promise resolving to success message
708
652
  */
709
653
  async deleteSetting(key) {
710
- log7("Deleting setting: %s", key);
654
+ log4("Deleting setting: %s", key);
711
655
  const result = await this.request(`/admin/settings/${key}`, {
712
656
  method: "DELETE"
713
657
  });
714
- log7("Setting deleted successfully");
658
+ log4("Setting deleted successfully");
715
659
  return result;
716
660
  }
717
661
  };
718
662
 
719
663
  // src/admin/services/ReviewService.ts
720
- import debug8 from "debug";
721
- var log8 = debug8("lobe-market-sdk:admin:review");
664
+ import debug5 from "debug";
665
+ var log5 = debug5("lobe-market-sdk:admin:review");
722
666
  var ReviewService = class extends BaseSDK {
723
667
  /**
724
- * 创建审核管理服务实例
725
- * @param options SDK 配置选项
726
- * @param sharedHeaders 共享的 headers 对象(可选)
668
+ * Creates a new ReviewService instance
669
+ *
670
+ * @param options - Configuration options for the SDK
671
+ * @param sharedHeaders - Optional shared headers object for reuse across services
727
672
  */
728
673
  constructor(options = {}, sharedHeaders) {
729
674
  super(options, sharedHeaders);
730
- log8("ReviewService instance created");
675
+ log5("ReviewService instance created");
731
676
  }
732
677
  /**
733
- * 获取审核列表
734
- * @param params 查询参数
735
- * @returns 审核列表响应
678
+ * Retrieves a list of reviews with filtering options
679
+ *
680
+ * @param params - Query parameters for filtering and pagination
681
+ * @returns Promise resolving to the review list response
736
682
  */
737
683
  async getReviews(params = {}) {
738
- log8("Getting reviews with params: %O", params);
684
+ log5("Getting reviews with params: %O", params);
739
685
  const queryString = this.buildQueryString(params);
740
686
  const url = `/admin/reviews${queryString ? `?${queryString}` : ""}`;
741
687
  const result = await this.request(url);
742
- log8("Retrieved %d reviews", result.data.length);
688
+ log5("Retrieved %d reviews", result.data.length);
743
689
  return result;
744
690
  }
745
691
  /**
746
- * 获取审核详情
747
- * @param id 审核 ID
748
- * @returns 审核详情
692
+ * Retrieves a specific review by ID
693
+ *
694
+ * @param id - Review ID
695
+ * @returns Promise resolving to the review details
749
696
  */
750
697
  async getReviewById(id) {
751
- log8("Getting review details: %d", id);
698
+ log5("Getting review details: %d", id);
752
699
  const result = await this.request(`/admin/reviews/${id}`);
753
- log8("Review details retrieved");
700
+ log5("Review details retrieved");
754
701
  return result;
755
702
  }
756
703
  /**
757
- * 更新审核状态
758
- * @param id 审核 ID
759
- * @param data 更新数据
760
- * @returns 更新后的审核信息
704
+ * Updates a review's status and comment
705
+ *
706
+ * @param id - Review ID
707
+ * @param data - Update parameters containing new status and optional comment
708
+ * @returns Promise resolving to the updated review
761
709
  */
762
710
  async updateReview(id, data) {
763
- log8("Updating review: %d, data: %O", id, data);
711
+ log5("Updating review: %d, data: %O", id, data);
764
712
  const result = await this.request(`/admin/reviews/${id}`, {
765
- method: "PUT",
766
- body: JSON.stringify(data)
713
+ body: JSON.stringify(data),
714
+ method: "PUT"
767
715
  });
768
- log8("Review updated successfully");
716
+ log5("Review updated successfully");
769
717
  return result;
770
718
  }
771
719
  /**
772
- * 获取插件的审核历史
773
- * @param pluginId 插件 ID
774
- * @returns 审核历史列表
720
+ * Retrieves the review history for a specific plugin
721
+ *
722
+ * @param pluginId - Plugin ID
723
+ * @returns Promise resolving to an array of reviews for the plugin
775
724
  */
776
725
  async getPluginReviews(pluginId) {
777
- log8("Getting plugin reviews: pluginId=%d", pluginId);
726
+ log5("Getting plugin reviews: pluginId=%d", pluginId);
778
727
  const result = await this.request(`/admin/reviews/plugin/${pluginId}`);
779
- log8("Retrieved %d reviews for plugin", result.data.length);
728
+ log5("Retrieved %d reviews for plugin", result.data.length);
780
729
  return result;
781
730
  }
782
731
  };
783
732
 
784
733
  // src/admin/MarketAdmin.ts
785
- var log9 = debug9("lobe-market-sdk:admin");
734
+ var log6 = debug6("lobe-market-sdk:admin");
786
735
  var MarketAdmin = class extends BaseSDK {
787
736
  /**
788
- * 创建 MarketAdmin 实例
789
- * @param options SDK 配置选项
737
+ * Creates a new MarketAdmin instance
738
+ *
739
+ * @param options - Configuration options for the SDK
790
740
  */
791
741
  constructor(options = {}) {
792
742
  const apiKey = options.apiKey || process.env.MARKET_ADMIN_API_KEY;
793
743
  super({ ...options, apiKey });
794
- log9("MarketAdmin instance created");
744
+ log6("MarketAdmin instance created");
795
745
  this.plugins = new PluginService(options, this.headers);
796
746
  this.reviews = new ReviewService(options, this.headers);
797
747
  this.settings = new SettingsService(options, this.headers);
@@ -799,6 +749,143 @@ var MarketAdmin = class extends BaseSDK {
799
749
  }
800
750
  };
801
751
 
752
+ // src/market/market-sdk.ts
753
+ import debug9 from "debug";
754
+
755
+ // src/market/services/DiscoveryService.ts
756
+ import debug7 from "debug";
757
+ var log7 = debug7("lobe-market-sdk:discovery");
758
+ var DiscoveryService = class extends BaseSDK {
759
+ /**
760
+ * Creates a new DiscoveryService instance
761
+ *
762
+ * @param options - Configuration options for the SDK
763
+ * @param sharedHeaders - Optional shared headers object for reuse across services
764
+ */
765
+ constructor(options = {}, sharedHeaders) {
766
+ super(options, sharedHeaders);
767
+ log7("DiscoveryService instance created");
768
+ }
769
+ /**
770
+ * Retrieves the service discovery document
771
+ *
772
+ * This document contains information about available API endpoints,
773
+ * authentication methods, and other capabilities of the Market API.
774
+ * The result is cached after the first request to improve performance.
775
+ *
776
+ * @returns Promise resolving to the service discovery document
777
+ */
778
+ async getDiscoveryDocument() {
779
+ log7("Fetching discovery document");
780
+ if (this.discoveryDoc) {
781
+ log7("Returning cached discovery document");
782
+ return this.discoveryDoc;
783
+ }
784
+ this.discoveryDoc = await this.request("/market/.well-known/discovery");
785
+ log7("Discovery document successfully fetched");
786
+ return this.discoveryDoc;
787
+ }
788
+ };
789
+
790
+ // src/market/services/PluginsService.ts
791
+ import debug8 from "debug";
792
+ var log8 = debug8("lobe-market-sdk:plugins");
793
+ var PluginsService = class extends BaseSDK {
794
+ /**
795
+ * Creates a new PluginsService instance
796
+ *
797
+ * @param options - Configuration options for the SDK
798
+ * @param sharedHeaders - Optional shared headers object for reuse across services
799
+ */
800
+ constructor(options = {}, sharedHeaders) {
801
+ super(options, sharedHeaders);
802
+ log8("PluginsService instance created");
803
+ }
804
+ /**
805
+ * Retrieves a list of plugins from the marketplace
806
+ *
807
+ * Supports filtering, pagination, and localization of results.
808
+ *
809
+ * @param params - Query parameters for filtering and pagination
810
+ * @returns Promise resolving to the plugin list response containing items and pagination info
811
+ */
812
+ async getPluginList(params = {}) {
813
+ const locale = params.locale || this.defaultLocale;
814
+ const queryParams = { ...params, locale };
815
+ const queryString = this.buildQueryString(queryParams);
816
+ log8("Getting plugin list: %O", queryParams);
817
+ const result = await this.request(`/v1/plugins${queryString}`);
818
+ log8("Retrieved %d plugins", result.items.length);
819
+ return result;
820
+ }
821
+ /**
822
+ * Retrieves all plugin categories and their counts
823
+ *
824
+ * Returns a list of categories along with the number of plugins in each category.
825
+ * Useful for building category filters in a UI.
826
+ *
827
+ * @returns Promise resolving to an array of category items with counts
828
+ */
829
+ async getCategories() {
830
+ log8("Getting plugin categories");
831
+ const result = await this.request("/v1/plugins/categories");
832
+ log8("Retrieved %d categories", result.length);
833
+ return result;
834
+ }
835
+ /**
836
+ * Retrieves the manifest for a specific plugin
837
+ *
838
+ * The manifest contains detailed information about a plugin, including
839
+ * its capabilities, tools, prompts, and resources.
840
+ *
841
+ * @param identifier - Unique identifier of the plugin
842
+ * @param locale - Optional locale for localized content (defaults to SDK default locale)
843
+ * @param version - Optional specific version to retrieve (defaults to latest)
844
+ * @returns Promise resolving to the plugin manifest
845
+ */
846
+ async getPluginManifest(identifier, locale, version) {
847
+ log8("Getting plugin manifest: %O", { identifier, locale, version });
848
+ const localeParam = locale || this.defaultLocale;
849
+ const params = { locale: localeParam };
850
+ if (version) {
851
+ params.version = version;
852
+ }
853
+ const queryString = this.buildQueryString(params);
854
+ const manifest = await this.request(
855
+ `/v1/plugins/${identifier}/manifest${queryString}`
856
+ );
857
+ log8("Plugin manifest successfully retrieved: %s", identifier);
858
+ return manifest;
859
+ }
860
+ };
861
+
862
+ // src/market/market-sdk.ts
863
+ var log9 = debug9("lobe-market-sdk");
864
+ var MarketSDK = class extends BaseSDK {
865
+ /**
866
+ * Creates a new MarketSDK instance
867
+ *
868
+ * @param options - Configuration options for the SDK
869
+ */
870
+ constructor(options = {}) {
871
+ super(options);
872
+ log9("MarketSDK instance created");
873
+ this.plugins = new PluginsService(options, this.headers);
874
+ this.discovery = new DiscoveryService(options, this.headers);
875
+ }
876
+ /**
877
+ * Retrieves the service discovery document
878
+ *
879
+ * The discovery document provides information about available API endpoints,
880
+ * versions, and capabilities of the Market API.
881
+ *
882
+ * @returns Promise resolving to the service discovery document
883
+ */
884
+ async getDiscoveryDocument() {
885
+ return this.discovery.getDiscoveryDocument();
886
+ }
887
+ };
888
+
802
889
  // src/types/admin.ts
803
890
  import { z } from "zod";
804
891
  var VisibilityEnumSchema = z.enum(["public", "private", "internal"]);