@mvkproject/stellar

1.0.6 • Public • Published

✨ StellarCore

A comprehensive JavaScript SDK for API interactions, AI services, and developer tools.

📦 Installation

npm install @mvkproject/stellar

🚀 Quick Start

const StellarCore = require('@mvkproject/stellar');

// Initialize with your API key
const stellar = new StellarCore('your-api-key-here');

// Use AI services
async function generateText() {
  try {
    // Generate text with ChatGPT
    const chatResponse = await stellar.chatgpt({
      prompt: 'Explain quantum computing in simple terms'
    });
    console.log('ChatGPT response:', chatResponse.response);
    
    // Generate text with Gemini
    const geminiResponse = await stellar.gemini({
      prompt: 'Write a short poem about technology'
    });
    console.log('Gemini response:', geminiResponse.response);
    
    // Generate an image
    const imageResponse = await stellar.generateImage({
      prompt: 'A futuristic city with flying cars',
      width: 512,
      height: 512
    });
    console.log('Generated image URL:', imageResponse.imageUrl);
  } catch (error) {
    console.error('API request failed:', error.message);
  }
}

generateText();

🌟 Features

🤖 AI Services

StellarCore provides easy access to various AI models:

// Generate text with Meta's Llama model
const metaResponse = await stellar.meta({
  prompt: 'Explain the theory of relativity',
  temperature: 0.7,
  max_tokens: 500
});

// Generate text with Google's Gemini model
const geminiResponse = await stellar.gemini({
  prompt: 'Write a short story about robots'
});

// Generate text with ChatGPT
const chatgptResponse = await stellar.chatgpt({
  prompt: 'What are the benefits of renewable energy?'
});

// Generate text with Phind AI
const phindResponse = await stellar.phind({
  prompt: 'How do I optimize a React application?'
});

// Generate text with other models
const otherResponse = await stellar.other({
  prompt: 'Explain quantum computing',
  model: 'qwen-qwq-32b',
  temperature: 0.8,
  max_tokens: 1000
});

🎨 Image Generation

Generate images from text prompts:

// Generate an image
const imageResponse = await stellar.generateImage({
  prompt: 'A beautiful sunset over mountains',
  model: 'flux',
  width: 512,
  height: 512,
  enhance: true
});

// Get image usage information
const usageInfo = await stellar.getImageUsage();
console.log(`You've used ${usageInfo.usage.imagesUsedToday} images today`);
console.log(`Your daily limit is ${usageInfo.usage.dailyImageLimit} images`);
console.log(`You have ${usageInfo.usage.imagesRemaining} images remaining today`);

🛠️ DevHelper

Tools for developers to improve code quality and workflow:

// Check dependencies for updates or issues
const dependencyAnalysis = await stellar.dev.checkDependencies('./package.json');
console.log('Outdated dependencies:', dependencyAnalysis.outdated);

// Clean directories
await stellar.dev.cleanDirectories(['dist', 'build']);

// Create directories
await stellar.dev.createDirectories(['src/components', 'src/utils']);

// Copy files
await stellar.dev.copyFiles('src/config.js', 'dist/config.js');

// Setup ESLint configuration
const eslintConfig = await stellar.dev.setupESLint({
  react: true,
  disableConsole: true
});

// Load environment variables
const envVars = stellar.dev.loadEnv('.env.local');

⚡ AsyncFlow

Manage complex asynchronous operations with ease:

// Run tasks in sequence
const sequentialResults = await stellar.async.sequence([
  async () => { return 'Task 1 result'; },
  async () => { return 'Task 2 result'; },
  async () => { return 'Task 3 result'; }
]);

// Run tasks in parallel with concurrency limit
const parallelResults = await stellar.async.parallel([
  async () => { return 'Task 1 result'; },
  async () => { return 'Task 2 result'; },
  async () => { return 'Task 3 result'; }
], 2); // Run 2 tasks at a time

// Retry a function with exponential backoff
const result = await stellar.async.retry(
  async () => { 
    // Potentially failing operation
    return await fetch('https://api.example.com/data');
  },
  { maxRetries: 3, initialDelay: 300, backoffFactor: 2 }
);

// Create a pipeline of async functions
const pipeline = stellar.async.pipeline(
  async data => { return { ...data, step1: true }; },
  async data => { return { ...data, step2: true }; },
  async data => { return { ...data, result: 'success' }; }
);

const pipelineResult = await pipeline({ initialData: true });

// Create a cancellable task
const task = stellar.async.createCancellableTask(async () => {
  // Long-running operation
  await new Promise(resolve => setTimeout(resolve, 5000));
  return 'Task completed';
});

// Execute the task
const taskPromise = task.execute();

// Cancel the task if needed
setTimeout(() => {
  task.cancel();
}, 2000);

📝 FormEase

Form management with validation:

// Create a form with validation
const form = stellar.form.createForm({
  username: {
    initialValue: '',
    required: true,
    validate: [
      {
        test: value => value.length >= 3,
        message: 'Username must be at least 3 characters'
      }
    ]
  },
  email: {
    initialValue: '',
    required: true,
    validate: [
      {
        test: value => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value),
        message: 'Please enter a valid email address'
      }
    ]
  }
});

// Get validation rules
const rules = stellar.form.validationRules();

// Update a field value
form.setValue('username', 'john');

// Get field value
const username = form.getValue('username');

// Validate a specific field
const emailErrors = form.validateField('email');

// Validate all fields
const isValid = form.validate();

// Handle form submission
const handleSubmit = form.handleSubmit(values => {
  console.log('Form submitted with values:', values);
});

// Reset the form
form.reset();

📊 LogMaster

Advanced logging capabilities:

// Configure logger
stellar.log.configure({
  level: 'debug',
  format: 'json',
  timestamp: true,
  outputs: ['console']
});

// Log at different levels
stellar.log.info('Application started');
stellar.log.debug('Processing data', { count: 42 });
stellar.log.warn('Resource usage high', { cpu: '80%', memory: '70%' });
stellar.log.error('Operation failed', { code: 'AUTH_ERROR' });

// Create a child logger with context
const userLogger = stellar.log.child({ userId: '123' });
userLogger.info('User logged in'); // Includes userId in the log

🔒 SecureConfig

Manage configuration securely:

// Set configuration values
stellar.config.set('API_URL', 'https://api.example.com');
stellar.config.set('MAX_RETRIES', 3);

// Get configuration values
const apiUrl = stellar.config.get('API_URL');
const maxRetries = stellar.config.get('MAX_RETRIES', 5); // With default value

// Load from environment variables
const envConfig = stellar.config.loadFromEnv(['DATABASE_URL', 'API_KEY']);

// Validate required configuration
const validation = stellar.config.validate(['API_KEY', 'DATABASE_URL']);
if (!validation.valid) {
  console.error('Missing required configuration:', validation.missing);
}

// Load from JSON file
await stellar.config.loadFromFile('./config.json');

// Get all configuration
const allConfig = stellar.config.getAll();

🌐 I18nHelper

Internationalization utilities:

// Add translations
stellar.i18n.addTranslations('en', {
  'welcome': 'Welcome, {{name}}!',
  'goodbye': 'Goodbye!'
});

stellar.i18n.addTranslations('es', {
  'welcome': '¡Bienvenido, {{name}}!',
  'goodbye': '¡Adiós!'
});

// Set locale
stellar.i18n.setLocale('es');

// Translate
const message = stellar.i18n.translate('welcome', { name: 'John' });
// Returns: "¡Bienvenido, John!"

// Auto-detect locale
const detectedLocale = stellar.i18n.detectLocale();

// Format date according to locale
const formattedDate = stellar.i18n.formatDate(new Date(), { 
  dateStyle: 'full' 
});

// Format number according to locale
const formattedNumber = stellar.i18n.formatNumber(1234567.89, { 
  style: 'currency', 
  currency: 'EUR' 
});

💻 CodeBuddy

Code analysis and improvement:

// Analyze code for issues
const analysis = stellar.code.analyzeCode(`
function example() {
  var x = 10;
  if (x == 20) {
    console.log("Equal");
  }
}
`);

console.log('Issues found:', analysis.issues);
console.log('Suggestions:', analysis.suggestions);

// Format code
const formatted = stellar.code.formatCode(`
function example() {
var x = 10;
if (x == 20) {
console.log("Equal");
}
}
`);

// Suggest refactoring
const refactoring = stellar.code.suggestRefactoring(longComplexCode);
console.log('Refactoring suggestions:', refactoring.suggestions);
console.log('Code complexity:', refactoring.complexity);

📄 License

MIT

Package Sidebar

Install

npm i @mvkproject/stellar

Version

1.0.6

License

MIT

Unpacked Size

38.7 kB

Total Files

12

Last publish

Collaborators

  • darknessdevv
  • spectre_stellarcore