@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/README.md +210 -112
- package/dist/index.d.mts +689 -385
- package/dist/index.mjs +468 -383
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -5
package/dist/index.mjs
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
// src/
|
|
2
|
-
import
|
|
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
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* @param
|
|
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
|
-
*
|
|
35
|
-
* @param
|
|
36
|
-
* @
|
|
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
|
-
*
|
|
58
|
-
* @
|
|
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
|
-
*
|
|
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
|
|
187
|
-
var
|
|
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
|
-
*
|
|
192
|
-
* @param
|
|
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
|
-
|
|
99
|
+
log2("PluginService instance created");
|
|
197
100
|
}
|
|
198
101
|
/**
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
*
|
|
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
|
-
|
|
111
|
+
log2(`Starting batch import of ${manifests.length} manifests`);
|
|
206
112
|
if (ownerId) {
|
|
207
|
-
|
|
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
|
-
|
|
125
|
+
log2(`Batch import completed: ${response.success} succeeded, ${response.failed} failed`);
|
|
220
126
|
return response;
|
|
221
127
|
}
|
|
222
128
|
/**
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
*
|
|
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
|
-
|
|
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
|
-
|
|
141
|
+
log2("Retrieved %d plugins", result.data.length);
|
|
233
142
|
return result;
|
|
234
143
|
}
|
|
235
144
|
/**
|
|
236
|
-
*
|
|
237
|
-
*
|
|
238
|
-
* @
|
|
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
|
-
|
|
242
|
-
const result = await this.request(
|
|
243
|
-
|
|
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
|
-
*
|
|
251
|
-
* @param
|
|
252
|
-
* @
|
|
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
|
-
|
|
164
|
+
log2("Updating plugin: %d, data: %O", id, data);
|
|
256
165
|
const result = await this.request(`/admin/plugins/${id}`, {
|
|
257
|
-
|
|
258
|
-
|
|
166
|
+
body: JSON.stringify(data),
|
|
167
|
+
method: "PUT"
|
|
259
168
|
});
|
|
260
|
-
|
|
169
|
+
log2("Plugin updated successfully");
|
|
261
170
|
return result;
|
|
262
171
|
}
|
|
263
172
|
/**
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
* @param
|
|
267
|
-
* @
|
|
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
|
-
|
|
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
|
-
|
|
275
|
-
|
|
184
|
+
body: JSON.stringify({ status }),
|
|
185
|
+
method: "PATCH"
|
|
276
186
|
}
|
|
277
187
|
);
|
|
278
|
-
|
|
188
|
+
log2("Plugin status updated successfully");
|
|
279
189
|
return result;
|
|
280
190
|
}
|
|
281
191
|
/**
|
|
282
|
-
*
|
|
283
|
-
*
|
|
284
|
-
* @
|
|
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
|
-
|
|
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
|
-
|
|
203
|
+
log2("Plugin deleted successfully");
|
|
293
204
|
return result;
|
|
294
205
|
}
|
|
295
206
|
/**
|
|
296
|
-
*
|
|
297
|
-
*
|
|
298
|
-
* @
|
|
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
|
-
|
|
213
|
+
log2("Getting plugin versions: pluginId=%d", pluginId);
|
|
302
214
|
const result = await this.request(`/admin/plugins/${pluginId}/versions`);
|
|
303
|
-
|
|
215
|
+
log2("Retrieved %d versions", result.length);
|
|
304
216
|
return result;
|
|
305
217
|
}
|
|
306
218
|
/**
|
|
307
|
-
*
|
|
308
|
-
*
|
|
309
|
-
* @param
|
|
310
|
-
* @
|
|
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
|
-
|
|
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
|
-
|
|
230
|
+
log2("Version details retrieved");
|
|
318
231
|
return result;
|
|
319
232
|
}
|
|
320
233
|
/**
|
|
321
|
-
*
|
|
322
|
-
*
|
|
323
|
-
* @param
|
|
324
|
-
* @
|
|
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
|
-
|
|
241
|
+
log2("Creating new version: pluginId=%d", pluginId);
|
|
328
242
|
const result = await this.request(`/admin/plugins/${pluginId}/versions`, {
|
|
329
|
-
|
|
330
|
-
|
|
243
|
+
body: JSON.stringify(data),
|
|
244
|
+
method: "POST"
|
|
331
245
|
});
|
|
332
|
-
|
|
246
|
+
log2("Plugin version created successfully");
|
|
333
247
|
return result;
|
|
334
248
|
}
|
|
335
249
|
/**
|
|
336
|
-
*
|
|
337
|
-
*
|
|
338
|
-
* @param
|
|
339
|
-
* @param
|
|
340
|
-
* @
|
|
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
|
-
|
|
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
|
-
|
|
348
|
-
|
|
262
|
+
body: JSON.stringify(data),
|
|
263
|
+
method: "PUT"
|
|
349
264
|
}
|
|
350
265
|
);
|
|
351
|
-
|
|
266
|
+
log2("Plugin version updated successfully");
|
|
352
267
|
return result;
|
|
353
268
|
}
|
|
354
269
|
/**
|
|
355
|
-
*
|
|
356
|
-
*
|
|
357
|
-
* @param
|
|
358
|
-
* @
|
|
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
|
-
|
|
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
|
-
|
|
282
|
+
log2("Plugin version deleted successfully");
|
|
367
283
|
return result;
|
|
368
284
|
}
|
|
369
285
|
/**
|
|
370
|
-
*
|
|
371
|
-
*
|
|
372
|
-
* @param
|
|
373
|
-
* @
|
|
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
|
-
|
|
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
|
-
|
|
298
|
+
log2("Version set as latest");
|
|
382
299
|
return result;
|
|
383
300
|
}
|
|
384
301
|
/**
|
|
385
|
-
*
|
|
386
|
-
*
|
|
387
|
-
* @param
|
|
388
|
-
* @
|
|
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
|
-
|
|
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
|
-
|
|
396
|
-
|
|
313
|
+
body: JSON.stringify({ visibility }),
|
|
314
|
+
method: "PATCH"
|
|
397
315
|
}
|
|
398
316
|
);
|
|
399
|
-
|
|
317
|
+
log2("Plugin visibility updated successfully");
|
|
400
318
|
return result;
|
|
401
319
|
}
|
|
402
320
|
/**
|
|
403
|
-
*
|
|
404
|
-
*
|
|
405
|
-
* @param
|
|
406
|
-
* @
|
|
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
|
-
|
|
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
|
-
|
|
414
|
-
|
|
332
|
+
body: JSON.stringify({ ids, status }),
|
|
333
|
+
method: "PATCH"
|
|
415
334
|
}
|
|
416
335
|
);
|
|
417
|
-
|
|
336
|
+
log2("Batch plugin status update completed");
|
|
418
337
|
return result;
|
|
419
338
|
}
|
|
420
339
|
/**
|
|
421
|
-
*
|
|
422
|
-
*
|
|
423
|
-
* @
|
|
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
|
-
|
|
346
|
+
log2("Batch deleting plugins: %O", ids);
|
|
427
347
|
const result = await this.request(
|
|
428
348
|
"/admin/plugins/batch/delete",
|
|
429
349
|
{
|
|
430
|
-
|
|
431
|
-
|
|
350
|
+
body: JSON.stringify({ ids }),
|
|
351
|
+
method: "DELETE"
|
|
432
352
|
}
|
|
433
353
|
);
|
|
434
|
-
|
|
354
|
+
log2("Batch plugin deletion completed");
|
|
435
355
|
return result;
|
|
436
356
|
}
|
|
437
357
|
/**
|
|
438
|
-
*
|
|
439
|
-
*
|
|
440
|
-
* @param
|
|
441
|
-
* @
|
|
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
|
-
|
|
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
|
-
|
|
373
|
+
log2("Version details with deployment options retrieved");
|
|
453
374
|
return result;
|
|
454
375
|
}
|
|
455
376
|
/**
|
|
456
|
-
*
|
|
457
|
-
*
|
|
458
|
-
* @param
|
|
459
|
-
* @param
|
|
460
|
-
* @
|
|
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
|
-
|
|
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
|
-
|
|
468
|
-
|
|
389
|
+
body: JSON.stringify(data),
|
|
390
|
+
method: "PUT"
|
|
469
391
|
}
|
|
470
392
|
);
|
|
471
|
-
|
|
393
|
+
log2("Version details updated successfully");
|
|
472
394
|
return result;
|
|
473
395
|
}
|
|
474
396
|
/**
|
|
475
|
-
*
|
|
476
|
-
*
|
|
477
|
-
* @param
|
|
478
|
-
* @
|
|
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
|
-
|
|
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
|
-
|
|
408
|
+
log2("Retrieved %d deployment options", result.length);
|
|
486
409
|
return result;
|
|
487
410
|
}
|
|
488
411
|
/**
|
|
489
|
-
*
|
|
490
|
-
*
|
|
491
|
-
* @param
|
|
492
|
-
* @param
|
|
493
|
-
* @
|
|
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
|
-
|
|
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
|
-
|
|
501
|
-
|
|
424
|
+
body: JSON.stringify(data),
|
|
425
|
+
method: "POST"
|
|
502
426
|
}
|
|
503
427
|
);
|
|
504
|
-
|
|
428
|
+
log2("Deployment option created successfully");
|
|
505
429
|
return result;
|
|
506
430
|
}
|
|
507
431
|
/**
|
|
508
|
-
*
|
|
509
|
-
*
|
|
510
|
-
* @param
|
|
511
|
-
* @param
|
|
512
|
-
* @param
|
|
513
|
-
* @
|
|
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
|
-
|
|
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
|
-
|
|
526
|
-
|
|
450
|
+
body: JSON.stringify(data),
|
|
451
|
+
method: "PUT"
|
|
527
452
|
}
|
|
528
453
|
);
|
|
529
|
-
|
|
454
|
+
log2("Deployment option updated successfully");
|
|
530
455
|
return result;
|
|
531
456
|
}
|
|
532
457
|
/**
|
|
533
|
-
*
|
|
534
|
-
*
|
|
535
|
-
* @param
|
|
536
|
-
* @param
|
|
537
|
-
* @
|
|
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
|
-
|
|
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
|
-
|
|
476
|
+
log2("Deployment option deleted successfully");
|
|
551
477
|
return result;
|
|
552
478
|
}
|
|
553
479
|
/**
|
|
554
|
-
*
|
|
555
|
-
*
|
|
556
|
-
* @param
|
|
557
|
-
* @param
|
|
558
|
-
* @
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
577
|
-
var
|
|
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
|
-
*
|
|
582
|
-
* @param
|
|
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
|
-
|
|
514
|
+
log3("SystemDependencyService instance created");
|
|
587
515
|
}
|
|
588
516
|
/**
|
|
589
|
-
*
|
|
590
|
-
*
|
|
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
|
-
|
|
524
|
+
log3("Getting all system dependencies");
|
|
594
525
|
const result = await this.request(`/admin/plugins/dependencies`);
|
|
595
|
-
|
|
526
|
+
log3("Retrieved %d system dependencies", result.length);
|
|
596
527
|
return result;
|
|
597
528
|
}
|
|
598
529
|
/**
|
|
599
|
-
*
|
|
600
|
-
*
|
|
601
|
-
* @
|
|
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
|
-
|
|
536
|
+
log3("Getting system dependency details: %d", id);
|
|
605
537
|
const result = await this.request(`/admin/plugins/dependencies/${id}`);
|
|
606
|
-
|
|
538
|
+
log3("System dependency details retrieved");
|
|
607
539
|
return result;
|
|
608
540
|
}
|
|
609
541
|
/**
|
|
610
|
-
*
|
|
611
|
-
*
|
|
612
|
-
* @
|
|
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
|
-
|
|
548
|
+
log3("Creating system dependency: %O", data);
|
|
616
549
|
const result = await this.request(`/admin/plugins/dependencies`, {
|
|
617
|
-
|
|
618
|
-
|
|
550
|
+
body: JSON.stringify(data),
|
|
551
|
+
method: "POST"
|
|
619
552
|
});
|
|
620
|
-
|
|
553
|
+
log3("System dependency created successfully");
|
|
621
554
|
return result;
|
|
622
555
|
}
|
|
623
556
|
/**
|
|
624
|
-
*
|
|
625
|
-
*
|
|
626
|
-
* @param
|
|
627
|
-
* @
|
|
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
|
-
|
|
564
|
+
log3("Updating system dependency: %d, data: %O", id, data);
|
|
631
565
|
const result = await this.request(`/admin/plugins/dependencies/${id}`, {
|
|
632
|
-
|
|
633
|
-
|
|
566
|
+
body: JSON.stringify(data),
|
|
567
|
+
method: "PUT"
|
|
634
568
|
});
|
|
635
|
-
|
|
569
|
+
log3("System dependency updated successfully");
|
|
636
570
|
return result;
|
|
637
571
|
}
|
|
638
572
|
/**
|
|
639
|
-
*
|
|
640
|
-
*
|
|
641
|
-
* @
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
656
|
-
var
|
|
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
|
-
*
|
|
661
|
-
*
|
|
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
|
-
*
|
|
669
|
-
* @
|
|
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
|
-
|
|
611
|
+
log4("Getting setting: %s", key);
|
|
673
612
|
const result = await this.request(`/admin/settings/${key}`);
|
|
674
|
-
|
|
613
|
+
log4("Setting retrieved");
|
|
675
614
|
return result;
|
|
676
615
|
}
|
|
677
616
|
/**
|
|
678
|
-
*
|
|
679
|
-
*
|
|
680
|
-
* @
|
|
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
|
-
|
|
623
|
+
log4("Creating setting: %O", data);
|
|
684
624
|
const result = await this.request("/admin/settings", {
|
|
685
|
-
|
|
686
|
-
|
|
625
|
+
body: JSON.stringify(data),
|
|
626
|
+
method: "POST"
|
|
687
627
|
});
|
|
688
|
-
|
|
628
|
+
log4("Setting created successfully");
|
|
689
629
|
return result;
|
|
690
630
|
}
|
|
691
631
|
/**
|
|
692
|
-
*
|
|
693
|
-
*
|
|
694
|
-
* @param
|
|
695
|
-
* @
|
|
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
|
-
|
|
639
|
+
log4("Updating setting: %s, data: %O", key, data);
|
|
699
640
|
const result = await this.request(`/admin/settings/${key}`, {
|
|
700
|
-
|
|
701
|
-
|
|
641
|
+
body: JSON.stringify(data),
|
|
642
|
+
method: "PUT"
|
|
702
643
|
});
|
|
703
|
-
|
|
644
|
+
log4("Setting updated successfully");
|
|
704
645
|
return result;
|
|
705
646
|
}
|
|
706
647
|
/**
|
|
707
|
-
*
|
|
708
|
-
*
|
|
709
|
-
* @
|
|
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
|
-
|
|
654
|
+
log4("Deleting setting: %s", key);
|
|
713
655
|
const result = await this.request(`/admin/settings/${key}`, {
|
|
714
656
|
method: "DELETE"
|
|
715
657
|
});
|
|
716
|
-
|
|
658
|
+
log4("Setting deleted successfully");
|
|
717
659
|
return result;
|
|
718
660
|
}
|
|
719
661
|
};
|
|
720
662
|
|
|
721
663
|
// src/admin/services/ReviewService.ts
|
|
722
|
-
import
|
|
723
|
-
var
|
|
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
|
-
*
|
|
728
|
-
* @param
|
|
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
|
-
|
|
675
|
+
log5("ReviewService instance created");
|
|
733
676
|
}
|
|
734
677
|
/**
|
|
735
|
-
*
|
|
736
|
-
*
|
|
737
|
-
* @
|
|
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
|
-
|
|
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
|
-
|
|
688
|
+
log5("Retrieved %d reviews", result.data.length);
|
|
745
689
|
return result;
|
|
746
690
|
}
|
|
747
691
|
/**
|
|
748
|
-
*
|
|
749
|
-
*
|
|
750
|
-
* @
|
|
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
|
-
|
|
698
|
+
log5("Getting review details: %d", id);
|
|
754
699
|
const result = await this.request(`/admin/reviews/${id}`);
|
|
755
|
-
|
|
700
|
+
log5("Review details retrieved");
|
|
756
701
|
return result;
|
|
757
702
|
}
|
|
758
703
|
/**
|
|
759
|
-
*
|
|
760
|
-
*
|
|
761
|
-
* @param
|
|
762
|
-
* @
|
|
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
|
-
|
|
711
|
+
log5("Updating review: %d, data: %O", id, data);
|
|
766
712
|
const result = await this.request(`/admin/reviews/${id}`, {
|
|
767
|
-
|
|
768
|
-
|
|
713
|
+
body: JSON.stringify(data),
|
|
714
|
+
method: "PUT"
|
|
769
715
|
});
|
|
770
|
-
|
|
716
|
+
log5("Review updated successfully");
|
|
771
717
|
return result;
|
|
772
718
|
}
|
|
773
719
|
/**
|
|
774
|
-
*
|
|
775
|
-
*
|
|
776
|
-
* @
|
|
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
|
-
|
|
726
|
+
log5("Getting plugin reviews: pluginId=%d", pluginId);
|
|
780
727
|
const result = await this.request(`/admin/reviews/plugin/${pluginId}`);
|
|
781
|
-
|
|
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
|
|
734
|
+
var log6 = debug6("lobe-market-sdk:admin");
|
|
788
735
|
var MarketAdmin = class extends BaseSDK {
|
|
789
736
|
/**
|
|
790
|
-
*
|
|
791
|
-
*
|
|
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
|
-
|
|
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"]);
|