@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
|
@@ -1,59 +1,117 @@
|
|
|
1
1
|
import type { MultipartCompletedPartRef, MultipartPartInfo, S3ObjectAcl } from "@dimah-s3/core";
|
|
2
|
-
/** Context for the
|
|
2
|
+
/** Context for the instance `guard` hook. */
|
|
3
3
|
export type GuardContext = {
|
|
4
4
|
/** The incoming HTTP request. */
|
|
5
5
|
request: Request;
|
|
6
6
|
};
|
|
7
|
-
|
|
7
|
+
/** Context for a route-level `guard` (every operation on that route). */
|
|
8
|
+
export type RouteGuardContext = GuardContext & {
|
|
9
|
+
/** Named file route. */
|
|
10
|
+
route: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Shared hook context once an object key is assigned — generated on
|
|
14
|
+
* upload / multipart init, or supplied on confirm / download / delete /
|
|
15
|
+
* multipart session ops.
|
|
16
|
+
*/
|
|
17
|
+
export type StoredObjectContext = RouteGuardContext & {
|
|
8
18
|
/** S3 object key. */
|
|
9
19
|
key: string;
|
|
10
20
|
/** Target bucket. */
|
|
11
21
|
bucket: string;
|
|
12
22
|
};
|
|
23
|
+
/** Declared file on upload / multipart init. */
|
|
24
|
+
export type ObjectFile = {
|
|
25
|
+
name: string;
|
|
26
|
+
size?: number;
|
|
27
|
+
type?: string;
|
|
28
|
+
};
|
|
13
29
|
/**
|
|
14
|
-
* Input to `
|
|
15
|
-
*
|
|
16
|
-
*
|
|
30
|
+
* Input to `upload.object` on presign / multipart init.
|
|
31
|
+
* `clientMetadata` is what the client sent — it is not written to S3
|
|
32
|
+
* unless `object` copies it into {@link UploadObjectInfo.metadata}.
|
|
17
33
|
*/
|
|
18
|
-
export type
|
|
34
|
+
export type UploadObjectContext = {
|
|
19
35
|
request: Request;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
fileName?: string;
|
|
23
|
-
contentType?: string;
|
|
36
|
+
route: string;
|
|
37
|
+
file: ObjectFile;
|
|
24
38
|
bucket: string;
|
|
39
|
+
/**
|
|
40
|
+
* Namespace this route writes under. `false` skips the follow-up
|
|
41
|
+
* namespace check and generates `{uuid}/{name}` when `object` omits
|
|
42
|
+
* `folder` / `key`.
|
|
43
|
+
*/
|
|
44
|
+
keyPrefix: string | false;
|
|
45
|
+
clientMetadata?: Record<string, string>;
|
|
25
46
|
};
|
|
26
|
-
/**
|
|
27
|
-
export type
|
|
28
|
-
/**
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
47
|
+
/** Server-owned S3 object identity from `upload.object`. */
|
|
48
|
+
export type UploadObjectInfo = {
|
|
49
|
+
/**
|
|
50
|
+
* Extra folder under the route {@link UploadObjectContext.keyPrefix}.
|
|
51
|
+
* Nested as `{keyPrefix}/{folder}/{uuid}/{name}` unless `keyPrefix` is
|
|
52
|
+
* `false` (`{folder}/{uuid}/{name}`). Ignored when {@link key} is set.
|
|
53
|
+
*/
|
|
54
|
+
folder?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Object key, nested under {@link UploadObjectContext.keyPrefix} unless
|
|
57
|
+
* the key is already inside that prefix or `keyPrefix` is `false`.
|
|
58
|
+
* If omitted, `{keyPrefix}/{folder}/{uuid}/{name}` is used
|
|
59
|
+
* (`{uuid}/{name}` when `keyPrefix` is `false` and `folder` is omitted).
|
|
60
|
+
*/
|
|
61
|
+
key?: string;
|
|
62
|
+
/** S3 user metadata (`x-amz-meta-*`). */
|
|
33
63
|
metadata?: Record<string, string>;
|
|
34
|
-
/**
|
|
64
|
+
/** Override the route ACL for this object. */
|
|
35
65
|
acl?: S3ObjectAcl;
|
|
36
|
-
/**
|
|
37
|
-
|
|
66
|
+
/**
|
|
67
|
+
* After confirm succeeds, delete this key (must stay under the route
|
|
68
|
+
* `keyPrefix`). Use with a new generated key to rotate avatars.
|
|
69
|
+
*/
|
|
70
|
+
previousKey?: string;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Context for `upload.guard`.
|
|
74
|
+
* Runs on single-shot presign and multipart init **after** `upload.object`
|
|
75
|
+
* so `key` is already assigned (plugins like `db()` check ownership here).
|
|
76
|
+
* Client-declared values are not verified by S3.
|
|
77
|
+
*/
|
|
78
|
+
export type UploadGuardContext = StoredObjectContext & {
|
|
79
|
+
/** Declared file from the presign body — same shape as `upload.object`. */
|
|
80
|
+
file: ObjectFile;
|
|
81
|
+
/** S3 object metadata from route `object`. */
|
|
82
|
+
metadata?: Record<string, string>;
|
|
83
|
+
/** Client extras from the request — not written to S3 automatically. */
|
|
84
|
+
clientMetadata?: Record<string, string>;
|
|
85
|
+
/** Resolved ACL. */
|
|
86
|
+
acl?: S3ObjectAcl;
|
|
87
|
+
/** Route `upload.replace`. */
|
|
88
|
+
replace?: "overwrite";
|
|
38
89
|
};
|
|
39
|
-
/** Context for `upload.onPresigned
|
|
40
|
-
export type UploadOnPresignedContext =
|
|
90
|
+
/** Context for `upload.onPresigned` (single-shot only). */
|
|
91
|
+
export type UploadOnPresignedContext = UploadGuardContext & {
|
|
41
92
|
/** Presigned upload URL. */
|
|
42
93
|
url: string;
|
|
43
94
|
/** Validity in seconds. */
|
|
44
95
|
expiresIn: number;
|
|
45
96
|
};
|
|
46
|
-
/**
|
|
47
|
-
|
|
97
|
+
/**
|
|
98
|
+
* Context for `upload.confirmGuard`.
|
|
99
|
+
* Runs on single-shot confirm and multipart complete.
|
|
100
|
+
*/
|
|
101
|
+
export type UploadConfirmGuardContext = StoredObjectContext & {
|
|
102
|
+
/** Present on multipart complete. */
|
|
103
|
+
uploadId?: string;
|
|
104
|
+
/** Parts to assemble. Present on multipart complete. */
|
|
105
|
+
parts?: MultipartCompletedPartRef[];
|
|
106
|
+
/** Route `upload.replace`. */
|
|
107
|
+
replace?: "overwrite";
|
|
108
|
+
};
|
|
48
109
|
/**
|
|
49
110
|
* Context for `upload.onConfirmed`.
|
|
50
111
|
* `contentLength` and `eTag` are verified by S3 via HeadObject.
|
|
112
|
+
* Runs after single-shot confirm and multipart complete.
|
|
51
113
|
*/
|
|
52
|
-
export type UploadOnConfirmedContext =
|
|
53
|
-
/** S3 object key. */
|
|
54
|
-
key: string;
|
|
55
|
-
/** Target bucket. */
|
|
56
|
-
bucket: string;
|
|
114
|
+
export type UploadOnConfirmedContext = StoredObjectContext & {
|
|
57
115
|
/** MIME type from HeadObject. */
|
|
58
116
|
contentType?: string;
|
|
59
117
|
/** Size from HeadObject — trust this, not the presign `fileSize`. */
|
|
@@ -62,7 +120,7 @@ export type UploadOnConfirmedContext = GuardContext & {
|
|
|
62
120
|
eTag?: string;
|
|
63
121
|
/** Object metadata. */
|
|
64
122
|
metadata?: Record<string, string>;
|
|
65
|
-
/**
|
|
123
|
+
/** ACL from the upload policy (`upload.acl` / `object`). */
|
|
66
124
|
acl?: S3ObjectAcl;
|
|
67
125
|
/** Stored filename. */
|
|
68
126
|
fileName?: string;
|
|
@@ -70,87 +128,66 @@ export type UploadOnConfirmedContext = GuardContext & {
|
|
|
70
128
|
versionId?: string;
|
|
71
129
|
/** Last modified timestamp. */
|
|
72
130
|
lastModified?: string;
|
|
131
|
+
/** Present after multipart complete. */
|
|
132
|
+
uploadId?: string;
|
|
73
133
|
};
|
|
74
134
|
/** Context for `download.guard`. */
|
|
75
|
-
export type
|
|
135
|
+
export type DownloadGuardContext = StoredObjectContext & {
|
|
76
136
|
/** Download filename for Content-Disposition. */
|
|
77
137
|
fileName?: string;
|
|
138
|
+
/** Client-requested or route default disposition. */
|
|
139
|
+
disposition?: "inline" | "attachment";
|
|
140
|
+
};
|
|
141
|
+
/** Per-request overrides from `download.resolve`. */
|
|
142
|
+
export type DownloadResolveInfo = {
|
|
143
|
+
disposition?: "inline" | "attachment";
|
|
144
|
+
expiresIn?: number;
|
|
145
|
+
fileName?: string;
|
|
78
146
|
};
|
|
79
147
|
/** Context for `download.onPresigned`. */
|
|
80
|
-
export type DownloadOnPresignedContext =
|
|
148
|
+
export type DownloadOnPresignedContext = DownloadGuardContext & {
|
|
81
149
|
/** Presigned GET URL. */
|
|
82
150
|
url: string;
|
|
83
151
|
/** Validity in seconds. */
|
|
84
152
|
expiresIn: number;
|
|
85
153
|
};
|
|
86
154
|
/** Context for `delete.guard`. */
|
|
87
|
-
export type DeleteGuardContext =
|
|
155
|
+
export type DeleteGuardContext = StoredObjectContext;
|
|
88
156
|
/** Context for `delete.onDeleted`. */
|
|
89
|
-
export type DeleteOnDeletedContext =
|
|
157
|
+
export type DeleteOnDeletedContext = StoredObjectContext;
|
|
90
158
|
/** Shared base for multipart operations that already have an upload id. */
|
|
91
|
-
export type MultipartUploadContext =
|
|
159
|
+
export type MultipartUploadContext = StoredObjectContext & {
|
|
92
160
|
/** Multipart upload ID. */
|
|
93
161
|
uploadId: string;
|
|
94
162
|
};
|
|
95
|
-
/** Context for `multipart.
|
|
96
|
-
export type
|
|
97
|
-
/**
|
|
98
|
-
|
|
99
|
-
/** MIME type the client sent — not verified until `onComplete`. */
|
|
100
|
-
contentType?: string;
|
|
101
|
-
/** Custom object metadata. */
|
|
102
|
-
metadata?: Record<string, string>;
|
|
103
|
-
/** Resolved ACL that will be applied at init. */
|
|
104
|
-
acl?: S3ObjectAcl;
|
|
105
|
-
/** Original filename for `Content-Disposition`. */
|
|
106
|
-
fileName?: string;
|
|
163
|
+
/** Context for `upload.multipart.onInit`. */
|
|
164
|
+
export type MultipartOnInitContext = UploadGuardContext & {
|
|
165
|
+
/** Multipart upload ID. */
|
|
166
|
+
uploadId: string;
|
|
107
167
|
};
|
|
108
|
-
/**
|
|
109
|
-
|
|
168
|
+
/**
|
|
169
|
+
* Context for `upload.multipart.guard`.
|
|
170
|
+
* Runs on part, list, abort, and complete (init uses `upload.guard`).
|
|
171
|
+
* Complete also runs `upload.confirmGuard`.
|
|
172
|
+
*/
|
|
173
|
+
export type MultipartGuardContext = (MultipartUploadContext & {
|
|
174
|
+
action: "part";
|
|
110
175
|
/** 1-based part number. */
|
|
111
176
|
partNumber: number;
|
|
112
177
|
/** Byte size locked into the presigned URL signature. */
|
|
113
|
-
partSize
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
/** Context for `multipart.listGuard`. */
|
|
123
|
-
export type MultipartListGuardContext = MultipartUploadContext;
|
|
124
|
-
/** Context for `multipart.onInit`. */
|
|
125
|
-
export type MultipartOnInitContext = MultipartInitGuardContext & {
|
|
126
|
-
/** Multipart upload ID. */
|
|
127
|
-
uploadId: string;
|
|
128
|
-
};
|
|
129
|
-
/** Context for `multipart.onComplete`. */
|
|
130
|
-
export type MultipartOnCompleteContext = MultipartUploadContext & {
|
|
131
|
-
/** Verified size in bytes. */
|
|
132
|
-
contentLength: number;
|
|
133
|
-
/** MIME type from HeadObject. */
|
|
134
|
-
contentType?: string;
|
|
135
|
-
/** ETag from HeadObject. */
|
|
136
|
-
eTag?: string;
|
|
137
|
-
/** Object metadata. */
|
|
138
|
-
metadata: Record<string, string>;
|
|
139
|
-
/** Resolved ACL. Omitted when ACL lookup is disabled or unsupported. */
|
|
140
|
-
acl?: S3ObjectAcl;
|
|
141
|
-
/** Stored filename. */
|
|
142
|
-
fileName?: string;
|
|
143
|
-
/** S3 version ID. */
|
|
144
|
-
versionId?: string;
|
|
145
|
-
/** Last modified timestamp. */
|
|
146
|
-
lastModified?: string;
|
|
147
|
-
};
|
|
148
|
-
/** Context for `multipart.onAbort`. */
|
|
178
|
+
partSize: number;
|
|
179
|
+
}) | (MultipartUploadContext & {
|
|
180
|
+
action: "list";
|
|
181
|
+
}) | (MultipartUploadContext & {
|
|
182
|
+
action: "abort";
|
|
183
|
+
}) | (MultipartUploadContext & {
|
|
184
|
+
action: "complete";
|
|
185
|
+
});
|
|
186
|
+
/** Context for `upload.multipart.onAbort`. */
|
|
149
187
|
export type MultipartOnAbortContext = MultipartUploadContext;
|
|
150
|
-
/** Context for `multipart.onList`. */
|
|
188
|
+
/** Context for `upload.multipart.onList`. */
|
|
151
189
|
export type MultipartOnListContext = MultipartUploadContext & {
|
|
152
190
|
/** Parts already uploaded to S3. */
|
|
153
191
|
parts: MultipartPartInfo[];
|
|
154
192
|
};
|
|
155
|
-
export {};
|
|
156
193
|
//# sourceMappingURL=hook-contexts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hook-contexts.d.ts","sourceRoot":"","sources":["../../src/types/hook-contexts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,iBAAiB,EACjB,WAAW,EACZ,MAAM,gBAAgB,CAAC;AAExB,
|
|
1
|
+
{"version":3,"file":"hook-contexts.d.ts","sourceRoot":"","sources":["../../src/types/hook-contexts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,iBAAiB,EACjB,WAAW,EACZ,MAAM,gBAAgB,CAAC;AAExB,6CAA6C;AAC7C,MAAM,MAAM,YAAY,GAAG;IACzB,iCAAiC;IACjC,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,yEAAyE;AACzE,MAAM,MAAM,iBAAiB,GAAG,YAAY,GAAG;IAC7C,wBAAwB;IACxB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;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AA6C;AAC7C,MAAM,MAAM,sBAAsB,GAAG,sBAAsB,GAAG;IAC5D,oCAAoC;IACpC,KAAK,EAAE,iBAAiB,EAAE,CAAC;CAC5B,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export type {
|
|
2
|
-
export type {
|
|
1
|
+
export type { DeleteGuardContext, DeleteOnDeletedContext, DownloadGuardContext, DownloadOnPresignedContext, GuardContext, MultipartOnAbortContext, MultipartOnInitContext, MultipartOnListContext, MultipartGuardContext, MultipartUploadContext, ObjectFile, RouteGuardContext, StoredObjectContext, UploadConfirmGuardContext, UploadGuardContext, UploadObjectContext, UploadObjectInfo, UploadOnConfirmedContext, UploadOnPresignedContext, DownloadResolveInfo, } from "./hook-contexts";
|
|
2
|
+
export type { DeleteConfig, DimahS3Config, DimahS3Logger, DimahS3RouteConfig, DisabledFeature, DownloadConfig, EnabledFeature, EnabledUploadConfig, FeatureToggle, MultipartConfig, OpenedRoute, ResolvedDimahS3Config, ResolvedFeature, ResolvedRoute, ResolvedUploadConfig, RouteFeature, RouteOperation, UploadConfig, } from "./config";
|
|
3
|
+
export { ROUTE_FEATURES, ROUTE_OPERATIONS } from "./config";
|
|
3
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,kBAAkB,EAClB,sBAAsB,EACtB,oBAAoB,EACpB,0BAA0B,EAC1B,YAAY,EACZ,uBAAuB,EACvB,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB,sBAAsB,EACtB,UAAU,EACV,iBAAiB,EACjB,mBAAmB,EACnB,yBAAyB,EACzB,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,wBAAwB,EACxB,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,YAAY,EACZ,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,aAAa,EACb,eAAe,EACf,WAAW,EACX,qBAAqB,EACrB,eAAe,EACf,aAAa,EACb,oBAAoB,EACpB,YAAY,EACZ,cAAc,EACd,YAAY,GACb,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dimah-s3/server",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Presigned S3 server — dimahS3() with HTTP handler and direct api for upload, download, delete, and multipart",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"s3",
|
|
@@ -78,25 +78,25 @@
|
|
|
78
78
|
"dist"
|
|
79
79
|
],
|
|
80
80
|
"dependencies": {
|
|
81
|
-
"@aws-sdk/s3-presigned-post": "^3.
|
|
82
|
-
"@aws-sdk/s3-request-presigner": "^3.
|
|
81
|
+
"@aws-sdk/s3-presigned-post": "^3.1121.0",
|
|
82
|
+
"@aws-sdk/s3-request-presigner": "^3.1121.0",
|
|
83
|
+
"@dimah-s3/core": "1.1.0",
|
|
83
84
|
"better-call": "1.4.0",
|
|
84
|
-
"zod": "^4.4
|
|
85
|
-
"@dimah-s3/core": "1.0.2"
|
|
85
|
+
"zod": "^4.5.4"
|
|
86
86
|
},
|
|
87
87
|
"peerDependencies": {
|
|
88
88
|
"@aws-sdk/client-s3": ">=3"
|
|
89
89
|
},
|
|
90
90
|
"devDependencies": {
|
|
91
|
-
"@aws-sdk/client-s3": "^3.
|
|
92
|
-
"@types/node": "^26.
|
|
93
|
-
"eslint": "
|
|
91
|
+
"@aws-sdk/client-s3": "^3.1121.0",
|
|
92
|
+
"@types/node": "^26.4.0",
|
|
93
|
+
"@workspace/eslint-config": "0.0.1",
|
|
94
|
+
"@workspace/typescript-config": "0.0.1",
|
|
95
|
+
"eslint": "^10.9.1",
|
|
94
96
|
"tsc-alias": "^1.9.2",
|
|
95
97
|
"tsup": "^8.5.1",
|
|
96
98
|
"typescript": "7.0.2",
|
|
97
|
-
"vitest": "^4.1.11"
|
|
98
|
-
"@workspace/eslint-config": "0.0.1",
|
|
99
|
-
"@workspace/typescript-config": "0.0.1"
|
|
99
|
+
"vitest": "^4.1.11"
|
|
100
100
|
},
|
|
101
101
|
"publishConfig": {
|
|
102
102
|
"access": "public"
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { ResolvedDimahS3Config } from "../types";
|
|
2
|
-
export type FeatureFlag = "upload" | "download" | "delete" | "multipart";
|
|
3
|
-
/** Disabled features respond 404 (`FEATURE_DISABLED`) from both HTTP and `s3.api`. */
|
|
4
|
-
export declare function assertFeatureEnabled(config: ResolvedDimahS3Config, feature: FeatureFlag): void;
|
|
5
|
-
//# sourceMappingURL=assert-feature-enabled.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"assert-feature-enabled.d.ts","sourceRoot":"","sources":["../../src/api/assert-feature-enabled.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAErD,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,UAAU,GAAG,QAAQ,GAAG,WAAW,CAAC;AAEzE,sFAAsF;AACtF,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,qBAAqB,EAC7B,OAAO,EAAE,WAAW,GACnB,IAAI,CAIN"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type S3Client } from "@aws-sdk/client-s3";
|
|
2
|
-
/**
|
|
3
|
-
* Determines the ACL of an S3 object by querying `GetObjectAcl`.
|
|
4
|
-
*
|
|
5
|
-
* Returns `"public-read"` when the `AllUsers` grantee has `READ` or
|
|
6
|
-
* `FULL_CONTROL` permission, `"private"` when ACL is resolvable but not public,
|
|
7
|
-
* and `undefined` when ACL cannot be resolved (e.g. unsupported providers).
|
|
8
|
-
*/
|
|
9
|
-
export declare function resolveObjectAcl(s3: S3Client, bucket: string, key: string, timeoutMs?: number): Promise<"public-read" | "private" | undefined>;
|
|
10
|
-
//# sourceMappingURL=resolve-object-acl.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-object-acl.d.ts","sourceRoot":"","sources":["../../src/helpers/resolve-object-acl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAIxE;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CACpC,EAAE,EAAE,QAAQ,EACZ,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,SAAS,GAAE,MAAsC,GAChD,OAAO,CAAC,aAAa,GAAG,SAAS,GAAG,SAAS,CAAC,CAoBhD"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { S3ObjectAcl } from "@dimah-s3/core";
|
|
2
|
-
import type { AclPolicy } from "../types/config";
|
|
3
|
-
export type { AclPolicy };
|
|
4
|
-
/**
|
|
5
|
-
* Resolve object ACL. Default is `private`. A server `acl` is forced.
|
|
6
|
-
* Client `acl` is used only when `allowClientAcl` is set and no server ACL
|
|
7
|
-
* is configured.
|
|
8
|
-
*/
|
|
9
|
-
export declare function resolveRequestAcl(policy: AclPolicy | undefined, requested?: S3ObjectAcl): S3ObjectAcl;
|
|
10
|
-
//# sourceMappingURL=resolve-request-acl.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-request-acl.d.ts","sourceRoot":"","sources":["../../src/helpers/resolve-request-acl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,YAAY,EAAE,SAAS,EAAE,CAAC;AAE1B;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,SAAS,GAAG,SAAS,EAC7B,SAAS,CAAC,EAAE,WAAW,GACtB,WAAW,CAIb"}
|