⚠ Breaking Changes
-
Input validation enabled by default:
validateInputdefaults totrue- Database names are validated for security by default
- Prevents path traversal attempts and invalid characters
- To disable validation (not recommended), explicitly set
validateInput: false
-
Atomic writes enabled by default:
useAtomicWritesdefaults totrue- Uses temporary file + rename pattern for safer write operations
- Prevents data corruption during write operations
- Requires
validateInput: true(throws error if not met)
Added
-
Atomic file operations:
- Implemented atomic writes using temporary file + rename pattern
- Prevents data corruption during write operations
- Requires
validateInput: trueto enable - Configurable via
useAtomicWritessetting (default: true)
-
Input validation:
- Database names are validated for security
- Prevents path traversal attempts and invalid characters
- Configurable via
validateInputsetting (default: true)
-
Write debouncing:
- Automatic batching of rapid write operations
- Configurable delay via
writeDebouncesetting (default: 10ms) - Improves performance for applications with frequent updates
-
File size limits:
- Added
maxFileSizeconfiguration setting (default: 100MB) - Prevents memory issues with large datasets
- Warning at 80% of limit
- Grace threshold at 99% of limit
- At or above 100% of limit, saves the latest write and raises a critical error so the application can stop cleanly
- Added
-
Enhanced logging:
- Added log levels: error, warn, info, debug
- Configurable via
logLevelsetting (default: 'warn') - Errors are now logged based on logLevel setting
- Critical errors bypass all settings and shut down the application with extensive error messages
-
Database size monitoring:
- Added
sizemethod to retrieve the size of a database - Added
sizeStatusmethod with percent-of-limit and status labels - Supports getting sizes of a specified database, multiple specified databases, or all existing databases
- Returns detailed size information including byte count and formatted size
- Added
-
exists()method:- Check if a database exists without loading its data
- Returns
trueif database exists,falseotherwise - Example:
nyadb.exists('users')
-
clear()method:- Reset a database to an empty state without deleting the file
- Preserves the database file but clears all contents
- Example:
nyadb.clear('users')
-
rename()method:- Rename a database file from one name to another
- Returns
falseif source doesn't exist or target already exists - Example:
nyadb.rename('oldName', 'newName')
-
New configuration options:
validateInput(boolean, default: true)useAtomicWrites(boolean, default: true)maxFileSize(number, default: 100)writeDebounce(number, default: 10)logLevel(string, default: 'warn')
Improved
- Standardized return types: All top-level database methods now return boolean values (true/false) instead of undefined
- Return value consistency:
create()anddelete()methods now correctly returnfalsewhen database already exists or doesn't exist, respectively - Better error handling throughout the codebase
- More descriptive error messages
- Graceful handling of corrupted database files
- Updated TypeScript definitions with current default values
Fixed
- Temporary files are now properly skipped during database loading
- Improved cleanup of temporary files after write operations
Removed
- Removed
word-wrapoverride as the security issue has been resolved