outlet-orm 9.0.2 → 10.0.0

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 CHANGED
@@ -7,6 +7,72 @@ A JavaScript ORM inspired by Laravel Eloquent for Node.js with support for MySQL
7
7
 
8
8
  📚 **[Complete documentation available in `/docs`](./docs/INDEX.md)**
9
9
 
10
+ ## Table of Contents
11
+
12
+ - [✅ Prerequisites and compatibility](#prerequisites-and-compatibility)
13
+ - [🚀 Installation](#installation)
14
+ - [Install the database driver](#install-the-database-driver)
15
+ - [📁 Recommended Project Structure](#recommended-project-structure)
16
+ - [🏗️ Architecture Flow](#architecture-flow)
17
+ - [📋 Role of each layer](#role-of-each-layer)
18
+ - [✅ Benefits of this architecture](#benefits-of-this-architecture)
19
+ - [📝 Example workflow](#example-workflow)
20
+ - [✨ Key features](#key-features)
21
+ - [⚡ Quick Start](#quick-start)
22
+ - [Project Initialisation](#project-initialisation)
23
+ - [🌱 Quick Seeding](#quick-seeding)
24
+ - [📖 Usage](#usage)
25
+ - [Connection configuration](#connection-configuration)
26
+ - [Importation](#importation)
27
+ - [Define a model](#define-a-model)
28
+ - [CRUD operations](#crud-operations)
29
+ - [Query Builder](#query-builder)
30
+ - [Relationship filters](#relationship-filters)
31
+ - [🔗 Relations](#relations)
32
+ - [One to One (hasOne)](#one-to-one-hasone)
33
+ - [One to Many (hasMany)](#one-to-many-hasmany)
34
+ - [Belongs To (belongsTo)](#belongs-to-belongsto)
35
+ - [Many to Many (belongsToMany)](#many-to-many-belongstomany)
36
+ - [Has Many Through (hasManyThrough)](#has-many-through-hasmanythrough)
37
+ - [Has One Through (hasOneThrough)](#has-one-through-hasonethrough)
38
+ - [Polymorphic relationships](#polymorphic-relationships)
39
+ - [Eager Loading](#eager-loading)
40
+ - [🎭 Attributs](#attributs)
41
+ - [Casts](#casts)
42
+ - [Hidden attributes](#hidden-attributes)
43
+ - [Timestamps](#timestamps)
44
+ - [🔄 Transactions](#transactions)
45
+ - [🗑️ Soft Deletes](#soft-deletes)
46
+ - [🔬 Scopes](#scopes)
47
+ - [Scopes Globaux](#scopes-globaux)
48
+ - [📣 Events / Hooks](#events-hooks)
49
+ - [✅ Validation](#validation)
50
+ - [Available rules](#available-rules)
51
+ - [📊 Query Logging](#query-logging)
52
+ - [📝 API Reference](#api-reference)
53
+ - [DatabaseConnection](#databaseconnection)
54
+ - [Model (static methods)](#model-static-methods)
55
+ - [Model (instance methods)](#model-instance-methods)
56
+ - [QueryBuilder](#querybuilder)
57
+ - [🛠️ CLI tools](#cli-tools)
58
+ - [outlet-init](#outlet-init)
59
+ - [outlet-migrate](#outlet-migrate)
60
+ - [outlet-convert](#outlet-convert)
61
+ - [🤖 AI Integration](#ai-integration)
62
+ - [AI — Multi-Provider LLM Abstraction](#ai-multi-provider-llm-abstraction)
63
+ - [AI Query Builder — Natural Language → SQL](#ai-query-builder-natural-language-sql)
64
+ - [AI Seeder — Realistic Data Generation](#ai-seeder-realistic-data-generation)
65
+ - [AI Query Optimizer](#ai-query-optimizer)
66
+ - [MCP Server — AI Agent Integration](#mcp-server-ai-agent-integration)
67
+ - [📚 Documentation](#documentation)
68
+ - [📘 TypeScript Support](#typescript-support)
69
+ - [Typed models](#typed-models)
70
+ - [Migrations typedes](#migrations-typedes)
71
+ - [🤝 Contributions](#contributions)
72
+ - [📄 Licence](#licence)
73
+
74
+ ---
75
+
10
76
  ## ✅ Prerequisites and compatibility
11
77
 
12
78
  - Node.js >= 18 (recommended/required)
@@ -197,7 +263,7 @@ async store(req, res) {
197
263
  - **Raw queries**: `executeRawQuery()` and `execute()` (native driver results)
198
264
  - **Complete Migrations** (create/alter/drop, index, foreign keys, batch tracking)
199
265
  - **Database Backup** (v6.0.0): full/partial/journal backups, recurring scheduler, AES-256-GCM encryption, TCP daemon + remote client, automatic restore
200
- - **🤖 AiBridge** (v8.0.0): Multi-provider LLM abstraction — chat, stream, embeddings, images, TTS, STT with 9+ providers
266
+ - **🤖 AI** (v8.0.0): Multi-provider LLM abstraction — chat, stream, embeddings, images, TTS, STT with 9+ providers
201
267
  - **🤖 AI Query Builder** (v8.0.0): Natural language → SQL with schema introspection
202
268
  - **🤖 AI Seeder** (v8.0.0): LLM-powered realistic, domain-specific data generation
203
269
  - **🤖 AI Query Optimizer** (v8.0.0): SQL analysis, optimization, and index recommendations
@@ -1233,12 +1299,12 @@ Outlet ORM includes a complete AI subsystem with multi-provider LLM support and
1233
1299
 
1234
1300
  📚 **[Complete AI documentation available in `/docs`](./docs/AI_BRIDGE.md)**
1235
1301
 
1236
- ### AiBridge — Multi-Provider LLM Abstraction
1302
+ ### AI — Multi-Provider LLM Abstraction
1237
1303
 
1238
1304
  ```javascript
1239
- const { AiBridgeManager } = require('outlet-orm');
1305
+ const { AIManager } = require('outlet-orm');
1240
1306
 
1241
- const ai = new AiBridgeManager({
1307
+ const ai = new AIManager({
1242
1308
  providers: {
1243
1309
  openai: { api_key: process.env.OPENAI_API_KEY, model: 'gpt-4o' },
1244
1310
  claude: { api_key: process.env.ANTHROPIC_API_KEY, model: 'claude-sonnet-4-20250514' },
@@ -1339,7 +1405,7 @@ Configure your AI editor:
1339
1405
  **13 MCP tools**: migrations, schema introspection, queries, seeds, backups, AI query, query optimization
1340
1406
 
1341
1407
  📖 Full documentation:
1342
- - [AiBridge Manager](docs/AI_BRIDGE.md) — Multi-provider LLM abstraction
1408
+ - [AI Manager](docs/AI_BRIDGE.md) — Multi-provider LLM abstraction
1343
1409
  - [AI Query Builder](docs/AI_QUERY.md) — Natural language to SQL
1344
1410
  - [AI Seeder](docs/AI_SEEDER.md) — Realistic data generation
1345
1411
  - [AI Query Optimizer](docs/AI_OPTIMIZER.md) — SQL optimization
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "outlet-orm",
3
- "version": "9.0.2",
3
+ "version": "10.0.0",
4
4
  "description": "A Laravel Eloquent-inspired ORM for Node.js with support for MySQL, PostgreSQL, and SQLite",
5
5
  "main": "src/index.js",
6
6
  "types": "types/index.d.ts",
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: outlet-orm-ai-integration
3
- description: Guide for AI agents to use Outlet ORM's AiBridge multi-provider LLM, AI Query Builder, AI Seeder, AI Optimizer, AI Prompt Enhancer, MCP Server, and AI Safety Guardrails. Use this skill when an AI agent needs to interact with LLMs, databases, run migrations, generate data, optimize queries, or create projects safely.
3
+ description: Guide for AI agents to use Outlet ORM's AI multi-provider LLM, AI Query Builder, AI Seeder, AI Optimizer, AI Prompt Enhancer, MCP Server, and AI Safety Guardrails. Use this skill when an AI agent needs to interact with LLMs, databases, run migrations, generate data, optimize queries, or create projects safely.
4
4
  license: MIT
5
5
  metadata:
6
6
  author: omgbwa-yasse
@@ -13,7 +13,7 @@ metadata:
13
13
 
14
14
  This skill covers Outlet ORM's complete AI feature set (v7.0.0 – v9.0.0):
15
15
 
16
- - **AiBridge** — Multi-provider LLM abstraction (9 providers, chat, stream, embeddings, images, TTS, STT, tool calling)
16
+ - **AI** — Multi-provider LLM abstraction (9 providers, chat, stream, embeddings, images, TTS, STT, tool calling)
17
17
  - **AI Query Builder** — Natural language to SQL
18
18
  - **AI Seeder** — LLM-powered realistic data generation
19
19
  - **AI Query Optimizer** — SQL optimization and EXPLAIN analysis
@@ -23,16 +23,16 @@ This skill covers Outlet ORM's complete AI feature set (v7.0.0 – v9.0.0):
23
23
 
24
24
  ---
25
25
 
26
- ## AiBridge — Multi-Provider LLM Abstraction
26
+ ## AI — Multi-Provider LLM Abstraction
27
27
 
28
28
  > Since v8.0.0
29
29
 
30
- AiBridge provides a unified API to interact with 9+ LLM providers. Zero production dependencies (Node 18+ native `fetch`).
30
+ AI provides a unified API to interact with 9+ LLM providers. Zero production dependencies (Node 18+ native `fetch`).
31
31
 
32
32
  ### Configuration
33
33
 
34
34
  ```javascript
35
- // config/aibridge.js
35
+ // config/ai.js
36
36
  module.exports = {
37
37
  default: process.env.AI_DEFAULT_PROVIDER || 'openai',
38
38
  providers: {
@@ -84,9 +84,9 @@ module.exports = {
84
84
  ### Chat
85
85
 
86
86
  ```javascript
87
- const { AiBridgeManager } = require('outlet-orm');
87
+ const { AIManager } = require('outlet-orm');
88
88
 
89
- const ai = new AiBridgeManager(config);
89
+ const ai = new AIManager(config);
90
90
 
91
91
  const response = await ai.chat('openai', [
92
92
  { role: 'system', content: 'You are a helpful assistant.' },
@@ -179,14 +179,14 @@ const response = await ai.chatWithTools('openai', [
179
179
  ]);
180
180
  ```
181
181
 
182
- ### AiBridge Facade
182
+ ### AI Facade
183
183
 
184
184
  ```javascript
185
- const { AiBridge, AiBridgeManager } = require('outlet-orm');
185
+ const { AI, AIManager } = require('outlet-orm');
186
186
 
187
- AiBridge.setManager(new AiBridgeManager(config));
187
+ AI.setManager(new AIManager(config));
188
188
 
189
- const { text } = await AiBridge.text()
189
+ const { text } = await AI.text()
190
190
  .using('openai', 'gpt-4o')
191
191
  .withPrompt('Hello!')
192
192
  .asText();
@@ -226,9 +226,9 @@ const { text } = await AiBridge.text()
226
226
  Convert natural language questions into SQL queries using any LLM.
227
227
 
228
228
  ```javascript
229
- const { AiBridgeManager, AIQueryBuilder, DatabaseConnection } = require('outlet-orm');
229
+ const { AIManager, AIQueryBuilder, DatabaseConnection } = require('outlet-orm');
230
230
 
231
- const ai = new AiBridgeManager(config);
231
+ const ai = new AIManager(config);
232
232
  const db = new DatabaseConnection();
233
233
  const qb = new AIQueryBuilder(ai, db);
234
234
 
@@ -267,9 +267,9 @@ const { sql } = await qb.toSql('Find duplicate emails');
267
267
  Generate realistic, domain-specific seed data using AI.
268
268
 
269
269
  ```javascript
270
- const { AiBridgeManager, AISeeder, DatabaseConnection } = require('outlet-orm');
270
+ const { AIManager, AISeeder, DatabaseConnection } = require('outlet-orm');
271
271
 
272
- const seeder = new AISeeder(new AiBridgeManager(config), new DatabaseConnection());
272
+ const seeder = new AISeeder(new AIManager(config), new DatabaseConnection());
273
273
 
274
274
  // Generate and insert
275
275
  const { records, inserted } = await seeder.seed('users', 10, {
@@ -309,9 +309,9 @@ const records = await seeder.generate('products', 20, {
309
309
  Analyze and optimize SQL queries using AI with index recommendations.
310
310
 
311
311
  ```javascript
312
- const { AiBridgeManager, AIQueryOptimizer, DatabaseConnection } = require('outlet-orm');
312
+ const { AIManager, AIQueryOptimizer, DatabaseConnection } = require('outlet-orm');
313
313
 
314
- const optimizer = new AIQueryOptimizer(new AiBridgeManager(config), new DatabaseConnection());
314
+ const optimizer = new AIQueryOptimizer(new AIManager(config), new DatabaseConnection());
315
315
 
316
316
  // Optimize
317
317
  const result = await optimizer.optimize(
@@ -352,9 +352,9 @@ const { plan, analysis } = await optimizer.explain('SELECT ...');
352
352
  Generate complete schemas, models, and migrations from natural language.
353
353
 
354
354
  ```javascript
355
- const { AiBridgeManager, AIPromptEnhancer } = require('outlet-orm');
355
+ const { AIManager, AIPromptEnhancer } = require('outlet-orm');
356
356
 
357
- const enhancer = new AIPromptEnhancer(new AiBridgeManager(config));
357
+ const enhancer = new AIPromptEnhancer(new AIManager(config));
358
358
 
359
359
  // Generate full schema
360
360
  const schema = await enhancer.generateSchema(
@@ -546,10 +546,10 @@ console.log(result.allowed); // true
546
546
 
547
547
  ```javascript
548
548
  const {
549
- // AiBridge — Multi-Provider LLM
550
- AiBridgeManager, // Main manager (chat, stream, embeddings, images, TTS, STT, tools)
551
- AiBridge, // Static facade
552
- // AiBridge Support
549
+ // AI — Multi-Provider LLM
550
+ AIManager, // Main manager (chat, stream, embeddings, images, TTS, STT, tools)
551
+ AI, // Static facade
552
+ // AI Support
553
553
  Message, // Chat message value object
554
554
  Document, // File/URL/base64 attachment
555
555
  StreamChunk, // Streaming DTO
@@ -515,15 +515,15 @@ const db = new DatabaseConnection({
515
515
 
516
516
  ---
517
517
 
518
- ## AiBridgeManager
518
+ ## AIManager
519
519
 
520
520
  > Since v8.0.0
521
521
 
522
522
  ### Constructor
523
523
 
524
524
  ```javascript
525
- const { AiBridgeManager } = require('outlet-orm');
526
- const ai = new AiBridgeManager(config); // From config/aibridge.js or inline
525
+ const { AIManager } = require('outlet-orm');
526
+ const ai = new AIManager(config); // From config/ai.js or inline
527
527
  ```
528
528
 
529
529
  ### Methods
@@ -304,12 +304,12 @@ const native = await db.execute(
304
304
 
305
305
  > Since v8.0.0
306
306
 
307
- Convert natural language into SQL queries using any LLM provider via AiBridge.
307
+ Convert natural language into SQL queries using any LLM provider via AI.
308
308
 
309
309
  ```javascript
310
- const { AiBridgeManager, AIQueryBuilder, DatabaseConnection } = require('outlet-orm');
310
+ const { AIManager, AIQueryBuilder, DatabaseConnection } = require('outlet-orm');
311
311
 
312
- const ai = new AiBridgeManager({ providers: { openai: { api_key: process.env.OPENAI_API_KEY, model: 'gpt-4o-mini' } } });
312
+ const ai = new AIManager({ providers: { openai: { api_key: process.env.OPENAI_API_KEY, model: 'gpt-4o-mini' } } });
313
313
  const db = new DatabaseConnection();
314
314
  const qb = new AIQueryBuilder(ai, db);
315
315
 
@@ -106,9 +106,9 @@ outlet-migrate seed
106
106
  Generate realistic domain-specific seed data using AI instead of generic lorem ipsum.
107
107
 
108
108
  ```javascript
109
- const { AiBridgeManager, AISeeder, DatabaseConnection } = require('outlet-orm');
109
+ const { AIManager, AISeeder, DatabaseConnection } = require('outlet-orm');
110
110
 
111
- const ai = new AiBridgeManager({
111
+ const ai = new AIManager({
112
112
  providers: { openai: { api_key: process.env.OPENAI_API_KEY, model: 'gpt-4o-mini' } }
113
113
  });
114
114
  const seeder = new AISeeder(ai, new DatabaseConnection());
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: outlet-orm-best-practices
3
- description: Outlet ORM is a Laravel Eloquent-inspired ORM for Node.js with MySQL, PostgreSQL, and SQLite support. Use this skill when working with Outlet ORM models, queries, relationships, migrations, backup, AI integration (AiBridge multi-provider LLM, AI Query Builder, AI Seeder, AI Optimizer, MCP Server) and database operations.
3
+ description: Outlet ORM is a Laravel Eloquent-inspired ORM for Node.js with MySQL, PostgreSQL, and SQLite support. Use this skill when working with Outlet ORM models, queries, relationships, migrations, backup, AI integration (AI multi-provider LLM, AI Query Builder, AI Seeder, AI Optimizer, MCP Server) and database operations.
4
4
  license: MIT
5
5
  metadata:
6
6
  author: omgbwa-yasse
@@ -13,9 +13,9 @@ npm: https://www.npmjs.com/package/outlet-orm
13
13
 
14
14
  Comprehensive guide for using Outlet ORM - a Laravel Eloquent-inspired ORM for Node.js/TypeScript with support for MySQL, PostgreSQL, and SQLite.
15
15
 
16
- > 🆕 **v9.0.0**: Complete AI documentation — AiBridge multi-provider LLM, AI Query Builder, AI Seeder, AI Optimizer, AI Prompt Enhancer, AI Safety Guardrails. See [AI.md](AI.md).
16
+ > 🆕 **v9.0.0**: Complete AI documentation — AI multi-provider LLM, AI Query Builder, AI Seeder, AI Optimizer, AI Prompt Enhancer, AI Safety Guardrails. See [AI.md](AI.md).
17
17
  >
18
- > 🔖 **v8.0.0**: AiBridge multi-provider LLM abstraction (9 providers), AI Query Builder, AI Seeder, AI Query Optimizer, AI Prompt Enhancer.
18
+ > 🔖 **v8.0.0**: AI multi-provider LLM abstraction (9 providers), AI Query Builder, AI Seeder, AI Query Optimizer, AI Prompt Enhancer.
19
19
  >
20
20
  > 🔖 **v7.0.0**: AI Integration — MCP Server (Model Context Protocol), AI Safety Guardrails, Prompt-based project initialization.
21
21
  >
@@ -37,7 +37,7 @@ Comprehensive guide for using Outlet ORM - a Laravel Eloquent-inspired ORM for N
37
37
  | **[TYPESCRIPT.md](TYPESCRIPT.md)** | TypeScript types, generics, typed models, migrations |
38
38
  | **[SECURITY.md](SECURITY.md)** | 🔐 Security best practices, authentication, authorisation |
39
39
  | **[BACKUP.md](BACKUP.md)** | 🗄️ Backups, scheduling, AES-256-GCM encryption, TCP daemon, restore |
40
- | **[AI.md](AI.md)** | 🤖 AiBridge (9 LLM providers), AI Query Builder, AI Seeder, AI Optimizer, AI Prompt Enhancer, MCP Server, AI Safety Guardrails |
40
+ | **[AI.md](AI.md)** | 🤖 AI (9 LLM providers), AI Query Builder, AI Seeder, AI Optimizer, AI Prompt Enhancer, MCP Server, AI Safety Guardrails |
41
41
  | **[API.md](API.md)** | Complete API Reference |
42
42
 
43
43
  ---
@@ -56,7 +56,7 @@ Reference these guidelines when:
56
56
  - Scheduling or encrypting database backups [BACKUP.md](BACKUP.md)
57
57
  - Restoring a database from a backup file [BACKUP.md](BACKUP.md)
58
58
  - Running a long-lived backup daemon over TCP [BACKUP.md](BACKUP.md)
59
- - Configuring LLM providers (AiBridge) [AI.md](AI.md)
59
+ - Configuring LLM providers (AI) [AI.md](AI.md)
60
60
  - Converting natural language to SQL (AI Query Builder) [AI.md](AI.md)
61
61
  - Generating realistic seed data with AI [AI.md](AI.md)
62
62
  - Optimizing SQL queries with AI [AI.md](AI.md)
@@ -16,12 +16,12 @@ const ToolChatRunner = require('./Support/ToolChatRunner');
16
16
  const BEARER_PREFIX = 'Bearer ';
17
17
 
18
18
  /**
19
- * AiBridgeManager
19
+ * AIManager
20
20
  * Central orchestrator for all AI providers. Supports provider registration,
21
21
  * per-call overrides, capability delegation (chat, stream, embeddings, images,
22
22
  * audio, models), tool registration, and chatWithTools loop.
23
23
  */
24
- class AiBridgeManager {
24
+ class AIManager {
25
25
  /**
26
26
  * @param {Object} config
27
27
  */
@@ -284,4 +284,4 @@ class AiBridgeManager {
284
284
  }
285
285
  }
286
286
 
287
- module.exports = AiBridgeManager;
287
+ module.exports = AIManager;
@@ -10,7 +10,7 @@
10
10
  */
11
11
  class AIPromptEnhancer {
12
12
  /**
13
- * @param {import('./AiBridgeManager')} manager
13
+ * @param {import('./AIManager')} manager
14
14
  */
15
15
  constructor(manager) {
16
16
  this._manager = manager;
@@ -2,7 +2,7 @@
2
2
 
3
3
  /**
4
4
  * AIQueryBuilder
5
- * Natural Language → SQL conversion using any AiBridge provider.
5
+ * Natural Language → SQL conversion using any AI provider.
6
6
  * Introspects the database schema, sends it with the NL prompt to an LLM,
7
7
  * and returns a safe, parameterized SQL query.
8
8
  *
@@ -10,7 +10,7 @@
10
10
  */
11
11
  class AIQueryBuilder {
12
12
  /**
13
- * @param {import('./AiBridgeManager')} manager - AiBridge manager instance
13
+ * @param {import('./AIManager')} manager - AI manager instance
14
14
  * @param {Object} connection - DatabaseConnection instance (outlet-orm)
15
15
  */
16
16
  constructor(manager, connection) {
@@ -9,7 +9,7 @@
9
9
  */
10
10
  class AIQueryOptimizer {
11
11
  /**
12
- * @param {import('./AiBridgeManager')} manager
12
+ * @param {import('./AIManager')} manager
13
13
  * @param {Object} [connection] - DatabaseConnection instance (optional, for schema introspection)
14
14
  */
15
15
  constructor(manager, connection = null) {
@@ -9,7 +9,7 @@
9
9
  */
10
10
  class AISeeder {
11
11
  /**
12
- * @param {import('./AiBridgeManager')} manager
12
+ * @param {import('./AIManager')} manager
13
13
  * @param {Object} connection - DatabaseConnection instance
14
14
  */
15
15
  constructor(manager, connection) {
@@ -5,7 +5,7 @@ const StreamChunk = require('../Support/StreamChunk');
5
5
 
6
6
  /**
7
7
  * TextBuilder
8
- * Fluent builder for text generation over AiBridge providers.
8
+ * Fluent builder for text generation over AI providers.
9
9
  * Keeps method names short and explicit, reducing array option errors.
10
10
  *
11
11
  * @example
@@ -19,7 +19,7 @@ class TextBuilder {
19
19
  static ERR_MISSING_USING = 'Provider and model must be set via using().';
20
20
 
21
21
  /**
22
- * @param {import('../AiBridgeManager')} manager
22
+ * @param {import('../AIManager')} manager
23
23
  */
24
24
  constructor(manager) {
25
25
  this._manager = manager;
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
3
  /**
4
- * AiBridge Facade
4
+ * AI Facade
5
5
  *
6
- * Convenience entry-point mirroring AiBridge\Facades\AiBridge in PHP.
7
- * Provides static-like helpers that delegate to an AiBridgeManager instance.
6
+ * Convenience entry-point for AI operations.
7
+ * Provides static-like helpers that delegate to an AIManager instance.
8
8
  */
9
9
 
10
10
  const ImageNormalizer = require('../Support/ImageNormalizer');
@@ -13,10 +13,10 @@ const EmbeddingsNormalizer = require('../Support/EmbeddingsNormalizer');
13
13
 
14
14
  let _manager = null;
15
15
 
16
- const AiBridge = {
16
+ const AI = {
17
17
  /**
18
- * Bind an AiBridgeManager instance so all helpers delegate to it.
19
- * @param {import('../AiBridgeManager')} manager
18
+ * Bind an AIManager instance so all helpers delegate to it.
19
+ * @param {import('../AIManager')} manager
20
20
  */
21
21
  setManager(manager) {
22
22
  _manager = manager;
@@ -24,7 +24,7 @@ const AiBridge = {
24
24
 
25
25
  /**
26
26
  * Return the bound manager (or null).
27
- * @returns {import('../AiBridgeManager')|null}
27
+ * @returns {import('../AIManager')|null}
28
28
  */
29
29
  getManager() {
30
30
  return _manager;
@@ -55,7 +55,7 @@ const AiBridge = {
55
55
  * @returns {import('../Builders/TextBuilder')}
56
56
  */
57
57
  text() {
58
- if (!_manager) throw new Error('AiBridge facade: no manager bound. Call AiBridge.setManager(manager) first.');
58
+ if (!_manager) throw new Error('AI facade: no manager bound. Call AI.setManager(manager) first.');
59
59
  return _manager.text();
60
60
  },
61
61
 
@@ -63,7 +63,7 @@ const AiBridge = {
63
63
  * Shorthand for manager.chat()
64
64
  */
65
65
  async chat(messages, opts) {
66
- if (!_manager) throw new Error('AiBridge facade: no manager bound.');
66
+ if (!_manager) throw new Error('AI facade: no manager bound.');
67
67
  return _manager.chat(messages, opts);
68
68
  },
69
69
 
@@ -71,9 +71,9 @@ const AiBridge = {
71
71
  * Shorthand for manager.provider()
72
72
  */
73
73
  provider(name) {
74
- if (!_manager) throw new Error('AiBridge facade: no manager bound.');
74
+ if (!_manager) throw new Error('AI facade: no manager bound.');
75
75
  return _manager.provider(name);
76
76
  },
77
77
  };
78
78
 
79
- module.exports = AiBridge;
79
+ module.exports = AI;
@@ -115,7 +115,7 @@ const TOOL_DEFINITIONS = [
115
115
  },
116
116
  {
117
117
  name: 'ai_query',
118
- description: 'Convert a natural language question into SQL and execute it. Requires an AI provider (AiBridge).',
118
+ description: 'Convert a natural language question into SQL and execute it. Requires an AI provider.',
119
119
  inputSchema: {
120
120
  type: 'object',
121
121
  properties: {
@@ -644,8 +644,8 @@ class MCPServer extends EventEmitter {
644
644
  async _toolAiQuery(args) {
645
645
  if (!args.question) throw new Error('A natural language question is required.');
646
646
  const conn = await this._getConnection();
647
- const manager = this._getAiBridgeManager();
648
- if (!manager) throw new Error('AiBridge is not configured. Set OPENAI_API_KEY or configure a provider.');
647
+ const manager = this._getAIManager();
648
+ if (!manager) throw new Error('AI is not configured. Set OPENAI_API_KEY or configure a provider.');
649
649
 
650
650
  const AIQueryBuilder = require('./AIQueryBuilder');
651
651
  const builder = new AIQueryBuilder(manager, conn);
@@ -672,8 +672,8 @@ class MCPServer extends EventEmitter {
672
672
  async _toolQueryOptimize(args) {
673
673
  if (!args.sql) throw new Error('SQL query is required.');
674
674
  const conn = await this._getConnection();
675
- const manager = this._getAiBridgeManager();
676
- if (!manager) throw new Error('AiBridge is not configured. Set OPENAI_API_KEY or configure a provider.');
675
+ const manager = this._getAIManager();
676
+ if (!manager) throw new Error('AI is not configured. Set OPENAI_API_KEY or configure a provider.');
677
677
 
678
678
  const AIQueryOptimizer = require('./AIQueryOptimizer');
679
679
  const optimizer = new AIQueryOptimizer(manager, conn);
@@ -692,17 +692,17 @@ class MCPServer extends EventEmitter {
692
692
  };
693
693
  }
694
694
 
695
- // ── AiBridge manager helper ────────────────────────────────────
695
+ // ── AI manager helper ────────────────────────────────────
696
696
 
697
697
  /**
698
- * Lazily creates an AiBridge manager from environment variables.
699
- * @returns {import('./Bridge/AiBridgeManager')|null}
698
+ * Lazily creates an AI manager from environment variables.
699
+ * @returns {import('./AIManager')|null}
700
700
  */
701
- _getAiBridgeManager() {
702
- if (this._aiBridgeManager) return this._aiBridgeManager;
701
+ _getAIManager() {
702
+ if (this._aiManager) return this._aiManager;
703
703
 
704
704
  try {
705
- const AiBridgeManager = require('./AiBridgeManager');
705
+ const AIManager = require('./AIManager');
706
706
  const config = {};
707
707
 
708
708
  // Auto-detect providers from env
@@ -716,8 +716,8 @@ class MCPServer extends EventEmitter {
716
716
 
717
717
  if (Object.keys(config).length === 0) return null;
718
718
 
719
- this._aiBridgeManager = new AiBridgeManager(config);
720
- return this._aiBridgeManager;
719
+ this._aiManager = new AIManager(config);
720
+ return this._aiManager;
721
721
  } catch {
722
722
  return null;
723
723
  }
@@ -8,7 +8,7 @@
8
8
  */
9
9
  class ToolChatRunner {
10
10
  /**
11
- * @param {import('../AiBridgeManager')} manager
11
+ * @param {import('../AIManager')} manager
12
12
  */
13
13
  constructor(manager) {
14
14
  this.manager = manager;
package/src/index.js CHANGED
@@ -33,9 +33,9 @@ const MCPServer = require('./AI/MCPServer');
33
33
  const AISafetyGuardrails = require('./AI/AISafetyGuardrails');
34
34
  const PromptGenerator = require('./AI/PromptGenerator');
35
35
 
36
- // AI Bridge (v8.0.0) — Multi-provider LLM abstraction
37
- const AiBridgeManager = require('./AI/AiBridgeManager');
38
- const AiBridgeFacade = require('./AI/Facades/AiBridge');
36
+ // AI (v8.0.0) — Multi-provider LLM abstraction
37
+ const AIManager = require('./AI/AIManager');
38
+ const AIFacade = require('./AI/Facades/AI');
39
39
  const TextBuilder = require('./AI/Builders/TextBuilder');
40
40
  const ChatProviderContract = require('./AI/Contracts/ChatProviderContract');
41
41
  const EmbeddingsProviderContract = require('./AI/Contracts/EmbeddingsProviderContract');
@@ -110,9 +110,9 @@ module.exports = {
110
110
  AISafetyGuardrails,
111
111
  PromptGenerator,
112
112
 
113
- // AI Bridge (v8.0.0)
114
- AiBridgeManager,
115
- AiBridgeFacade,
113
+ // AI (v8.0.0)
114
+ AIManager,
115
+ AIFacade,
116
116
  TextBuilder,
117
117
  ChatProviderContract,
118
118
  EmbeddingsProviderContract,
package/types/index.d.ts CHANGED
@@ -1154,7 +1154,7 @@ declare module 'outlet-orm' {
1154
1154
 
1155
1155
  /** Tool chat runner — executes tool loops */
1156
1156
  export class ToolChatRunner {
1157
- constructor(manager: AiBridgeManager, registry: ToolRegistry);
1157
+ constructor(manager: AIManager, registry: ToolRegistry);
1158
1158
  run(provider: string, messages: Array<{ role: string; content: string }>, options?: { maxToolIterations?: number; model?: string }): Promise<ChatResponse>;
1159
1159
  }
1160
1160
 
@@ -1243,8 +1243,8 @@ declare module 'outlet-orm' {
1243
1243
  listModels(): Promise<any[]>;
1244
1244
  }
1245
1245
 
1246
- /** AiBridge manager configuration */
1247
- export interface AiBridgeConfig {
1246
+ /** AI manager configuration */
1247
+ export interface AIConfig {
1248
1248
  default?: string;
1249
1249
  openai?: OpenAIProviderConfig;
1250
1250
  ollama?: { endpoint?: string; model?: string };
@@ -1261,7 +1261,7 @@ declare module 'outlet-orm' {
1261
1261
 
1262
1262
  /** TextBuilder — fluent API for building AI requests */
1263
1263
  export class TextBuilder {
1264
- constructor(manager: AiBridgeManager);
1264
+ constructor(manager: AIManager);
1265
1265
  using(provider: string, model?: string): this;
1266
1266
  withPrompt(text: string, attachments?: Document[]): this;
1267
1267
  withSystemPrompt(text: string): this;
@@ -1280,9 +1280,9 @@ declare module 'outlet-orm' {
1280
1280
  asStream(): AsyncGenerator<StreamChunk>;
1281
1281
  }
1282
1282
 
1283
- /** AiBridge Manager — central orchestrator for multi-provider AI */
1284
- export class AiBridgeManager {
1285
- constructor(config?: AiBridgeConfig);
1283
+ /** AIManager — central orchestrator for multi-provider AI */
1284
+ export class AIManager {
1285
+ constructor(config?: AIConfig);
1286
1286
  provider(name: string): ChatProviderContract;
1287
1287
  registerProvider(name: string, provider: ChatProviderContract): void;
1288
1288
  chat(provider: string, messages: Array<{ role: string; content: string }>, options?: Record<string, any>): Promise<ChatResponse>;
@@ -1315,7 +1315,7 @@ declare module 'outlet-orm' {
1315
1315
 
1316
1316
  /** AIQueryBuilder — natural language to SQL conversion */
1317
1317
  export class AIQueryBuilder {
1318
- constructor(manager: AiBridgeManager, connection: DatabaseConnection);
1318
+ constructor(manager: AIManager, connection: DatabaseConnection);
1319
1319
  using(provider: string, model: string): this;
1320
1320
  safeMode(safe: boolean): this;
1321
1321
  query(question: string, options?: { model?: string; max_tokens?: number; temperature?: number }): Promise<AIQueryResult>;
@@ -1330,7 +1330,7 @@ declare module 'outlet-orm' {
1330
1330
 
1331
1331
  /** AISeeder — AI-powered data seeding */
1332
1332
  export class AISeeder {
1333
- constructor(manager: AiBridgeManager, connection: DatabaseConnection);
1333
+ constructor(manager: AIManager, connection: DatabaseConnection);
1334
1334
  using(provider: string, model: string): this;
1335
1335
  seed(table: string, count?: number, context?: { description?: string; locale?: string; domain?: string }): Promise<AISeedResult>;
1336
1336
  generate(table: string, count?: number, context?: { description?: string; locale?: string; domain?: string }): Promise<Record<string, any>[]>;
@@ -1348,7 +1348,7 @@ declare module 'outlet-orm' {
1348
1348
 
1349
1349
  /** AIQueryOptimizer — AI-powered SQL query optimization */
1350
1350
  export class AIQueryOptimizer {
1351
- constructor(manager: AiBridgeManager, connection?: DatabaseConnection);
1351
+ constructor(manager: AIManager, connection?: DatabaseConnection);
1352
1352
  using(provider: string, model: string): this;
1353
1353
  optimize(sql: string, options?: { schema?: string; dialect?: string; model?: string }): Promise<OptimizationResult>;
1354
1354
  explain(sql: string): Promise<{ plan: any[]; analysis: string }>;
@@ -1363,7 +1363,7 @@ declare module 'outlet-orm' {
1363
1363
 
1364
1364
  /** AIPromptEnhancer — LLM-powered schema/code generation */
1365
1365
  export class AIPromptEnhancer {
1366
- constructor(manager: AiBridgeManager);
1366
+ constructor(manager: AIManager);
1367
1367
  using(provider: string, model: string): this;
1368
1368
  generateSchema(description: string, options?: { model?: string }): Promise<AISchema>;
1369
1369
  generateModelCode(tableName: string, tableSchema: { columns: string[] }, relations?: any[]): Promise<string>;