@dimah-s3/server 1.0.2 → 1.1.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 +7 -3
- package/dist/adapters/express.js +16 -9
- package/dist/adapters/express.js.map +1 -1
- package/dist/adapters/fastify.js +16 -9
- package/dist/adapters/fastify.js.map +1 -1
- package/dist/adapters/hono.d.ts +1 -1
- package/dist/adapters/hono.js.map +1 -1
- package/dist/adapters/node.d.ts +1 -1
- package/dist/adapters/node.js +16 -9
- package/dist/adapters/node.js.map +1 -1
- package/dist/api/index.js +742 -388
- package/dist/api/index.js.map +1 -1
- package/dist/api/router.d.ts.map +1 -1
- package/dist/api/routes/catalog.d.ts +9 -0
- package/dist/api/routes/catalog.d.ts.map +1 -0
- package/dist/api/routes/confirm.d.ts +3 -4
- package/dist/api/routes/confirm.d.ts.map +1 -1
- package/dist/api/routes/delete-batch.d.ts +14 -0
- package/dist/api/routes/delete-batch.d.ts.map +1 -0
- package/dist/api/routes/delete.d.ts +2 -2
- package/dist/api/routes/delete.d.ts.map +1 -1
- package/dist/api/routes/download.d.ts +8 -8
- package/dist/api/routes/download.d.ts.map +1 -1
- package/dist/api/routes/file.d.ts +20 -0
- package/dist/api/routes/file.d.ts.map +1 -0
- package/dist/api/routes/index.d.ts +76 -50
- package/dist/api/routes/index.d.ts.map +1 -1
- package/dist/api/routes/multipart/abort.d.ts +2 -2
- package/dist/api/routes/multipart/abort.d.ts.map +1 -1
- package/dist/api/routes/multipart/complete.d.ts +2 -2
- package/dist/api/routes/multipart/complete.d.ts.map +1 -1
- package/dist/api/routes/multipart/init.d.ts +10 -12
- package/dist/api/routes/multipart/init.d.ts.map +1 -1
- package/dist/api/routes/multipart/list-parts.d.ts +2 -2
- package/dist/api/routes/multipart/list-parts.d.ts.map +1 -1
- package/dist/api/routes/multipart/part.d.ts +4 -6
- package/dist/api/routes/multipart/part.d.ts.map +1 -1
- package/dist/api/routes/upload.d.ts +10 -14
- package/dist/api/routes/upload.d.ts.map +1 -1
- package/dist/dimah-s3.d.ts +19 -8
- package/dist/dimah-s3.d.ts.map +1 -1
- package/dist/errors.d.ts +5 -4
- package/dist/errors.d.ts.map +1 -1
- package/dist/helpers/best-effort.d.ts +6 -0
- package/dist/helpers/best-effort.d.ts.map +1 -0
- package/dist/helpers/constraints.d.ts +16 -0
- package/dist/helpers/constraints.d.ts.map +1 -0
- package/dist/helpers/expires.d.ts +2 -2
- package/dist/helpers/features.d.ts +12 -29
- package/dist/helpers/features.d.ts.map +1 -1
- package/dist/helpers/finalize-confirmed.d.ts +19 -0
- package/dist/helpers/finalize-confirmed.d.ts.map +1 -0
- package/dist/helpers/head-object.d.ts.map +1 -1
- package/dist/helpers/hooks.d.ts +7 -1
- package/dist/helpers/hooks.d.ts.map +1 -1
- package/dist/helpers/index.d.ts +12 -9
- package/dist/helpers/index.d.ts.map +1 -1
- package/dist/helpers/list-parts.d.ts +5 -0
- package/dist/helpers/list-parts.d.ts.map +1 -1
- package/dist/helpers/logger.d.ts +4 -0
- package/dist/helpers/logger.d.ts.map +1 -0
- package/dist/helpers/previous-key.d.ts +5 -0
- package/dist/helpers/previous-key.d.ts.map +1 -0
- package/dist/helpers/resolve-route.d.ts +36 -0
- package/dist/helpers/resolve-route.d.ts.map +1 -0
- package/dist/helpers/resolve-target.d.ts +25 -14
- package/dist/helpers/resolve-target.d.ts.map +1 -1
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1017 -477
- package/dist/index.js.map +1 -1
- package/dist/plugin/apply-plugins.d.ts +9 -4
- package/dist/plugin/apply-plugins.d.ts.map +1 -1
- package/dist/plugin/hook-registry.d.ts +13 -4
- package/dist/plugin/hook-registry.d.ts.map +1 -1
- package/dist/plugin/index.d.ts +1 -2
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/types.d.ts +12 -7
- package/dist/plugin/types.d.ts.map +1 -1
- package/dist/plugins.d.ts +5 -3
- package/dist/plugins.d.ts.map +1 -1
- package/dist/plugins.js +951 -475
- package/dist/plugins.js.map +1 -1
- package/dist/put.d.ts +15 -0
- package/dist/put.d.ts.map +1 -0
- package/dist/route.d.ts +13 -0
- package/dist/route.d.ts.map +1 -0
- package/dist/types/config.d.ts +190 -95
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/hook-contexts.d.ts +124 -87
- package/dist/types/hook-contexts.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -2
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +11 -11
- package/dist/api/assert-feature-enabled.d.ts +0 -5
- package/dist/api/assert-feature-enabled.d.ts.map +0 -1
- package/dist/helpers/resolve-object-acl.d.ts +0 -10
- package/dist/helpers/resolve-object-acl.d.ts.map +0 -1
- package/dist/helpers/resolve-request-acl.d.ts +0 -10
- package/dist/helpers/resolve-request-acl.d.ts.map +0 -1
package/dist/types/config.d.ts
CHANGED
|
@@ -1,97 +1,181 @@
|
|
|
1
1
|
import type { S3Client } from "@aws-sdk/client-s3";
|
|
2
2
|
import type { S3ObjectAcl, UploadPresignMethod } from "@dimah-s3/core";
|
|
3
|
-
import type { DeleteGuardContext, DeleteOnDeletedContext, DownloadOnPresignedContext,
|
|
3
|
+
import type { DeleteGuardContext, DeleteOnDeletedContext, DownloadGuardContext, DownloadOnPresignedContext, DownloadResolveInfo, GuardContext, MultipartGuardContext, MultipartOnAbortContext, MultipartOnInitContext, MultipartOnListContext, RouteGuardContext, UploadConfirmGuardContext, UploadGuardContext, UploadObjectContext, UploadObjectInfo, UploadOnConfirmedContext, UploadOnPresignedContext } from "./hook-contexts";
|
|
4
4
|
import type { DimahS3Plugin } from "../plugin/types";
|
|
5
|
-
export type {
|
|
5
|
+
export type { UploadObjectContext, UploadObjectInfo, DownloadResolveInfo };
|
|
6
|
+
/** The three nested features on a named route. */
|
|
7
|
+
export declare const ROUTE_FEATURES: readonly ["upload", "download", "delete"];
|
|
8
|
+
export type RouteFeature = (typeof ROUTE_FEATURES)[number];
|
|
6
9
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* {@link KeyPolicy.resolveKey} when you need to replace the key entirely.
|
|
10
|
+
* Endpoint operations. Multipart is nested under upload — it is not a
|
|
11
|
+
* fourth route feature.
|
|
10
12
|
*/
|
|
11
|
-
export
|
|
12
|
-
export type
|
|
13
|
+
export declare const ROUTE_OPERATIONS: readonly ["upload", "download", "delete", "multipart"];
|
|
14
|
+
export type RouteOperation = (typeof ROUTE_OPERATIONS)[number];
|
|
15
|
+
/** `true` or an options object enables the feature; omit or `false` disables it. */
|
|
16
|
+
export type FeatureToggle<T> = boolean | T;
|
|
17
|
+
/** Optional structured logger on {@link DimahS3Config}. */
|
|
18
|
+
export type DimahS3Logger = {
|
|
19
|
+
debug?: (message: string, ...args: unknown[]) => void;
|
|
20
|
+
info?: (message: string, ...args: unknown[]) => void;
|
|
21
|
+
warn?: (message: string, ...args: unknown[]) => void;
|
|
22
|
+
error?: (message: string, ...args: unknown[]) => void;
|
|
23
|
+
};
|
|
24
|
+
export type DisabledFeature = {
|
|
25
|
+
enabled: false;
|
|
26
|
+
};
|
|
27
|
+
export type EnabledFeature<T extends object> = T & {
|
|
28
|
+
enabled: true;
|
|
29
|
+
};
|
|
30
|
+
export type ResolvedFeature<T extends object> = EnabledFeature<T> | DisabledFeature;
|
|
31
|
+
/**
|
|
32
|
+
* Multipart-only hooks. Init shares `upload.guard` / `onInit`. Complete
|
|
33
|
+
* runs `guard` (`action: "complete"`) then `upload.confirmGuard` /
|
|
34
|
+
* `upload.onConfirmed`.
|
|
35
|
+
*/
|
|
36
|
+
export type MultipartConfig = {
|
|
37
|
+
/** After `CreateMultipartUpload` — persist `uploadId` for resume. */
|
|
38
|
+
onInit?: (context: MultipartOnInitContext) => Promise<void> | void;
|
|
39
|
+
/** Authorize part, list, abort, and complete. Branch on `action` if needed. */
|
|
40
|
+
guard?: (context: MultipartGuardContext) => Promise<void> | void;
|
|
41
|
+
onAbort?: (context: MultipartOnAbortContext) => Promise<void> | void;
|
|
42
|
+
onList?: (context: MultipartOnListContext) => Promise<void> | void;
|
|
43
|
+
};
|
|
44
|
+
/** Upload feature: constraints, object identity, and lifecycle hooks. */
|
|
45
|
+
export type UploadConfig = {
|
|
46
|
+
/** HTML `accept` tokens (`image/*`, `.pdf`, `application/pdf`). */
|
|
47
|
+
fileTypes?: string[];
|
|
13
48
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* …). Already-prefixed keys are left unchanged so confirm / download of the
|
|
17
|
-
* stored key still work.
|
|
49
|
+
* Max declared size, signed part size, listed multipart total, and
|
|
50
|
+
* HeadObject size in bytes.
|
|
18
51
|
*/
|
|
19
|
-
|
|
52
|
+
maxFileSize?: number;
|
|
20
53
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
54
|
+
* Server-owned object identity. Return `folder` for a directory under
|
|
55
|
+
* the route `keyPrefix`, `key` for the rest of the key (also nested
|
|
56
|
+
* under `keyPrefix`), plus optional S3 `metadata` and `acl`.
|
|
57
|
+
* Runs on upload / multipart init only. Default key is
|
|
58
|
+
* `{keyPrefix}/{uuid}/{name}` (`keyPrefix` defaults to the route name).
|
|
59
|
+
* `keyPrefix: false` generates `{uuid}/{name}` and skips the follow-up
|
|
60
|
+
* namespace check.
|
|
24
61
|
*/
|
|
25
|
-
|
|
26
|
-
};
|
|
27
|
-
export type AclPolicy = {
|
|
62
|
+
object?: (context: UploadObjectContext) => UploadObjectInfo | void | Promise<UploadObjectInfo | void>;
|
|
28
63
|
/**
|
|
29
|
-
* Server-forced ACL
|
|
30
|
-
* @default "private"
|
|
64
|
+
* Server-forced ACL when `object` does not return one.
|
|
65
|
+
* @default "private"
|
|
31
66
|
*/
|
|
32
67
|
acl?: S3ObjectAcl;
|
|
68
|
+
/** Presign verb. Use `"PUT"` on R2 (no Presigned POST). @default "POST" */
|
|
69
|
+
method?: UploadPresignMethod;
|
|
70
|
+
/** Presign TTL in seconds. Clamped by instance `maxExpiresIn`. */
|
|
71
|
+
expiresIn?: number;
|
|
33
72
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
73
|
+
* Require a SHA-256 `checksum` on the presign body and lock it into the
|
|
74
|
+
* signed PUT/POST.
|
|
36
75
|
*/
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
76
|
+
checksum?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Overwrite an existing object at the resolved key without flipping a
|
|
79
|
+
* `db()` row from `active` to `pending` during the new upload.
|
|
80
|
+
*/
|
|
81
|
+
replace?: "overwrite";
|
|
82
|
+
/** Presign and multipart init. */
|
|
83
|
+
guard?: (context: UploadGuardContext) => Promise<void> | void;
|
|
84
|
+
/** After a single-shot URL is signed. Multipart uses `multipart.onInit`. */
|
|
44
85
|
onPresigned?: (context: UploadOnPresignedContext) => Promise<void> | void;
|
|
86
|
+
/** Confirm and multipart complete. */
|
|
45
87
|
confirmGuard?: (context: UploadConfirmGuardContext) => Promise<void> | void;
|
|
88
|
+
/** After HeadObject on confirm and multipart complete. */
|
|
46
89
|
onConfirmed?: (context: UploadOnConfirmedContext) => Promise<void> | void;
|
|
90
|
+
/** Opt-in multipart. Default off. */
|
|
91
|
+
multipart?: FeatureToggle<MultipartConfig>;
|
|
47
92
|
};
|
|
48
93
|
/** Download feature. A config object (or `true`) enables the feature. */
|
|
49
|
-
export type DownloadConfig =
|
|
50
|
-
|
|
94
|
+
export type DownloadConfig = {
|
|
95
|
+
/**
|
|
96
|
+
* Presign TTL in seconds. Defaults to `S3_DEFAULT_EXPIRES_IN` (600).
|
|
97
|
+
* Independent of {@link UploadConfig.expiresIn}.
|
|
98
|
+
*/
|
|
99
|
+
expiresIn?: number;
|
|
100
|
+
/**
|
|
101
|
+
* Default Content-Disposition. @default "attachment"
|
|
102
|
+
*/
|
|
103
|
+
disposition?: "inline" | "attachment";
|
|
104
|
+
/**
|
|
105
|
+
* `"presign"` (default) returns an S3 URL. `"proxy"` returns a
|
|
106
|
+
* same-origin `/file` URL that streams through the server.
|
|
107
|
+
*/
|
|
108
|
+
mode?: "presign" | "proxy";
|
|
109
|
+
/**
|
|
110
|
+
* Per-request download options. Return values override route defaults.
|
|
111
|
+
* The client `disposition` / `fileName` query is a fallback.
|
|
112
|
+
*/
|
|
113
|
+
resolve?: (context: DownloadGuardContext) => DownloadResolveInfo | void | Promise<DownloadResolveInfo | void>;
|
|
114
|
+
guard?: (context: DownloadGuardContext) => Promise<void> | void;
|
|
51
115
|
onPresigned?: (context: DownloadOnPresignedContext) => Promise<void> | void;
|
|
52
116
|
};
|
|
53
117
|
/** Delete feature. A config object (or `true`) enables the feature. */
|
|
54
|
-
export type DeleteConfig =
|
|
118
|
+
export type DeleteConfig = {
|
|
55
119
|
guard?: (context: DeleteGuardContext) => Promise<void> | void;
|
|
56
120
|
onDeleted?: (context: DeleteOnDeletedContext) => Promise<void> | void;
|
|
57
121
|
};
|
|
58
|
-
/**
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
122
|
+
/**
|
|
123
|
+
* Named file route — a mini {@link DimahS3Config} under `routes`.
|
|
124
|
+
* Upload, download, delete, and `upload.multipart` are off until set.
|
|
125
|
+
* Prefer one feature per route; combine only when those callers share
|
|
126
|
+
* the key namespace.
|
|
127
|
+
*/
|
|
128
|
+
export type DimahS3RouteConfig = {
|
|
129
|
+
/** Override the instance S3 client for this route. */
|
|
130
|
+
client?: S3Client;
|
|
131
|
+
/** Override the instance bucket for this route. */
|
|
132
|
+
bucket?: string;
|
|
133
|
+
/**
|
|
134
|
+
* Object-key namespace. Generated keys and follow-up ops (confirm,
|
|
135
|
+
* download, delete, multipart) must stay under it.
|
|
136
|
+
* Defaults to the route name. `false` disables the bound.
|
|
137
|
+
*/
|
|
138
|
+
keyPrefix?: string | false;
|
|
139
|
+
/** Runs before every operation on this route. */
|
|
140
|
+
guard?: (context: RouteGuardContext) => Promise<void> | void;
|
|
141
|
+
/**
|
|
142
|
+
* Opt out of instance plugins by id (`{ db: false }`).
|
|
143
|
+
* Hooks from opted-out plugins are not merged onto this route.
|
|
144
|
+
*/
|
|
145
|
+
plugins?: {
|
|
146
|
+
readonly [pluginId: string]: false;
|
|
147
|
+
};
|
|
148
|
+
upload?: FeatureToggle<UploadConfig>;
|
|
149
|
+
download?: FeatureToggle<DownloadConfig>;
|
|
150
|
+
delete?: FeatureToggle<DeleteConfig>;
|
|
70
151
|
};
|
|
71
|
-
/** `true` or an options object enables the feature; omit or `false` disables it. */
|
|
72
|
-
export type FeatureToggle<T> = boolean | T;
|
|
73
152
|
/**
|
|
74
153
|
* Options for {@link dimahS3}.
|
|
75
154
|
*
|
|
76
155
|
* @example
|
|
77
156
|
* ```ts
|
|
78
|
-
* export const awsS3 = new S3Client({ ... });
|
|
79
157
|
* export const s3 = dimahS3({
|
|
80
158
|
* client: awsS3,
|
|
81
159
|
* bucket: "my-bucket",
|
|
82
|
-
*
|
|
160
|
+
* routes: {
|
|
161
|
+
* uploads: route({
|
|
162
|
+
* upload: { fileTypes: ["image/*"], multipart: true },
|
|
163
|
+
* }),
|
|
164
|
+
* },
|
|
83
165
|
* });
|
|
84
166
|
* ```
|
|
85
167
|
*/
|
|
86
168
|
export type DimahS3Config = {
|
|
87
|
-
/** AWS SDK v3 `S3Client`. Export it as `awsS3` so scripts and a custom backend can reuse it. */
|
|
88
|
-
client: S3Client;
|
|
89
169
|
/**
|
|
90
|
-
* Default
|
|
91
|
-
*
|
|
92
|
-
* `bucket`; it only wins with {@link allowClientBucket} or {@link buckets}.
|
|
170
|
+
* Default AWS SDK v3 `S3Client`. Required unless every route sets
|
|
171
|
+
* {@link DimahS3RouteConfig.client}.
|
|
93
172
|
*/
|
|
94
|
-
|
|
173
|
+
client?: S3Client;
|
|
174
|
+
/**
|
|
175
|
+
* Default bucket. Required unless every route sets
|
|
176
|
+
* {@link DimahS3RouteConfig.bucket}.
|
|
177
|
+
*/
|
|
178
|
+
bucket?: string;
|
|
95
179
|
/**
|
|
96
180
|
* API path prefix for the HTTP `handler`.
|
|
97
181
|
* Must match `createS3Client({ basePath })` on the client.
|
|
@@ -99,56 +183,67 @@ export type DimahS3Config = {
|
|
|
99
183
|
*/
|
|
100
184
|
basePath?: string;
|
|
101
185
|
/**
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
* Keep disabled unless you need ACL inference in responses/hooks —
|
|
106
|
-
* it adds one extra S3 request per upload confirmation.
|
|
107
|
-
*
|
|
108
|
-
* @default false
|
|
109
|
-
*/
|
|
110
|
-
resolveObjectAcl?: boolean;
|
|
111
|
-
/**
|
|
112
|
-
* Allow the client to pick any bucket. Off by default — the request `bucket`
|
|
113
|
-
* is ignored and {@link bucket} is used.
|
|
114
|
-
*
|
|
115
|
-
* Mutually exclusive with {@link buckets}.
|
|
116
|
-
*/
|
|
117
|
-
allowClientBucket?: boolean;
|
|
118
|
-
/**
|
|
119
|
-
* Allowlist of buckets the client may send. When set, a request bucket
|
|
120
|
-
* outside this list is rejected. {@link bucket} should be included.
|
|
121
|
-
*
|
|
122
|
-
* Mutually exclusive with {@link allowClientBucket}.
|
|
123
|
-
*/
|
|
124
|
-
buckets?: string[];
|
|
125
|
-
/**
|
|
126
|
-
* Upper bound for client `expiresIn` (seconds). Requests above this are
|
|
127
|
-
* clamped. The protocol maximum is 7 days (604800).
|
|
186
|
+
* Upper bound for `upload.expiresIn` and `download.expiresIn` (seconds).
|
|
187
|
+
* The protocol maximum is 7 days (604800).
|
|
128
188
|
* @default 604800
|
|
129
189
|
*/
|
|
130
190
|
maxExpiresIn?: number;
|
|
131
|
-
/**
|
|
191
|
+
/**
|
|
192
|
+
* Structured logs for lifecycle failures and unmatched router errors.
|
|
193
|
+
* `false` silences the default `console.error`.
|
|
194
|
+
*/
|
|
195
|
+
logger?: DimahS3Logger | false;
|
|
196
|
+
/** Called after an unexpected throw is mapped to `INTERNAL_ERROR`. */
|
|
197
|
+
onError?: (error: unknown, context: {
|
|
198
|
+
request?: Request;
|
|
199
|
+
}) => void;
|
|
200
|
+
/** Runs before every operation, before route lookup. Throw to reject. */
|
|
132
201
|
guard?: (context: GuardContext) => Promise<void> | void;
|
|
133
|
-
upload?: FeatureToggle<UploadConfig>;
|
|
134
|
-
download?: FeatureToggle<DownloadConfig>;
|
|
135
|
-
delete?: FeatureToggle<DeleteConfig>;
|
|
136
|
-
multipart?: FeatureToggle<MultipartConfig>;
|
|
137
202
|
/**
|
|
138
203
|
* Optional server plugins (e.g. `db()` from `@dimah-s3/db`).
|
|
139
|
-
* Plugin hooks merge
|
|
140
|
-
* and are flattened onto the instance (`s3[id]`).
|
|
204
|
+
* Plugin hooks merge onto each route unless the route opts out.
|
|
141
205
|
*/
|
|
142
206
|
plugins?: readonly DimahS3Plugin[];
|
|
207
|
+
/** Named file routes. At least one is required. */
|
|
208
|
+
routes: Record<string, DimahS3RouteConfig>;
|
|
143
209
|
};
|
|
144
|
-
type
|
|
145
|
-
|
|
210
|
+
type UploadFields = Omit<UploadConfig, "multipart">;
|
|
211
|
+
export type EnabledUploadConfig = EnabledFeature<UploadFields> & {
|
|
212
|
+
multipart: ResolvedFeature<MultipartConfig>;
|
|
146
213
|
};
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
214
|
+
export type ResolvedUploadConfig = EnabledUploadConfig | (DisabledFeature & {
|
|
215
|
+
multipart: DisabledFeature;
|
|
216
|
+
});
|
|
217
|
+
/** One named route after {@link dimahS3} normalizes toggles and plugin hooks. */
|
|
218
|
+
export type ResolvedRoute = {
|
|
219
|
+
name: string;
|
|
220
|
+
client: S3Client;
|
|
221
|
+
bucket: string;
|
|
222
|
+
/** `false` means follow-up keys are not namespace-checked. */
|
|
223
|
+
keyPrefix: string | false;
|
|
224
|
+
guard?: DimahS3RouteConfig["guard"];
|
|
225
|
+
skippedPluginIds: ReadonlySet<string>;
|
|
226
|
+
upload: ResolvedUploadConfig;
|
|
227
|
+
download: ResolvedFeature<DownloadConfig>;
|
|
228
|
+
delete: ResolvedFeature<DeleteConfig>;
|
|
229
|
+
};
|
|
230
|
+
/**
|
|
231
|
+
* A {@link ResolvedRoute} after the named operation has been asserted on.
|
|
232
|
+
* `route.upload.fileTypes` is typed as present only after opening `"upload"`.
|
|
233
|
+
*/
|
|
234
|
+
export type OpenedRoute<F extends RouteOperation> = F extends "multipart" ? ResolvedRoute & {
|
|
235
|
+
upload: EnabledUploadConfig & {
|
|
236
|
+
multipart: EnabledFeature<MultipartConfig>;
|
|
237
|
+
};
|
|
238
|
+
} : F extends "upload" ? ResolvedRoute & {
|
|
239
|
+
upload: EnabledUploadConfig;
|
|
240
|
+
} : F extends "download" ? ResolvedRoute & {
|
|
241
|
+
download: EnabledFeature<DownloadConfig>;
|
|
242
|
+
} : F extends "delete" ? ResolvedRoute & {
|
|
243
|
+
delete: EnabledFeature<DeleteConfig>;
|
|
244
|
+
} : never;
|
|
245
|
+
/** Instance config after {@link dimahS3} normalizes routes and plugins. */
|
|
246
|
+
export type ResolvedDimahS3Config = Omit<DimahS3Config, "routes" | "plugins"> & {
|
|
247
|
+
routes: Record<string, ResolvedRoute>;
|
|
153
248
|
};
|
|
154
249
|
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,KAAK,EACV,kBAAkB,EAClB,sBAAsB,EACtB,0BAA0B,EAC1B,
|
|
1
|
+
{"version":3,"file":"config.d.ts","s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