@objectstack/runtime 0.3.3 → 0.4.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,36 @@
1
1
  # @objectstack/runtime
2
2
 
3
+ ## 0.4.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Unify all package versions to 0.4.2
8
+ - Updated dependencies
9
+ - @objectstack/spec@0.4.2
10
+ - @objectstack/objectql@0.4.2
11
+ - @objectstack/types@0.4.2
12
+
13
+ ## 0.4.1
14
+
15
+ ### Patch Changes
16
+
17
+ - Version synchronization and dependency updates
18
+
19
+ - Synchronized plugin-msw version to 0.4.1
20
+ - Updated runtime peer dependency versions to ^0.4.1
21
+ - Fixed internal dependency version mismatches
22
+
23
+ - Updated dependencies
24
+ - @objectstack/spec@0.4.1
25
+ - @objectstack/types@0.4.1
26
+ - @objectstack/objectql@0.4.1
27
+
28
+ ## 0.4.0
29
+
30
+ ### Minor Changes
31
+
32
+ - Release version 0.4.0
33
+
3
34
  ## 0.3.3
4
35
 
5
36
  ### Patch Changes
package/README.md ADDED
@@ -0,0 +1,162 @@
1
+ # @objectstack/runtime
2
+
3
+ ObjectStack Core Runtime & Query Engine
4
+
5
+ ## Overview
6
+
7
+ The runtime package provides the `ObjectStackKernel` - the central orchestrator for ObjectStack applications. It manages the application lifecycle, plugins, and the ObjectQL data engine.
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ npm install @objectstack/runtime
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ### Basic Setup
18
+
19
+ ```typescript
20
+ import { ObjectStackKernel, ObjectQLPlugin } from '@objectstack/runtime';
21
+ import { InMemoryDriver } from '@objectstack/driver-memory';
22
+
23
+ const kernel = new ObjectStackKernel([
24
+ // Register ObjectQL engine
25
+ new ObjectQLPlugin(),
26
+
27
+ // Add database driver
28
+ new InMemoryDriver(),
29
+
30
+ // Add your app configurations
31
+ // appConfig,
32
+ ]);
33
+
34
+ await kernel.start();
35
+ ```
36
+
37
+ ### Custom ObjectQL Instance
38
+
39
+ If you have a separate ObjectQL implementation or need custom configuration:
40
+
41
+ ```typescript
42
+ import { ObjectStackKernel, ObjectQLPlugin, ObjectQL } from '@objectstack/runtime';
43
+
44
+ // Create custom ObjectQL instance
45
+ const customQL = new ObjectQL({
46
+ env: 'production',
47
+ customConfig: true
48
+ });
49
+
50
+ // Pre-configure with custom hooks
51
+ customQL.registerHook('beforeInsert', async (ctx) => {
52
+ console.log(`Inserting into ${ctx.object}`);
53
+ });
54
+
55
+ const kernel = new ObjectStackKernel([
56
+ // Use your custom ObjectQL instance
57
+ new ObjectQLPlugin(customQL),
58
+
59
+ // ... other plugins
60
+ ]);
61
+
62
+ await kernel.start();
63
+ ```
64
+
65
+ ### Backward Compatibility
66
+
67
+ For backward compatibility, the kernel will automatically initialize ObjectQL if no `ObjectQLPlugin` is provided:
68
+
69
+ ```typescript
70
+ // This still works, but will show a deprecation warning
71
+ const kernel = new ObjectStackKernel([
72
+ new InMemoryDriver(),
73
+ // ... other plugins
74
+ ]);
75
+ ```
76
+
77
+ ## Architecture
78
+
79
+ ### ObjectStackKernel
80
+
81
+ The kernel is responsible for:
82
+ - Orchestrating application lifecycle
83
+ - Managing plugins
84
+ - Coordinating the ObjectQL engine
85
+ - Handling data operations
86
+
87
+ ### ObjectQLPlugin
88
+
89
+ The `ObjectQLPlugin` provides:
90
+ - Explicit ObjectQL engine registration
91
+ - Support for custom ObjectQL instances
92
+ - Clean separation of concerns
93
+ - Better testability
94
+
95
+ ## API Reference
96
+
97
+ ### ObjectStackKernel
98
+
99
+ #### Constructor
100
+ ```typescript
101
+ constructor(plugins: any[] = [])
102
+ ```
103
+
104
+ #### Methods
105
+ - `start()`: Initialize and start the kernel
106
+ - `find(objectName, query)`: Query data
107
+ - `get(objectName, id)`: Get single record
108
+ - `create(objectName, data)`: Create record
109
+ - `update(objectName, id, data)`: Update record
110
+ - `delete(objectName, id)`: Delete record
111
+ - `getMetadata(objectName)`: Get object metadata
112
+ - `getView(objectName, viewType)`: Get UI view definition
113
+
114
+ ### ObjectQLPlugin
115
+
116
+ #### Constructor
117
+ ```typescript
118
+ constructor(ql?: ObjectQL, hostContext?: Record<string, any>)
119
+ ```
120
+
121
+ #### Parameters
122
+ - `ql` (optional): Custom ObjectQL instance
123
+ - `hostContext` (optional): Host context configuration
124
+
125
+ ## Examples
126
+
127
+ See the `examples/` directory for complete examples:
128
+ - `examples/host/` - Full server setup with Hono
129
+ - `examples/msw-react-crud/` - Browser-based setup with MSW
130
+ - `examples/custom-objectql-example.ts` - Custom ObjectQL instance
131
+
132
+ ## Migration Guide
133
+
134
+ ### From Hardcoded ObjectQL to Plugin-Based
135
+
136
+ **Before:**
137
+ ```typescript
138
+ const kernel = new ObjectStackKernel([appConfig, driver]);
139
+ ```
140
+
141
+ **After (Recommended):**
142
+ ```typescript
143
+ const kernel = new ObjectStackKernel([
144
+ new ObjectQLPlugin(),
145
+ appConfig,
146
+ driver
147
+ ]);
148
+ ```
149
+
150
+ **After (Custom Instance):**
151
+ ```typescript
152
+ const customQL = new ObjectQL({ /* config */ });
153
+ const kernel = new ObjectStackKernel([
154
+ new ObjectQLPlugin(customQL),
155
+ appConfig,
156
+ driver
157
+ ]);
158
+ ```
159
+
160
+ ## License
161
+
162
+ MIT
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { ObjectQL, SchemaRegistry } from '@objectstack/objectql';
2
2
  export { ObjectStackKernel } from './kernel';
3
+ export { ObjectQLPlugin } from './objectql-plugin';
3
4
  export { ObjectStackRuntimeProtocol } from './protocol';
4
5
  export * from './types';
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  // Export core engine
2
2
  export { ObjectQL, SchemaRegistry } from '@objectstack/objectql';
3
3
  export { ObjectStackKernel } from './kernel';
4
+ export { ObjectQLPlugin } from './objectql-plugin';
4
5
  export { ObjectStackRuntimeProtocol } from './protocol';
5
6
  export * from './types';
package/dist/kernel.d.ts CHANGED
@@ -6,9 +6,14 @@ import { ObjectQL } from '@objectstack/objectql';
6
6
  * plugins, and the core ObjectQL engine.
7
7
  */
8
8
  export declare class ObjectStackKernel {
9
- ql: ObjectQL;
9
+ ql?: ObjectQL;
10
10
  private plugins;
11
11
  constructor(plugins?: any[]);
12
+ /**
13
+ * Ensure ObjectQL engine is initialized
14
+ * @throws Error if ObjectQL is not available
15
+ */
16
+ private ensureObjectQL;
12
17
  start(): Promise<void>;
13
18
  seed(): Promise<void>;
14
19
  find(objectName: string, query: any): Promise<{
@@ -21,7 +26,7 @@ export declare class ObjectStackKernel {
21
26
  delete(objectName: string, id: string): Promise<any>;
22
27
  getMetadata(objectName: string): {
23
28
  fields: Record<string, {
24
- type: "number" | "boolean" | "code" | "date" | "text" | "textarea" | "email" | "url" | "phone" | "password" | "markdown" | "html" | "richtext" | "currency" | "percent" | "datetime" | "time" | "select" | "lookup" | "master_detail" | "image" | "file" | "avatar" | "formula" | "summary" | "autonumber" | "location" | "geolocation" | "address" | "color" | "rating" | "slider" | "signature" | "qrcode";
29
+ type: "number" | "boolean" | "code" | "date" | "text" | "textarea" | "email" | "url" | "phone" | "password" | "markdown" | "html" | "richtext" | "currency" | "percent" | "datetime" | "time" | "toggle" | "select" | "multiselect" | "radio" | "checkboxes" | "lookup" | "master_detail" | "tree" | "image" | "file" | "avatar" | "video" | "audio" | "formula" | "summary" | "autonumber" | "location" | "address" | "json" | "color" | "rating" | "slider" | "signature" | "qrcode" | "progress" | "tags" | "vector";
25
30
  required: boolean;
26
31
  searchable: boolean;
27
32
  multiple: boolean;
@@ -82,15 +87,22 @@ export declare class ObjectStackKernel {
82
87
  currencyMode: "dynamic" | "fixed";
83
88
  defaultCurrency: string;
84
89
  } | undefined;
90
+ vectorConfig?: {
91
+ dimensions: number;
92
+ distanceMetric: "cosine" | "euclidean" | "dotProduct" | "manhattan";
93
+ normalized: boolean;
94
+ indexed: boolean;
95
+ indexType?: "flat" | "hnsw" | "ivfflat" | undefined;
96
+ } | undefined;
85
97
  }>;
86
98
  name: string;
87
99
  active: boolean;
88
100
  isSystem: boolean;
89
101
  abstract: boolean;
90
102
  datasource: string;
103
+ tags?: string[] | undefined;
91
104
  label?: string | undefined;
92
105
  description?: string | undefined;
93
- tags?: string[] | undefined;
94
106
  search?: {
95
107
  fields: string[];
96
108
  displayFields?: string[] | undefined;
package/dist/kernel.js CHANGED
@@ -7,11 +7,27 @@ import { SchemaRegistry, ObjectQL } from '@objectstack/objectql';
7
7
  */
8
8
  export class ObjectStackKernel {
9
9
  constructor(plugins = []) {
10
- // 1. Initialize Engine with Host Context (Simulated OS services)
11
- this.ql = new ObjectQL({
12
- env: process.env.NODE_ENV || 'development'
13
- });
14
10
  this.plugins = plugins;
11
+ // Check if any plugin provides ObjectQL via type: 'objectql'
12
+ // This aligns with the manifest schema that supports objectql as a package type
13
+ const hasObjectQLPlugin = plugins.some(p => p && typeof p === 'object' && p.type === 'objectql');
14
+ if (!hasObjectQLPlugin) {
15
+ // Backward compatibility: Initialize ObjectQL directly if no plugin provides it
16
+ console.warn('[Kernel] No ObjectQL plugin found, using default initialization. Consider using ObjectQLPlugin.');
17
+ this.ql = new ObjectQL({
18
+ env: process.env.NODE_ENV || 'development'
19
+ });
20
+ }
21
+ }
22
+ /**
23
+ * Ensure ObjectQL engine is initialized
24
+ * @throws Error if ObjectQL is not available
25
+ */
26
+ ensureObjectQL() {
27
+ if (!this.ql) {
28
+ throw new Error('[Kernel] ObjectQL engine not initialized. Ensure ObjectQLPlugin is registered or kernel is properly initialized.');
29
+ }
30
+ return this.ql;
15
31
  }
16
32
  async start() {
17
33
  console.log('[Kernel] Starting...');
@@ -44,13 +60,13 @@ export class ObjectStackKernel {
44
60
  // @ts-ignore
45
61
  const { InMemoryDriver } = await import('@objectstack/driver-memory');
46
62
  const driver = new InMemoryDriver();
47
- this.ql.registerDriver(driver);
63
+ this.ensureObjectQL().registerDriver(driver);
48
64
  }
49
65
  catch (e) {
50
66
  // Ignore if not present
51
67
  }
52
68
  // 2. Initialize Engine
53
- await this.ql.init();
69
+ await this.ensureObjectQL().init();
54
70
  // 3. Seed Data
55
71
  await this.seed();
56
72
  // 4. Start Runtime Plugins
@@ -84,11 +100,11 @@ export class ObjectStackKernel {
84
100
  for (const seed of app.data) {
85
101
  try {
86
102
  // Check if data exists
87
- const existing = await this.ql.find(seed.object, { top: 1 });
103
+ const existing = await this.ensureObjectQL().find(seed.object, { top: 1 });
88
104
  if (existing.length === 0) {
89
105
  console.log(`[Kernel] Inserting ${seed.records.length} records into ${seed.object}`);
90
106
  for (const record of seed.records) {
91
- await this.ql.insert(seed.object, record);
107
+ await this.ensureObjectQL().insert(seed.object, record);
92
108
  }
93
109
  }
94
110
  }
@@ -106,26 +122,26 @@ export class ObjectStackKernel {
106
122
  // Forward methods to ObjectQL
107
123
  async find(objectName, query) {
108
124
  this.ensureSchema(objectName);
109
- const results = await this.ql.find(objectName, { top: 100 });
125
+ const results = await this.ensureObjectQL().find(objectName, { top: 100 });
110
126
  return { value: results, count: results.length };
111
127
  }
112
128
  async get(objectName, id) {
113
129
  this.ensureSchema(objectName);
114
130
  // Find One
115
- const results = await this.ql.find(objectName, { top: 1 }); // Mock implementation
131
+ const results = await this.ensureObjectQL().find(objectName, { top: 1 }); // Mock implementation
116
132
  return results[0];
117
133
  }
118
134
  async create(objectName, data) {
119
135
  this.ensureSchema(objectName);
120
- return this.ql.insert(objectName, data);
136
+ return this.ensureObjectQL().insert(objectName, data);
121
137
  }
122
138
  async update(objectName, id, data) {
123
139
  this.ensureSchema(objectName);
124
- return this.ql.update(objectName, id, data);
140
+ return this.ensureObjectQL().update(objectName, id, data);
125
141
  }
126
142
  async delete(objectName, id) {
127
143
  this.ensureSchema(objectName);
128
- return this.ql.delete(objectName, id);
144
+ return this.ensureObjectQL().delete(objectName, id);
129
145
  }
130
146
  // [New Methods for ObjectUI]
131
147
  getMetadata(objectName) {
@@ -0,0 +1,27 @@
1
+ import { ObjectQL } from '@objectstack/objectql';
2
+ import { RuntimePlugin, RuntimeContext } from '@objectstack/types';
3
+ /**
4
+ * ObjectQL Engine Plugin
5
+ *
6
+ * Registers the ObjectQL engine instance with the kernel.
7
+ * This allows users to provide their own ObjectQL implementation or configuration.
8
+ *
9
+ * Usage:
10
+ * - new ObjectQLPlugin() - Creates new ObjectQL with default settings
11
+ * - new ObjectQLPlugin(existingQL) - Uses existing ObjectQL instance
12
+ * - new ObjectQLPlugin(undefined, { custom: 'context' }) - Creates new ObjectQL with custom context
13
+ */
14
+ export declare class ObjectQLPlugin implements RuntimePlugin {
15
+ name: string;
16
+ type: "objectql";
17
+ private ql;
18
+ /**
19
+ * @param ql - Existing ObjectQL instance to use (optional)
20
+ * @param hostContext - Host context for new ObjectQL instance (ignored if ql is provided)
21
+ */
22
+ constructor(ql?: ObjectQL, hostContext?: Record<string, any>);
23
+ /**
24
+ * Install the ObjectQL engine into the kernel
25
+ */
26
+ install(ctx: RuntimeContext): Promise<void>;
27
+ }
@@ -0,0 +1,41 @@
1
+ import { ObjectQL } from '@objectstack/objectql';
2
+ /**
3
+ * ObjectQL Engine Plugin
4
+ *
5
+ * Registers the ObjectQL engine instance with the kernel.
6
+ * This allows users to provide their own ObjectQL implementation or configuration.
7
+ *
8
+ * Usage:
9
+ * - new ObjectQLPlugin() - Creates new ObjectQL with default settings
10
+ * - new ObjectQLPlugin(existingQL) - Uses existing ObjectQL instance
11
+ * - new ObjectQLPlugin(undefined, { custom: 'context' }) - Creates new ObjectQL with custom context
12
+ */
13
+ export class ObjectQLPlugin {
14
+ /**
15
+ * @param ql - Existing ObjectQL instance to use (optional)
16
+ * @param hostContext - Host context for new ObjectQL instance (ignored if ql is provided)
17
+ */
18
+ constructor(ql, hostContext) {
19
+ this.name = 'com.objectstack.engine.objectql';
20
+ this.type = 'objectql';
21
+ if (ql && hostContext) {
22
+ console.warn('[ObjectQLPlugin] Both ql and hostContext provided. hostContext will be ignored.');
23
+ }
24
+ if (ql) {
25
+ this.ql = ql;
26
+ }
27
+ else {
28
+ this.ql = new ObjectQL(hostContext || {
29
+ env: process.env.NODE_ENV || 'development'
30
+ });
31
+ }
32
+ }
33
+ /**
34
+ * Install the ObjectQL engine into the kernel
35
+ */
36
+ async install(ctx) {
37
+ // Attach the ObjectQL engine to the kernel
38
+ ctx.engine.ql = this.ql;
39
+ console.log('[ObjectQLPlugin] ObjectQL engine registered');
40
+ }
41
+ }
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@objectstack/runtime",
3
- "version": "0.3.3",
3
+ "version": "0.4.2",
4
4
  "description": "ObjectStack Core Runtime & Query Engine",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "dependencies": {
8
- "@objectstack/objectql": "0.3.3",
9
- "@objectstack/types": "0.3.3",
10
- "@objectstack/spec": "0.3.3"
8
+ "@objectstack/objectql": "0.4.2",
9
+ "@objectstack/types": "0.4.2",
10
+ "@objectstack/spec": "0.4.2"
11
11
  },
12
12
  "devDependencies": {
13
13
  "typescript": "^5.0.0"
package/src/index.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  // Export core engine
2
2
  export { ObjectQL, SchemaRegistry } from '@objectstack/objectql';
3
3
  export { ObjectStackKernel } from './kernel';
4
+ export { ObjectQLPlugin } from './objectql-plugin';
4
5
  export { ObjectStackRuntimeProtocol } from './protocol';
5
6
 
6
7
  export * from './types';
package/src/kernel.ts CHANGED
@@ -8,15 +8,36 @@ import { SchemaRegistry, ObjectQL } from '@objectstack/objectql';
8
8
  * plugins, and the core ObjectQL engine.
9
9
  */
10
10
  export class ObjectStackKernel {
11
- public ql: ObjectQL;
11
+ public ql?: ObjectQL; // Will be set by ObjectQLPlugin or fallback initialization
12
12
  private plugins: any[];
13
13
 
14
14
  constructor(plugins: any[] = []) {
15
- // 1. Initialize Engine with Host Context (Simulated OS services)
16
- this.ql = new ObjectQL({
17
- env: process.env.NODE_ENV || 'development'
18
- });
19
15
  this.plugins = plugins;
16
+
17
+ // Check if any plugin provides ObjectQL via type: 'objectql'
18
+ // This aligns with the manifest schema that supports objectql as a package type
19
+ const hasObjectQLPlugin = plugins.some(p =>
20
+ p && typeof p === 'object' && p.type === 'objectql'
21
+ );
22
+
23
+ if (!hasObjectQLPlugin) {
24
+ // Backward compatibility: Initialize ObjectQL directly if no plugin provides it
25
+ console.warn('[Kernel] No ObjectQL plugin found, using default initialization. Consider using ObjectQLPlugin.');
26
+ this.ql = new ObjectQL({
27
+ env: process.env.NODE_ENV || 'development'
28
+ });
29
+ }
30
+ }
31
+
32
+ /**
33
+ * Ensure ObjectQL engine is initialized
34
+ * @throws Error if ObjectQL is not available
35
+ */
36
+ private ensureObjectQL(): ObjectQL {
37
+ if (!this.ql) {
38
+ throw new Error('[Kernel] ObjectQL engine not initialized. Ensure ObjectQLPlugin is registered or kernel is properly initialized.');
39
+ }
40
+ return this.ql;
20
41
  }
21
42
 
22
43
  async start() {
@@ -54,13 +75,13 @@ export class ObjectStackKernel {
54
75
  // @ts-ignore
55
76
  const { InMemoryDriver } = await import('@objectstack/driver-memory');
56
77
  const driver = new InMemoryDriver();
57
- this.ql.registerDriver(driver);
78
+ this.ensureObjectQL().registerDriver(driver);
58
79
  } catch (e) {
59
80
  // Ignore if not present
60
81
  }
61
82
 
62
83
  // 2. Initialize Engine
63
- await this.ql.init();
84
+ await this.ensureObjectQL().init();
64
85
 
65
86
 
66
87
  // 3. Seed Data
@@ -102,11 +123,11 @@ export class ObjectStackKernel {
102
123
  for (const seed of app.data) {
103
124
  try {
104
125
  // Check if data exists
105
- const existing = await this.ql.find(seed.object, { top: 1 });
126
+ const existing = await this.ensureObjectQL().find(seed.object, { top: 1 });
106
127
  if (existing.length === 0) {
107
128
  console.log(`[Kernel] Inserting ${seed.records.length} records into ${seed.object}`);
108
129
  for (const record of seed.records) {
109
- await this.ql.insert(seed.object, record);
130
+ await this.ensureObjectQL().insert(seed.object, record);
110
131
  }
111
132
  }
112
133
  } catch (e) {
@@ -124,30 +145,30 @@ export class ObjectStackKernel {
124
145
  // Forward methods to ObjectQL
125
146
  async find(objectName: string, query: any) {
126
147
  this.ensureSchema(objectName);
127
- const results = await this.ql.find(objectName, { top: 100 });
148
+ const results = await this.ensureObjectQL().find(objectName, { top: 100 });
128
149
  return { value: results, count: results.length };
129
150
  }
130
151
 
131
152
  async get(objectName: string, id: string) {
132
153
  this.ensureSchema(objectName);
133
154
  // Find One
134
- const results = await this.ql.find(objectName, { top: 1 }); // Mock implementation
155
+ const results = await this.ensureObjectQL().find(objectName, { top: 1 }); // Mock implementation
135
156
  return results[0];
136
157
  }
137
158
 
138
159
  async create(objectName: string, data: any) {
139
160
  this.ensureSchema(objectName);
140
- return this.ql.insert(objectName, data);
161
+ return this.ensureObjectQL().insert(objectName, data);
141
162
  }
142
163
 
143
164
  async update(objectName: string, id: string, data: any) {
144
165
  this.ensureSchema(objectName);
145
- return this.ql.update(objectName, id, data);
166
+ return this.ensureObjectQL().update(objectName, id, data);
146
167
  }
147
168
 
148
169
  async delete(objectName: string, id: string) {
149
170
  this.ensureSchema(objectName);
150
- return this.ql.delete(objectName, id);
171
+ return this.ensureObjectQL().delete(objectName, id);
151
172
  }
152
173
 
153
174
  // [New Methods for ObjectUI]
@@ -0,0 +1,47 @@
1
+ import { ObjectQL } from '@objectstack/objectql';
2
+ import { RuntimePlugin, RuntimeContext } from '@objectstack/types';
3
+
4
+ /**
5
+ * ObjectQL Engine Plugin
6
+ *
7
+ * Registers the ObjectQL engine instance with the kernel.
8
+ * This allows users to provide their own ObjectQL implementation or configuration.
9
+ *
10
+ * Usage:
11
+ * - new ObjectQLPlugin() - Creates new ObjectQL with default settings
12
+ * - new ObjectQLPlugin(existingQL) - Uses existing ObjectQL instance
13
+ * - new ObjectQLPlugin(undefined, { custom: 'context' }) - Creates new ObjectQL with custom context
14
+ */
15
+ export class ObjectQLPlugin implements RuntimePlugin {
16
+ name = 'com.objectstack.engine.objectql';
17
+ type = 'objectql' as const;
18
+
19
+ private ql: ObjectQL;
20
+
21
+ /**
22
+ * @param ql - Existing ObjectQL instance to use (optional)
23
+ * @param hostContext - Host context for new ObjectQL instance (ignored if ql is provided)
24
+ */
25
+ constructor(ql?: ObjectQL, hostContext?: Record<string, any>) {
26
+ if (ql && hostContext) {
27
+ console.warn('[ObjectQLPlugin] Both ql and hostContext provided. hostContext will be ignored.');
28
+ }
29
+
30
+ if (ql) {
31
+ this.ql = ql;
32
+ } else {
33
+ this.ql = new ObjectQL(hostContext || {
34
+ env: process.env.NODE_ENV || 'development'
35
+ });
36
+ }
37
+ }
38
+
39
+ /**
40
+ * Install the ObjectQL engine into the kernel
41
+ */
42
+ async install(ctx: RuntimeContext) {
43
+ // Attach the ObjectQL engine to the kernel
44
+ ctx.engine.ql = this.ql;
45
+ console.log('[ObjectQLPlugin] ObjectQL engine registered');
46
+ }
47
+ }