Skip to content

Commit a776337

Browse files
rwarnerclaude
andcommitted
Upgrade firebase-functions to v6 for firebase-admin v13 compatibility
firebase-admin v13.5.0+ (required for liveActivityToken) has a peer dependency on firebase-functions v6.1.1+. firebase-functions v6 changes the default export to v2 APIs, so index.js now imports from firebase-functions/v1 to retain functions.config(), functions.region(), and functions.runWith(). Test mocks updated to mock both firebase-functions and firebase-functions/v1 paths. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 75002fc commit a776337

7 files changed

Lines changed: 16 additions & 7 deletions

File tree

functions/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
'use strict';
22

3-
const functions = require('firebase-functions');
3+
// firebase-functions v6+ defaults to v2 APIs; use the v1 import to retain
4+
// functions.config(), functions.region(), and functions.runWith().
5+
const functions = require('firebase-functions/v1');
46
const { initializeApp } = require('firebase-admin/app');
57

68
// We need to initialize the app before importing modules that want Firestore.

functions/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"@valkey/valkey-glide": "^2.0.1",
1919
"fastify": "^5.7.3",
2020
"firebase-admin": "^13.5.0",
21-
"firebase-functions": "^5.0.1"
21+
"firebase-functions": "^6.1.1"
2222
},
2323
"devDependencies": {
2424
"@types/node": "^24.1.0",

functions/test/fcm-errors.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const mockLogging = {
4040
};
4141

4242
jest.mock('firebase-functions', () => mockFunctions);
43+
jest.mock('firebase-functions/v1', () => mockFunctions);
4344
jest.mock('@google-cloud/logging', () => ({
4445
Logging: jest.fn(() => mockLogging),
4546
}));

functions/test/handleRequest.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ const mockLogging = {
4848
};
4949

5050
jest.mock('firebase-functions', () => mockFunctions);
51+
jest.mock('firebase-functions/v1', () => mockFunctions);
5152
jest.mock('@google-cloud/logging', () => ({
5253
Logging: jest.fn(() => mockLogging),
5354
}));

functions/test/ios.test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,14 @@ jest.mock('firebase-admin/firestore', () => ({
2929
jest.mock('firebase-admin/messaging', () => ({
3030
getMessaging: jest.fn(() => mockMessaging),
3131
}));
32-
jest.mock('firebase-functions', () => ({
32+
const mockFunctions = {
3333
config: jest.fn(() => ({})),
3434
region: jest.fn().mockReturnThis(),
3535
runWith: jest.fn().mockReturnThis(),
3636
https: { onRequest: jest.fn() },
37-
}));
37+
};
38+
jest.mock('firebase-functions', () => mockFunctions);
39+
jest.mock('firebase-functions/v1', () => mockFunctions);
3840

3941
const { handleRequest } = require('../index.js');
4042
const ios = require('../ios');

functions/test/rate-limiter/firestore-rate-limiter.test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ jest.mock('firebase-admin/firestore', () => ({
3434
Timestamp: mockTimestamp,
3535
}));
3636

37-
jest.mock('firebase-functions', () => ({
37+
const mockFunctionsLogger = {
3838
logger: {
3939
info: jest.fn(),
4040
},
41-
}));
41+
};
42+
jest.mock('firebase-functions', () => mockFunctionsLogger);
43+
jest.mock('firebase-functions/v1', () => mockFunctionsLogger);
4244

4345
const FirestoreRateLimiter = require('../../rate-limiter/firestore-rate-limiter');
4446

functions/test/utils/firebase-mocks.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ const setupFirebaseMocks = () => {
3838
fromDate: jest.fn((date) => ({ toDate: () => date })),
3939
};
4040

41-
// Set up Jest mocks
41+
// Set up Jest mocks — mock both paths since index.js uses firebase-functions/v1
4242
jest.mock('firebase-functions', () => mockFunctions);
43+
jest.mock('firebase-functions/v1', () => mockFunctions);
4344
jest.mock('@google-cloud/logging', () => ({
4445
Logging: jest.fn(() => mockLogging),
4546
}));

0 commit comments

Comments
 (0)