cloudrop 0.1.1 → 0.3.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 +115 -0
- package/README.md +34 -4
- 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 +4 -1
- package/dist/adapters/sql.js +8 -1
- package/dist/adapters/sql.js.map +1 -1
- package/dist/cli.js +2045 -0
- package/dist/{client-Dj6ON4MN.d.ts → client-CP_ajLF4.d.ts} +43 -25
- package/dist/{client-Y1zUEbCj.js → client-DxP3uv8V.js} +172 -44
- package/dist/client-DxP3uv8V.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 +92 -7
- package/dist/index.js +432 -152
- 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/testing.d.ts +81 -0
- package/dist/testing.js +1243 -0
- package/dist/testing.js.map +1 -0
- 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/docs/README.md +30 -0
- package/docs/bucket-setup.md +226 -0
- package/docs/client.md +386 -0
- package/docs/command.md +129 -0
- package/docs/deployment.md +169 -0
- package/docs/errors.md +150 -0
- package/docs/hono.md +276 -0
- package/docs/react.md +508 -0
- package/docs/resume.md +253 -0
- package/docs/server.md +603 -0
- package/docs/store.md +804 -0
- package/docs/testing-your-app.md +328 -0
- package/docs/troubleshooting.md +176 -0
- package/package.json +16 -8
- 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;
|
|
@@ -58,12 +58,16 @@ interface ListedObject {
|
|
|
58
58
|
etag: string;
|
|
59
59
|
uploadedAt: Date;
|
|
60
60
|
}
|
|
61
|
-
/** One rule of the bucket's CORS configuration, as S3's GetBucketCors returns it. */
|
|
61
|
+
/** One rule of the bucket's CORS configuration, as S3's GetBucketCors returns it: every field S3 documents. */
|
|
62
62
|
interface BucketCorsRule {
|
|
63
|
+
/** Present only when the rule has one. */
|
|
64
|
+
id?: string;
|
|
63
65
|
allowedOrigins: string[];
|
|
64
66
|
allowedMethods: string[];
|
|
65
67
|
allowedHeaders: string[];
|
|
66
68
|
exposeHeaders: string[];
|
|
69
|
+
/** Present only when the rule sets it. */
|
|
70
|
+
maxAgeSeconds?: number;
|
|
67
71
|
}
|
|
68
72
|
/** One rule of the bucket's lifecycle configuration; only what cloudrop checks. */
|
|
69
73
|
interface BucketLifecycleRule {
|
|
@@ -77,6 +81,12 @@ interface BucketLifecycleRule {
|
|
|
77
81
|
prefix: string;
|
|
78
82
|
/** Days after which an incomplete multipart upload is aborted, when the rule does that. */
|
|
79
83
|
abortIncompleteMultipartUploadDays?: number;
|
|
84
|
+
/**
|
|
85
|
+
* The rule's XML inside `<Rule>`, exactly as the storage sent it. `putBucketLifecycle` writes it unchanged when it is
|
|
86
|
+
* present, so what the fields above leave out (expirations, transitions, tag and size filters) survives a read
|
|
87
|
+
* followed by a write. A rule without it is written from the fields above.
|
|
88
|
+
*/
|
|
89
|
+
sourceXml?: string;
|
|
80
90
|
}
|
|
81
91
|
/** Implemented by cloudrop's presets, r2() and s3(); its methods may change before 1.0. */
|
|
82
92
|
interface StorageDriver {
|
|
@@ -118,6 +128,20 @@ interface StorageDriver {
|
|
|
118
128
|
getBucketCors(): Promise<Result<BucketCorsRule[]>>;
|
|
119
129
|
/** The bucket's lifecycle rules; [] when it has none. Credentials that may not read them get STORAGE_DENIED. */
|
|
120
130
|
getBucketLifecycle(): Promise<Result<BucketLifecycleRule[]>>;
|
|
131
|
+
/**
|
|
132
|
+
* Replaces the bucket's whole CORS configuration with `rules` (at least one), as S3's PutBucketCors does: to keep a
|
|
133
|
+
* rule, read it and pass it back. Needs credentials that may change bucket settings; others get STORAGE_DENIED.
|
|
134
|
+
* Optional, so a hand-written driver need not implement it. r2() and s3() do not either, to keep it out of an app's
|
|
135
|
+
* bundle: the `cloudrop setup --apply` command writes bucket settings.
|
|
136
|
+
*/
|
|
137
|
+
putBucketCors?(rules: readonly BucketCorsRule[]): Promise<Result<void>>;
|
|
138
|
+
/**
|
|
139
|
+
* Replaces the bucket's whole lifecycle configuration with `rules` (at least one), as S3's
|
|
140
|
+
* PutBucketLifecycleConfiguration does. A rule read from the bucket keeps everything through its `sourceXml`; a new
|
|
141
|
+
* rule is written from its fields and needs `abortIncompleteMultipartUploadDays`, the only action cloudrop writes.
|
|
142
|
+
* Optional, like putBucketCors.
|
|
143
|
+
*/
|
|
144
|
+
putBucketLifecycle?(rules: readonly BucketLifecycleRule[]): Promise<Result<void>>;
|
|
121
145
|
/** `null` only when the object does not exist; every other failure is an error. */
|
|
122
146
|
head(key: string): Promise<Result<ObjectInfo | null>>;
|
|
123
147
|
/** Inclusive byte range. */
|
|
@@ -224,7 +248,7 @@ interface StoreOptions {
|
|
|
224
248
|
/**
|
|
225
249
|
* A database store, such as `sqlStore(...)` from `cloudrop/adapters/sql`. With one, `/upload` writes a row per file
|
|
226
250
|
* 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`.
|
|
251
|
+
* gains `file`, `files`, `usage`, `revokeUploads`, `deleteFile`, `eraseOwner`, `reconcile` and `sweep`.
|
|
228
252
|
*/
|
|
229
253
|
store?: CloudropStore<unknown>;
|
|
230
254
|
/**
|
|
@@ -274,9 +298,61 @@ interface BucketReport {
|
|
|
274
298
|
lifecycle: BucketCheck;
|
|
275
299
|
publicAccess: BucketCheck;
|
|
276
300
|
}
|
|
301
|
+
interface EraseOptions {
|
|
302
|
+
/**
|
|
303
|
+
* How long a PUT already under way gets to land after its URL ran out, before the key is checked for the last time:
|
|
304
|
+
* at least 900000 (15 minutes). Default 3600000 (1 hour).
|
|
305
|
+
*/
|
|
306
|
+
graceMs?: number;
|
|
307
|
+
/** Stops the run before the next file; the report then says done: false. */
|
|
308
|
+
signal?: AbortSignal;
|
|
309
|
+
}
|
|
310
|
+
interface EraseReport {
|
|
311
|
+
/** Unfinished uploads ended, so their next /sign or /complete is refused. */
|
|
312
|
+
revoked: number;
|
|
313
|
+
/** Completed files deleted: their rows are `deleted` and their bytes released. */
|
|
314
|
+
deleted: number;
|
|
315
|
+
/** Ended uploads whose key this run checked once their URLs and the grace had run out: it holds nothing of theirs. */
|
|
316
|
+
cleaned: number;
|
|
317
|
+
/** Files this run could not handle (a storage or database error, logged with the file's id). */
|
|
318
|
+
failed: number;
|
|
319
|
+
/**
|
|
320
|
+
* Files not provable yet: a completion still under way, an upload that started after this run began, or an ended
|
|
321
|
+
* upload whose URLs, or the grace after them, have not run out. Their objects were removed where there were any.
|
|
322
|
+
*/
|
|
323
|
+
waiting: number;
|
|
324
|
+
/**
|
|
325
|
+
* True when the run found nothing of the owner unfinished or completed, and every ended upload of theirs had its key
|
|
326
|
+
* checked once its URLs and the grace after them ran out. Run eraseOwner again until it is.
|
|
327
|
+
*/
|
|
328
|
+
done: boolean;
|
|
329
|
+
}
|
|
330
|
+
interface FilesOptions {
|
|
331
|
+
/** The owner, as the route's `owner` callback returned it. */
|
|
332
|
+
owner: string;
|
|
333
|
+
/** Only this route's files. */
|
|
334
|
+
route?: string;
|
|
335
|
+
/** Files per page, 1 to 1000. Default 100. */
|
|
336
|
+
limit?: number;
|
|
337
|
+
/** The `cursor` an earlier page answered, to read the next one. */
|
|
338
|
+
cursor?: string;
|
|
339
|
+
}
|
|
340
|
+
interface FilesPage {
|
|
341
|
+
/** The files' rows, newest upload first. */
|
|
342
|
+
items: FileRecord[];
|
|
343
|
+
/** Pass it back to read the next page; null on the last one. */
|
|
344
|
+
cursor: string | null;
|
|
345
|
+
}
|
|
277
346
|
interface SweepOptions {
|
|
278
|
-
/** Rows handled in this call, 1 to 1000. Default 100. */
|
|
347
|
+
/** Rows handled in this call, 1 to 1000; with `all`, rows per page. Default 100. */
|
|
279
348
|
limit?: number;
|
|
349
|
+
/**
|
|
350
|
+
* Sweeps every page in this one call, `limit` rows at a time, until every row has been seen or `signal` aborts, and
|
|
351
|
+
* answers the pages' reports summed. For a cron job: `sweep({ all: true, signal: AbortSignal.timeout(25_000) })`.
|
|
352
|
+
*/
|
|
353
|
+
all?: boolean;
|
|
354
|
+
/** With `all`: checked before each page. Once aborted, the call stops and its `cursor` continues where it stopped. */
|
|
355
|
+
signal?: AbortSignal;
|
|
280
356
|
/** The `cursor` an earlier sweep returned, to continue where it stopped. */
|
|
281
357
|
cursor?: string;
|
|
282
358
|
/**
|
|
@@ -291,7 +367,7 @@ interface SweepOptions {
|
|
|
291
367
|
interface SweepReport {
|
|
292
368
|
/** Unfinished uploads ended as expired, with what they left removed. */
|
|
293
369
|
expired: number;
|
|
294
|
-
/** Ended uploads whose late objects and parts were removed. */
|
|
370
|
+
/** Ended uploads whose late objects and parts were removed, counted once no upload URL can add more (M8-A4). */
|
|
295
371
|
cleaned: number;
|
|
296
372
|
/**
|
|
297
373
|
* 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 +382,16 @@ interface SweepReport {
|
|
|
306
382
|
/**
|
|
307
383
|
* Pass it to the next sweep to continue; null when every row has been seen, or when a listing failed after this call
|
|
308
384
|
* had handled rows (counted in `failed`). A listing that fails before any row answers the store's error instead.
|
|
385
|
+
* With `all`, it is null unless the signal stopped the call; a listing that fails after the first page counts in
|
|
386
|
+
* `failed` and answers null too.
|
|
309
387
|
*/
|
|
310
388
|
cursor: string | null;
|
|
311
389
|
}
|
|
312
390
|
interface StoreFileApi {
|
|
313
391
|
/** A file's row, or null when the store has none. */
|
|
314
392
|
file(id: string): Promise<Result<FileRecord | null>>;
|
|
393
|
+
/** An owner's completed files, newest first, a page at a time. */
|
|
394
|
+
files(options: FilesOptions): Promise<Result<FilesPage>>;
|
|
315
395
|
/** An owner's counters, with or without a quota. */
|
|
316
396
|
usage(owner: string): Promise<Result<OwnerUsage>>;
|
|
317
397
|
/** Ends an owner's unfinished uploads, such as at sign-out: their next /sign or /complete is refused. */
|
|
@@ -324,6 +404,11 @@ interface StoreFileApi {
|
|
|
324
404
|
deleteFile(id: string): Promise<Result<{
|
|
325
405
|
id: string;
|
|
326
406
|
}>>;
|
|
407
|
+
/**
|
|
408
|
+
* Erases an owner, such as a deleted account: ends their unfinished uploads, deletes every completed file and removes
|
|
409
|
+
* what ended uploads left. Idempotent; run it again, such as with each sweep, until it reports done.
|
|
410
|
+
*/
|
|
411
|
+
eraseOwner(owner: string, options?: EraseOptions): Promise<Result<EraseReport>>;
|
|
327
412
|
/** Recounts one owner's counters from their rows, or every owner's: for drift after manual database edits. */
|
|
328
413
|
reconcile(options?: {
|
|
329
414
|
owner?: string;
|
|
@@ -418,4 +503,4 @@ interface S3Options {
|
|
|
418
503
|
}
|
|
419
504
|
export declare function r2(given?: R2Options): StorageDriver;
|
|
420
505
|
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 };
|
|
506
|
+
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 };
|