cloudflare / workerd

The JavaScript / Wasm runtime that powers Cloudflare Workers
https://blog.cloudflare.com/workerd-open-source-workers-runtime/
Apache License 2.0
6.07k stars 287 forks source link

Missing `include` property from `R2ListOptions ` #1522

Closed gnosticdev closed 8 months ago

gnosticdev commented 8 months ago

Per the API Reference:

R2ListOptions has an include property that accepts httpMetadata and/or customMetadata. If included, items returned by the list will include the specified metadata.

This property is not included in the typescript definitions:

declare interface R2ListOptions {
  limit?: number;
  prefix?: string;
  cursor?: string;
  delimiter?: string;
  startAfter?: string;
//include?: Array<string> <-- missing
}
KianNH commented 8 months ago

The @cloudflare/workers-types package has several folders which contain the correct types for different compatibility dates. If you don't specify one of those, you will default to the oldest types.

You need to be on (at least) the 2022-08-04 types for the include property, since it wasn't respected up until that compatibility date when it was fixed via the r2_list_honor_include flag.

Replace @cloudflare/workers-types in tsconfig.json with the appropriate set, i.e @cloudflare/workers-types/2023-07-01 if your compatibility date is on or after 2023-07-01.

gnosticdev commented 8 months ago

Ah I shouldve known that would have an impact. Thanks!

Jesse Greer

On Jan 8, 2024, at 8:37 PM, Kian @.***> wrote:

The @cloudflare/workers-types package has several folders which contain the correct types for different compatibility dates. If you don't specify one of those, you will default to the oldest types.

You need to be on (at least) the 2022-08-04 types for the include property, since it wasn't respected up until that compatibility date when it was fixed via the r2_list_honor_include https://developers.cloudflare.com/workers/configuration/compatibility-dates/#r2-bucket-list-respects-the-include-option flag.

Replace @cloudflare/workers-types in tsconfig.json with the appropriate set, i.e @cloudflare/workers-types/2023-07-01 if your compatibility date is on or after 2023-07-01.

— Reply to this email directly, view it on GitHub https://github.com/cloudflare/workerd/issues/1522#issuecomment-1882132968, or unsubscribe https://github.com/notifications/unsubscribe-auth/APM3ZKPZKRHSOCUMP4AXP7TYNSNPPAVCNFSM6AAAAABBSFYW5WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBSGEZTEOJWHA. You are receiving this because you authored the thread.

mrbbot commented 8 months ago

Looks like this has been resolved. We're working on a new types generation system that should make these kind of issues harder to come by. 👍