@objectql/driver-fs 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.
- package/CHANGELOG.md +31 -0
- package/dist/index.d.ts +32 -167
- package/dist/index.js +145 -735
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
# Changelog
|
|
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,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
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,214 +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
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
-
*
|
|
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
|
-
|
|
58
|
+
protected loadAllFromDisk(): void;
|
|
80
59
|
/**
|
|
81
|
-
* Load
|
|
60
|
+
* Load records for an object type from disk
|
|
82
61
|
*/
|
|
83
|
-
|
|
62
|
+
protected loadRecordsFromDisk(objectName: string): any[];
|
|
84
63
|
/**
|
|
85
|
-
*
|
|
64
|
+
* Save records for an object type to disk
|
|
86
65
|
*/
|
|
87
|
-
|
|
66
|
+
protected saveRecordsToDisk(objectName: string, records: any[]): void;
|
|
88
67
|
/**
|
|
89
|
-
*
|
|
68
|
+
* Get file path for an object type
|
|
90
69
|
*/
|
|
91
|
-
|
|
70
|
+
protected getFilePath(objectName: string): string;
|
|
92
71
|
/**
|
|
93
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
80
|
+
* Override delete to persist to disk
|
|
114
81
|
*/
|
|
115
82
|
delete(objectName: string, id: string | number, options?: any): Promise<any>;
|
|
116
83
|
/**
|
|
117
|
-
*
|
|
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
|
-
|
|
86
|
+
find(objectName: string, query?: any, options?: any): Promise<any[]>;
|
|
145
87
|
/**
|
|
146
|
-
*
|
|
147
|
-
* Removes all JSON files in the data directory.
|
|
88
|
+
* Sync an object type's data to disk
|
|
148
89
|
*/
|
|
149
|
-
|
|
90
|
+
protected syncObjectToDisk(objectName: string): void;
|
|
150
91
|
/**
|
|
151
|
-
*
|
|
152
|
-
* Forces reload from file on next access.
|
|
92
|
+
* Clear cache for an object
|
|
153
93
|
*/
|
|
154
|
-
invalidateCache(objectName
|
|
94
|
+
invalidateCache(objectName?: string): void;
|
|
155
95
|
/**
|
|
156
|
-
* Get the
|
|
96
|
+
* Get the number of cached objects
|
|
157
97
|
*/
|
|
158
98
|
getCacheSize(): number;
|
|
159
99
|
/**
|
|
160
|
-
*
|
|
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 FilterNode from QueryAST to legacy filter format.
|
|
195
|
-
*
|
|
196
|
-
* @param node - The FilterNode to convert
|
|
197
|
-
* @returns Legacy filter array format
|
|
198
|
-
*/
|
|
199
|
-
private convertFilterNodeToLegacy;
|
|
200
|
-
/**
|
|
201
|
-
* Normalizes query format to support both legacy UnifiedQuery and QueryAST formats.
|
|
202
|
-
* This ensures backward compatibility while supporting the new @objectstack/spec interface.
|
|
203
|
-
*
|
|
204
|
-
* QueryAST format uses 'top' for limit, while UnifiedQuery uses 'limit'.
|
|
205
|
-
* QueryAST sort is array of {field, order}, while UnifiedQuery is array of [field, order].
|
|
100
|
+
* Clear data for a specific object or all data
|
|
206
101
|
*/
|
|
207
|
-
|
|
102
|
+
clear(objectName?: string): Promise<void>;
|
|
208
103
|
/**
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
* Supports ObjectQL filter format with logical operators (AND/OR):
|
|
212
|
-
* [
|
|
213
|
-
* ['field', 'operator', value],
|
|
214
|
-
* 'or',
|
|
215
|
-
* ['field2', 'operator', value2]
|
|
216
|
-
* ]
|
|
104
|
+
* Clear all data from the store and disk
|
|
217
105
|
*/
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* Check if a single record matches the filter conditions.
|
|
221
|
-
*/
|
|
222
|
-
private matchesFilters;
|
|
223
|
-
/**
|
|
224
|
-
* Evaluate a single filter condition.
|
|
225
|
-
*/
|
|
226
|
-
private evaluateCondition;
|
|
227
|
-
/**
|
|
228
|
-
* Apply sorting to an array of records.
|
|
229
|
-
*/
|
|
230
|
-
private applySort;
|
|
231
|
-
/**
|
|
232
|
-
* Project specific fields from a document.
|
|
233
|
-
*/
|
|
234
|
-
private projectFields;
|
|
235
|
-
/**
|
|
236
|
-
* Generate a unique ID for a record.
|
|
237
|
-
* Uses timestamp + counter for uniqueness.
|
|
238
|
-
* Note: For production use with high-frequency writes, consider using crypto.randomUUID().
|
|
239
|
-
*/
|
|
240
|
-
private generateId;
|
|
106
|
+
clearAll(): Promise<void>;
|
|
241
107
|
}
|
|
242
|
-
export {};
|