@dimah-s3/server 1.0.2 → 1.1.1

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.
Files changed (100) hide show
  1. package/README.md +7 -3
  2. package/dist/adapters/express.js +16 -9
  3. package/dist/adapters/express.js.map +1 -1
  4. package/dist/adapters/fastify.js +16 -9
  5. package/dist/adapters/fastify.js.map +1 -1
  6. package/dist/adapters/hono.d.ts +1 -1
  7. package/dist/adapters/hono.js.map +1 -1
  8. package/dist/adapters/node.d.ts +1 -1
  9. package/dist/adapters/node.js +16 -9
  10. package/dist/adapters/node.js.map +1 -1
  11. package/dist/api/index.js +742 -388
  12. package/dist/api/index.js.map +1 -1
  13. package/dist/api/router.d.ts.map +1 -1
  14. package/dist/api/routes/catalog.d.ts +9 -0
  15. package/dist/api/routes/catalog.d.ts.map +1 -0
  16. package/dist/api/routes/confirm.d.ts +3 -4
  17. package/dist/api/routes/confirm.d.ts.map +1 -1
  18. package/dist/api/routes/delete-batch.d.ts +14 -0
  19. package/dist/api/routes/delete-batch.d.ts.map +1 -0
  20. package/dist/api/routes/delete.d.ts +2 -2
  21. package/dist/api/routes/delete.d.ts.map +1 -1
  22. package/dist/api/routes/download.d.ts +8 -8
  23. package/dist/api/routes/download.d.ts.map +1 -1
  24. package/dist/api/routes/file.d.ts +20 -0
  25. package/dist/api/routes/file.d.ts.map +1 -0
  26. package/dist/api/routes/index.d.ts +76 -50
  27. package/dist/api/routes/index.d.ts.map +1 -1
  28. package/dist/api/routes/multipart/abort.d.ts +2 -2
  29. package/dist/api/routes/multipart/abort.d.ts.map +1 -1
  30. package/dist/api/routes/multipart/complete.d.ts +2 -2
  31. package/dist/api/routes/multipart/complete.d.ts.map +1 -1
  32. package/dist/api/routes/multipart/init.d.ts +10 -12
  33. package/dist/api/routes/multipart/init.d.ts.map +1 -1
  34. package/dist/api/routes/multipart/list-parts.d.ts +2 -2
  35. package/dist/api/routes/multipart/list-parts.d.ts.map +1 -1
  36. package/dist/api/routes/multipart/part.d.ts +4 -6
  37. package/dist/api/routes/multipart/part.d.ts.map +1 -1
  38. package/dist/api/routes/upload.d.ts +10 -14
  39. package/dist/api/routes/upload.d.ts.map +1 -1
  40. package/dist/dimah-s3.d.ts +19 -8
  41. package/dist/dimah-s3.d.ts.map +1 -1
  42. package/dist/errors.d.ts +5 -4
  43. package/dist/errors.d.ts.map +1 -1
  44. package/dist/helpers/best-effort.d.ts +6 -0
  45. package/dist/helpers/best-effort.d.ts.map +1 -0
  46. package/dist/helpers/constraints.d.ts +16 -0
  47. package/dist/helpers/constraints.d.ts.map +1 -0
  48. package/dist/helpers/expires.d.ts +2 -2
  49. package/dist/helpers/features.d.ts +12 -29
  50. package/dist/helpers/features.d.ts.map +1 -1
  51. package/dist/helpers/finalize-confirmed.d.ts +19 -0
  52. package/dist/helpers/finalize-confirmed.d.ts.map +1 -0
  53. package/dist/helpers/head-object.d.ts.map +1 -1
  54. package/dist/helpers/hooks.d.ts +7 -1
  55. package/dist/helpers/hooks.d.ts.map +1 -1
  56. package/dist/helpers/index.d.ts +12 -9
  57. package/dist/helpers/index.d.ts.map +1 -1
  58. package/dist/helpers/list-parts.d.ts +5 -0
  59. package/dist/helpers/list-parts.d.ts.map +1 -1
  60. package/dist/helpers/logger.d.ts +4 -0
  61. package/dist/helpers/logger.d.ts.map +1 -0
  62. package/dist/helpers/previous-key.d.ts +5 -0
  63. package/dist/helpers/previous-key.d.ts.map +1 -0
  64. package/dist/helpers/resolve-route.d.ts +36 -0
  65. package/dist/helpers/resolve-route.d.ts.map +1 -0
  66. package/dist/helpers/resolve-target.d.ts +25 -14
  67. package/dist/helpers/resolve-target.d.ts.map +1 -1
  68. package/dist/index.d.ts +7 -2
  69. package/dist/index.d.ts.map +1 -1
  70. package/dist/index.js +1017 -477
  71. package/dist/index.js.map +1 -1
  72. package/dist/plugin/apply-plugins.d.ts +9 -4
  73. package/dist/plugin/apply-plugins.d.ts.map +1 -1
  74. package/dist/plugin/hook-registry.d.ts +13 -4
  75. package/dist/plugin/hook-registry.d.ts.map +1 -1
  76. package/dist/plugin/index.d.ts +1 -2
  77. package/dist/plugin/index.d.ts.map +1 -1
  78. package/dist/plugin/types.d.ts +12 -7
  79. package/dist/plugin/types.d.ts.map +1 -1
  80. package/dist/plugins.d.ts +5 -3
  81. package/dist/plugins.d.ts.map +1 -1
  82. package/dist/plugins.js +951 -475
  83. package/dist/plugins.js.map +1 -1
  84. package/dist/put.d.ts +15 -0
  85. package/dist/put.d.ts.map +1 -0
  86. package/dist/route.d.ts +13 -0
  87. package/dist/route.d.ts.map +1 -0
  88. package/dist/types/config.d.ts +190 -95
  89. package/dist/types/config.d.ts.map +1 -1
  90. package/dist/types/hook-contexts.d.ts +124 -87
  91. package/dist/types/hook-contexts.d.ts.map +1 -1
  92. package/dist/types/index.d.ts +3 -2
  93. package/dist/types/index.d.ts.map +1 -1
  94. package/package.json +11 -11
  95. package/dist/api/assert-feature-enabled.d.ts +0 -5
  96. package/dist/api/assert-feature-enabled.d.ts.map +0 -1
  97. package/dist/helpers/resolve-object-acl.d.ts +0 -10
  98. package/dist/helpers/resolve-object-acl.d.ts.map +0 -1
  99. package/dist/helpers/resolve-request-acl.d.ts +0 -10
  100. 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 global `guard` hook. */
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
- type ObjectContext = GuardContext & {
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 `prefix` (string or factory) and `resolveKey` on a feature config.
15
- * Prefer a `prefix` factory for per-user / per-tenant folders so already-
16
- * prefixed stored keys stay idempotent.
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 ResolveKeyContext = {
34
+ export type UploadObjectContext = {
19
35
  request: Request;
20
- /** Key the client sent. */
21
- proposedKey: string;
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
- /** Context for `upload.guard`. Client-declared values are not verified by S3. */
27
- export type UploadPresignGuardContext = ObjectContext & {
28
- /** MIME type the client sent — not verified until `onConfirmed`. */
29
- contentType?: string;
30
- /** Size the client sent — not verified until `onConfirmed`. */
31
- fileSize?: number;
32
- /** Custom object metadata. */
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
- /** Requested ACL. */
64
+ /** Override the route ACL for this object. */
35
65
  acl?: S3ObjectAcl;
36
- /** Original filename for `Content-Disposition`. */
37
- fileName?: string;
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 = UploadPresignGuardContext & {
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
- /** Context for `upload.confirmGuard`. */
47
- export type UploadConfirmGuardContext = ObjectContext;
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 = GuardContext & {
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
- /** Resolved ACL. Omitted when ACL lookup is disabled or unsupported. */
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 DownloadPresignGuardContext = ObjectContext & {
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 = DownloadPresignGuardContext & {
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 = ObjectContext;
155
+ export type DeleteGuardContext = StoredObjectContext;
88
156
  /** Context for `delete.onDeleted`. */
89
- export type DeleteOnDeletedContext = ObjectContext;
157
+ export type DeleteOnDeletedContext = StoredObjectContext;
90
158
  /** Shared base for multipart operations that already have an upload id. */
91
- export type MultipartUploadContext = ObjectContext & {
159
+ export type MultipartUploadContext = StoredObjectContext & {
92
160
  /** Multipart upload ID. */
93
161
  uploadId: string;
94
162
  };
95
- /** Context for `multipart.initGuard`. */
96
- export type MultipartInitGuardContext = ObjectContext & {
97
- /** Declared byte size of the file — available during init only. */
98
- fileSize?: number;
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
- /** Context for `multipart.partGuard`. */
109
- export type MultipartPartGuardContext = MultipartUploadContext & {
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?: number;
114
- };
115
- /** Context for `multipart.completeGuard`. */
116
- export type MultipartCompleteGuardContext = MultipartUploadContext & {
117
- /** Parts to assemble. */
118
- parts: MultipartCompletedPartRef[];
119
- };
120
- /** Context for `multipart.abortGuard`. */
121
- export type MultipartAbortGuardContext = MultipartUploadContext;
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,2CAA2C;AAC3C,MAAM,MAAM,YAAY,GAAG;IACzB,iCAAiC;IACjC,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,KAAK,aAAa,GAAG,YAAY,GAAG;IAClC,qBAAqB;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,qBAAqB;IACrB,MAAM,EAAE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IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,GAC7C,CAAC,sBAAsB,GAAG;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,CAAC,GAC9C,CAAC,sBAAsB,GAAG;IAAE,MAAM,EAAE,UAAU,CAAA;CAAE,CAAC,CAAC;AAEtD,8CAA8C;AAC9C,MAAM,MAAM,uBAAuB,GAAG,sBAAsB,CAAC;AAE7D,6CAA6C;AAC7C,MAAM,MAAM,sBAAsB,GAAG,sBAAsB,GAAG;IAC5D,oCAAoC;IACpC,KAAK,EAAE,iBAAiB,EAAE,CAAC;CAC5B,CAAC"}
@@ -1,3 +1,4 @@
1
- export type { GuardContext, ResolveKeyContext, UploadPresignGuardContext, UploadOnPresignedContext, UploadConfirmGuardContext, UploadOnConfirmedContext, DownloadPresignGuardContext, DownloadOnPresignedContext, DeleteGuardContext, DeleteOnDeletedContext, MultipartUploadContext, MultipartInitGuardContext, MultipartPartGuardContext, MultipartCompleteGuardContext, MultipartAbortGuardContext, MultipartListGuardContext, MultipartOnInitContext, MultipartOnCompleteContext, MultipartOnAbortContext, MultipartOnListContext, } from "./hook-contexts";
2
- export type { AclPolicy, DimahS3Config, DownloadConfig, DeleteConfig, FeatureToggle, KeyPolicy, KeyPrefix, MultipartConfig, ResolvedDimahS3Config, UploadConfig, } from "./config";
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,YAAY,EACZ,iBAAiB,EACjB,yBAAyB,EACzB,wBAAwB,EACxB,yBAAyB,EACzB,wBAAwB,EACxB,2BAA2B,EAC3B,0BAA0B,EAC1B,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,yBAAyB,EACzB,yBAAyB,EACzB,6BAA6B,EAC7B,0BAA0B,EAC1B,yBAAyB,EACzB,sBAAsB,EACtB,0BAA0B,EAC1B,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,SAAS,EACT,aAAa,EACb,cAAc,EACd,YAAY,EACZ,aAAa,EACb,SAAS,EACT,SAAS,EACT,eAAe,EACf,qBAAqB,EACrB,YAAY,GACb,MAAM,UAAU,CAAC"}
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.2",
3
+ "version": "1.1.1",
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.1116.0",
82
- "@aws-sdk/s3-request-presigner": "^3.1116.0",
81
+ "@aws-sdk/s3-presigned-post": "^3.1121.0",
82
+ "@aws-sdk/s3-request-presigner": "^3.1121.0",
83
+ "@dimah-s3/core": "1.1.1",
83
84
  "better-call": "1.4.0",
84
- "zod": "^4.4.3",
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.1116.0",
92
- "@types/node": "^26.2.0",
93
- "eslint": "^10.9.0",
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"}