Skip to content

Commit ef89d7b

Browse files
chore: delete old config setup for compare scripts and get types from root node_modules/ (#9011)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent 3183884 commit ef89d7b

22 files changed

Lines changed: 451 additions & 16628 deletions

File tree

.github/scripts/compare-types/README.md

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@ For each registered package it compares the **modular** public API exported by t
1010
| **Extra in RN Firebase** | Export exists in the RN package but not in the firebase-js-sdk |
1111
| **Different shape** | Same name, but the type signature or interface members differ |
1212

13-
Every difference must have an entry in the package's `config.ts` explaining why it exists. The script exits with code 1, failing CI, if either:
13+
Every difference must have an entry in the package's `configs/<package-name>.ts` explaining why it exists. The script exits with code 1, failing CI, if either:
1414

15-
- A difference is **undocumented** — add it to `config.ts` with a reason, or fix the RN Firebase types to match.
16-
- A config entry is **stale** — the API now matches the firebase-js-sdk, so the entry should be removed from `config.ts`.
15+
- A difference is **undocumented** — add it to `configs/<package-name>.ts` with a reason, or fix the RN Firebase types to match.
16+
- A config entry is **stale** — the API now matches the firebase-js-sdk, so the entry should be removed from `configs/<package-name>.ts`.
1717

1818
## Prerequisites
1919

20-
The RN Firebase package(s) must be built before running the script, because the script reads from the compiled `dist/typescript/lib/` files:
20+
The root repository dependencies must be installed because the script reads the Firebase JS SDK types from the installed root `node_modules/firebase` package.
21+
22+
The RN Firebase package(s) must also be built before running the script, because the script reads from the compiled `dist/typescript/lib/` files:
2123

2224
```sh
2325
yarn
@@ -54,16 +56,16 @@ yarn compare
5456
rn: (RemoteConfig) => ConfigValues
5557
...
5658
57-
✓ All 17 difference(s) are documented in config.ts
59+
✓ All 17 difference(s) are documented in configs/<name>.ts
5860
```
5961

6062
```
6163
📦 storage
6264
6365
Stale config entries (1):
64-
✗ uploadString [STALE] — now matches the firebase-js-sdk; remove from config.ts
66+
✗ uploadString [STALE] — now matches the firebase-js-sdk; remove from configs/<name>.ts
6567
66-
✗ 1 stale config entry/entries — remove them from config.ts
68+
✗ 1 stale config entry/entries — remove them from configs/<name>.ts
6769
```
6870

6971
`~` (yellow) = documented difference — CI passes.
@@ -76,8 +78,8 @@ yarn compare
7678
```
7779
src/
7880
index.ts Entry point. Iterates packages, calls parse → compare → report.
79-
parse.ts Uses ts-morph to read .d.ts files and extract typed export shapes
80-
without needing to resolve external imports (reads type text as-written).
81+
parse.ts Uses ts-morph to read .d.ts files, resolve SDK re-export chains,
82+
and extract typed export shapes.
8183
compare.ts Diffs two export maps and classifies each difference.
8284
Cross-references against the package config to split documented
8385
from undocumented differences, and detects stale config entries
@@ -88,8 +90,10 @@ src/
8890
8991
packages/
9092
<package-name>/
91-
firebase-sdk.d.ts Snapshot of the firebase-js-sdk public types for this package.
92-
config.ts Documented known differences for this package.
93+
(obsolete snapshots should not be added here)
94+
95+
configs/
96+
<package-name>.ts Documented known differences for this package.
9397
```
9498

9599
### Type shapes
@@ -107,17 +111,17 @@ Shapes are compared as normalised strings. Semantically equivalent types that ar
107111

108112
## Adding a new package
109113

110-
### 1. Get the firebase-js-sdk public types
114+
### 1. Confirm the firebase-js-sdk public types
111115

112-
Copy the public type declarations for the package from the firebase-js-sdk release into a new file:
116+
The script reads Firebase JS SDK public declarations from the root `node_modules/firebase` package. Confirm the package exposes the modular public type entry in `node_modules/firebase/package.json`:
113117

114118
```
115-
packages/<package-name>/firebase-sdk.d.ts
119+
"./<package-name>": {
120+
"types": "./<package-name>/dist/<package-name>/index.d.ts"
121+
}
116122
```
117123

118-
The file should contain only the **modular** (tree-shakeable) public exports — interfaces, type aliases, and `declare function` declarations. Strip internal/private types.
119-
120-
> In the future this step will be automated: a CI job will clone the firebase-js-sdk, run `yarn && yarn build`, and extract the generated `.d.ts` files automatically.
124+
Those wrapper files often re-export public declarations from `@firebase/<package-name>`, and the parser resolves that chain through root `node_modules`.
121125

122126
### 2. Identify the RN Firebase modular files
123127

@@ -134,10 +138,10 @@ Also note any **support files** — files that are re-exported from the modular
134138

135139
### 3. Create the config file
136140

137-
Create `packages/<package-name>/config.ts` with a `PackageConfig` object:
141+
Create `configs/<package-name>.ts` with a `PackageConfig` object:
138142

139143
```typescript
140-
import type { PackageConfig } from '../../src/types';
144+
import type { PackageConfig } from '../src/types';
141145

142146
const config: PackageConfig = {
143147
// Rename mapping: sdkName → rnName (when an export has been renamed)
@@ -180,14 +184,12 @@ Leave any section as an empty array (or omit it) if there are no differences in
180184
Add an entry to [`src/registry.ts`](src/registry.ts):
181185

182186
```typescript
183-
import newPackageConfig from '../packages/<package-name>/config';
187+
import newPackageConfig from '../configs/<package-name>';
184188

185189
// inside the packages array:
186190
{
187191
name: '<package-name>',
188-
firebaseSdkTypesPaths: [
189-
path.join(SCRIPT_DIR, 'packages', '<package-name>', 'firebase-sdk.d.ts'),
190-
],
192+
firebaseSdkTypesPaths: [firebaseTypes('<package-name>')],
191193
rnFirebaseModularFiles: [
192194
path.join(rnDist('<package-name>'), 'types', 'modular.d.ts'),
193195
path.join(rnDist('<package-name>'), 'modular.d.ts'),
@@ -202,7 +204,7 @@ import newPackageConfig from '../packages/<package-name>/config';
202204

203205
### 5. Verify
204206

205-
Build the package and run the script. Any undocumented differences will be printed in red — add them to `config.ts` with a reason, or fix the RN Firebase types to match the SDK.
207+
Build the package and run the script. Any undocumented differences will be printed in red — add them to `configs/<package-name>.ts` with a reason, or fix the RN Firebase types to match the SDK.
206208

207209
```sh
208210
# from repo root
@@ -212,21 +214,21 @@ yarn compare:types
212214

213215
---
214216

215-
## Updating a package's firebase-sdk snapshot
217+
## Updating the Firebase SDK reference
216218

217219
When a new firebase-js-sdk version ships with type changes:
218220

219-
1. Copy the updated public types from `node_modules/@firebase/<package>/dist/index.d.ts` (or the equivalent built output) into `packages/<package-name>/firebase-sdk.d.ts`.
221+
1. Update the root `firebase` dependency and run `yarn` from the repository root.
220222
2. Run `yarn compare:types`.
221223
3. Any newly introduced differences will be flagged as undocumented. Either:
222224
- Update the RN Firebase types to match, or
223-
- Add a new entry to `config.ts` explaining why the difference is intentional.
224-
4. Any config entries that the SDK change has now made redundant will be flagged as **stale**. Remove them from `config.ts`.
225+
- Add a new entry to `configs/<package-name>.ts` explaining why the difference is intentional.
226+
4. Any config entries that the SDK change has now made redundant will be flagged as **stale**. Remove them from `configs/<package-name>.ts`.
225227

226228
## Resolving a known difference in RN Firebase
227229

228230
When the RN Firebase types are updated to match the firebase-js-sdk for a previously documented difference:
229231

230232
1. Update the RN Firebase types and rebuild the package.
231233
2. Run `yarn compare:types`.
232-
3. The resolved entry will be flagged as **stale** (`✗ [STALE]`). Remove it from `config.ts`.
234+
3. The resolved entry will be flagged as **stale** (`✗ [STALE]`). Remove it from `configs/<package-name>.ts`.

.github/scripts/compare-types/packages/ai/config.ts renamed to .github/scripts/compare-types/configs/ai.ts

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Known differences between the firebase-js-sdk AI public API and the
33
* @react-native-firebase/ai public API.
44
*
5-
* Reference: .github/scripts/compare-types/packages/ai/firebase-sdk.d.ts (JS SDK snapshot).
5+
* Reference: root node_modules/firebase AI public types.
66
* RN Firebase built types: packages/ai/dist/typescript/lib/(any subdir)/*.d.ts
77
*
88
* Each entry must have a `name` (the export name) and a `reason` explaining
@@ -16,7 +16,7 @@
1616
* differentShape - exports present in both but with differing signatures/members
1717
*/
1818

19-
import type { PackageConfig } from '../../src/types';
19+
import type { PackageConfig } from '../src/types';
2020

2121
const config: PackageConfig = {
2222
nameMapping: {},
@@ -121,6 +121,36 @@ const config: PackageConfig = {
121121
reason:
122122
'RN Firebase does not currently expose per-call request overrides such as `AbortSignal`; requests are configured via model-level `RequestOptions` only.',
123123
},
124+
{
125+
name: 'ChatSessionBase',
126+
reason:
127+
'Base class used by the firebase-js-sdk template chat implementation. RN Firebase exposes its concrete chat session surface instead.',
128+
},
129+
{
130+
name: 'StartTemplateChatParams',
131+
reason:
132+
'Template chat startup parameters are part of the firebase-js-sdk template chat API, which RN Firebase does not currently expose.',
133+
},
134+
{
135+
name: 'TemplateChatSession',
136+
reason:
137+
'Template chat sessions are not currently part of the RN Firebase public AI API.',
138+
},
139+
{
140+
name: 'TemplateFunctionDeclaration',
141+
reason:
142+
'Template function declaration helpers are part of firebase-js-sdk template tooling that RN Firebase does not currently expose.',
143+
},
144+
{
145+
name: 'TemplateFunctionDeclarationsTool',
146+
reason:
147+
'Template function declaration tools are part of firebase-js-sdk template tooling that RN Firebase does not currently expose.',
148+
},
149+
{
150+
name: 'TemplateTool',
151+
reason:
152+
'Template tool unions are part of firebase-js-sdk template tooling that RN Firebase does not currently expose.',
153+
},
124154
{
125155
name: 'ThinkingLevel',
126156
reason:
@@ -195,6 +225,11 @@ const config: PackageConfig = {
195225
reason:
196226
'RN Firebase function responses omit the optional `parts` field from the JS SDK declaration and only expose the structured response payload.',
197227
},
228+
{
229+
name: 'GenerationConfig',
230+
reason:
231+
'RN Firebase does not currently expose the JS SDK `responseJsonSchema` generation config field.',
232+
},
198233
{
199234
name: 'GenerativeModel',
200235
reason:

.github/scripts/compare-types/packages/app-check/config.ts renamed to .github/scripts/compare-types/configs/app-check.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* fail so that new drift is caught and deliberately acknowledged.
88
*/
99

10-
import type { PackageConfig } from '../../src/types';
10+
import type { PackageConfig } from '../src/types';
1111

1212
const config: PackageConfig = {
1313
nameMapping: {},

.github/scripts/compare-types/packages/database/config.ts renamed to .github/scripts/compare-types/configs/database.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { PackageConfig } from '../../src/types';
1+
import type { PackageConfig } from '../src/types';
22

33
const config: PackageConfig = {
44
nameMapping: {},
@@ -41,12 +41,19 @@ const config: PackageConfig = {
4141
],
4242
differentShape: [
4343
{
44-
name: 'EmulatorMockTokenOptions',
44+
name: 'Database',
4545
reason:
46-
'RN Firebase reuses the local `FirebaseIdToken` alias in ' +
47-
'`Partial<FirebaseIdToken>`, while the snapshot inlines the token ' +
48-
'shape so compare-types does not treat the helper alias as an extra export. ' +
49-
'The two types are structurally equivalent.',
46+
'RN Firebase narrows the public `type` member to the concrete `database` literal, while the firebase-js-sdk declaration leaves it less specific.',
47+
},
48+
{
49+
name: 'DataSnapshot',
50+
reason:
51+
'RN Firebase exposes native snapshot metadata helpers such as `key`, `priority`, and `size` on the public snapshot type.',
52+
},
53+
{
54+
name: 'OnDisconnect',
55+
reason:
56+
'The public method signatures are equivalent, but the generated declaration text differs in union ordering for the priority parameter.',
5057
},
5158
],
5259
};

0 commit comments

Comments
 (0)