Skip to content

Commit 4a99eb5

Browse files
authored
fix: rename v1 Event to LegacyEvent to avoid api-extractor conflict (#1767)
* fix: rename v1 Event to LegacyEvent to avoid api-extractor conflict * fix: add changelog entry for #1767 * rename type in specs. * make formatter happy.
1 parent 7a97e7c commit 4a99eb5

File tree

13 files changed

+45
-44
lines changed

13 files changed

+45
-44
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
- BREAKING: Unhandled errors in async `onRequest` handlers in the Emulator now return a 500 error immediately. (#1755)
55
- Add support for ESM (ECMAScript Modules) alongside CommonJS. (#1750)
66
- Add `onMutationExecuted()` trigger for Firebase Data Connect. (#1727)
7+
- BREAKING: Rename v1 Event to LegacyEvent to avoid api-extractor conflict. (#1767)

spec/v1/cloud-functions.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { expect } from "chai";
2424

2525
import {
2626
onInit,
27-
Event,
27+
LegacyEvent,
2828
EventContext,
2929
makeCloudFunction,
3030
MakeCloudFunctionArgs,
@@ -43,7 +43,7 @@ describe("makeCloudFunction", () => {
4343
};
4444

4545
it("calls init function", async () => {
46-
const test: Event = {
46+
const test: LegacyEvent = {
4747
context: {
4848
eventId: "00000",
4949
timestamp: "2016-11-04T21:29:03.496Z",
@@ -253,7 +253,7 @@ describe("makeCloudFunction", () => {
253253
handler: (data: any, context: EventContext) => context,
254254
};
255255
const cf = makeCloudFunction(args);
256-
const test: Event = {
256+
const test: LegacyEvent = {
257257
context: {
258258
eventId: "00000",
259259
timestamp: "2016-11-04T21:29:03.496Z",
@@ -285,7 +285,7 @@ describe("makeCloudFunction", () => {
285285
triggerResource: () => null,
286286
};
287287
const cf = makeCloudFunction(args);
288-
const test: Event = {
288+
const test: LegacyEvent = {
289289
context: {
290290
eventId: "00000",
291291
timestamp: "2016-11-04T21:29:03.496Z",
@@ -325,7 +325,7 @@ describe("makeParams", () => {
325325
const cf = makeCloudFunction(args);
326326

327327
it("should construct params from the event resource of events", () => {
328-
const testEvent: Event = {
328+
const testEvent: LegacyEvent = {
329329
context: {
330330
eventId: "111",
331331
timestamp: "2016-11-04T21:29:03.496Z",

spec/v1/providers/analytics.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import { expect } from "chai";
2424

2525
import * as functions from "../../../src/v1";
26-
import { Event } from "../../../src/v1/cloud-functions";
26+
import { LegacyEvent } from "../../../src/v1/cloud-functions";
2727
import * as analytics from "../../../src/v1/providers/analytics";
2828
import * as analyticsSpecInput from "./analytics.spec.input";
2929
import { MINIMAL_V1_ENDPOINT } from "../../fixtures";
@@ -92,7 +92,7 @@ describe("Analytics Functions", () => {
9292

9393
// The event data delivered over the wire will be the JSON for an AnalyticsEvent:
9494
// https://firebase.google.com/docs/auth/admin/manage-users#retrieve_user_data
95-
const event: Event = {
95+
const event: LegacyEvent = {
9696
data: {
9797
userDim: {
9898
userId: "hi!",
@@ -126,7 +126,7 @@ describe("Analytics Functions", () => {
126126
// Incoming events will have four kinds of "xValue" fields: "intValue",
127127
// "stringValue", "doubleValue" and "floatValue". We expect those to get
128128
// flattened away, leaving just their values.
129-
const event: Event = {
129+
const event: LegacyEvent = {
130130
data: {
131131
eventDim: [
132132
{
@@ -193,7 +193,7 @@ describe("Analytics Functions", () => {
193193
.event("first_open")
194194
.onLog((data: analytics.AnalyticsEvent) => data);
195195

196-
const event: Event = {
196+
const event: LegacyEvent = {
197197
data: {
198198
eventDim: [
199199
{
@@ -264,7 +264,7 @@ describe("Analytics Functions", () => {
264264
//
265265
// Separately, the input has a number of microsecond timestamps that we'd
266266
// like to rename and scale down to milliseconds.
267-
const event: Event = {
267+
const event: LegacyEvent = {
268268
data: {
269269
eventDim: [
270270
{
@@ -311,7 +311,7 @@ describe("Analytics Functions", () => {
311311
.event("app_remove")
312312
.onLog((data: analytics.AnalyticsEvent) => data);
313313

314-
const event: Event = {
314+
const event: LegacyEvent = {
315315
data: {
316316
eventDim: [
317317
{

spec/v1/providers/auth.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
import { expect } from "chai";
2424
import { UserRecord } from "../../../src/common/providers/identity";
2525
import * as functions from "../../../src/v1";
26-
import { CloudFunction, Event } from "../../../src/v1/cloud-functions";
26+
import { CloudFunction, LegacyEvent } from "../../../src/v1/cloud-functions";
2727
import * as auth from "../../../src/v1/providers/auth";
2828
import { MINIMAL_V1_ENDPOINT } from "../../fixtures";
2929

3030
describe("Auth Functions", () => {
31-
const event: Event = {
31+
const event: LegacyEvent = {
3232
data: {
3333
metadata: {
3434
creationTime: "2016-12-15T19:37:37.059Z",

spec/v1/providers/pubsub.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
import { expect } from "chai";
2424

25-
import { Event, RESET_VALUE } from "../../../src/v1";
25+
import { LegacyEvent, RESET_VALUE } from "../../../src/v1";
2626
import { MINIMAL_V1_ENDPOINT } from "../../fixtures";
2727
import { MINIMAL_SCHEDULE_TRIGGER } from "./fixtures";
2828
import * as functions from "../../../src/v1";
@@ -125,7 +125,7 @@ describe("Pubsub Functions", () => {
125125

126126
it("should properly handle a new-style event", () => {
127127
const raw = new Buffer('{"hello":"world"}', "utf8").toString("base64");
128-
const event: Event = {
128+
const event: LegacyEvent = {
129129
data: {
130130
data: raw,
131131
attributes: {

spec/v1/providers/remoteConfig.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import { expect } from "chai";
2323

2424
import * as functions from "../../../src/v1";
25-
import { CloudFunction, Event } from "../../../src/v1/cloud-functions";
25+
import { CloudFunction, LegacyEvent } from "../../../src/v1/cloud-functions";
2626
import * as remoteConfig from "../../../src/v1/providers/remoteConfig";
2727
import { MINIMAL_V1_ENDPOINT } from "../../fixtures";
2828

@@ -96,7 +96,7 @@ describe("RemoteConfig Functions", () => {
9696

9797
describe("unwraps TemplateVersion", () => {
9898
let cloudFunctionUpdate: CloudFunction<remoteConfig.TemplateVersion>;
99-
let event: Event;
99+
let event: LegacyEvent;
100100

101101
before(() => {
102102
process.env.GCLOUD_PROJECT = "project1";

spec/v1/providers/storage.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
// SOFTWARE.
2222

2323
import { expect } from "chai";
24-
import { Event } from "../../../src/v1";
24+
import { LegacyEvent } from "../../../src/v1";
2525
import * as config from "../../../src/common/config";
2626
import * as functions from "../../../src/v1";
2727
import * as storage from "../../../src/v1/providers/storage";
@@ -136,7 +136,7 @@ describe("Storage Functions", () => {
136136
const cloudFunction = storage.object().onArchive((data) => {
137137
return data.mediaLink;
138138
});
139-
const goodMediaLinkEvent: Event = {
139+
const goodMediaLinkEvent: LegacyEvent = {
140140
data: {
141141
mediaLink:
142142
"https://www.googleapis.com/storage/v1/b/mybucket.appspot.com" +

src/v1/cloud-functions.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const WILDCARD_REGEX = new RegExp("{[^/{}]*}", "g");
5454
/**
5555
* Wire format for an event.
5656
*/
57-
export interface Event {
57+
export interface LegacyEvent {
5858
/**
5959
* Wire format for an event context.
6060
*/
@@ -344,7 +344,7 @@ export interface BlockingFunction {
344344
* from your JavaScript file to define a Cloud Function.
345345
*
346346
* This type is a special JavaScript function which takes a templated
347-
* `Event` object as its only argument.
347+
* `LegacyEvent` object as its only argument.
348348
*/
349349
export interface CloudFunction<T> extends Runnable<T> {
350350
(input: any, context?: any): PromiseLike<any> | any;
@@ -361,10 +361,10 @@ export interface CloudFunction<T> extends Runnable<T> {
361361

362362
/** @internal */
363363
export interface MakeCloudFunctionArgs<EventData> {
364-
after?: (raw: Event) => void;
365-
before?: (raw: Event) => void;
364+
after?: (raw: LegacyEvent) => void;
365+
before?: (raw: LegacyEvent) => void;
366366
contextOnlyHandler?: (context: EventContext) => PromiseLike<any> | any;
367-
dataConstructor?: (raw: Event) => EventData;
367+
dataConstructor?: (raw: LegacyEvent) => EventData;
368368
eventType: string;
369369
handler?: (data: EventData, context: EventContext) => PromiseLike<any> | any;
370370
labels?: Record<string, string>;
@@ -382,7 +382,7 @@ export interface MakeCloudFunctionArgs<EventData> {
382382
/** @internal */
383383
export function makeCloudFunction<EventData>({
384384
contextOnlyHandler,
385-
dataConstructor = (raw: Event) => raw.data,
385+
dataConstructor = (raw: LegacyEvent) => raw.data,
386386
eventType,
387387
handler,
388388
labels = {},
@@ -406,7 +406,7 @@ export function makeCloudFunction<EventData>({
406406
};
407407
}
408408

409-
const event: Event = {
409+
const event: LegacyEvent = {
410410
data,
411411
context,
412412
};
@@ -550,7 +550,7 @@ function _makeParams(
550550
return params;
551551
}
552552

553-
function _makeAuth(event: Event, authType: string) {
553+
function _makeAuth(event: LegacyEvent, authType: string) {
554554
if (authType === "UNAUTHENTICATED") {
555555
return null;
556556
}
@@ -560,7 +560,7 @@ function _makeAuth(event: Event, authType: string) {
560560
};
561561
}
562562

563-
function _detectAuthType(event: Event) {
563+
function _detectAuthType(event: LegacyEvent) {
564564
if (event.context?.auth?.admin) {
565565
return "ADMIN";
566566
}

src/v1/providers/analytics.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
// SOFTWARE.
2222

23-
import { CloudFunction, Event, EventContext, makeCloudFunction } from "../cloud-functions";
23+
import { CloudFunction, LegacyEvent, EventContext, makeCloudFunction } from "../cloud-functions";
2424
import { DeploymentOptions } from "../function-configuration";
2525

2626
/** @internal */
@@ -70,7 +70,7 @@ export class AnalyticsEventBuilder {
7070
onLog(
7171
handler: (event: AnalyticsEvent, context: EventContext) => PromiseLike<any> | any
7272
): CloudFunction<AnalyticsEvent> {
73-
const dataConstructor = (raw: Event) => {
73+
const dataConstructor = (raw: LegacyEvent) => {
7474
return new AnalyticsEvent(raw.data);
7575
};
7676
return makeCloudFunction({

src/v1/providers/auth.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import {
4040
import {
4141
BlockingFunction,
4242
CloudFunction,
43-
Event,
43+
LegacyEvent,
4444
EventContext,
4545
makeCloudFunction,
4646
optionsToEndpoint,
@@ -108,7 +108,7 @@ export function _userWithOptions(options: DeploymentOptions, userOptions: UserOp
108108
* @public
109109
*/
110110
export class UserBuilder {
111-
private static dataConstructor(raw: Event): UserRecord {
111+
private static dataConstructor(raw: LegacyEvent): UserRecord {
112112
return userRecordConstructor(raw.data);
113113
}
114114

0 commit comments

Comments
 (0)