@objectql/core 3.0.1 → 4.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.
Files changed (97) hide show
  1. package/IMPLEMENTATION_STATUS.md +364 -0
  2. package/README.md +31 -9
  3. package/RUNTIME_INTEGRATION.md +391 -0
  4. package/dist/ai-agent.d.ts +4 -3
  5. package/dist/ai-agent.js +10 -3
  6. package/dist/ai-agent.js.map +1 -1
  7. package/dist/app.d.ts +29 -6
  8. package/dist/app.js +117 -58
  9. package/dist/app.js.map +1 -1
  10. package/dist/formula-engine.d.ts +7 -0
  11. package/dist/formula-engine.js +9 -2
  12. package/dist/formula-engine.js.map +1 -1
  13. package/dist/formula-plugin.d.ts +52 -0
  14. package/dist/formula-plugin.js +107 -0
  15. package/dist/formula-plugin.js.map +1 -0
  16. package/dist/index.d.ts +13 -3
  17. package/dist/index.js +14 -3
  18. package/dist/index.js.map +1 -1
  19. package/dist/plugin.d.ts +89 -0
  20. package/dist/plugin.js +99 -0
  21. package/dist/plugin.js.map +1 -0
  22. package/dist/query/filter-translator.d.ts +37 -0
  23. package/dist/query/filter-translator.js +135 -0
  24. package/dist/query/filter-translator.js.map +1 -0
  25. package/dist/query/index.d.ts +22 -0
  26. package/dist/query/index.js +39 -0
  27. package/dist/query/index.js.map +1 -0
  28. package/dist/query/query-analyzer.d.ts +186 -0
  29. package/dist/query/query-analyzer.js +349 -0
  30. package/dist/query/query-analyzer.js.map +1 -0
  31. package/dist/query/query-builder.d.ts +27 -0
  32. package/dist/query/query-builder.js +71 -0
  33. package/dist/query/query-builder.js.map +1 -0
  34. package/dist/query/query-service.d.ts +150 -0
  35. package/dist/query/query-service.js +268 -0
  36. package/dist/query/query-service.js.map +1 -0
  37. package/dist/repository.d.ts +23 -2
  38. package/dist/repository.js +62 -13
  39. package/dist/repository.js.map +1 -1
  40. package/dist/util.d.ts +7 -0
  41. package/dist/util.js +18 -3
  42. package/dist/util.js.map +1 -1
  43. package/dist/validator-plugin.d.ts +56 -0
  44. package/dist/validator-plugin.js +106 -0
  45. package/dist/validator-plugin.js.map +1 -0
  46. package/dist/validator.d.ts +7 -0
  47. package/dist/validator.js +10 -8
  48. package/dist/validator.js.map +1 -1
  49. package/jest.config.js +16 -0
  50. package/package.json +8 -5
  51. package/src/ai-agent.ts +8 -0
  52. package/src/app.ts +136 -72
  53. package/src/formula-engine.ts +8 -0
  54. package/src/formula-plugin.ts +141 -0
  55. package/src/index.ts +25 -3
  56. package/src/plugin.ts +179 -0
  57. package/src/query/filter-translator.ts +147 -0
  58. package/src/query/index.ts +24 -0
  59. package/src/query/query-analyzer.ts +535 -0
  60. package/src/query/query-builder.ts +80 -0
  61. package/src/query/query-service.ts +392 -0
  62. package/src/repository.ts +81 -17
  63. package/src/util.ts +19 -3
  64. package/src/validator-plugin.ts +140 -0
  65. package/src/validator.ts +12 -5
  66. package/test/__mocks__/@objectstack/runtime.ts +255 -0
  67. package/test/app.test.ts +23 -35
  68. package/test/filter-syntax.test.ts +233 -0
  69. package/test/formula-engine.test.ts +8 -0
  70. package/test/formula-integration.test.ts +8 -0
  71. package/test/formula-plugin.test.ts +197 -0
  72. package/test/introspection.test.ts +8 -0
  73. package/test/mock-driver.ts +8 -0
  74. package/test/plugin-integration.test.ts +213 -0
  75. package/test/repository-validation.test.ts +8 -0
  76. package/test/repository.test.ts +8 -0
  77. package/test/util.test.ts +9 -1
  78. package/test/utils.ts +8 -0
  79. package/test/validator-plugin.test.ts +126 -0
  80. package/test/validator.test.ts +8 -0
  81. package/tsconfig.json +9 -0
  82. package/tsconfig.tsbuildinfo +1 -1
  83. package/dist/action.d.ts +0 -7
  84. package/dist/action.js +0 -23
  85. package/dist/action.js.map +0 -1
  86. package/dist/hook.d.ts +0 -8
  87. package/dist/hook.js +0 -25
  88. package/dist/hook.js.map +0 -1
  89. package/dist/object.d.ts +0 -3
  90. package/dist/object.js +0 -28
  91. package/dist/object.js.map +0 -1
  92. package/src/action.ts +0 -40
  93. package/src/hook.ts +0 -42
  94. package/src/object.ts +0 -26
  95. package/test/action.test.ts +0 -276
  96. package/test/hook.test.ts +0 -343
  97. package/test/object.test.ts +0 -183
@@ -0,0 +1,364 @@
1
+ # @objectql/core Implementation Status
2
+
3
+ **Document Version**: 1.0
4
+ **Date**: January 2026
5
+ **Package Version**: 3.0.1
6
+
7
+ This document provides a detailed feature-by-feature analysis of the `@objectql/core` package's implementation against the `@objectstack/runtime` requirements, identifying which methods are production-ready versus experimental stubs.
8
+
9
+ ---
10
+
11
+ ## Executive Summary
12
+
13
+ **Overall Completion**: ~70%
14
+
15
+ - **Production Ready**: Core CRUD operations, Metadata management, Validation, Formula engine
16
+ - **Partial Implementation**: Plugin system (70%), Hook system (80%), Action system (75%)
17
+ - **Experimental/Stub**: Query analysis tools (0%), AI integration (30%), Transaction management (60%)
18
+
19
+ **Current Package Stats**:
20
+ - Total LOC: ~3,913 lines
21
+ - Source Files: 13 TypeScript files
22
+ - Test Files: 14 test files
23
+ - Test Coverage: ~85% (estimated)
24
+
25
+ ---
26
+
27
+ ## Architecture Overview
28
+
29
+ ```
30
+ @objectql/core (Current State)
31
+ ├── ObjectQL (Main App Class)
32
+ │ └── Wraps ObjectStackKernel from @objectstack/runtime
33
+ ├── ObjectQLPlugin (RuntimePlugin Implementation)
34
+ │ ├── ValidatorPlugin (Sub-plugin)
35
+ │ ├── FormulaPlugin (Sub-plugin)
36
+ │ ├── Repository Pattern (Placeholder)
37
+ │ └── AI Integration (Placeholder)
38
+ └── Core Engines
39
+ ├── Validator (Production Ready)
40
+ ├── FormulaEngine (Production Ready)
41
+ ├── Repository (Production Ready)
42
+ ├── QueryBuilder (Production Ready)
43
+ └── AIAgent (Experimental)
44
+ ```
45
+
46
+ ---
47
+
48
+ ## Feature Matrix
49
+
50
+ ### 1. Plugin System Integration
51
+
52
+ **Status**: 🟡 **70% Complete** - Core structure in place, some features incomplete
53
+
54
+ | Feature | Status | Implementation File | Notes |
55
+ |---------|--------|-------------------|-------|
56
+ | RuntimePlugin Interface | ✅ Complete | `plugin.ts:62-136` | Implements install(), onStart() |
57
+ | Plugin Registration | ✅ Complete | `plugin.ts:81-106` | Via ObjectQLPlugin constructor |
58
+ | Plugin Lifecycle (install) | ✅ Complete | `plugin.ts:81-106` | Sub-plugins registered |
59
+ | Plugin Lifecycle (onStart) | ✅ Complete | `plugin.ts:112-115` | Implemented, basic logging |
60
+ | Plugin Lifecycle (onStop) | ❌ Missing | N/A | Not implemented |
61
+ | Repository Registration | 🟡 Stub | `plugin.ts:121-125` | Placeholder only |
62
+ | AI Registration | 🟡 Stub | `plugin.ts:131-135` | Placeholder only |
63
+ | Service Container | ❌ Missing | N/A | No service registry pattern |
64
+
65
+ **Production Readiness**: Can be used in production for basic plugin registration, but lacks advanced lifecycle management and service registration.
66
+
67
+ ---
68
+
69
+ ### 2. Metadata Management
70
+
71
+ **Status**: ✅ **95% Complete** - Delegates to kernel, fully functional
72
+
73
+ | Feature | Status | Implementation File | Notes |
74
+ |---------|--------|-------------------|-------|
75
+ | Object Registration | ✅ Complete | `app.ts:197-211` | Delegates to kernel.metadata |
76
+ | Object Unregistration | ✅ Complete | `app.ts:213-215` | Delegates to kernel.metadata |
77
+ | Object Retrieval | ✅ Complete | `app.ts:217-219` | Delegates to kernel.metadata |
78
+ | Field Normalization | ✅ Complete | `app.ts:199-205` | Ensures field.name is set |
79
+ | Package Management | ✅ Complete | `app.ts:102-107` | Full delegate to kernel |
80
+ | Metadata Query API | ✅ Complete | `app.ts:221-228` | getConfigs() method |
81
+
82
+ **Production Readiness**: ✅ Production ready. Fully delegates to `ObjectStackKernel.metadata`.
83
+
84
+ ---
85
+
86
+ ### 3. Hook System
87
+
88
+ **Status**: 🟡 **80% Complete** - Core hooks work, advanced features partial
89
+
90
+ | Feature | Status | Implementation File | Notes |
91
+ |---------|--------|-------------------|-------|
92
+ | Hook Registration | ✅ Complete | `app.ts:109-115` | Delegates to kernel.hooks |
93
+ | Hook Triggering | ✅ Complete | `app.ts:117-121` | Delegates to kernel.hooks |
94
+ | Lifecycle Hooks | ✅ Complete | `repository.ts:148-226` | beforeCreate, afterUpdate, etc. |
95
+ | Package-scoped Hooks | ✅ Complete | `app.ts:109` | packageName parameter supported |
96
+ | Hook Context Enrichment | ✅ Complete | `repository.ts:148-226` | Rich HookContext with API |
97
+ | Hook Error Handling | 🟡 Partial | `repository.ts` | Basic try/catch, no rollback |
98
+ | Async Hook Support | ✅ Complete | `app.ts:117-121` | Fully async |
99
+ | Hook Priority/Ordering | ❌ Missing | N/A | First-in-first-out only |
100
+
101
+ **Production Readiness**: ✅ Production ready for standard use cases. Missing advanced ordering/priority features.
102
+
103
+ ---
104
+
105
+ ### 4. Action System
106
+
107
+ **Status**: 🟡 **75% Complete** - Basic actions work, missing introspection
108
+
109
+ | Feature | Status | Implementation File | Notes |
110
+ |---------|--------|-------------------|-------|
111
+ | Action Registration | ✅ Complete | `app.ts:123-129` | Delegates to kernel.actions |
112
+ | Action Execution | ✅ Complete | `app.ts:131-135` | Delegates to kernel.actions |
113
+ | Package-scoped Actions | ✅ Complete | `app.ts:123` | packageName parameter supported |
114
+ | Action Context | ✅ Complete | `app.ts:131-135` | Supports input/output/api |
115
+ | Action Discovery API | ❌ Missing | N/A | No getActions() method |
116
+ | Action Metadata | ❌ Missing | N/A | No schema/docs registration |
117
+
118
+ **Production Readiness**: ✅ Production ready for execution. Missing developer experience features.
119
+
120
+ ---
121
+
122
+ ### 5. Repository Pattern
123
+
124
+ **Status**: ✅ **90% Complete** - Full CRUD, missing advanced query features
125
+
126
+ | Feature | Status | Implementation File | Notes |
127
+ |---------|--------|-------------------|-------|
128
+ | Find (Query) | ✅ Complete | `repository.ts:126-175` | With filters, sorting, pagination |
129
+ | FindOne (by ID) | ✅ Complete | `repository.ts:176-185` | Single record retrieval |
130
+ | Count | ✅ Complete | `repository.ts:186-203` | With filter support |
131
+ | Create | ✅ Complete | `repository.ts:204-279` | With validation & hooks |
132
+ | Update | ✅ Complete | `repository.ts:280-354` | With validation & hooks |
133
+ | Delete | ✅ Complete | `repository.ts:355-397` | With hooks |
134
+ | Direct Query | ✅ Complete | `repository.ts:408-415` | SQL passthrough |
135
+ | Aggregate Queries | ❌ Missing | N/A | No groupBy/sum/avg support |
136
+ | Batch Operations | ❌ Missing | N/A | No bulkCreate/bulkUpdate |
137
+ | Query Caching | ❌ Missing | N/A | No cache layer |
138
+
139
+ **Production Readiness**: ✅ Production ready for standard CRUD. Missing advanced query optimization.
140
+
141
+ ---
142
+
143
+ ### 6. Validation Engine
144
+
145
+ **Status**: ✅ **95% Complete** - Comprehensive validation, minor gaps
146
+
147
+ | Feature | Status | Implementation File | Notes |
148
+ |---------|--------|-------------------|-------|
149
+ | Required Field Validation | ✅ Complete | `validator.ts:147-152` | Full implementation |
150
+ | Type Validation | ✅ Complete | `validator.ts:154-159` | All field types |
151
+ | Unique Validation | ✅ Complete | `validator.ts:161-174` | Database-level checks |
152
+ | Min/Max Validation | ✅ Complete | `validator.ts:176-189` | For numbers & strings |
153
+ | Reference Validation | ✅ Complete | `validator.ts:191-212` | Lookup field checks |
154
+ | Custom Validators | ✅ Complete | `validator.ts:224-252` | Via object.validations |
155
+ | Plugin Integration | ✅ Complete | `validator-plugin.ts:67-88` | ValidatorPlugin |
156
+ | Error Localization | ✅ Complete | `validator.ts:88-145` | i18n support |
157
+ | Schema Validation | 🟡 Partial | `validator.ts` | No JSON Schema support |
158
+
159
+ **Production Readiness**: ✅ Production ready. Covers all standard validation scenarios.
160
+
161
+ ---
162
+
163
+ ### 7. Formula Engine
164
+
165
+ **Status**: ✅ **85% Complete** - Core formulas work, missing advanced functions
166
+
167
+ | Feature | Status | Implementation File | Notes |
168
+ |---------|--------|-------------------|-------|
169
+ | Expression Parsing | ✅ Complete | `formula-engine.ts:105-181` | Tokenization & AST |
170
+ | Field References | ✅ Complete | `formula-engine.ts:197-241` | {fieldName} syntax |
171
+ | Arithmetic Operations | ✅ Complete | `formula-engine.ts:243-280` | +, -, *, /, % |
172
+ | String Operations | ✅ Complete | `formula-engine.ts:282-315` | CONCAT, UPPER, etc. |
173
+ | Logical Operations | ✅ Complete | `formula-engine.ts:317-348` | AND, OR, NOT |
174
+ | Date/Time Functions | ✅ Complete | `formula-engine.ts:350-402` | NOW, DATE_ADD, etc. |
175
+ | Conditional Logic | ✅ Complete | `formula-engine.ts:404-421` | IF, SWITCH |
176
+ | Plugin Integration | ✅ Complete | `formula-plugin.ts:58-75` | FormulaPlugin |
177
+ | Custom Functions | 🟡 Partial | `formula-engine.ts` | Limited extensibility |
178
+ | Cross-Object Formulas | ❌ Missing | N/A | Can't reference related records |
179
+
180
+ **Production Readiness**: ✅ Production ready for most use cases. Missing cross-object references.
181
+
182
+ ---
183
+
184
+ ### 8. Query Builder
185
+
186
+ **Status**: ✅ **90% Complete** - Translates queries correctly, no optimization
187
+
188
+ | Feature | Status | Implementation File | Notes |
189
+ |---------|--------|-------------------|-------|
190
+ | Filter Translation | ✅ Complete | `query/filter-translator.ts` | ObjectQL → FilterNode |
191
+ | Sort Translation | ✅ Complete | `query/query-builder.ts:52-59` | Multi-field sorting |
192
+ | Pagination | ✅ Complete | `query/query-builder.ts:61-66` | limit/offset |
193
+ | Field Selection | ✅ Complete | `query/query-builder.ts:68-73` | Projection support |
194
+ | Query AST Building | ✅ Complete | `query/query-builder.ts:27-76` | Full QueryAST |
195
+ | Complex Filters | ✅ Complete | `query/filter-translator.ts` | Nested AND/OR |
196
+ | Query Optimization | ❌ Missing | N/A | No query plan optimization |
197
+ | Query Analysis | ❌ Missing | N/A | No performance profiling |
198
+
199
+ **Production Readiness**: ✅ Production ready. Missing optimization and analysis tools.
200
+
201
+ ---
202
+
203
+ ### 9. AI Integration
204
+
205
+ **Status**: 🟡 **30% Complete** - Experimental, not production ready
206
+
207
+ | Feature | Status | Implementation File | Notes |
208
+ |---------|--------|-------------------|-------|
209
+ | Schema Generation | 🟡 Experimental | `ai-agent.ts:40-109` | Uses OpenAI API |
210
+ | Field Inference | 🟡 Experimental | `ai-agent.ts:111-169` | Basic implementation |
211
+ | Relationship Detection | 🟡 Experimental | `ai-agent.ts:171-242` | Works with hints |
212
+ | API Key Management | 🟡 Basic | `ai-agent.ts:20-25` | ENV var only |
213
+ | Error Handling | 🟡 Basic | `ai-agent.ts` | Limited retry logic |
214
+ | Plugin Registration | 🟡 Stub | `plugin.ts:131-135` | Not integrated |
215
+ | Caching | ❌ Missing | N/A | Re-generates every time |
216
+ | Cost Tracking | ❌ Missing | N/A | No usage monitoring |
217
+
218
+ **Production Readiness**: ❌ Experimental only. Needs hardening for production use.
219
+
220
+ ---
221
+
222
+ ### 10. Transaction Management
223
+
224
+ **Status**: 🟡 **60% Complete** - Basic transactions work, missing distributed support
225
+
226
+ | Feature | Status | Implementation File | Notes |
227
+ |---------|--------|-------------------|-------|
228
+ | Transaction Begin | ✅ Complete | `app.ts:146-173` | Via driver.beginTransaction() |
229
+ | Transaction Commit | ✅ Complete | `app.ts:167` | driver.commitTransaction() |
230
+ | Transaction Rollback | ✅ Complete | `app.ts:170` | driver.rollbackTransaction() |
231
+ | Nested Transactions | 🟡 Partial | `app.ts:162` | Reuses parent transaction |
232
+ | Transaction Context | ✅ Complete | `app.ts:159-163` | Passed to repository |
233
+ | Hook Rollback Support | 🟡 Basic | `repository.ts` | Throws error, driver rolls back |
234
+ | Savepoints | ❌ Missing | N/A | No nested savepoint support |
235
+ | Distributed Transactions | ❌ Missing | N/A | Single datasource only |
236
+ | Transaction Timeout | ❌ Missing | N/A | No timeout handling |
237
+
238
+ **Production Readiness**: ✅ Production ready for single-database transactions. Missing distributed support.
239
+
240
+ ---
241
+
242
+ ## @objectstack/runtime Integration Status
243
+
244
+ ### Current Delegation to Kernel
245
+
246
+ | ObjectQL Method | Kernel Delegation | Status |
247
+ |----------------|-------------------|--------|
248
+ | `metadata.register()` | `kernel.metadata.register()` | ✅ Complete |
249
+ | `on()` | `kernel.hooks.register()` | ✅ Complete |
250
+ | `triggerHook()` | `kernel.hooks.trigger()` | ✅ Complete |
251
+ | `registerAction()` | `kernel.actions.register()` | ✅ Complete |
252
+ | `executeAction()` | `kernel.actions.execute()` | ✅ Complete |
253
+
254
+ ### Type Compatibility
255
+
256
+ **Issue**: ObjectQL has richer context types than @objectstack/runtime:
257
+ - `HookContext` (ObjectQL) includes `api` field for cross-object queries
258
+ - `ActionContext` (ObjectQL) includes `input`, `output`, `api` fields
259
+ - Runtime types use index signatures `[key: string]: unknown` for extensibility
260
+
261
+ **Current Solution**: Type assertions via `as unknown as RuntimeType`
262
+
263
+ **Recommended**: Enhance runtime types to include common fields.
264
+
265
+ ---
266
+
267
+ ## Gaps & Recommendations
268
+
269
+ ### Critical Gaps (Blocking Production)
270
+ 1. **Query Analysis Tools** (0% complete)
271
+ - No query performance profiling
272
+ - No execution plan visualization
273
+ - Recommendation: Implement QueryAnalyzer class (Week 4)
274
+
275
+ 2. **Service Registration in Plugin** (0% complete)
276
+ - Repository and AI are placeholders in ObjectQLPlugin
277
+ - No service container pattern
278
+ - Recommendation: Implement proper service registration
279
+
280
+ ### High Priority (Missing Features)
281
+ 3. **Aggregate Queries** (Repository)
282
+ - No groupBy/sum/avg/min/max support
283
+ - Recommendation: Add to Repository in Week 4
284
+
285
+ 4. **Transaction Savepoints**
286
+ - No nested transaction support beyond simple nesting
287
+ - Recommendation: Add savepoint API to drivers
288
+
289
+ 5. **AI Integration Hardening**
290
+ - Currently experimental
291
+ - Recommendation: Add caching, retry logic, cost tracking
292
+
293
+ ### Medium Priority (DX Improvements)
294
+ 6. **Action Discovery API**
295
+ - No way to list registered actions
296
+ - Recommendation: Add `getActions()` method
297
+
298
+ 7. **Query Caching**
299
+ - No cache layer for repeated queries
300
+ - Recommendation: Optional cache plugin
301
+
302
+ 8. **Batch Operations**
303
+ - No bulkCreate/bulkUpdate
304
+ - Recommendation: Add batch methods to Repository
305
+
306
+ ---
307
+
308
+ ## Version Compatibility
309
+
310
+ | Package | Current Version | Compatible With |
311
+ |---------|----------------|----------------|
312
+ | @objectql/core | 3.0.1 | ✅ |
313
+ | @objectql/types | workspace:* | ✅ |
314
+ | @objectstack/spec | 0.2.0 | ✅ |
315
+ | @objectstack/runtime | 0.2.0 | ✅ |
316
+ | @objectstack/objectql | 0.2.0 | 🟡 Partially used |
317
+
318
+ **Note**: `@objectstack/objectql` is imported but not extensively used yet. Core still manages drivers directly.
319
+
320
+ ---
321
+
322
+ ## Testing Coverage
323
+
324
+ | Component | Test File | Coverage | Status |
325
+ |-----------|-----------|----------|--------|
326
+ | ObjectQL App | `app.test.ts` | ~85% | ✅ Good |
327
+ | Repository | `repository.test.ts` | ~80% | ✅ Good |
328
+ | Validator | `validator.test.ts` | ~90% | ✅ Excellent |
329
+ | Formula Engine | `formula-engine.test.ts` | ~85% | ✅ Good |
330
+ | Query Builder | `filter-syntax.test.ts` | ~75% | 🟡 Adequate |
331
+ | Plugin System | `plugin-integration.test.ts` | ~70% | 🟡 Adequate |
332
+ | AI Agent | None | 0% | ❌ Missing |
333
+ | Transaction | Partial in `repository.test.ts` | ~50% | 🟡 Needs improvement |
334
+
335
+ ---
336
+
337
+ ## Conclusion
338
+
339
+ **@objectql/core is 70% production-ready** with strong fundamentals:
340
+
341
+ ✅ **Production Ready**:
342
+ - Metadata management (95%)
343
+ - Validation engine (95%)
344
+ - Formula engine (85%)
345
+ - Repository CRUD (90%)
346
+ - Basic plugins (70%)
347
+
348
+ 🟡 **Needs Work**:
349
+ - Query analysis (0%)
350
+ - AI integration (30%)
351
+ - Advanced transactions (60%)
352
+ - Service registration (0%)
353
+
354
+ ❌ **Missing**:
355
+ - Query optimization
356
+ - Distributed transactions
357
+ - Batch operations
358
+ - Comprehensive AI error handling
359
+
360
+ **Next Steps** (Weeks 4-5):
361
+ 1. Implement QueryService and QueryAnalyzer
362
+ 2. Complete plugin service registration
363
+ 3. Driver ecosystem audit and migration
364
+ 4. Add missing aggregate query support
package/README.md CHANGED
@@ -1,22 +1,35 @@
1
1
  # @objectql/core
2
2
 
3
- The core ORM and runtime engine for ObjectQL. This package handles object querying, CRUD operations, database driver coordination, transaction management, and **metadata-driven validation**.
3
+ The core ORM and runtime engine for ObjectQL. This package handles object querying, CRUD operations, database driver coordination, transaction management, and **metadata-driven validation**. As of version 4.0.0, it wraps the **ObjectStackKernel** for plugin architecture and lifecycle management.
4
4
 
5
5
  ## Features
6
6
 
7
- - **Unified Query Language**: A generic way to query data across different databases (SQL, Mongo, etc.).
8
- - **Repository Pattern**: `ObjectRepository` for managing object records.
9
- - **Driver Agnostic**: Abstraction layer for database drivers.
10
- - **Dynamic Schema**: Loads object definitions from metadata.
11
- - **Hooks & Actions**: Runtime logic injection.
12
- - **Validation Engine**: Metadata-driven validation with field-level, cross-field, and state machine rules.
7
+ - **Plugin Architecture**: Built on top of `@objectstack/runtime` with kernel-based plugin system
8
+ - **Unified Query Language**: A generic way to query data across different databases (SQL, Mongo, etc.)
9
+ - **Repository Pattern**: `ObjectRepository` for managing object records
10
+ - **Driver Agnostic**: Abstraction layer for database drivers
11
+ - **Dynamic Schema**: Loads object definitions from metadata
12
+ - **Hooks & Actions**: Runtime logic injection
13
+ - **Validation Engine**: Metadata-driven validation with field-level, cross-field, and state machine rules
14
+ - **Formula Engine**: Computed fields with dynamic formulas
15
+ - **AI Integration**: Built-in AI agent capabilities
13
16
 
14
17
  ## Installation
15
18
 
16
19
  ```bash
17
- npm install @objectql/core @objectql/types
20
+ npm install @objectql/core @objectql/types @objectstack/runtime @objectstack/spec
18
21
  ```
19
22
 
23
+ ## Architecture
24
+
25
+ ObjectQL now wraps the `ObjectStackKernel` from `@objectstack/runtime`, providing:
26
+
27
+ - **Kernel-based lifecycle management**: Initialization, startup, and shutdown
28
+ - **Plugin system**: Extensible architecture with `ObjectQLPlugin`
29
+ - **Enhanced features**: Repository, Validator, Formula, and AI capabilities as plugins
30
+
31
+ See [RUNTIME_INTEGRATION.md](./RUNTIME_INTEGRATION.md) for detailed architecture documentation.
32
+
20
33
  ## Usage
21
34
 
22
35
  ### Basic Setup
@@ -31,7 +44,7 @@ const objectql = new ObjectQL({
31
44
  }
32
45
  });
33
46
 
34
- await objectql.init();
47
+ await objectql.init(); // Initializes the kernel and all plugins
35
48
 
36
49
  // Use context for operations
37
50
  const ctx = objectql.createContext({ userId: 'u-1' });
@@ -40,6 +53,15 @@ const projects = await ctx.object('project').find({
40
53
  });
41
54
  ```
42
55
 
56
+ ### Accessing the Kernel
57
+
58
+ For advanced use cases, you can access the underlying kernel:
59
+
60
+ ```typescript
61
+ const kernel = objectql.getKernel();
62
+ // Use kernel methods if needed
63
+ ```
64
+
43
65
  ### Validation System
44
66
 
45
67
  The validation system allows you to define validation rules in your object metadata and execute them programmatically.