firestore-typesense-search
firestore-typesense-search copied to clipboard
Add document transformation capability for indexing
TLDR
New options to transform Firestore documents before indexing to Typesense.
Change Summary
Added Configuration:
-
In
extension.yaml:- Added 4 new configuration parameters:
-
TRANSFORM_FUNCTION_NAME: Name of Cloud Function for document transformation -
TRANSFORM_FUNCTION_PROJECT_ID: Project where transform function is deployed -
TRANSFORM_FUNCTION_REGION: Region of transform function -
TRANSFORM_FUNCTION_SECRET: Auth secret for transform function
-
- Added 4 new configuration parameters:
Added Functionality:
-
In
utils.js:- Added
transformDocument(): Calls external transform function with error handling - Implements fallback to original document when transformation fails
- Added
-
In
indexOnWrite.js:- Updated to conditionally use document transformation before indexing
- Added branch to handle transformed vs. non-transformed document flow
Added Tests:
-
New file
test/utilsTransform.spec.js:- Tests for transform function with various scenarios:
- Success path with proper transformation
- Handling missing transform function configuration
- Error handling for failed transformations
- Edge cases like documents without IDs
- Tests for transform function with various scenarios:
-
In
package.json:- Added new test command:
test:utils
- Added new test command:
PR Checklist
- [x] I have read and signed the Contributor License Agreement.