Skip to content

Commit 25cd5c9

Browse files
committed
fix: rename v1 Event to LegacyEvent to avoid api-extractor conflict
1 parent 7a97e7c commit 25cd5c9

File tree

6 files changed

+25
-25
lines changed

6 files changed

+25
-25
lines changed

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

src/v1/providers/database.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { ParamsOf } from "../../common/params";
2727
import { DataSnapshot } from "../../common/providers/database";
2828
import { normalizePath } from "../../common/utilities/path";
2929
import { applyChange } from "../../common/utilities/utils";
30-
import { CloudFunction, Event, EventContext, makeCloudFunction } from "../cloud-functions";
30+
import { CloudFunction, LegacyEvent, EventContext, makeCloudFunction } from "../cloud-functions";
3131
import { DeploymentOptions } from "../function-configuration";
3232

3333
export { DataSnapshot };
@@ -217,7 +217,7 @@ export class RefBuilder<Ref extends string> {
217217
context: EventContext<ParamsOf<Ref>>
218218
) => PromiseLike<any> | any
219219
): CloudFunction<DataSnapshot> {
220-
const dataConstructor = (raw: Event) => {
220+
const dataConstructor = (raw: LegacyEvent) => {
221221
const [dbInstance, path] = extractInstanceAndPath(
222222
raw.context.resource.name,
223223
raw.context.domain
@@ -241,7 +241,7 @@ export class RefBuilder<Ref extends string> {
241241
context: EventContext<ParamsOf<Ref>>
242242
) => PromiseLike<any> | any
243243
): CloudFunction<DataSnapshot> {
244-
const dataConstructor = (raw: Event) => {
244+
const dataConstructor = (raw: LegacyEvent) => {
245245
const [dbInstance, path] = extractInstanceAndPath(
246246
raw.context.resource.name,
247247
raw.context.domain
@@ -254,7 +254,7 @@ export class RefBuilder<Ref extends string> {
254254
private onOperation<T>(
255255
handler: (data: T, context: EventContext) => PromiseLike<any> | any,
256256
eventType: string,
257-
dataConstructor: (raw: Event | Event) => any
257+
dataConstructor: (raw: LegacyEvent | LegacyEvent) => any
258258
): CloudFunction<T> {
259259
return makeCloudFunction({
260260
handler,
@@ -268,7 +268,7 @@ export class RefBuilder<Ref extends string> {
268268
});
269269
}
270270

271-
private changeConstructor = (raw: Event): Change<DataSnapshot> => {
271+
private changeConstructor = (raw: LegacyEvent): Change<DataSnapshot> => {
272272
const [dbInstance, path] = extractInstanceAndPath(
273273
raw.context.resource.name,
274274
raw.context.domain

src/v1/providers/firestore.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import {
2929
createBeforeSnapshotFromJson,
3030
createSnapshotFromJson,
3131
} from "../../common/providers/firestore";
32-
import { CloudFunction, Event, EventContext, makeCloudFunction } from "../cloud-functions";
32+
import { CloudFunction, LegacyEvent, EventContext, makeCloudFunction } from "../cloud-functions";
3333
import { DeploymentOptions } from "../function-configuration";
3434

3535
/** @internal */
@@ -120,7 +120,7 @@ export class NamespaceBuilder {
120120
}
121121
}
122122

123-
export function snapshotConstructor(event: Event): DocumentSnapshot {
123+
export function snapshotConstructor(event: LegacyEvent): DocumentSnapshot {
124124
return createSnapshotFromJson(
125125
event.data,
126126
event.context.resource.name,
@@ -130,7 +130,7 @@ export function snapshotConstructor(event: Event): DocumentSnapshot {
130130
}
131131

132132
// TODO remove this function when wire format changes to new format
133-
export function beforeSnapshotConstructor(event: Event): DocumentSnapshot {
133+
export function beforeSnapshotConstructor(event: LegacyEvent): DocumentSnapshot {
134134
return createBeforeSnapshotFromJson(
135135
event.data,
136136
event.context.resource.name,
@@ -139,7 +139,7 @@ export function beforeSnapshotConstructor(event: Event): DocumentSnapshot {
139139
);
140140
}
141141

142-
function changeConstructor(raw: Event) {
142+
function changeConstructor(raw: LegacyEvent) {
143143
return Change.fromObjects(beforeSnapshotConstructor(raw), snapshotConstructor(raw));
144144
}
145145

@@ -191,7 +191,7 @@ export class DocumentBuilder<Path extends string> {
191191
private onOperation<T>(
192192
handler: (data: T, context: EventContext<ParamsOf<Path>>) => PromiseLike<any> | any,
193193
eventType: string,
194-
dataConstructor: (raw: Event) => any
194+
dataConstructor: (raw: LegacyEvent) => any
195195
): CloudFunction<T> {
196196
return makeCloudFunction({
197197
handler,

src/v1/providers/testLab.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 */
@@ -54,7 +54,7 @@ export class TestMatrixBuilder {
5454
onComplete(
5555
handler: (testMatrix: TestMatrix, context: EventContext) => PromiseLike<any> | any
5656
): CloudFunction<TestMatrix> {
57-
const dataConstructor = (raw: Event) => {
57+
const dataConstructor = (raw: LegacyEvent) => {
5858
return new TestMatrix(raw.data);
5959
};
6060
return makeCloudFunction({

0 commit comments

Comments
 (0)