UNPKG

auto-builder-sdk

Version:

SDK for building Auto Builder workflow plugins

31 lines (30 loc) 1.1 kB
/** * Database service interface for dependency injection * This allows plugins to execute database queries without importing drivers directly */ /** * Get the injected database service * @returns IDatabaseService instance * @throws Error if database service is not available */ export function getDatabaseService() { if (typeof globalThis !== 'undefined' && globalThis.__databaseService) { return globalThis.__databaseService; } if (typeof global !== 'undefined' && global.__databaseService) { return global.__databaseService; } throw new Error('Database service not available. This may indicate the plugin is not running in the proper sandbox environment.'); } /** * Internal function to inject database service (used by main auto-builder project) * @param service - Database service implementation */ export function _internalInjectDatabaseService(service) { if (typeof globalThis !== 'undefined') { globalThis.__databaseService = service; } if (typeof global !== 'undefined') { global.__databaseService = service; } }