Skip to content

Commit f251a04

Browse files
committed
Update the typings export for pipelines and lite pipelines so that it auguments the Firestore and Query classes.
1 parent ea5c8e1 commit f251a04

File tree

5 files changed

+63
-10
lines changed

5 files changed

+63
-10
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* @license
3+
* Copyright 2024 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
import {PipelineSource, Pipeline} from "../../dist/lite/pipelines";
18+
19+
// Augument the Firestore class with the pipeline() method.
20+
// This is stripped from dist/lite/pipelines.d.ts during the build
21+
// so it needs to be re-added here.
22+
declare module '@firebase/firestore' {
23+
interface Firestore {
24+
pipeline(): PipelineSource<Pipeline>;
25+
}
26+
}
27+
28+
export * from "../../dist/lite/pipelines";

packages/firestore/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
"default": "./dist/lite/pipelines.browser.esm2017.js"
9999
},
100100
"./pipelines": {
101-
"types": "./dist/pipelines.d.ts",
101+
"types": "./pipelines/pipelines.d.ts",
102102
"node": {
103103
"require": "./dist/pipelines.node.cjs.js",
104104
"import": "./dist/pipelines.node.mjs"

packages/firestore/pipelines/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"module": "../dist/pipelines.browser.esm2017.js",
77
"browser": "../dist/pipelines.browser.esm2017.js",
88
"react-native": "../dist/pipelines.rn.esm2017.js",
9-
"typings": "../dist/pipelines.d.ts",
9+
"typings": "./pipelines.d.ts",
1010
"private": true,
1111
"engines": {
1212
"node": ">=18.0.0"
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* @license
3+
* Copyright 2024 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
import {PipelineSource, Pipeline} from "../dist/pipelines";
18+
19+
// Augument the Firestore and Query classes with the pipeline() method.
20+
// This is stripped from dist/lite/pipelines.d.ts during the build
21+
// so it needs to be re-added here.
22+
declare module '@firebase/firestore' {
23+
interface Firestore {
24+
pipeline(): PipelineSource<Pipeline>;
25+
}
26+
interface Query {
27+
pipeline(): Pipeline;
28+
}
29+
}
30+
31+
export * from "../dist/pipelines";

packages/firestore/src/api/pipeline_impl.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@ import { Firestore } from './database';
2727
import { Query } from './reference';
2828
import { ExpUserDataWriter } from './user_data_writer';
2929

30-
declare module './database' {
31-
interface Firestore {
32-
pipeline(): PipelineSource<Pipeline>;
33-
}
34-
}
35-
3630
/**
3731
* Experimental Modular API for console testing.
3832
* @param firestore
@@ -79,12 +73,12 @@ export function execute(pipeline: LitePipeline): Promise<PipelineResult[]> {
7973
return pipeline.execute();
8074
}
8175

82-
// Augument the Firestore class with the pipeline() factory method
76+
// Augment the Firestore class with the pipeline() factory method
8377
Firestore.prototype.pipeline = function (): PipelineSource<Pipeline> {
8478
return pipeline(this);
8579
};
8680

87-
// Augument the Query class with the pipeline() factory method
81+
// Augment the Query class with the pipeline() factory method
8882
Query.prototype.pipeline = function (): Pipeline {
8983
return pipeline(this);
9084
};

0 commit comments

Comments
 (0)