Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add Queues message contentType to types #879

Merged

Conversation

kewbish
Copy link
Contributor

@kewbish kewbish commented Jul 19, 2023

Following on from #690, this PR changes the type definitions for the Queues message .send() and .sendBatch() functions to reflect the new contentType option. This was originally left out of the generated types so it could be tested before it was documented (see here)

(cc @jbwcloudflare)

@github-actions
Copy link

github-actions bot commented Jul 19, 2023

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

github-actions bot added a commit that referenced this pull request Jul 19, 2023
@jbwcloudflare
Copy link
Contributor

This looks pretty solid to me. We should get some eyes from folks with more experience with workerd and the auto-generated workers-types (e.g. @jasnell + @mrbbot or their delegates).

I think there is also a way to inspect the generated types on your dev machine, so we can give them a quick look.

@kewbish
Copy link
Contributor Author

kewbish commented Jul 19, 2023

I think there is also a way to inspect the generated types on your dev machine, so we can give them a quick look.

Ah good idea - the relevant bit is this:

declare type QueueContentType = "text" | "bytes" | "json" | "v8";
declare interface Queue<Body> {
  send(message: Body, options?: QueueSendOptions): Promise<void>;
  sendBatch(messages: Iterable<MessageSendRequest<Body>>): Promise<void>;
}
declare interface QueueSendOptions {
  contentType?: QueueContentType;
}
declare interface MessageSendRequest<Body = unknown> {
  body: Body;
  contentType?: QueueContentType;
}

@kewbish
Copy link
Contributor Author

kewbish commented Jul 20, 2023

Thanks for the reviews! Could someone merge and run the Publish types to NPM action for me (or whatever the release process is for Workers types) please? I don't have permissions 😅

@mrbbot
Copy link
Contributor

mrbbot commented Jul 20, 2023

@kewbish will get #878 merged too, and then publish a new version of the types. 👍

@kewbish kewbish deleted the ema/add-queues-message-contenttype-to-types branch July 20, 2023 16:58
@mrbbot
Copy link
Contributor

mrbbot commented Jul 21, 2023

@cloudflare/workers-types@4.20230717.1 has been published including these changes 👍

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants