Skip to content

Commit 82ef153

Browse files
committed
Pass config to InMemoryDriver and update plugin type
Updated the objectstack.config.ts to set type as 'driver' instead of 'plugin'. Modified the driver initialization to pass configuration to InMemoryDriver and adjusted the constructor to accept and store config. This allows the driver to be configured via context.
1 parent 4a9e6de commit 82ef153

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

packages/driver-memory/objectstack.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const MemoryDriverPlugin: ObjectStackManifest = {
44
id: 'com.objectstack.driver.memory',
55
name: 'In-Memory Driver',
66
version: '1.0.0',
7-
type: 'plugin', // Acts as a plugin that contributes a driver
7+
type: 'driver',
88
description: 'A reference specificiation implementation of the DriverInterface using in-memory arrays.',
99

1010
configuration: {

packages/driver-memory/src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ export default {
1717
version: '1.0.0',
1818

1919
onEnable: async (context: any) => {
20-
const { logger } = context;
20+
const { logger, config, drivers } = context;
2121
logger.info('[Memory Driver] Initializing...');
2222

2323
// Simulate driver registration
2424
// This assumes the runtime exposes a 'drivers' registry
25-
if (context.drivers) {
26-
const driver = new InMemoryDriver();
27-
context.drivers.register(driver);
25+
if (drivers) {
26+
const driver = new InMemoryDriver(config); // Pass config to driver
27+
drivers.register(driver);
2828
logger.info(`[Memory Driver] Registered driver: ${driver.name}`);
2929
} else {
3030
logger.warn('[Memory Driver] No driver registry found in context.');

packages/driver-memory/src/memory-driver.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ import { DriverInterface, DriverOptions } from '@objectstack/spec/driver';
1010
export class InMemoryDriver implements DriverInterface {
1111
name = 'in-memory-driver';
1212
version = '0.0.1';
13+
private config: any;
14+
15+
constructor(config?: any) {
16+
this.config = config || {};
17+
}
1318

1419
// Duck-typed RuntimePlugin hook
1520
install(ctx: any) {

0 commit comments

Comments
 (0)