From 25cd5c9e7adbed198318c62439b53176b2f39925 Mon Sep 17 00:00:00 2001 From: Daniel Lee Date: Thu, 6 Nov 2025 14:54:53 -0800 Subject: [PATCH 1/4] fix: rename v1 Event to LegacyEvent to avoid api-extractor conflict --- src/v1/cloud-functions.ts | 18 +++++++++--------- src/v1/providers/analytics.ts | 4 ++-- src/v1/providers/auth.ts | 4 ++-- src/v1/providers/database.ts | 10 +++++----- src/v1/providers/firestore.ts | 10 +++++----- src/v1/providers/testLab.ts | 4 ++-- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/v1/cloud-functions.ts b/src/v1/cloud-functions.ts index 7fd24252b..ac0d87752 100644 --- a/src/v1/cloud-functions.ts +++ b/src/v1/cloud-functions.ts @@ -54,7 +54,7 @@ const WILDCARD_REGEX = new RegExp("{[^/{}]*}", "g"); /** * Wire format for an event. */ -export interface Event { +export interface LegacyEvent { /** * Wire format for an event context. */ @@ -344,7 +344,7 @@ export interface BlockingFunction { * from your JavaScript file to define a Cloud Function. * * This type is a special JavaScript function which takes a templated - * `Event` object as its only argument. + * `LegacyEvent` object as its only argument. */ export interface CloudFunction extends Runnable { (input: any, context?: any): PromiseLike | any; @@ -361,10 +361,10 @@ export interface CloudFunction extends Runnable { /** @internal */ export interface MakeCloudFunctionArgs { - after?: (raw: Event) => void; - before?: (raw: Event) => void; + after?: (raw: LegacyEvent) => void; + before?: (raw: LegacyEvent) => void; contextOnlyHandler?: (context: EventContext) => PromiseLike | any; - dataConstructor?: (raw: Event) => EventData; + dataConstructor?: (raw: LegacyEvent) => EventData; eventType: string; handler?: (data: EventData, context: EventContext) => PromiseLike | any; labels?: Record; @@ -382,7 +382,7 @@ export interface MakeCloudFunctionArgs { /** @internal */ export function makeCloudFunction({ contextOnlyHandler, - dataConstructor = (raw: Event) => raw.data, + dataConstructor = (raw: LegacyEvent) => raw.data, eventType, handler, labels = {}, @@ -406,7 +406,7 @@ export function makeCloudFunction({ }; } - const event: Event = { + const event: LegacyEvent = { data, context, }; @@ -550,7 +550,7 @@ function _makeParams( return params; } -function _makeAuth(event: Event, authType: string) { +function _makeAuth(event: LegacyEvent, authType: string) { if (authType === "UNAUTHENTICATED") { return null; } @@ -560,7 +560,7 @@ function _makeAuth(event: Event, authType: string) { }; } -function _detectAuthType(event: Event) { +function _detectAuthType(event: LegacyEvent) { if (event.context?.auth?.admin) { return "ADMIN"; } diff --git a/src/v1/providers/analytics.ts b/src/v1/providers/analytics.ts index 2168df487..3049f0c97 100644 --- a/src/v1/providers/analytics.ts +++ b/src/v1/providers/analytics.ts @@ -20,7 +20,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -import { CloudFunction, Event, EventContext, makeCloudFunction } from "../cloud-functions"; +import { CloudFunction, LegacyEvent, EventContext, makeCloudFunction } from "../cloud-functions"; import { DeploymentOptions } from "../function-configuration"; /** @internal */ @@ -70,7 +70,7 @@ export class AnalyticsEventBuilder { onLog( handler: (event: AnalyticsEvent, context: EventContext) => PromiseLike | any ): CloudFunction { - const dataConstructor = (raw: Event) => { + const dataConstructor = (raw: LegacyEvent) => { return new AnalyticsEvent(raw.data); }; return makeCloudFunction({ diff --git a/src/v1/providers/auth.ts b/src/v1/providers/auth.ts index e6990f495..e7100b048 100644 --- a/src/v1/providers/auth.ts +++ b/src/v1/providers/auth.ts @@ -40,7 +40,7 @@ import { import { BlockingFunction, CloudFunction, - Event, + LegacyEvent, EventContext, makeCloudFunction, optionsToEndpoint, @@ -108,7 +108,7 @@ export function _userWithOptions(options: DeploymentOptions, userOptions: UserOp * @public */ export class UserBuilder { - private static dataConstructor(raw: Event): UserRecord { + private static dataConstructor(raw: LegacyEvent): UserRecord { return userRecordConstructor(raw.data); } diff --git a/src/v1/providers/database.ts b/src/v1/providers/database.ts index d59d7de19..bca59f57d 100644 --- a/src/v1/providers/database.ts +++ b/src/v1/providers/database.ts @@ -27,7 +27,7 @@ import { ParamsOf } from "../../common/params"; import { DataSnapshot } from "../../common/providers/database"; import { normalizePath } from "../../common/utilities/path"; import { applyChange } from "../../common/utilities/utils"; -import { CloudFunction, Event, EventContext, makeCloudFunction } from "../cloud-functions"; +import { CloudFunction, LegacyEvent, EventContext, makeCloudFunction } from "../cloud-functions"; import { DeploymentOptions } from "../function-configuration"; export { DataSnapshot }; @@ -217,7 +217,7 @@ export class RefBuilder { context: EventContext> ) => PromiseLike | any ): CloudFunction { - const dataConstructor = (raw: Event) => { + const dataConstructor = (raw: LegacyEvent) => { const [dbInstance, path] = extractInstanceAndPath( raw.context.resource.name, raw.context.domain @@ -241,7 +241,7 @@ export class RefBuilder { context: EventContext> ) => PromiseLike | any ): CloudFunction { - const dataConstructor = (raw: Event) => { + const dataConstructor = (raw: LegacyEvent) => { const [dbInstance, path] = extractInstanceAndPath( raw.context.resource.name, raw.context.domain @@ -254,7 +254,7 @@ export class RefBuilder { private onOperation( handler: (data: T, context: EventContext) => PromiseLike | any, eventType: string, - dataConstructor: (raw: Event | Event) => any + dataConstructor: (raw: LegacyEvent | LegacyEvent) => any ): CloudFunction { return makeCloudFunction({ handler, @@ -268,7 +268,7 @@ export class RefBuilder { }); } - private changeConstructor = (raw: Event): Change => { + private changeConstructor = (raw: LegacyEvent): Change => { const [dbInstance, path] = extractInstanceAndPath( raw.context.resource.name, raw.context.domain diff --git a/src/v1/providers/firestore.ts b/src/v1/providers/firestore.ts index 00ee71114..2cf906944 100644 --- a/src/v1/providers/firestore.ts +++ b/src/v1/providers/firestore.ts @@ -29,7 +29,7 @@ import { createBeforeSnapshotFromJson, createSnapshotFromJson, } from "../../common/providers/firestore"; -import { CloudFunction, Event, EventContext, makeCloudFunction } from "../cloud-functions"; +import { CloudFunction, LegacyEvent, EventContext, makeCloudFunction } from "../cloud-functions"; import { DeploymentOptions } from "../function-configuration"; /** @internal */ @@ -120,7 +120,7 @@ export class NamespaceBuilder { } } -export function snapshotConstructor(event: Event): DocumentSnapshot { +export function snapshotConstructor(event: LegacyEvent): DocumentSnapshot { return createSnapshotFromJson( event.data, event.context.resource.name, @@ -130,7 +130,7 @@ export function snapshotConstructor(event: Event): DocumentSnapshot { } // TODO remove this function when wire format changes to new format -export function beforeSnapshotConstructor(event: Event): DocumentSnapshot { +export function beforeSnapshotConstructor(event: LegacyEvent): DocumentSnapshot { return createBeforeSnapshotFromJson( event.data, event.context.resource.name, @@ -139,7 +139,7 @@ export function beforeSnapshotConstructor(event: Event): DocumentSnapshot { ); } -function changeConstructor(raw: Event) { +function changeConstructor(raw: LegacyEvent) { return Change.fromObjects(beforeSnapshotConstructor(raw), snapshotConstructor(raw)); } @@ -191,7 +191,7 @@ export class DocumentBuilder { private onOperation( handler: (data: T, context: EventContext>) => PromiseLike | any, eventType: string, - dataConstructor: (raw: Event) => any + dataConstructor: (raw: LegacyEvent) => any ): CloudFunction { return makeCloudFunction({ handler, diff --git a/src/v1/providers/testLab.ts b/src/v1/providers/testLab.ts index ae9f9e584..3ae851437 100644 --- a/src/v1/providers/testLab.ts +++ b/src/v1/providers/testLab.ts @@ -20,7 +20,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -import { CloudFunction, Event, EventContext, makeCloudFunction } from "../cloud-functions"; +import { CloudFunction, LegacyEvent, EventContext, makeCloudFunction } from "../cloud-functions"; import { DeploymentOptions } from "../function-configuration"; /** @internal */ @@ -54,7 +54,7 @@ export class TestMatrixBuilder { onComplete( handler: (testMatrix: TestMatrix, context: EventContext) => PromiseLike | any ): CloudFunction { - const dataConstructor = (raw: Event) => { + const dataConstructor = (raw: LegacyEvent) => { return new TestMatrix(raw.data); }; return makeCloudFunction({ From e162ceca7caba4e3620b5779992f9a058f727b41 Mon Sep 17 00:00:00 2001 From: Daniel Lee Date: Thu, 6 Nov 2025 15:00:22 -0800 Subject: [PATCH 2/4] fix: add changelog entry for #1767 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ecb712245..c2ef4e0cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,3 +4,4 @@ - BREAKING: Unhandled errors in async `onRequest` handlers in the Emulator now return a 500 error immediately. (#1755) - Add support for ESM (ECMAScript Modules) alongside CommonJS. (#1750) - Add `onMutationExecuted()` trigger for Firebase Data Connect. (#1727) +- BREAKING: Rename v1 Event to LegacyEvent to avoid api-extractor conflict. (#1767) \ No newline at end of file From 1d867cb504a28695b307fd1a25896add6c4491d3 Mon Sep 17 00:00:00 2001 From: Daniel Lee Date: Thu, 6 Nov 2025 15:06:33 -0800 Subject: [PATCH 3/4] rename type in specs. --- spec/v1/cloud-functions.spec.ts | 10 +++++----- spec/v1/providers/analytics.spec.ts | 12 ++++++------ spec/v1/providers/auth.spec.ts | 4 ++-- spec/v1/providers/pubsub.spec.ts | 4 ++-- spec/v1/providers/remoteConfig.spec.ts | 4 ++-- spec/v1/providers/storage.spec.ts | 4 ++-- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/spec/v1/cloud-functions.spec.ts b/spec/v1/cloud-functions.spec.ts index d85afbe2f..8729f300b 100644 --- a/spec/v1/cloud-functions.spec.ts +++ b/spec/v1/cloud-functions.spec.ts @@ -24,7 +24,7 @@ import { expect } from "chai"; import { onInit, - Event, + LegacyEvent, EventContext, makeCloudFunction, MakeCloudFunctionArgs, @@ -43,7 +43,7 @@ describe("makeCloudFunction", () => { }; it("calls init function", async () => { - const test: Event = { + const test: LegacyEvent = { context: { eventId: "00000", timestamp: "2016-11-04T21:29:03.496Z", @@ -253,7 +253,7 @@ describe("makeCloudFunction", () => { handler: (data: any, context: EventContext) => context, }; const cf = makeCloudFunction(args); - const test: Event = { + const test: LegacyEvent = { context: { eventId: "00000", timestamp: "2016-11-04T21:29:03.496Z", @@ -285,7 +285,7 @@ describe("makeCloudFunction", () => { triggerResource: () => null, }; const cf = makeCloudFunction(args); - const test: Event = { + const test: LegacyEvent = { context: { eventId: "00000", timestamp: "2016-11-04T21:29:03.496Z", @@ -325,7 +325,7 @@ describe("makeParams", () => { const cf = makeCloudFunction(args); it("should construct params from the event resource of events", () => { - const testEvent: Event = { + const testEvent: LegacyEvent = { context: { eventId: "111", timestamp: "2016-11-04T21:29:03.496Z", diff --git a/spec/v1/providers/analytics.spec.ts b/spec/v1/providers/analytics.spec.ts index 2cc1d8ecd..af1e09ad0 100644 --- a/spec/v1/providers/analytics.spec.ts +++ b/spec/v1/providers/analytics.spec.ts @@ -23,7 +23,7 @@ import { expect } from "chai"; import * as functions from "../../../src/v1"; -import { Event } from "../../../src/v1/cloud-functions"; +import { LegacyEvent } from "../../../src/v1/cloud-functions"; import * as analytics from "../../../src/v1/providers/analytics"; import * as analyticsSpecInput from "./analytics.spec.input"; import { MINIMAL_V1_ENDPOINT } from "../../fixtures"; @@ -92,7 +92,7 @@ describe("Analytics Functions", () => { // The event data delivered over the wire will be the JSON for an AnalyticsEvent: // https://firebase.google.com/docs/auth/admin/manage-users#retrieve_user_data - const event: Event = { + const event: LegacyEvent = { data: { userDim: { userId: "hi!", @@ -126,7 +126,7 @@ describe("Analytics Functions", () => { // Incoming events will have four kinds of "xValue" fields: "intValue", // "stringValue", "doubleValue" and "floatValue". We expect those to get // flattened away, leaving just their values. - const event: Event = { + const event: LegacyEvent = { data: { eventDim: [ { @@ -193,7 +193,7 @@ describe("Analytics Functions", () => { .event("first_open") .onLog((data: analytics.AnalyticsEvent) => data); - const event: Event = { + const event: LegacyEvent = { data: { eventDim: [ { @@ -264,7 +264,7 @@ describe("Analytics Functions", () => { // // Separately, the input has a number of microsecond timestamps that we'd // like to rename and scale down to milliseconds. - const event: Event = { + const event: LegacyEvent = { data: { eventDim: [ { @@ -311,7 +311,7 @@ describe("Analytics Functions", () => { .event("app_remove") .onLog((data: analytics.AnalyticsEvent) => data); - const event: Event = { + const event: LegacyEvent = { data: { eventDim: [ { diff --git a/spec/v1/providers/auth.spec.ts b/spec/v1/providers/auth.spec.ts index ec1a793f5..f252bb75b 100644 --- a/spec/v1/providers/auth.spec.ts +++ b/spec/v1/providers/auth.spec.ts @@ -23,12 +23,12 @@ import { expect } from "chai"; import { UserRecord } from "../../../src/common/providers/identity"; import * as functions from "../../../src/v1"; -import { CloudFunction, Event } from "../../../src/v1/cloud-functions"; +import { CloudFunction, LegacyEvent } from "../../../src/v1/cloud-functions"; import * as auth from "../../../src/v1/providers/auth"; import { MINIMAL_V1_ENDPOINT } from "../../fixtures"; describe("Auth Functions", () => { - const event: Event = { + const event: LegacyEvent = { data: { metadata: { creationTime: "2016-12-15T19:37:37.059Z", diff --git a/spec/v1/providers/pubsub.spec.ts b/spec/v1/providers/pubsub.spec.ts index 0a7b89ad6..eed99bc85 100644 --- a/spec/v1/providers/pubsub.spec.ts +++ b/spec/v1/providers/pubsub.spec.ts @@ -22,7 +22,7 @@ import { expect } from "chai"; -import { Event, RESET_VALUE } from "../../../src/v1"; +import { LegacyEvent, RESET_VALUE } from "../../../src/v1"; import { MINIMAL_V1_ENDPOINT } from "../../fixtures"; import { MINIMAL_SCHEDULE_TRIGGER } from "./fixtures"; import * as functions from "../../../src/v1"; @@ -125,7 +125,7 @@ describe("Pubsub Functions", () => { it("should properly handle a new-style event", () => { const raw = new Buffer('{"hello":"world"}', "utf8").toString("base64"); - const event: Event = { + const event: LegacyEvent = { data: { data: raw, attributes: { diff --git a/spec/v1/providers/remoteConfig.spec.ts b/spec/v1/providers/remoteConfig.spec.ts index e207b5de3..695140432 100644 --- a/spec/v1/providers/remoteConfig.spec.ts +++ b/spec/v1/providers/remoteConfig.spec.ts @@ -22,7 +22,7 @@ import { expect } from "chai"; import * as functions from "../../../src/v1"; -import { CloudFunction, Event } from "../../../src/v1/cloud-functions"; +import { CloudFunction, LegacyEvent } from "../../../src/v1/cloud-functions"; import * as remoteConfig from "../../../src/v1/providers/remoteConfig"; import { MINIMAL_V1_ENDPOINT } from "../../fixtures"; @@ -96,7 +96,7 @@ describe("RemoteConfig Functions", () => { describe("unwraps TemplateVersion", () => { let cloudFunctionUpdate: CloudFunction; - let event: Event; + let event: LegacyEvent; before(() => { process.env.GCLOUD_PROJECT = "project1"; diff --git a/spec/v1/providers/storage.spec.ts b/spec/v1/providers/storage.spec.ts index 77f8610fc..84094204b 100644 --- a/spec/v1/providers/storage.spec.ts +++ b/spec/v1/providers/storage.spec.ts @@ -21,7 +21,7 @@ // SOFTWARE. import { expect } from "chai"; -import { Event } from "../../../src/v1"; +import { LegacyEvent } from "../../../src/v1"; import * as config from "../../../src/common/config"; import * as functions from "../../../src/v1"; import * as storage from "../../../src/v1/providers/storage"; @@ -136,7 +136,7 @@ describe("Storage Functions", () => { const cloudFunction = storage.object().onArchive((data) => { return data.mediaLink; }); - const goodMediaLinkEvent: Event = { + const goodMediaLinkEvent: LegacyEvent = { data: { mediaLink: "https://www.googleapis.com/storage/v1/b/mybucket.appspot.com" + From 38f7c924f5420c982e6a728c52b6c565716a70b4 Mon Sep 17 00:00:00 2001 From: Daniel Lee Date: Thu, 6 Nov 2025 15:08:23 -0800 Subject: [PATCH 4/4] make formatter happy. --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c2ef4e0cc..a89f89ba1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,4 +4,4 @@ - BREAKING: Unhandled errors in async `onRequest` handlers in the Emulator now return a 500 error immediately. (#1755) - Add support for ESM (ECMAScript Modules) alongside CommonJS. (#1750) - Add `onMutationExecuted()` trigger for Firebase Data Connect. (#1727) -- BREAKING: Rename v1 Event to LegacyEvent to avoid api-extractor conflict. (#1767) \ No newline at end of file +- BREAKING: Rename v1 Event to LegacyEvent to avoid api-extractor conflict. (#1767)