Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/v2/providers/pubsub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import * as options from '../options';
* <li>Messages are listened to via a subscription.
* <li>Each subscription listens to the messages published to exactly one topic.
*/
export type PubSubTopic = string;
export type Topic = string;

/**
* Resource that listens to the messages published by exactly one topic.
*/
export type PubSubSubscription = string;
export type Subscription = string;

/**
* Interface representing a Google Cloud Pub/Sub message.
Expand Down Expand Up @@ -111,13 +111,13 @@ export interface MessagePublishedData<T = any> {
/** Google Cloud Pub/Sub message. */
readonly message: Message<T>;
/** A subscription resource. */
readonly subscription: PubSubSubscription;
readonly subscription: string;
}

/** PubSubOptions extend EventHandlerOptions but must include a topic. */
export interface PubSubOptions extends options.EventHandlerOptions {
/** The Pub/Sub topic to watch for message events */
topic: PubSubTopic;
topic: string;
}

/**
Expand All @@ -127,7 +127,7 @@ export interface PubSubOptions extends options.EventHandlerOptions {
* @typeParam T - Type representing `Message.data`'s JSON format
*/
export function onMessagePublished<T = any>(
topic: PubSubTopic,
topic: string,
handler: (event: CloudEvent<MessagePublishedData<T>>) => any | Promise<any>
): CloudFunction<CloudEvent<MessagePublishedData<T>>>;

Expand Down Expand Up @@ -166,7 +166,7 @@ export function onMessagePublished<T = any>(
const func = (raw: CloudEvent<unknown>) => {
const messagePublishedData = raw.data as {
message: unknown;
subscription: PubSubSubscription;
subscription: string;
};
messagePublishedData.message = new Message(messagePublishedData.message);
return handler(raw as CloudEvent<MessagePublishedData<T>>);
Expand Down