From 1e79f06d118fc1fb3d8c6d33f2911bfe3bd5ea4d Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Wed, 15 Oct 2025 12:32:56 -0600 Subject: [PATCH 01/10] dist/firestore/src/global_index.d.ts now includes pipelines in namespace 'pipelines' --- packages/firestore/rollup.config.js | 2 +- packages/firestore/src/global.ts | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 packages/firestore/src/global.ts diff --git a/packages/firestore/rollup.config.js b/packages/firestore/rollup.config.js index c9222f69ab4..6b43183c87c 100644 --- a/packages/firestore/rollup.config.js +++ b/packages/firestore/rollup.config.js @@ -214,7 +214,7 @@ const allBuilds = [ } }, { - input: 'dist/firestore/src/index.d.ts', + input: 'dist/firestore/src/global.d.ts', output: { file: 'dist/firestore/src/global_index.d.ts', format: 'es' diff --git a/packages/firestore/src/global.ts b/packages/firestore/src/global.ts new file mode 100644 index 00000000000..71c8fb86b4c --- /dev/null +++ b/packages/firestore/src/global.ts @@ -0,0 +1,23 @@ +/** + * @license + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// This file supports a special internal build that includes the entire +// Firestore classic and pipeline api surface in one bundle. + +export * from './api'; +import * as pipelines from './api_pipelines'; +export { pipelines }; From 4cee76e720e50ef20dc33ccc3c1a919aa2e10d9c Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Wed, 15 Oct 2025 14:10:38 -0600 Subject: [PATCH 02/10] Update global.ts --- packages/firestore/src/global.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/firestore/src/global.ts b/packages/firestore/src/global.ts index 71c8fb86b4c..f68d24b5241 100644 --- a/packages/firestore/src/global.ts +++ b/packages/firestore/src/global.ts @@ -19,5 +19,5 @@ // Firestore classic and pipeline api surface in one bundle. export * from './api'; -import * as pipelines from './api_pipelines'; +import * as pipelines from '../pipelines/pipelines'; export { pipelines }; From 704d2f743c767df2823caa720518fd3bcdbff943 Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Wed, 15 Oct 2025 16:59:48 -0600 Subject: [PATCH 03/10] Custom replacer plugin to remove declare module block from global.d.ts --- packages/firestore/rollup.config.js | 33 ++++++++++++++++++++++++++++- packages/firestore/src/global.ts | 2 +- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/packages/firestore/rollup.config.js b/packages/firestore/rollup.config.js index 6b43183c87c..b9db3922098 100644 --- a/packages/firestore/rollup.config.js +++ b/packages/firestore/rollup.config.js @@ -59,6 +59,35 @@ const browserPlugins = [ terser(util.manglePrivatePropertiesOptions) ]; +// TODO - update the implementation to match all content in the declare module block. +function declareModuleReplacePlugin() { + // The regex we created earlier + const moduleToReplace = + /declare module '\.\/\S+' \{\s+interface Firestore \{\s+pipeline\(\): PipelineSource;\s+}\s*}/gm; + + // What to replace it with (an empty string to remove it) + const replacement = + 'interface Firestore {pipeline(): PipelineSource;}'; + + return { + name: 'declare-module-replace', + generateBundle(options, bundle) { + const outputFileName = 'global_index.d.ts'; + if (!bundle[outputFileName]) { + console.warn( + `[regexReplacePlugin] File not found in bundle: ${outputFileName}` + ); + return; + } + + const chunk = bundle[outputFileName]; + if (chunk.type === 'chunk') { + chunk.code = chunk.code.replace(moduleToReplace, replacement); + } + } + }; +} + const allBuilds = [ // Intermediate Node ESM build without build target reporting // this is an intermediate build used to generate the actual esm and cjs builds @@ -222,7 +251,9 @@ const allBuilds = [ plugins: [ dts({ respectExternal: true - }) + }), + + declareModuleReplacePlugin() ] } ]; diff --git a/packages/firestore/src/global.ts b/packages/firestore/src/global.ts index f68d24b5241..529f43e022b 100644 --- a/packages/firestore/src/global.ts +++ b/packages/firestore/src/global.ts @@ -18,6 +18,6 @@ // This file supports a special internal build that includes the entire // Firestore classic and pipeline api surface in one bundle. +import * as pipelines from './api_pipelines'; export * from './api'; -import * as pipelines from '../pipelines/pipelines'; export { pipelines }; From 80caec9f76fb493005ea22b0f7b8eb592cecab3e Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Thu, 16 Oct 2025 13:58:56 -0600 Subject: [PATCH 04/10] Update CDN and g3 builds of Firestore to include Pipelines in the firebase-firestore.js file --- packages/firebase/firestore/index.ts | 3 +++ packages/firebase/package.json | 2 -- packages/firebase/rollup.config.js | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/firebase/firestore/index.ts b/packages/firebase/firestore/index.ts index 5d721c4e3b3..2247bdfebf5 100644 --- a/packages/firebase/firestore/index.ts +++ b/packages/firebase/firestore/index.ts @@ -16,3 +16,6 @@ */ export * from '@firebase/firestore'; + +import * as pipelines from '@firebase/firestore/pipelines'; +export { pipelines }; diff --git a/packages/firebase/package.json b/packages/firebase/package.json index 704b5395a40..67bd1deb559 100644 --- a/packages/firebase/package.json +++ b/packages/firebase/package.json @@ -476,9 +476,7 @@ "auth/web-extension", "functions", "firestore", - "firestore/pipelines", "firestore/lite", - "firestore/lite/pipelines", "installations", "storage", "performance", diff --git a/packages/firebase/rollup.config.js b/packages/firebase/rollup.config.js index f96ff01666c..9a9cacdf573 100644 --- a/packages/firebase/rollup.config.js +++ b/packages/firebase/rollup.config.js @@ -149,7 +149,7 @@ const cdnBuilds = [ .map(component => { // It is needed for handling sub modules, for example firestore/lite which should produce firebase-firestore-lite.js // Otherwise, we will create a directory with '/' in the name. - const componentName = component.replace('/', '-'); + const componentName = component.replaceAll('/', '-'); return { input: `${component}/index.ts`, From b11446cda34590d9ea8d98098670a9235d419d57 Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Thu, 16 Oct 2025 14:49:15 -0600 Subject: [PATCH 05/10] Updated CDN bundles so that firebase-firestore.js is not modified, but firebase-firestore-pipelines.js contains both classic and pipelines APIs. --- packages/firebase/firestore/index.ts | 3 --- packages/firebase/firestore/pipelines/index.ts | 5 ++++- packages/firebase/package.json | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/firebase/firestore/index.ts b/packages/firebase/firestore/index.ts index 2247bdfebf5..5d721c4e3b3 100644 --- a/packages/firebase/firestore/index.ts +++ b/packages/firebase/firestore/index.ts @@ -16,6 +16,3 @@ */ export * from '@firebase/firestore'; - -import * as pipelines from '@firebase/firestore/pipelines'; -export { pipelines }; diff --git a/packages/firebase/firestore/pipelines/index.ts b/packages/firebase/firestore/pipelines/index.ts index be062f16e96..81e81b39d81 100644 --- a/packages/firebase/firestore/pipelines/index.ts +++ b/packages/firebase/firestore/pipelines/index.ts @@ -15,4 +15,7 @@ * limitations under the License. */ -export * from '@firebase/firestore/pipelines'; +export * from '@firebase/firestore'; + +import * as pipelines from '@firebase/firestore/pipelines'; +export { pipelines }; diff --git a/packages/firebase/package.json b/packages/firebase/package.json index 67bd1deb559..349b9146829 100644 --- a/packages/firebase/package.json +++ b/packages/firebase/package.json @@ -477,6 +477,7 @@ "functions", "firestore", "firestore/lite", + "firestore/pipelines", "installations", "storage", "performance", From 78de11887201e8d9eb89eecd7631e6603a008080 Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Thu, 16 Oct 2025 16:17:52 -0600 Subject: [PATCH 06/10] Fix regression in _internalPipelineToExecutePipelineRequestProto --- .../src/remote/internal_serializer.ts | 23 +++++++++++++++++-- .../test/integration/api/pipeline.test.ts | 17 +++++++------- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/packages/firestore/src/remote/internal_serializer.ts b/packages/firestore/src/remote/internal_serializer.ts index 29a68620efc..1e759dab814 100644 --- a/packages/firestore/src/remote/internal_serializer.ts +++ b/packages/firestore/src/remote/internal_serializer.ts @@ -18,14 +18,23 @@ import { ensureFirestoreConfigured, Firestore } from '../api/database'; import { AggregateImpl } from '../core/aggregate'; import { queryToAggregateTarget, queryToTarget } from '../core/query'; +import { + StructuredPipeline, + StructuredPipelineOptions +} from '../core/structured_pipeline'; import { AggregateSpec } from '../lite-api/aggregate_types'; import { getDatastore } from '../lite-api/components'; import { Pipeline } from '../lite-api/pipeline'; import { Query } from '../lite-api/reference'; +import { ExecutePipelineRequest as ProtoExecutePipelineRequest } from '../protos/firestore_proto_api'; import { cast } from '../util/input_validation'; import { mapToArray } from '../util/obj'; -import { toQueryTarget, toRunAggregationQueryRequest } from './serializer'; +import { + getEncodedDatabaseId, + toQueryTarget, + toRunAggregationQueryRequest +} from './serializer'; /** * @internal @@ -112,5 +121,15 @@ export function _internalPipelineToExecutePipelineRequestProto( if (serializer === undefined) { return null; } - return pipeline._toProto(serializer); + + const structuredPipeline = new StructuredPipeline( + pipeline, + new StructuredPipelineOptions() + ); + const executePipelineRequest: ProtoExecutePipelineRequest = { + database: getEncodedDatabaseId(serializer), + structuredPipeline: structuredPipeline._toProto(serializer) + }; + + return executePipelineRequest; } diff --git a/packages/firestore/test/integration/api/pipeline.test.ts b/packages/firestore/test/integration/api/pipeline.test.ts index aab69008254..9ebf9ced4b5 100644 --- a/packages/firestore/test/integration/api/pipeline.test.ts +++ b/packages/firestore/test/integration/api/pipeline.test.ts @@ -346,18 +346,19 @@ const timestampDeltaMS = 1000; describe('console support', () => { it('supports internal serialization to proto', async () => { + // Perform the same test as the console const pipeline = firestore .pipeline() - .collection('books') - .where(equal('awards.hugo', true)) - .select( - 'title', - field('nestedField.level.1'), - mapGet('nestedField', 'level.1').mapGet('level.2').as('nested') - ); + .collection('customers') + .where(field('country').equal('United Kingdom')); const proto = _internalPipelineToExecutePipelineRequestProto(pipeline); - expect(proto).not.to.be.null; + + const expectedStructuredPipelineProto = + '{"pipeline":{"stages":[{"name":"collection","options":{},"args":[{"referenceValue":"/customers"}]},{"name":"where","options":{},"args":[{"functionValue":{"name":"equal","args":[{"fieldReferenceValue":"country"},{"stringValue":"United Kingdom"}]}}]}]}}'; + expect(JSON.stringify(proto.structuredPipeline)).to.equal( + expectedStructuredPipelineProto + ); }); }); From 81cae6d7830190fb68f601e7d1a481f5239b7363 Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Fri, 17 Oct 2025 09:44:11 -0600 Subject: [PATCH 07/10] Fixing missing paths in package.json --- packages/firebase/gulpfile.js | 2 +- packages/firebase/package.json | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/firebase/gulpfile.js b/packages/firebase/gulpfile.js index 4ea24182af2..e05345fbdf7 100644 --- a/packages/firebase/gulpfile.js +++ b/packages/firebase/gulpfile.js @@ -21,7 +21,7 @@ const replace = require('gulp-replace'); const pkgJson = require('./package.json'); const files = pkgJson.components.map(component => { - const componentName = component.replace('/', '-'); + const componentName = component.replaceAll('/', '-'); return `firebase-${componentName}.js`; }); const FIREBASE_APP_URL = `https://www.gstatic.com/firebasejs/${pkgJson.version}/firebase-app.js`; diff --git a/packages/firebase/package.json b/packages/firebase/package.json index 349b9146829..cab2a72f634 100644 --- a/packages/firebase/package.json +++ b/packages/firebase/package.json @@ -478,6 +478,7 @@ "firestore", "firestore/lite", "firestore/pipelines", + "firestore/lite/pipelines", "installations", "storage", "performance", From 8c2de70d310879fb96151cc15b01575a217a7eb7 Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Fri, 17 Oct 2025 10:34:11 -0600 Subject: [PATCH 08/10] Fix binary size script --- scripts/size_report/report_binary_size.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/size_report/report_binary_size.ts b/scripts/size_report/report_binary_size.ts index da1ad166702..34dce01924e 100644 --- a/scripts/size_report/report_binary_size.ts +++ b/scripts/size_report/report_binary_size.ts @@ -57,7 +57,7 @@ function generateReportForCDNScripts(): Report[] { ...special_files.map((file: string) => `${firebaseRoot}/${file}`), ...pkgJson.components.map( (component: string) => - `${firebaseRoot}/firebase-${component.replace('/', '-')}.js` + `${firebaseRoot}/firebase-${component.replaceAll('/', '-')}.js` ), ...compatPkgJson.components.map( (component: string) => `${firebaseRoot}/firebase-${component}-compat.js` From d6a9322da08d65edf75148b26dd88ec69608eaf1 Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Fri, 17 Oct 2025 15:43:00 -0600 Subject: [PATCH 09/10] Add support for index.cdn.ts files in packages/firebase. Then added a cdn.ts to packages/firebase/firestore/pipelines --- .../firebase/firestore/pipelines/index.cdn.ts | 21 +++++++++++++++++++ .../firebase/firestore/pipelines/index.ts | 5 +---- packages/firebase/rollup.config.js | 5 ++++- 3 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 packages/firebase/firestore/pipelines/index.cdn.ts diff --git a/packages/firebase/firestore/pipelines/index.cdn.ts b/packages/firebase/firestore/pipelines/index.cdn.ts new file mode 100644 index 00000000000..81e81b39d81 --- /dev/null +++ b/packages/firebase/firestore/pipelines/index.cdn.ts @@ -0,0 +1,21 @@ +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export * from '@firebase/firestore'; + +import * as pipelines from '@firebase/firestore/pipelines'; +export { pipelines }; diff --git a/packages/firebase/firestore/pipelines/index.ts b/packages/firebase/firestore/pipelines/index.ts index 81e81b39d81..be062f16e96 100644 --- a/packages/firebase/firestore/pipelines/index.ts +++ b/packages/firebase/firestore/pipelines/index.ts @@ -15,7 +15,4 @@ * limitations under the License. */ -export * from '@firebase/firestore'; - -import * as pipelines from '@firebase/firestore/pipelines'; -export { pipelines }; +export * from '@firebase/firestore/pipelines'; diff --git a/packages/firebase/rollup.config.js b/packages/firebase/rollup.config.js index 9a9cacdf573..87b9f7c834d 100644 --- a/packages/firebase/rollup.config.js +++ b/packages/firebase/rollup.config.js @@ -20,6 +20,7 @@ import commonjs from '@rollup/plugin-commonjs'; import json from '@rollup/plugin-json'; import pkg from './package.json'; import { resolve } from 'path'; +import { existsSync } from 'fs'; import resolveModule from '@rollup/plugin-node-resolve'; import rollupTypescriptPlugin from 'rollup-plugin-typescript2'; import sourcemaps from 'rollup-plugin-sourcemaps'; @@ -152,7 +153,9 @@ const cdnBuilds = [ const componentName = component.replaceAll('/', '-'); return { - input: `${component}/index.ts`, + input: existsSync(`${component}/index.cdn.ts`) + ? `${component}/index.cdn.ts` + : `${component}/index.ts`, output: { file: `firebase-${componentName}.js`, sourcemap: true, From 9c029f9c5f6aef9154bdf185fbd2ff8e5a7e9206 Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Mon, 20 Oct 2025 12:43:37 -0600 Subject: [PATCH 10/10] Rename grpc_connection.node.test.ts, so the file is filtered from browser unit testing. --- .../{grpc_connection.test.ts => grpc_connection.node.test.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename packages/firestore/test/unit/remote/{grpc_connection.test.ts => grpc_connection.node.test.ts} (100%) diff --git a/packages/firestore/test/unit/remote/grpc_connection.test.ts b/packages/firestore/test/unit/remote/grpc_connection.node.test.ts similarity index 100% rename from packages/firestore/test/unit/remote/grpc_connection.test.ts rename to packages/firestore/test/unit/remote/grpc_connection.node.test.ts