feat(firestore): typed dotted field paths in Query.where/orderBy - #84
Merged
Conversation
FieldKeys/FieldType now derive from FieldPathRecord (the type behind Repository.update's UpdateData), so nested map fields are addressable as 'metaData.type' with the leaf's type, following the same descent rules and MAX_FIELD_PATH_DEPTH. Runtime already accepted dotted paths in the admin, client and mock backends; this is type-only. Fixes #18 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Greptile SummaryThe PR adds typed dotted field paths to Firestore query constraints by sharing the existing update-path type derivation.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| packages/effect-firebase/src/lib/firestore/model/update-path.ts | Generalizes dotted-path derivation to class and recursive object types while nominally excluding atomic Firestore values. |
| packages/effect-firebase/src/lib/firestore/query/query.ts | Derives query field names and values from the shared dotted-path record types. |
| packages/effect-firebase/src/lib/firestore/model/update-path.spec.ts | Covers recursive interfaces, Schema.Class fields, atomic leaves, and structurally similar map values. |
| packages/effect-firebase/src/lib/firestore/query/query.spec.ts | Verifies dotted query paths, leaf typing, invalid paths, nested records, options, and class fields. |
| packages/effect-firebase/src/lib/firestore/schema/geopoint.ts | Adds a type-only nominal brand so GeoPoint remains an atomic field-path leaf. |
| packages/effect-firebase/src/lib/firestore/schema/reference.ts | Adds a type-only nominal brand so Reference remains an atomic field-path leaf. |
| packages/effect-firebase/src/lib/firestore/schema/timestamp.ts | Adds a type-only nominal brand so Timestamp remains an atomic field-path leaf. |
Reviews (3): Last reviewed commit: "fix(firestore): brand leaf classes so fi..." | Re-trigger Greptile
…e type level Replace the implicit-index-signature heuristic with an explicit FieldPathLeaf union (arrays, functions, DateTime, Timestamp, GeoPoint, Reference, sentinels, JS builtins); any other object type is a map. Aligns UpdateData/FieldPaths with resolveFieldPath, which already descended into Class declarations, and gives recursive interfaces typed paths too. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…minal
GeoPoint, Reference, Timestamp, Increment, ArrayUnion and ArrayRemove get a
type-only unique-symbol member. Without it, any struct sharing their field
shape (e.g. { path: string }) matched the FieldPathLeaf union structurally
and lost its dotted paths.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #18
Query.where('metaData.type', '==', 'post')now type-checks.FieldKeys<S>/FieldType<S, K>derive fromFieldPathRecord<S['Type']>, the type behindRepository.update'sUpdateData, so nested maps are addressable with dotted paths and the value is typed as the leaf. Same descent rules (structs,Model.Struct,Schema.Class,Record,suspend,Option; arrays/DateTime/class instances are leaves) and the sameMAX_FIELD_PATH_DEPTH.Type-only: admin/client pass
constraint.fieldstraight to the SDK, and the mock already resolves dotted paths.Exports
FieldPathRecord,FieldPaths,FieldPathTypefromFirestore.Note (pre-existing, unchanged): under contextual inference (
repo.query(Query.where(...)))Kwidens to the full key union, so the value is checked against the union of all field types rather than the exact leaf. Exact whenKis given explicitly.🤖 Generated with Claude Code