chore: bump 1.9.2, safe discoverPlugins with error handling

This commit is contained in:
Кирилл Осипков 2026-06-01 14:06:44 +03:00
parent 04cbcb791e
commit 89d871e5d6
2 changed files with 9 additions and 4 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@erp/plugin-sdk",
"version": "1.9.1",
"version": "1.9.2",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"bin": {

View File

@ -22,7 +22,6 @@ export class CoreService {
const coreUrl = process.env.CORE_BACKEND_URL || 'http://localhost:3001';
const store = requestContext.getStore();
const authHeader = store?.get('authorization');
const headers = {
'Content-Type': 'application/json',
...(authHeader ? { 'Authorization': authHeader } : {}),
@ -169,8 +168,14 @@ export class CoreService {
}
async discoverPlugins(): Promise<any[]> {
const response = await this.fetchCore('/api/plugins/discovery');
return response.data || response || [];
try {
const response = await this.fetchCore('/api/plugins/discovery');
if (Array.isArray(response)) return response;
if (response && Array.isArray(response.data)) return response.data;
return [];
} catch {
return [];
}
}
async findPluginsByEvent(eventName: string): Promise<any[]> {