@objectql/driver-excel 4.0.1 → 4.0.3

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.
@@ -0,0 +1,4 @@
1
+
2
+ > @objectql/driver-excel@4.0.3 build /home/runner/work/objectql/objectql/packages/drivers/excel
3
+ > tsc
4
+
package/CHANGELOG.md CHANGED
@@ -1,5 +1,36 @@
1
1
  # @objectql/driver-excel
2
2
 
3
+ ## 4.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - **Patch Release v4.0.3**
8
+
9
+ This patch release includes infrastructure improvements and development experience enhancements:
10
+ - Refactored dev server setup for improved configuration handling
11
+ - Enhanced example scripts and development workflow
12
+ - Updated build and test infrastructure
13
+ - Improved documentation and developer tools
14
+ - Bug fixes and stability improvements
15
+
16
+ - Updated dependencies
17
+ - @objectql/driver-memory@4.0.3
18
+ - @objectql/types@4.0.3
19
+
20
+ ## 4.0.2
21
+
22
+ ### Patch Changes
23
+
24
+ - **Patch Release v4.0.2**
25
+
26
+ This patch release includes:
27
+ - Infrastructure improvements and maintenance updates
28
+ - Enhanced stability and reliability
29
+ - Bug fixes and performance optimizations
30
+
31
+ - Updated dependencies
32
+ - @objectql/types@4.0.2
33
+
3
34
  ## 4.0.1
4
35
 
5
36
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1,60 +1,5 @@
1
- import { Data } from '@objectstack/spec';
2
- type QueryAST = Data.QueryAST;
3
- /**
4
- * ObjectQL
5
- * Copyright (c) 2026-present ObjectStack Inc.
6
- *
7
- * This source code is licensed under the MIT license found in the
8
- * LICENSE file in the root directory of this source tree.
9
- */
10
- /**
11
- * Excel Driver for ObjectQL (Production-Ready)
12
- *
13
- * A driver for ObjectQL that reads and writes data from Excel (.xlsx) files.
14
- * Each worksheet in the Excel file represents an object type, with the first row
15
- * containing column headers (field names) and subsequent rows containing data.
16
- *
17
- * ✅ Features:
18
- * - Read data from Excel files
19
- * - Write data back to Excel files
20
- * - Multiple sheets support (one sheet per object type)
21
- * - Full CRUD operations
22
- * - Query support (filters, sorting, pagination)
23
- * - Automatic data type handling
24
- * - Secure: Uses ExcelJS (no known vulnerabilities)
25
- *
26
- * Use Cases:
27
- * - Import/export data from Excel spreadsheets
28
- * - Use Excel as a simple database for prototyping
29
- * - Data migration from Excel to other databases
30
- * - Generate reports in Excel format
31
- */
32
- import { Driver } from '@objectql/types';
33
- /**
34
- * Command interface for executeCommand method
35
- */
36
- export interface Command {
37
- type: 'create' | 'update' | 'delete' | 'bulkCreate' | 'bulkUpdate' | 'bulkDelete';
38
- object: string;
39
- data?: any;
40
- id?: string | number;
41
- ids?: Array<string | number>;
42
- records?: any[];
43
- updates?: Array<{
44
- id: string | number;
45
- data: any;
46
- }>;
47
- options?: any;
48
- }
49
- /**
50
- * Command result interface
51
- */
52
- export interface CommandResult {
53
- success: boolean;
54
- data?: any;
55
- affected: number;
56
- error?: string;
57
- }
1
+ import { MemoryDriver, MemoryDriverConfig, Command, CommandResult } from '@objectql/driver-memory';
2
+ export type { Command, CommandResult };
58
3
  /**
59
4
  * File storage mode for the Excel driver.
60
5
  */
@@ -62,7 +7,7 @@ export type FileStorageMode = 'single-file' | 'file-per-object';
62
7
  /**
63
8
  * Configuration options for the Excel driver.
64
9
  */
65
- export interface ExcelDriverConfig {
10
+ export interface ExcelDriverConfig extends MemoryDriverConfig {
66
11
  /**
67
12
  * Path to the Excel file or directory.
68
13
  * - In 'single-file' mode: Path to a single .xlsx file
@@ -79,14 +24,17 @@ export interface ExcelDriverConfig {
79
24
  autoSave?: boolean;
80
25
  /** Optional: Create file if it doesn't exist (default: true) */
81
26
  createIfMissing?: boolean;
82
- /** Optional: Enable strict mode (throw on missing objects) */
83
- strictMode?: boolean;
84
27
  }
85
28
  /**
86
29
  * Excel Driver Implementation
87
30
  *
88
- * Stores ObjectQL documents in Excel worksheets. Each object type is stored
89
- * in a separate worksheet, with the first row containing column headers.
31
+ * Extends MemoryDriver with Excel file persistence.
32
+ * All query and aggregation logic is inherited from MemoryDriver.
33
+ * Only the persistence layer (load/save) is overridden.
34
+ *
35
+ * Stores ObjectQL documents in Excel worksheets with format:
36
+ * - Single-file mode: All objects as worksheets in one .xlsx file
37
+ * - File-per-object mode: Each object in a separate .xlsx file
90
38
  *
91
39
  * Uses ExcelJS library for secure Excel file operations.
92
40
  *
@@ -94,29 +42,14 @@ export interface ExcelDriverConfig {
94
42
  * the standard DriverInterface from @objectstack/spec for compatibility
95
43
  * with the new kernel-based plugin system.
96
44
  */
97
- export declare class ExcelDriver implements Driver {
98
- readonly name = "ExcelDriver";
99
- readonly version = "4.0.0";
100
- readonly supports: {
101
- transactions: boolean;
102
- joins: boolean;
103
- fullTextSearch: boolean;
104
- jsonFields: boolean;
105
- arrayFields: boolean;
106
- queryFilters: boolean;
107
- queryAggregations: boolean;
108
- querySorting: boolean;
109
- queryPagination: boolean;
110
- queryWindowFunctions: boolean;
111
- querySubqueries: boolean;
112
- };
113
- private config;
114
- private workbook;
115
- private workbooks;
116
- private data;
117
- private idCounters;
45
+ export declare class ExcelDriver extends MemoryDriver {
118
46
  private filePath;
119
47
  private fileStorageMode;
48
+ private autoSave;
49
+ private createIfMissing;
50
+ private workbook;
51
+ private workbooks;
52
+ private fileLocks;
120
53
  constructor(config: ExcelDriverConfig);
121
54
  /**
122
55
  * Initialize the driver by loading the workbook from file.
@@ -125,56 +58,42 @@ export declare class ExcelDriver implements Driver {
125
58
  init(): Promise<void>;
126
59
  /**
127
60
  * Connect to the database (for DriverInterface compatibility)
128
- * This calls init() to load the workbook.
129
61
  */
130
62
  connect(): Promise<void>;
131
- /**
132
- * Check database connection health
133
- */
134
- checkHealth(): Promise<boolean>;
135
63
  /**
136
64
  * Factory method to create and initialize the driver.
137
65
  */
138
66
  static create(config: ExcelDriverConfig): Promise<ExcelDriver>;
67
+ /**
68
+ * Check database connection health
69
+ */
70
+ checkHealth(): Promise<boolean>;
139
71
  /**
140
72
  * Load workbook from file or create a new one.
141
- * Handles both single-file and file-per-object modes.
142
73
  */
143
74
  private loadWorkbook;
144
75
  /**
145
- * Load workbook in single-file mode (all objects in one Excel file).
76
+ * Load workbook in single-file mode.
146
77
  */
147
78
  private loadSingleFileWorkbook;
148
79
  /**
149
- * Load workbooks in file-per-object mode (each object in separate Excel file).
80
+ * Load workbooks in file-per-object mode.
150
81
  */
151
82
  private loadFilePerObjectWorkbooks;
152
83
  /**
153
- * Load data from workbook into memory.
154
- *
155
- * Expected Excel format:
156
- * - First row contains column headers (field names)
157
- * - Subsequent rows contain data records
158
- * - Each worksheet represents one object type
84
+ * Load all data from single-file workbook into memory.
159
85
  */
160
86
  private loadDataFromWorkbook;
161
87
  /**
162
- * Load data from a single worksheet into memory.
163
- */
164
- private loadDataFromSingleWorksheet;
165
- /**
166
- * Update ID counter based on existing records.
167
- *
168
- * Attempts to extract counter from auto-generated IDs (format: objectName-timestamp-counter).
169
- * If IDs don't follow this format, counter starts from existing record count.
88
+ * Load data from workbook for a specific object.
170
89
  */
171
- private updateIdCounter;
90
+ private loadDataFromWorkbookForObject;
172
91
  /**
173
- * Save workbook to file.
92
+ * Parse worksheet into array of records.
174
93
  */
94
+ private parseWorksheet;
175
95
  /**
176
96
  * Save workbook to file.
177
- * Handles both single-file and file-per-object modes.
178
97
  */
179
98
  private saveWorkbook;
180
99
  /**
@@ -186,9 +105,7 @@ export declare class ExcelDriver implements Driver {
186
105
  */
187
106
  private saveFilePerObjectWorkbook;
188
107
  /**
189
- * Sync in-memory data to workbook.
190
- *
191
- * Creates or updates a worksheet for the given object type.
108
+ * Sync in-memory data to workbook and save.
192
109
  */
193
110
  private syncToWorkbook;
194
111
  /**
@@ -200,128 +117,35 @@ export declare class ExcelDriver implements Driver {
200
117
  */
201
118
  private syncToFilePerObjectWorkbook;
202
119
  /**
203
- * Find multiple records matching the query criteria.
204
- */
205
- find(objectName: string, query?: any, options?: any): Promise<any[]>;
206
- /**
207
- * Find a single record by ID or query.
208
- */
209
- findOne(objectName: string, id: string | number, query?: any, options?: any): Promise<any>;
210
- /**
211
- * Create a new record.
120
+ * Get all records for an object from memory store.
212
121
  */
213
- create(objectName: string, data: any, options?: any): Promise<any>;
122
+ private getObjectRecords;
214
123
  /**
215
- * Update an existing record.
124
+ * Populate worksheet with records.
216
125
  */
217
- update(objectName: string, id: string | number, data: any, options?: any): Promise<any>;
218
- /**
219
- * Delete a record.
220
- */
221
- delete(objectName: string, id: string | number, options?: any): Promise<any>;
126
+ private populateWorksheet;
222
127
  /**
223
- * Count records matching filters.
128
+ * Simple file locking mechanism.
224
129
  */
225
- count(objectName: string, filters: any, options?: any): Promise<number>;
130
+ private acquireLock;
226
131
  /**
227
- * Get distinct values for a field.
132
+ * Release file lock.
228
133
  */
229
- distinct(objectName: string, field: string, filters?: any, options?: any): Promise<any[]>;
134
+ private releaseLock;
230
135
  /**
231
- * Create multiple records at once.
136
+ * Override create to persist to Excel.
232
137
  */
233
- createMany(objectName: string, data: any[], options?: any): Promise<any>;
234
- /**
235
- * Update multiple records matching filters.
236
- */
237
- updateMany(objectName: string, filters: any, data: any, options?: any): Promise<any>;
138
+ create(objectName: string, data: any, options?: any): Promise<any>;
238
139
  /**
239
- * Delete multiple records matching filters.
140
+ * Override update to persist to Excel.
240
141
  */
241
- deleteMany(objectName: string, filters: any, options?: any): Promise<any>;
142
+ update(objectName: string, id: string | number, data: any, options?: any): Promise<any>;
242
143
  /**
243
- * Manually save the workbook to file.
144
+ * Override delete to persist to Excel.
244
145
  */
146
+ delete(objectName: string, id: string | number, options?: any): Promise<any>;
245
147
  /**
246
- * Manually save the workbook to file.
148
+ * Manually save all data to Excel file(s).
247
149
  */
248
150
  save(): Promise<void>;
249
- /**
250
- * Disconnect (flush any pending writes).
251
- */
252
- disconnect(): Promise<void>;
253
- /**
254
- * Execute a query using QueryAST (DriverInterface v4.0 method)
255
- *
256
- * This method handles all query operations using the standard QueryAST format
257
- * from @objectstack/spec. It converts the AST to the legacy query format
258
- * and delegates to the existing find() method.
259
- *
260
- * @param ast - The query AST to execute
261
- * @param options - Optional execution options
262
- * @returns Query results with value array and count
263
- */
264
- executeQuery(ast: QueryAST, options?: any): Promise<{
265
- value: any[];
266
- count?: number;
267
- }>;
268
- /**
269
- * Execute a command (DriverInterface v4.0 method)
270
- *
271
- * This method handles all mutation operations (create, update, delete)
272
- * using a unified command interface.
273
- *
274
- * @param command - The command to execute
275
- * @param options - Optional execution options
276
- * @returns Command execution result
277
- */
278
- executeCommand(command: Command, options?: any): Promise<CommandResult>;
279
- /**
280
- * Execute raw command (for compatibility)
281
- *
282
- * @param command - Command string or object
283
- * @param parameters - Command parameters
284
- * @param options - Execution options
285
- */
286
- execute(command: any, parameters?: any[], options?: any): Promise<any>;
287
- /**
288
- * Convert FilterNode from QueryAST to legacy filter format.
289
- *
290
- * @param node - The FilterNode to convert
291
- * @returns Legacy filter array format
292
- */
293
- private convertFilterNodeToLegacy;
294
- /**
295
- * Normalizes query format to support both legacy UnifiedQuery and QueryAST formats.
296
- * This ensures backward compatibility while supporting the new @objectstack/spec interface.
297
- *
298
- * QueryAST format uses 'top' for limit, while UnifiedQuery uses 'limit'.
299
- * QueryAST sort is array of {field, order}, while UnifiedQuery is array of [field, order].
300
- */
301
- private normalizeQuery;
302
- /**
303
- * Apply filters to an array of records (in-memory filtering).
304
- */
305
- private applyFilters;
306
- /**
307
- * Check if a single record matches the filter conditions.
308
- */
309
- private matchesFilters;
310
- /**
311
- * Evaluate a single filter condition.
312
- */
313
- private evaluateCondition;
314
- /**
315
- * Apply sorting to an array of records.
316
- */
317
- private applySort;
318
- /**
319
- * Project specific fields from a document.
320
- */
321
- private projectFields;
322
- /**
323
- * Generate a unique ID for a record.
324
- */
325
- private generateId;
326
151
  }
327
- export {};