@dimah-s3/server 1.7.1 → 2.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 +73 -96
  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 +73 -96
  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 +71 -94
  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
@@ -0,0 +1,16 @@
1
+ import type { RouteCatalogResponse } from "@dimah-s3/core";
2
+ import type { S3ServerCallOptions } from "../types/config.js";
3
+ import type { ResolvedConfig } from "../types/resolved.js";
4
+ /**
5
+ * Lists every route and the features a client may use
6
+ * (`GET /routes`, `s3.api.catalog`). It runs the instance guard like every
7
+ * other call.
8
+ */
9
+ export declare function getRouteCatalog(config: ResolvedConfig, options?: S3ServerCallOptions): Promise<RouteCatalogResponse>;
10
+ /**
11
+ * The catalog of a resolved config. It reports effective values: `checksum`
12
+ * is on whenever `verifyContent` is, and `inlineTypes` is the allow-list a
13
+ * download really uses (`[]` when nothing opens inline).
14
+ */
15
+ export declare function buildRouteCatalog(config: ResolvedConfig): RouteCatalogResponse;
16
+ //# sourceMappingURL=catalog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../src/operations/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAqB,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAG9E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAiB,MAAM,kBAAkB,CAAC;AAEtE;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,cAAc,EACtB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,oBAAoB,CAAC,CAI/B;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,cAAc,GACrB,oBAAoB,CAMtB"}
@@ -0,0 +1,19 @@
1
+ import type { UploadConfirmResponse } from "@dimah-s3/core";
2
+ import type { ticketBodySchema } from "@dimah-s3/core/schema";
3
+ import type * as z from "zod";
4
+ import type { S3ServerCallOptions } from "../types/config.js";
5
+ import type { ResolvedConfig } from "../types/resolved.js";
6
+ /** Body of `POST /presign/upload/confirm`, after validation. */
7
+ export type ConfirmBody = z.output<typeof ticketBodySchema>;
8
+ /**
9
+ * Confirms a single-shot upload (`POST /presign/upload/confirm`,
10
+ * `s3.api.confirm`).
11
+ *
12
+ * The ticket names the route, the key and the declared file. After the
13
+ * route guard and the subject check, HeadObject reads the object, and
14
+ * {@link finalizeConfirmed} checks it and runs `upload.confirmGuard` and
15
+ * `upload.onConfirmed`. Confirm keeps no state: a retry with the same ticket
16
+ * runs the checks and hooks again.
17
+ */
18
+ export declare function confirmUpload(config: ResolvedConfig, body: ConfirmBody, options?: S3ServerCallOptions): Promise<UploadConfirmResponse>;
19
+ //# sourceMappingURL=confirm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"confirm.d.ts","sourceRoot":"","sources":["../../src/operations/confirm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,KAAK,CAAC,MAAM,KAAK,CAAC;AAK9B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,gEAAgE;AAChE,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE5D;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,cAAc,EACtB,IAAI,EAAE,WAAW,EACjB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,qBAAqB,CAAC,CAuBhC"}
@@ -0,0 +1,18 @@
1
+ import type { DeleteManyPayload, DeleteManyResponse } from "@dimah-s3/core";
2
+ import type { S3ServerCallOptions } from "../types/config.js";
3
+ import type { ResolvedConfig } from "../types/resolved.js";
4
+ /**
5
+ * Deletes many objects of one route (`POST /delete/batch`,
6
+ * `s3.api.deleteMany`).
7
+ *
8
+ * The route guard runs once for the call. Each key is then checked against
9
+ * the route namespace and `delete.guard`, and the keys that pass go to S3 in
10
+ * one DeleteObjects request. `delete.onDeleted` runs for each deleted key.
11
+ * A per-key failure (an invalid key, a guard, an S3 error or an `onDeleted`
12
+ * throw) is reported in `failed` and does not fail the call. A route error,
13
+ * or a DeleteObjects request that fails as a whole, fails the call. Like
14
+ * single delete, a key that is already gone counts as deleted, and the S3
15
+ * call ignores client disconnects.
16
+ */
17
+ export declare function deleteManyObjects(config: ResolvedConfig, payload: DeleteManyPayload, options?: S3ServerCallOptions): Promise<DeleteManyResponse>;
18
+ //# sourceMappingURL=delete-many.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete-many.d.ts","sourceRoot":"","sources":["../../src/operations/delete-many.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,iBAAiB,EACjB,kBAAkB,EAEnB,MAAM,gBAAgB,CAAC;AAMxB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAE1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,cAAc,EACtB,OAAO,EAAE,iBAAiB,EAC1B,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,kBAAkB,CAAC,CA6D7B"}
@@ -0,0 +1,14 @@
1
+ import type { DeletePayload, DeleteResponse } from "@dimah-s3/core";
2
+ import type { S3ServerCallOptions } from "../types/config.js";
3
+ import type { ResolvedConfig } from "../types/resolved.js";
4
+ /**
5
+ * Deletes one object (`DELETE /delete`, `s3.api.delete`).
6
+ *
7
+ * After the route guard and `delete.guard`, DeleteObject runs, then
8
+ * `delete.onDeleted`. Delete is idempotent: a key that never landed or is
9
+ * already gone succeeds and still runs `onDeleted`, so a pending or expired
10
+ * upload's bookkeeping is cleaned up. The S3 call ignores client
11
+ * disconnects, so `onDeleted` sees every delete that happened.
12
+ */
13
+ export declare function deleteStoredObject(config: ResolvedConfig, payload: DeletePayload, options?: S3ServerCallOptions): Promise<DeleteResponse>;
14
+ //# sourceMappingURL=delete.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../src/operations/delete.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAIpE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,cAAc,EACtB,OAAO,EAAE,aAAa,EACtB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,cAAc,CAAC,CAiBzB"}
@@ -0,0 +1,20 @@
1
+ import { type DownloadPresignResponse } from "@dimah-s3/core";
2
+ import type { downloadQuerySchema } from "@dimah-s3/core/schema";
3
+ import type * as z from "zod";
4
+ import type { S3ServerCallOptions } from "../types/config.js";
5
+ import type { ResolvedConfig } from "../types/resolved.js";
6
+ /** Query of `GET /presign/download`, after validation. */
7
+ export type DownloadQuery = z.output<typeof downloadQuerySchema>;
8
+ /**
9
+ * Presigns a download (`GET /presign/download`, `s3.api.download`).
10
+ *
11
+ * After the route guard, `download.resolve` can change the name, the
12
+ * disposition and the TTL, and `download.guard` sees the values that will
13
+ * be used. HeadObject then reads the stored type, and `inline` is kept only
14
+ * for a type on the route's `inlineTypes`. In presign mode the URL is a
15
+ * signed GetObject. In proxy mode it is the `/file` URL, relative to the API
16
+ * unless `baseURL` is set, and has no `expiresIn`. `download.onPresigned`
17
+ * runs last with the URL and the disposition that was sent.
18
+ */
19
+ export declare function presignDownload(config: ResolvedConfig, query: DownloadQuery, options?: S3ServerCallOptions): Promise<DownloadPresignResponse>;
20
+ //# sourceMappingURL=download.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../../src/operations/download.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,KAAK,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,KAAK,CAAC,MAAM,KAAK,CAAC;AAO9B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,0DAA0D;AAC1D,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEjE;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,cAAc,EACtB,KAAK,EAAE,aAAa,EACpB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,uBAAuB,CAAC,CAgElC"}
@@ -0,0 +1,38 @@
1
+ import type { fileQuerySchema } from "@dimah-s3/core/schema";
2
+ import type * as z from "zod";
3
+ import type { S3ServerCallOptions } from "../types/config.js";
4
+ import type { ResolvedConfig } from "../types/resolved.js";
5
+ /** Query of `GET /file`, after validation. */
6
+ export type FileQuery = z.output<typeof fileQuerySchema>;
7
+ /**
8
+ * Streams an object through the API (`GET /file`). Proxy-mode download URLs
9
+ * point here, and there is no `s3.api` method for it. Only a route with
10
+ * `download.mode: "proxy"` is served; any other fails with
11
+ * `FEATURE_DISABLED` (`feature: "proxy"`), so the server never streams
12
+ * objects the route did not opt in for.
13
+ *
14
+ * Guards run first: the route guard, then `download.guard` with the values
15
+ * from `download.resolve`. Then a single GetObject runs with the request's
16
+ * Range and conditional headers and its abort signal, and the response
17
+ * carries the hardening headers, `ETag` and `Last-Modified`.
18
+ *
19
+ * - Only one byte range is forwarded. A multi-range or malformed `Range` is
20
+ * ignored, so the response is a 200.
21
+ * - `If-Match`, `If-None-Match`, `If-Modified-Since` and
22
+ * `If-Unmodified-Since` are forwarded. S3's 304 becomes a bare 304, and
23
+ * its 412 becomes `PRECONDITION_FAILED`.
24
+ * - `If-Range` is checked against the ranged response. When the object
25
+ * changed, the range is dropped and the whole object is fetched again.
26
+ * - A range S3 cannot satisfy fails with `RANGE_NOT_SATISFIABLE` and a
27
+ * `Content-Range` that names the object size.
28
+ *
29
+ * Error responses carry the hardening headers too, with the default
30
+ * `Cache-Control`, so a shared cache never keeps a refusal for others.
31
+ */
32
+ export declare function serveFile(config: ResolvedConfig, query: FileQuery, options?: S3ServerCallOptions): Promise<Response>;
33
+ /**
34
+ * Adds the `/file` hardening headers to an `APIError`, keeping the ones it
35
+ * carries. Anything else is returned as it is.
36
+ */
37
+ export declare function withFileHeaders(error: unknown): unknown;
38
+ //# sourceMappingURL=file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/operations/file.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,KAAK,CAAC,MAAM,KAAK,CAAC;AAO9B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAE1D,OAAO,KAAK,EAAe,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEpE,8CAA8C;AAC9C,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,eAAe,CAAC,CAAC;AAqBzD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,SAAS,CAC7B,MAAM,EAAE,cAAc,EACtB,KAAK,EAAE,SAAS,EAChB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,QAAQ,CAAC,CAwDnB;AAsKD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAQvD"}
@@ -0,0 +1,20 @@
1
+ import { type MultipartAbortResponse } from "@dimah-s3/core";
2
+ import type { S3ServerCallOptions } from "../../types/config.js";
3
+ import type { ResolvedConfig } from "../../types/resolved.js";
4
+ import { type MultipartTicketBody } from "./open-multipart";
5
+ /**
6
+ * Aborts a multipart upload (`POST /presign/multipart/abort`,
7
+ * `s3.api.multipart.abort`).
8
+ *
9
+ * The ticket is accepted for 7 days after it expires, so an abandoned upload
10
+ * can still be cleaned up. After `upload.multipart.guard`
11
+ * (`action: "abort"`), AbortMultipartUpload runs, then
12
+ * `upload.multipart.onAbort`.
13
+ *
14
+ * Abort is idempotent, like delete: an upload that is already gone (aborted
15
+ * before, or removed by a bucket lifecycle rule) succeeds and still runs
16
+ * `onAbort`, so its bookkeeping is cleaned up. An upload that was completed
17
+ * instead fails with `CONFLICT`: its object carries this upload's marker.
18
+ */
19
+ export declare function abortMultipart(config: ResolvedConfig, body: MultipartTicketBody, options?: S3ServerCallOptions): Promise<MultipartAbortResponse>;
20
+ //# sourceMappingURL=abort.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abort.d.ts","sourceRoot":"","sources":["../../../src/operations/multipart/abort.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,sBAAsB,EAC5B,MAAM,gBAAgB,CAAC;AAMxB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAE1D,OAAO,KAAK,EAAe,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAiB,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAE3E;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,cAAc,EACtB,IAAI,EAAE,mBAAmB,EACzB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,sBAAsB,CAAC,CA0BjC"}
@@ -0,0 +1,21 @@
1
+ import { type MultipartCompleteResponse } from "@dimah-s3/core";
2
+ import type { S3ServerCallOptions } from "../../types/config.js";
3
+ import type { ResolvedConfig } from "../../types/resolved.js";
4
+ import { type MultipartTicketBody } from "./open-multipart";
5
+ /**
6
+ * Completes a multipart upload (`POST /presign/multipart/complete`,
7
+ * `s3.api.multipart.complete`).
8
+ *
9
+ * After `upload.multipart.guard` (`action: "complete"`), it reads every
10
+ * ListParts page and checks the parts against the layout chosen at init
11
+ * (see {@link completedParts}). CompleteMultipartUpload assembles parts
12
+ * `1..partCount`, then HeadObject reads the object and
13
+ * {@link finalizeConfirmed} runs the same checks and hooks as confirm.
14
+ *
15
+ * Like confirm, a retry is safe. When the upload no longer exists because
16
+ * an earlier or concurrent call completed it (at ListParts or at
17
+ * CompleteMultipartUpload), the stored object is finalized again, as long
18
+ * as it carries this upload's marker.
19
+ */
20
+ export declare function completeMultipart(config: ResolvedConfig, body: MultipartTicketBody, options?: S3ServerCallOptions): Promise<MultipartCompleteResponse>;
21
+ //# sourceMappingURL=complete.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"complete.d.ts","sourceRoot":"","sources":["../../../src/operations/multipart/complete.ts"],"names":[],"mappings":"AAMA,OAAO,EAGL,KAAK,yBAAyB,EAC/B,MAAM,gBAAgB,CAAC;AAQxB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAE1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAiB,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAE3E;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,cAAc,EACtB,IAAI,EAAE,mBAAmB,EACzB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,yBAAyB,CAAC,CA4CpC"}
@@ -0,0 +1,19 @@
1
+ import type { MultipartInitResponse } from "@dimah-s3/core";
2
+ import type { multipartInitBodySchema } from "@dimah-s3/core/schema";
3
+ import type * as z from "zod";
4
+ import type { S3ServerCallOptions } from "../../types/config.js";
5
+ import type { ResolvedConfig } from "../../types/resolved.js";
6
+ /** Body of `POST /presign/multipart/init`, after validation. */
7
+ export type MultipartInitBody = z.output<typeof multipartInitBodySchema>;
8
+ /**
9
+ * Starts a multipart upload (`POST /presign/multipart/init`,
10
+ * `s3.api.multipart.init`).
11
+ *
12
+ * {@link openUploadTarget} checks the request and runs `upload.object()`
13
+ * and `upload.guard`, and the part layout is picked. CreateMultipartUpload writes the type, the disposition,
14
+ * the metadata and the upload marker, and asks for SHA-256 part checksums
15
+ * when the route requires them. Then it issues the ticket and runs
16
+ * `upload.onStart`. If either fails, the multipart upload is aborted.
17
+ */
18
+ export declare function initMultipart(config: ResolvedConfig, body: MultipartInitBody, options?: S3ServerCallOptions): Promise<MultipartInitResponse>;
19
+ //# sourceMappingURL=init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/operations/multipart/init.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,KAAK,KAAK,CAAC,MAAM,KAAK,CAAC;AAQ9B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,gEAAgE;AAChE,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAEzE;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,cAAc,EACtB,IAAI,EAAE,iBAAiB,EACvB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,qBAAqB,CAAC,CA6EhC"}
@@ -0,0 +1,11 @@
1
+ import type { MultipartListPartsResponse } from "@dimah-s3/core";
2
+ import type { S3ServerCallOptions } from "../../types/config.js";
3
+ import type { ResolvedConfig } from "../../types/resolved.js";
4
+ import { type MultipartTicketBody } from "./open-multipart";
5
+ /**
6
+ * Lists the uploaded parts (`POST /presign/multipart/parts`,
7
+ * `s3.api.multipart.listParts`), so a client can resume an upload. It reads
8
+ * every ListParts page.
9
+ */
10
+ export declare function listMultipartParts(config: ResolvedConfig, body: MultipartTicketBody, options?: S3ServerCallOptions): Promise<MultipartListPartsResponse>;
11
+ //# sourceMappingURL=list-parts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-parts.d.ts","sourceRoot":"","sources":["../../../src/operations/multipart/list-parts.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,0BAA0B,EAE3B,MAAM,gBAAgB,CAAC;AAIxB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAiB,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC3E;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,cAAc,EACtB,IAAI,EAAE,mBAAmB,EACzB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,0BAA0B,CAAC,CAUrC"}
@@ -0,0 +1,25 @@
1
+ import type { ticketBodySchema } from "@dimah-s3/core/schema";
2
+ import type * as z from "zod";
3
+ import type { PartLayout } from "../../helpers/part-layout.js";
4
+ import type { UploadTicket } from "../../helpers/ticket.js";
5
+ import type { GuardContext, MultipartUploadContext, ObjectContext } from "../../types/hook-contexts.js";
6
+ import type { OpenedRoute, ResolvedConfig } from "../../types/resolved.js";
7
+ /** Body of the multipart list, complete and abort calls, after validation. */
8
+ export type MultipartTicketBody = z.output<typeof ticketBodySchema>;
9
+ export type OpenedMultipart = {
10
+ route: OpenedRoute<"multipart">;
11
+ ticket: UploadTicket<"multipart">;
12
+ /** Context with the key and bucket, for the confirm hooks. */
13
+ objectContext: ObjectContext;
14
+ /** Context for `upload.multipart.guard` and `onAbort`. */
15
+ context: MultipartUploadContext;
16
+ /** The part layout chosen at init. */
17
+ layout: PartLayout;
18
+ };
19
+ /**
20
+ * Opens a multipart call after init: sign part, list, complete or abort.
21
+ * The ticket is verified, the route guard runs and the subject is checked
22
+ * (see {@link openTicket}). The caller runs `upload.multipart.guard`.
23
+ */
24
+ export declare function openMultipart(config: ResolvedConfig, call: GuardContext, token: string): Promise<OpenedMultipart>;
25
+ //# sourceMappingURL=open-multipart.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"open-multipart.d.ts","sourceRoot":"","sources":["../../../src/operations/multipart/open-multipart.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,KAAK,CAAC,MAAM,KAAK,CAAC;AAC9B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EACV,YAAY,EACZ,sBAAsB,EACtB,aAAa,EACd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEpE,8EAA8E;AAC9E,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEpE,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,WAAW,CAAC,WAAW,CAAC,CAAC;IAChC,MAAM,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC;IAClC,8DAA8D;IAC9D,aAAa,EAAE,aAAa,CAAC;IAC7B,0DAA0D;IAC1D,OAAO,EAAE,sBAAsB,CAAC;IAChC,sCAAsC;IACtC,MAAM,EAAE,UAAU,CAAC;CACpB,CAAC;AAEF;;;;GAIG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,cAAc,EACtB,IAAI,EAAE,YAAY,EAClB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,eAAe,CAAC,CAuB1B"}
@@ -0,0 +1,20 @@
1
+ import { type MultipartPartResponse } from "@dimah-s3/core";
2
+ import type { multipartSignPartBodySchema } from "@dimah-s3/core/schema";
3
+ import type * as z from "zod";
4
+ import type { S3ServerCallOptions } from "../../types/config.js";
5
+ import type { ResolvedConfig } from "../../types/resolved.js";
6
+ /** Body of `POST /presign/multipart/part`, after validation. */
7
+ export type MultipartSignPartBody = z.output<typeof multipartSignPartBodySchema>;
8
+ /**
9
+ * Presigns one part (`POST /presign/multipart/part`,
10
+ * `s3.api.multipart.signPart`).
11
+ *
12
+ * The part number must be inside the layout chosen at init
13
+ * (`MULTIPART_PART_INVALID`), and the part size comes from that layout, so
14
+ * this never calls ListParts. The URL signs that size. When the ticket
15
+ * requires checksums, the part's SHA-256 is required (`CHECKSUM_REQUIRED`)
16
+ * and signed. Otherwise a sent checksum is ignored: the upload was created
17
+ * without part checksums, and S3 would reject the part.
18
+ */
19
+ export declare function signMultipartPart(config: ResolvedConfig, body: MultipartSignPartBody, options?: S3ServerCallOptions): Promise<MultipartPartResponse>;
20
+ //# sourceMappingURL=sign-part.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sign-part.d.ts","sourceRoot":"","sources":["../../../src/operations/multipart/sign-part.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,KAAK,KAAK,CAAC,MAAM,KAAK,CAAC;AAK9B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGvD,gEAAgE;AAChE,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAC1C,OAAO,2BAA2B,CACnC,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,cAAc,EACtB,IAAI,EAAE,qBAAqB,EAC3B,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,qBAAqB,CAAC,CAgChC"}
@@ -0,0 +1,18 @@
1
+ import { type ConfirmedObjectResponse } from "@dimah-s3/core";
2
+ import type { PutInput, S3ServerCallOptions } from "../types/config.js";
3
+ import type { ResolvedConfig } from "../types/resolved.js";
4
+ /**
5
+ * Uploads from the server (`s3.put`) through the same route policy as a
6
+ * presigned upload.
7
+ *
8
+ * It opens the route, runs `upload.object()` and `upload.guard`, then
9
+ * `upload.onStart` (`kind: "server"`). A throw from `onStart` skips the
10
+ * PutObject. The body streams to PutObject with `Content-Disposition` and
11
+ * the upload marker, and then {@link finalizeConfirmed} checks the object
12
+ * and runs `upload.onConfirmed`. `confirmGuard` does not run.
13
+ *
14
+ * `input.metadata` is written to S3 on top of `upload.object().metadata`.
15
+ * `input.clientMetadata` reaches the hooks and is never written.
16
+ */
17
+ export declare function putObject(config: ResolvedConfig, input: PutInput, options?: S3ServerCallOptions): Promise<ConfirmedObjectResponse>;
18
+ //# sourceMappingURL=put.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"put.d.ts","sourceRoot":"","sources":["../../src/operations/put.ts"],"names":[],"mappings":"AAEA,OAAO,EAAW,KAAK,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAQvE,OAAO,KAAK,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAevD;;;;;;;;;;;;GAYG;AACH,wBAAsB,SAAS,CAC7B,MAAM,EAAE,cAAc,EACtB,KAAK,EAAE,QAAQ,EACf,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,uBAAuB,CAAC,CA2DlC"}
@@ -0,0 +1,18 @@
1
+ import type { S3ServerCallOptions } from "../types/config.js";
2
+ import type { GuardContext, S3Operation } from "../types/hook-contexts.js";
3
+ import type { ResolvedConfig } from "../types/resolved.js";
4
+ /**
5
+ * Runs one operation behind the error boundary. HTTP endpoints, `s3.api`
6
+ * and `s3.put` all enter through here.
7
+ *
8
+ * It picks the request (`options.request`, else a synthetic one from
9
+ * `options.headers` and `options.signal`), creates the call's `locals` seeded from
10
+ * `options.locals`, and runs the instance guards. Then it calls `run` with
11
+ * that guard context. Every failure leaves as an `APIError`; see
12
+ * {@link toAPIError}.
13
+ *
14
+ * HTTP endpoints pass only `request`: `locals` is trusted and never read
15
+ * from HTTP.
16
+ */
17
+ export declare function runOperation<T>(config: ResolvedConfig, operation: S3Operation, options: S3ServerCallOptions, run: (context: GuardContext) => Promise<T>): Promise<T>;
18
+ //# sourceMappingURL=run-operation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-operation.d.ts","sourceRoot":"","sources":["../../src/operations/run-operation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD;;;;;;;;;;;;GAYG;AACH,wBAAsB,YAAY,CAAC,CAAC,EAClC,MAAM,EAAE,cAAc,EACtB,SAAS,EAAE,WAAW,EACtB,OAAO,EAAE,mBAAmB,EAC5B,GAAG,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,OAAO,CAAC,CAAC,CAAC,GACzC,OAAO,CAAC,CAAC,CAAC,CAaZ"}
@@ -0,0 +1,12 @@
1
+ import type { DimahS3Api } from "../types/config.js";
2
+ import type { ResolvedConfig } from "../types/resolved.js";
3
+ /**
4
+ * Builds `s3.api`: the browser client's methods, run in process.
5
+ *
6
+ * Each payload is checked with the same schema as its HTTP endpoint, so a
7
+ * bad payload fails with the same `VALIDATION_ERROR`. Then the call runs
8
+ * the same operation. `options.locals` is trusted and seeds `locals` before
9
+ * the guards run.
10
+ */
11
+ export declare function createS3Api(config: ResolvedConfig): DimahS3Api;
12
+ //# sourceMappingURL=s3-api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"s3-api.d.ts","sourceRoot":"","sources":["../../src/operations/s3-api.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,cAAc,GAAG,UAAU,CA0D9D"}
@@ -0,0 +1,19 @@
1
+ import type { UploadPresignResponse } from "@dimah-s3/core";
2
+ import type { uploadBodySchema } from "@dimah-s3/core/schema";
3
+ import type * as z from "zod";
4
+ import type { S3ServerCallOptions } from "../types/config.js";
5
+ import type { ResolvedConfig } from "../types/resolved.js";
6
+ /** Body of `POST /presign/upload`, after validation. */
7
+ export type UploadBody = z.output<typeof uploadBodySchema>;
8
+ /**
9
+ * Presigns a single-shot upload (`POST /presign/upload`, `s3.api.upload`).
10
+ *
11
+ * {@link openUploadTarget} checks the request and runs `upload.object()`
12
+ * and `upload.guard`. Then a PUT URL or a POST policy is signed: it pins
13
+ * the size, the type, the metadata, the upload marker and, when sent, the
14
+ * checksum. Then the upload ticket is issued and `upload.onStart` runs. A
15
+ * throw from `onStart` returns its error, and nothing has been written to
16
+ * S3 yet.
17
+ */
18
+ export declare function presignUpload(config: ResolvedConfig, body: UploadBody, options?: S3ServerCallOptions): Promise<UploadPresignResponse>;
19
+ //# sourceMappingURL=upload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../src/operations/upload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,KAAK,CAAC,MAAM,KAAK,CAAC;AAU9B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAE1D,OAAO,KAAK,EAAE,cAAc,EAAiB,MAAM,kBAAkB,CAAC;AAEtE,wDAAwD;AACxD,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE3D;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,cAAc,EACtB,IAAI,EAAE,UAAU,EAChB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,qBAAqB,CAAC,CA2EhC"}
@@ -1,16 +1,14 @@
1
- import type { DimahS3Config } from "../types/index.js";
2
- import { type AppliedPlugins, type DimahS3Plugin, type PluginContextMap } from "./types";
1
+ import type { DimahS3Config, DimahS3Logger } from "../types/config.js";
2
+ import type { AppliedPlugins, DimahS3Plugin, PluginContextMap } from "./types";
3
3
  /**
4
- * Validate plugins, build context map, collect endpoints, validate routes,
5
- * run `init`, and merge hooks into each route.
4
+ * Checks the plugins, builds the context map, collects the endpoints, and
5
+ * runs each `init` in plugin order. Throws on a config error, so
6
+ * `dimahS3()` fails at startup.
6
7
  *
7
- * Guard / `*Guard` hooks: plugins first (array order), then user.
8
- * Lifecycle `on*` hooks: user first, then plugins, so `db().markActive`
9
- * runs last and confirm rollback can still `DeleteObject`.
10
- *
11
- * Hooks are not merged onto a feature that is off for that route.
8
+ * Plugin hooks are not merged here: route resolution builds each hook list
9
+ * with plugin hooks first, then the user hook.
12
10
  */
13
- export declare function applyPlugins<const P extends readonly DimahS3Plugin[], C extends Record<string, unknown> = PluginContextMap<P>>(config: DimahS3Config & {
11
+ export declare function applyPlugins<const P extends readonly DimahS3Plugin[], C = PluginContextMap<P>>(config: DimahS3Config & {
14
12
  plugins?: P;
15
- }): AppliedPlugins<C>;
13
+ }, logger: DimahS3Logger): AppliedPlugins<C>;
16
14
  //# sourceMappingURL=apply-plugins.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"apply-plugins.d.ts","sourceRoot":"","sources":["../../src/plugin/apply-plugins.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,aAAa,EAGd,MAAM,SAAS,CAAC;AAQjB,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACtB,MAAM,SAAS,CAAC;AA0FjB;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAC1B,KAAK,CAAC,CAAC,SAAS,SAAS,aAAa,EAAE,EACxC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,EACvD,MAAM,EAAE,aAAa,GAAG;IAAE,OAAO,CAAC,EAAE,CAAC,CAAA;CAAE,GAAG,cAAc,CAAC,CAAC,CAAC,CA4H5D"}
1
+ {"version":3,"file":"apply-plugins.d.ts","sourceRoot":"","sources":["../../src/plugin/apply-plugins.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,gBAAgB,EAEjB,MAAM,SAAS,CAAC;AAsBjB;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC1B,KAAK,CAAC,CAAC,SAAS,SAAS,aAAa,EAAE,EACxC,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,EAEvB,MAAM,EAAE,aAAa,GAAG;IAAE,OAAO,CAAC,EAAE,CAAC,CAAA;CAAE,EACvC,MAAM,EAAE,aAAa,GACpB,cAAc,CAAC,CAAC,CAAC,CA0BnB"}
@@ -1,18 +1,21 @@
1
- type Hook<Context> = (context: Context) => Promise<void> | void;
1
+ import type { DimahS3Locals, Guard, LifecycleHook } from "../types/locals.js";
2
2
  /**
3
- * Compose hooks into one that awaits each in order.
4
- *
5
- * Used by {@link dimahS3} when merging plugin + user hooks, and by consumers
6
- * to stack extras (quota, audit) beside plugin hooks:
3
+ * Composes hooks into one that awaits each in order and stops at the first
4
+ * throw. `undefined` entries are skipped, so optional hooks compose:
7
5
  *
8
6
  * ```ts
9
7
  * upload: {
10
- * guard: chainHooks(myQuotaGuard, myAuditGuard),
8
+ * guard: chainHooks(requireUser, checkQuota),
11
9
  * }
12
10
  * ```
13
11
  *
14
- * `undefined` entries are skipped, so optional hooks compose cleanly.
12
+ * Chained guards behave like separate ones: each `{ locals }` result is
13
+ * copied into `context.locals` before the next hook runs. Any other return
14
+ * value is passed on after the chain, so the server still rejects it as a
15
+ * config error.
15
16
  */
16
- export declare function chainHooks<Context>(...hooks: (Hook<Context> | undefined)[]): (context: Context) => Promise<void>;
17
- export {};
17
+ export declare function chainHooks<C>(...hooks: (LifecycleHook<C> | undefined)[]): LifecycleHook<C>;
18
+ export declare function chainHooks<C extends {
19
+ locals: DimahS3Locals;
20
+ }>(...hooks: (Guard<C> | undefined)[]): Guard<C>;
18
21
  //# sourceMappingURL=chain-hooks.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"chain-hooks.d.ts","sourceRoot":"","sources":["../../src/plugin/chain-hooks.ts"],"names":[],"mappings":"AAAA,KAAK,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AAEhE;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAChC,GAAG,KAAK,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC,EAAE,GACtC,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAMrC"}
1
+ {"version":3,"file":"chain-hooks.d.ts","sourceRoot":"","sources":["../../src/plugin/chain-hooks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,aAAa,EACb,KAAK,EAEL,aAAa,EACd,MAAM,gBAAgB,CAAC;AAExB;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAC1B,GAAG,KAAK,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,EAAE,GACzC,aAAa,CAAC,CAAC,CAAC,CAAC;AACpB,wBAAgB,UAAU,CAAC,CAAC,SAAS;IAAE,MAAM,EAAE,aAAa,CAAA;CAAE,EAC5D,GAAG,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,EAAE,GACjC,KAAK,CAAC,CAAC,CAAC,CAAC"}
@@ -1,8 +1,15 @@
1
- import type { Endpoint } from "better-call";
2
1
  import type { DimahS3Plugin } from "./types";
3
2
  /**
4
- * Identity helper that preserves literal `id`, context, and endpoint types
5
- * for {@link dimahS3} inference (`s3.context[id]` / `s3.api`).
3
+ * Identity helper that keeps the literal `id` and the `context` type, so
4
+ * `s3.context[id]` and `s3[id]` are typed.
5
+ *
6
+ * ```ts
7
+ * export const audit = definePlugin({
8
+ * id: "audit",
9
+ * hooks: { upload: { onConfirmed: ({ key }) => log(key) } },
10
+ * context: { log },
11
+ * });
12
+ * ```
6
13
  */
7
- export declare function definePlugin<Id extends string, TContext extends Record<string, unknown> = Record<string, unknown>, TEndpoints extends Record<string, Endpoint> = Record<string, Endpoint>>(plugin: DimahS3Plugin<Id, TContext, TEndpoints>): DimahS3Plugin<Id, TContext, TEndpoints>;
14
+ export declare function definePlugin<Id extends string, TContext extends Record<string, unknown> = Record<string, unknown>>(plugin: DimahS3Plugin<Id, TContext>): DimahS3Plugin<Id, TContext>;
8
15
  //# sourceMappingURL=define-plugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"define-plugin.d.ts","sourceRoot":"","sources":["../../src/plugin/define-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,EAAE,SAAS,MAAM,EACjB,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClE,UAAU,SAAS,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,EAEtE,MAAM,EAAE,aAAa,CAAC,EAAE,EAAE,QAAQ,EAAE,UAAU,CAAC,GAC9C,aAAa,CAAC,EAAE,EAAE,QAAQ,EAAE,UAAU,CAAC,CAEzC"}
1
+ {"version":3,"file":"define-plugin.d.ts","sourceRoot":"","sources":["../../src/plugin/define-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAC1B,EAAE,SAAS,MAAM,EACjB,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClE,MAAM,EAAE,aAAa,CAAC,EAAE,EAAE,QAAQ,CAAC,GAAG,aAAa,CAAC,EAAE,EAAE,QAAQ,CAAC,CAElE"}
@@ -1,6 +1,5 @@
1
1
  export { applyPlugins } from "./apply-plugins";
2
2
  export { chainHooks } from "./chain-hooks";
3
3
  export { definePlugin } from "./define-plugin";
4
- export { FEATURE_HOOK_KEYS, MULTIPART_HOOK_KEYS, LIFECYCLE_FEATURE_HOOK_KEYS, LIFECYCLE_MULTIPART_HOOK_KEYS, } from "./hook-registry";
5
- export { RESERVED_PLUGIN_IDS, type AppliedPlugins, type DimahS3Plugin, type DimahS3PluginHooks, type PluginContextMap, type PluginEndpointMap, type PluginInitEnv, type ReservedPluginId, } from "./types";
4
+ export type { AppliedPlugins, DimahS3Plugin, DimahS3PluginHooks, PluginContextMap, PluginInitEnv, } from "./types";
6
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,2BAA2B,EAC3B,6BAA6B,GAC9B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,mBAAmB,EACnB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,gBAAgB,GACtB,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,YAAY,EACV,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,GACd,MAAM,SAAS,CAAC"}