Skip to content

Commit

Permalink
add /v2 imports back in to support firebase-functions versions below …
Browse files Browse the repository at this point in the history
…6.x (#252)
  • Loading branch information
Berlioz authored Dec 18, 2024
1 parent b78cbc4 commit cbf289a
Show file tree
Hide file tree
Showing 42 changed files with 79 additions and 77 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
19 changes: 9 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion spec/cloudevent/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)', () => {
Expand Down
2 changes: 1 addition & 1 deletion spec/main.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
2 changes: 1 addition & 1 deletion spec/v2.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/cloudevent/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
CloudFunction,
database,
pubsub,
} from 'firebase-functions';
} from 'firebase-functions/v2';
import {
DocumentSnapshot,
QueryDocumentSnapshot,
Expand Down
4 changes: 2 additions & 2 deletions src/cloudevent/mocks/alerts/alerts-on-alert-published.ts
Original file line number Diff line number Diff line change
@@ -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<AlertEvent<
FirebaseAlertData
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DeepPartial, MockCloudEventAbstractFactory } from '../../types';
import { CloudFunction } from 'firebase-functions';
import { CloudFunction } from 'firebase-functions/v2';
import {
getBaseCloudEvent,
getEventFilters,
Expand All @@ -9,7 +9,7 @@ import {
import {
AppDistributionEvent,
NewTesterDevicePayload,
} from 'firebase-functions/alerts/appDistribution';
} from 'firebase-functions/v2/alerts/appDistribution';

export const alertsAppDistributionOnNewTesterIosDevicePublished: MockCloudEventAbstractFactory<AppDistributionEvent<
NewTesterDevicePayload
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { DeepPartial, MockCloudEventAbstractFactory } from '../../types';
import { CloudFunction } from 'firebase-functions';
import { FirebaseAlertData } from 'firebase-functions/alerts';
import { CloudFunction } from 'firebase-functions/v2';
import { FirebaseAlertData } from 'firebase-functions/v2/alerts';
import {
BillingEvent,
PlanAutomatedUpdatePayload,
} from 'firebase-functions/alerts/billing';
} from 'firebase-functions/v2/alerts/billing';
import {
getBaseCloudEvent,
getEventFilters,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { DeepPartial, MockCloudEventAbstractFactory } from '../../types';
import { CloudFunction } from 'firebase-functions';
import { FirebaseAlertData } from 'firebase-functions/alerts';
import { CloudFunction } from 'firebase-functions/v2';
import { FirebaseAlertData } from 'firebase-functions/v2/alerts';
import {
BillingEvent,
PlanUpdatePayload,
} from 'firebase-functions/alerts/billing';
} from 'firebase-functions/v2/alerts/billing';
import {
getBaseCloudEvent,
getEventFilters,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DeepPartial, MockCloudEventAbstractFactory } from '../../types';
import { CloudFunction } from 'firebase-functions';
import { CloudFunction } from 'firebase-functions/v2';
import {
getBaseCloudEvent,
getEventFilters,
Expand All @@ -9,8 +9,8 @@ import {
import {
CrashlyticsEvent,
NewAnrIssuePayload,
} from 'firebase-functions/alerts/crashlytics';
import { FirebaseAlertData } from 'firebase-functions/alerts';
} from 'firebase-functions/v2/alerts/crashlytics';
import { FirebaseAlertData } from 'firebase-functions/v2/alerts';

export const alertsCrashlyticsOnNewAnrIssuePublished: MockCloudEventAbstractFactory<CrashlyticsEvent<
NewAnrIssuePayload
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DeepPartial, MockCloudEventAbstractFactory } from '../../types';
import { CloudFunction } from 'firebase-functions';
import { CloudFunction } from 'firebase-functions/v2';
import {
getBaseCloudEvent,
getEventFilters,
Expand All @@ -9,8 +9,8 @@ import {
import {
CrashlyticsEvent,
NewFatalIssuePayload,
} from 'firebase-functions/alerts/crashlytics';
import { FirebaseAlertData } from 'firebase-functions/alerts';
} from 'firebase-functions/v2/alerts/crashlytics';
import { FirebaseAlertData } from 'firebase-functions/v2/alerts';

export const alertsCrashlyticsOnNewFatalIssuePublished: MockCloudEventAbstractFactory<CrashlyticsEvent<
NewFatalIssuePayload
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DeepPartial, MockCloudEventAbstractFactory } from '../../types';
import { CloudFunction } from 'firebase-functions';
import { CloudFunction } from 'firebase-functions/v2';
import {
getBaseCloudEvent,
getEventFilters,
Expand All @@ -9,8 +9,8 @@ import {
import {
CrashlyticsEvent,
NewNonfatalIssuePayload,
} from 'firebase-functions/alerts/crashlytics';
import { FirebaseAlertData } from 'firebase-functions/alerts';
} from 'firebase-functions/v2/alerts/crashlytics';
import { FirebaseAlertData } from 'firebase-functions/v2/alerts';

export const alertsCrashlyticsOnNewNonfatalIssuePublished: MockCloudEventAbstractFactory<CrashlyticsEvent<
NewNonfatalIssuePayload
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DeepPartial, MockCloudEventAbstractFactory } from '../../types';
import { CloudFunction } from 'firebase-functions';
import { CloudFunction } from 'firebase-functions/v2';
import {
getBaseCloudEvent,
getEventFilters,
Expand All @@ -9,8 +9,8 @@ import {
import {
CrashlyticsEvent,
RegressionAlertPayload,
} from 'firebase-functions/alerts/crashlytics';
import { FirebaseAlertData } from 'firebase-functions/alerts';
} from 'firebase-functions/v2/alerts/crashlytics';
import { FirebaseAlertData } from 'firebase-functions/v2/alerts';

export const alertsCrashlyticsOnRegressionAlertPublished: MockCloudEventAbstractFactory<CrashlyticsEvent<
RegressionAlertPayload
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DeepPartial, MockCloudEventAbstractFactory } from '../../types';
import { CloudFunction } from 'firebase-functions';
import { CloudFunction } from 'firebase-functions/v2';
import {
getBaseCloudEvent,
getEventFilters,
Expand All @@ -9,8 +9,8 @@ import {
import {
CrashlyticsEvent,
StabilityDigestPayload,
} from 'firebase-functions/alerts/crashlytics';
import { FirebaseAlertData } from 'firebase-functions/alerts';
} from 'firebase-functions/v2/alerts/crashlytics';
import { FirebaseAlertData } from 'firebase-functions/v2/alerts';

export const alertsCrashlyticsOnStabilityDigestPublished: MockCloudEventAbstractFactory<CrashlyticsEvent<
StabilityDigestPayload
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DeepPartial, MockCloudEventAbstractFactory } from '../../types';
import { CloudFunction } from 'firebase-functions';
import { CloudFunction } from 'firebase-functions/v2';
import {
getBaseCloudEvent,
getEventFilters,
Expand All @@ -9,8 +9,8 @@ import {
import {
CrashlyticsEvent,
VelocityAlertPayload,
} from 'firebase-functions/alerts/crashlytics';
import { FirebaseAlertData } from 'firebase-functions/alerts';
} from 'firebase-functions/v2/alerts/crashlytics';
import { FirebaseAlertData } from 'firebase-functions/v2/alerts';

export const alertsCrashlyticsOnVelocityAlertPublished: MockCloudEventAbstractFactory<CrashlyticsEvent<
VelocityAlertPayload
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { DeepPartial, MockCloudEventAbstractFactory } from '../../types';
import { CloudFunction } from 'firebase-functions';
import { CloudFunction } from 'firebase-functions/v2';
import {
PerformanceEvent,
ThresholdAlertPayload,
} from 'firebase-functions/alerts/performance';
} from 'firebase-functions/v2/alerts/performance';
import {
getBaseCloudEvent,
getEventFilters,
getEventType,
PROJECT_ID,
APP_ID,
} from '../helpers';
import { FirebaseAlertData } from 'firebase-functions/alerts';
import { FirebaseAlertData } from 'firebase-functions/v2/alerts';

export const performanceThresholdOnThresholdAlertPublished: MockCloudEventAbstractFactory<PerformanceEvent<
ThresholdAlertPayload
Expand Down
2 changes: 1 addition & 1 deletion src/cloudevent/mocks/database/database-on-value-created.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MockCloudEventAbstractFactory } from '../../types';
import { CloudEvent, CloudFunction, database } from 'firebase-functions';
import { CloudEvent, CloudFunction, database } from 'firebase-functions/v2';
import { getEventType } from '../helpers';
import { getDatabaseSnapshotCloudEvent } from './helpers';

Expand Down
2 changes: 1 addition & 1 deletion src/cloudevent/mocks/database/database-on-value-deleted.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MockCloudEventAbstractFactory } from '../../types';
import { CloudEvent, CloudFunction, database } from 'firebase-functions';
import { CloudEvent, CloudFunction, database } from 'firebase-functions/v2';
import { getEventType } from '../helpers';
import { getDatabaseSnapshotCloudEvent } from './helpers';

Expand Down
2 changes: 1 addition & 1 deletion src/cloudevent/mocks/database/database-on-value-updated.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MockCloudEventAbstractFactory } from '../../types';
import { CloudEvent, CloudFunction, database } from 'firebase-functions';
import { CloudEvent, CloudFunction, database } from 'firebase-functions/v2';
import { getEventType } from '../helpers';
import { Change } from 'firebase-functions/v1';
import { getDatabaseChangeSnapshotCloudEvent } from './helpers';
Expand Down
2 changes: 1 addition & 1 deletion src/cloudevent/mocks/database/database-on-value-written.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MockCloudEventAbstractFactory } from '../../types';
import { CloudEvent, CloudFunction, database } from 'firebase-functions';
import { CloudEvent, CloudFunction, database } from 'firebase-functions/v2';
import { getEventType } from '../helpers';
import { Change } from 'firebase-functions/v1';
import { getDatabaseChangeSnapshotCloudEvent } from './helpers';
Expand Down
2 changes: 1 addition & 1 deletion src/cloudevent/mocks/database/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CloudFunction, database } from 'firebase-functions';
import { CloudFunction, database } from 'firebase-functions/v2';
import { DeepPartial } from '../../types';
import {
exampleDataSnapshot,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DeepPartial, MockCloudEventAbstractFactory } from '../../types';
import { CloudEvent, CloudFunction } from 'firebase-functions';
import { CloudEvent, CloudFunction } from 'firebase-functions/v2';
import { getBaseCloudEvent } from '../helpers';

export const eventarcOnCustomEventPublished: MockCloudEventAbstractFactory<any> = {
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Loading

0 comments on commit cbf289a

Please sign in to comment.