@objectstack/driver-memory 3.2.9 → 3.3.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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @objectstack/driver-memory@3.2.9 build /home/runner/work/spec/spec/packages/plugins/driver-memory
2
+ > @objectstack/driver-memory@3.3.1 build /home/runner/work/spec/spec/packages/plugins/driver-memory
3
3
  > tsup --config ../../../tsup.config.ts
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -10,13 +10,13 @@
10
10
  CLI Cleaning output folder
11
11
  ESM Build start
12
12
  CJS Build start
13
- ESM dist/index.mjs 52.62 KB
14
- ESM dist/index.mjs.map 104.48 KB
15
- ESM ⚡️ Build success in 128ms
16
- CJS dist/index.js 54.30 KB
17
- CJS dist/index.js.map 104.53 KB
18
- CJS ⚡️ Build success in 128ms
13
+ CJS dist/index.js 55.83 KB
14
+ CJS dist/index.js.map 107.83 KB
15
+ CJS ⚡️ Build success in 143ms
16
+ ESM dist/index.mjs 54.10 KB
17
+ ESM dist/index.mjs.map 107.78 KB
18
+ ESM ⚡️ Build success in 149ms
19
19
  DTS Build start
20
- DTS ⚡️ Build success in 16559ms
21
- DTS dist/index.d.mts 14.27 KB
22
- DTS dist/index.d.ts 14.27 KB
20
+ DTS ⚡️ Build success in 17435ms
21
+ DTS dist/index.d.mts 15.60 KB
22
+ DTS dist/index.d.ts 15.60 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @objectstack/driver-memory
2
2
 
3
+ ## 3.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - @objectstack/spec@3.3.1
8
+ - @objectstack/core@3.3.1
9
+
10
+ ## 3.3.0
11
+
12
+ ### Patch Changes
13
+
14
+ - @objectstack/spec@3.3.0
15
+ - @objectstack/core@3.3.0
16
+
3
17
  ## 3.2.9
4
18
 
5
19
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
- import { QueryInput, DriverOptions, Cube, AnalyticsQuery } from '@objectstack/spec/data';
2
- import { DriverInterface, Logger } from '@objectstack/core';
3
- import { IAnalyticsService, AnalyticsResult, CubeMeta } from '@objectstack/spec/contracts';
1
+ import { QueryAST, DriverOptions, QueryInput, Cube, AnalyticsQuery } from '@objectstack/spec/data';
2
+ import { IDataDriver, IAnalyticsService, AnalyticsResult, CubeMeta, AnalyticsStrategy, AnalyticsQuery as AnalyticsQuery$1, StrategyContext } from '@objectstack/spec/contracts';
3
+ import { Logger } from '@objectstack/core';
4
4
 
5
5
  /**
6
6
  * Persistence adapter interface.
@@ -65,10 +65,10 @@ interface InMemoryDriverConfig {
65
65
  *
66
66
  * Reference: objectql/packages/drivers/memory
67
67
  */
68
- declare class InMemoryDriver implements DriverInterface {
69
- name: string;
68
+ declare class InMemoryDriver implements IDataDriver {
69
+ readonly name = "com.objectstack.driver.memory";
70
70
  type: string;
71
- version: string;
71
+ readonly version = "1.0.0";
72
72
  private config;
73
73
  private logger;
74
74
  private idCounters;
@@ -76,20 +76,38 @@ declare class InMemoryDriver implements DriverInterface {
76
76
  private persistenceAdapter;
77
77
  constructor(config?: InMemoryDriverConfig);
78
78
  install(ctx: any): void;
79
- supports: {
79
+ readonly supports: {
80
+ create: boolean;
81
+ read: boolean;
82
+ update: boolean;
83
+ delete: boolean;
84
+ bulkCreate: boolean;
85
+ bulkUpdate: boolean;
86
+ bulkDelete: boolean;
80
87
  transactions: boolean;
88
+ savepoints: boolean;
81
89
  queryFilters: boolean;
82
90
  queryAggregations: boolean;
83
91
  querySorting: boolean;
84
92
  queryPagination: boolean;
85
93
  queryWindowFunctions: boolean;
86
94
  querySubqueries: boolean;
95
+ queryCTE: boolean;
87
96
  joins: boolean;
88
97
  fullTextSearch: boolean;
89
- vectorSearch: boolean;
90
- geoSpatial: boolean;
98
+ jsonQuery: boolean;
99
+ geospatialQuery: boolean;
100
+ streaming: boolean;
91
101
  jsonFields: boolean;
92
102
  arrayFields: boolean;
103
+ vectorSearch: boolean;
104
+ schemaSync: boolean;
105
+ batchSchemaSync: boolean;
106
+ migrations: boolean;
107
+ indexes: boolean;
108
+ connectionPooling: boolean;
109
+ preparedStatements: boolean;
110
+ queryCache: boolean;
93
111
  };
94
112
  /**
95
113
  * The "Database": A map of TableName -> Array of Records
@@ -99,9 +117,9 @@ declare class InMemoryDriver implements DriverInterface {
99
117
  disconnect(): Promise<void>;
100
118
  checkHealth(): Promise<boolean>;
101
119
  execute(command: any, params?: any[]): Promise<null>;
102
- find(object: string, query: QueryInput, options?: DriverOptions): Promise<any[]>;
103
- findStream(object: string, query: QueryInput, options?: DriverOptions): AsyncGenerator<any, void, unknown>;
104
- findOne(object: string, query: QueryInput, options?: DriverOptions): Promise<any>;
120
+ find(object: string, query: QueryAST, options?: DriverOptions): Promise<any[]>;
121
+ findStream(object: string, query: QueryAST, options?: DriverOptions): AsyncGenerator<any, void, unknown>;
122
+ findOne(object: string, query: QueryAST, options?: DriverOptions): Promise<any>;
105
123
  create(object: string, data: Record<string, any>, options?: DriverOptions): Promise<{
106
124
  created_at: any;
107
125
  updated_at: any;
@@ -110,18 +128,14 @@ declare class InMemoryDriver implements DriverInterface {
110
128
  update(object: string, id: string | number, data: Record<string, any>, options?: DriverOptions): Promise<any>;
111
129
  upsert(object: string, data: Record<string, any>, conflictKeys?: string[], options?: DriverOptions): Promise<any>;
112
130
  delete(object: string, id: string | number, options?: DriverOptions): Promise<boolean>;
113
- count(object: string, query?: QueryInput, options?: DriverOptions): Promise<number>;
131
+ count(object: string, query?: QueryAST, options?: DriverOptions): Promise<number>;
114
132
  bulkCreate(object: string, dataArray: Record<string, any>[], options?: DriverOptions): Promise<{
115
133
  created_at: any;
116
134
  updated_at: any;
117
135
  id: any;
118
136
  }[]>;
119
- updateMany(object: string, query: QueryInput, data: Record<string, any>, options?: DriverOptions): Promise<{
120
- count: number;
121
- }>;
122
- deleteMany(object: string, query: QueryInput, options?: DriverOptions): Promise<{
123
- count: number;
124
- }>;
137
+ updateMany(object: string, query: QueryAST, data: Record<string, any>, options?: DriverOptions): Promise<number>;
138
+ deleteMany(object: string, query: QueryAST, options?: DriverOptions): Promise<number>;
125
139
  bulkUpdate(object: string, updates: {
126
140
  id: string | number;
127
141
  data: Record<string, any>;
@@ -393,10 +407,31 @@ declare class MemoryAnalyticsService implements IAnalyticsService {
393
407
  private generateSqlFromPipeline;
394
408
  }
395
409
 
410
+ /**
411
+ * InMemoryStrategy — Priority 3
412
+ *
413
+ * Delegates to an existing `IAnalyticsService` instance that was registered
414
+ * as a fallback (typically `MemoryAnalyticsService` from this package).
415
+ *
416
+ * This is the lowest-priority strategy, used in:
417
+ * - `dev` / `test` environments
418
+ * - Any runtime where the backing driver is in-memory
419
+ */
420
+ declare class InMemoryStrategy implements AnalyticsStrategy {
421
+ readonly name = "InMemoryStrategy";
422
+ readonly priority = 30;
423
+ canHandle(query: AnalyticsQuery$1, ctx: StrategyContext): boolean;
424
+ execute(query: AnalyticsQuery$1, ctx: StrategyContext): Promise<AnalyticsResult>;
425
+ generateSql(query: AnalyticsQuery$1, ctx: StrategyContext): Promise<{
426
+ sql: string;
427
+ params: unknown[];
428
+ }>;
429
+ }
430
+
396
431
  declare const _default: {
397
432
  id: string;
398
433
  version: string;
399
434
  onEnable: (context: any) => Promise<void>;
400
435
  };
401
436
 
402
- export { FileSystemPersistenceAdapter, InMemoryDriver, type InMemoryDriverConfig, LocalStoragePersistenceAdapter, type MemoryAnalyticsConfig, MemoryAnalyticsService, type PersistenceAdapterInterface, _default as default };
437
+ export { FileSystemPersistenceAdapter, InMemoryDriver, type InMemoryDriverConfig, InMemoryStrategy, LocalStoragePersistenceAdapter, type MemoryAnalyticsConfig, MemoryAnalyticsService, type PersistenceAdapterInterface, _default as default };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { QueryInput, DriverOptions, Cube, AnalyticsQuery } from '@objectstack/spec/data';
2
- import { DriverInterface, Logger } from '@objectstack/core';
3
- import { IAnalyticsService, AnalyticsResult, CubeMeta } from '@objectstack/spec/contracts';
1
+ import { QueryAST, DriverOptions, QueryInput, Cube, AnalyticsQuery } from '@objectstack/spec/data';
2
+ import { IDataDriver, IAnalyticsService, AnalyticsResult, CubeMeta, AnalyticsStrategy, AnalyticsQuery as AnalyticsQuery$1, StrategyContext } from '@objectstack/spec/contracts';
3
+ import { Logger } from '@objectstack/core';
4
4
 
5
5
  /**
6
6
  * Persistence adapter interface.
@@ -65,10 +65,10 @@ interface InMemoryDriverConfig {
65
65
  *
66
66
  * Reference: objectql/packages/drivers/memory
67
67
  */
68
- declare class InMemoryDriver implements DriverInterface {
69
- name: string;
68
+ declare class InMemoryDriver implements IDataDriver {
69
+ readonly name = "com.objectstack.driver.memory";
70
70
  type: string;
71
- version: string;
71
+ readonly version = "1.0.0";
72
72
  private config;
73
73
  private logger;
74
74
  private idCounters;
@@ -76,20 +76,38 @@ declare class InMemoryDriver implements DriverInterface {
76
76
  private persistenceAdapter;
77
77
  constructor(config?: InMemoryDriverConfig);
78
78
  install(ctx: any): void;
79
- supports: {
79
+ readonly supports: {
80
+ create: boolean;
81
+ read: boolean;
82
+ update: boolean;
83
+ delete: boolean;
84
+ bulkCreate: boolean;
85
+ bulkUpdate: boolean;
86
+ bulkDelete: boolean;
80
87
  transactions: boolean;
88
+ savepoints: boolean;
81
89
  queryFilters: boolean;
82
90
  queryAggregations: boolean;
83
91
  querySorting: boolean;
84
92
  queryPagination: boolean;
85
93
  queryWindowFunctions: boolean;
86
94
  querySubqueries: boolean;
95
+ queryCTE: boolean;
87
96
  joins: boolean;
88
97
  fullTextSearch: boolean;
89
- vectorSearch: boolean;
90
- geoSpatial: boolean;
98
+ jsonQuery: boolean;
99
+ geospatialQuery: boolean;
100
+ streaming: boolean;
91
101
  jsonFields: boolean;
92
102
  arrayFields: boolean;
103
+ vectorSearch: boolean;
104
+ schemaSync: boolean;
105
+ batchSchemaSync: boolean;
106
+ migrations: boolean;
107
+ indexes: boolean;
108
+ connectionPooling: boolean;
109
+ preparedStatements: boolean;
110
+ queryCache: boolean;
93
111
  };
94
112
  /**
95
113
  * The "Database": A map of TableName -> Array of Records
@@ -99,9 +117,9 @@ declare class InMemoryDriver implements DriverInterface {
99
117
  disconnect(): Promise<void>;
100
118
  checkHealth(): Promise<boolean>;
101
119
  execute(command: any, params?: any[]): Promise<null>;
102
- find(object: string, query: QueryInput, options?: DriverOptions): Promise<any[]>;
103
- findStream(object: string, query: QueryInput, options?: DriverOptions): AsyncGenerator<any, void, unknown>;
104
- findOne(object: string, query: QueryInput, options?: DriverOptions): Promise<any>;
120
+ find(object: string, query: QueryAST, options?: DriverOptions): Promise<any[]>;
121
+ findStream(object: string, query: QueryAST, options?: DriverOptions): AsyncGenerator<any, void, unknown>;
122
+ findOne(object: string, query: QueryAST, options?: DriverOptions): Promise<any>;
105
123
  create(object: string, data: Record<string, any>, options?: DriverOptions): Promise<{
106
124
  created_at: any;
107
125
  updated_at: any;
@@ -110,18 +128,14 @@ declare class InMemoryDriver implements DriverInterface {
110
128
  update(object: string, id: string | number, data: Record<string, any>, options?: DriverOptions): Promise<any>;
111
129
  upsert(object: string, data: Record<string, any>, conflictKeys?: string[], options?: DriverOptions): Promise<any>;
112
130
  delete(object: string, id: string | number, options?: DriverOptions): Promise<boolean>;
113
- count(object: string, query?: QueryInput, options?: DriverOptions): Promise<number>;
131
+ count(object: string, query?: QueryAST, options?: DriverOptions): Promise<number>;
114
132
  bulkCreate(object: string, dataArray: Record<string, any>[], options?: DriverOptions): Promise<{
115
133
  created_at: any;
116
134
  updated_at: any;
117
135
  id: any;
118
136
  }[]>;
119
- updateMany(object: string, query: QueryInput, data: Record<string, any>, options?: DriverOptions): Promise<{
120
- count: number;
121
- }>;
122
- deleteMany(object: string, query: QueryInput, options?: DriverOptions): Promise<{
123
- count: number;
124
- }>;
137
+ updateMany(object: string, query: QueryAST, data: Record<string, any>, options?: DriverOptions): Promise<number>;
138
+ deleteMany(object: string, query: QueryAST, options?: DriverOptions): Promise<number>;
125
139
  bulkUpdate(object: string, updates: {
126
140
  id: string | number;
127
141
  data: Record<string, any>;
@@ -393,10 +407,31 @@ declare class MemoryAnalyticsService implements IAnalyticsService {
393
407
  private generateSqlFromPipeline;
394
408
  }
395
409
 
410
+ /**
411
+ * InMemoryStrategy — Priority 3
412
+ *
413
+ * Delegates to an existing `IAnalyticsService` instance that was registered
414
+ * as a fallback (typically `MemoryAnalyticsService` from this package).
415
+ *
416
+ * This is the lowest-priority strategy, used in:
417
+ * - `dev` / `test` environments
418
+ * - Any runtime where the backing driver is in-memory
419
+ */
420
+ declare class InMemoryStrategy implements AnalyticsStrategy {
421
+ readonly name = "InMemoryStrategy";
422
+ readonly priority = 30;
423
+ canHandle(query: AnalyticsQuery$1, ctx: StrategyContext): boolean;
424
+ execute(query: AnalyticsQuery$1, ctx: StrategyContext): Promise<AnalyticsResult>;
425
+ generateSql(query: AnalyticsQuery$1, ctx: StrategyContext): Promise<{
426
+ sql: string;
427
+ params: unknown[];
428
+ }>;
429
+ }
430
+
396
431
  declare const _default: {
397
432
  id: string;
398
433
  version: string;
399
434
  onEnable: (context: any) => Promise<void>;
400
435
  };
401
436
 
402
- export { FileSystemPersistenceAdapter, InMemoryDriver, type InMemoryDriverConfig, LocalStoragePersistenceAdapter, type MemoryAnalyticsConfig, MemoryAnalyticsService, type PersistenceAdapterInterface, _default as default };
437
+ export { FileSystemPersistenceAdapter, InMemoryDriver, type InMemoryDriverConfig, InMemoryStrategy, LocalStoragePersistenceAdapter, type MemoryAnalyticsConfig, MemoryAnalyticsService, type PersistenceAdapterInterface, _default as default };
package/dist/index.js CHANGED
@@ -182,6 +182,7 @@ var index_exports = {};
182
182
  __export(index_exports, {
183
183
  FileSystemPersistenceAdapter: () => FileSystemPersistenceAdapter,
184
184
  InMemoryDriver: () => InMemoryDriver,
185
+ InMemoryStrategy: () => InMemoryStrategy,
185
186
  LocalStoragePersistenceAdapter: () => LocalStoragePersistenceAdapter,
186
187
  MemoryAnalyticsService: () => MemoryAnalyticsService,
187
188
  default: () => index_default
@@ -208,9 +209,19 @@ var _InMemoryDriver = class _InMemoryDriver {
208
209
  this.transactions = /* @__PURE__ */ new Map();
209
210
  this.persistenceAdapter = null;
210
211
  this.supports = {
212
+ // Basic CRUD Operations
213
+ create: true,
214
+ read: true,
215
+ update: true,
216
+ delete: true,
217
+ // Bulk Operations
218
+ bulkCreate: true,
219
+ bulkUpdate: true,
220
+ bulkDelete: true,
211
221
  // Transaction & Connection Management
212
222
  transactions: true,
213
223
  // Snapshot-based transactions
224
+ savepoints: false,
214
225
  // Query Operations
215
226
  queryFilters: true,
216
227
  // Implemented via memory-matcher
@@ -224,19 +235,32 @@ var _InMemoryDriver = class _InMemoryDriver {
224
235
  // @planned: Window functions (ROW_NUMBER, RANK, etc.)
225
236
  querySubqueries: false,
226
237
  // @planned: Subquery execution
238
+ queryCTE: false,
227
239
  joins: false,
228
240
  // @planned: In-memory join operations
229
241
  // Advanced Features
230
242
  fullTextSearch: false,
231
243
  // @planned: Text tokenization + matching
232
- vectorSearch: false,
233
- // @planned: Cosine similarity search
234
- geoSpatial: false,
235
- // @planned: Distance/within calculations
244
+ jsonQuery: false,
245
+ geospatialQuery: false,
246
+ streaming: true,
247
+ // Implemented via findStream()
236
248
  jsonFields: true,
237
249
  // Native JS object support
238
- arrayFields: true
250
+ arrayFields: true,
239
251
  // Native JS array support
252
+ vectorSearch: false,
253
+ // @planned: Cosine similarity search
254
+ // Schema Management
255
+ schemaSync: true,
256
+ // Implemented via syncSchema()
257
+ batchSchemaSync: false,
258
+ migrations: false,
259
+ indexes: false,
260
+ // Performance & Optimization
261
+ connectionPooling: false,
262
+ preparedStatements: false,
263
+ queryCache: false
240
264
  };
241
265
  /**
242
266
  * The "Database": A map of TableName -> Array of Records
@@ -498,7 +522,7 @@ var _InMemoryDriver = class _InMemoryDriver {
498
522
  }
499
523
  if (count > 0) this.markDirty();
500
524
  this.logger.debug("UpdateMany completed", { object, count });
501
- return { count };
525
+ return count;
502
526
  }
503
527
  async deleteMany(object, query, options) {
504
528
  this.logger.debug("DeleteMany operation", { object, query });
@@ -520,7 +544,7 @@ var _InMemoryDriver = class _InMemoryDriver {
520
544
  const count = initialLength - this.db[object].length;
521
545
  if (count > 0) this.markDirty();
522
546
  this.logger.debug("DeleteMany completed", { object, count });
523
- return { count };
547
+ return count;
524
548
  }
525
549
  // Compatibility aliases
526
550
  async bulkUpdate(object, updates, options) {
@@ -1523,6 +1547,37 @@ ${stages}`;
1523
1547
  }
1524
1548
  };
1525
1549
 
1550
+ // src/in-memory-strategy.ts
1551
+ var InMemoryStrategy = class {
1552
+ constructor() {
1553
+ this.name = "InMemoryStrategy";
1554
+ this.priority = 30;
1555
+ }
1556
+ canHandle(query, ctx) {
1557
+ if (!query.cube) return false;
1558
+ if (ctx.fallbackService) return true;
1559
+ const caps = ctx.queryCapabilities(query.cube);
1560
+ return caps.inMemory;
1561
+ }
1562
+ async execute(query, ctx) {
1563
+ if (!ctx.fallbackService) {
1564
+ throw new Error(
1565
+ `[InMemoryStrategy] No fallback analytics service available for cube "${query.cube}". Register a MemoryAnalyticsService or configure a driver with analytics support.`
1566
+ );
1567
+ }
1568
+ return ctx.fallbackService.query(query);
1569
+ }
1570
+ async generateSql(query, ctx) {
1571
+ if (ctx.fallbackService?.generateSql) {
1572
+ return ctx.fallbackService.generateSql(query);
1573
+ }
1574
+ return {
1575
+ sql: `-- InMemoryStrategy: SQL generation not supported for cube "${query.cube}"`,
1576
+ params: []
1577
+ };
1578
+ }
1579
+ };
1580
+
1526
1581
  // src/index.ts
1527
1582
  var index_default = {
1528
1583
  id: "com.objectstack.driver.memory",
@@ -1543,6 +1598,7 @@ var index_default = {
1543
1598
  0 && (module.exports = {
1544
1599
  FileSystemPersistenceAdapter,
1545
1600
  InMemoryDriver,
1601
+ InMemoryStrategy,
1546
1602
  LocalStoragePersistenceAdapter,
1547
1603
  MemoryAnalyticsService
1548
1604
  });