cloudrop 0.1.1 → 0.2.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/CHANGELOG.md +60 -0
- package/README.md +5 -3
- package/dist/adapters/drizzle.d.ts +1 -1
- package/dist/adapters/drizzle.js +3 -3
- package/dist/adapters/drizzle.js.map +1 -1
- package/dist/adapters/prisma.d.ts +1 -1
- package/dist/adapters/prisma.js +1 -1
- package/dist/adapters/sql.d.ts +1 -1
- package/dist/adapters/sql.js +1 -1
- package/dist/{client-Dj6ON4MN.d.ts → client-CP_ajLF4.d.ts} +43 -25
- package/dist/{client-Y1zUEbCj.js → client-ePVHwvMv.js} +126 -40
- package/dist/client-ePVHwvMv.js.map +1 -0
- package/dist/client.d.ts +3 -3
- package/dist/client.js +1 -1
- package/dist/errors-CUxMmFAe.js.map +1 -1
- package/dist/index.d.ts +67 -6
- package/dist/index.js +352 -113
- package/dist/index.js.map +1 -1
- package/dist/next.d.ts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/react.d.ts +18 -4
- package/dist/react.js +23 -3
- package/dist/react.js.map +1 -1
- package/dist/{route-CspI1Ypt.js → route-C8-YjzdY.js} +3 -2
- package/dist/{route-CspI1Ypt.js.map → route-C8-YjzdY.js.map} +1 -1
- package/dist/{store-BfCJejGh.d.ts → store-B539nY3J.d.ts} +41 -3
- package/dist/{transactional-DnvnGsVH.js → transactional-CiNwMiDb.js} +215 -105
- package/dist/transactional-CiNwMiDb.js.map +1 -0
- package/dist/{types-BrAx3dA4.d.ts → types-CFfMw-n_.d.ts} +1 -1
- package/package.json +7 -7
- package/dist/client-Y1zUEbCj.js.map +0 -1
- package/dist/transactional-DnvnGsVH.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as CloudropErrorCode, E as CloudropError, O as CloudropErrorOptions, T as UploadedFile, _ as RouteResult, g as RouteName, h as RouteMetadata, k as Result, u as InferableCloudrop } from "./types-
|
|
2
|
-
import { C as
|
|
1
|
+
import { D as CloudropErrorCode, E as CloudropError, O as CloudropErrorOptions, T as UploadedFile, _ as RouteResult, g as RouteName, h as RouteMetadata, k as Result, u as InferableCloudrop } from "./types-CFfMw-n_.js";
|
|
2
|
+
import { C as allowAnyone, D as Size, E as unauthorized, O as StandardSchema, S as RoutePolicy, T as route, _ as Refusal, a as FileRecord, b as RouteDefinition, c as OwnerUsage, d as AfterCompleteContext, f as AuthorizeContext, g as OwnerContext, h as KeyContext, i as EndedStatus, l as TransactionalStore, m as CompleteContext, n as CloudropStore, o as FileStatus, p as Awaitable, r as Completion, s as NewFile, t as ClaimOutcome, u as Transition, v as Route, w as forbidden, x as RouteFunction, y as RouteCallbacks } from "./store-B539nY3J.js";
|
|
3
3
|
/** Limits of a storage backend, in bytes and seconds. */
|
|
4
4
|
interface StorageRules {
|
|
5
5
|
minPartSize: number;
|
|
@@ -224,7 +224,7 @@ interface StoreOptions {
|
|
|
224
224
|
/**
|
|
225
225
|
* A database store, such as `sqlStore(...)` from `cloudrop/adapters/sql`. With one, `/upload` writes a row per file
|
|
226
226
|
* before anything is signed, `onComplete` runs once per file, `/abort` never deletes a completed file, and `api`
|
|
227
|
-
* gains `file`, `usage`, `revokeUploads`, `deleteFile`, `reconcile` and `sweep`.
|
|
227
|
+
* gains `file`, `files`, `usage`, `revokeUploads`, `deleteFile`, `eraseOwner`, `reconcile` and `sweep`.
|
|
228
228
|
*/
|
|
229
229
|
store?: CloudropStore<unknown>;
|
|
230
230
|
/**
|
|
@@ -274,9 +274,61 @@ interface BucketReport {
|
|
|
274
274
|
lifecycle: BucketCheck;
|
|
275
275
|
publicAccess: BucketCheck;
|
|
276
276
|
}
|
|
277
|
+
interface EraseOptions {
|
|
278
|
+
/**
|
|
279
|
+
* How long a PUT already under way gets to land after its URL ran out, before the key is checked for the last time:
|
|
280
|
+
* at least 900000 (15 minutes). Default 3600000 (1 hour).
|
|
281
|
+
*/
|
|
282
|
+
graceMs?: number;
|
|
283
|
+
/** Stops the run before the next file; the report then says done: false. */
|
|
284
|
+
signal?: AbortSignal;
|
|
285
|
+
}
|
|
286
|
+
interface EraseReport {
|
|
287
|
+
/** Unfinished uploads ended, so their next /sign or /complete is refused. */
|
|
288
|
+
revoked: number;
|
|
289
|
+
/** Completed files deleted: their rows are `deleted` and their bytes released. */
|
|
290
|
+
deleted: number;
|
|
291
|
+
/** Ended uploads whose key this run checked once their URLs and the grace had run out: it holds nothing of theirs. */
|
|
292
|
+
cleaned: number;
|
|
293
|
+
/** Files this run could not handle (a storage or database error, logged with the file's id). */
|
|
294
|
+
failed: number;
|
|
295
|
+
/**
|
|
296
|
+
* Files not provable yet: a completion still under way, an upload that started after this run began, or an ended
|
|
297
|
+
* upload whose URLs, or the grace after them, have not run out. Their objects were removed where there were any.
|
|
298
|
+
*/
|
|
299
|
+
waiting: number;
|
|
300
|
+
/**
|
|
301
|
+
* True when the run found nothing of the owner unfinished or completed, and every ended upload of theirs had its key
|
|
302
|
+
* checked once its URLs and the grace after them ran out. Run eraseOwner again until it is.
|
|
303
|
+
*/
|
|
304
|
+
done: boolean;
|
|
305
|
+
}
|
|
306
|
+
interface FilesOptions {
|
|
307
|
+
/** The owner, as the route's `owner` callback returned it. */
|
|
308
|
+
owner: string;
|
|
309
|
+
/** Only this route's files. */
|
|
310
|
+
route?: string;
|
|
311
|
+
/** Files per page, 1 to 1000. Default 100. */
|
|
312
|
+
limit?: number;
|
|
313
|
+
/** The `cursor` an earlier page answered, to read the next one. */
|
|
314
|
+
cursor?: string;
|
|
315
|
+
}
|
|
316
|
+
interface FilesPage {
|
|
317
|
+
/** The files' rows, newest upload first. */
|
|
318
|
+
items: FileRecord[];
|
|
319
|
+
/** Pass it back to read the next page; null on the last one. */
|
|
320
|
+
cursor: string | null;
|
|
321
|
+
}
|
|
277
322
|
interface SweepOptions {
|
|
278
|
-
/** Rows handled in this call, 1 to 1000. Default 100. */
|
|
323
|
+
/** Rows handled in this call, 1 to 1000; with `all`, rows per page. Default 100. */
|
|
279
324
|
limit?: number;
|
|
325
|
+
/**
|
|
326
|
+
* Sweeps every page in this one call, `limit` rows at a time, until every row has been seen or `signal` aborts, and
|
|
327
|
+
* answers the pages' reports summed. For a cron job: `sweep({ all: true, signal: AbortSignal.timeout(25_000) })`.
|
|
328
|
+
*/
|
|
329
|
+
all?: boolean;
|
|
330
|
+
/** With `all`: checked before each page. Once aborted, the call stops and its `cursor` continues where it stopped. */
|
|
331
|
+
signal?: AbortSignal;
|
|
280
332
|
/** The `cursor` an earlier sweep returned, to continue where it stopped. */
|
|
281
333
|
cursor?: string;
|
|
282
334
|
/**
|
|
@@ -291,7 +343,7 @@ interface SweepOptions {
|
|
|
291
343
|
interface SweepReport {
|
|
292
344
|
/** Unfinished uploads ended as expired, with what they left removed. */
|
|
293
345
|
expired: number;
|
|
294
|
-
/** Ended uploads whose late objects and parts were removed. */
|
|
346
|
+
/** Ended uploads whose late objects and parts were removed, counted once no upload URL can add more (M8-A4). */
|
|
295
347
|
cleaned: number;
|
|
296
348
|
/**
|
|
297
349
|
* Rows that failed this time (a storage or database error, logged with the row's id). Each stays as it was and the
|
|
@@ -306,12 +358,16 @@ interface SweepReport {
|
|
|
306
358
|
/**
|
|
307
359
|
* Pass it to the next sweep to continue; null when every row has been seen, or when a listing failed after this call
|
|
308
360
|
* had handled rows (counted in `failed`). A listing that fails before any row answers the store's error instead.
|
|
361
|
+
* With `all`, it is null unless the signal stopped the call; a listing that fails after the first page counts in
|
|
362
|
+
* `failed` and answers null too.
|
|
309
363
|
*/
|
|
310
364
|
cursor: string | null;
|
|
311
365
|
}
|
|
312
366
|
interface StoreFileApi {
|
|
313
367
|
/** A file's row, or null when the store has none. */
|
|
314
368
|
file(id: string): Promise<Result<FileRecord | null>>;
|
|
369
|
+
/** An owner's completed files, newest first, a page at a time. */
|
|
370
|
+
files(options: FilesOptions): Promise<Result<FilesPage>>;
|
|
315
371
|
/** An owner's counters, with or without a quota. */
|
|
316
372
|
usage(owner: string): Promise<Result<OwnerUsage>>;
|
|
317
373
|
/** Ends an owner's unfinished uploads, such as at sign-out: their next /sign or /complete is refused. */
|
|
@@ -324,6 +380,11 @@ interface StoreFileApi {
|
|
|
324
380
|
deleteFile(id: string): Promise<Result<{
|
|
325
381
|
id: string;
|
|
326
382
|
}>>;
|
|
383
|
+
/**
|
|
384
|
+
* Erases an owner, such as a deleted account: ends their unfinished uploads, deletes every completed file and removes
|
|
385
|
+
* what ended uploads left. Idempotent; run it again, such as with each sweep, until it reports done.
|
|
386
|
+
*/
|
|
387
|
+
eraseOwner(owner: string, options?: EraseOptions): Promise<Result<EraseReport>>;
|
|
327
388
|
/** Recounts one owner's counters from their rows, or every owner's: for drift after manual database edits. */
|
|
328
389
|
reconcile(options?: {
|
|
329
390
|
owner?: string;
|
|
@@ -418,4 +479,4 @@ interface S3Options {
|
|
|
418
479
|
}
|
|
419
480
|
export declare function r2(given?: R2Options): StorageDriver;
|
|
420
481
|
export declare function s3(given?: S3Options): StorageDriver;
|
|
421
|
-
export { type AbortContext, type AfterCompleteContext, type AfterVerifyContext, type AuthorizeContext, type BeforeUploadContext, type BucketCheck, type BucketCorsRule, type BucketLifecycleRule, type BucketReport, type ClaimOutcome, type Cloudrop, CloudropError, type CloudropErrorCode, type CloudropErrorOptions, type CloudropOptions, type CloudropPlugin, type CloudropStore, type CompleteContext, type CompletedPart, type EndedStatus, type FetchLike, type FileApi, type FileRecord, type FileStatus, type InferableCloudrop, type KeyContext, type ListedObject, type Logger, type NewFile, type ObjectInfo, type ObjectOptions, type OwnerContext, type OwnerUsage, type PartInfo, type PluginFile, type PresignedRequest, type Quota, type R2Options, type Refusal, type Result, type Route, type RouteCallbacks, type RouteDefinition, type RouteFunction, type RouteMetadata, type RouteName, type RoutePolicy, type RouteResult, type S3Options, type ServerHooks, type Size, type StandardSchema, type StorageDriver, type StorageRules, type StoreFileApi, type StoreOptions, type SweepOptions, type SweepReport, type TransactionalStore, type Transition, type UploadedFile, type WriteOptions, allowAnyone, forbidden, route, unauthorized };
|
|
482
|
+
export { type AbortContext, type AfterCompleteContext, type AfterVerifyContext, type AuthorizeContext, type BeforeUploadContext, type BucketCheck, type BucketCorsRule, type BucketLifecycleRule, type BucketReport, type ClaimOutcome, type Cloudrop, CloudropError, type CloudropErrorCode, type CloudropErrorOptions, type CloudropOptions, type CloudropPlugin, type CloudropStore, type CompleteContext, type CompletedPart, type Completion, type EndedStatus, type EraseOptions, type EraseReport, type FetchLike, type FileApi, type FileRecord, type FileStatus, type FilesOptions, type FilesPage, type InferableCloudrop, type KeyContext, type ListedObject, type Logger, type NewFile, type ObjectInfo, type ObjectOptions, type OwnerContext, type OwnerUsage, type PartInfo, type PluginFile, type PresignedRequest, type Quota, type R2Options, type Refusal, type Result, type Route, type RouteCallbacks, type RouteDefinition, type RouteFunction, type RouteMetadata, type RouteName, type RoutePolicy, type RouteResult, type S3Options, type ServerHooks, type Size, type StandardSchema, type StorageDriver, type StorageRules, type StoreFileApi, type StoreOptions, type SweepOptions, type SweepReport, type TransactionalStore, type Transition, type UploadedFile, type WriteOptions, allowAnyone, forbidden, route, unauthorized };
|