@guardaian/sdk
Version:
Zero-friction AI governance and monitoring SDK for Node.js applications
69 lines (55 loc) • 1.71 kB
JavaScript
/**
* GuardAIan SDK - Main Entry Point
*/
const GuardAIanClient = require('./client');
// Global configuration storage
global.__GUARDAIAN_CONFIG__ = global.__GUARDAIAN_CONFIG__ || {};
// Main SDK class
class GuardAIan {
constructor(options = {}) {
this.client = new GuardAIanClient(options);
}
// Static initialization method - REQUIRED before using auto-import
static init(options = {}) {
if (!options.apiKey) {
throw new Error('GuardAIan API key is required. Get one at https://guardaian.ai');
}
global.__GUARDAIAN_CONFIG__ = {
apiKey: options.apiKey,
baseURL: options.baseURL || 'https://api.guardaian.ai',
environment: options.environment || 'production',
debug: options.debug || false
};
if (options.debug) {
console.log('🛡️ GuardAIan initialized. Import @guardaian/sdk/auto to enable monitoring.');
}
return global.__GUARDAIAN_CONFIG__;
}
// Check if SDK is initialized
static isInitialized() {
return !!(global.__GUARDAIAN_CONFIG__ && global.__GUARDAIAN_CONFIG__.apiKey);
}
// Get current config
static getConfig() {
return global.__GUARDAIAN_CONFIG__ || {};
}
// Manual tracking method
async track(data) {
return this.client.track(data);
}
// Flush pending data
async flush() {
return this.client.flush();
}
// Cleanup
destroy() {
this.client.destroy();
}
}
// Export both ways to support different import styles
module.exports = GuardAIan;
module.exports.GuardAIan = GuardAIan;
module.exports.GuardAIanClient = GuardAIanClient;
module.exports.version = '1.0.0-beta.1';
// Default export for ES6 compatibility
module.exports.default = GuardAIan;