deepspace 0.19.4 → 0.20.0

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.
package/dist/server.d.ts CHANGED
@@ -207,13 +207,9 @@ declare const UPLOAD_PART_BYTES: number;
207
207
  /**
208
208
  * The highest part number the server accepts.
209
209
  *
210
- * The handler holds no per-session state, so this — not the declared total —
211
- * is what bounds an in-flight upload. It is computed against
212
- * {@link UPLOAD_PART_BYTES}, which is why the server refuses a part larger
213
- * than that even though a whole small file may be 25 MiB: admitting 25 MiB
214
- * parts would make the real in-flight bound 52 × 25 MiB = 1300 MiB while the
215
- * advertised ceiling stayed 1 GiB. With both numbers agreeing, a session's
216
- * worst case is 52 × 20 MiB = 1040 MiB — the ceiling plus one part.
210
+ * The server derives the only valid part number and byte length from the
211
+ * declared total and {@link UPLOAD_PART_BYTES}. The maximum part count is
212
+ * therefore the exact number needed to reach the file ceiling.
217
213
  *
218
214
  * R2 allows 10,000 parts, so this is far inside what the API permits.
219
215
  */
@@ -253,6 +249,25 @@ declare function storageQuotaMessage(incomingBytes: number, usedBytes: number, l
253
249
  declare const MAX_DEPLOY_ASSET_FILE_BYTES: number;
254
250
  declare function formatBytes(bytes: number): string;
255
251
 
252
+ /**
253
+ * Everything the files handler needs to enforce one account allocation.
254
+ *
255
+ * `quotaKey` is required because an exact scan followed by an uncoordinated
256
+ * write cannot enforce a limit under concurrency. Callers that do not want a
257
+ * quota omit `storage`; callers that do want one must name its serialized
258
+ * summary.
259
+ */
260
+ interface StorageAdmission {
261
+ /** The app prefix receiving this request's write. */
262
+ prefix: string;
263
+ /** Internal R2 key for the account's ETag-serialized usage summary. */
264
+ quotaKey: string;
265
+ /** Resolve the account's limit. `null` fails writes closed. */
266
+ limitBytes: () => Promise<number | null>;
267
+ /** Resolve the other app prefixes in the account. `null` fails closed. */
268
+ siblingPrefixes?: () => Promise<string[] | null>;
269
+ }
270
+
256
271
  /**
257
272
  * Shared Scoped R2 Files Handler
258
273
  *
@@ -296,6 +311,7 @@ interface ScopeContext {
296
311
  }
297
312
  type PrefixResult = {
298
313
  prefix: string;
314
+ excludedPrefixes?: readonly string[];
299
315
  error?: undefined;
300
316
  } | {
301
317
  prefix?: undefined;
@@ -318,32 +334,12 @@ interface ScopedR2Config {
318
334
  * mount. The handler is the enforcer; the mount only knows whose limit
319
335
  * applies.
320
336
  */
321
- interface StorageAdmission {
322
- /** This app's own prefix — the one the incoming write lands under. */
323
- prefix: string;
324
- /**
325
- * Resolve the owner's limit in bytes. `null` means the lookup failed;
326
- * writes then fail closed (503) rather than admitting unmetered storage.
327
- */
328
- limitBytes: () => Promise<number | null>;
329
- /**
330
- * The OTHER app prefixes this owner's storage spans, if any.
331
- *
332
- * The limit is per ACCOUNT, not per app: an owner's allocation is the total
333
- * across everything they own, so admission has to see the siblings too. `[]`
334
- * for an owner with one app, which is the common case and costs exactly what
335
- * it did when this was a per-app limit.
336
- *
337
- * Returning `null` means the owner's apps could not be enumerated. Like a
338
- * failed limit lookup that fails the write closed rather than admitting a
339
- * write against an allocation we cannot measure.
340
- */
341
- siblingPrefixes?: () => Promise<string[] | null>;
342
- }
343
337
  interface ScopedR2Auth {
344
338
  userId: string | null;
345
339
  /** Absent = no quota on this mount (e.g. an app's own bucket). */
346
340
  storage?: StorageAdmission;
341
+ /** Account-wide quota details are private to an authorized owner surface. */
342
+ includeStorageUsage?: boolean;
347
343
  }
348
344
  type ScopedR2Handler = (request: Request, url: URL, bucket: R2Bucket, auth: ScopedR2Auth) => Promise<Response>;
349
345
  declare function isFilesVerbPath(method: string, subpath: string): boolean;