@dimah-s3/core 1.7.0 → 2.0.0-beta.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/README.md +32 -13
- package/dist/create-s3-client.d.ts +3 -0
- package/dist/create-s3-client.d.ts.map +1 -1
- package/dist/error-codes.d.ts +297 -29
- package/dist/error-codes.d.ts.map +1 -1
- package/dist/error.d.ts +46 -14
- package/dist/error.d.ts.map +1 -1
- package/dist/helpers/base64url.d.ts +18 -0
- package/dist/helpers/base64url.d.ts.map +1 -0
- package/dist/helpers/build-content-disposition.d.ts +4 -4
- package/dist/helpers/build-content-disposition.d.ts.map +1 -1
- package/dist/helpers/build-object-key.d.ts.map +1 -1
- package/dist/helpers/checksum.d.ts +8 -2
- package/dist/helpers/checksum.d.ts.map +1 -1
- package/dist/helpers/content-type.d.ts +17 -0
- package/dist/helpers/content-type.d.ts.map +1 -0
- package/dist/helpers/fit-file-name.d.ts +15 -0
- package/dist/helpers/fit-file-name.d.ts.map +1 -0
- package/dist/helpers/index.d.ts +7 -9
- package/dist/helpers/index.d.ts.map +1 -1
- package/dist/helpers/magic-bytes.d.ts +9 -2
- package/dist/helpers/magic-bytes.d.ts.map +1 -1
- package/dist/helpers/normalize-object-key.d.ts +8 -3
- package/dist/helpers/normalize-object-key.d.ts.map +1 -1
- package/dist/helpers/parse-file-name.d.ts +5 -0
- package/dist/helpers/parse-file-name.d.ts.map +1 -1
- package/dist/helpers/public-object-url.d.ts.map +1 -1
- package/dist/helpers/resolve-inline-disposition.d.ts +16 -6
- package/dist/helpers/resolve-inline-disposition.d.ts.map +1 -1
- package/dist/helpers/strip-slashes.d.ts +5 -0
- package/dist/helpers/strip-slashes.d.ts.map +1 -0
- package/dist/helpers/validate-file.d.ts +13 -16
- package/dist/helpers/validate-file.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +713 -465
- package/dist/index.js.map +1 -1
- package/dist/limits.d.ts +30 -0
- package/dist/limits.d.ts.map +1 -0
- package/dist/plugin/create-s3-fetch.d.ts +5 -3
- package/dist/plugin/create-s3-fetch.d.ts.map +1 -1
- package/dist/plugin/types.d.ts +13 -4
- package/dist/plugin/types.d.ts.map +1 -1
- package/dist/routes.d.ts +10 -4
- package/dist/routes.d.ts.map +1 -1
- package/dist/schema/catalog.d.ts +30 -39
- package/dist/schema/catalog.d.ts.map +1 -1
- package/dist/schema/delete.d.ts +1 -2
- package/dist/schema/delete.d.ts.map +1 -1
- package/dist/schema/download.d.ts +16 -3
- package/dist/schema/download.d.ts.map +1 -1
- package/dist/schema/index.d.ts +5 -9
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js +221 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/schema/multipart.d.ts +6 -29
- package/dist/schema/multipart.d.ts.map +1 -1
- package/dist/schema/shared.d.ts +25 -17
- package/dist/schema/shared.d.ts.map +1 -1
- package/dist/schema/upload.d.ts +10 -7
- package/dist/schema/upload.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/requests.d.ts +25 -31
- package/dist/types/requests.d.ts.map +1 -1
- package/dist/types/responses.d.ts +96 -83
- package/dist/types/responses.d.ts.map +1 -1
- package/package.json +9 -4
- package/dist/helpers/format-file-size.d.ts +0 -18
- package/dist/helpers/format-file-size.d.ts.map +0 -1
- package/dist/helpers/sanitize-file-name.d.ts +0 -3
- package/dist/helpers/sanitize-file-name.d.ts.map +0 -1
- package/dist/helpers/truncate-file-name.d.ts +0 -5
- package/dist/helpers/truncate-file-name.d.ts.map +0 -1
- package/dist/schema/error.d.ts +0 -14
- package/dist/schema/error.d.ts.map +0 -1
- package/dist/schema/file.d.ts +0 -12
- package/dist/schema/file.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -1,37 +1,56 @@
|
|
|
1
1
|
# @dimah-s3/core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**2.0 beta.** Install with `@beta`. `@latest` stays on 1.x, and betas can include breaking changes until 2.0.0.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
The protocol, typed fetch client, error catalog, and pure helpers shared by
|
|
6
|
+
`@dimah-s3/server` and `@dimah-s3/react`.
|
|
7
|
+
|
|
8
|
+
Full documentation: [v2.s3.dimah.dev/docs/core](https://v2.s3.dimah.dev/docs/core) ·
|
|
9
|
+
[llms.txt](https://v2.s3.dimah.dev/llms.txt)
|
|
7
10
|
|
|
8
11
|
## Install
|
|
9
12
|
|
|
10
13
|
```bash
|
|
11
|
-
pnpm add @dimah-s3/core
|
|
14
|
+
pnpm add @dimah-s3/core@beta
|
|
12
15
|
```
|
|
13
16
|
|
|
14
17
|
## Minimal setup
|
|
15
18
|
|
|
16
19
|
```ts
|
|
17
|
-
import { createS3Client,
|
|
20
|
+
import { createS3Client, isAPIError } from "@dimah-s3/core";
|
|
18
21
|
|
|
19
22
|
export const api = createS3Client({
|
|
20
|
-
//
|
|
23
|
+
// Must match the server basePath.
|
|
24
|
+
basePath: "/api/s3",
|
|
21
25
|
credentials: "include",
|
|
22
|
-
headers: () => ({ Authorization: `Bearer ${
|
|
26
|
+
headers: async () => ({ Authorization: `Bearer ${await getToken()}` }),
|
|
23
27
|
});
|
|
24
28
|
|
|
25
29
|
try {
|
|
26
|
-
await api.download({ route: "uploads", key });
|
|
27
|
-
} catch (
|
|
28
|
-
if (
|
|
29
|
-
console.error(
|
|
30
|
+
const { url } = await api.download({ route: "uploads", key });
|
|
31
|
+
} catch (error) {
|
|
32
|
+
if (isAPIError(error)) {
|
|
33
|
+
console.error(error.statusCode, error.code, error.message);
|
|
34
|
+
}
|
|
30
35
|
}
|
|
31
36
|
```
|
|
32
37
|
|
|
33
|
-
|
|
34
|
-
|
|
38
|
+
Every method takes a payload, then optional `{ signal, headers }`. Uploads
|
|
39
|
+
return an upload `ticket`; confirm and the later multipart calls send only
|
|
40
|
+
that ticket.
|
|
41
|
+
|
|
42
|
+
For React apps, use `createS3Client` from `@dimah-s3/react`. It takes the same
|
|
43
|
+
options and adds a bound `Provider` and `useApi`.
|
|
44
|
+
|
|
45
|
+
## Errors
|
|
46
|
+
|
|
47
|
+
Every failure is an `APIError` with a stable `code` from `S3_ERROR_CODES`.
|
|
48
|
+
Narrow it with `isS3ErrorCode(error, "OBJECT_NOT_FOUND")`. See
|
|
49
|
+
[Errors](https://v2.s3.dimah.dev/docs/server/errors).
|
|
50
|
+
|
|
51
|
+
## Upgrading from 1.7
|
|
52
|
+
|
|
53
|
+
See [Upgrade to 2.0 beta](https://v2.s3.dimah.dev/docs/migration-2-0).
|
|
35
54
|
|
|
36
55
|
## License
|
|
37
56
|
|
|
@@ -24,6 +24,9 @@ export type CreateS3ClientResult<P extends readonly S3ClientPlugin[] = []> = S3A
|
|
|
24
24
|
/**
|
|
25
25
|
* Browser (or isomorphic) client for the dimah-s3 HTTP API.
|
|
26
26
|
*
|
|
27
|
+
* Every method takes per-call `{ signal, headers }` last. Per-call headers
|
|
28
|
+
* override the client `headers`. Failures throw `APIError`.
|
|
29
|
+
*
|
|
27
30
|
* For React apps prefer `createS3Client` from `@dimah-s3/react` — same options,
|
|
28
31
|
* plus a bound `Provider` / typed `useApi` on the client object.
|
|
29
32
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-s3-client.d.ts","sourceRoot":"","sources":["../src/create-s3-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EASV,KAAK,
|
|
1
|
+
{"version":3,"file":"create-s3-client.d.ts","sourceRoot":"","sources":["../src/create-s3-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EASV,KAAK,EAKN,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,OAAO,EAGL,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,KAAK,OAAO,EACb,MAAM,UAAU,CAAC;AAOlB,0CAA0C;AAC1C,MAAM,MAAM,qBAAqB,CAC/B,CAAC,SAAS,SAAS,cAAc,EAAE,GAAG,SAAS,cAAc,EAAE,IAC7D;IACF,yEAAyE;IACzE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qEAAqE;IACrE,OAAO,CAAC,EAAE,CAAC,CAAC;CACb,GAAG,oBAAoB,CAAC;AA+HzB,yDAAyD;AACzD,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,SAAS,cAAc,EAAE,GAAG,EAAE,IACvE,KAAK,GACH,sBAAsB,CAAC,CAAC,CAAC,GAAG;IAC1B,YAAY,EAAE,OAAO,cAAc,CAAC;IACpC,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE;QAAE,OAAO,EAAE,CAAC,CAAA;KAAE,CAAC;CACxB,CAAC;AAEN;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,cAAc,CAAC,KAAK,CAAC,CAAC,SAAS,SAAS,cAAc,EAAE,GAAG,EAAE,EAC3E,OAAO,CAAC,EAAE,qBAAqB,CAAC,CAAC,CAAC,GACjC,oBAAoB,CAAC,CAAC,CAAC,CAmCzB"}
|
package/dist/error-codes.d.ts
CHANGED
|
@@ -1,78 +1,346 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* One catalog entry: HTTP `status`, an English `message` template with
|
|
3
|
+
* `{param}` placeholders, and `client: true` on codes only the browser raises.
|
|
4
4
|
*/
|
|
5
|
-
export
|
|
5
|
+
export type S3ErrorEntry = {
|
|
6
|
+
status: number;
|
|
7
|
+
message: string;
|
|
8
|
+
client?: true;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Tag each catalog entry with its own key as `code`.
|
|
12
|
+
* Same idea as Better Auth `defineErrorCodes`.
|
|
13
|
+
*/
|
|
14
|
+
export declare function defineErrorCodes<const T extends Record<string, S3ErrorEntry>>(codes: T): {
|
|
6
15
|
readonly [K in keyof T]: {
|
|
7
16
|
readonly code: K;
|
|
8
|
-
|
|
9
|
-
};
|
|
17
|
+
} & T[K];
|
|
10
18
|
};
|
|
11
19
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
20
|
+
* Every error code the protocol knows, with its status and message template.
|
|
21
|
+
* Entries flagged `client` are raised in the browser and never sent by the
|
|
22
|
+
* server.
|
|
14
23
|
*/
|
|
15
24
|
export declare const S3_ERROR_CODES: {
|
|
25
|
+
readonly VALIDATION_ERROR: {
|
|
26
|
+
readonly code: "VALIDATION_ERROR";
|
|
27
|
+
} & {
|
|
28
|
+
readonly status: 400;
|
|
29
|
+
readonly message: "Invalid request: {issue}";
|
|
30
|
+
};
|
|
31
|
+
readonly REQUEST_TOO_LARGE: {
|
|
32
|
+
readonly code: "REQUEST_TOO_LARGE";
|
|
33
|
+
} & {
|
|
34
|
+
readonly status: 413;
|
|
35
|
+
readonly message: "Request body exceeds {maxSize} bytes";
|
|
36
|
+
};
|
|
37
|
+
readonly UNSUPPORTED_MEDIA_TYPE: {
|
|
38
|
+
readonly code: "UNSUPPORTED_MEDIA_TYPE";
|
|
39
|
+
} & {
|
|
40
|
+
readonly status: 415;
|
|
41
|
+
readonly message: "Request body must be application/json";
|
|
42
|
+
};
|
|
16
43
|
readonly NOT_FOUND: {
|
|
17
44
|
readonly code: "NOT_FOUND";
|
|
18
|
-
|
|
45
|
+
} & {
|
|
46
|
+
readonly status: 404;
|
|
47
|
+
readonly message: "Not found";
|
|
19
48
|
};
|
|
20
49
|
readonly UNAUTHORIZED: {
|
|
21
50
|
readonly code: "UNAUTHORIZED";
|
|
51
|
+
} & {
|
|
52
|
+
readonly status: 401;
|
|
22
53
|
readonly message: "Unauthorized";
|
|
23
54
|
};
|
|
24
55
|
readonly FORBIDDEN: {
|
|
25
56
|
readonly code: "FORBIDDEN";
|
|
57
|
+
} & {
|
|
58
|
+
readonly status: 403;
|
|
26
59
|
readonly message: "Forbidden";
|
|
27
60
|
};
|
|
28
61
|
readonly CONFLICT: {
|
|
29
62
|
readonly code: "CONFLICT";
|
|
63
|
+
} & {
|
|
64
|
+
readonly status: 409;
|
|
30
65
|
readonly message: "Conflict";
|
|
31
66
|
};
|
|
32
67
|
readonly INTERNAL_ERROR: {
|
|
33
68
|
readonly code: "INTERNAL_ERROR";
|
|
69
|
+
} & {
|
|
70
|
+
readonly status: 500;
|
|
34
71
|
readonly message: "Internal server error";
|
|
35
72
|
};
|
|
36
|
-
readonly
|
|
37
|
-
readonly code: "
|
|
38
|
-
|
|
73
|
+
readonly S3_NETWORK_ERROR: {
|
|
74
|
+
readonly code: "S3_NETWORK_ERROR";
|
|
75
|
+
} & {
|
|
76
|
+
readonly status: 502;
|
|
77
|
+
readonly message: "S3 endpoint unreachable ({code})";
|
|
78
|
+
};
|
|
79
|
+
readonly UNKNOWN_ROUTE: {
|
|
80
|
+
readonly code: "UNKNOWN_ROUTE";
|
|
81
|
+
} & {
|
|
82
|
+
readonly status: 404;
|
|
83
|
+
readonly message: "Unknown file route \"{route}\"";
|
|
39
84
|
};
|
|
40
85
|
readonly FEATURE_DISABLED: {
|
|
41
86
|
readonly code: "FEATURE_DISABLED";
|
|
87
|
+
} & {
|
|
88
|
+
readonly status: 404;
|
|
42
89
|
readonly message: "{feature} is disabled";
|
|
43
90
|
};
|
|
44
|
-
readonly
|
|
45
|
-
readonly code: "
|
|
91
|
+
readonly KEY_INVALID: {
|
|
92
|
+
readonly code: "KEY_INVALID";
|
|
93
|
+
} & {
|
|
94
|
+
readonly status: 400;
|
|
46
95
|
readonly message: "Object key is invalid";
|
|
47
96
|
};
|
|
48
|
-
readonly
|
|
49
|
-
readonly code: "
|
|
50
|
-
|
|
97
|
+
readonly OBJECT_NOT_FOUND: {
|
|
98
|
+
readonly code: "OBJECT_NOT_FOUND";
|
|
99
|
+
} & {
|
|
100
|
+
readonly status: 404;
|
|
101
|
+
readonly message: "Object not found";
|
|
102
|
+
};
|
|
103
|
+
readonly RANGE_NOT_SATISFIABLE: {
|
|
104
|
+
readonly code: "RANGE_NOT_SATISFIABLE";
|
|
105
|
+
} & {
|
|
106
|
+
readonly status: 416;
|
|
107
|
+
readonly message: "Requested range not satisfiable";
|
|
108
|
+
};
|
|
109
|
+
readonly PRECONDITION_FAILED: {
|
|
110
|
+
readonly code: "PRECONDITION_FAILED";
|
|
111
|
+
} & {
|
|
112
|
+
readonly status: 412;
|
|
113
|
+
readonly message: "Precondition failed";
|
|
114
|
+
};
|
|
115
|
+
readonly FILE_EMPTY: {
|
|
116
|
+
readonly code: "FILE_EMPTY";
|
|
117
|
+
} & {
|
|
118
|
+
readonly status: 400;
|
|
119
|
+
readonly message: "File is empty";
|
|
120
|
+
};
|
|
121
|
+
readonly FILE_TOO_LARGE: {
|
|
122
|
+
readonly code: "FILE_TOO_LARGE";
|
|
123
|
+
} & {
|
|
124
|
+
readonly status: 413;
|
|
125
|
+
readonly message: "File is {size} bytes; the limit is {maxFileSize} bytes";
|
|
51
126
|
};
|
|
52
127
|
readonly FILE_TYPE_NOT_ALLOWED: {
|
|
53
128
|
readonly code: "FILE_TYPE_NOT_ALLOWED";
|
|
54
|
-
|
|
129
|
+
} & {
|
|
130
|
+
readonly status: 400;
|
|
131
|
+
readonly message: "File type \"{type}\" is not allowed";
|
|
55
132
|
};
|
|
56
|
-
readonly
|
|
57
|
-
readonly code: "
|
|
58
|
-
|
|
133
|
+
readonly FILE_CONTENT_MISMATCH: {
|
|
134
|
+
readonly code: "FILE_CONTENT_MISMATCH";
|
|
135
|
+
} & {
|
|
136
|
+
readonly status: 400;
|
|
137
|
+
readonly message: "File content does not match type \"{type}\"";
|
|
138
|
+
};
|
|
139
|
+
readonly CHECKSUM_REQUIRED: {
|
|
140
|
+
readonly code: "CHECKSUM_REQUIRED";
|
|
141
|
+
} & {
|
|
142
|
+
readonly status: 400;
|
|
143
|
+
readonly message: "A SHA-256 checksum is required";
|
|
144
|
+
};
|
|
145
|
+
readonly QUOTA_EXCEEDED: {
|
|
146
|
+
readonly code: "QUOTA_EXCEEDED";
|
|
147
|
+
} & {
|
|
148
|
+
readonly status: 403;
|
|
149
|
+
readonly message: "Storage quota exceeded";
|
|
150
|
+
};
|
|
151
|
+
readonly UPLOAD_TICKET_INVALID: {
|
|
152
|
+
readonly code: "UPLOAD_TICKET_INVALID";
|
|
153
|
+
} & {
|
|
154
|
+
readonly status: 403;
|
|
155
|
+
readonly message: "Upload ticket is invalid";
|
|
156
|
+
};
|
|
157
|
+
readonly UPLOAD_TICKET_EXPIRED: {
|
|
158
|
+
readonly code: "UPLOAD_TICKET_EXPIRED";
|
|
159
|
+
} & {
|
|
160
|
+
readonly status: 410;
|
|
161
|
+
readonly message: "Upload ticket has expired";
|
|
162
|
+
};
|
|
163
|
+
readonly UPLOAD_SIZE_MISMATCH: {
|
|
164
|
+
readonly code: "UPLOAD_SIZE_MISMATCH";
|
|
165
|
+
} & {
|
|
166
|
+
readonly status: 400;
|
|
167
|
+
readonly message: "Uploaded {actual} bytes; expected {expected}";
|
|
59
168
|
};
|
|
60
169
|
readonly MULTIPART_PART_MISSING: {
|
|
61
170
|
readonly code: "MULTIPART_PART_MISSING";
|
|
171
|
+
} & {
|
|
172
|
+
readonly status: 400;
|
|
62
173
|
readonly message: "Uploaded part {partNumber} was not found";
|
|
63
174
|
};
|
|
64
|
-
readonly
|
|
65
|
-
readonly code: "
|
|
66
|
-
|
|
175
|
+
readonly MULTIPART_PART_INVALID: {
|
|
176
|
+
readonly code: "MULTIPART_PART_INVALID";
|
|
177
|
+
} & {
|
|
178
|
+
readonly status: 400;
|
|
179
|
+
readonly message: "Part {partNumber} is outside 1..{partCount}";
|
|
67
180
|
};
|
|
68
|
-
readonly
|
|
69
|
-
readonly code: "
|
|
70
|
-
|
|
181
|
+
readonly OBJECT_EXISTS: {
|
|
182
|
+
readonly code: "OBJECT_EXISTS";
|
|
183
|
+
} & {
|
|
184
|
+
readonly status: 409;
|
|
185
|
+
readonly message: "An object already exists at this key";
|
|
71
186
|
};
|
|
72
|
-
readonly
|
|
73
|
-
readonly code: "
|
|
74
|
-
|
|
187
|
+
readonly FOLDER_INVALID: {
|
|
188
|
+
readonly code: "FOLDER_INVALID";
|
|
189
|
+
} & {
|
|
190
|
+
readonly status: 400;
|
|
191
|
+
readonly message: "Folder path is invalid";
|
|
192
|
+
};
|
|
193
|
+
readonly FOLDER_EXISTS: {
|
|
194
|
+
readonly code: "FOLDER_EXISTS";
|
|
195
|
+
} & {
|
|
196
|
+
readonly status: 409;
|
|
197
|
+
readonly message: "Folder already exists";
|
|
198
|
+
};
|
|
199
|
+
readonly FOLDER_NOT_EMPTY: {
|
|
200
|
+
readonly code: "FOLDER_NOT_EMPTY";
|
|
201
|
+
} & {
|
|
202
|
+
readonly status: 409;
|
|
203
|
+
readonly message: "Folder is not empty";
|
|
204
|
+
};
|
|
205
|
+
readonly TOO_MANY_FILES: {
|
|
206
|
+
readonly code: "TOO_MANY_FILES";
|
|
207
|
+
} & {
|
|
208
|
+
readonly status: 400;
|
|
209
|
+
readonly client: true;
|
|
210
|
+
readonly message: "At most {maxFiles} files can be added";
|
|
211
|
+
};
|
|
212
|
+
readonly HOOK_FAILED: {
|
|
213
|
+
readonly code: "HOOK_FAILED";
|
|
214
|
+
} & {
|
|
215
|
+
readonly status: 500;
|
|
216
|
+
readonly client: true;
|
|
217
|
+
readonly message: "The {hook} callback failed";
|
|
218
|
+
};
|
|
219
|
+
readonly NETWORK_ERROR: {
|
|
220
|
+
readonly code: "NETWORK_ERROR";
|
|
221
|
+
} & {
|
|
222
|
+
readonly status: 502;
|
|
223
|
+
readonly client: true;
|
|
224
|
+
readonly message: "Network error";
|
|
225
|
+
};
|
|
226
|
+
readonly UPLOAD_FAILED: {
|
|
227
|
+
readonly code: "UPLOAD_FAILED";
|
|
228
|
+
} & {
|
|
229
|
+
readonly status: 502;
|
|
230
|
+
readonly client: true;
|
|
231
|
+
readonly message: "Upload failed with HTTP {status}";
|
|
232
|
+
};
|
|
233
|
+
readonly DOWNLOAD_FAILED: {
|
|
234
|
+
readonly code: "DOWNLOAD_FAILED";
|
|
235
|
+
} & {
|
|
236
|
+
readonly status: 502;
|
|
237
|
+
readonly client: true;
|
|
238
|
+
readonly message: "Download failed with HTTP {status}";
|
|
239
|
+
};
|
|
240
|
+
readonly CHECKSUM_MISMATCH: {
|
|
241
|
+
readonly code: "CHECKSUM_MISMATCH";
|
|
242
|
+
} & {
|
|
243
|
+
readonly status: 400;
|
|
244
|
+
readonly client: true;
|
|
245
|
+
readonly message: "Uploaded bytes do not match the checksum";
|
|
246
|
+
};
|
|
247
|
+
readonly PARTIAL_FAILURE: {
|
|
248
|
+
readonly code: "PARTIAL_FAILURE";
|
|
249
|
+
} & {
|
|
250
|
+
readonly status: 207;
|
|
251
|
+
readonly client: true;
|
|
252
|
+
readonly message: "{failed} of {total} operations failed";
|
|
253
|
+
};
|
|
254
|
+
readonly UNKNOWN_ERROR: {
|
|
255
|
+
readonly code: "UNKNOWN_ERROR";
|
|
256
|
+
} & {
|
|
257
|
+
readonly status: 500;
|
|
258
|
+
readonly client: true;
|
|
259
|
+
readonly message: "Something went wrong";
|
|
75
260
|
};
|
|
76
261
|
};
|
|
77
262
|
export type S3ErrorCode = keyof typeof S3_ERROR_CODES;
|
|
263
|
+
/** Codes only the browser raises (`client: true`). */
|
|
264
|
+
export type S3ClientErrorCode = {
|
|
265
|
+
[K in S3ErrorCode]: (typeof S3_ERROR_CODES)[K] extends {
|
|
266
|
+
client: true;
|
|
267
|
+
} ? K : never;
|
|
268
|
+
}[S3ErrorCode];
|
|
269
|
+
/** Codes the server sends on the wire. */
|
|
270
|
+
export type S3ServerErrorCode = Exclude<S3ErrorCode, S3ClientErrorCode>;
|
|
271
|
+
/** Typed `params` for each code whose message has placeholders. */
|
|
272
|
+
export interface S3ErrorParamsMap {
|
|
273
|
+
VALIDATION_ERROR: {
|
|
274
|
+
issue: string;
|
|
275
|
+
};
|
|
276
|
+
REQUEST_TOO_LARGE: {
|
|
277
|
+
maxSize: number;
|
|
278
|
+
};
|
|
279
|
+
S3_NETWORK_ERROR: {
|
|
280
|
+
code: string;
|
|
281
|
+
};
|
|
282
|
+
UNKNOWN_ROUTE: {
|
|
283
|
+
route: string;
|
|
284
|
+
};
|
|
285
|
+
/** `proxy` is `/file` on a route whose downloads are not in proxy mode. */
|
|
286
|
+
FEATURE_DISABLED: {
|
|
287
|
+
feature: "upload" | "download" | "delete" | "multipart" | "proxy";
|
|
288
|
+
};
|
|
289
|
+
FILE_TOO_LARGE: {
|
|
290
|
+
size: number;
|
|
291
|
+
maxFileSize: number;
|
|
292
|
+
};
|
|
293
|
+
/** `allowed` is the allow-list joined with `", "`. */
|
|
294
|
+
FILE_TYPE_NOT_ALLOWED: {
|
|
295
|
+
type: string;
|
|
296
|
+
allowed: string;
|
|
297
|
+
};
|
|
298
|
+
FILE_CONTENT_MISMATCH: {
|
|
299
|
+
type: string;
|
|
300
|
+
detected: string;
|
|
301
|
+
};
|
|
302
|
+
QUOTA_EXCEEDED: {
|
|
303
|
+
limit: "bytes" | "files";
|
|
304
|
+
};
|
|
305
|
+
UPLOAD_SIZE_MISMATCH: {
|
|
306
|
+
expected: number;
|
|
307
|
+
actual: number;
|
|
308
|
+
};
|
|
309
|
+
MULTIPART_PART_MISSING: {
|
|
310
|
+
partNumber: number;
|
|
311
|
+
};
|
|
312
|
+
MULTIPART_PART_INVALID: {
|
|
313
|
+
partNumber: number;
|
|
314
|
+
partCount: number;
|
|
315
|
+
};
|
|
316
|
+
TOO_MANY_FILES: {
|
|
317
|
+
maxFiles: number;
|
|
318
|
+
};
|
|
319
|
+
HOOK_FAILED: {
|
|
320
|
+
hook: string;
|
|
321
|
+
};
|
|
322
|
+
UPLOAD_FAILED: {
|
|
323
|
+
status: number;
|
|
324
|
+
};
|
|
325
|
+
DOWNLOAD_FAILED: {
|
|
326
|
+
status: number;
|
|
327
|
+
};
|
|
328
|
+
PARTIAL_FAILURE: {
|
|
329
|
+
failed: number;
|
|
330
|
+
total: number;
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
/** `params` for `C`, or `undefined` when its message has no placeholders. */
|
|
334
|
+
export type S3ErrorParams<C extends S3ErrorCode> = C extends keyof S3ErrorParamsMap ? S3ErrorParamsMap[C] : undefined;
|
|
335
|
+
/** Wire body of every error response; also `deleteMany.failed[].error`. */
|
|
336
|
+
export type S3ErrorShape<C extends S3ErrorCode = S3ErrorCode> = {
|
|
337
|
+
code: C;
|
|
338
|
+
message: string;
|
|
339
|
+
params?: S3ErrorParams<C>;
|
|
340
|
+
};
|
|
341
|
+
/**
|
|
342
|
+
* Fill `{name}` placeholders in `template` from `params`.
|
|
343
|
+
* Placeholders without a matching param are left as they are.
|
|
344
|
+
*/
|
|
345
|
+
export declare function formatErrorMessage(template: string, params?: Record<string, string | number>): string;
|
|
78
346
|
//# sourceMappingURL=error-codes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-codes.d.ts","sourceRoot":"","sources":["../src/error-codes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"error-codes.d.ts","sourceRoot":"","sources":["../src/error-codes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,IAAI,CAAA;CAAE,CAAC;AAE9E;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,EAC3E,KAAK,EAAE,CAAC,GACP;IAAE,QAAQ,EAAE,CAAC,IAAI,MAAM,CAAC,GAAG;QAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAA;KAAE,GAAG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C;AAEF;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,GACvC,MAAM,CAKR"}
|
package/dist/error.d.ts
CHANGED
|
@@ -1,33 +1,65 @@
|
|
|
1
1
|
import { APIError as BetterCallAPIError } from "better-call/error";
|
|
2
|
-
import type
|
|
3
|
-
export { defineErrorCodes, S3_ERROR_CODES, type S3ErrorCode, } from "./error-codes";
|
|
4
|
-
type NamedStatus = ConstructorParameters<typeof BetterCallAPIError>[0]
|
|
5
|
-
|
|
6
|
-
type
|
|
2
|
+
import { type S3ErrorCode, type S3ErrorParams } from "./error-codes";
|
|
3
|
+
export { defineErrorCodes, formatErrorMessage, S3_ERROR_CODES, type S3ClientErrorCode, type S3ErrorCode, type S3ErrorEntry, type S3ErrorParams, type S3ErrorParamsMap, type S3ErrorShape, type S3ServerErrorCode, } from "./error-codes";
|
|
4
|
+
type NamedStatus = NonNullable<ConstructorParameters<typeof BetterCallAPIError>[0]>;
|
|
5
|
+
/** better-call status name (`"FORBIDDEN"`) or any numeric HTTP status. */
|
|
6
|
+
export type APIErrorStatus = NamedStatus | number;
|
|
7
|
+
/** Error body: `{ code, message, params? }` on the wire; `cause` stays local. */
|
|
8
|
+
export type APIErrorBody = {
|
|
9
|
+
code: string;
|
|
10
|
+
message: string;
|
|
7
11
|
params?: Record<string, string | number>;
|
|
8
12
|
cause?: unknown;
|
|
9
13
|
};
|
|
14
|
+
export type S3ErrorOptions = {
|
|
15
|
+
cause?: unknown;
|
|
16
|
+
/** Overrides the catalog status (e.g. `UPLOAD_FAILED` carries S3's). */
|
|
17
|
+
status?: number;
|
|
18
|
+
};
|
|
10
19
|
/**
|
|
11
20
|
* better-call `APIError` — same name and `(status, body)` constructor as
|
|
12
|
-
* `ctx.error(...)`. HTTP serializes `{ message,
|
|
13
|
-
* `toResponse`.
|
|
21
|
+
* `ctx.error(...)`. HTTP serializes `{ code, message, params? }` via native
|
|
22
|
+
* `toResponse`. Build catalog errors with {@link s3Error}.
|
|
14
23
|
*/
|
|
15
24
|
export declare class APIError extends BetterCallAPIError {
|
|
16
|
-
constructor(status
|
|
17
|
-
|
|
25
|
+
constructor(status: APIErrorStatus, body: APIErrorBody, headers?: HeadersInit);
|
|
26
|
+
/** Stable machine-readable code; always set. */
|
|
27
|
+
get code(): string;
|
|
18
28
|
get params(): Record<string, string | number> | undefined;
|
|
19
|
-
/**
|
|
20
|
-
static from(status: APIErrorStatus,
|
|
29
|
+
/** Plugin-defined or catalog codes with an explicit status. */
|
|
30
|
+
static from(status: APIErrorStatus, body: {
|
|
21
31
|
code: string;
|
|
22
32
|
message: string;
|
|
23
33
|
params?: Record<string, string | number>;
|
|
24
34
|
}): APIError;
|
|
25
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Rebuild from a wire body (e.g. `deleteMany` `failed[].error`).
|
|
37
|
+
* Status: explicit, else the catalog status, else 500.
|
|
38
|
+
*/
|
|
39
|
+
static fromShape(shape: {
|
|
40
|
+
code: string;
|
|
41
|
+
message: string;
|
|
42
|
+
params?: Record<string, string | number>;
|
|
43
|
+
}, status?: number): APIError;
|
|
26
44
|
}
|
|
27
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* Build a catalog error: status from the entry, message filled from `params`.
|
|
47
|
+
* `options.status` overrides the status; `options.cause` stays server-side.
|
|
48
|
+
*/
|
|
49
|
+
export declare function s3Error<C extends S3ErrorCode>(code: C, ...args: S3ErrorParams<C> extends undefined ? [params?: undefined, options?: S3ErrorOptions] : [params: S3ErrorParams<C>, options?: S3ErrorOptions]): APIError;
|
|
50
|
+
/**
|
|
51
|
+
* True for an {@link APIError}: an instance, or one from another copy of
|
|
52
|
+
* this package (named `APIError`, with a string `code` and a numeric
|
|
53
|
+
* `statusCode`), so `error.code` and `error.params` are really there. A
|
|
54
|
+
* raw better-call error, which keeps its code only in `body`, is not one.
|
|
55
|
+
*/
|
|
28
56
|
export declare function isAPIError(error: unknown): error is APIError;
|
|
29
|
-
/**
|
|
57
|
+
/**
|
|
58
|
+
* True when `error` is an {@link APIError} with this catalog `code`, so its
|
|
59
|
+
* `params` have that code's type.
|
|
60
|
+
*/
|
|
30
61
|
export declare function isS3ErrorCode<C extends S3ErrorCode>(error: unknown, code: C): error is APIError & {
|
|
31
62
|
code: C;
|
|
63
|
+
params: S3ErrorParams<C>;
|
|
32
64
|
};
|
|
33
65
|
//# sourceMappingURL=error.d.ts.map
|
package/dist/error.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,kBAAkB,
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,kBAAkB,EAAe,MAAM,mBAAmB,CAAC;AAChF,OAAO,EAGL,KAAK,WAAW,EAChB,KAAK,aAAa,EACnB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,iBAAiB,GACvB,MAAM,eAAe,CAAC;AAEvB,KAAK,WAAW,GAAG,WAAW,CAC5B,qBAAqB,CAAC,OAAO,kBAAkB,CAAC,CAAC,CAAC,CAAC,CACpD,CAAC;AAEF,0EAA0E;AAC1E,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,MAAM,CAAC;AAElD,iFAAiF;AACjF,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAA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EAAE,OAAO,CAAC,EAAE,cAAc,CAAC,GACvD,QAAQ,CAYV;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ,CAY5D;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,WAAW,EACjD,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,CAAC,GACN,KAAK,IAAI,QAAQ,GAAG;IAAE,IAAI,EAAE,CAAC,CAAC;IAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,CAAA;CAAE,CAE3D"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standard padded base64 of `bytes`. Uses `btoa`, so it runs in browsers,
|
|
3
|
+
* workers, and Node without `Buffer`.
|
|
4
|
+
*/
|
|
5
|
+
export declare function bytesToBase64(bytes: Uint8Array): string;
|
|
6
|
+
/**
|
|
7
|
+
* Unpadded base64url (RFC 4648 §5) of `bytes`. A string is encoded as UTF-8
|
|
8
|
+
* first. Does not need `Buffer`.
|
|
9
|
+
*/
|
|
10
|
+
export declare function base64UrlEncode(bytes: Uint8Array | string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Decode unpadded base64url back to bytes.
|
|
13
|
+
* Throws a `TypeError` when `value` is not valid base64url or is not the
|
|
14
|
+
* canonical encoding of its bytes (non-zero trailing bits), so one byte
|
|
15
|
+
* sequence has exactly one accepted string.
|
|
16
|
+
*/
|
|
17
|
+
export declare function base64UrlDecode(value: string): Uint8Array<ArrayBuffer>;
|
|
18
|
+
//# sourceMappingURL=base64url.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base64url.d.ts","sourceRoot":"","sources":["../../src/helpers/base64url.ts"],"names":[],"mappings":"AAOA;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAQvD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,GAAG,MAAM,CAMlE;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAAC,WAAW,CAAC,CAWtE"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export type ContentDispositionType = "inline" | "attachment";
|
|
2
2
|
/**
|
|
3
|
-
* Builds a RFC 6266 `Content-Disposition` value
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* `filename
|
|
3
|
+
* Builds a RFC 6266 `Content-Disposition` value: an ASCII `filename`
|
|
4
|
+
* fallback and the RFC 5987 `filename*` with the full UTF-8 name. The
|
|
5
|
+
* fallback replaces non-ASCII, `"`, `\` and `%` with `_`, since some
|
|
6
|
+
* browsers percent-decode `filename`.
|
|
7
7
|
*/
|
|
8
8
|
export declare function buildContentDisposition(fileName: string, type?: ContentDispositionType): string;
|
|
9
9
|
//# sourceMappingURL=build-content-disposition.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-content-disposition.d.ts","sourceRoot":"","sources":["../../src/helpers/build-content-disposition.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,sBAAsB,GAAG,QAAQ,GAAG,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"build-content-disposition.d.ts","sourceRoot":"","sources":["../../src/helpers/build-content-disposition.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,sBAAsB,GAAG,QAAQ,GAAG,YAAY,CAAC;AAU7D;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,MAAM,EAChB,IAAI,GAAE,sBAAqC,GAC1C,MAAM,CAGR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-object-key.d.ts","sourceRoot":"","sources":["../../src/helpers/build-object-key.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build-object-key.d.ts","sourceRoot":"","sources":["../../src/helpers/build-object-key.ts"],"names":[],"mappings":"AAEA,wBAAgB,cAAc,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAKzD"}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
/** SHA-256 digest as unpadded base64 (S3 `ChecksumSHA256`). */
|
|
2
2
|
export declare function sha256Base64(data: BufferSource): Promise<string>;
|
|
3
|
-
/**
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* SHA-256 of a `Blob` / `File` as unpadded base64, read in 1 MiB chunks so
|
|
5
|
+
* large files and multipart parts are never held in memory whole.
|
|
6
|
+
* Rejects with `signal.reason` when `signal` aborts.
|
|
7
|
+
*/
|
|
8
|
+
export declare function sha256Blob(blob: Blob, options?: {
|
|
9
|
+
signal?: AbortSignal;
|
|
10
|
+
}): Promise<string>;
|
|
5
11
|
//# sourceMappingURL=checksum.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checksum.d.ts","sourceRoot":"","sources":["../../src/helpers/checksum.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"checksum.d.ts","sourceRoot":"","sources":["../../src/helpers/checksum.ts"],"names":[],"mappings":"AAUA,+DAA+D;AAC/D,wBAAsB,YAAY,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAGtE;AAED;;;;GAIG;AACH,wBAAsB,UAAU,CAC9B,IAAI,EAAE,IAAI,EACV,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,WAAW,CAAA;CAAO,GACrC,OAAO,CAAC,MAAM,CAAC,CAUjB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Lower-cased MIME type without parameters (`""` when missing). */
|
|
2
|
+
export declare function baseType(contentType: string | undefined): string;
|
|
3
|
+
/**
|
|
4
|
+
* The type an object is served as: the stored type without parameters,
|
|
5
|
+
* lower-cased, or, when it is missing, empty, `application/octet-stream` or
|
|
6
|
+
* `binary/octet-stream`, the type its file name gives (`x.png` as
|
|
7
|
+
* `image/png`). `undefined` when neither gives a type. Inline display and
|
|
8
|
+
* `verifyContent` both use it.
|
|
9
|
+
*/
|
|
10
|
+
export declare function effectiveContentType(contentType?: string, fileName?: string): string | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* The `type` param of `FILE_TYPE_NOT_ALLOWED`: the extension (`.exe`), else
|
|
13
|
+
* the MIME type, else `unknown`. `validateFile` and the server use it, so the
|
|
14
|
+
* browser and server report a refused file the same way.
|
|
15
|
+
*/
|
|
16
|
+
export declare function describeFileType(fileName: string, contentType: string | undefined): string;
|
|
17
|
+
//# sourceMappingURL=content-type.d.ts.map
|