Skip to content
Open
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
20 changes: 18 additions & 2 deletions src/providers/pubsub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,31 @@

import { pubsub } from 'firebase-functions/v1';

/** Create a Message from a JSON object. */
/**
* Create a Message from a JSON object.
*
* Note: this helper is for v1 `functions.pubsub.topic(...).onPublish` functions
* only. Do not pass its result to `wrapV2`; for v2 `onMessagePublished`
* functions, pass a plain CloudEvent partial instead, e.g.
* `wrapV2(fn)({ data: { message: { json: { hello: 'world' } } } })` or
* `wrapV2(fn)({ data: { message: { data: base64String } } })`.
*/
export function makeMessage(
/** Content of message. */
json: { [key: string]: any },
/** Optional Pubsub message attributes. */
attributes?: { [key: string]: string }
): pubsub.Message;

/** Create a Message from a base-64 encoded string. */
/**
* Create a Message from a base-64 encoded string.
*
* Note: this helper is for v1 `functions.pubsub.topic(...).onPublish` functions
* only. Do not pass its result to `wrapV2`; for v2 `onMessagePublished`
* functions, pass a plain CloudEvent partial instead, e.g.
* `wrapV2(fn)({ data: { message: { json: { hello: 'world' } } } })` or
* `wrapV2(fn)({ data: { message: { data: base64String } } })`.
*/
export function makeMessage(
/** Base-64 encoded message string. */
encodedString: string,
Expand Down
Loading