refactor(firestore): modernize internal proto call sites and eliminate local declarations (#9076) - #9076
Draft
quirogas wants to merge 2 commits into
Draft
Conversation
… callsite modernization (#8928)
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a new TypeScript declaration file, bundle.d.ts, defining the custom Firestore bundle persistence protocol types. The review feedback focuses on improving type safety across these declarations. Specifically, it is recommended to replace several any types for time-related fields (createTime and readTime) with a dedicated Timestamp interface, define that Timestamp interface, and restrict the limitType field to the specific string union values 'FIRST' | 'LAST'.
| } | ||
| export interface BundleMetadata { | ||
| id?: string | null; | ||
| createTime?: any | null; |
Contributor
| export interface NamedQuery { | ||
| name?: string | null; | ||
| bundledQuery?: BundledQuery | null; | ||
| readTime?: any | null; |
Contributor
| } | ||
| export interface BundledDocumentMetadata { | ||
| name?: string | null; | ||
| readTime?: any | null; |
Contributor
Comment on lines
+44
to
+48
| export interface BundledQuery { | ||
| parent?: string | null; | ||
| structuredQuery?: any | null; | ||
| limitType?: string | null; | ||
| } |
Contributor
There was a problem hiding this comment.
Define a Timestamp interface to represent protobuf Timestamps, and restrict limitType to the allowed string union values 'FIRST' | 'LAST' for better type safety.
export interface BundledQuery {
parent?: string | null;
structuredQuery?: any | null;
limitType?: 'FIRST' | 'LAST' | null;
}
export interface Timestamp {
seconds?: string | number | null;
nanos?: number | null;
}…e local declarations (#8928) - Remove dev/protos/firestore_v1_proto_api.* and dev/protos/v1.json to transition @google-cloud/firestore-api into our automated Single Source of Truth for TypeScript declarations - Extract custom offline bundle persistence interface definitions into standalone dev/src/bundle-proto.* modules - Update query operator dictionaries (directionOperators, comparisonOperators) and internal comparators to consume native GAPIC enum objects and 64-bit Long structures - Verify 100% clean compilation and passing unit test suites across watch, partition-query, aggregate-query, and transaction operations
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.
Part 4 of stacked disentanglement (#8928). Transition
@google-cloud/firestoreto directly consume@google-cloud/firestore-apias its native Single Source of Truth for TypeScript declarations, removing static checked-in local proto types.Background & Motivation
Historically,
dev/protos/update.shcompiled static TypeScript interfaces (firestore_v1_proto_api.d.ts) using custom build transformations:--force-enum-stringto convert protobuf numeric enums into string literal unions ('ASCENDING' | 'DESCENDING').Longreferences withstring.While this simplified early static method signatures, it created dependency on static checked-in declaration files that risk drifting out of sync as upstream protobuf definitions evolve over time. Transitioning directly to
@google-cloud/firestore-apiprovides continuous automated type generation without build script maintenance.Summary of Changes
dev/protos/firestore_v1_proto_api.d.ts,dev/protos/firestore_v1_proto_api.js, anddev/protos/v1.json, making@google-cloud/firestore-apiour native Single Source of Truth.bundle.proto), which belong strictly to the handwritten SDK wrapper and are independent of GAPIC models, into standalone local modules (dev/src/bundle-proto).directionOperators,comparisonOperators) and sorting algorithms to natively consume GAPIC enum objects and 64-bitLongstructures.Backward Compatibility Guarantee
orderBy.direction === 'ASCENDING' || orderBy.direction === api.StructuredQuery.Direction.ASCENDING) to support both literal strings and numeric GAPIC enums interchangeably.fallback: true),proto3-json-serializerinspects GAPIC reflection models and automatically translates numeric integer enum codes back into standard JSON string schema names before transmitting payloads over HTTP, guaranteeing zero regressions for REST consumers.Internal: b/531788771
📚 Stack Navigation Index