@objectql/driver-fs 4.0.2 → 4.0.4

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,65 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.0.4
4
+
5
+ ### Patch Changes
6
+
7
+ - **Patch Release v4.0.4**
8
+
9
+ This patch release includes bug fixes, driver improvements, and enhanced test coverage:
10
+
11
+ ### Driver Improvements
12
+ - **MongoDB Driver**: Fixed bulk operations, transaction support, and type safety improvements
13
+ - **FileSystem Driver**: Fixed TCK test compatibility with dataDir parameter
14
+ - **SQL Driver**: Enhanced TCK test compatibility and fixed test failures
15
+ - **Redis Driver**: Improved TCK test configuration and dependencies
16
+ - **Driver Utils**: Added shared utilities package for cross-driver functionality
17
+
18
+ ### Testing & Quality
19
+ - Added comprehensive TCK (Technology Compatibility Kit) compliance tests for all drivers
20
+ - Expanded TCK test suite to 30+ comprehensive tests
21
+ - Enhanced test infrastructure with better error handling
22
+ - Added --passWithNoTests flag for packages without tests
23
+
24
+ ### Type Safety
25
+ - Improved type safety in MongoDB driver update methods
26
+ - Better handling of atomic operators in MongoDB driver
27
+ - Enhanced type definitions across driver layer
28
+
29
+ ### Documentation
30
+ - Added comprehensive driver documentation
31
+ - Enhanced official documentation with Phase 2 implementation summaries
32
+ - Improved protocol layer documentation
33
+
34
+ ### Infrastructure
35
+ - Standardized driver layer implementation
36
+ - Enhanced protocol layer with better abstraction
37
+ - Improved GitHub Actions workflow configurations
38
+ - Better CI/CD pipeline stability
39
+
40
+ This release maintains full backward compatibility with v4.0.3.
41
+
42
+ - Updated dependencies
43
+ - @objectql/driver-memory@4.0.4
44
+ - @objectql/types@4.0.4
45
+
46
+ ## 4.0.3
47
+
48
+ ### Patch Changes
49
+
50
+ - **Patch Release v4.0.3**
51
+
52
+ This patch release includes infrastructure improvements and development experience enhancements:
53
+ - Refactored dev server setup for improved configuration handling
54
+ - Enhanced example scripts and development workflow
55
+ - Updated build and test infrastructure
56
+ - Improved documentation and developer tools
57
+ - Bug fixes and stability improvements
58
+
59
+ - Updated dependencies
60
+ - @objectql/driver-memory@4.0.3
61
+ - @objectql/types@4.0.3
62
+
3
63
  ## 4.0.2
4
64
 
5
65
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1,6 +1,4 @@
1
- import { Data } from '@objectstack/spec';
2
- type QueryAST = Data.QueryAST;
3
- import { Driver } from '@objectql/types';
1
+ import { MemoryDriver, MemoryDriverConfig } from '@objectql/driver-memory';
4
2
  /**
5
3
  * Command interface for executeCommand method
6
4
  */
@@ -29,218 +27,81 @@ export interface CommandResult {
29
27
  /**
30
28
  * Configuration options for the FileSystem driver.
31
29
  */
32
- export interface FileSystemDriverConfig {
30
+ export interface FileSystemDriverConfig extends MemoryDriverConfig {
33
31
  /** Directory path where JSON files will be stored */
34
32
  dataDir: string;
35
33
  /** Optional: Enable pretty-print JSON for readability (default: true) */
36
34
  prettyPrint?: boolean;
37
35
  /** Optional: Enable backup files on write (default: true) */
38
36
  enableBackup?: boolean;
39
- /** Optional: Enable strict mode (throw on missing objects) */
40
- strictMode?: boolean;
41
- /** Optional: Initial data to populate the store */
42
- initialData?: Record<string, any[]>;
43
37
  }
44
38
  /**
45
39
  * FileSystem Driver Implementation
46
40
  *
41
+ * Extends MemoryDriver with file system persistence.
42
+ * All query and aggregation logic is inherited from MemoryDriver.
43
+ * Only the persistence layer (load/save) is overridden.
44
+ *
47
45
  * Stores ObjectQL documents in JSON files with format:
48
46
  * - File: `{dataDir}/{objectName}.json`
49
47
  * - Content: Array of records `[{id: "1", ...}, {id: "2", ...}]`
50
48
  */
51
- export declare class FileSystemDriver implements Driver {
52
- readonly name = "FileSystemDriver";
53
- readonly version = "4.0.0";
54
- readonly supports: {
55
- transactions: boolean;
56
- joins: boolean;
57
- fullTextSearch: boolean;
58
- jsonFields: boolean;
59
- arrayFields: boolean;
60
- queryFilters: boolean;
61
- queryAggregations: boolean;
62
- querySorting: boolean;
63
- queryPagination: boolean;
64
- queryWindowFunctions: boolean;
65
- querySubqueries: boolean;
66
- };
67
- private config;
68
- private idCounters;
49
+ export declare class FileSystemDriver extends MemoryDriver {
50
+ private dataDir;
51
+ private prettyPrint;
52
+ private enableBackup;
69
53
  private cache;
70
54
  constructor(config: FileSystemDriverConfig);
71
55
  /**
72
- * Connect to the database (for DriverInterface compatibility)
73
- * This is a no-op for filesystem driver as there's no external connection.
74
- */
75
- connect(): Promise<void>;
76
- /**
77
- * Check database connection health
56
+ * Load all JSON files from disk into memory
78
57
  */
79
- checkHealth(): Promise<boolean>;
58
+ protected loadAllFromDisk(): void;
80
59
  /**
81
- * Load initial data into the store.
60
+ * Load records for an object type from disk
82
61
  */
83
- private loadInitialData;
62
+ protected loadRecordsFromDisk(objectName: string): any[];
84
63
  /**
85
- * Get the file path for an object type.
64
+ * Save records for an object type to disk
86
65
  */
87
- private getFilePath;
66
+ protected saveRecordsToDisk(objectName: string, records: any[]): void;
88
67
  /**
89
- * Load records from file into memory cache.
68
+ * Get file path for an object type
90
69
  */
91
- private loadRecords;
70
+ protected getFilePath(objectName: string): string;
92
71
  /**
93
- * Save records to file with atomic write strategy.
94
- */
95
- private saveRecords;
96
- /**
97
- * Find multiple records matching the query criteria.
98
- */
99
- find(objectName: string, query?: any, options?: any): Promise<any[]>;
100
- /**
101
- * Find a single record by ID or query.
102
- */
103
- findOne(objectName: string, id: string | number, query?: any, options?: any): Promise<any>;
104
- /**
105
- * Create a new record.
72
+ * Override create to persist to disk
106
73
  */
107
74
  create(objectName: string, data: any, options?: any): Promise<any>;
108
75
  /**
109
- * Update an existing record.
76
+ * Override update to persist to disk
110
77
  */
111
78
  update(objectName: string, id: string | number, data: any, options?: any): Promise<any>;
112
79
  /**
113
- * Delete a record.
80
+ * Override delete to persist to disk
114
81
  */
115
82
  delete(objectName: string, id: string | number, options?: any): Promise<any>;
116
83
  /**
117
- * Count records matching filters.
118
- */
119
- count(objectName: string, filters: any, options?: any): Promise<number>;
120
- /**
121
- * Get distinct values for a field.
122
- */
123
- distinct(objectName: string, field: string, filters?: any, options?: any): Promise<any[]>;
124
- /**
125
- * Create multiple records at once.
126
- */
127
- createMany(objectName: string, data: any[], options?: any): Promise<any>;
128
- /**
129
- * Update multiple records matching filters.
130
- */
131
- updateMany(objectName: string, filters: any, data: any, options?: any): Promise<any>;
132
- /**
133
- * Delete multiple records matching filters.
134
- */
135
- deleteMany(objectName: string, filters: any, options?: any): Promise<any>;
136
- /**
137
- * Disconnect (flush cache).
138
- */
139
- disconnect(): Promise<void>;
140
- /**
141
- * Clear all data from a specific object.
142
- * Useful for testing or data reset scenarios.
84
+ * Override find to load from disk if not in cache
143
85
  */
144
- clear(objectName: string): Promise<void>;
86
+ find(objectName: string, query?: any, options?: any): Promise<any[]>;
145
87
  /**
146
- * Clear all data from all objects.
147
- * Removes all JSON files in the data directory.
88
+ * Sync an object type's data to disk
148
89
  */
149
- clearAll(): Promise<void>;
90
+ protected syncObjectToDisk(objectName: string): void;
150
91
  /**
151
- * Invalidate cache for a specific object.
152
- * Forces reload from file on next access.
92
+ * Clear cache for an object
153
93
  */
154
- invalidateCache(objectName: string): void;
94
+ invalidateCache(objectName?: string): void;
155
95
  /**
156
- * Get the size of the cache (number of objects cached).
96
+ * Get the number of cached objects
157
97
  */
158
98
  getCacheSize(): number;
159
99
  /**
160
- * Execute a query using QueryAST (DriverInterface v4.0 method)
161
- *
162
- * This method handles all query operations using the standard QueryAST format
163
- * from @objectstack/spec. It converts the AST to the legacy query format
164
- * and delegates to the existing find() method.
165
- *
166
- * @param ast - The query AST to execute
167
- * @param options - Optional execution options
168
- * @returns Query results with value array and count
169
- */
170
- executeQuery(ast: QueryAST, options?: any): Promise<{
171
- value: any[];
172
- count?: number;
173
- }>;
174
- /**
175
- * Execute a command (DriverInterface v4.0 method)
176
- *
177
- * This method handles all mutation operations (create, update, delete)
178
- * using a unified command interface.
179
- *
180
- * @param command - The command to execute
181
- * @param options - Optional execution options
182
- * @returns Command execution result
183
- */
184
- executeCommand(command: Command, options?: any): Promise<CommandResult>;
185
- /**
186
- * Execute raw command (for compatibility)
187
- *
188
- * @param command - Command string or object
189
- * @param parameters - Command parameters
190
- * @param options - Execution options
191
- */
192
- execute(command: any, parameters?: any[], options?: any): Promise<any>;
193
- /**
194
- * Convert FilterCondition (MongoDB-like format) to legacy array format.
195
- * This allows the fs driver to use its existing filter evaluation logic.
196
- *
197
- * @param condition - FilterCondition object or legacy array
198
- * @returns Legacy filter array format
199
- */
200
- private convertFilterConditionToArray;
201
- /**
202
- * Normalizes query format to support both legacy UnifiedQuery and QueryAST formats.
203
- * This ensures backward compatibility while supporting the new @objectstack/spec interface.
204
- *
205
- * QueryAST format uses:
206
- * - 'where' with MongoDB-like filters (convert to 'filters' array)
207
- * - 'orderBy' with array of {field, order} (convert to 'sort' with [field, order])
208
- * - 'offset' (convert to 'skip')
209
- * - 'top' (convert to 'limit')
100
+ * Clear data for a specific object or all data
210
101
  */
211
- private normalizeQuery;
102
+ clear(objectName?: string): Promise<void>;
212
103
  /**
213
- * Apply filters to an array of records.
214
- *
215
- * Supports ObjectQL filter format with logical operators (AND/OR):
216
- * [
217
- * ['field', 'operator', value],
218
- * 'or',
219
- * ['field2', 'operator', value2]
220
- * ]
104
+ * Clear all data from the store and disk
221
105
  */
222
- private applyFilters;
223
- /**
224
- * Check if a single record matches the filter conditions.
225
- */
226
- private matchesFilters;
227
- /**
228
- * Evaluate a single filter condition.
229
- */
230
- private evaluateCondition;
231
- /**
232
- * Apply sorting to an array of records.
233
- */
234
- private applySort;
235
- /**
236
- * Project specific fields from a document.
237
- */
238
- private projectFields;
239
- /**
240
- * Generate a unique ID for a record.
241
- * Uses timestamp + counter for uniqueness.
242
- * Note: For production use with high-frequency writes, consider using crypto.randomUUID().
243
- */
244
- private generateId;
106
+ clearAll(): Promise<void>;
245
107
  }
246
- export {};