@lunora/storage 1.0.0-alpha.13 → 1.0.0-alpha.15
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/index.d.mts +3 -132
- package/dist/index.d.ts +3 -132
- package/package.json +3 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,134 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* bound required, mirroring R2's own `R2Range`) or a `{ suffix }` tail. The
|
|
4
|
-
* subset of `R2Range` that {@link Storage.download} forwards so a caller can
|
|
5
|
-
* stream just the bytes it needs instead of the whole object.
|
|
6
|
-
*/
|
|
7
|
-
type R2RangeLike = {
|
|
8
|
-
length: number;
|
|
9
|
-
offset?: number;
|
|
10
|
-
} | {
|
|
11
|
-
length?: number;
|
|
12
|
-
offset: number;
|
|
13
|
-
} | {
|
|
14
|
-
suffix: number;
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Minimal projection of `R2Bucket`. Declared structurally so unit tests can
|
|
18
|
-
* pass a plain object double; the real binding satisfies the same shape.
|
|
19
|
-
*/
|
|
20
|
-
interface R2BucketLike {
|
|
21
|
-
/**
|
|
22
|
-
* Begin a multipart upload (R2 `createMultipartUpload`). Optional so existing
|
|
23
|
-
* test doubles still satisfy the type; {@link Storage.createMultipartUpload}
|
|
24
|
-
* throws a clear error when the binding lacks it.
|
|
25
|
-
*/
|
|
26
|
-
createMultipartUpload?: (key: string, options?: {
|
|
27
|
-
customMetadata?: Record<string, string>;
|
|
28
|
-
httpMetadata?: {
|
|
29
|
-
contentType?: string;
|
|
30
|
-
};
|
|
31
|
-
}) => Promise<R2MultipartUploadLike>;
|
|
32
|
-
delete: (key: string) => Promise<void>;
|
|
33
|
-
get: (key: string, options?: {
|
|
34
|
-
range?: R2RangeLike;
|
|
35
|
-
}) => Promise<R2ObjectBodyLike | null>;
|
|
36
|
-
/**
|
|
37
|
-
* Fetch an object's metadata without its body (R2 HEAD). Returns `null` when
|
|
38
|
-
* the object is absent. Declared optional so existing test doubles that only
|
|
39
|
-
* implement `get`/`put`/`list`/`delete` still satisfy the type; callers that
|
|
40
|
-
* need metadata fall back to a 0-length ranged `get()` when `head` is absent.
|
|
41
|
-
*/
|
|
42
|
-
head?: (key: string) => Promise<R2ObjectLike | null>;
|
|
43
|
-
list: (options?: {
|
|
44
|
-
cursor?: string;
|
|
45
|
-
delimiter?: string;
|
|
46
|
-
limit?: number;
|
|
47
|
-
prefix?: string;
|
|
48
|
-
}) => Promise<{
|
|
49
|
-
cursor?: string;
|
|
50
|
-
objects: R2ObjectLike[];
|
|
51
|
-
truncated?: boolean;
|
|
52
|
-
}>;
|
|
53
|
-
put: (key: string, body: ReadableStream | ArrayBuffer | Blob | string | null, options?: {
|
|
54
|
-
customMetadata?: Record<string, string>;
|
|
55
|
-
httpMetadata?: {
|
|
56
|
-
contentType?: string;
|
|
57
|
-
};
|
|
58
|
-
}) => Promise<R2ObjectLike>;
|
|
59
|
-
/** Resume an in-progress multipart upload by id (R2 `resumeMultipartUpload`). Optional; see {@link Storage.resumeMultipartUpload}. */
|
|
60
|
-
resumeMultipartUpload?: (key: string, uploadId: string) => R2MultipartUploadLike;
|
|
61
|
-
}
|
|
62
|
-
/** One uploaded multipart part — returned by `uploadPart`, required to `complete`. Mirrors R2's `R2UploadedPart`. */
|
|
63
|
-
interface R2UploadedPartLike {
|
|
64
|
-
etag: string;
|
|
65
|
-
partNumber: number;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* An in-progress multipart upload, mirroring R2's `R2MultipartUpload`. Each part
|
|
69
|
-
* (except the last) must be uniform in size. The object does not guarantee the
|
|
70
|
-
* underlying upload still exists — a parallel `complete`/`abort` can invalidate
|
|
71
|
-
* it — so wrap each call in error handling.
|
|
72
|
-
*/
|
|
73
|
-
interface R2MultipartUploadLike {
|
|
74
|
-
/** Abort the upload, discarding any uploaded parts. */
|
|
75
|
-
abort: () => Promise<void>;
|
|
76
|
-
/** Finish the upload from the collected parts; resolves to the stored object. */
|
|
77
|
-
complete: (uploadedParts: R2UploadedPartLike[]) => Promise<R2ObjectLike>;
|
|
78
|
-
/** The object key being assembled. */
|
|
79
|
-
readonly key: string;
|
|
80
|
-
/** The R2 upload id (persist it to resume across requests). */
|
|
81
|
-
readonly uploadId: string;
|
|
82
|
-
/** Upload one part (1-indexed); returns the `{ partNumber, etag }` to pass to `complete`. */
|
|
83
|
-
uploadPart: (partNumber: number, value: ArrayBuffer | ArrayBufferView | Blob | ReadableStream | string) => Promise<R2UploadedPartLike>;
|
|
84
|
-
}
|
|
85
|
-
interface R2ObjectLike {
|
|
86
|
-
/**
|
|
87
|
-
* R2-computed checksums. The real binding exposes `sha256` as an
|
|
88
|
-
* `ArrayBuffer` (present only when R2 stored a SHA-256 for the object);
|
|
89
|
-
* declared optional so fakes and non-checksummed objects type-check.
|
|
90
|
-
*/
|
|
91
|
-
checksums?: {
|
|
92
|
-
sha256?: ArrayBuffer;
|
|
93
|
-
};
|
|
94
|
-
customMetadata?: Record<string, string>;
|
|
95
|
-
etag: string;
|
|
96
|
-
/**
|
|
97
|
-
* The quoted form of {@link R2ObjectLike.etag} (e.g. `"abc123"`), suitable
|
|
98
|
-
* for emitting directly as an HTTP `ETag` header. The real binding always
|
|
99
|
-
* provides it; declared optional so existing doubles that only set `etag`
|
|
100
|
-
* still type-check (callers fall back to quoting `etag`).
|
|
101
|
-
*/
|
|
102
|
-
httpEtag?: string;
|
|
103
|
-
httpMetadata?: {
|
|
104
|
-
contentType?: string;
|
|
105
|
-
};
|
|
106
|
-
key: string;
|
|
107
|
-
/**
|
|
108
|
-
* Hex-encoded SHA-256 of the object body, surfaced by `download()`/`list()`
|
|
109
|
-
* when R2 carries a checksum (derived from {@link R2ObjectLike.checksums}).
|
|
110
|
-
*/
|
|
111
|
-
sha256?: string;
|
|
112
|
-
/**
|
|
113
|
-
* Base64-encoded SHA-256 of the object body, surfaced alongside
|
|
114
|
-
* {@link R2ObjectLike.sha256} from the same checksum. Base64 is the encoding
|
|
115
|
-
* RFC 9530 digest headers (`Repr-Digest`/`Content-Digest`) require, so HTTP
|
|
116
|
-
* layers can emit a spec-compliant digest without re-deriving it.
|
|
117
|
-
*/
|
|
118
|
-
sha256Base64?: string;
|
|
119
|
-
size: number;
|
|
120
|
-
/**
|
|
121
|
-
* When the object was written. The real binding exposes this as a `Date`;
|
|
122
|
-
* declared optional so fakes that omit it still type-check.
|
|
123
|
-
* {@link Storage.getMetadata} normalises it to epoch ms.
|
|
124
|
-
*/
|
|
125
|
-
uploaded?: Date;
|
|
126
|
-
}
|
|
127
|
-
interface R2ObjectBodyLike extends R2ObjectLike {
|
|
128
|
-
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
129
|
-
body: ReadableStream | null;
|
|
130
|
-
text: () => Promise<string>;
|
|
131
|
-
}
|
|
1
|
+
import { R2MultipartUploadLike, R2RangeLike, R2ObjectBodyLike, R2ObjectLike, R2BucketLike } from '@lunora/platform';
|
|
2
|
+
export type { R2BucketLike, R2MultipartUploadLike, R2ObjectBodyLike, R2ObjectLike, R2RangeLike, R2UploadedPartLike } from '@lunora/platform';
|
|
132
3
|
/**
|
|
133
4
|
* R2 S3-API credentials for {@link Storage.getPresignedUrl}. These are an R2 API
|
|
134
5
|
* token's Access Key ID / Secret Access Key (NOT a Cloudflare API token), plus
|
|
@@ -403,4 +274,4 @@ interface VerifyResult {
|
|
|
403
274
|
declare const verifySignedUrl: (input: string | URL, secret: string, options?: {
|
|
404
275
|
expectedHost?: string;
|
|
405
276
|
}) => Promise<VerifyResult>;
|
|
406
|
-
export { type BucketStorage, type ListOptions, type LunoraStorageOptions, type ObjectMetadata, type PresignedUrlOptions, type PresignedUrlParams, type
|
|
277
|
+
export { type BucketStorage, type ListOptions, type LunoraStorageOptions, type ObjectMetadata, type PresignedUrlOptions, type PresignedUrlParams, type R2S3Credentials, type SignedUrlOptions, type Storage, type UploadOptions, type VerifyResult, buildPresignedUrl, buildSignedUrl, createBucketStorage, createStorage, scopeKey, verifySignedUrl };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,134 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* bound required, mirroring R2's own `R2Range`) or a `{ suffix }` tail. The
|
|
4
|
-
* subset of `R2Range` that {@link Storage.download} forwards so a caller can
|
|
5
|
-
* stream just the bytes it needs instead of the whole object.
|
|
6
|
-
*/
|
|
7
|
-
type R2RangeLike = {
|
|
8
|
-
length: number;
|
|
9
|
-
offset?: number;
|
|
10
|
-
} | {
|
|
11
|
-
length?: number;
|
|
12
|
-
offset: number;
|
|
13
|
-
} | {
|
|
14
|
-
suffix: number;
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Minimal projection of `R2Bucket`. Declared structurally so unit tests can
|
|
18
|
-
* pass a plain object double; the real binding satisfies the same shape.
|
|
19
|
-
*/
|
|
20
|
-
interface R2BucketLike {
|
|
21
|
-
/**
|
|
22
|
-
* Begin a multipart upload (R2 `createMultipartUpload`). Optional so existing
|
|
23
|
-
* test doubles still satisfy the type; {@link Storage.createMultipartUpload}
|
|
24
|
-
* throws a clear error when the binding lacks it.
|
|
25
|
-
*/
|
|
26
|
-
createMultipartUpload?: (key: string, options?: {
|
|
27
|
-
customMetadata?: Record<string, string>;
|
|
28
|
-
httpMetadata?: {
|
|
29
|
-
contentType?: string;
|
|
30
|
-
};
|
|
31
|
-
}) => Promise<R2MultipartUploadLike>;
|
|
32
|
-
delete: (key: string) => Promise<void>;
|
|
33
|
-
get: (key: string, options?: {
|
|
34
|
-
range?: R2RangeLike;
|
|
35
|
-
}) => Promise<R2ObjectBodyLike | null>;
|
|
36
|
-
/**
|
|
37
|
-
* Fetch an object's metadata without its body (R2 HEAD). Returns `null` when
|
|
38
|
-
* the object is absent. Declared optional so existing test doubles that only
|
|
39
|
-
* implement `get`/`put`/`list`/`delete` still satisfy the type; callers that
|
|
40
|
-
* need metadata fall back to a 0-length ranged `get()` when `head` is absent.
|
|
41
|
-
*/
|
|
42
|
-
head?: (key: string) => Promise<R2ObjectLike | null>;
|
|
43
|
-
list: (options?: {
|
|
44
|
-
cursor?: string;
|
|
45
|
-
delimiter?: string;
|
|
46
|
-
limit?: number;
|
|
47
|
-
prefix?: string;
|
|
48
|
-
}) => Promise<{
|
|
49
|
-
cursor?: string;
|
|
50
|
-
objects: R2ObjectLike[];
|
|
51
|
-
truncated?: boolean;
|
|
52
|
-
}>;
|
|
53
|
-
put: (key: string, body: ReadableStream | ArrayBuffer | Blob | string | null, options?: {
|
|
54
|
-
customMetadata?: Record<string, string>;
|
|
55
|
-
httpMetadata?: {
|
|
56
|
-
contentType?: string;
|
|
57
|
-
};
|
|
58
|
-
}) => Promise<R2ObjectLike>;
|
|
59
|
-
/** Resume an in-progress multipart upload by id (R2 `resumeMultipartUpload`). Optional; see {@link Storage.resumeMultipartUpload}. */
|
|
60
|
-
resumeMultipartUpload?: (key: string, uploadId: string) => R2MultipartUploadLike;
|
|
61
|
-
}
|
|
62
|
-
/** One uploaded multipart part — returned by `uploadPart`, required to `complete`. Mirrors R2's `R2UploadedPart`. */
|
|
63
|
-
interface R2UploadedPartLike {
|
|
64
|
-
etag: string;
|
|
65
|
-
partNumber: number;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* An in-progress multipart upload, mirroring R2's `R2MultipartUpload`. Each part
|
|
69
|
-
* (except the last) must be uniform in size. The object does not guarantee the
|
|
70
|
-
* underlying upload still exists — a parallel `complete`/`abort` can invalidate
|
|
71
|
-
* it — so wrap each call in error handling.
|
|
72
|
-
*/
|
|
73
|
-
interface R2MultipartUploadLike {
|
|
74
|
-
/** Abort the upload, discarding any uploaded parts. */
|
|
75
|
-
abort: () => Promise<void>;
|
|
76
|
-
/** Finish the upload from the collected parts; resolves to the stored object. */
|
|
77
|
-
complete: (uploadedParts: R2UploadedPartLike[]) => Promise<R2ObjectLike>;
|
|
78
|
-
/** The object key being assembled. */
|
|
79
|
-
readonly key: string;
|
|
80
|
-
/** The R2 upload id (persist it to resume across requests). */
|
|
81
|
-
readonly uploadId: string;
|
|
82
|
-
/** Upload one part (1-indexed); returns the `{ partNumber, etag }` to pass to `complete`. */
|
|
83
|
-
uploadPart: (partNumber: number, value: ArrayBuffer | ArrayBufferView | Blob | ReadableStream | string) => Promise<R2UploadedPartLike>;
|
|
84
|
-
}
|
|
85
|
-
interface R2ObjectLike {
|
|
86
|
-
/**
|
|
87
|
-
* R2-computed checksums. The real binding exposes `sha256` as an
|
|
88
|
-
* `ArrayBuffer` (present only when R2 stored a SHA-256 for the object);
|
|
89
|
-
* declared optional so fakes and non-checksummed objects type-check.
|
|
90
|
-
*/
|
|
91
|
-
checksums?: {
|
|
92
|
-
sha256?: ArrayBuffer;
|
|
93
|
-
};
|
|
94
|
-
customMetadata?: Record<string, string>;
|
|
95
|
-
etag: string;
|
|
96
|
-
/**
|
|
97
|
-
* The quoted form of {@link R2ObjectLike.etag} (e.g. `"abc123"`), suitable
|
|
98
|
-
* for emitting directly as an HTTP `ETag` header. The real binding always
|
|
99
|
-
* provides it; declared optional so existing doubles that only set `etag`
|
|
100
|
-
* still type-check (callers fall back to quoting `etag`).
|
|
101
|
-
*/
|
|
102
|
-
httpEtag?: string;
|
|
103
|
-
httpMetadata?: {
|
|
104
|
-
contentType?: string;
|
|
105
|
-
};
|
|
106
|
-
key: string;
|
|
107
|
-
/**
|
|
108
|
-
* Hex-encoded SHA-256 of the object body, surfaced by `download()`/`list()`
|
|
109
|
-
* when R2 carries a checksum (derived from {@link R2ObjectLike.checksums}).
|
|
110
|
-
*/
|
|
111
|
-
sha256?: string;
|
|
112
|
-
/**
|
|
113
|
-
* Base64-encoded SHA-256 of the object body, surfaced alongside
|
|
114
|
-
* {@link R2ObjectLike.sha256} from the same checksum. Base64 is the encoding
|
|
115
|
-
* RFC 9530 digest headers (`Repr-Digest`/`Content-Digest`) require, so HTTP
|
|
116
|
-
* layers can emit a spec-compliant digest without re-deriving it.
|
|
117
|
-
*/
|
|
118
|
-
sha256Base64?: string;
|
|
119
|
-
size: number;
|
|
120
|
-
/**
|
|
121
|
-
* When the object was written. The real binding exposes this as a `Date`;
|
|
122
|
-
* declared optional so fakes that omit it still type-check.
|
|
123
|
-
* {@link Storage.getMetadata} normalises it to epoch ms.
|
|
124
|
-
*/
|
|
125
|
-
uploaded?: Date;
|
|
126
|
-
}
|
|
127
|
-
interface R2ObjectBodyLike extends R2ObjectLike {
|
|
128
|
-
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
129
|
-
body: ReadableStream | null;
|
|
130
|
-
text: () => Promise<string>;
|
|
131
|
-
}
|
|
1
|
+
import { R2MultipartUploadLike, R2RangeLike, R2ObjectBodyLike, R2ObjectLike, R2BucketLike } from '@lunora/platform';
|
|
2
|
+
export type { R2BucketLike, R2MultipartUploadLike, R2ObjectBodyLike, R2ObjectLike, R2RangeLike, R2UploadedPartLike } from '@lunora/platform';
|
|
132
3
|
/**
|
|
133
4
|
* R2 S3-API credentials for {@link Storage.getPresignedUrl}. These are an R2 API
|
|
134
5
|
* token's Access Key ID / Secret Access Key (NOT a Cloudflare API token), plus
|
|
@@ -403,4 +274,4 @@ interface VerifyResult {
|
|
|
403
274
|
declare const verifySignedUrl: (input: string | URL, secret: string, options?: {
|
|
404
275
|
expectedHost?: string;
|
|
405
276
|
}) => Promise<VerifyResult>;
|
|
406
|
-
export { type BucketStorage, type ListOptions, type LunoraStorageOptions, type ObjectMetadata, type PresignedUrlOptions, type PresignedUrlParams, type
|
|
277
|
+
export { type BucketStorage, type ListOptions, type LunoraStorageOptions, type ObjectMetadata, type PresignedUrlOptions, type PresignedUrlParams, type R2S3Credentials, type SignedUrlOptions, type Storage, type UploadOptions, type VerifyResult, buildPresignedUrl, buildSignedUrl, createBucketStorage, createStorage, scopeKey, verifySignedUrl };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/storage",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.15",
|
|
4
4
|
"description": "R2-backed storage for Lunora: typed buckets and signed URLs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -50,7 +50,8 @@
|
|
|
50
50
|
"access": "public"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@lunora/errors": "1.0.0-alpha.
|
|
53
|
+
"@lunora/errors": "1.0.0-alpha.10",
|
|
54
|
+
"@lunora/platform": "1.0.0-alpha.1",
|
|
54
55
|
"@visulima/storage": "1.0.5",
|
|
55
56
|
"aws4fetch": "1.0.20"
|
|
56
57
|
},
|