Skip to content

feat(firestore): split GAPIC from the firestore handwritten package#8928

Open
quirogas wants to merge 3 commits into
googleapis:mainfrom
quirogas:feat/disentangle-firestore-handwritten
Open

feat(firestore): split GAPIC from the firestore handwritten package#8928
quirogas wants to merge 3 commits into
googleapis:mainfrom
quirogas:feat/disentangle-firestore-handwritten

Conversation

@quirogas

@quirogas quirogas commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Decouple the handwritten Firestore wrapper from the auto-generated GAPIC client layer by importing a standalone version of the GAPIC library. Standalone -api packages are now generated and maintained independently.

  • Removed embedded GAPIC generated code (dev/src/v1/, dev/src/v1beta1/) and OwlBot files (owlbot.py, .OwlBot.yaml).
  • Added dependency on standalone @google-cloud/firestore-api (^0.2.0).
  • Re-exported v1, v1beta1, and protos from @google-cloud/firestore-api.
  • Implemented lazy getter wrappers on module.exports.v1 and module.exports.v1beta1 to preserve backwards-compatible constructor behavior (new firestorePkg.v1(...)).

Internal: b/531788771

@quirogas quirogas self-assigned this Jul 21, 2026
@product-auto-label product-auto-label Bot added the api: firestore Issues related to the Firestore API. label Jul 21, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request removes auto-generated configuration and proto files, transitioning the Firestore library to depend on the external @google-cloud/firestore-api package. Imports and lazy-loading getters for v1 and v1beta1 are updated accordingly. The review feedback highlights opportunities to optimize performance and code cleanliness: first, by directly requiring @google-cloud/firestore-api in the client factory to avoid repeatedly triggering lazy getters; and second, by caching the loaded modules in the lazy getters for v1 and v1beta1 to prevent redundant module loading and property copying on multiple accesses.

Comment thread handwritten/firestore/dev/src/index.ts
Comment thread handwritten/firestore/dev/src/index.ts
Comment thread handwritten/firestore/dev/src/index.ts
@quirogas
quirogas marked this pull request as ready for review July 23, 2026 18:05
@quirogas
quirogas requested a review from a team as a code owner July 23, 2026 18:05
// scope, we lazy-load the module.
get: () => require('./v1'),
get: () => {
const api = require('@google-cloud/firestore-api').v1;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will @google-cloud/firestore-api be published to NPM? If so, it may be preferred to deprecate this v1 property.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or simply remove this and the related type in ./types/...

get: () => require('./v1beta1'),
// scope, we lazy-load the module.
get: () => {
const api = require('@google-cloud/firestore-api').v1beta1;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will @google-cloud/firestore-api be published to NPM? If so, it may be preferred to deprecate this v1beta1 property.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or simply remove this and the related type in ./types/...

* @internal
* @name Firestore.GrpcStatus
* @type {function}
*/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this removal intentional? If so, can you clarify why?

)
s.replace(
"handwritten/firestore/types/protos/firestore_admin_v1_proto_api.d.ts",
'import Long = require\("long"\);',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO we need to understand why this replacement was made and determine if we need a new workaround


# Mark v1beta1 as deprecated
s.replace(
"handwritten/firestore/dev/src/v1beta1/firestore_client.ts",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may need to migrate this deprecation to the new implmementation, or simply mark the v1beta1 property deprecated in index.ts?

os.unlink('handwritten/firestore/dev/protos.js')
os.unlink('handwritten/firestore/dev/protos.d.ts')
os.unlink('handwritten/firestore/dev/protos.json')
subprocess.run('handwritten/firestore/dev/protos/update.sh', shell=True)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming we should also remove this script update.sh which is compiling the protos?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps even remove all of handwritten/firestore/dev/protos/... and handwritten/firestore/dev/protos.(js|d.ts|json)

return new (api.FirestoreClient as any)(...args);
};
return Object.assign(fn, api);
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering if we also need to update the related manually generated type exports in .types/firestore.d.ts lines 2990 - 3005

return new (api.FirestoreClient as any)(...args);
};
return Object.assign(fn, api);
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering if we also need to update the related manually generated type exports in .types/firestore.d.ts lines 2990 - 3005

shell.run(["npm", "run", "compile"], cwd="handwritten/firestore", hide_output=True)
s.copy("handwritten/firestore/build/src/v1/firestore*.d.ts", "handwritten/firestore/types/v1")
s.copy("handwritten/firestore/build/src/v1beta1/firestore_client.d.ts", "handwritten/firestore/types/v1beta1")
s.copy("handwritten/firestore/build/protos/firestore*.d.ts", "handwritten/firestore/types/protos")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

possibly also remove handwritten/firestore/types/v1, handwritten/firestore/types/v1beta1, handwritten/firestore/types/protos

source_location="build/src", test_project="node-gcloud-ci"
)

s.copy(templates, destination="handwritten/firestore", excludes=[".eslintrc.json", ".kokoro/**/*", ".github/CODEOWNERS", "README.md"])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the CODEOWNERS and README.md still getting generated with Librarian? Or are they even still useful with the new repo structure?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: firestore Issues related to the Firestore API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants