@lobehub/market-sdk 0.0.28 → 0.0.30
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 +690 -366
- package/dist/index.mjs +467 -380
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -29
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,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
|
|
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
|
-
|
|
151
|
+
log2("Getting plugin details (admin): %d", id);
|
|
242
152
|
const result = await this.request(`/admin/plugins/${id}`);
|
|
243
|
-
|
|
153
|
+
log2("Retrieved plugin with %d versions", result.versions.length);
|
|
244
154
|
return result;
|
|
245
155
|
}
|
|
246
156
|
/**
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
* @param
|
|
250
|
-
* @
|
|
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
|
-
|
|
164
|
+
log2("Updating plugin: %d, data: %O", id, data);
|
|
254
165
|
const result = await this.request(`/admin/plugins/${id}`, {
|
|
255
|
-
|
|
256
|
-
|
|
166
|
+
body: JSON.stringify(data),
|
|
167
|
+
method: "PUT"
|
|
257
168
|
});
|
|
258
|
-
|
|
169
|
+
log2("Plugin updated successfully");
|
|
259
170
|
return result;
|
|
260
171
|
}
|
|
261
172
|
/**
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
* @param
|
|
265
|
-
* @
|
|
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
|
-
|
|
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
|
-
|
|
273
|
-
|
|
184
|
+
body: JSON.stringify({ status }),
|
|
185
|
+
method: "PATCH"
|
|
274
186
|
}
|
|
275
187
|
);
|
|
276
|
-
|
|
188
|
+
log2("Plugin status updated successfully");
|
|
277
189
|
return result;
|
|
278
190
|
}
|
|
279
191
|
/**
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
* @
|
|
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
|
-
|
|
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
|
-
|
|
203
|
+
log2("Plugin deleted successfully");
|
|
291
204
|
return result;
|
|
292
205
|
}
|
|
293
206
|
/**
|
|
294
|
-
*
|
|
295
|
-
*
|
|
296
|
-
* @
|
|
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
|
-
|
|
213
|
+
log2("Getting plugin versions: pluginId=%d", pluginId);
|
|
300
214
|
const result = await this.request(`/admin/plugins/${pluginId}/versions`);
|
|
301
|
-
|
|
215
|
+
log2("Retrieved %d versions", result.length);
|
|
302
216
|
return result;
|
|
303
217
|
}
|
|
304
218
|
/**
|
|
305
|
-
*
|
|
306
|
-
*
|
|
307
|
-
* @param
|
|
308
|
-
* @
|
|
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
|
-
|
|
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
|
-
|
|
230
|
+
log2("Version details retrieved");
|
|
316
231
|
return result;
|
|
317
232
|
}
|
|
318
233
|
/**
|
|
319
|
-
*
|
|
320
|
-
*
|
|
321
|
-
* @param
|
|
322
|
-
* @
|
|
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
|
-
|
|
241
|
+
log2("Creating new version: pluginId=%d", pluginId);
|
|
326
242
|
const result = await this.request(`/admin/plugins/${pluginId}/versions`, {
|
|
327
|
-
|
|
328
|
-
|
|
243
|
+
body: JSON.stringify(data),
|
|
244
|
+
method: "POST"
|
|
329
245
|
});
|
|
330
|
-
|
|
246
|
+
log2("Plugin version created successfully");
|
|
331
247
|
return result;
|
|
332
248
|
}
|
|
333
249
|
/**
|
|
334
|
-
*
|
|
335
|
-
*
|
|
336
|
-
* @param
|
|
337
|
-
* @param
|
|
338
|
-
* @
|
|
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
|
-
|
|
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
|
-
|
|
346
|
-
|
|
262
|
+
body: JSON.stringify(data),
|
|
263
|
+
method: "PUT"
|
|
347
264
|
}
|
|
348
265
|
);
|
|
349
|
-
|
|
266
|
+
log2("Plugin version updated successfully");
|
|
350
267
|
return result;
|
|
351
268
|
}
|
|
352
269
|
/**
|
|
353
|
-
*
|
|
354
|
-
*
|
|
355
|
-
* @param
|
|
356
|
-
* @
|
|
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
|
-
|
|
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
|
-
|
|
282
|
+
log2("Plugin version deleted successfully");
|
|
365
283
|
return result;
|
|
366
284
|
}
|
|
367
285
|
/**
|
|
368
|
-
*
|
|
369
|
-
*
|
|
370
|
-
* @param
|
|
371
|
-
* @
|
|
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
|
-
|
|
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
|
-
|
|
298
|
+
log2("Version set as latest");
|
|
380
299
|
return result;
|
|
381
300
|
}
|
|
382
301
|
/**
|
|
383
|
-
*
|
|
384
|
-
*
|
|
385
|
-
* @param
|
|
386
|
-
* @
|
|
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
|
-
|
|
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
|
-
|
|
394
|
-
|
|
313
|
+
body: JSON.stringify({ visibility }),
|
|
314
|
+
method: "PATCH"
|
|
395
315
|
}
|
|
396
316
|
);
|
|
397
|
-
|
|
317
|
+
log2("Plugin visibility updated successfully");
|
|
398
318
|
return result;
|
|
399
319
|
}
|
|
400
320
|
/**
|
|
401
|
-
*
|
|
402
|
-
*
|
|
403
|
-
* @param
|
|
404
|
-
* @
|
|
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
|
-
|
|
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
|
-
|
|
412
|
-
|
|
332
|
+
body: JSON.stringify({ ids, status }),
|
|
333
|
+
method: "PATCH"
|
|
413
334
|
}
|
|
414
335
|
);
|
|
415
|
-
|
|
336
|
+
log2("Batch plugin status update completed");
|
|
416
337
|
return result;
|
|
417
338
|
}
|
|
418
339
|
/**
|
|
419
|
-
*
|
|
420
|
-
*
|
|
421
|
-
* @
|
|
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
|
-
|
|
346
|
+
log2("Batch deleting plugins: %O", ids);
|
|
425
347
|
const result = await this.request(
|
|
426
348
|
"/admin/plugins/batch/delete",
|
|
427
349
|
{
|
|
428
|
-
|
|
429
|
-
|
|
350
|
+
body: JSON.stringify({ ids }),
|
|
351
|
+
method: "DELETE"
|
|
430
352
|
}
|
|
431
353
|
);
|
|
432
|
-
|
|
354
|
+
log2("Batch plugin deletion completed");
|
|
433
355
|
return result;
|
|
434
356
|
}
|
|
435
357
|
/**
|
|
436
|
-
*
|
|
437
|
-
*
|
|
438
|
-
* @param
|
|
439
|
-
* @
|
|
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
|
-
|
|
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
|
-
|
|
373
|
+
log2("Version details with deployment options retrieved");
|
|
451
374
|
return result;
|
|
452
375
|
}
|
|
453
376
|
/**
|
|
454
|
-
*
|
|
455
|
-
*
|
|
456
|
-
* @param
|
|
457
|
-
* @param
|
|
458
|
-
* @
|
|
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
|
-
|
|
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
|
-
|
|
466
|
-
|
|
389
|
+
body: JSON.stringify(data),
|
|
390
|
+
method: "PUT"
|
|
467
391
|
}
|
|
468
392
|
);
|
|
469
|
-
|
|
393
|
+
log2("Version details updated successfully");
|
|
470
394
|
return result;
|
|
471
395
|
}
|
|
472
396
|
/**
|
|
473
|
-
*
|
|
474
|
-
*
|
|
475
|
-
* @param
|
|
476
|
-
* @
|
|
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
|
-
|
|
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
|
-
|
|
408
|
+
log2("Retrieved %d deployment options", result.length);
|
|
484
409
|
return result;
|
|
485
410
|
}
|
|
486
411
|
/**
|
|
487
|
-
*
|
|
488
|
-
*
|
|
489
|
-
* @param
|
|
490
|
-
* @param
|
|
491
|
-
* @
|
|
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
|
-
|
|
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
|
-
|
|
499
|
-
|
|
424
|
+
body: JSON.stringify(data),
|
|
425
|
+
method: "POST"
|
|
500
426
|
}
|
|
501
427
|
);
|
|
502
|
-
|
|
428
|
+
log2("Deployment option created successfully");
|
|
503
429
|
return result;
|
|
504
430
|
}
|
|
505
431
|
/**
|
|
506
|
-
*
|
|
507
|
-
*
|
|
508
|
-
* @param
|
|
509
|
-
* @param
|
|
510
|
-
* @param
|
|
511
|
-
* @
|
|
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
|
-
|
|
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
|
-
|
|
524
|
-
|
|
450
|
+
body: JSON.stringify(data),
|
|
451
|
+
method: "PUT"
|
|
525
452
|
}
|
|
526
453
|
);
|
|
527
|
-
|
|
454
|
+
log2("Deployment option updated successfully");
|
|
528
455
|
return result;
|
|
529
456
|
}
|
|
530
457
|
/**
|
|
531
|
-
*
|
|
532
|
-
*
|
|
533
|
-
* @param
|
|
534
|
-
* @param
|
|
535
|
-
* @
|
|
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
|
-
|
|
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
|
-
|
|
476
|
+
log2("Deployment option deleted successfully");
|
|
549
477
|
return result;
|
|
550
478
|
}
|
|
551
479
|
/**
|
|
552
|
-
*
|
|
553
|
-
*
|
|
554
|
-
* @param
|
|
555
|
-
* @param
|
|
556
|
-
* @
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
575
|
-
var
|
|
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
|
-
*
|
|
580
|
-
* @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
|
|
581
511
|
*/
|
|
582
512
|
constructor(options = {}, sharedHeaders) {
|
|
583
513
|
super(options, sharedHeaders);
|
|
584
|
-
|
|
514
|
+
log3("SystemDependencyService instance created");
|
|
585
515
|
}
|
|
586
516
|
/**
|
|
587
|
-
*
|
|
588
|
-
*
|
|
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
|
-
|
|
524
|
+
log3("Getting all system dependencies");
|
|
592
525
|
const result = await this.request(`/admin/plugins/dependencies`);
|
|
593
|
-
|
|
526
|
+
log3("Retrieved %d system dependencies", result.length);
|
|
594
527
|
return result;
|
|
595
528
|
}
|
|
596
529
|
/**
|
|
597
|
-
*
|
|
598
|
-
*
|
|
599
|
-
* @
|
|
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
|
-
|
|
536
|
+
log3("Getting system dependency details: %d", id);
|
|
603
537
|
const result = await this.request(`/admin/plugins/dependencies/${id}`);
|
|
604
|
-
|
|
538
|
+
log3("System dependency details retrieved");
|
|
605
539
|
return result;
|
|
606
540
|
}
|
|
607
541
|
/**
|
|
608
|
-
*
|
|
609
|
-
*
|
|
610
|
-
* @
|
|
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
|
-
|
|
548
|
+
log3("Creating system dependency: %O", data);
|
|
614
549
|
const result = await this.request(`/admin/plugins/dependencies`, {
|
|
615
|
-
|
|
616
|
-
|
|
550
|
+
body: JSON.stringify(data),
|
|
551
|
+
method: "POST"
|
|
617
552
|
});
|
|
618
|
-
|
|
553
|
+
log3("System dependency created successfully");
|
|
619
554
|
return result;
|
|
620
555
|
}
|
|
621
556
|
/**
|
|
622
|
-
*
|
|
623
|
-
*
|
|
624
|
-
* @param
|
|
625
|
-
* @
|
|
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
|
-
|
|
564
|
+
log3("Updating system dependency: %d, data: %O", id, data);
|
|
629
565
|
const result = await this.request(`/admin/plugins/dependencies/${id}`, {
|
|
630
|
-
|
|
631
|
-
|
|
566
|
+
body: JSON.stringify(data),
|
|
567
|
+
method: "PUT"
|
|
632
568
|
});
|
|
633
|
-
|
|
569
|
+
log3("System dependency updated successfully");
|
|
634
570
|
return result;
|
|
635
571
|
}
|
|
636
572
|
/**
|
|
637
|
-
*
|
|
638
|
-
*
|
|
639
|
-
* @
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
654
|
-
var
|
|
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
|
-
*
|
|
659
|
-
*
|
|
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
|
-
*
|
|
667
|
-
* @
|
|
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
|
-
|
|
611
|
+
log4("Getting setting: %s", key);
|
|
671
612
|
const result = await this.request(`/admin/settings/${key}`);
|
|
672
|
-
|
|
613
|
+
log4("Setting retrieved");
|
|
673
614
|
return result;
|
|
674
615
|
}
|
|
675
616
|
/**
|
|
676
|
-
*
|
|
677
|
-
*
|
|
678
|
-
* @
|
|
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
|
-
|
|
623
|
+
log4("Creating setting: %O", data);
|
|
682
624
|
const result = await this.request("/admin/settings", {
|
|
683
|
-
|
|
684
|
-
|
|
625
|
+
body: JSON.stringify(data),
|
|
626
|
+
method: "POST"
|
|
685
627
|
});
|
|
686
|
-
|
|
628
|
+
log4("Setting created successfully");
|
|
687
629
|
return result;
|
|
688
630
|
}
|
|
689
631
|
/**
|
|
690
|
-
*
|
|
691
|
-
*
|
|
692
|
-
* @param
|
|
693
|
-
* @
|
|
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
|
-
|
|
639
|
+
log4("Updating setting: %s, data: %O", key, data);
|
|
697
640
|
const result = await this.request(`/admin/settings/${key}`, {
|
|
698
|
-
|
|
699
|
-
|
|
641
|
+
body: JSON.stringify(data),
|
|
642
|
+
method: "PUT"
|
|
700
643
|
});
|
|
701
|
-
|
|
644
|
+
log4("Setting updated successfully");
|
|
702
645
|
return result;
|
|
703
646
|
}
|
|
704
647
|
/**
|
|
705
|
-
*
|
|
706
|
-
*
|
|
707
|
-
* @
|
|
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
|
-
|
|
654
|
+
log4("Deleting setting: %s", key);
|
|
711
655
|
const result = await this.request(`/admin/settings/${key}`, {
|
|
712
656
|
method: "DELETE"
|
|
713
657
|
});
|
|
714
|
-
|
|
658
|
+
log4("Setting deleted successfully");
|
|
715
659
|
return result;
|
|
716
660
|
}
|
|
717
661
|
};
|
|
718
662
|
|
|
719
663
|
// src/admin/services/ReviewService.ts
|
|
720
|
-
import
|
|
721
|
-
var
|
|
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
|
-
*
|
|
726
|
-
* @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
|
|
727
672
|
*/
|
|
728
673
|
constructor(options = {}, sharedHeaders) {
|
|
729
674
|
super(options, sharedHeaders);
|
|
730
|
-
|
|
675
|
+
log5("ReviewService instance created");
|
|
731
676
|
}
|
|
732
677
|
/**
|
|
733
|
-
*
|
|
734
|
-
*
|
|
735
|
-
* @
|
|
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
|
-
|
|
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
|
-
|
|
688
|
+
log5("Retrieved %d reviews", result.data.length);
|
|
743
689
|
return result;
|
|
744
690
|
}
|
|
745
691
|
/**
|
|
746
|
-
*
|
|
747
|
-
*
|
|
748
|
-
* @
|
|
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
|
-
|
|
698
|
+
log5("Getting review details: %d", id);
|
|
752
699
|
const result = await this.request(`/admin/reviews/${id}`);
|
|
753
|
-
|
|
700
|
+
log5("Review details retrieved");
|
|
754
701
|
return result;
|
|
755
702
|
}
|
|
756
703
|
/**
|
|
757
|
-
*
|
|
758
|
-
*
|
|
759
|
-
* @param
|
|
760
|
-
* @
|
|
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
|
-
|
|
711
|
+
log5("Updating review: %d, data: %O", id, data);
|
|
764
712
|
const result = await this.request(`/admin/reviews/${id}`, {
|
|
765
|
-
|
|
766
|
-
|
|
713
|
+
body: JSON.stringify(data),
|
|
714
|
+
method: "PUT"
|
|
767
715
|
});
|
|
768
|
-
|
|
716
|
+
log5("Review updated successfully");
|
|
769
717
|
return result;
|
|
770
718
|
}
|
|
771
719
|
/**
|
|
772
|
-
*
|
|
773
|
-
*
|
|
774
|
-
* @
|
|
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
|
-
|
|
726
|
+
log5("Getting plugin reviews: pluginId=%d", pluginId);
|
|
778
727
|
const result = await this.request(`/admin/reviews/plugin/${pluginId}`);
|
|
779
|
-
|
|
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
|
|
734
|
+
var log6 = debug6("lobe-market-sdk:admin");
|
|
786
735
|
var MarketAdmin = class extends BaseSDK {
|
|
787
736
|
/**
|
|
788
|
-
*
|
|
789
|
-
*
|
|
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
|
-
|
|
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"]);
|