@encore.dev/sdk 2.0.0-beta.15 → 2.0.0-beta.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (235) hide show
  1. package/README.md +111 -101
  2. package/app_meta.ts +56 -54
  3. package/config/config.ts +60 -57
  4. package/config/secrets.ts +45 -52
  5. package/config/value.ts +23 -26
  6. package/cron/mod.ts +28 -29
  7. package/dist/app_meta.d.ts +52 -50
  8. package/dist/app_meta.d.ts.map +1 -1
  9. package/dist/app_meta.js +2 -2
  10. package/dist/app_meta.js.map +1 -1
  11. package/dist/config/config.d.ts +58 -55
  12. package/dist/config/config.d.ts.map +1 -1
  13. package/dist/config/config.js +8 -9
  14. package/dist/config/config.js.map +1 -1
  15. package/dist/config/secrets.d.ts +45 -52
  16. package/dist/config/secrets.d.ts.map +1 -1
  17. package/dist/config/secrets.js +8 -9
  18. package/dist/config/secrets.js.map +1 -1
  19. package/dist/config/value.d.ts +20 -23
  20. package/dist/config/value.d.ts.map +1 -1
  21. package/dist/config/value.js +20 -23
  22. package/dist/config/value.js.map +1 -1
  23. package/dist/cron/mod.d.ts +26 -27
  24. package/dist/cron/mod.d.ts.map +1 -1
  25. package/dist/cron/mod.js +13 -14
  26. package/dist/cron/mod.js.map +1 -1
  27. package/dist/frontends/mod.d.ts +20 -19
  28. package/dist/frontends/mod.d.ts.map +1 -1
  29. package/dist/frontends/mod.js +20 -19
  30. package/dist/frontends/mod.js.map +1 -1
  31. package/dist/gateway/errors.d.ts +28 -30
  32. package/dist/gateway/errors.d.ts.map +1 -1
  33. package/dist/gateway/errors.js +29 -31
  34. package/dist/gateway/errors.js.map +1 -1
  35. package/dist/gateway/match.d.ts +54 -54
  36. package/dist/gateway/match.d.ts.map +1 -1
  37. package/dist/gateway/match.js +56 -56
  38. package/dist/gateway/match.js.map +1 -1
  39. package/dist/gateway/middleware.d.ts +62 -64
  40. package/dist/gateway/middleware.d.ts.map +1 -1
  41. package/dist/gateway/middleware.js +1 -1
  42. package/dist/gateway/middleware.js.map +1 -1
  43. package/dist/gateway/mod.d.ts +64 -67
  44. package/dist/gateway/mod.d.ts.map +1 -1
  45. package/dist/gateway/mod.js +72 -76
  46. package/dist/gateway/mod.js.map +1 -1
  47. package/dist/gateway/request.d.ts +138 -134
  48. package/dist/gateway/request.d.ts.map +1 -1
  49. package/dist/gateway/request.js +117 -108
  50. package/dist/gateway/request.js.map +1 -1
  51. package/dist/gateway/serve.d.ts +29 -34
  52. package/dist/gateway/serve.d.ts.map +1 -1
  53. package/dist/gateway/serve.js +51 -56
  54. package/dist/gateway/serve.js.map +1 -1
  55. package/dist/gateways/mod.d.ts +23 -21
  56. package/dist/gateways/mod.d.ts.map +1 -1
  57. package/dist/gateways/mod.js +25 -23
  58. package/dist/gateways/mod.js.map +1 -1
  59. package/dist/internal/runtime/napi/napi.cjs +1 -1
  60. package/dist/internal/runtime/napi/napi.d.cts +10 -3
  61. package/dist/internal/runtime/shutdown.d.ts +75 -57
  62. package/dist/internal/runtime/shutdown.d.ts.map +1 -1
  63. package/dist/internal/runtime/shutdown.js +88 -84
  64. package/dist/internal/runtime/shutdown.js.map +1 -1
  65. package/dist/log/logger.d.ts +43 -37
  66. package/dist/log/logger.d.ts.map +1 -1
  67. package/dist/log/logger.js +26 -25
  68. package/dist/log/logger.js.map +1 -1
  69. package/dist/metrics/mod.d.ts +133 -114
  70. package/dist/metrics/mod.d.ts.map +1 -1
  71. package/dist/metrics/mod.js +109 -101
  72. package/dist/metrics/mod.js.map +1 -1
  73. package/dist/otel.d.ts +6 -3
  74. package/dist/otel.d.ts.map +1 -1
  75. package/dist/otel.js +6 -3
  76. package/dist/otel.js.map +1 -1
  77. package/dist/pubsub/subscription.d.ts +88 -116
  78. package/dist/pubsub/subscription.d.ts.map +1 -1
  79. package/dist/pubsub/subscription.js +14 -17
  80. package/dist/pubsub/subscription.js.map +1 -1
  81. package/dist/pubsub/topic.d.ts +86 -113
  82. package/dist/pubsub/topic.d.ts.map +1 -1
  83. package/dist/pubsub/topic.js +68 -82
  84. package/dist/pubsub/topic.js.map +1 -1
  85. package/dist/reqctx/mod.d.ts +83 -86
  86. package/dist/reqctx/mod.d.ts.map +1 -1
  87. package/dist/reqctx/mod.js +39 -41
  88. package/dist/reqctx/mod.js.map +1 -1
  89. package/dist/services/index.d.ts +76 -75
  90. package/dist/services/index.d.ts.map +1 -1
  91. package/dist/services/index.js +73 -71
  92. package/dist/services/index.js.map +1 -1
  93. package/dist/shutdown/mod.d.ts +26 -25
  94. package/dist/shutdown/mod.d.ts.map +1 -1
  95. package/dist/shutdown/mod.js +26 -25
  96. package/dist/shutdown/mod.js.map +1 -1
  97. package/dist/storage/clickhouse/database.d.ts +113 -115
  98. package/dist/storage/clickhouse/database.d.ts.map +1 -1
  99. package/dist/storage/clickhouse/database.js +65 -79
  100. package/dist/storage/clickhouse/database.js.map +1 -1
  101. package/dist/storage/clickhouse/errors.d.ts +25 -26
  102. package/dist/storage/clickhouse/errors.d.ts.map +1 -1
  103. package/dist/storage/clickhouse/errors.js +15 -17
  104. package/dist/storage/clickhouse/errors.js.map +1 -1
  105. package/dist/storage/clickhouse/mod.d.ts +10 -10
  106. package/dist/storage/clickhouse/mod.js +10 -10
  107. package/dist/storage/objects/bucket.d.ts +196 -225
  108. package/dist/storage/objects/bucket.d.ts.map +1 -1
  109. package/dist/storage/objects/bucket.js +71 -84
  110. package/dist/storage/objects/bucket.js.map +1 -1
  111. package/dist/storage/objects/error.d.ts +4 -4
  112. package/dist/storage/objects/error.js +4 -4
  113. package/dist/storage/postgres/database.d.ts +124 -149
  114. package/dist/storage/postgres/database.d.ts.map +1 -1
  115. package/dist/storage/postgres/database.js +98 -135
  116. package/dist/storage/postgres/database.js.map +1 -1
  117. package/dist/storage/postgres/errors.d.ts +42 -48
  118. package/dist/storage/postgres/errors.d.ts.map +1 -1
  119. package/dist/storage/postgres/errors.js +44 -51
  120. package/dist/storage/postgres/errors.js.map +1 -1
  121. package/dist/storage/postgres/interval.d.ts +19 -19
  122. package/dist/storage/postgres/interval.d.ts.map +1 -1
  123. package/dist/storage/postgres/interval.js +21 -21
  124. package/dist/storage/postgres/interval.js.map +1 -1
  125. package/dist/storage/redis/bitfield.d.ts +48 -23
  126. package/dist/storage/redis/bitfield.d.ts.map +1 -1
  127. package/dist/storage/redis/bitfield.js +38 -19
  128. package/dist/storage/redis/bitfield.js.map +1 -1
  129. package/dist/storage/redis/command.d.ts +16 -12
  130. package/dist/storage/redis/command.d.ts.map +1 -1
  131. package/dist/storage/redis/command.js +16 -12
  132. package/dist/storage/redis/command.js.map +1 -1
  133. package/dist/storage/redis/commands.d.ts +99 -100
  134. package/dist/storage/redis/commands.d.ts.map +1 -1
  135. package/dist/storage/redis/commands.js +84 -85
  136. package/dist/storage/redis/commands.js.map +1 -1
  137. package/dist/storage/redis/database.d.ts +138 -122
  138. package/dist/storage/redis/database.d.ts.map +1 -1
  139. package/dist/storage/redis/database.js +120 -101
  140. package/dist/storage/redis/database.js.map +1 -1
  141. package/dist/storage/redis/mod.d.ts +52 -48
  142. package/dist/storage/redis/mod.d.ts.map +1 -1
  143. package/dist/storage/redis/mod.js +52 -48
  144. package/dist/storage/redis/mod.js.map +1 -1
  145. package/dist/storage/redis/options.d.ts +26 -24
  146. package/dist/storage/redis/options.d.ts.map +1 -1
  147. package/dist/storage/redis/options.js.map +1 -1
  148. package/dist/storage/redis/pubsub.d.ts +16 -16
  149. package/dist/storage/redis/pubsub.d.ts.map +1 -1
  150. package/dist/storage/redis/pubsub.js +14 -14
  151. package/dist/storage/redis/pubsub.js.map +1 -1
  152. package/dist/storage/redis/reply.d.ts +80 -72
  153. package/dist/storage/redis/reply.d.ts.map +1 -1
  154. package/dist/storage/redis/reply.js +53 -46
  155. package/dist/storage/redis/reply.js.map +1 -1
  156. package/dist/storage/redis/scan.d.ts +4 -4
  157. package/dist/storage/redis/scan.d.ts.map +1 -1
  158. package/dist/storage/redis/scan.js +6 -6
  159. package/dist/storage/redis/scan.js.map +1 -1
  160. package/dist/storage/redis/script.d.ts +28 -21
  161. package/dist/storage/redis/script.d.ts.map +1 -1
  162. package/dist/storage/redis/script.js +29 -22
  163. package/dist/storage/redis/script.js.map +1 -1
  164. package/dist/storage/redis/target.d.ts +17 -1
  165. package/dist/storage/redis/target.d.ts.map +1 -1
  166. package/dist/storage/redis/target.js +30 -1
  167. package/dist/storage/redis/target.js.map +1 -1
  168. package/dist/storage/redis/wire.d.ts +6 -6
  169. package/dist/storage/redis/wire.d.ts.map +1 -1
  170. package/dist/storage/redis/wire.js +6 -6
  171. package/dist/storage/redis/wire.js.map +1 -1
  172. package/dist/testing/mod.d.ts +83 -88
  173. package/dist/testing/mod.d.ts.map +1 -1
  174. package/dist/testing/mod.js +75 -81
  175. package/dist/testing/mod.js.map +1 -1
  176. package/dist/testing/playwright.d.ts +28 -32
  177. package/dist/testing/playwright.d.ts.map +1 -1
  178. package/dist/testing/playwright.js +22 -27
  179. package/dist/testing/playwright.js.map +1 -1
  180. package/dist/testing/puppeteer.d.ts +11 -12
  181. package/dist/testing/puppeteer.d.ts.map +1 -1
  182. package/dist/testing/puppeteer.js +17 -18
  183. package/dist/testing/puppeteer.js.map +1 -1
  184. package/dist/testing/system.d.ts +72 -90
  185. package/dist/testing/system.d.ts.map +1 -1
  186. package/dist/testing/system.js +90 -107
  187. package/dist/testing/system.js.map +1 -1
  188. package/dist/tsconfig.build.tsbuildinfo +1 -1
  189. package/frontends/mod.test.ts +6 -2
  190. package/frontends/mod.ts +20 -19
  191. package/gateway/errors.ts +30 -32
  192. package/gateway/match.ts +61 -57
  193. package/gateway/middleware.ts +62 -64
  194. package/gateway/mod.ts +73 -76
  195. package/gateway/request.ts +143 -140
  196. package/gateway/serve.ts +58 -63
  197. package/gateways/mod.ts +25 -23
  198. package/internal/runtime/napi/napi.cjs +1 -1
  199. package/internal/runtime/napi/napi.d.cts +10 -3
  200. package/internal/runtime/shutdown.ts +113 -101
  201. package/log/logger.test.ts +8 -0
  202. package/log/logger.ts +48 -45
  203. package/metrics/mod.ts +138 -122
  204. package/otel.ts +6 -3
  205. package/package.json +1 -1
  206. package/pubsub/subscription.ts +93 -123
  207. package/pubsub/topic.ts +96 -130
  208. package/reqctx/mod.ts +83 -86
  209. package/services/index.ts +78 -78
  210. package/shutdown/mod.ts +26 -25
  211. package/storage/clickhouse/database.ts +115 -129
  212. package/storage/clickhouse/errors.ts +27 -29
  213. package/storage/clickhouse/mod.ts +10 -10
  214. package/storage/objects/bucket.ts +209 -239
  215. package/storage/objects/error.ts +4 -4
  216. package/storage/postgres/database.ts +131 -164
  217. package/storage/postgres/errors.ts +45 -52
  218. package/storage/postgres/interval.ts +21 -21
  219. package/storage/redis/bitfield.ts +51 -26
  220. package/storage/redis/command.ts +16 -12
  221. package/storage/redis/commands.ts +99 -100
  222. package/storage/redis/database.ts +145 -123
  223. package/storage/redis/mod.ts +52 -48
  224. package/storage/redis/options.ts +26 -24
  225. package/storage/redis/pubsub.ts +14 -14
  226. package/storage/redis/redis.test.ts +17 -2
  227. package/storage/redis/reply.ts +85 -77
  228. package/storage/redis/scan.ts +6 -6
  229. package/storage/redis/script.ts +29 -22
  230. package/storage/redis/target.ts +34 -1
  231. package/storage/redis/wire.ts +8 -8
  232. package/testing/mod.ts +99 -105
  233. package/testing/playwright.ts +32 -37
  234. package/testing/puppeteer.ts +22 -23
  235. package/testing/system.ts +117 -133
@@ -19,129 +19,126 @@ import {
19
19
  } from './refs';
20
20
 
21
21
  /**
22
- * How often an object is expected to be read, which the cloud provider
23
- * prices its storage by.
22
+ * Storage tier indicating how frequently an object is accessed, used by cloud
23
+ * providers to price storage and retrieval:
24
24
  *
25
- * - `standard`: read often. No minimum storage duration and no retrieval fee.
26
- * - `infrequent`: read about once a month or less (GCS Nearline, S3
27
- * Standard-IA). Billed for at least 30 days, with a fee per read.
28
- * - `cold`: read about once a quarter or less (GCS Coldline, S3 Glacier
29
- * Instant Retrieval; Standard-IA on Cloudflare R2). Billed for at least
30
- * 90 days, with a higher fee per read.
25
+ * - `standard`: frequent access; no minimum storage duration or retrieval fee.
26
+ * - `infrequent`: accessed roughly once a month or less (GCS Nearline, S3
27
+ * Standard-IA); billed for at least 30 days with a per-read retrieval fee.
28
+ * - `cold`: accessed roughly once a quarter or less (GCS Coldline, S3 Glacier
29
+ * Instant Retrieval; Standard-IA on Cloudflare R2); billed for at least 90
30
+ * days with a higher per-read retrieval fee.
31
31
  *
32
- * Every class can be read immediately.
32
+ * Objects in every class remain immediately readable.
33
33
  */
34
34
  export type StorageClass = 'standard' | 'infrequent' | 'cold';
35
35
 
36
36
  /**
37
- * Configuration options for declaring a Bucket.
38
- *
39
- * Encore reads the configuration when it builds the app, so its values must
40
- * be literals.
37
+ * Configuration options for declaring a {@link Bucket}. Values must be
38
+ * literals so Encore can inspect them at build time.
41
39
  */
42
40
  export interface BucketConfig {
43
41
  /**
44
- * Whether the objects in the bucket should be publicly
45
- * accessible, via CDN. Defaults to false if unset.
42
+ * Whether objects in the bucket are publicly accessible via CDN.
43
+ * Defaults to `false`.
46
44
  */
47
45
  public?: boolean;
48
46
 
49
47
  /**
50
- * Whether to enable versioning of the objects in the bucket.
51
- * Defaults to false if unset.
48
+ * Whether object versioning is enabled on the bucket.
49
+ * Defaults to `false`.
52
50
  */
53
51
  versioned?: boolean;
54
52
 
55
53
  /**
56
- * The storage class of an object uploaded without one.
57
- * Defaults to `"standard"`.
54
+ * Default storage class for newly uploaded objects. Defaults to `"standard"`.
58
55
  *
59
- * `"auto"` lets the provider move each object between classes by how
60
- * often it is read (GCS Autoclass, S3 Intelligent-Tiering). It is a
61
- * bucket's class only: objects in such a bucket can't name a class, and
62
- * lifecycle rules can't move them.
56
+ * Setting `"auto"` delegates class transitions to the provider based on
57
+ * access patterns (GCS Autoclass, S3 Intelligent-Tiering). When `"auto"` is
58
+ * set, individual uploads cannot override `storageClass` and lifecycle rules
59
+ * cannot transition storage classes.
63
60
  */
64
61
  storageClass?: StorageClass | 'auto';
65
62
 
66
63
  /**
67
- * Rules that move objects to colder storage classes, or delete them, as
68
- * they age. Providers apply them asynchronously, usually within a day,
69
- * to the objects already in the bucket too.
64
+ * Lifecycle rules that automatically transition objects to colder storage
65
+ * classes or delete them as they age. Providers evaluate rules
66
+ * asynchronously (typically within a day), including for existing objects.
70
67
  */
71
68
  lifecycle?: LifecycleRule[];
72
69
 
73
70
  /**
74
- * Keep every object for at least this long after it was written: it
75
- * can't be deleted or overwritten sooner.
71
+ * Minimum retention period applied to every object in the bucket; objects
72
+ * cannot be deleted or overwritten before this period elapses.
76
73
  */
77
74
  retention?: Retention;
78
75
 
79
76
  /**
80
- * Whether objects can be given their own retain-until time, with the
81
- * `retainUntil` upload option and `extendRetention`.
82
- * Defaults to false if unset.
77
+ * Whether individual objects can specify their own `retainUntil` timestamp
78
+ * via upload options and {@link Bucket.extendRetention}. Defaults to `false`.
83
79
  */
84
80
  objectRetention?: boolean;
85
81
 
86
82
  /**
87
- * Tags that classify the bucket, for policies to read: written out as
88
- * string literals, as in `{data: "pci"}`. Keys and values are lowercase
89
- * letters, digits, `_` and `-`, at most 63 characters; a key starts with a
90
- * letter, and not with `encore`, which is reserved. At most 32 tags.
83
+ * Static string-literal tags that classify the bucket for policy checks
84
+ * (e.g. `{data: "pci"}`). Keys and values may contain lowercase letters,
85
+ * digits, `_`, and `-`, up to 63 characters. Keys must start with a letter
86
+ * and cannot start with the reserved prefix `encore`. At most 32 tags.
91
87
  */
92
88
  tags?: Record<string, string>;
93
89
  }
94
90
 
95
91
  /**
96
- * A lifecycle rule: an optional prefix and at least one action. Days are
97
- * whole numbers from 1 to 36500 and count from when an object was written,
98
- * or for the noncurrent fields, from when it was replaced or removed.
92
+ * A lifecycle rule with an optional key prefix and at least one action. Day
93
+ * counts are whole numbers from 1 to 36500 measured from creation time (or
94
+ * from replacement/deletion time for noncurrent version rules).
99
95
  */
100
96
  export interface LifecycleRule {
101
- /** Only objects whose names start with it. Defaults to every object. */
97
+ /** Restrict the rule to objects whose names start with this prefix. Defaults to all objects. */
102
98
  prefix?: string;
103
99
 
104
100
  /**
105
- * Move an object to `infrequent` this many days after it was written.
106
- * At least 30.
101
+ * Transition objects to `infrequent` storage this many days after creation.
102
+ * Must be at least 30.
107
103
  */
108
104
  moveToInfrequentAfterDays?: number;
109
105
 
110
106
  /**
111
- * Move an object to `cold` this many days after it was written. With
112
- * `moveToInfrequentAfterDays`, at least 30 days after it.
107
+ * Transition objects to `cold` storage this many days after creation. When
108
+ * combined with `moveToInfrequentAfterDays`, must be at least 30 days later.
113
109
  */
114
110
  moveToColdAfterDays?: number;
115
111
 
116
112
  /**
117
- * Delete an object this many days after it was written. In a versioned
118
- * bucket it becomes a noncurrent version, as `remove` does.
113
+ * Delete objects this many days after creation. In versioned buckets, the
114
+ * object becomes a noncurrent version (just like {@link Bucket.remove}).
119
115
  */
120
116
  deleteAfterDays?: number;
121
117
 
122
118
  /**
123
- * Versioned buckets: delete a noncurrent version this many days after it
124
- * was replaced or removed.
119
+ * Versioned buckets only: delete noncurrent versions this many days after
120
+ * they were replaced or removed.
125
121
  */
126
122
  deleteNoncurrentAfterDays?: number;
127
123
 
128
124
  /**
129
- * Versioned buckets: never delete the newest this many noncurrent
130
- * versions. On its own, delete the noncurrent versions beyond them.
125
+ * Versioned buckets only: retain at least this many of the newest noncurrent
126
+ * versions (deleting older noncurrent versions beyond this count when used
127
+ * on its own).
131
128
  */
132
129
  keepNoncurrentVersions?: number;
133
130
  }
134
131
 
135
132
  /**
136
- * A bucket's retention period.
133
+ * Bucket-level retention period.
137
134
  */
138
135
  export interface Retention {
139
- /** The days, from 1 to 36500, an object is kept after it was written. */
136
+ /** Number of days (1 to 36500) to retain each object after creation. */
140
137
  days: number;
141
138
  }
142
139
 
143
140
  /**
144
- * Defines a new Object Storage bucket infrastructure resource.
141
+ * Declares an Object Storage bucket infrastructure resource.
145
142
  */
146
143
  export class Bucket
147
144
  extends BucketPerms
@@ -159,11 +156,11 @@ export class Bucket
159
156
  IfMatchRemover
160
157
  {
161
158
  private readonly bucketName: string;
162
- /** The runtime's bucket: made on first use in test mode. */
159
+ /** Native runtime bucket, initialized lazily in test mode. */
163
160
  private own?: runtime.Bucket;
164
161
 
165
162
  /**
166
- * Creates a new bucket with the given name and configuration
163
+ * Declares a new bucket with the given name and configuration.
167
164
  */
168
165
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
169
166
  constructor(name: string, cfg?: BucketConfig) {
@@ -172,8 +169,7 @@ export class Bucket
172
169
  if (!testMode) this.own = runtime.RT.bucket(name);
173
170
  }
174
171
 
175
- /** The native bucket: in a test, the test's instance of it.
176
- * @internal */
172
+ /** Native bucket handle (resolves to the current test's instance in test mode). @internal */
177
173
  get impl(): runtime.Bucket {
178
174
  return (
179
175
  currentScope()?.bucket(this.bucketName) ??
@@ -182,19 +178,19 @@ export class Bucket
182
178
  }
183
179
 
184
180
  /**
185
- * Reference an existing bucket by name.
186
- * To create a new storage bucket, use `new StorageBucket(...)` instead.
181
+ * References an existing bucket by name.
182
+ * To declare a new bucket, use `new Bucket(...)` instead.
187
183
  */
188
184
  static named<name extends string>(name: StringLiteral<name>): Bucket {
189
185
  return new Bucket(name, {});
190
186
  }
191
187
 
192
188
  /**
193
- * Lists the objects in the bucket, sorted by name.
189
+ * Lists objects in the bucket in lexicographical order by name.
194
190
  *
195
- * With a `delimiter`, the names that continue past the `prefix` with the
196
- * delimiter are grouped into one entry per common prefix, with
197
- * `isPrefix` set, as a directory listing does.
191
+ * When `delimiter` is set, keys sharing a common prefix past `options.prefix`
192
+ * up to the delimiter are grouped into a single entry with `isPrefix: true`
193
+ * (similar to a directory listing).
198
194
  */
199
195
  async *list(options?: ListOptions): AsyncGenerator<ListEntry> {
200
196
  const source = activeCtxBytes();
@@ -228,9 +224,9 @@ export class Bucket
228
224
  }
229
225
 
230
226
  /**
231
- * Lists every stored version of the objects in the bucket, sorted by
232
- * name and then newest first. A removed object has no `latest` version.
233
- * An unversioned bucket lists one latest version per object.
227
+ * Lists all stored object versions in the bucket, sorted by name and then
228
+ * newest first. Deleted objects have no `latest` version. In unversioned
229
+ * buckets, yields one `latest` version per object.
234
230
  */
235
231
  async *listVersions(
236
232
  options?: ListVersionsOptions,
@@ -275,7 +271,7 @@ export class Bucket
275
271
 
276
272
  /**
277
273
  * Returns the object's attributes.
278
- * Throws an error if the object does not exist.
274
+ * Throws `ObjectNotFound` if the object does not exist.
279
275
  */
280
276
  async attrs(name: string, options?: AttrsOptions): Promise<ObjectAttrs> {
281
277
  const source = activeCtxBytes();
@@ -300,10 +296,9 @@ export class Bucket
300
296
  }
301
297
 
302
298
  /**
303
- * Uploads an object to the bucket from a stream of bytes: a Web
304
- * `ReadableStream`, a Node.js `Readable`, or any async iterable of
305
- * `Uint8Array` chunks. The stream is read as fast as the upload takes
306
- * its bytes.
299
+ * Uploads an object from a byte stream — a Web `ReadableStream`, Node.js
300
+ * `Readable`, or any async iterable of `Uint8Array` chunks — pulling chunks
301
+ * as the upload consumes them.
307
302
  *
308
303
  * If the stream errors, the upload is aborted and nothing is stored.
309
304
  */
@@ -320,21 +315,19 @@ export class Bucket
320
315
  }
321
316
 
322
317
  /**
323
- * Uploads an object only if the bucket still holds the given revision of
324
- * it, as a download, `attrs`, `upload`, `updateAttrs` or a listing
325
- * returned it, and throws `PreconditionFailed` otherwise, also if the
326
- * object no longer exists. This makes read-modify-write safe against
327
- * concurrent writers. A missing revision throws `InvalidArgument`.
328
- *
329
- * `data` is bytes or a stream, as `upload` and `uploadStream` take.
318
+ * Conditionally uploads an object only if the bucket still holds `revision`
319
+ * (returned by `download`, `attrs`, `upload`, `updateAttrs`, or `list`),
320
+ * throwing `PreconditionFailed` if the object changed or was deleted. Throws
321
+ * `InvalidArgument` if `revision` is missing.
330
322
  *
331
- * The match compares the object's contents, not its attributes:
332
- * `updateAttrs` doesn't break it. Google Cloud Storage matches the
333
- * revision's `version`, so a revision without one throws
334
- * `InvalidArgument` there; Amazon S3 and Cloudflare R2 match its `etag`.
323
+ * `data` may be a `Uint8Array` or a stream (as in {@link upload} and
324
+ * {@link uploadStream}). Comparisons check object contents rather than
325
+ * metadata, so {@link updateAttrs} does not invalidate a match. GCS matches
326
+ * on `revision.version` (throwing `InvalidArgument` if absent), while S3 and
327
+ * Cloudflare R2 match on `revision.etag`.
335
328
  *
336
- * On Amazon S3 a conditional write also needs read access to the bucket,
337
- * which Encore grants to the services that call this.
329
+ * On AWS S3, conditional writes also require read permission, which Encore
330
+ * grants automatically to calling services.
338
331
  */
339
332
  async uploadIfMatch(
340
333
  name: string,
@@ -352,13 +345,13 @@ export class Bucket
352
345
  }
353
346
 
354
347
  /**
355
- * Replaces the given attributes of an object and leaves the others as
356
- * they are. An empty string clears an attribute (a cleared content type
357
- * is `application/octet-stream`, as S3 keeps no object without one), and
358
- * `metadata` replaces the whole map.
348
+ * Updates the specified attributes of an object while leaving omitted
349
+ * attributes unchanged. Pass an empty string to clear an attribute (clearing
350
+ * `contentType` resets it to `application/octet-stream`), and pass a new
351
+ * `metadata` object to replace the entire metadata map (`{}` clears it).
359
352
  *
360
- * On S3 this rewrites the object, so a versioned bucket gets a new
361
- * version, and the object's age for lifecycle rules starts over.
353
+ * On AWS S3, updating attributes rewrites the object, creating a new version
354
+ * in versioned buckets and resetting the object's lifecycle age.
362
355
  */
363
356
  async updateAttrs(
364
357
  name: string,
@@ -384,9 +377,9 @@ export class Bucket
384
377
  }
385
378
 
386
379
  /**
387
- * Keeps the object until `until` at least. Retention can only be
388
- * extended: a time earlier than the object's current one throws
389
- * `InvalidArgument`. The bucket must be declared with `objectRetention`.
380
+ * Extends the object's retention until at least `until`. Retention can only
381
+ * be extended — passing a time earlier than the current retention throws
382
+ * `InvalidArgument`. Requires `objectRetention: true` on the bucket.
390
383
  */
391
384
  async extendRetention(
392
385
  name: string,
@@ -404,13 +397,11 @@ export class Bucket
404
397
  }
405
398
 
406
399
  /**
407
- * Generate an external URL to allow uploading an object to the bucket.
400
+ * Generates a pre-signed URL allowing anyone with the URL to upload to
401
+ * `name` without additional authentication.
408
402
  *
409
- * Anyone with possession of the URL can write to the given object name
410
- * without any additional auth.
411
- *
412
- * The URL doesn't carry the bucket's storage class: an object uploaded
413
- * through it gets the provider's default class for the bucket.
403
+ * Note: Pre-signed upload URLs do not enforce the bucket's configured
404
+ * `storageClass`; uploaded objects receive the provider's default class.
414
405
  */
415
406
  async signedUploadUrl(
416
407
  name: string,
@@ -423,10 +414,8 @@ export class Bucket
423
414
  }
424
415
 
425
416
  /**
426
- * Generate an external URL to allow downloading an object from the bucket.
427
- *
428
- * Anyone with possession of the URL can download the given object without
429
- * any additional auth.
417
+ * Generates a pre-signed URL allowing anyone with the URL to download `name`
418
+ * without additional authentication.
430
419
  */
431
420
  async signedDownloadUrl(
432
421
  name: string,
@@ -439,16 +428,15 @@ export class Bucket
439
428
  }
440
429
 
441
430
  /**
442
- * Downloads an object from the bucket. It resolves once the provider has
443
- * answered, before any of the object's bytes: a missing object, or a
444
- * range outside it, throws here. The `Download` says what the provider
445
- * said of the object, and gives its contents whole (`bytes`) or as they
446
- * arrive (`stream`).
431
+ * Starts downloading an object from the bucket. Resolves as soon as the
432
+ * provider responds (throwing immediately if the object is missing or the
433
+ * byte range is invalid), returning a {@link Download} with response
434
+ * metadata and one-shot `bytes()` / `stream()` readers.
447
435
  *
448
436
  * ```ts
449
437
  * const d = await uploads.download("state.json");
450
438
  * const state = JSON.parse((await d.bytes()).toString());
451
- * // Written only if nobody else has since it was read.
439
+ * // Write only if nobody else updated the object since we read it.
452
440
  * await uploads.uploadIfMatch("state.json", next(state), d.revision);
453
441
  * ```
454
442
  */
@@ -473,18 +461,15 @@ export class Bucket
473
461
  }
474
462
 
475
463
  /**
476
- * Removes an object only if the bucket still holds the given revision of
477
- * it, as a download, `attrs`, `upload`, `updateAttrs` or a listing
478
- * returned it, and throws `PreconditionFailed` otherwise, also if the
479
- * object no longer exists. It compares the latest version, so there is no
480
- * `version` to remove. A missing revision throws `InvalidArgument`.
464
+ * Conditionally removes an object only if its latest version still matches
465
+ * `revision` (returned by `download`, `attrs`, `upload`, `updateAttrs`, or
466
+ * `list`), throwing `PreconditionFailed` if it changed or no longer exists.
467
+ * Throws `InvalidArgument` if `revision` is missing.
481
468
  *
482
- * The match compares the object's contents, not its attributes:
483
- * `updateAttrs` doesn't break it.
484
- *
485
- * On Amazon S3 a conditional delete also needs read access to the
486
- * bucket, which Encore grants to the services that call this. Cloudflare
487
- * R2 doesn't support conditional deletes: there it throws
469
+ * Comparisons check object contents rather than metadata, so
470
+ * {@link updateAttrs} does not invalidate a match. On AWS S3, conditional
471
+ * deletes require read permission (granted automatically by Encore).
472
+ * Cloudflare R2 does not support conditional deletes and throws
488
473
  * `InvalidArgument`.
489
474
  */
490
475
  async removeIfMatch(name: string, revision: Revision): Promise<void> {
@@ -498,8 +483,8 @@ export class Bucket
498
483
  }
499
484
 
500
485
  /**
501
- * Returns the public URL for accessing the object with the given name.
502
- * Throws an error if the bucket is not public.
486
+ * Returns the public CDN URL for accessing the object.
487
+ * Throws an error if the bucket is not declared with `public: true`.
503
488
  */
504
489
  publicUrl(name: string): string {
505
490
  const obj = this.impl.object(name);
@@ -511,13 +496,13 @@ export class Bucket
511
496
  }
512
497
  }
513
498
 
514
- /** The most bytes handed to the native upload at a time. */
499
+ /** Maximum chunk size passed to the native upload writer at a time. */
515
500
  const CHUNK_SIZE = 64 * 1024;
516
501
 
517
502
  const STREAM_EXPECTED =
518
- 'uploadStream takes a ReadableStream or an async iterable of Uint8Array chunks';
503
+ 'uploadStream expects a ReadableStream or an async iterable of Uint8Array chunks';
519
504
  const BODY_EXPECTED =
520
- 'uploadIfMatch takes a Uint8Array, a ReadableStream or an async iterable of Uint8Array chunks';
505
+ 'uploadIfMatch expects a Uint8Array, ReadableStream, or async iterable of Uint8Array chunks';
521
506
 
522
507
  async function uploadChunks(
523
508
  obj: runtime.BucketObject,
@@ -529,7 +514,7 @@ async function uploadChunks(
529
514
  try {
530
515
  for await (const chunk of data) {
531
516
  if (!(chunk instanceof Uint8Array)) {
532
- throw new TypeError('upload data must be Uint8Array chunks');
517
+ throw new TypeError('upload data must consist of Uint8Array chunks');
533
518
  }
534
519
  for (const slice of slices(chunk)) {
535
520
  const err = await stream.write(slice);
@@ -546,7 +531,7 @@ async function uploadChunks(
546
531
  return toAttrs(unwrapErr(await stream.finish()));
547
532
  }
548
533
 
549
- /** Views of `data`, of at most CHUNK_SIZE bytes each, as Buffers. */
534
+ /** Yields `Buffer` views of `data`, each at most `CHUNK_SIZE` bytes. */
550
535
  function* slices(data: Uint8Array): Generator<Buffer> {
551
536
  const buf = Buffer.isBuffer(data)
552
537
  ? data
@@ -627,20 +612,20 @@ function byteRange(
627
612
  if (range.last !== undefined) {
628
613
  if (range.offset !== undefined || range.length !== undefined) {
629
614
  throw new InvalidArgument(
630
- 'a byte range is an offset, with or without a length, or the last bytes: not both',
615
+ 'byte range must specify either `offset` (with optional `length`) or `last`, not both',
631
616
  );
632
617
  }
633
618
  return {last: range.last};
634
619
  }
635
620
  if (typeof range.offset !== 'number') {
636
621
  throw new InvalidArgument(
637
- 'a byte range needs an offset, or `last` for the last bytes',
622
+ 'byte range must specify either a numeric `offset` or `last`',
638
623
  );
639
624
  }
640
625
  return {offset: range.offset, length: range.length};
641
626
  }
642
627
 
643
- /** The `Download` of the native runtime's download. */
628
+ /** Wraps a native runtime download handle. */
644
629
  class NativeDownload implements Download {
645
630
  readonly revision: Revision;
646
631
  readonly size: number;
@@ -683,11 +668,11 @@ class NativeDownload implements Download {
683
668
  );
684
669
  }
685
670
 
686
- /** The contents are read once: the bytes are not kept. */
671
+ /** Enforces single consumption of the download body. */
687
672
  private take(method: string): void {
688
673
  if (this.read) {
689
674
  throw new InvalidArgument(
690
- `${method}: the download's contents were already read`,
675
+ `${method}: download body has already been consumed`,
691
676
  );
692
677
  }
693
678
  this.read = true;
@@ -699,14 +684,13 @@ function toRevision(rev: Revision | undefined): runtime.Revision | undefined {
699
684
  }
700
685
 
701
686
  /**
702
- * The revision a `*IfMatch` method matches. A missing one, which the types
703
- * forbid but plain JavaScript can pass, is refused: the write or delete would
704
- * otherwise be unconditional.
687
+ * Validates that `*IfMatch` callers supplied a revision so writes or deletes
688
+ * cannot silently become unconditional in untyped JS.
705
689
  */
706
690
  function requiredRevision(method: string, rev: Revision): runtime.Revision {
707
691
  if (rev == null || typeof rev.etag !== 'string') {
708
692
  throw new InvalidArgument(
709
- `${method} needs the revision to match: a download's revision, or the attributes attrs, upload or updateAttrs returned`,
693
+ `${method} requires a revision (e.g. from download.revision, attrs(), upload(), or updateAttrs())`,
710
694
  );
711
695
  }
712
696
  return {etag: rev.etag, version: rev.version};
@@ -737,20 +721,20 @@ function toAttrs(attrs: runtime.ObjectAttrs): ObjectAttrs {
737
721
  */
738
722
  export interface ListOptions {
739
723
  /**
740
- * Only include objects with this prefix in the listing.
741
- * If unset, all objects are included.
724
+ * Only include objects whose names start with this prefix.
725
+ * Defaults to all objects.
742
726
  */
743
727
  prefix?: string;
744
728
 
745
729
  /**
746
- * Maximum number of entries to return, common prefixes included.
747
- * Defaults to no limit.
730
+ * Maximum number of entries to return (including common prefixes).
731
+ * Unlimited when unset.
748
732
  */
749
733
  limit?: number;
750
734
 
751
735
  /**
752
- * Group the names that continue past the prefix with this delimiter,
753
- * usually `"/"`, into one entry per common prefix.
736
+ * Delimiter (typically `"/"`) used to group object names past `prefix` into
737
+ * single common-prefix entries.
754
738
  */
755
739
  delimiter?: string;
756
740
  }
@@ -760,37 +744,33 @@ export interface ListOptions {
760
744
  */
761
745
  export interface ListVersionsOptions {
762
746
  /**
763
- * Only include objects with this prefix in the listing.
764
- * If unset, all objects are included.
747
+ * Only include objects whose names start with this prefix.
748
+ * Defaults to all objects.
765
749
  */
766
750
  prefix?: string;
767
751
 
768
- /** Maximum number of versions to return. Defaults to no limit. */
752
+ /** Maximum number of versions to return. Unlimited when unset. */
769
753
  limit?: number;
770
754
  }
771
755
 
772
756
  /**
773
- * Options for retrieving the attributes of an object.
757
+ * Options for retrieving an object's attributes.
774
758
  */
775
759
  export interface AttrsOptions {
776
760
  /**
777
- * The object version to retrieve attributes for.
778
- * Defaults to the lastest version if unset.
779
- *
780
- * If bucket versioning is not enabled, this option is ignored.
761
+ * Object version to inspect. Defaults to the latest version.
762
+ * Ignored if bucket versioning is disabled.
781
763
  */
782
764
  version?: string;
783
765
  }
784
766
 
785
767
  /**
786
- * Options for checking the existence of an object.
768
+ * Options for checking whether an object exists.
787
769
  */
788
770
  export interface ExistsOptions {
789
771
  /**
790
- * The object version to check for existence.
791
- * Defaults to the lastest version if unset.
792
- *
793
- * If bucket versioning is not enabled, this option is ignored.
772
+ * Object version to check. Defaults to the latest version.
773
+ * Ignored if bucket versioning is disabled.
794
774
  */
795
775
  version?: string;
796
776
  }
@@ -800,26 +780,24 @@ export interface ExistsOptions {
800
780
  */
801
781
  export interface DeleteOptions {
802
782
  /**
803
- * The object version to delete.
804
- * Defaults to the lastest version if unset.
805
- *
806
- * If bucket versioning is not enabled, this option is ignored.
783
+ * Object version to delete. Defaults to the latest version.
784
+ * Ignored if bucket versioning is disabled.
807
785
  */
808
786
  version?: string;
809
787
  }
810
788
 
811
789
  /**
812
- * A contiguous byte range within an object: `length` bytes from `offset`,
813
- * or the object's last bytes.
790
+ * A contiguous byte range within an object: either `length` bytes starting at
791
+ * `offset`, or the final `last` bytes of the object.
814
792
  */
815
793
  export type ByteRange =
816
794
  | {
817
- /** The zero-based index of the first byte to read. */
795
+ /** Zero-based index of the first byte to read. */
818
796
  offset: number;
819
797
 
820
798
  /**
821
- * The number of bytes to read.
822
- * Defaults to reading to the end of the object if unset.
799
+ * Number of bytes to read. Reads through the end of the object when
800
+ * omitted.
823
801
  */
824
802
  length?: number;
825
803
 
@@ -827,9 +805,8 @@ export type ByteRange =
827
805
  }
828
806
  | {
829
807
  /**
830
- * Read the object's last `last` bytes, however long it is; all of it,
831
- * if it is shorter. The download's `size` says how long the object
832
- * is, and so where in it the bytes are.
808
+ * Read the final `last` bytes of the object (or the entire object if it
809
+ * is shorter). Check {@link Download.size} for the object's full length.
833
810
  */
834
811
  last: number;
835
812
 
@@ -842,70 +819,63 @@ export type ByteRange =
842
819
  */
843
820
  export interface DownloadOptions {
844
821
  /**
845
- * The object version to download.
846
- * Defaults to the lastest version if unset.
847
- *
848
- * If bucket versioning is not enabled, this option is ignored.
822
+ * Object version to download. Defaults to the latest version.
823
+ * Ignored if bucket versioning is disabled.
849
824
  */
850
825
  version?: string;
851
826
 
852
827
  /**
853
- * Download only the given byte range of the object, instead of the whole
854
- * object. The download's contents are just the requested bytes; its
855
- * `size` is still the whole object's.
828
+ * Optional byte range to download instead of the full object. The body
829
+ * contains only the requested slice while {@link Download.size} still
830
+ * reports the full object size.
856
831
  *
857
- * Throws InvalidArgument if the range is empty or lies beyond the end
858
- * of the object.
832
+ * Throws `InvalidArgument` if the range is empty or starts past the end of
833
+ * the object.
859
834
  */
860
835
  range?: ByteRange;
861
836
  }
862
837
 
863
838
  /**
864
- * A download under way, as `download` returns it: what the provider said of
865
- * the object when it answered, and the object's contents, which are read
866
- * once, whole or as they arrive.
839
+ * An in-progress download returned by {@link Bucket.download}, exposing basic
840
+ * response metadata and one-shot body readers (`bytes()` or `stream()`).
867
841
  *
868
- * What it says is less than `attrs` does: it is what every provider sends
869
- * with an object's bytes.
870
- *
871
- * A download whose contents are never read keeps its connection open until
872
- * it is garbage collected. To give one up, cancel its stream:
873
- * `await d.stream().cancel()`.
842
+ * Includes only the metadata providers send alongside download responses (use
843
+ * {@link Bucket.attrs} for full metadata). An unread download holds its
844
+ * connection open until garbage collected; call `await d.stream().cancel()` to
845
+ * release it early.
874
846
  */
875
847
  export interface Download {
876
848
  /**
877
- * The revision the contents are of. Pass it to `uploadIfMatch` or
878
- * `removeIfMatch` to write or remove the object only if it is still what
879
- * was read.
849
+ * Revision of the downloaded contents. Pass to {@link Bucket.uploadIfMatch}
850
+ * or {@link Bucket.removeIfMatch} for optimistic concurrency control.
880
851
  */
881
852
  readonly revision: Revision;
882
- /** The size of the whole object in bytes, also when a range is read. */
853
+ /** Full object size in bytes, even when downloading a byte range. */
883
854
  readonly size: number;
884
855
  readonly contentType?: string;
885
- /** When the object last changed, if the provider said. */
856
+ /** Last modification timestamp, if reported by the provider. */
886
857
  readonly lastModified?: Date;
887
858
 
888
859
  /**
889
- * The contents, in one piece. Throws `InvalidArgument` if they were
890
- * already read.
860
+ * Buffers and returns the entire download body. Throws `InvalidArgument` if
861
+ * the body has already been consumed.
891
862
  */
892
863
  bytes(): Promise<Buffer>;
893
864
 
894
865
  /**
895
- * The contents as a Web `ReadableStream`, read from the provider as the
896
- * consumer reads it. Cancelling the stream stops the download. Throws
897
- * `InvalidArgument` if the contents were already read.
866
+ * Streams the download body as a Web `ReadableStream`. Canceling the stream
867
+ * aborts the download. Throws `InvalidArgument` if the body has already been
868
+ * consumed.
898
869
  *
899
- * In Node.js, `Readable.fromWeb` converts it to a Node.js stream.
870
+ * In Node.js, use `Readable.fromWeb` to convert this into a Node stream.
900
871
  */
901
872
  stream(): ReadableStream<Uint8Array>;
902
873
  }
903
874
 
904
875
  /**
905
- * One revision of an object: what `uploadIfMatch`, `removeIfMatch` and the
906
- * `ifMatch` precondition of `updateAttrs` compare. `ObjectAttrs` is one, so
907
- * the attributes an operation returned can be passed as they are, and a
908
- * download's `revision` is one, of the contents it reads.
876
+ * Identifies a specific content revision of an object for conditional
877
+ * operations (`uploadIfMatch`, `removeIfMatch`, and `updateAttrs` `ifMatch`).
878
+ * Both {@link ObjectAttrs} and {@link Download.revision} satisfy `Revision`.
909
879
  */
910
880
  export interface Revision {
911
881
  etag: string;
@@ -913,68 +883,67 @@ export interface Revision {
913
883
  }
914
884
 
915
885
  /**
916
- * Conditions on the object an upload writes.
886
+ * Preconditions for an upload.
917
887
  */
918
888
  export interface Preconditions {
919
889
  /**
920
- * Only write the object if it does not exist yet.
921
- * Throws `PreconditionFailed` otherwise.
890
+ * Only write the object if it does not already exist; throws
891
+ * `PreconditionFailed` otherwise.
922
892
  */
923
893
  notExists?: boolean;
924
894
  }
925
895
 
926
896
  /**
927
- * Describes the attributes of an object stored in a bucket.
897
+ * Attributes of an object stored in a bucket.
928
898
  */
929
899
  export interface ObjectAttrs {
930
900
  name: string;
931
901
  size: number;
932
- /** The version of the object, if bucket versioning is enabled. */
902
+ /** Object version identifier, if bucket versioning is enabled. */
933
903
  version?: string;
934
904
  etag: string;
935
905
  contentType?: string;
936
906
  cacheControl?: string;
937
907
  contentDisposition?: string;
938
- /** Custom metadata; empty if the object has none. */
908
+ /** Custom metadata map (empty object if none). */
939
909
  metadata: Record<string, string>;
940
- /** When this version of the object was written. */
910
+ /** Timestamp when this object version was written. */
941
911
  lastModified?: Date;
942
912
  /**
943
- * The object's storage class. Every object in a bucket whose class is
944
- * `"auto"` reads `"auto"`. Undefined for a class Encore doesn't model,
945
- * set outside Encore.
913
+ * Object storage class (`"auto"` for buckets with `storageClass: "auto"`,
914
+ * or `undefined` if a provider-specific class was set outside Encore).
946
915
  */
947
916
  storageClass?: StorageClass | 'auto';
948
- /** The object's own retain-until time, if it has one. */
917
+ /** Per-object retain-until timestamp, if set. */
949
918
  retainUntil?: Date;
950
919
  }
951
920
 
952
921
  /**
953
- * A single entry returned when listing objects in a bucket.
922
+ * A single entry yielded by {@link Bucket.list}.
954
923
  */
955
924
  export interface ListEntry {
956
- /** The object's name, or a common prefix, ending in the delimiter. */
925
+ /** Object key, or common prefix ending with the delimiter. */
957
926
  name: string;
958
927
  size: number;
959
928
  etag: string;
960
- /** When the object was written. Unset for a common prefix. */
929
+ /** Timestamp when the object was written (unset for common prefixes). */
961
930
  lastModified?: Date;
962
931
  /**
963
- * Whether the entry is a common prefix of a listing with a delimiter,
964
- * rather than an object. A prefix has size 0 and an empty etag.
932
+ * `true` when this entry represents a common prefix grouped by a delimiter
933
+ * (with `size: 0` and empty `etag`), rather than an object.
965
934
  */
966
935
  isPrefix: boolean;
967
936
  }
968
937
 
969
938
  /**
970
- * One stored version of an object, as `listVersions` lists it.
939
+ * A single stored object version yielded by {@link Bucket.listVersions}.
971
940
  */
972
941
  export interface ObjectVersion {
973
942
  name: string;
974
943
  version?: string;
975
944
  size: number;
976
945
  etag: string;
977
- /** Whether this is the object's current version. */
946
+ /** Whether this is the object's current (latest) version. */
978
947
  latest: boolean;
979
948
  lastModified?: Date;
980
949
  }
@@ -985,25 +954,25 @@ export interface ObjectVersion {
985
954
  export interface UploadOptions {
986
955
  contentType?: string;
987
956
 
988
- /** The `Cache-Control` header that downloads of the object get. */
957
+ /** `Cache-Control` header returned when downloading the object. */
989
958
  cacheControl?: string;
990
959
 
991
- /** The `Content-Disposition` header that downloads of the object get. */
960
+ /** `Content-Disposition` header returned when downloading the object. */
992
961
  contentDisposition?: string;
993
962
 
994
963
  /**
995
- * Custom metadata. Keys match `[a-z0-9][a-z0-9_-]*` and values are
996
- * printable ASCII. Keys and values together may take 8 KiB on GCS and
964
+ * Custom key-value metadata. Keys must match `[a-z0-9][a-z0-9_-]*` and
965
+ * values must be printable ASCII. Total size is limited to 8 KiB on GCS and
997
966
  * 2 KiB on S3.
998
967
  */
999
968
  metadata?: Record<string, string>;
1000
969
 
1001
- /** The object's storage class. Defaults to the bucket's. */
970
+ /** Object storage class. Defaults to the bucket's configured storage class. */
1002
971
  storageClass?: StorageClass;
1003
972
 
1004
973
  /**
1005
- * Keep the object until then: it can't be deleted or overwritten
1006
- * sooner. The bucket must be declared with `objectRetention`.
974
+ * Prevents the object from being deleted or overwritten until this time.
975
+ * Requires `objectRetention: true` on the bucket.
1007
976
  */
1008
977
  retainUntil?: Date;
1009
978
 
@@ -1011,15 +980,16 @@ export interface UploadOptions {
1011
980
  }
1012
981
 
1013
982
  /**
1014
- * Options for `uploadIfMatch`: those of `upload`, without preconditions.
983
+ * Options for {@link Bucket.uploadIfMatch} (all {@link UploadOptions} except
984
+ * `preconditions`).
1015
985
  */
1016
986
  export type UploadIfMatchOptions = Omit<UploadOptions, 'preconditions'>;
1017
987
 
1018
988
  /**
1019
- * The attributes `updateAttrs` replaces. An attribute left out stays as it
1020
- * is, and an empty string clears it; a cleared `contentType` is
1021
- * `application/octet-stream`. `metadata` replaces the whole map, so `{}`
1022
- * clears it.
989
+ * Attributes to update via {@link Bucket.updateAttrs}. Omitted fields remain
990
+ * unchanged; an empty string clears a field (clearing `contentType` resets it
991
+ * to `application/octet-stream`). `metadata` replaces the entire map (`{}`
992
+ * clears it).
1023
993
  */
1024
994
  export interface UpdateAttrs {
1025
995
  contentType?: string;
@@ -1032,13 +1002,13 @@ export interface UpdateAttrs {
1032
1002
  * Options for updating an object's attributes.
1033
1003
  */
1034
1004
  export interface UpdateAttrsOptions {
1035
- /** The object version to update. Defaults to the latest. */
1005
+ /** Object version to update. Defaults to the latest version. */
1036
1006
  version?: string;
1037
1007
 
1038
1008
  preconditions?: {
1039
1009
  /**
1040
- * Only update the object if it is still this revision.
1041
- * Throws `PreconditionFailed` otherwise.
1010
+ * Only update the object if it still matches this revision; throws
1011
+ * `PreconditionFailed` otherwise.
1042
1012
  */
1043
1013
  ifMatch?: Revision;
1044
1014
  };
@@ -1048,7 +1018,7 @@ export interface UpdateAttrsOptions {
1048
1018
  * Options for extending an object's retention.
1049
1019
  */
1050
1020
  export interface ExtendRetentionOptions {
1051
- /** The object version to retain. Defaults to the latest. */
1021
+ /** Object version to retain. Defaults to the latest version. */
1052
1022
  version?: string;
1053
1023
  }
1054
1024
 
@@ -1056,9 +1026,9 @@ export interface ExtendRetentionOptions {
1056
1026
  * Options for generating a signed upload URL.
1057
1027
  */
1058
1028
  export interface UploadUrlOptions {
1059
- /** The expiration time of the url, in seconds from signing. The maximum
1060
- * value is seven days. If no value is given, a default of one hour is
1061
- * used. */
1029
+ /**
1030
+ * URL lifetime in seconds from creation (maximum 7 days; defaults to 1 hour).
1031
+ */
1062
1032
  ttl?: number;
1063
1033
  }
1064
1034
 
@@ -1073,9 +1043,9 @@ export interface SignedUploadUrl {
1073
1043
  * Options for generating a signed download URL.
1074
1044
  */
1075
1045
  export interface DownloadUrlOptions {
1076
- /** The expiration time of the url, in seconds from signing. The maximum
1077
- * value is seven days. If no value is given, a default of one hour is
1078
- * used. */
1046
+ /**
1047
+ * URL lifetime in seconds from creation (maximum 7 days; defaults to 1 hour).
1048
+ */
1079
1049
  ttl?: number;
1080
1050
  }
1081
1051