diff --git a/CHANGELOG.md b/CHANGELOG.md index e69de29..34f4893 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -0,0 +1,3 @@ +- Explicitly import from the v1 namespace to unbreak firebase-functions 6.x (#243). +- Explciitly import from the v2 namespace so that #243 doesn't break firebase-functions versions below 6.x (#252) +- Also adds firebase-admin 13.x as a supported version in peer-deps (#252) diff --git a/package-lock.json b/package-lock.json index 2a88c5a..84a91a3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,7 @@ "@types/mocha": "^5.2.7", "chai": "^4.2.0", "firebase-admin": "^12.0.0", - "firebase-functions": "^6.0.1", + "firebase-functions": "^4.9.0", "firebase-tools": "^8.9.2", "mocha": "^6.2.2", "prettier": "^1.19.1", @@ -32,7 +32,7 @@ }, "peerDependencies": { "firebase-admin": "^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0 || ^12.0.0", - "firebase-functions": ">=6.0.1", + "firebase-functions": ">=4.9.0", "jest": ">=28.0.0" } }, @@ -5435,11 +5435,10 @@ "dev": true }, "node_modules/firebase-functions": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/firebase-functions/-/firebase-functions-6.0.1.tgz", - "integrity": "sha512-0rIpTU6dnLRvP3IK+okn1FDjoqjzShm0/S+i4OMY7JFu/HJoyJ1JNkrT4KjECy1/mCHK49KsmH8iYE0rzrglHg==", + "version": "4.9.0", + "resolved": "https://registry.npmjs.org/firebase-functions/-/firebase-functions-4.9.0.tgz", + "integrity": "sha512-IqxOEsVAWGcRv9KRGzWQR5mOFuNsil3vsfkRPPiaV1U/ATC27/jbahh4z8I4rW8Xqa6cQE5xqnw0ueyMH7i7Ag==", "dev": true, - "license": "MIT", "dependencies": { "@types/cors": "^2.8.5", "@types/express": "4.17.3", @@ -5454,7 +5453,7 @@ "node": ">=14.10.0" }, "peerDependencies": { - "firebase-admin": "^11.10.0 || ^12.0.0" + "firebase-admin": "^10.0.0 || ^11.0.0 || ^12.0.0" } }, "node_modules/firebase-functions/node_modules/@types/express": { @@ -17806,9 +17805,9 @@ } }, "firebase-functions": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/firebase-functions/-/firebase-functions-6.0.1.tgz", - "integrity": "sha512-0rIpTU6dnLRvP3IK+okn1FDjoqjzShm0/S+i4OMY7JFu/HJoyJ1JNkrT4KjECy1/mCHK49KsmH8iYE0rzrglHg==", + "version": "4.9.0", + "resolved": "https://registry.npmjs.org/firebase-functions/-/firebase-functions-4.9.0.tgz", + "integrity": "sha512-IqxOEsVAWGcRv9KRGzWQR5mOFuNsil3vsfkRPPiaV1U/ATC27/jbahh4z8I4rW8Xqa6cQE5xqnw0ueyMH7i7Ag==", "dev": true, "requires": { "@types/cors": "^2.8.5", diff --git a/package.json b/package.json index ca9ee47..178b4fb 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@types/mocha": "^5.2.7", "chai": "^4.2.0", "firebase-admin": "^12.0.0", - "firebase-functions": "^6.0.1", + "firebase-functions": "^4.9.0", "firebase-tools": "^8.9.2", "mocha": "^6.2.2", "prettier": "^1.19.1", @@ -57,8 +57,8 @@ "typescript": "^4.2.5" }, "peerDependencies": { - "firebase-admin": "^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0 || ^12.0.0", - "firebase-functions": ">=6.0.1", + "firebase-admin": "^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0", + "firebase-functions": ">=4.9.0", "jest": ">=28.0.0" }, "engines": { diff --git a/spec/cloudevent/generate.ts b/spec/cloudevent/generate.ts index ebbd0f6..f245887 100644 --- a/spec/cloudevent/generate.ts +++ b/spec/cloudevent/generate.ts @@ -22,7 +22,7 @@ import { expect } from 'chai'; -import { alerts, storage } from 'firebase-functions'; +import { alerts, storage } from 'firebase-functions/v2'; import { generateMockCloudEvent } from '../../src/cloudevent/generate'; describe('generate (CloudEvent)', () => { diff --git a/spec/main.spec.ts b/spec/main.spec.ts index dfa23cc..703495c 100644 --- a/spec/main.spec.ts +++ b/spec/main.spec.ts @@ -28,7 +28,7 @@ import { mockConfig, makeChange, wrap } from '../src/main'; import { _makeResourceName, _extractParams } from '../src/v1'; import { features } from '../src/features'; import { FirebaseFunctionsTest } from '../src/lifecycle'; -import { alerts } from 'firebase-functions'; +import { alerts } from 'firebase-functions/v2'; import { wrapV2 } from '../src/v2'; describe('main', () => { diff --git a/spec/v2.spec.ts b/spec/v2.spec.ts index 921c93a..1101aa7 100644 --- a/spec/v2.spec.ts +++ b/spec/v2.spec.ts @@ -35,7 +35,7 @@ import { eventarc, https, firestore, -} from 'firebase-functions'; +} from 'firebase-functions/v2'; import { defineString } from 'firebase-functions/params'; import { makeDataSnapshot } from '../src/providers/database'; import { makeDocumentSnapshot } from '../src/providers/firestore'; diff --git a/src/cloudevent/generate.ts b/src/cloudevent/generate.ts index 0111d26..4cb908d 100644 --- a/src/cloudevent/generate.ts +++ b/src/cloudevent/generate.ts @@ -3,7 +3,7 @@ import { CloudFunction, database, pubsub, -} from 'firebase-functions'; +} from 'firebase-functions/v2'; import { DocumentSnapshot, QueryDocumentSnapshot, diff --git a/src/cloudevent/mocks/alerts/alerts-on-alert-published.ts b/src/cloudevent/mocks/alerts/alerts-on-alert-published.ts index 2607817..a13c371 100644 --- a/src/cloudevent/mocks/alerts/alerts-on-alert-published.ts +++ b/src/cloudevent/mocks/alerts/alerts-on-alert-published.ts @@ -1,12 +1,12 @@ import { DeepPartial, MockCloudEventAbstractFactory } from '../../types'; -import { CloudFunction } from 'firebase-functions'; +import { CloudFunction } from 'firebase-functions/v2'; import { APP_ID, getBaseCloudEvent, getEventType, PROJECT_ID, } from '../helpers'; -import { FirebaseAlertData, AlertEvent } from 'firebase-functions/alerts'; +import { FirebaseAlertData, AlertEvent } from 'firebase-functions/v2/alerts'; export const alertsOnAlertPublished: MockCloudEventAbstractFactory = { diff --git a/src/cloudevent/mocks/firestore/firestore-on-document-created-with-auth-context.ts b/src/cloudevent/mocks/firestore/firestore-on-document-created-with-auth-context.ts index 6e795bd..bf4359c 100644 --- a/src/cloudevent/mocks/firestore/firestore-on-document-created-with-auth-context.ts +++ b/src/cloudevent/mocks/firestore/firestore-on-document-created-with-auth-context.ts @@ -1,5 +1,5 @@ import { MockCloudEventAbstractFactory } from '../../types'; -import { CloudEvent, CloudFunction, firestore } from 'firebase-functions'; +import { CloudEvent, CloudFunction, firestore } from 'firebase-functions/v2'; import { getEventType } from '../helpers'; import { QueryDocumentSnapshot } from 'firebase-admin/firestore'; import { getDocumentSnapshotCloudEventWithAuthContext } from './helpers'; diff --git a/src/cloudevent/mocks/firestore/firestore-on-document-created.ts b/src/cloudevent/mocks/firestore/firestore-on-document-created.ts index 4768b4c..4b8b532 100644 --- a/src/cloudevent/mocks/firestore/firestore-on-document-created.ts +++ b/src/cloudevent/mocks/firestore/firestore-on-document-created.ts @@ -1,5 +1,5 @@ import { MockCloudEventAbstractFactory } from '../../types'; -import { CloudEvent, CloudFunction, firestore } from 'firebase-functions'; +import { CloudEvent, CloudFunction, firestore } from 'firebase-functions/v2'; import { getEventType } from '../helpers'; import { QueryDocumentSnapshot } from 'firebase-admin/firestore'; import { getDocumentSnapshotCloudEvent } from './helpers'; diff --git a/src/cloudevent/mocks/firestore/firestore-on-document-deleted-with-auth-context.ts b/src/cloudevent/mocks/firestore/firestore-on-document-deleted-with-auth-context.ts index 40fd9e4..942ebc7 100644 --- a/src/cloudevent/mocks/firestore/firestore-on-document-deleted-with-auth-context.ts +++ b/src/cloudevent/mocks/firestore/firestore-on-document-deleted-with-auth-context.ts @@ -1,5 +1,5 @@ import { MockCloudEventAbstractFactory } from '../../types'; -import { CloudEvent, CloudFunction, firestore } from 'firebase-functions'; +import { CloudEvent, CloudFunction, firestore } from 'firebase-functions/v2'; import { getEventType } from '../helpers'; import { QueryDocumentSnapshot } from 'firebase-admin/firestore'; import { getDocumentSnapshotCloudEventWithAuthContext } from './helpers'; diff --git a/src/cloudevent/mocks/firestore/firestore-on-document-deleted.ts b/src/cloudevent/mocks/firestore/firestore-on-document-deleted.ts index fde9b2d..e29f1f6 100644 --- a/src/cloudevent/mocks/firestore/firestore-on-document-deleted.ts +++ b/src/cloudevent/mocks/firestore/firestore-on-document-deleted.ts @@ -1,5 +1,5 @@ import { MockCloudEventAbstractFactory } from '../../types'; -import { CloudEvent, CloudFunction, firestore } from 'firebase-functions'; +import { CloudEvent, CloudFunction, firestore } from 'firebase-functions/v2'; import { getEventType } from '../helpers'; import { QueryDocumentSnapshot } from 'firebase-admin/firestore'; import { getDocumentSnapshotCloudEvent } from './helpers'; diff --git a/src/cloudevent/mocks/firestore/firestore-on-document-updated-with-auth-context.ts b/src/cloudevent/mocks/firestore/firestore-on-document-updated-with-auth-context.ts index 95f26a0..a023ce8 100644 --- a/src/cloudevent/mocks/firestore/firestore-on-document-updated-with-auth-context.ts +++ b/src/cloudevent/mocks/firestore/firestore-on-document-updated-with-auth-context.ts @@ -4,7 +4,7 @@ import { CloudEvent, CloudFunction, firestore, -} from 'firebase-functions'; +} from 'firebase-functions/v2'; import { getEventType } from '../helpers'; import { QueryDocumentSnapshot } from 'firebase-admin/firestore'; import { getDocumentSnapshotChangeCloudEventWithAuthContext } from './helpers'; diff --git a/src/cloudevent/mocks/firestore/firestore-on-document-updated.ts b/src/cloudevent/mocks/firestore/firestore-on-document-updated.ts index 9ee0cd9..bf5da64 100644 --- a/src/cloudevent/mocks/firestore/firestore-on-document-updated.ts +++ b/src/cloudevent/mocks/firestore/firestore-on-document-updated.ts @@ -4,7 +4,7 @@ import { CloudEvent, CloudFunction, firestore, -} from 'firebase-functions'; +} from 'firebase-functions/v2'; import { getEventType } from '../helpers'; import { QueryDocumentSnapshot } from 'firebase-admin/firestore'; import { getDocumentSnapshotChangeCloudEvent } from './helpers'; diff --git a/src/cloudevent/mocks/firestore/firestore-on-document-written-with-auth-context.ts b/src/cloudevent/mocks/firestore/firestore-on-document-written-with-auth-context.ts index c57ac54..a9171a9 100644 --- a/src/cloudevent/mocks/firestore/firestore-on-document-written-with-auth-context.ts +++ b/src/cloudevent/mocks/firestore/firestore-on-document-written-with-auth-context.ts @@ -4,7 +4,7 @@ import { CloudEvent, CloudFunction, firestore, -} from 'firebase-functions'; +} from 'firebase-functions/v2'; import { getEventType } from '../helpers'; import { DocumentSnapshot } from 'firebase-admin/firestore'; import { getDocumentSnapshotChangeCloudEventWithAuthContext } from './helpers'; diff --git a/src/cloudevent/mocks/firestore/firestore-on-document-written.ts b/src/cloudevent/mocks/firestore/firestore-on-document-written.ts index 71f0a57..20e9f0e 100644 --- a/src/cloudevent/mocks/firestore/firestore-on-document-written.ts +++ b/src/cloudevent/mocks/firestore/firestore-on-document-written.ts @@ -4,7 +4,7 @@ import { CloudEvent, CloudFunction, firestore, -} from 'firebase-functions'; +} from 'firebase-functions/v2'; import { getEventType } from '../helpers'; import { DocumentSnapshot } from 'firebase-admin/firestore'; import { getDocumentSnapshotChangeCloudEvent } from './helpers'; diff --git a/src/cloudevent/mocks/firestore/helpers.ts b/src/cloudevent/mocks/firestore/helpers.ts index dabf425..77b144c 100644 --- a/src/cloudevent/mocks/firestore/helpers.ts +++ b/src/cloudevent/mocks/firestore/helpers.ts @@ -1,5 +1,5 @@ import { DocumentSnapshot } from 'firebase-admin/firestore'; -import { Change, CloudFunction, firestore } from 'firebase-functions'; +import { Change, CloudFunction, firestore } from 'firebase-functions/v2'; import { exampleDocumentSnapshot, exampleDocumentSnapshotChange, diff --git a/src/cloudevent/mocks/helpers.ts b/src/cloudevent/mocks/helpers.ts index 3715c92..5bc785e 100644 --- a/src/cloudevent/mocks/helpers.ts +++ b/src/cloudevent/mocks/helpers.ts @@ -1,5 +1,5 @@ import * as v1 from 'firebase-functions/v1'; -import * as v2 from 'firebase-functions'; +import * as v2 from 'firebase-functions/v2'; import { Expression } from 'firebase-functions/params'; export const APP_ID = '__APP_ID__'; diff --git a/src/cloudevent/mocks/pubsub/pubsub-on-message-published.ts b/src/cloudevent/mocks/pubsub/pubsub-on-message-published.ts index 7826a29..78a0af7 100644 --- a/src/cloudevent/mocks/pubsub/pubsub-on-message-published.ts +++ b/src/cloudevent/mocks/pubsub/pubsub-on-message-published.ts @@ -1,5 +1,5 @@ import { DeepPartial, MockCloudEventAbstractFactory } from '../../types'; -import { CloudEvent, CloudFunction, pubsub } from 'firebase-functions'; +import { CloudEvent, CloudFunction, pubsub } from 'firebase-functions/v2'; import { getBaseCloudEvent, getEventFilters, diff --git a/src/cloudevent/mocks/remoteconfig/remote-config-on-config-updated.ts b/src/cloudevent/mocks/remoteconfig/remote-config-on-config-updated.ts index 53a36a1..2f257db 100644 --- a/src/cloudevent/mocks/remoteconfig/remote-config-on-config-updated.ts +++ b/src/cloudevent/mocks/remoteconfig/remote-config-on-config-updated.ts @@ -1,6 +1,6 @@ import { DeepPartial, MockCloudEventAbstractFactory } from '../../types'; -import { CloudFunction, CloudEvent } from 'firebase-functions'; -import { ConfigUpdateData } from 'firebase-functions/remoteConfig'; +import { CloudFunction, CloudEvent } from 'firebase-functions/v2'; +import { ConfigUpdateData } from 'firebase-functions/v2/remoteConfig'; import { getBaseCloudEvent, getEventType, PROJECT_ID } from '../helpers'; export const remoteConfigOnConfigUpdated: MockCloudEventAbstractFactory = { [Key in keyof T]?: T[Key] extends object ? DeepPartial : T[Key]; diff --git a/src/main.ts b/src/main.ts index 6764246..a2e621d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -29,12 +29,12 @@ import { import { CloudFunction as CloudFunctionV2, CloudEvent, -} from 'firebase-functions'; +} from 'firebase-functions/v2'; import { CallableFunction, HttpsFunction as HttpsFunctionV2, -} from 'firebase-functions/https'; +} from 'firebase-functions/v2/https'; import { wrapV1, WrappedFunction, WrappedScheduledFunction } from './v1'; diff --git a/src/v2.ts b/src/v2.ts index ed2152c..e3fef18 100644 --- a/src/v2.ts +++ b/src/v2.ts @@ -20,8 +20,8 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -import { CloudFunction, CloudEvent } from 'firebase-functions'; -import { CallableFunction, CallableRequest } from 'firebase-functions/https'; +import { CloudFunction, CloudEvent } from 'firebase-functions/v2'; +import { CallableFunction, CallableRequest } from 'firebase-functions/v2/https'; import { generateCombinedCloudEvent } from './cloudevent/generate'; import { DeepPartial } from './cloudevent/types';