@dimah-s3/server 1.7.1 → 2.0.0-beta.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 (187) hide show
  1. package/README.md +72 -16
  2. package/dist/adapters/express.d.ts +7 -7
  3. package/dist/adapters/express.d.ts.map +1 -1
  4. package/dist/adapters/express.js +94 -94
  5. package/dist/adapters/express.js.map +1 -1
  6. package/dist/adapters/fastify.d.ts +11 -5
  7. package/dist/adapters/fastify.d.ts.map +1 -1
  8. package/dist/adapters/fastify.js +94 -94
  9. package/dist/adapters/fastify.js.map +1 -1
  10. package/dist/adapters/node.d.ts +20 -3
  11. package/dist/adapters/node.d.ts.map +1 -1
  12. package/dist/adapters/node.js +92 -92
  13. package/dist/adapters/node.js.map +1 -1
  14. package/dist/api/context.d.ts +8 -4
  15. package/dist/api/context.d.ts.map +1 -1
  16. package/dist/api/{routes/index.d.ts → core-endpoints.d.ts} +43 -68
  17. package/dist/api/core-endpoints.d.ts.map +1 -0
  18. package/dist/api/create-s3-endpoint.d.ts +70 -48
  19. package/dist/api/create-s3-endpoint.d.ts.map +1 -1
  20. package/dist/api/create-s3-middleware.d.ts +19 -16
  21. package/dist/api/create-s3-middleware.d.ts.map +1 -1
  22. package/dist/api/router-context.d.ts +23 -0
  23. package/dist/api/router-context.d.ts.map +1 -0
  24. package/dist/api/router.d.ts +15 -5
  25. package/dist/api/router.d.ts.map +1 -1
  26. package/dist/config/feature-toggle.d.ts +16 -0
  27. package/dist/config/feature-toggle.d.ts.map +1 -0
  28. package/dist/config/resolve-config.d.ts +9 -0
  29. package/dist/config/resolve-config.d.ts.map +1 -0
  30. package/dist/config/resolve-routes.d.ts +37 -0
  31. package/dist/config/resolve-routes.d.ts.map +1 -0
  32. package/dist/dimah-s3.d.ts +22 -32
  33. package/dist/dimah-s3.d.ts.map +1 -1
  34. package/dist/helpers/authorize-download.d.ts +25 -0
  35. package/dist/helpers/authorize-download.d.ts.map +1 -0
  36. package/dist/helpers/aws-errors.d.ts +16 -0
  37. package/dist/helpers/aws-errors.d.ts.map +1 -0
  38. package/dist/helpers/best-effort.d.ts +22 -3
  39. package/dist/helpers/best-effort.d.ts.map +1 -1
  40. package/dist/helpers/checksum-config.d.ts +13 -0
  41. package/dist/helpers/checksum-config.d.ts.map +1 -0
  42. package/dist/helpers/constraints.d.ts +17 -12
  43. package/dist/helpers/constraints.d.ts.map +1 -1
  44. package/dist/helpers/error-boundary.d.ts +28 -0
  45. package/dist/helpers/error-boundary.d.ts.map +1 -0
  46. package/dist/helpers/finalize-confirmed.d.ts +42 -13
  47. package/dist/helpers/finalize-confirmed.d.ts.map +1 -1
  48. package/dist/helpers/head-object.d.ts +6 -9
  49. package/dist/helpers/head-object.d.ts.map +1 -1
  50. package/dist/helpers/hooks.d.ts +29 -15
  51. package/dist/helpers/hooks.d.ts.map +1 -1
  52. package/dist/helpers/inline-types.d.ts +24 -7
  53. package/dist/helpers/inline-types.d.ts.map +1 -1
  54. package/dist/helpers/list-parts.d.ts +4 -6
  55. package/dist/helpers/list-parts.d.ts.map +1 -1
  56. package/dist/helpers/metadata-encoding.d.ts +15 -0
  57. package/dist/helpers/metadata-encoding.d.ts.map +1 -0
  58. package/dist/helpers/object-meta.d.ts +39 -0
  59. package/dist/helpers/object-meta.d.ts.map +1 -0
  60. package/dist/helpers/object-s3.d.ts +5 -2
  61. package/dist/helpers/object-s3.d.ts.map +1 -1
  62. package/dist/helpers/open-target.d.ts +89 -0
  63. package/dist/helpers/open-target.d.ts.map +1 -0
  64. package/dist/helpers/part-layout.d.ts +19 -0
  65. package/dist/helpers/part-layout.d.ts.map +1 -0
  66. package/dist/helpers/presign.d.ts +54 -0
  67. package/dist/helpers/presign.d.ts.map +1 -0
  68. package/dist/helpers/request.d.ts +6 -11
  69. package/dist/helpers/request.d.ts.map +1 -1
  70. package/dist/helpers/resolve-target.d.ts +28 -20
  71. package/dist/helpers/resolve-target.d.ts.map +1 -1
  72. package/dist/helpers/sniff-object.d.ts +22 -0
  73. package/dist/helpers/sniff-object.d.ts.map +1 -0
  74. package/dist/helpers/ticket.d.ts +75 -0
  75. package/dist/helpers/ticket.d.ts.map +1 -0
  76. package/dist/index.d.ts +4 -12
  77. package/dist/index.d.ts.map +1 -1
  78. package/dist/index.js +2647 -1579
  79. package/dist/index.js.map +1 -1
  80. package/dist/operations/catalog.d.ts +16 -0
  81. package/dist/operations/catalog.d.ts.map +1 -0
  82. package/dist/operations/confirm.d.ts +19 -0
  83. package/dist/operations/confirm.d.ts.map +1 -0
  84. package/dist/operations/delete-many.d.ts +18 -0
  85. package/dist/operations/delete-many.d.ts.map +1 -0
  86. package/dist/operations/delete.d.ts +14 -0
  87. package/dist/operations/delete.d.ts.map +1 -0
  88. package/dist/operations/download.d.ts +20 -0
  89. package/dist/operations/download.d.ts.map +1 -0
  90. package/dist/operations/file.d.ts +38 -0
  91. package/dist/operations/file.d.ts.map +1 -0
  92. package/dist/operations/multipart/abort.d.ts +20 -0
  93. package/dist/operations/multipart/abort.d.ts.map +1 -0
  94. package/dist/operations/multipart/complete.d.ts +21 -0
  95. package/dist/operations/multipart/complete.d.ts.map +1 -0
  96. package/dist/operations/multipart/init.d.ts +19 -0
  97. package/dist/operations/multipart/init.d.ts.map +1 -0
  98. package/dist/operations/multipart/list-parts.d.ts +11 -0
  99. package/dist/operations/multipart/list-parts.d.ts.map +1 -0
  100. package/dist/operations/multipart/open-multipart.d.ts +25 -0
  101. package/dist/operations/multipart/open-multipart.d.ts.map +1 -0
  102. package/dist/operations/multipart/sign-part.d.ts +20 -0
  103. package/dist/operations/multipart/sign-part.d.ts.map +1 -0
  104. package/dist/operations/put.d.ts +18 -0
  105. package/dist/operations/put.d.ts.map +1 -0
  106. package/dist/operations/run-operation.d.ts +18 -0
  107. package/dist/operations/run-operation.d.ts.map +1 -0
  108. package/dist/operations/s3-api.d.ts +12 -0
  109. package/dist/operations/s3-api.d.ts.map +1 -0
  110. package/dist/operations/upload.d.ts +19 -0
  111. package/dist/operations/upload.d.ts.map +1 -0
  112. package/dist/plugin/apply-plugins.d.ts +9 -11
  113. package/dist/plugin/apply-plugins.d.ts.map +1 -1
  114. package/dist/plugin/chain-hooks.d.ts +12 -9
  115. package/dist/plugin/chain-hooks.d.ts.map +1 -1
  116. package/dist/plugin/define-plugin.d.ts +11 -4
  117. package/dist/plugin/define-plugin.d.ts.map +1 -1
  118. package/dist/plugin/index.d.ts +1 -2
  119. package/dist/plugin/index.d.ts.map +1 -1
  120. package/dist/plugin/types.d.ts +52 -56
  121. package/dist/plugin/types.d.ts.map +1 -1
  122. package/dist/plugins.d.ts +10 -8
  123. package/dist/plugins.d.ts.map +1 -1
  124. package/dist/plugins.js +325 -1627
  125. package/dist/plugins.js.map +1 -1
  126. package/dist/route.d.ts +0 -1
  127. package/dist/route.d.ts.map +1 -1
  128. package/dist/types/config.d.ts +171 -172
  129. package/dist/types/config.d.ts.map +1 -1
  130. package/dist/types/hook-contexts.d.ts +139 -147
  131. package/dist/types/hook-contexts.d.ts.map +1 -1
  132. package/dist/types/index.d.ts +3 -3
  133. package/dist/types/index.d.ts.map +1 -1
  134. package/dist/types/locals.d.ts +37 -0
  135. package/dist/types/locals.d.ts.map +1 -0
  136. package/dist/types/resolved.d.ts +118 -0
  137. package/dist/types/resolved.d.ts.map +1 -0
  138. package/package.json +8 -12
  139. package/dist/api/bind-endpoints.d.ts +0 -12
  140. package/dist/api/bind-endpoints.d.ts.map +0 -1
  141. package/dist/api/index.d.ts +0 -6
  142. package/dist/api/index.d.ts.map +0 -1
  143. package/dist/api/index.js +0 -1353
  144. package/dist/api/index.js.map +0 -1
  145. package/dist/api/routes/catalog.d.ts +0 -9
  146. package/dist/api/routes/catalog.d.ts.map +0 -1
  147. package/dist/api/routes/confirm.d.ts +0 -13
  148. package/dist/api/routes/confirm.d.ts.map +0 -1
  149. package/dist/api/routes/delete-batch.d.ts +0 -14
  150. package/dist/api/routes/delete-batch.d.ts.map +0 -1
  151. package/dist/api/routes/delete.d.ts +0 -26
  152. package/dist/api/routes/delete.d.ts.map +0 -1
  153. package/dist/api/routes/download.d.ts +0 -21
  154. package/dist/api/routes/download.d.ts.map +0 -1
  155. package/dist/api/routes/file.d.ts +0 -20
  156. package/dist/api/routes/file.d.ts.map +0 -1
  157. package/dist/api/routes/index.d.ts.map +0 -1
  158. package/dist/api/routes/multipart/abort.d.ts +0 -16
  159. package/dist/api/routes/multipart/abort.d.ts.map +0 -1
  160. package/dist/api/routes/multipart/complete.d.ts +0 -22
  161. package/dist/api/routes/multipart/complete.d.ts.map +0 -1
  162. package/dist/api/routes/multipart/init.d.ts +0 -22
  163. package/dist/api/routes/multipart/init.d.ts.map +0 -1
  164. package/dist/api/routes/multipart/list-parts.d.ts +0 -17
  165. package/dist/api/routes/multipart/list-parts.d.ts.map +0 -1
  166. package/dist/api/routes/multipart/part.d.ts +0 -20
  167. package/dist/api/routes/multipart/part.d.ts.map +0 -1
  168. package/dist/api/routes/upload.d.ts +0 -22
  169. package/dist/api/routes/upload.d.ts.map +0 -1
  170. package/dist/errors.d.ts +0 -23
  171. package/dist/errors.d.ts.map +0 -1
  172. package/dist/helpers/expires.d.ts +0 -21
  173. package/dist/helpers/expires.d.ts.map +0 -1
  174. package/dist/helpers/features.d.ts +0 -17
  175. package/dist/helpers/features.d.ts.map +0 -1
  176. package/dist/helpers/index.d.ts +0 -19
  177. package/dist/helpers/index.d.ts.map +0 -1
  178. package/dist/helpers/is-aws-not-found.d.ts +0 -5
  179. package/dist/helpers/is-aws-not-found.d.ts.map +0 -1
  180. package/dist/helpers/previous-key.d.ts +0 -5
  181. package/dist/helpers/previous-key.d.ts.map +0 -1
  182. package/dist/helpers/resolve-route.d.ts +0 -33
  183. package/dist/helpers/resolve-route.d.ts.map +0 -1
  184. package/dist/plugin/hook-registry.d.ts +0 -21
  185. package/dist/plugin/hook-registry.d.ts.map +0 -1
  186. package/dist/put.d.ts +0 -15
  187. package/dist/put.d.ts.map +0 -1
@@ -1,34 +1,24 @@
1
1
  import { S3_ERROR_CODES, type ConfirmedObjectResponse } from "@dimah-s3/core";
2
- import { type PutObjectInput } from "./put";
3
- import { type DimahS3Plugin, type PluginContextMap, type PluginEndpointMap } from "./plugin";
4
- import { type CoreEndpoints } from "./api/routes";
5
- import type { DimahS3Config, DimahS3RouteConfig } from "./types";
6
- export type MultipartAliasApi = {
7
- init: CoreEndpoints["multipartInit"];
8
- signPart: CoreEndpoints["multipartPart"];
9
- listParts: CoreEndpoints["multipartListParts"];
10
- complete: CoreEndpoints["multipartComplete"];
11
- abort: CoreEndpoints["multipartAbort"];
12
- };
13
- export type DimahS3Api<P extends readonly DimahS3Plugin[] = []> = CoreEndpoints & {
14
- multipart: MultipartAliasApi;
15
- deleteMany: CoreEndpoints["deleteBatch"];
16
- } & PluginEndpointMap<P>;
17
- export type DimahS3<P extends readonly DimahS3Plugin[] = [], C extends Record<string, unknown> = PluginContextMap<P>, R extends Record<string, DimahS3RouteConfig> = Record<string, DimahS3RouteConfig>> = {
2
+ import { type DimahS3Plugin, type PluginContextMap } from "./plugin/index.js";
3
+ import type { DimahS3Api, DimahS3Config, DimahS3RouteConfig, PutInput, S3ServerCallOptions } from "./types/config.js";
4
+ /** A dimah-s3 server instance, returned by {@link dimahS3}. */
5
+ export type DimahS3<P extends readonly DimahS3Plugin[] = [], C = PluginContextMap<P>, R extends Record<string, DimahS3RouteConfig> = Record<string, DimahS3RouteConfig>> = {
18
6
  /** Framework-agnostic HTTP handler (`Request` → `Response`). */
19
7
  handler: (request: Request) => Promise<Response>;
20
8
  /**
21
- * better-call endpoints — invoke as functions from Server Actions / RSC.
9
+ * The browser client's API, run in process. Pass `request` or `headers`
10
+ * for the hooks, and trusted `locals` to seed the guards.
22
11
  *
23
12
  * ```ts
24
- * await s3.api.download({ query: { route, key }, headers: await headers() });
25
- * await s3.api.multipart.init({ body: { route, fileName, fileSize } });
13
+ * await s3.api.download({ route: "invoices", key }, { headers: await headers() });
26
14
  * ```
27
15
  */
28
- api: DimahS3Api<P>;
16
+ api: DimahS3Api;
17
+ /** Uploads from the server through the route's upload policy. */
18
+ put: (input: PutInput, options?: S3ServerCallOptions) => Promise<ConfirmedObjectResponse>;
29
19
  /** Plugin contexts keyed by plugin id. */
30
20
  context: C;
31
- /** Lookup a registered plugin by id. */
21
+ /** Looks up a registered plugin by id. */
32
22
  getPlugin: {
33
23
  <Id extends P[number]["id"]>(id: Id): Extract<P[number], {
34
24
  id: Id;
@@ -36,25 +26,25 @@ export type DimahS3<P extends readonly DimahS3Plugin[] = [], C extends Record<st
36
26
  (id: string): DimahS3Plugin | undefined;
37
27
  };
38
28
  $ERROR_CODES: typeof S3_ERROR_CODES;
29
+ /** Type-only helpers: `typeof s3.$Infer.routes`. */
39
30
  $Infer: {
40
- api: DimahS3Api<P>;
31
+ api: DimahS3Api;
41
32
  context: C;
42
33
  routes: keyof R & string;
43
34
  };
44
- /**
45
- * Server-side upload through the same route policy as presign + confirm.
46
- */
47
- put: (input: PutObjectInput) => Promise<ConfirmedObjectResponse>;
48
35
  } & C;
49
36
  /**
50
- * Create a dimah-s3 server instance.
37
+ * Creates a dimah-s3 server instance.
38
+ *
39
+ * The config is checked here, so a mistake throws at startup. The ticket
40
+ * secret is the exception: without a `secret` option, `DIMAH_S3_SECRET` is
41
+ * read on the first upload.
51
42
  *
52
- * Plugin contexts are available on `s3.context[id]` and flattened onto the
53
- * instance itself (`s3.db` when the `db` plugin is registered, etc.).
43
+ * Plugin contexts are on `s3.context[id]` and on the instance itself
44
+ * (`s3.db` when the `db` plugin is registered).
54
45
  *
55
46
  * @example
56
47
  * ```ts
57
- * export const awsS3 = new S3Client({ ... });
58
48
  * export const s3 = dimahS3({
59
49
  * client: awsS3,
60
50
  * bucket: "my-bucket",
@@ -64,9 +54,9 @@ export type DimahS3<P extends readonly DimahS3Plugin[] = [], C extends Record<st
64
54
  * },
65
55
  * });
66
56
  *
67
- * export const { GET, POST, PUT, PATCH, DELETE } = toNextJsHandler(s3);
57
+ * export const { GET, POST, PATCH, DELETE } = toNextJsHandler(s3);
68
58
  *
69
- * await s3.api.download({ query: { route: "invoices", key }, headers: await headers() });
59
+ * await s3.api.download({ route: "invoices", key }, { headers: await headers() });
70
60
  * ```
71
61
  */
72
62
  export declare function dimahS3<const P extends readonly DimahS3Plugin[] = [], const R extends Record<string, DimahS3RouteConfig> = Record<string, DimahS3RouteConfig>>(config: DimahS3Config & {
@@ -1 +1 @@
1
- {"version":3,"file":"dimah-s3.d.ts","sourceRoot":"","sources":["../src/dimah-s3.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EAAa,KAAK,cAAc,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACvB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAiB,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAEjE,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAEjE,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;IACrC,QAAQ,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;IACzC,SAAS,EAAE,aAAa,CAAC,oBAAoB,CAAC,CAAC;IAC/C,QAAQ,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAAC;IAC7C,KAAK,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,SAAS,aAAa,EAAE,GAAG,EAAE,IAC5D,aAAa,GAAG;IACd,SAAS,EAAE,iBAAiB,CAAC;IAC7B,UAAU,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC;CAC1C,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAC;AAE3B,MAAM,MAAM,OAAO,CACjB,CAAC,SAAS,SAAS,aAAa,EAAE,GAAG,EAAE,EACvC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,EACvD,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,GAAG,MAAM,CACnD,MAAM,EACN,kBAAkB,CACnB,IACC;IACF,gEAAgE;IAChE,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IACjD;;;;;;;OAOG;IACH,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IACnB,0CAA0C;IAC1C,OAAO,EAAE,CAAC,CAAC;IACX,wCAAwC;IACxC,SAAS,EAAE;QACT,CAAC,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,EACzB,EAAE,EAAE,EAAE,GACL,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE;YAAE,EAAE,EAAE,EAAE,CAAA;SAAE,CAAC,GAAG,SAAS,CAAC;QAC9C,CAAC,EAAE,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAAC;KACzC,CAAC;IACF,YAAY,EAAE,OAAO,cAAc,CAAC;IACpC,MAAM,EAAE;QACN,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;QACnB,OAAO,EAAE,CAAC,CAAC;QACX,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC;KAC1B,CAAC;IACF;;OAEG;IACH,GAAG,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,OAAO,CAAC,uBAAuB,CAAC,CAAC;CAClE,GAAG,CAAC,CAAC;AAEN;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,OAAO,CACrB,KAAK,CAAC,CAAC,SAAS,SAAS,aAAa,EAAE,GAAG,EAAE,EAC7C,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,GAAG,MAAM,CACzD,MAAM,EACN,kBAAkB,CACnB,EAED,MAAM,EAAE,aAAa,GAAG;IAAE,OAAO,CAAC,EAAE,CAAC,CAAC;IAAC,MAAM,EAAE,CAAC,CAAA;CAAE,GACjD,OAAO,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAkCpC"}
1
+ {"version":3,"file":"dimah-s3.d.ts","sourceRoot":"","sources":["../src/dimah-s3.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAM9E,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACtB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EACV,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,QAAQ,EACR,mBAAmB,EACpB,MAAM,gBAAgB,CAAC;AAExB,+DAA+D;AAC/D,MAAM,MAAM,OAAO,CACjB,CAAC,SAAS,SAAS,aAAa,EAAE,GAAG,EAAE,EACvC,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,EACvB,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,GAAG,MAAM,CACnD,MAAM,EACN,kBAAkB,CACnB,IACC;IACF,gEAAgE;IAChE,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IACjD;;;;;;;OAOG;IACH,GAAG,EAAE,UAAU,CAAC;IAChB,iEAAiE;IACjE,GAAG,EAAE,CACH,KAAK,EAAE,QAAQ,EACf,OAAO,CAAC,EAAE,mBAAmB,KAC1B,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACtC,0CAA0C;IAC1C,OAAO,EAAE,CAAC,CAAC;IACX,0CAA0C;IAC1C,SAAS,EAAE;QACT,CAAC,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,EACzB,EAAE,EAAE,EAAE,GACL,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE;YAAE,EAAE,EAAE,EAAE,CAAA;SAAE,CAAC,GAAG,SAAS,CAAC;QAC9C,CAAC,EAAE,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAAC;KACzC,CAAC;IACF,YAAY,EAAE,OAAO,cAAc,CAAC;IACpC,oDAAoD;IACpD,MAAM,EAAE;QACN,GAAG,EAAE,UAAU,CAAC;QAChB,OAAO,EAAE,CAAC,CAAC;QACX,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC;KAC1B,CAAC;CACH,GAAG,CAAC,CAAC;AAEN;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,OAAO,CACrB,KAAK,CAAC,CAAC,SAAS,SAAS,aAAa,EAAE,GAAG,EAAE,EAC7C,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,GAAG,MAAM,CACzD,MAAM,EACN,kBAAkB,CACnB,EAED,MAAM,EAAE,aAAa,GAAG;IAAE,OAAO,CAAC,EAAE,CAAC,CAAC;IAAC,MAAM,EAAE,CAAC,CAAA;CAAE,GACjD,OAAO,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAqBpC"}
@@ -0,0 +1,25 @@
1
+ import type { ContentDispositionType } from "@dimah-s3/core";
2
+ import type { DownloadGuardContext, DownloadResolveInfo, ObjectContext } from "../types/hook-contexts.js";
3
+ import type { OpenedRoute, ResolvedConfig } from "../types/resolved.js";
4
+ /** What the client asked for: the download query or the `/file` query. */
5
+ export type DownloadRequest = {
6
+ mode: "presign" | "proxy";
7
+ name?: string;
8
+ disposition?: ContentDispositionType;
9
+ /** Presign mode only. */
10
+ expiresIn?: number;
11
+ };
12
+ export type AuthorizedDownload = {
13
+ /** The values that will be used, as `download.guard` saw them. */
14
+ context: DownloadGuardContext;
15
+ /** What `download.resolve` returned. */
16
+ resolved?: DownloadResolveInfo;
17
+ };
18
+ /**
19
+ * The download steps that presign and `/file` share, after the route
20
+ * guard: `download.resolve` can replace the name, the disposition and the
21
+ * TTL, and `download.guard` then runs with the values that will be used.
22
+ * In proxy mode the contexts have no `expiresIn`.
23
+ */
24
+ export declare function authorizeDownload(config: Pick<ResolvedConfig, "maxExpiresIn">, route: OpenedRoute<"download">, context: ObjectContext, request: DownloadRequest): Promise<AuthorizedDownload>;
25
+ //# sourceMappingURL=authorize-download.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorize-download.d.ts","sourceRoot":"","sources":["../../src/helpers/authorize-download.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAG7D,OAAO,KAAK,EACV,oBAAoB,EACpB,mBAAmB,EACnB,aAAa,EACd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEpE,0EAA0E;AAC1E,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,sBAAsB,CAAC;IACrC,yBAAyB;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,kEAAkE;IAClE,OAAO,EAAE,oBAAoB,CAAC;IAC9B,wCAAwC;IACxC,QAAQ,CAAC,EAAE,mBAAmB,CAAC;CAChC,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,IAAI,CAAC,cAAc,EAAE,cAAc,CAAC,EAC5C,KAAK,EAAE,WAAW,CAAC,UAAU,CAAC,EAC9B,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,kBAAkB,CAAC,CA+B7B"}
@@ -0,0 +1,16 @@
1
+ /** The HTTP status S3 answered a failed call with, when there was one. */
2
+ export declare function awsStatus(error: unknown): number | undefined;
3
+ /**
4
+ * The object, or the multipart upload, does not exist. A missing bucket is
5
+ * a 404 too, but it is a config error, so it does not count.
6
+ */
7
+ export declare function isAwsNotFound(error: unknown): boolean;
8
+ /** An `If-Match` or `If-Unmodified-Since` condition failed. */
9
+ export declare function isAwsPreconditionFailed(error: unknown): boolean;
10
+ /** The provider does not implement the request, such as a conditional delete. */
11
+ export declare function isAwsNotImplemented(error: unknown): boolean;
12
+ /** The requested byte range is outside the object. */
13
+ export declare function isAwsRangeNotSatisfiable(error: unknown): boolean;
14
+ /** Runs an S3 call and turns a not-found error into `OBJECT_NOT_FOUND`. */
15
+ export declare function sendOrObjectNotFound<T>(send: () => Promise<T>): Promise<T>;
16
+ //# sourceMappingURL=aws-errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aws-errors.d.ts","sourceRoot":"","sources":["../../src/helpers/aws-errors.ts"],"names":[],"mappings":"AAqCA,0EAA0E;AAC1E,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAG5D;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAGrD;AAED,+DAA+D;AAC/D,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAE/D;AAED,iFAAiF;AACjF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAE3D;AAED,sDAAsD;AACtD,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEhE;AAED,2EAA2E;AAC3E,wBAAsB,oBAAoB,CAAC,CAAC,EAC1C,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACrB,OAAO,CAAC,CAAC,CAAC,CASZ"}
@@ -1,6 +1,25 @@
1
1
  import { type S3Client } from "@aws-sdk/client-s3";
2
- /** Best-effort DeleteObject after a failed constraint check. */
3
- export declare function deleteObjectBestEffort(client: S3Client, bucket: string, key: string): Promise<void>;
4
- /** Best-effort AbortMultipartUpload before assembly or after a failed complete. */
2
+ /** The object to delete, and the ETag it must still have. */
3
+ export type ConditionalDeleteInput = {
4
+ bucket: string;
5
+ key: string;
6
+ /** ETag from the HeadObject that identified the object. */
7
+ eTag?: string;
8
+ };
9
+ /**
10
+ * DeleteObject that keeps a newer object at the same key. With an `eTag`,
11
+ * the delete is conditional (`If-Match`): when the key now holds another
12
+ * object (`412`), nothing is deleted and it returns `false`. A provider
13
+ * without conditional DeleteObject (`501`) gets a plain delete. Any other
14
+ * failure is thrown.
15
+ */
16
+ export declare function deleteObjectIfMatch(client: S3Client, input: ConditionalDeleteInput): Promise<boolean>;
17
+ /**
18
+ * {@link deleteObjectIfMatch} after a failed check, ignoring every failure:
19
+ * the caller is already returning an error, and an object left behind is
20
+ * caught by purge or a bucket lifecycle rule.
21
+ */
22
+ export declare function deleteObjectBestEffort(client: S3Client, bucket: string, key: string, eTag?: string): Promise<void>;
23
+ /** Best-effort AbortMultipartUpload, when init fails after CreateMultipartUpload. */
5
24
  export declare function abortMultipartBestEffort(client: S3Client, bucket: string, key: string, uploadId: string): Promise<void>;
6
25
  //# sourceMappingURL=best-effort.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"best-effort.d.ts","sourceRoot":"","sources":["../../src/helpers/best-effort.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,QAAQ,EACd,MAAM,oBAAoB,CAAC;AAE5B,gEAAgE;AAChE,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,QAAQ,EAChB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,IAAI,CAAC,CAMf;AAED,mFAAmF;AACnF,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,QAAQ,EAChB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC,CAYf"}
1
+ {"version":3,"file":"best-effort.d.ts","sourceRoot":"","sources":["../../src/helpers/best-effort.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,QAAQ,EACd,MAAM,oBAAoB,CAAC;AAG5B,6DAA6D;AAC7D,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,2DAA2D;IAC3D,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,QAAQ,EAChB,KAAK,EAAE,sBAAsB,GAC5B,OAAO,CAAC,OAAO,CAAC,CAgBlB;AAED;;;;GAIG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,QAAQ,EAChB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC,CAMf;AAED,qFAAqF;AACrF,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,QAAQ,EAChB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC,CAYf"}
@@ -0,0 +1,13 @@
1
+ import type { S3Client } from "@aws-sdk/client-s3";
2
+ /**
3
+ * Checks once per client that the AWS SDK does not add flexible checksums
4
+ * to presigned requests. With `requestChecksumCalculation: "WHEN_SUPPORTED"`
5
+ * (the SDK default since 3.729) a presigned URL signs a checksum of an empty
6
+ * body, and every upload to it fails at S3.
7
+ *
8
+ * The first failing call throws a {@link ConfigError}, which the error
9
+ * boundary logs. Later calls with the same client fail with
10
+ * `INTERNAL_ERROR` without logging again. An SDK without the option passes.
11
+ */
12
+ export declare function assertChecksumConfig(client: S3Client): Promise<void>;
13
+ //# sourceMappingURL=checksum-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checksum-config.d.ts","sourceRoot":"","sources":["../../src/helpers/checksum-config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAQnD;;;;;;;;;GASG;AACH,wBAAsB,oBAAoB,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAa1E"}
@@ -1,16 +1,21 @@
1
- import type { UploadConfig } from "../types/index.js";
1
+ import type { UploadFile } from "../types/hook-contexts.js";
2
+ import type { ResolvedUpload } from "../types/resolved.js";
2
3
  /** File limits from `upload` (`fileTypes` / `maxFileSize`). */
3
- export type FileConstraints = Pick<UploadConfig, "fileTypes" | "maxFileSize">;
4
- /** Reject when `size` is over the route cap. No-op when `maxFileSize` is unset. */
4
+ export type FileConstraints = Pick<ResolvedUpload, "fileTypes" | "maxFileSize">;
5
+ /** Fails with `FILE_TOO_LARGE` when `size` is over `maxFileSize`, if one is set. */
5
6
  export declare function assertWithinMaxFileSize(maxFileSize: number | undefined, size: number): void;
6
- export declare function assertDeclaredConstraints(constraints: FileConstraints | undefined, input: {
7
- fileName: string;
8
- fileSize: number;
9
- contentType?: string;
10
- }): void;
11
- export declare function assertVerifiedConstraints(constraints: FileConstraints | undefined, input: {
12
- fileName?: string;
13
- contentType?: string;
14
- contentLength: number;
7
+ /**
8
+ * Checks a file against the route limits: `FILE_TYPE_NOT_ALLOWED` when it
9
+ * matches none of `fileTypes`, `FILE_EMPTY` when it has no bytes, and
10
+ * `FILE_TOO_LARGE` when it is over `maxFileSize`. Runs on the declared file
11
+ * at presign, and again on the HeadObject values at confirm.
12
+ */
13
+ export declare function assertFileConstraints(constraints: FileConstraints, file: Pick<UploadFile, "size" | "type"> & {
14
+ name?: string;
15
15
  }): void;
16
+ /**
17
+ * Fails with `FILE_TOO_LARGE` above 5 GiB, the most S3 takes in one POST or
18
+ * PutObject. Larger files need multipart.
19
+ */
20
+ export declare function assertSingleUploadSize(size: number): void;
16
21
  //# sourceMappingURL=constraints.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constraints.d.ts","sourceRoot":"","sources":["../../src/helpers/constraints.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,+DAA+D;AAC/D,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,YAAY,EAAE,WAAW,GAAG,aAAa,CAAC,CAAC;AAE9E,mFAAmF;AACnF,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,IAAI,EAAE,MAAM,GACX,IAAI,CAIN;AAED,wBAAgB,yBAAyB,CACvC,WAAW,EAAE,eAAe,GAAG,SAAS,EACxC,KAAK,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,GAClE,IAAI,CAQN;AAED,wBAAgB,yBAAyB,CACvC,WAAW,EAAE,eAAe,GAAG,SAAS,EACxC,KAAK,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,GACxE,IAAI,CASN"}
1
+ {"version":3,"file":"constraints.d.ts","sourceRoot":"","sources":["../../src/helpers/constraints.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,+DAA+D;AAC/D,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,cAAc,EAAE,WAAW,GAAG,aAAa,CAAC,CAAC;AAEhF,oFAAoF;AACpF,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,IAAI,EAAE,MAAM,GACX,IAAI,CAIN;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,eAAe,EAC5B,IAAI,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAC1D,IAAI,CAWN;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAOzD"}
@@ -0,0 +1,28 @@
1
+ import { APIError } from "@dimah-s3/core";
2
+ import type { S3Operation } from "../types/hook-contexts.js";
3
+ import type { ResolvedConfig } from "../types/resolved.js";
4
+ /**
5
+ * A server misconfiguration found while handling a call, such as a guard
6
+ * that returned a boolean. The error boundary logs it and returns
7
+ * `500 INTERNAL_ERROR`.
8
+ */
9
+ export declare class ConfigError extends Error {
10
+ constructor(message: string);
11
+ }
12
+ export type ErrorBoundaryEnv = Pick<ResolvedConfig, "logger" | "onError">;
13
+ /**
14
+ * Maps anything a call throws to the {@link APIError} the client receives.
15
+ *
16
+ * - An `APIError` passes through. A raw better-call error gets a code:
17
+ * `UNSUPPORTED_MEDIA_TYPE`, `VALIDATION_ERROR` for a bad request, or the
18
+ * code and message it carries.
19
+ * - A socket error from S3 becomes `S3_NETWORK_ERROR`.
20
+ * - Anything else becomes `INTERNAL_ERROR`.
21
+ *
22
+ * Failures that are not an `APIError` are logged and passed to `onError`,
23
+ * unless the client already went away. Only a real better-call error passes
24
+ * through: another library's error that is merely named `APIError` is an
25
+ * unexpected failure like any other.
26
+ */
27
+ export declare function toAPIError(error: unknown, env: ErrorBoundaryEnv, request: Request, operation?: S3Operation): APIError;
28
+ //# sourceMappingURL=error-boundary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-boundary.d.ts","sourceRoot":"","sources":["../../src/helpers/error-boundary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAW,MAAM,gBAAgB,CAAC;AAEnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAqBvD;;;;GAIG;AACH,qBAAa,WAAY,SAAQ,KAAK;IACpC,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AAED,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,cAAc,EAAE,QAAQ,GAAG,SAAS,CAAC,CAAC;AAE1E;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,gBAAgB,EACrB,OAAO,EAAE,OAAO,EAChB,SAAS,CAAC,EAAE,WAAW,GACtB,QAAQ,CAaV"}
@@ -1,19 +1,48 @@
1
- import type { ConfirmedObjectResponse, S3ObjectAcl } from "@dimah-s3/core";
2
- import type { HeadObjectCommandOutput, S3Client } from "@aws-sdk/client-s3";
3
- import type { OpenedRoute, ResolvedDimahS3Config, StoredObjectContext } from "../types/index.js";
1
+ import type { HeadObjectCommandOutput } from "@aws-sdk/client-s3";
2
+ import { type ConfirmedObjectResponse, type S3ObjectAcl } from "@dimah-s3/core";
3
+ import type { ObjectContext, UploadFile, UploadKind } from "../types/hook-contexts.js";
4
+ import type { OpenedRoute } from "../types/resolved.js";
4
5
  export type FinalizeConfirmedInput = {
5
- config: ResolvedDimahS3Config;
6
- route: OpenedRoute<"upload" | "multipart">;
7
- stored: StoredObjectContext;
8
- head: HeadObjectCommandOutput;
6
+ route: OpenedRoute<"upload">;
7
+ /** Context of the call, with the uploaded key and bucket. */
8
+ context: ObjectContext;
9
+ kind: UploadKind;
10
+ /** Upload token of this upload. The object must carry it as its marker. */
11
+ uploadToken: string;
12
+ /** Multipart only. */
9
13
  uploadId?: string;
10
- /** ACL from the upload policy, not GetObjectAcl. */
11
- acl?: S3ObjectAcl;
14
+ /** File declared at presign, multipart init or `s3.put`. */
15
+ file: UploadFile;
16
+ /** Effective ACL written at presign, multipart init or `s3.put`. */
17
+ acl: S3ObjectAcl;
18
+ /** HeadObject of the uploaded key. */
19
+ head: HeadObjectCommandOutput;
12
20
  };
13
21
  /**
14
- * HeadObject constraints, `onConfirmed`, then compensating `DeleteObject`
15
- * (and `previousKey` cleanup) so a thrown check or lifecycle hook cannot
16
- * leave an orphan object.
22
+ * Finishes an upload once its object is in S3: confirm, multipart complete
23
+ * and `s3.put`.
24
+ *
25
+ * 1. The object must carry this upload's marker. Otherwise the key holds
26
+ * another upload's object, so the call fails with `OBJECT_NOT_FOUND` and
27
+ * nothing is deleted.
28
+ * 2. The HeadObject size must equal the declared size
29
+ * (`UPLOAD_SIZE_MISMATCH`), and the stored name, type and size must pass
30
+ * the route limits.
31
+ * 3. With `verifyContent`, the first bytes must match the type (for an
32
+ * untyped object, the type its name gives on download).
33
+ * 4. `upload.confirmGuard` runs with the verified `object`, except for
34
+ * `s3.put`.
35
+ * 5. `upload.onConfirmed` runs: plugins first, then the user hook.
36
+ *
37
+ * A rejection (a `4xx` `APIError`) in steps 2 to 4, or from a plugin
38
+ * `onConfirmed`, deletes the object and returns the error. That delete is
39
+ * conditional on the HeadObject ETag where the provider supports `If-Match`,
40
+ * so a newer upload at the same key is kept. Any other failure, such as an
41
+ * S3 network error or a hook whose database is down, keeps the object, so
42
+ * the confirm can be retried. A throw from the user `onConfirmed` keeps the
43
+ * object and returns `500 INTERNAL_ERROR`, even for an `APIError`, so a
44
+ * retried confirm replays the hooks with the same `uploadToken`. After every
45
+ * hook succeeds, `upload.object().previousKey` is deleted.
17
46
  */
18
- export declare function finalizeConfirmedObject(client: S3Client, bucket: string, key: string, input: FinalizeConfirmedInput): Promise<ConfirmedObjectResponse>;
47
+ export declare function finalizeConfirmed(input: FinalizeConfirmedInput): Promise<ConfirmedObjectResponse>;
19
48
  //# sourceMappingURL=finalize-confirmed.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"finalize-confirmed.d.ts","sourceRoot":"","sources":["../../src/helpers/finalize-confirmed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE3E,OAAO,KAAK,EAAE,uBAAuB,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAU5E,OAAO,KAAK,EACV,WAAW,EACX,qBAAqB,EACrB,mBAAmB,EAEpB,MAAM,SAAS,CAAC;AAEjB,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,EAAE,qBAAqB,CAAC;IAC9B,KAAK,EAAE,WAAW,CAAC,QAAQ,GAAG,WAAW,CAAC,CAAC;IAC3C,MAAM,EAAE,mBAAmB,CAAC;IAC5B,IAAI,EAAE,uBAAuB,CAAC;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oDAAoD;IACpD,GAAG,CAAC,EAAE,WAAW,CAAC;CACnB,CAAC;AAEF;;;;GAIG;AACH,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,QAAQ,EAChB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,sBAAsB,GAC5B,OAAO,CAAC,uBAAuB,CAAC,CAwDlC"}
1
+ {"version":3,"file":"finalize-confirmed.d.ts","sourceRoot":"","sources":["../../src/helpers/finalize-confirmed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAIL,KAAK,uBAAuB,EAC5B,KAAK,WAAW,EACjB,MAAM,gBAAgB,CAAC;AAOxB,OAAO,KAAK,EACV,aAAa,EACb,UAAU,EACV,UAAU,EAGX,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,MAAM,MAAM,sBAAsB,GAAG;IACnC,KAAK,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC7B,6DAA6D;IAC7D,OAAO,EAAE,aAAa,CAAC;IACvB,IAAI,EAAE,UAAU,CAAC;IACjB,2EAA2E;IAC3E,WAAW,EAAE,MAAM,CAAC;IACpB,sBAAsB;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,4DAA4D;IAC5D,IAAI,EAAE,UAAU,CAAC;IACjB,oEAAoE;IACpE,GAAG,EAAE,WAAW,CAAC;IACjB,sCAAsC;IACtC,IAAI,EAAE,uBAAuB,CAAC;CAC/B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAsB,iBAAiB,CACrC,KAAK,EAAE,sBAAsB,GAC5B,OAAO,CAAC,uBAAuB,CAAC,CA4DlC"}
@@ -1,13 +1,10 @@
1
1
  import { type HeadObjectCommandOutput, type S3Client } from "@aws-sdk/client-s3";
2
- /** HeadObject as a yes/no. Errors other than not-found still throw. */
3
- export declare function objectExists(client: S3Client, bucket: string, key: string): Promise<boolean>;
4
- /** HeadObject, mapping AWS not-found to `OBJECT_NOT_FOUND`. */
5
- export declare function headObjectOrNotFound(client: S3Client, bucket: string, key: string): Promise<HeadObjectCommandOutput>;
6
2
  /**
7
- * HeadObject after CompleteMultipartUpload. Some providers briefly omit
8
- * `ContentLength`; retry a few times with exponential backoff.
3
+ * HeadObject of a stored object. A missing object fails with
4
+ * `OBJECT_NOT_FOUND`. `abortSignal` cancels the call, for example when the
5
+ * client disconnects.
9
6
  */
10
- export declare function headObjectAfterMultipartComplete(client: S3Client, bucket: string, key: string): Promise<HeadObjectCommandOutput>;
11
- /** Verified size from HeadObject — never invent `0` when S3 omits it. */
12
- export declare function requireContentLength(head: HeadObjectCommandOutput): number;
7
+ export declare function headObjectOrNotFound(client: S3Client, bucket: string, key: string, options?: {
8
+ abortSignal?: AbortSignal;
9
+ }): Promise<HeadObjectCommandOutput>;
13
10
  //# sourceMappingURL=head-object.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"head-object.d.ts","sourceRoot":"","sources":["../../src/helpers/head-object.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,uBAAuB,EAC5B,KAAK,QAAQ,EACd,MAAM,oBAAoB,CAAC;AAI5B,uEAAuE;AACvE,wBAAsB,YAAY,CAChC,MAAM,EAAE,QAAQ,EAChB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,OAAO,CAAC,CAQlB;AAED,+DAA+D;AAC/D,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,QAAQ,EAChB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,uBAAuB,CAAC,CAIlC;AAED;;;GAGG;AACH,wBAAsB,gCAAgC,CACpD,MAAM,EAAE,QAAQ,EAChB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,uBAAuB,CAAC,CAgBlC;AAED,yEAAyE;AACzE,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,uBAAuB,GAAG,MAAM,CAK1E"}
1
+ {"version":3,"file":"head-object.d.ts","sourceRoot":"","sources":["../../src/helpers/head-object.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,uBAAuB,EAC5B,KAAK,QAAQ,EACd,MAAM,oBAAoB,CAAC;AAG5B;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,QAAQ,EAChB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,OAAO,GAAE;IAAE,WAAW,CAAC,EAAE,WAAW,CAAA;CAAO,GAC1C,OAAO,CAAC,uBAAuB,CAAC,CAIlC"}
@@ -1,22 +1,36 @@
1
- import type { ResolvedDimahS3Config, UploadConfig, UploadObjectContext, UploadObjectInfo } from "../types/index.js";
1
+ import type { GuardContext } from "../types/hook-contexts.js";
2
+ import type { DimahS3Locals, Guard, LifecycleHook } from "../types/locals.js";
3
+ import type { HookList } from "../types/resolved.js";
2
4
  /**
3
- * Run a guard hook. {@link isAPIError} values are preserved; plain Errors keep
4
- * their English message without a library `code` so client
5
- * `useFormatDimahError` does not replace them with a generic mapped string.
5
+ * A new null-prototype `locals` object for one call, seeded with trusted
6
+ * in-process values.
6
7
  */
7
- export declare function runHook<T extends {
8
- request: Request;
9
- }>(hook: ((context: T) => Promise<void> | void) | undefined, context: T): Promise<void>;
8
+ export declare function createLocals(seed?: Partial<DimahS3Locals>): DimahS3Locals;
10
9
  /**
11
- * Run `upload.object`. Same rejection mapping as {@link runHook}
12
- * (plain `Error` → 403) so auth throws in `object` match `guard`.
10
+ * Runs guards in order. Each `{ locals }` result is copied into
11
+ * `context.locals`, so later hooks in the call see it. A throw rejects the
12
+ * call. Any other return value is a {@link ConfigError} and never allows.
13
13
  */
14
- export declare function runObjectHook(hook: UploadConfig["object"], context: UploadObjectContext): Promise<UploadObjectInfo | void>;
14
+ export declare function runGuards<C extends GuardContext>(guards: HookList<Guard<C>>, context: C): Promise<void>;
15
+ export type RunLifecycleOptions = {
16
+ /**
17
+ * Runs when a plugin hook throws, before the error is rethrown. Use it to
18
+ * undo the operation, for example to delete an object whose bookkeeping
19
+ * failed.
20
+ */
21
+ onPluginError?: (error: unknown) => Promise<void> | void;
22
+ };
15
23
  /**
16
- * Run a lifecycle `on*` hook. Failures become {@link errors.internalError}
17
- * (or preserve an existing APIError).
24
+ * Runs lifecycle hooks in order: plugins first, then the user hook. The
25
+ * first throw stops the rest and is rethrown. A user hook failure leaves the
26
+ * operation's effects in place.
18
27
  */
19
- export declare function runLifecycleHook<T extends {
20
- request: Request;
21
- }>(hook: ((context: T) => Promise<void> | void) | undefined, context: T, config?: Pick<ResolvedDimahS3Config, "logger" | "onError">): Promise<void>;
28
+ export declare function runLifecycle<C>(hooks: HookList<LifecycleHook<C>>, context: C, options?: RunLifecycleOptions): Promise<void>;
29
+ /**
30
+ * Exactly `{ locals: object }`: a plain object whose only key is `locals`,
31
+ * holding an object that is not an array.
32
+ */
33
+ export declare function isGuardResult(value: unknown): value is {
34
+ locals: Partial<DimahS3Locals>;
35
+ };
22
36
  //# sourceMappingURL=hooks.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/helpers/hooks.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,qBAAqB,EACrB,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAajB;;;;GAIG;AACH,wBAAsB,OAAO,CAAC,CAAC,SAAS;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,EAC1D,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,SAAS,EACxD,OAAO,EAAE,CAAC,GACT,OAAO,CAAC,IAAI,CAAC,CAOf;AAED;;;GAGG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,YAAY,CAAC,QAAQ,CAAC,EAC5B,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAOlC;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,SAAS;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,EACnE,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,SAAS,EACxD,OAAO,EAAE,CAAC,EACV,MAAM,CAAC,EAAE,IAAI,CAAC,qBAAqB,EAAE,QAAQ,GAAG,SAAS,CAAC,GACzD,OAAO,CAAC,IAAI,CAAC,CAUf"}
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/helpers/hooks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC1E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEjD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,aAAa,CAIzE;AAED;;;;GAIG;AACH,wBAAsB,SAAS,CAAC,CAAC,SAAS,YAAY,EACpD,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAC1B,OAAO,EAAE,CAAC,GACT,OAAO,CAAC,IAAI,CAAC,CAYf;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC;;;;OAIG;IACH,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CAC1D,CAAC;AAEF;;;;GAIG;AACH,wBAAsB,YAAY,CAAC,CAAC,EAClC,KAAK,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EACjC,OAAO,EAAE,CAAC,EACV,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,IAAI,CAAC,CASf;AAQD;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,OAAO,GACb,KAAK,IAAI;IAAE,MAAM,EAAE,OAAO,CAAC,aAAa,CAAC,CAAA;CAAE,CAU7C"}
@@ -1,12 +1,29 @@
1
- import { type ContentDispositionType, type ResolveInlineDispositionResult } from "@dimah-s3/core";
1
+ import { type ContentDispositionType } from "@dimah-s3/core";
2
+ import type { ResolvedDownload } from "../types/resolved.js";
3
+ /** How a stored object is sent: the presigned GET or the `/file` response. */
4
+ export type ObjectDisposition = {
5
+ disposition: ContentDispositionType;
6
+ /** `Content-Disposition` value, with the file name when there is one. */
7
+ header: string;
8
+ /**
9
+ * Set when the object opens inline but has no usable stored type: the
10
+ * type matched from the file name. Send it as `Content-Type`.
11
+ */
12
+ contentType?: string;
13
+ };
2
14
  /**
3
- * Route `download.inlineTypes` after HeadObject. Without a list, the
4
- * disposition is signed as is.
15
+ * The disposition for a stored object, after S3 reports its type. `inline`
16
+ * is kept only when the type is on the route's effective `inlineTypes`;
17
+ * anything else is sent as `attachment`. Without a requested `name`, the
18
+ * file name comes from the stored `Content-Disposition`, else the key.
5
19
  */
6
- export declare function applyInlineTypes(inlineTypes: readonly string[] | undefined, input: {
20
+ export declare function resolveObjectDisposition(inlineTypes: ResolvedDownload["inlineTypes"], input: {
7
21
  key: string;
8
- fileName?: string;
9
- disposition: ContentDispositionType;
22
+ name?: string;
23
+ requested: ContentDispositionType;
24
+ /** Stored `Content-Type`, as S3 reports it. */
10
25
  contentType?: string;
11
- }): ResolveInlineDispositionResult;
26
+ /** Stored `Content-Disposition`, as S3 reports it. */
27
+ contentDisposition?: string;
28
+ }): ObjectDisposition;
12
29
  //# sourceMappingURL=inline-types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"inline-types.d.ts","sourceRoot":"","sources":["../../src/helpers/inline-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,sBAAsB,EAC3B,KAAK,8BAA8B,EACpC,MAAM,gBAAgB,CAAC;AAExB;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,EAC1C,KAAK,EAAE;IACL,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,sBAAsB,CAAC;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GACA,8BAA8B,CAQhC"}
1
+ {"version":3,"file":"inline-types.d.ts","sourceRoot":"","sources":["../../src/helpers/inline-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,sBAAsB,EAC5B,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,8EAA8E;AAC9E,MAAM,MAAM,iBAAiB,GAAG;IAC9B,WAAW,EAAE,sBAAsB,CAAC;IACpC,yEAAyE;IACzE,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,WAAW,EAAE,gBAAgB,CAAC,aAAa,CAAC,EAC5C,KAAK,EAAE;IACL,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,sBAAsB,CAAC;IAClC,+CAA+C;IAC/C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sDAAsD;IACtD,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,GACA,iBAAiB,CAenB"}
@@ -1,13 +1,11 @@
1
1
  import { type Part, type S3Client } from "@aws-sdk/client-s3";
2
- /** Page through ListParts until S3 reports no more parts. */
2
+ /**
3
+ * Every uploaded part of a multipart upload, reading ListParts page by page
4
+ * until S3 reports no more. A missing upload fails with `OBJECT_NOT_FOUND`.
5
+ */
3
6
  export declare function listAllParts(client: S3Client, input: {
4
7
  bucket: string;
5
8
  key: string;
6
9
  uploadId: string;
7
10
  }): Promise<Part[]>;
8
- /** Sum `Size` on listed parts. Pass `excludePartNumber` when replacing a part. */
9
- export declare function listedPartsByteSize(parts: readonly {
10
- PartNumber?: number;
11
- Size?: number;
12
- }[], excludePartNumber?: number): number;
13
11
  //# sourceMappingURL=list-parts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"list-parts.d.ts","sourceRoot":"","sources":["../../src/helpers/list-parts.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,IAAI,EACT,KAAK,QAAQ,EACd,MAAM,oBAAoB,CAAC;AAG5B,6DAA6D;AAC7D,wBAAsB,YAAY,CAChC,MAAM,EAAE,QAAQ,EAChB,KAAK,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GACvD,OAAO,CAAC,IAAI,EAAE,CAAC,CAsBjB;AAED,kFAAkF;AAClF,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,SAAS;IAAE,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,EACxD,iBAAiB,CAAC,EAAE,MAAM,GACzB,MAAM,CAYR"}
1
+ {"version":3,"file":"list-parts.d.ts","sourceRoot":"","sources":["../../src/helpers/list-parts.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,IAAI,EACT,KAAK,QAAQ,EACd,MAAM,oBAAoB,CAAC;AAM5B;;;GAGG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,QAAQ,EAChB,KAAK,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GACvD,OAAO,CAAC,IAAI,EAAE,CAAC,CA4BjB"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Makes a metadata value safe to send as an `x-amz-meta-*` header. Printable
3
+ * ASCII without surrounding spaces is kept as is. Anything else becomes one
4
+ * RFC 2047 encoded word (`=?UTF-8?B?…?=`), the form S3 itself returns for
5
+ * non-ASCII metadata.
6
+ */
7
+ export declare function encodeMetadataValue(value: string): string;
8
+ /**
9
+ * Reverses {@link encodeMetadataValue}, and decodes any RFC 2047 value S3
10
+ * returns: one or more `B` or `Q` encoded words in UTF-8 or US-ASCII,
11
+ * separated by whitespace. A value that is not a well-formed encoded word
12
+ * is returned unchanged.
13
+ */
14
+ export declare function decodeMetadataValue(value: string): string;
15
+ //# sourceMappingURL=metadata-encoding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metadata-encoding.d.ts","sourceRoot":"","sources":["../../src/helpers/metadata-encoding.ts"],"names":[],"mappings":"AAaA;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGzD;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAkBzD"}
@@ -0,0 +1,39 @@
1
+ /** S3 user-metadata key for the upload marker. Its value is the upload token. */
2
+ export declare const UPLOAD_MARKER_META = "dimah-upload";
3
+ /** S3 user-metadata key for `upload.object().previousKey`. */
4
+ export declare const PREVIOUS_KEY_META = "dimah-previous-key";
5
+ /** S3 limit on user metadata: UTF-8 bytes of every key and value, summed. */
6
+ export declare const MAX_METADATA_BYTES = 2048;
7
+ export type ObjectMetadataInput = {
8
+ /** User metadata from `upload.object()` or `s3.put`. */
9
+ metadata?: Record<string, string>;
10
+ uploadToken: string;
11
+ /** Key to delete after a successful confirm. */
12
+ previousKey?: string;
13
+ };
14
+ /**
15
+ * S3 user metadata for a new object: the user metadata plus the upload
16
+ * marker and the previous key. Keys are lowercased, as S3 stores them, and
17
+ * values are RFC 2047-encoded where needed.
18
+ *
19
+ * Throws a {@link ConfigError} when a key is invalid, repeats, or uses an
20
+ * internal name, or when the total exceeds {@link MAX_METADATA_BYTES}.
21
+ */
22
+ export declare function buildObjectMetadata(input: ObjectMetadataInput): Record<string, string>;
23
+ /** User metadata as HeadObject returns it, split from the internal keys. */
24
+ export type StoredObjectMetadata = {
25
+ /** Decoded user metadata, without internal keys. */
26
+ metadata: Record<string, string>;
27
+ uploadToken?: string;
28
+ previousKey?: string;
29
+ };
30
+ /** Splits and decodes HeadObject `Metadata`. */
31
+ export declare function readObjectMetadata(raw: Record<string, string> | undefined): StoredObjectMetadata;
32
+ /**
33
+ * The upload token an object was written with: its upload marker, read
34
+ * from HeadObject `Metadata`. `undefined` for an object dimah-s3 did not
35
+ * write. A plugin that cleans up an upload deletes the object only while
36
+ * this still equals the token of the upload it tracks.
37
+ */
38
+ export declare function readUploadMarker(metadata: Record<string, string> | undefined): string | undefined;
39
+ //# sourceMappingURL=object-meta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object-meta.d.ts","sourceRoot":"","sources":["../../src/helpers/object-meta.ts"],"names":[],"mappings":"AAMA,iFAAiF;AACjF,eAAO,MAAM,kBAAkB,iBAAiB,CAAC;AAEjD,8DAA8D;AAC9D,eAAO,MAAM,iBAAiB,uBAAuB,CAAC;AAEtD,6EAA6E;AAC7E,eAAO,MAAM,kBAAkB,OAAO,CAAC;AAUvC,MAAM,MAAM,mBAAmB,GAAG;IAChC,wDAAwD;IACxD,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,gDAAgD;IAChD,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,mBAAmB,GACzB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA8BxB;AAED,4EAA4E;AAC5E,MAAM,MAAM,oBAAoB,GAAG;IACjC,oDAAoD;IACpD,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,gDAAgD;AAChD,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,GACtC,oBAAoB,CAYtB;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,GAC3C,MAAM,GAAG,SAAS,CAEpB"}
@@ -1,6 +1,9 @@
1
1
  import type { StorageClass } from "@aws-sdk/client-s3";
2
- import type { ObjectS3Headers } from "../types/index.js";
3
- /** URL-encoded `key=value&…` for the S3 `Tagging` / `x-amz-tagging` field. */
2
+ import type { ObjectS3Headers } from "../types/hook-contexts.js";
3
+ /**
4
+ * URL-encoded `key=value&…` for the S3 `Tagging` / `x-amz-tagging` field.
5
+ * Tags come from `upload.object`, so an invalid tag is a {@link ConfigError}.
6
+ */
4
7
  export declare function encodeObjectTagging(tagging: Record<string, string>): string;
5
8
  /**
6
9
  * Drop blank `storageClass` / `cacheControl` / empty `tagging`, and reject
@@ -1 +1 @@
1
- {"version":3,"file":"object-s3.d.ts","sourceRoot":"","sources":["../../src/helpers/object-s3.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AA2B/C,8EAA8E;AAC9E,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAa3E;AAOD;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,eAAe,GAAG,SAAS,GAChC,eAAe,CAajB;AAED,wDAAwD;AACxD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,eAAe;;;;EASxD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,eAAe,GACpB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAOxB"}
1
+ {"version":3,"file":"object-s3.d.ts","sourceRoot":"","sources":["../../src/helpers/object-s3.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AA+B7D;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAa3E;AAOD;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,eAAe,GAAG,SAAS,GAChC,eAAe,CAajB;AAED,wDAAwD;AACxD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,eAAe;;;;EASxD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,eAAe,GACpB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAOxB"}