chore: bump 1.9.2, safe discoverPlugins with error handling
This commit is contained in:
parent
04cbcb791e
commit
89d871e5d6
|
|
@ -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": {
|
||||
|
|
|
|||
|
|
@ -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[]> {
|
||||
try {
|
||||
const response = await this.fetchCore('/api/plugins/discovery');
|
||||
return response.data || response || [];
|
||||
if (Array.isArray(response)) return response;
|
||||
if (response && Array.isArray(response.data)) return response.data;
|
||||
return [];
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
async findPluginsByEvent(eventName: string): Promise<any[]> {
|
||||
|
|
|
|||
Loading…
Reference in New Issue