UNPKG

@altus4/sdk

Version:

Official TypeScript SDK for Altus 4 - AI-Enhanced MySQL Full-Text Search Engine

205 lines 6.53 kB
"use strict"; /** * SDK package entrypoint - re-export client, services and types */ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.altus4 = exports.createAltus4SDK = exports.Altus4SDK = exports.BaseClient = exports.ManagementService = exports.DatabaseService = exports.AuthService = exports.ApiKeysService = exports.AnalyticsService = void 0; __exportStar(require("./client"), exports); __exportStar(require("./services"), exports); __exportStar(require("./types"), exports); /** * Altus 4 SDK * * A comprehensive TypeScript SDK for the Altus 4 API. * Provides a unified interface for authentication, API key management, * database connections, analytics, and system management. * * @example * ```typescript * import { Altus4SDK } from './sdk'; * * // Initialize the SDK * const altus4 = new Altus4SDK({ * baseURL: 'https://api.altus4.com/v1' * }); * * // Authenticate * const loginResult = await altus4.auth.handleLogin({ * email: 'user@example.com', * password: 'password' * }); * * if (loginResult.success) { * // Create API key * const apiKey = await altus4.apiKeys.createApiKey({ * name: 'My API Key', * environment: 'test', * permissions: ['search', 'analytics'] * }); * * // Add database connection * const database = await altus4.database.addDatabaseConnection({ * name: 'My Database', * host: 'localhost', * port: 3306, * database: 'mydb', * username: 'user', * password: 'pass' * }); * * // Get analytics * const dashboard = await altus4.analytics.getDashboardAnalytics({ * period: 'week' * }); * } * ``` */ const services_1 = require("./services"); // Re-export all types for convenience __exportStar(require("./types"), exports); // Re-export utilities for convenience __exportStar(require("./utils"), exports); // Re-export individual services for advanced usage var services_2 = require("./services"); Object.defineProperty(exports, "AnalyticsService", { enumerable: true, get: function () { return services_2.AnalyticsService; } }); Object.defineProperty(exports, "ApiKeysService", { enumerable: true, get: function () { return services_2.ApiKeysService; } }); Object.defineProperty(exports, "AuthService", { enumerable: true, get: function () { return services_2.AuthService; } }); Object.defineProperty(exports, "DatabaseService", { enumerable: true, get: function () { return services_2.DatabaseService; } }); Object.defineProperty(exports, "ManagementService", { enumerable: true, get: function () { return services_2.ManagementService; } }); // Re-export base client for custom implementations var client_1 = require("./client"); Object.defineProperty(exports, "BaseClient", { enumerable: true, get: function () { return client_1.BaseClient; } }); /** * Main Altus 4 SDK class that provides a unified interface to all services */ class Altus4SDK { /** * Initialize the Altus 4 SDK * * @param config - Configuration options for the SDK */ constructor(config = {}) { // Initialize all services with the same configuration this.auth = new services_1.AuthService(config); this.apiKeys = new services_1.ApiKeysService(config); this.database = new services_1.DatabaseService(config); this.analytics = new services_1.AnalyticsService(config); this.management = new services_1.ManagementService(config); } /** * Check if the user is currently authenticated */ isAuthenticated() { return this.auth.isAuthenticated(); } /** * Set authentication token manually */ setToken(token, expiresIn) { this.auth.setToken(token, expiresIn); } /** * Clear authentication token */ clearToken() { this.auth.clearToken(); } /** * Test connection to the API */ async testConnection() { return this.management.testConnection(); } /** * Get the base URL being used by the SDK */ getBaseURL() { return this.auth.getBaseURL(); } /** * Update the base URL for all services */ setBaseURL(baseURL) { this.auth.setBaseURL(baseURL); this.apiKeys.setBaseURL(baseURL); this.database.setBaseURL(baseURL); this.analytics.setBaseURL(baseURL); this.management.setBaseURL(baseURL); } // Convenience methods that delegate to individual services /** * Quick login helper */ async login(email, password) { return this.auth.handleLogin({ email, password }); } /** * Quick register helper */ async register(name, email, password) { return this.auth.handleRegister({ name, email, password }); } /** * Quick logout helper */ async logout() { return this.auth.handleLogout(); } /** * Get current user profile */ async getCurrentUser() { return this.auth.getCurrentUser(); } /** * Check if current user is admin */ async isAdmin() { return this.auth.isAdmin(); } /** * Refresh authentication token if needed */ async refreshTokenIfNeeded() { return this.auth.refreshTokenIfNeeded(); } } exports.Altus4SDK = Altus4SDK; /** * Create a new Altus 4 SDK instance * * @param config - Configuration options for the SDK * @returns New SDK instance */ function createAltus4SDK(config) { return new Altus4SDK(config); } exports.createAltus4SDK = createAltus4SDK; /** * Default SDK instance for convenience * * @example * ```typescript * import { altus4 } from './sdk'; * * const user = await altus4.auth.getCurrentUser(); * ``` */ exports.altus4 = new Altus4SDK(); // Default export is the SDK class exports.default = Altus4SDK; //# sourceMappingURL=index.js.map