outlet-orm 7.0.0 → 9.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +130 -2
- package/docs/skills/outlet-orm/AI.md +452 -102
- package/docs/skills/outlet-orm/API.md +108 -0
- package/docs/skills/outlet-orm/QUERIES.md +64 -0
- package/docs/skills/outlet-orm/SEEDS.md +47 -0
- package/docs/skills/outlet-orm/SKILL.md +15 -7
- package/package.json +1 -1
- package/src/AI/AIPromptEnhancer.js +170 -0
- package/src/AI/AIQueryBuilder.js +234 -0
- package/src/AI/AIQueryOptimizer.js +185 -0
- package/src/AI/AISeeder.js +181 -0
- package/src/AI/AiBridgeManager.js +287 -0
- package/src/AI/Builders/TextBuilder.js +170 -0
- package/src/AI/Contracts/AudioProviderContract.js +29 -0
- package/src/AI/Contracts/ChatProviderContract.js +38 -0
- package/src/AI/Contracts/EmbeddingsProviderContract.js +19 -0
- package/src/AI/Contracts/ImageProviderContract.js +19 -0
- package/src/AI/Contracts/ModelsProviderContract.js +26 -0
- package/src/AI/Contracts/ToolContract.js +25 -0
- package/src/AI/Facades/AiBridge.js +79 -0
- package/src/AI/MCPServer.js +113 -0
- package/src/AI/Providers/ClaudeProvider.js +64 -0
- package/src/AI/Providers/CustomOpenAIProvider.js +238 -0
- package/src/AI/Providers/GeminiProvider.js +68 -0
- package/src/AI/Providers/GrokProvider.js +46 -0
- package/src/AI/Providers/MistralProvider.js +21 -0
- package/src/AI/Providers/OllamaProvider.js +249 -0
- package/src/AI/Providers/OllamaTurboProvider.js +32 -0
- package/src/AI/Providers/OnnProvider.js +46 -0
- package/src/AI/Providers/OpenAIProvider.js +471 -0
- package/src/AI/Support/AudioNormalizer.js +37 -0
- package/src/AI/Support/ChatNormalizer.js +42 -0
- package/src/AI/Support/Document.js +77 -0
- package/src/AI/Support/DocumentAttachmentMapper.js +101 -0
- package/src/AI/Support/EmbeddingsNormalizer.js +30 -0
- package/src/AI/Support/Exceptions/ProviderError.js +22 -0
- package/src/AI/Support/FileSecurity.js +56 -0
- package/src/AI/Support/ImageNormalizer.js +62 -0
- package/src/AI/Support/JsonSchemaValidator.js +73 -0
- package/src/AI/Support/Message.js +40 -0
- package/src/AI/Support/StreamChunk.js +45 -0
- package/src/AI/Support/ToolChatRunner.js +160 -0
- package/src/AI/Support/ToolRegistry.js +62 -0
- package/src/AI/Tools/SystemInfoTool.js +25 -0
- package/src/index.js +67 -1
- package/types/index.d.ts +326 -0
package/README.md
CHANGED
|
@@ -197,7 +197,14 @@ async store(req, res) {
|
|
|
197
197
|
- **Raw queries**: `executeRawQuery()` and `execute()` (native driver results)
|
|
198
198
|
- **Complete Migrations** (create/alter/drop, index, foreign keys, batch tracking)
|
|
199
199
|
- **Database Backup** (v6.0.0): full/partial/journal backups, recurring scheduler, AES-256-GCM encryption, TCP daemon + remote client, automatic restore
|
|
200
|
-
- **
|
|
200
|
+
- **🤖 AiBridge** (v8.0.0): Multi-provider LLM abstraction — chat, stream, embeddings, images, TTS, STT with 9+ providers
|
|
201
|
+
- **🤖 AI Query Builder** (v8.0.0): Natural language → SQL with schema introspection
|
|
202
|
+
- **🤖 AI Seeder** (v8.0.0): LLM-powered realistic, domain-specific data generation
|
|
203
|
+
- **🤖 AI Query Optimizer** (v8.0.0): SQL analysis, optimization, and index recommendations
|
|
204
|
+
- **🤖 AI Prompt Enhancer** (v8.0.0): Schema/model/migration generation from natural language
|
|
205
|
+
- **🤖 MCP Server** (v7.0.0): Model Context Protocol for AI agent integration (13 tools)
|
|
206
|
+
- **🤖 AI Safety Guardrails** (v7.0.0): Automatic AI agent detection + destructive operation protection
|
|
207
|
+
- **Handy CLI tools**: `outlet-init`, `outlet-migrate`, `outlet-convert`, `outlet-mcp`
|
|
201
208
|
- **`.env` configuration** (loaded automatically)
|
|
202
209
|
- **Multi-database**: MySQL, PostgreSQL, and SQLite
|
|
203
210
|
- **Complete TypeScript types** with Generic Model and typed Schema Builder (v4.0.0+)
|
|
@@ -1220,6 +1227,126 @@ outlet-convert
|
|
|
1220
1227
|
- ✅ Automatic timestamps support
|
|
1221
1228
|
- ✅ Class names converted to PascalCase
|
|
1222
1229
|
|
|
1230
|
+
## 🤖 AI Integration
|
|
1231
|
+
|
|
1232
|
+
Outlet ORM includes a complete AI subsystem with multi-provider LLM support and ORM-specific AI features.
|
|
1233
|
+
|
|
1234
|
+
📚 **[Complete AI documentation available in `/docs`](./docs/AI_BRIDGE.md)**
|
|
1235
|
+
|
|
1236
|
+
### AiBridge — Multi-Provider LLM Abstraction
|
|
1237
|
+
|
|
1238
|
+
```javascript
|
|
1239
|
+
const { AiBridgeManager } = require('outlet-orm');
|
|
1240
|
+
|
|
1241
|
+
const ai = new AiBridgeManager({
|
|
1242
|
+
providers: {
|
|
1243
|
+
openai: { api_key: process.env.OPENAI_API_KEY, model: 'gpt-4o' },
|
|
1244
|
+
claude: { api_key: process.env.ANTHROPIC_API_KEY, model: 'claude-sonnet-4-20250514' },
|
|
1245
|
+
ollama: { endpoint: 'http://localhost:11434', model: 'llama3' }
|
|
1246
|
+
}
|
|
1247
|
+
});
|
|
1248
|
+
|
|
1249
|
+
// Chat with any provider
|
|
1250
|
+
const response = await ai.chat('openai', [
|
|
1251
|
+
{ role: 'user', content: 'What is Node.js?' }
|
|
1252
|
+
]);
|
|
1253
|
+
|
|
1254
|
+
// Fluent TextBuilder
|
|
1255
|
+
const { text } = await ai.text()
|
|
1256
|
+
.using('openai', 'gpt-4o')
|
|
1257
|
+
.withSystemPrompt('You are a helpful assistant.')
|
|
1258
|
+
.withPrompt('Explain closures in JavaScript.')
|
|
1259
|
+
.asText();
|
|
1260
|
+
|
|
1261
|
+
// Stream responses
|
|
1262
|
+
for await (const chunk of ai.stream('claude', messages)) {
|
|
1263
|
+
process.stdout.write(chunk.text || '');
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1266
|
+
// Embeddings, images, TTS, STT
|
|
1267
|
+
const embeddings = await ai.embeddings('openai', ['Hello world']);
|
|
1268
|
+
const image = await ai.image('openai', 'A sunset over mountains');
|
|
1269
|
+
```
|
|
1270
|
+
|
|
1271
|
+
**Supported providers**: OpenAI, Claude, Gemini, Ollama, Grok, Mistral, ONN, Custom OpenAI, OpenRouter
|
|
1272
|
+
|
|
1273
|
+
### AI Query Builder — Natural Language → SQL
|
|
1274
|
+
|
|
1275
|
+
```javascript
|
|
1276
|
+
const { AIQueryBuilder } = require('outlet-orm');
|
|
1277
|
+
|
|
1278
|
+
const qb = new AIQueryBuilder(ai, db);
|
|
1279
|
+
|
|
1280
|
+
// Ask in natural language, get SQL + results
|
|
1281
|
+
const result = await qb.query('How many users signed up last month?');
|
|
1282
|
+
console.log(result.sql); // SELECT COUNT(*) FROM users WHERE ...
|
|
1283
|
+
console.log(result.results); // [{ count: 42 }]
|
|
1284
|
+
|
|
1285
|
+
// Generate SQL without executing
|
|
1286
|
+
const { sql } = await qb.toSql('Show me the top 5 users by post count');
|
|
1287
|
+
```
|
|
1288
|
+
|
|
1289
|
+
### AI Seeder — Realistic Data Generation
|
|
1290
|
+
|
|
1291
|
+
```javascript
|
|
1292
|
+
const { AISeeder } = require('outlet-orm');
|
|
1293
|
+
|
|
1294
|
+
const seeder = new AISeeder(ai, db);
|
|
1295
|
+
|
|
1296
|
+
// Generate and insert realistic data
|
|
1297
|
+
await seeder.seed('products', 20, {
|
|
1298
|
+
domain: 'e-commerce',
|
|
1299
|
+
locale: 'fr_FR',
|
|
1300
|
+
description: 'Fashion store for young adults'
|
|
1301
|
+
});
|
|
1302
|
+
```
|
|
1303
|
+
|
|
1304
|
+
### AI Query Optimizer
|
|
1305
|
+
|
|
1306
|
+
```javascript
|
|
1307
|
+
const { AIQueryOptimizer } = require('outlet-orm');
|
|
1308
|
+
|
|
1309
|
+
const optimizer = new AIQueryOptimizer(ai, db);
|
|
1310
|
+
const result = await optimizer.optimize(
|
|
1311
|
+
'SELECT * FROM orders WHERE user_id IN (SELECT id FROM users WHERE status = "active")'
|
|
1312
|
+
);
|
|
1313
|
+
|
|
1314
|
+
console.log(result.optimized); // Rewritten SQL
|
|
1315
|
+
console.log(result.suggestions); // [{ type: 'index', impact: 'high', ... }]
|
|
1316
|
+
console.log(result.indexes); // ['CREATE INDEX idx_...']
|
|
1317
|
+
```
|
|
1318
|
+
|
|
1319
|
+
### MCP Server — AI Agent Integration
|
|
1320
|
+
|
|
1321
|
+
```bash
|
|
1322
|
+
# Start MCP server for AI editors
|
|
1323
|
+
npx outlet-mcp
|
|
1324
|
+
```
|
|
1325
|
+
|
|
1326
|
+
Configure your AI editor:
|
|
1327
|
+
|
|
1328
|
+
```json
|
|
1329
|
+
{
|
|
1330
|
+
"mcpServers": {
|
|
1331
|
+
"outlet-orm": {
|
|
1332
|
+
"command": "npx",
|
|
1333
|
+
"args": ["outlet-mcp"]
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
```
|
|
1338
|
+
|
|
1339
|
+
**13 MCP tools**: migrations, schema introspection, queries, seeds, backups, AI query, query optimization
|
|
1340
|
+
|
|
1341
|
+
📖 Full documentation:
|
|
1342
|
+
- [AiBridge Manager](docs/AI_BRIDGE.md) — Multi-provider LLM abstraction
|
|
1343
|
+
- [AI Query Builder](docs/AI_QUERY.md) — Natural language to SQL
|
|
1344
|
+
- [AI Seeder](docs/AI_SEEDER.md) — Realistic data generation
|
|
1345
|
+
- [AI Query Optimizer](docs/AI_OPTIMIZER.md) — SQL optimization
|
|
1346
|
+
- [AI Prompt Enhancer](docs/AI_PROMPT.md) — Schema/code generation
|
|
1347
|
+
- [MCP Server](docs/MCP.md) — AI agent integration
|
|
1348
|
+
- [AI Safety Guardrails](docs/AI_SAFETY.md) — Destructive operation protection
|
|
1349
|
+
|
|
1223
1350
|
## 📚 Documentation
|
|
1224
1351
|
|
|
1225
1352
|
- [Migrations Guide](docs/MIGRATIONS.md)
|
|
@@ -1227,7 +1354,8 @@ outlet-convert
|
|
|
1227
1354
|
- [Relation Detection](docs/RELATIONS_DETECTION.md)
|
|
1228
1355
|
- [Quick Start Guide](docs/QUICKSTART.md)
|
|
1229
1356
|
- [Architecture](docs/ARCHITECTURE.md)
|
|
1230
|
-
- [**TypeScript (
|
|
1357
|
+
- [**TypeScript (complete)**](docs/TYPESCRIPT.md)
|
|
1358
|
+
- [**AI Integration (complete)**](docs/AI_BRIDGE.md)
|
|
1231
1359
|
|
|
1232
1360
|
## 📘 TypeScript Support
|
|
1233
1361
|
|