@lobehub/market-sdk 0.0.27 → 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,370 +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);
242
- const result = await this.request(
243
- `/admin/plugins/${id}`
244
- );
245
- log5("Retrieved plugin with %d versions", result.versions.length);
151
+ log2("Getting plugin details (admin): %d", id);
152
+ const result = await this.request(`/admin/plugins/${id}`);
153
+ log2("Retrieved plugin with %d versions", result.versions.length);
246
154
  return result;
247
155
  }
248
156
  /**
249
- * 更新插件信息
250
- * @param id 插件 ID
251
- * @param data 插件更新数据
252
- * @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
253
162
  */
254
163
  async updatePlugin(id, data) {
255
- log5("Updating plugin: %d, data: %O", id, data);
164
+ log2("Updating plugin: %d, data: %O", id, data);
256
165
  const result = await this.request(`/admin/plugins/${id}`, {
257
- method: "PUT",
258
- body: JSON.stringify(data)
166
+ body: JSON.stringify(data),
167
+ method: "PUT"
259
168
  });
260
- log5("Plugin updated successfully");
169
+ log2("Plugin updated successfully");
261
170
  return result;
262
171
  }
263
172
  /**
264
- * 更新插件状态
265
- * @param id 插件 ID
266
- * @param status 新状态
267
- * @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
268
178
  */
269
179
  async updatePluginStatus(id, status) {
270
- log5("Updating plugin status: %d to %s", id, status);
180
+ log2("Updating plugin status: %d to %s", id, status);
271
181
  const result = await this.request(
272
182
  `/admin/plugins/${id}/status`,
273
183
  {
274
- method: "PATCH",
275
- body: JSON.stringify({ status })
184
+ body: JSON.stringify({ status }),
185
+ method: "PATCH"
276
186
  }
277
187
  );
278
- log5("Plugin status updated successfully");
188
+ log2("Plugin status updated successfully");
279
189
  return result;
280
190
  }
281
191
  /**
282
- * 删除插件
283
- * @param id 插件 ID
284
- * @returns 成功响应
192
+ * Deletes a plugin
193
+ *
194
+ * @param id - Plugin ID
195
+ * @returns Promise resolving to success response
285
196
  */
286
197
  async deletePlugin(id) {
287
- log5("Deleting plugin: %d", id);
198
+ log2("Deleting plugin: %d", id);
288
199
  const result = await this.request(
289
200
  `/admin/plugins/${id}`,
290
201
  { method: "DELETE" }
291
202
  );
292
- log5("Plugin deleted successfully");
203
+ log2("Plugin deleted successfully");
293
204
  return result;
294
205
  }
295
206
  /**
296
- * 获取插件版本列表
297
- * @param pluginId 插件 ID
298
- * @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
299
211
  */
300
212
  async getPluginVersions(pluginId) {
301
- log5("Getting plugin versions: pluginId=%d", pluginId);
213
+ log2("Getting plugin versions: pluginId=%d", pluginId);
302
214
  const result = await this.request(`/admin/plugins/${pluginId}/versions`);
303
- log5("Retrieved %d versions", result.length);
215
+ log2("Retrieved %d versions", result.length);
304
216
  return result;
305
217
  }
306
218
  /**
307
- * 获取单个插件版本
308
- * @param pluginId 插件 ID
309
- * @param versionId 版本 ID
310
- * @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
311
224
  */
312
225
  async getPluginVersion(pluginId, versionId) {
313
- log5("Getting version details: pluginId=%d, versionId=%d", pluginId, versionId);
226
+ log2("Getting version details: pluginId=%d, versionId=%d", pluginId, versionId);
314
227
  const result = await this.request(
315
228
  `/admin/plugins/${pluginId}/versions/${versionId}`
316
229
  );
317
- log5("Version details retrieved");
230
+ log2("Version details retrieved");
318
231
  return result;
319
232
  }
320
233
  /**
321
- * 创建插件版本
322
- * @param pluginId 插件 ID
323
- * @param data 版本创建数据
324
- * @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
325
239
  */
326
240
  async createPluginVersion(pluginId, data) {
327
- log5("Creating new version: pluginId=%d", pluginId);
241
+ log2("Creating new version: pluginId=%d", pluginId);
328
242
  const result = await this.request(`/admin/plugins/${pluginId}/versions`, {
329
- method: "POST",
330
- body: JSON.stringify(data)
243
+ body: JSON.stringify(data),
244
+ method: "POST"
331
245
  });
332
- log5("Plugin version created successfully");
246
+ log2("Plugin version created successfully");
333
247
  return result;
334
248
  }
335
249
  /**
336
- * 更新插件版本
337
- * @param pluginId 插件 ID
338
- * @param versionId 版本 ID
339
- * @param data 版本更新数据
340
- * @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
341
256
  */
342
257
  async updatePluginVersion(pluginId, versionId, data) {
343
- log5("Updating version: pluginId=%d, versionId=%d", pluginId, versionId);
258
+ log2("Updating version: pluginId=%d, versionId=%d", pluginId, versionId);
344
259
  const result = await this.request(
345
260
  `/admin/plugins/${pluginId}/versions/${versionId}`,
346
261
  {
347
- method: "PUT",
348
- body: JSON.stringify(data)
262
+ body: JSON.stringify(data),
263
+ method: "PUT"
349
264
  }
350
265
  );
351
- log5("Plugin version updated successfully");
266
+ log2("Plugin version updated successfully");
352
267
  return result;
353
268
  }
354
269
  /**
355
- * 删除插件版本
356
- * @param pluginId 插件 ID
357
- * @param versionId 版本 ID
358
- * @returns 成功响应
270
+ * Deletes a plugin version
271
+ *
272
+ * @param pluginId - Plugin ID
273
+ * @param versionId - Version ID
274
+ * @returns Promise resolving to success response
359
275
  */
360
276
  async deletePluginVersion(pluginId, versionId) {
361
- log5("Deleting version: pluginId=%d, versionId=%d", pluginId, versionId);
277
+ log2("Deleting version: pluginId=%d, versionId=%d", pluginId, versionId);
362
278
  const result = await this.request(
363
279
  `/admin/plugins/${pluginId}/versions/${versionId}`,
364
280
  { method: "DELETE" }
365
281
  );
366
- log5("Plugin version deleted successfully");
282
+ log2("Plugin version deleted successfully");
367
283
  return result;
368
284
  }
369
285
  /**
370
- * 设置插件版本为最新版本
371
- * @param pluginId 插件 ID
372
- * @param versionId 版本 ID
373
- * @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
374
291
  */
375
292
  async setPluginVersionAsLatest(pluginId, versionId) {
376
- log5("Setting version as latest: pluginId=%d, versionId=%d", pluginId, versionId);
293
+ log2("Setting version as latest: pluginId=%d, versionId=%d", pluginId, versionId);
377
294
  const result = await this.request(
378
295
  `/admin/plugins/${pluginId}/versions/${versionId}/latest`,
379
296
  { method: "POST" }
380
297
  );
381
- log5("Version set as latest");
298
+ log2("Version set as latest");
382
299
  return result;
383
300
  }
384
301
  /**
385
- * 更新插件可见性
386
- * @param id 插件 ID
387
- * @param visibility 新的可见性状态
388
- * @returns 成功响应
302
+ * Updates plugin visibility
303
+ *
304
+ * @param id - Plugin ID
305
+ * @param visibility - New visibility setting
306
+ * @returns Promise resolving to success response
389
307
  */
390
308
  async updatePluginVisibility(id, visibility) {
391
- log5("Updating plugin visibility: %d to %s", id, visibility);
309
+ log2("Updating plugin visibility: %d to %s", id, visibility);
392
310
  const result = await this.request(
393
311
  `/admin/plugins/${id}/visibility`,
394
312
  {
395
- method: "PATCH",
396
- body: JSON.stringify({ visibility })
313
+ body: JSON.stringify({ visibility }),
314
+ method: "PATCH"
397
315
  }
398
316
  );
399
- log5("Plugin visibility updated successfully");
317
+ log2("Plugin visibility updated successfully");
400
318
  return result;
401
319
  }
402
320
  /**
403
- * 批量更新插件状态
404
- * @param ids 插件 ID 数组
405
- * @param status 新的状态
406
- * @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
407
326
  */
408
327
  async batchUpdatePluginStatus(ids, status) {
409
- log5("Batch updating plugin status: %O to %s", ids, status);
328
+ log2("Batch updating plugin status: %O to %s", ids, status);
410
329
  const result = await this.request(
411
330
  "/admin/plugins/batch/status",
412
331
  {
413
- method: "PATCH",
414
- body: JSON.stringify({ ids, status })
332
+ body: JSON.stringify({ ids, status }),
333
+ method: "PATCH"
415
334
  }
416
335
  );
417
- log5("Batch plugin status update completed");
336
+ log2("Batch plugin status update completed");
418
337
  return result;
419
338
  }
420
339
  /**
421
- * 批量删除插件
422
- * @param ids 插件 ID 数组
423
- * @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
424
344
  */
425
345
  async batchDeletePlugins(ids) {
426
- log5("Batch deleting plugins: %O", ids);
346
+ log2("Batch deleting plugins: %O", ids);
427
347
  const result = await this.request(
428
348
  "/admin/plugins/batch/delete",
429
349
  {
430
- method: "DELETE",
431
- body: JSON.stringify({ ids })
350
+ body: JSON.stringify({ ids }),
351
+ method: "DELETE"
432
352
  }
433
353
  );
434
- log5("Batch plugin deletion completed");
354
+ log2("Batch plugin deletion completed");
435
355
  return result;
436
356
  }
437
357
  /**
438
- * 获取插件版本详情
439
- * @param pluginId 插件 ID
440
- * @param versionId 版本 ID
441
- * @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
442
363
  */
443
364
  async getPluginVersionDetails(pluginId, versionId) {
444
- log5(
365
+ log2(
445
366
  "Getting version details with deployment options: pluginId=%d, versionId=%d",
446
367
  pluginId,
447
368
  versionId
@@ -449,71 +370,75 @@ var PluginService = class extends BaseSDK {
449
370
  const result = await this.request(
450
371
  `/admin/plugins/${pluginId}/versions/${versionId}`
451
372
  );
452
- log5("Version details with deployment options retrieved");
373
+ log2("Version details with deployment options retrieved");
453
374
  return result;
454
375
  }
455
376
  /**
456
- * 更新插件版本信息
457
- * @param pluginId 插件 ID
458
- * @param versionId 版本 ID
459
- * @param data 版本更新数据
460
- * @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
461
383
  */
462
384
  async updatePluginVersionDetails(pluginId, versionId, data) {
463
- log5("Updating version details: pluginId=%d, versionId=%d", pluginId, versionId);
385
+ log2("Updating version details: pluginId=%d, versionId=%d", pluginId, versionId);
464
386
  const result = await this.request(
465
387
  `/admin/plugins/${pluginId}/versions/${versionId}`,
466
388
  {
467
- method: "PUT",
468
- body: JSON.stringify(data)
389
+ body: JSON.stringify(data),
390
+ method: "PUT"
469
391
  }
470
392
  );
471
- log5("Version details updated successfully");
393
+ log2("Version details updated successfully");
472
394
  return result;
473
395
  }
474
396
  /**
475
- * 获取插件版本的部署选项列表
476
- * @param pluginId 插件 ID
477
- * @param versionId 版本 ID
478
- * @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
479
402
  */
480
403
  async getDeploymentOptions(pluginId, versionId) {
481
- log5("Getting deployment options: pluginId=%d, versionId=%d", pluginId, versionId);
404
+ log2("Getting deployment options: pluginId=%d, versionId=%d", pluginId, versionId);
482
405
  const result = await this.request(
483
406
  `/admin/plugins/${pluginId}/versions/${versionId}/deployment-options`
484
407
  );
485
- log5("Retrieved %d deployment options", result.length);
408
+ log2("Retrieved %d deployment options", result.length);
486
409
  return result;
487
410
  }
488
411
  /**
489
- * 创建部署选项
490
- * @param pluginId 插件 ID
491
- * @param versionId 版本 ID
492
- * @param data 部署选项数据
493
- * @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
494
418
  */
495
419
  async createDeploymentOption(pluginId, versionId, data) {
496
- log5("Creating deployment option: pluginId=%d, versionId=%d", pluginId, versionId);
420
+ log2("Creating deployment option: pluginId=%d, versionId=%d", pluginId, versionId);
497
421
  const result = await this.request(
498
422
  `/admin/plugins/${pluginId}/versions/${versionId}/deployment-options`,
499
423
  {
500
- method: "POST",
501
- body: JSON.stringify(data)
424
+ body: JSON.stringify(data),
425
+ method: "POST"
502
426
  }
503
427
  );
504
- log5("Deployment option created successfully");
428
+ log2("Deployment option created successfully");
505
429
  return result;
506
430
  }
507
431
  /**
508
- * 更新部署选项
509
- * @param pluginId 插件 ID
510
- * @param versionId 版本 ID
511
- * @param optionId 部署选项 ID
512
- * @param data 部署选项更新数据
513
- * @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
514
439
  */
515
440
  async updateDeploymentOption(pluginId, versionId, optionId, data) {
516
- log5(
441
+ log2(
517
442
  "Updating deployment option: pluginId=%d, versionId=%d, optionId=%d",
518
443
  pluginId,
519
444
  versionId,
@@ -522,22 +447,23 @@ var PluginService = class extends BaseSDK {
522
447
  const result = await this.request(
523
448
  `/admin/plugins/${pluginId}/versions/${versionId}/deployment-options/${optionId}`,
524
449
  {
525
- method: "PUT",
526
- body: JSON.stringify(data)
450
+ body: JSON.stringify(data),
451
+ method: "PUT"
527
452
  }
528
453
  );
529
- log5("Deployment option updated successfully");
454
+ log2("Deployment option updated successfully");
530
455
  return result;
531
456
  }
532
457
  /**
533
- * 删除部署选项
534
- * @param pluginId 插件 ID
535
- * @param versionId 版本 ID
536
- * @param optionId 部署选项 ID
537
- * @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
538
464
  */
539
465
  async deleteDeploymentOption(pluginId, versionId, optionId) {
540
- log5(
466
+ log2(
541
467
  "Deleting deployment option: pluginId=%d, versionId=%d, optionId=%d",
542
468
  pluginId,
543
469
  versionId,
@@ -547,18 +473,19 @@ var PluginService = class extends BaseSDK {
547
473
  `/admin/plugins/${pluginId}/versions/${versionId}/deployment-options/${optionId}`,
548
474
  { method: "DELETE" }
549
475
  );
550
- log5("Deployment option deleted successfully");
476
+ log2("Deployment option deleted successfully");
551
477
  return result;
552
478
  }
553
479
  /**
554
- * 获取部署选项的系统依赖
555
- * @param pluginId 插件 ID
556
- * @param versionId 版本 ID
557
- * @param optionId 部署选项 ID
558
- * @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
559
486
  */
560
487
  async getDeploymentOptionSystemDependencies(pluginId, versionId, optionId) {
561
- log5(
488
+ log2(
562
489
  "Getting system dependencies: pluginId=%d, versionId=%d, optionId=%d",
563
490
  pluginId,
564
491
  versionId,
@@ -567,233 +494,254 @@ var PluginService = class extends BaseSDK {
567
494
  const result = await this.request(
568
495
  `/admin/plugins/${pluginId}/versions/${versionId}/deployment-options/${optionId}/system-dependencies`
569
496
  );
570
- log5("Retrieved %d system dependencies", result.length);
497
+ log2("Retrieved %d system dependencies", result.length);
571
498
  return result;
572
499
  }
573
500
  };
574
501
 
575
502
  // src/admin/services/SystemDependencyService.ts
576
- import debug6 from "debug";
577
- var log6 = debug6("lobe-market-sdk:admin:dependency");
503
+ import debug3 from "debug";
504
+ var log3 = debug3("lobe-market-sdk:admin:dependency");
578
505
  var SystemDependencyService = class extends BaseSDK {
579
506
  /**
580
- * 创建系统依赖管理服务实例
581
- * @param options SDK 配置选项
582
- * @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
583
511
  */
584
512
  constructor(options = {}, sharedHeaders) {
585
513
  super(options, sharedHeaders);
586
- log6("SystemDependencyService instance created");
514
+ log3("SystemDependencyService instance created");
587
515
  }
588
516
  /**
589
- * 获取所有系统依赖项
590
- * @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
591
522
  */
592
523
  async getSystemDependencies() {
593
- log6("Getting all system dependencies");
524
+ log3("Getting all system dependencies");
594
525
  const result = await this.request(`/admin/plugins/dependencies`);
595
- log6("Retrieved %d system dependencies", result.length);
526
+ log3("Retrieved %d system dependencies", result.length);
596
527
  return result;
597
528
  }
598
529
  /**
599
- * 获取特定系统依赖项
600
- * @param id 依赖项 ID
601
- * @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
602
534
  */
603
535
  async getSystemDependency(id) {
604
- log6("Getting system dependency details: %d", id);
536
+ log3("Getting system dependency details: %d", id);
605
537
  const result = await this.request(`/admin/plugins/dependencies/${id}`);
606
- log6("System dependency details retrieved");
538
+ log3("System dependency details retrieved");
607
539
  return result;
608
540
  }
609
541
  /**
610
- * 创建系统依赖项
611
- * @param data 依赖项创建数据
612
- * @returns 创建的依赖项
542
+ * Creates a new system dependency
543
+ *
544
+ * @param data - System dependency creation data
545
+ * @returns Promise resolving to the created system dependency
613
546
  */
614
547
  async createSystemDependency(data) {
615
- log6("Creating system dependency: %O", data);
548
+ log3("Creating system dependency: %O", data);
616
549
  const result = await this.request(`/admin/plugins/dependencies`, {
617
- method: "POST",
618
- body: JSON.stringify(data)
550
+ body: JSON.stringify(data),
551
+ method: "POST"
619
552
  });
620
- log6("System dependency created successfully");
553
+ log3("System dependency created successfully");
621
554
  return result;
622
555
  }
623
556
  /**
624
- * 更新系统依赖项
625
- * @param id 依赖项 ID
626
- * @param data 依赖项更新数据
627
- * @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
628
562
  */
629
563
  async updateSystemDependency(id, data) {
630
- log6("Updating system dependency: %d, data: %O", id, data);
564
+ log3("Updating system dependency: %d, data: %O", id, data);
631
565
  const result = await this.request(`/admin/plugins/dependencies/${id}`, {
632
- method: "PUT",
633
- body: JSON.stringify(data)
566
+ body: JSON.stringify(data),
567
+ method: "PUT"
634
568
  });
635
- log6("System dependency updated successfully");
569
+ log3("System dependency updated successfully");
636
570
  return result;
637
571
  }
638
572
  /**
639
- * 删除系统依赖项
640
- * @param id 依赖项 ID
641
- * @returns 成功响应
573
+ * Deletes a system dependency
574
+ *
575
+ * @param id - System dependency ID
576
+ * @returns Promise resolving to success response
642
577
  */
643
578
  async deleteSystemDependency(id) {
644
- log6("Deleting system dependency: %d", id);
579
+ log3("Deleting system dependency: %d", id);
645
580
  const result = await this.request(
646
581
  `/admin/plugins/dependencies/${id}`,
647
582
  { method: "DELETE" }
648
583
  );
649
- log6("System dependency deleted successfully");
584
+ log3("System dependency deleted successfully");
650
585
  return result;
651
586
  }
652
587
  };
653
588
 
654
589
  // src/admin/services/SettingsService.ts
655
- import debug7 from "debug";
656
- var log7 = debug7("lobe-market-sdk:admin:settings");
590
+ import debug4 from "debug";
591
+ var log4 = debug4("lobe-market-sdk:admin:settings");
657
592
  var SettingsService = class extends BaseSDK {
658
593
  /**
659
- * 获取设置列表
660
- * @param params 查询参数
661
- * @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
662
600
  */
663
601
  async getSettings() {
664
602
  return await this.request("/admin/settings");
665
603
  }
666
604
  /**
667
- * 获取单个设置
668
- * @param key 设置键名
669
- * @returns 设置详情
605
+ * Retrieves a specific setting by key
606
+ *
607
+ * @param key - Setting key name
608
+ * @returns Promise resolving to the setting details
670
609
  */
671
610
  async getSettingByKey(key) {
672
- log7("Getting setting: %s", key);
611
+ log4("Getting setting: %s", key);
673
612
  const result = await this.request(`/admin/settings/${key}`);
674
- log7("Setting retrieved");
613
+ log4("Setting retrieved");
675
614
  return result;
676
615
  }
677
616
  /**
678
- * 创建设置
679
- * @param data 设置数据
680
- * @returns 创建的设置
617
+ * Creates a new system setting
618
+ *
619
+ * @param data - Setting creation parameters
620
+ * @returns Promise resolving to the created setting
681
621
  */
682
622
  async createSetting(data) {
683
- log7("Creating setting: %O", data);
623
+ log4("Creating setting: %O", data);
684
624
  const result = await this.request("/admin/settings", {
685
- method: "POST",
686
- body: JSON.stringify(data)
625
+ body: JSON.stringify(data),
626
+ method: "POST"
687
627
  });
688
- log7("Setting created successfully");
628
+ log4("Setting created successfully");
689
629
  return result;
690
630
  }
691
631
  /**
692
- * 更新设置
693
- * @param key 设置键名
694
- * @param data 更新数据
695
- * @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
696
637
  */
697
638
  async updateSetting(key, data) {
698
- log7("Updating setting: %s, data: %O", key, data);
639
+ log4("Updating setting: %s, data: %O", key, data);
699
640
  const result = await this.request(`/admin/settings/${key}`, {
700
- method: "PUT",
701
- body: JSON.stringify(data)
641
+ body: JSON.stringify(data),
642
+ method: "PUT"
702
643
  });
703
- log7("Setting updated successfully");
644
+ log4("Setting updated successfully");
704
645
  return result;
705
646
  }
706
647
  /**
707
- * 删除设置
708
- * @param key 设置键名
709
- * @returns 删除结果
648
+ * Deletes a setting
649
+ *
650
+ * @param key - Setting key name
651
+ * @returns Promise resolving to success message
710
652
  */
711
653
  async deleteSetting(key) {
712
- log7("Deleting setting: %s", key);
654
+ log4("Deleting setting: %s", key);
713
655
  const result = await this.request(`/admin/settings/${key}`, {
714
656
  method: "DELETE"
715
657
  });
716
- log7("Setting deleted successfully");
658
+ log4("Setting deleted successfully");
717
659
  return result;
718
660
  }
719
661
  };
720
662
 
721
663
  // src/admin/services/ReviewService.ts
722
- import debug8 from "debug";
723
- var log8 = debug8("lobe-market-sdk:admin:review");
664
+ import debug5 from "debug";
665
+ var log5 = debug5("lobe-market-sdk:admin:review");
724
666
  var ReviewService = class extends BaseSDK {
725
667
  /**
726
- * 创建审核管理服务实例
727
- * @param options SDK 配置选项
728
- * @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
729
672
  */
730
673
  constructor(options = {}, sharedHeaders) {
731
674
  super(options, sharedHeaders);
732
- log8("ReviewService instance created");
675
+ log5("ReviewService instance created");
733
676
  }
734
677
  /**
735
- * 获取审核列表
736
- * @param params 查询参数
737
- * @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
738
682
  */
739
683
  async getReviews(params = {}) {
740
- log8("Getting reviews with params: %O", params);
684
+ log5("Getting reviews with params: %O", params);
741
685
  const queryString = this.buildQueryString(params);
742
686
  const url = `/admin/reviews${queryString ? `?${queryString}` : ""}`;
743
687
  const result = await this.request(url);
744
- log8("Retrieved %d reviews", result.data.length);
688
+ log5("Retrieved %d reviews", result.data.length);
745
689
  return result;
746
690
  }
747
691
  /**
748
- * 获取审核详情
749
- * @param id 审核 ID
750
- * @returns 审核详情
692
+ * Retrieves a specific review by ID
693
+ *
694
+ * @param id - Review ID
695
+ * @returns Promise resolving to the review details
751
696
  */
752
697
  async getReviewById(id) {
753
- log8("Getting review details: %d", id);
698
+ log5("Getting review details: %d", id);
754
699
  const result = await this.request(`/admin/reviews/${id}`);
755
- log8("Review details retrieved");
700
+ log5("Review details retrieved");
756
701
  return result;
757
702
  }
758
703
  /**
759
- * 更新审核状态
760
- * @param id 审核 ID
761
- * @param data 更新数据
762
- * @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
763
709
  */
764
710
  async updateReview(id, data) {
765
- log8("Updating review: %d, data: %O", id, data);
711
+ log5("Updating review: %d, data: %O", id, data);
766
712
  const result = await this.request(`/admin/reviews/${id}`, {
767
- method: "PUT",
768
- body: JSON.stringify(data)
713
+ body: JSON.stringify(data),
714
+ method: "PUT"
769
715
  });
770
- log8("Review updated successfully");
716
+ log5("Review updated successfully");
771
717
  return result;
772
718
  }
773
719
  /**
774
- * 获取插件的审核历史
775
- * @param pluginId 插件 ID
776
- * @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
777
724
  */
778
725
  async getPluginReviews(pluginId) {
779
- log8("Getting plugin reviews: pluginId=%d", pluginId);
726
+ log5("Getting plugin reviews: pluginId=%d", pluginId);
780
727
  const result = await this.request(`/admin/reviews/plugin/${pluginId}`);
781
- log8("Retrieved %d reviews for plugin", result.data.length);
728
+ log5("Retrieved %d reviews for plugin", result.data.length);
782
729
  return result;
783
730
  }
784
731
  };
785
732
 
786
733
  // src/admin/MarketAdmin.ts
787
- var log9 = debug9("lobe-market-sdk:admin");
734
+ var log6 = debug6("lobe-market-sdk:admin");
788
735
  var MarketAdmin = class extends BaseSDK {
789
736
  /**
790
- * 创建 MarketAdmin 实例
791
- * @param options SDK 配置选项
737
+ * Creates a new MarketAdmin instance
738
+ *
739
+ * @param options - Configuration options for the SDK
792
740
  */
793
741
  constructor(options = {}) {
794
742
  const apiKey = options.apiKey || process.env.MARKET_ADMIN_API_KEY;
795
743
  super({ ...options, apiKey });
796
- log9("MarketAdmin instance created");
744
+ log6("MarketAdmin instance created");
797
745
  this.plugins = new PluginService(options, this.headers);
798
746
  this.reviews = new ReviewService(options, this.headers);
799
747
  this.settings = new SettingsService(options, this.headers);
@@ -801,6 +749,143 @@ var MarketAdmin = class extends BaseSDK {
801
749
  }
802
750
  };
803
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
+
804
889
  // src/types/admin.ts
805
890
  import { z } from "zod";
806
891
  var VisibilityEnumSchema = z.enum(["public", "private", "internal"]);