Skip to content

Conversation

@tobyhede
Copy link

No description provided.

Add comprehensive design document for Sequelize ORM integration with
Protect.js, covering:

- Hook-based transparent encryption using beforeFind/afterFind
- Custom DataType for eql_v2_encrypted composite type
- Schema extraction from Sequelize models
- Support for all comparison, range, and text search operators
- Automatic encryption/decryption with normal Sequelize syntax

Design leverages EQL's PostgreSQL operator classes for native operator
support without custom SQL generation.
Add detailed step-by-step implementation plan covering:
- Project scaffolding with package.json, tsconfig, tsup
- Custom ENCRYPTED DataType with composite type parsing
- Schema extraction from Sequelize models to Protect schemas
- beforeFind/afterFind hooks for transparent encryption/decryption
- Comprehensive tests for all components
- README documentation with usage examples

Plan includes TDD approach with failing tests first, minimal
implementations, and frequent commits.
- Fix TypeScript compilation errors with proper ENCRYPTEDConstructor interface
- Add error handling to parse() function for malformed composite type values
- Fix TokenFilter type inference with const assertion
- Scope registry to factory instance to prevent memory leaks and test pollution
- Update getEncryptedColumnConfig API to accept column instance parameter

All tests passing (11/11) and TypeScript compilation successful.

Addresses code review items B1, B2, and B3 from 2025-11-10-review.md
Implement bulkFromComposite() function that automatically detects and
parses composite type fields in Sequelize model objects, providing the
same ergonomic API as Drizzle's bulkDecryptModels.

Features:
- Automatic field detection for composite type values
- Handles Sequelize model instances and plain objects
- Supports nested objects and arrays
- Non-destructive (doesn't mutate originals)
- Type-safe with generics

Also includes:
- Comprehensive test suite (27 tests)
- Complete manual encryption guide
- Full API documentation

This provides an alternative to hooks for users who need manual control
over encryption workflows (raw SQL, performance optimization, debugging).
- Move MANUAL_ENCRYPTION_GUIDE.md and COMPOSITE_TYPE_UTILITIES.md to docs/sequelize/
- Update README.md links to point to new documentation locations
- Add comprehensive code review document (76 tests passing, production-ready)
- Add complete production-quality README with installation, usage, API docs, and troubleshooting

This cleanup organizes documentation properly while adding the code review
results and final README for the sequelize integration.
- Add 13 new tests for error handling, partial failures, and mock improvements (63→76 tests)
- Enhance raw SQL example in README with complete workflow
- Standardize error message formatting in schema-extraction
- Add explanatory comment in hooks for parsing optimization
- Add biome.json configuration to manage linter rules appropriately
- Improve test isolation with input-based mock implementations

All tests passing. Non-blocking improvements from code review.
- Update tsconfig.json and tsup.config.ts for compilation settings
- Remove MANUAL_ENCRYPTION_GUIDE.md (moved to docs/)
- Update pnpm-lock.yaml with new dependencies
- Update implementation plan with progress notes

Configuration updates to support the sequelize integration features.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants