Skip to content

Commit ff4fc3f

Browse files
authored
Update docs for pubsub to show string for topic + subscription (#1114)
The generated docs show the typing as `PubSubTopic` and `PubSubSubscription`. But to the end user they just need to know its a string.
1 parent 8d45c40 commit ff4fc3f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/v2/providers/pubsub.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ import * as options from '../options';
1212
* <li>Messages are listened to via a subscription.
1313
* <li>Each subscription listens to the messages published to exactly one topic.
1414
*/
15-
export type PubSubTopic = string;
15+
export type Topic = string;
1616

1717
/**
1818
* Resource that listens to the messages published by exactly one topic.
1919
*/
20-
export type PubSubSubscription = string;
20+
export type Subscription = string;
2121

2222
/**
2323
* Interface representing a Google Cloud Pub/Sub message.
@@ -111,13 +111,13 @@ export interface MessagePublishedData<T = any> {
111111
/** Google Cloud Pub/Sub message. */
112112
readonly message: Message<T>;
113113
/** A subscription resource. */
114-
readonly subscription: PubSubSubscription;
114+
readonly subscription: string;
115115
}
116116

117117
/** PubSubOptions extend EventHandlerOptions but must include a topic. */
118118
export interface PubSubOptions extends options.EventHandlerOptions {
119119
/** The Pub/Sub topic to watch for message events */
120-
topic: PubSubTopic;
120+
topic: string;
121121
}
122122

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

@@ -166,7 +166,7 @@ export function onMessagePublished<T = any>(
166166
const func = (raw: CloudEvent<unknown>) => {
167167
const messagePublishedData = raw.data as {
168168
message: unknown;
169-
subscription: PubSubSubscription;
169+
subscription: string;
170170
};
171171
messagePublishedData.message = new Message(messagePublishedData.message);
172172
return handler(raw as CloudEvent<MessagePublishedData<T>>);

0 commit comments

Comments
 (0)