Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions .github/scripts/compare-types/packages/installations/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/**
* Known differences between the firebase-js-sdk @firebase/installations public
* API and the @react-native-firebase/installations modular API.
*
* Each entry must have a `name` (the export name) and a `reason` explaining
* why the difference exists. Any difference NOT listed here will cause CI to
* fail so that new drift is caught and deliberately acknowledged.
*
* Sections:
* nameMapping — exports that exist in both packages but under different names
* missingInRN — firebase-js-sdk exports absent from RN Firebase
* extraInRN — RN Firebase exports not present in the firebase-js-sdk
* differentShape — exports present in both but with differing signatures/members
*/

import type { PackageConfig } from '../../src/types';

const config: PackageConfig = {
// ---------------------------------------------------------------------------
// Name mapping
// ---------------------------------------------------------------------------
nameMapping: {},

// ---------------------------------------------------------------------------
// Missing in RN Firebase
// ---------------------------------------------------------------------------
missingInRN: [
{
name: 'IdChangeCallbackFn',
reason:
'The firebase-js-sdk exports this type alias for the callback passed to ' +
'`onIdChange`. RN Firebase does not export it; the callback is typed inline. ' +
'`onIdChange` itself is present but throws at runtime (unsupported).',
},
{
name: 'IdChangeUnsubscribeFn',
reason:
'The firebase-js-sdk exports this type alias for the unsubscribe return of ' +
'`onIdChange`. RN Firebase does not export it; the return type is inline `() => void`. ' +
'`onIdChange` itself is present but throws at runtime (unsupported).',
},
],

// ---------------------------------------------------------------------------
// Extra in RN Firebase
// ---------------------------------------------------------------------------
extraInRN: [
{
name: 'Statics',
reason:
'RN Firebase exposes a `Statics` interface (e.g. `SDK_VERSION`) for package ' +
'version and static metadata. The firebase-js-sdk does not expose an equivalent ' +
'named type in its public installations API.',
},
{
name: 'FirebaseInstallationsTypes',
reason:
'RN Firebase exports the deprecated `FirebaseInstallationsTypes` namespace for ' +
'backwards compatibility with the namespaced API. The firebase-js-sdk has no ' +
'equivalent; it only exposes the modular API.',
},
],

// ---------------------------------------------------------------------------
// Different shape
// ---------------------------------------------------------------------------
differentShape: [
{
name: 'getInstallations',
reason:
'The optional `app` parameter is typed as `ReactNativeFirebase.FirebaseApp` in RN Firebase ' +
'and as `FirebaseApp` from `@firebase/app` in the firebase-js-sdk. Both represent the app ' +
'instance; the RN type comes from the React Native Firebase app package.',
},
{
name: 'Installations',
reason:
'The `app` property is typed as `ReactNativeFirebase.FirebaseApp` in RN Firebase ' +
'and as `FirebaseApp` from `@firebase/app` in the firebase-js-sdk. Both represent ' +
'the app instance; the RN type comes from the React Native Firebase app package.',
},
{
name: 'onIdChange',
reason:
'RN Firebase exposes `onIdChange` with the same signature as the firebase-js-sdk ' +
'for API compatibility, but it is not implemented: it throws at runtime with a message ' +
'that the method is unsupported. The JS SDK supports ID change callbacks; the native ' +
'RN implementations do not yet provide this.',
},
],
};

export default config;
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/**
* The Firebase Installations Web SDK.
* This SDK does not work in a Node.js environment.
*
* @packageDocumentation
*/

import { FirebaseApp } from '@firebase/app';

/**
* Deletes the Firebase Installation and all associated data.
* @param installations - The `Installations` instance.
*
* @public
*/
export declare function deleteInstallations(installations: Installations): Promise<void>;

/* Excluded from this release type: _FirebaseInstallationsInternal */

/**
* Creates a Firebase Installation if there isn't one for the app and
* returns the Installation ID.
* @param installations - The `Installations` instance.
*
* @public
*/
export declare function getId(installations: Installations): Promise<string>;

/**
* Returns an instance of {@link Installations} associated with the given
* {@link @firebase/app#FirebaseApp} instance.
* @param app - The {@link @firebase/app#FirebaseApp} instance.
*
* @public
*/
export declare function getInstallations(app?: FirebaseApp): Installations;

/**
* Returns a Firebase Installations auth token, identifying the current
* Firebase Installation.
* @param installations - The `Installations` instance.
* @param forceRefresh - Force refresh regardless of token expiration.
*
* @public
*/
export declare function getToken(installations: Installations, forceRefresh?: boolean): Promise<string>;

/**
* An user defined callback function that gets called when Installations ID changes.
*
* @public
*/
export declare type IdChangeCallbackFn = (installationId: string) => void;

/**
* Unsubscribe a callback function previously added via {@link IdChangeCallbackFn}.
*
* @public
*/
export declare type IdChangeUnsubscribeFn = () => void;

/**
* Public interface of the Firebase Installations SDK.
*
* @public
*/
export declare interface Installations {
/**
* The {@link @firebase/app#FirebaseApp} this `Installations` instance is associated with.
*/
app: FirebaseApp;
}

/**
* Sets a new callback that will get called when Installation ID changes.
* Returns an unsubscribe function that will remove the callback when called.
* @param installations - The `Installations` instance.
* @param callback - The callback function that is invoked when FID changes.
* @returns A function that can be called to unsubscribe.
*
* @public
*/
export declare function onIdChange(installations: Installations, callback: IdChangeCallbackFn): IdChangeUnsubscribeFn;

export { }
20 changes: 19 additions & 1 deletion .github/scripts/compare-types/src/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,23 @@ function rnDist(packageName: string): string {
}

export const packages: PackageEntry[] = [

{
name: 'installations',
firebaseSdkTypesPath: path.join(
SCRIPT_DIR,
'packages',
'installations',
'installations-js-sdk.d.ts',
),
rnFirebaseModularFiles: [
path.join(rnDist('installations'), 'types', 'installations.d.ts'),
path.join(rnDist('installations'), 'modular.d.ts'),
],
rnFirebaseSupportFiles: [
path.join(rnDist('installations'), 'types', 'namespaced.d.ts'),
path.join(rnDist('installations'), 'types', 'internal.d.ts'),
],
config: require(path.join(SCRIPT_DIR, 'packages', 'installations', 'config'))
.default as PackageConfig,
},
];
2 changes: 1 addition & 1 deletion .github/scripts/compare-types/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"esModuleInterop": true,
"resolveJsonModule": true,
"outDir": "dist",
"rootDir": "src"
"rootDir": "."
},
"include": ["src/**/*.ts", "packages/**/*.ts"]
}
3 changes: 3 additions & 0 deletions packages/installations/__tests__/installations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ describe('installations()', function () {
const installations = getInstallations();
installationsV9Deprecation(
() => deleteInstallations(installations),
// @ts-expect-error Combines modular and namespace API
() => installations.delete(),
'delete',
);
Expand All @@ -118,6 +119,7 @@ describe('installations()', function () {
const installations = getInstallations();
installationsV9Deprecation(
() => getId(installations),
// @ts-expect-error Combines modular and namespace API
() => installations.getId(),
'getId',
);
Expand All @@ -127,6 +129,7 @@ describe('installations()', function () {
const installations = getInstallations();
installationsV9Deprecation(
() => getToken(installations),
// @ts-expect-error Combines modular and namespace API
() => installations.getToken(),
'getToken',
);
Expand Down
Loading
Loading