@dimah-s3/server 1.7.0 → 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 +9 -13
  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,227 +1,219 @@
1
- import type { MultipartCompletedPartRef, MultipartPartInfo, S3ObjectAcl } from "@dimah-s3/core";
2
- /** Context for the instance `guard` hook. */
1
+ import type { ContentDispositionType, S3ObjectAcl } from "@dimah-s3/core";
2
+ import type { DimahS3Locals } from "./locals";
3
+ /** The call a hook runs in. Plugin endpoints use `"plugin"`. */
4
+ export type S3Operation = "upload" | "confirm" | "download" | "file" | "delete" | "deleteMany" | "catalog" | "put" | "multipart.init" | "multipart.signPart" | "multipart.listParts" | "multipart.complete" | "multipart.abort" | "plugin";
5
+ /**
6
+ * How the bytes reach S3: a presigned POST or PUT, a multipart upload, or
7
+ * `s3.put` on the server.
8
+ */
9
+ export type UploadKind = "post" | "put" | "multipart" | "server";
10
+ /** Context for the instance `guard`. Every other context extends it. */
3
11
  export type GuardContext = {
4
- /** The incoming HTTP request. */
12
+ /** The incoming request, or a synthetic one for in-process calls. */
5
13
  request: Request;
14
+ operation: S3Operation;
15
+ /** Values from earlier guards in this call. See {@link DimahS3Locals}. */
16
+ locals: DimahS3Locals;
6
17
  };
7
- /** Context for a route-level `guard` (every operation on that route). */
18
+ /** Context for a route `guard`. It runs before every operation on the route. */
8
19
  export type RouteGuardContext = GuardContext & {
9
20
  /** Named file route. */
10
21
  route: string;
11
22
  };
12
- /**
13
- * Shared hook context once an object key is assigned — generated on
14
- * upload / multipart init, or supplied on confirm / download / delete /
15
- * multipart session ops.
16
- */
17
- export type StoredObjectContext = RouteGuardContext & {
23
+ /** Shared context once the object key is known. */
24
+ export type ObjectContext = RouteGuardContext & {
18
25
  /** S3 object key. */
19
26
  key: string;
20
- /** Target bucket. */
21
27
  bucket: string;
22
28
  };
23
- /** Declared file on upload / multipart init. */
24
- export type ObjectFile = {
29
+ /** File the client declared. S3 has not verified it yet. */
30
+ export type UploadFile = {
25
31
  name: string;
26
- size?: number;
32
+ size: number;
27
33
  type?: string;
28
34
  };
29
35
  /**
30
- * Input to `upload.object` on presign / multipart init.
31
- * `clientMetadata` is what the client sent — it is not written to S3
32
- * unless `object` copies it into {@link UploadObjectInfo.metadata}.
36
+ * Input to `upload.object`. `clientMetadata` is what the client sent; it is
37
+ * written to S3 only when `object` copies it into
38
+ * {@link UploadObjectInfo.metadata}.
33
39
  */
34
- export type UploadObjectContext = {
35
- request: Request;
36
- route: string;
37
- file: ObjectFile;
40
+ export type UploadObjectContext = RouteGuardContext & {
41
+ file: UploadFile;
38
42
  bucket: string;
39
43
  /**
40
- * Namespace this route writes under. `false` skips the follow-up
41
- * namespace check and generates `{uuid}/{name}` when `object` omits
42
- * `folder` / `key`.
44
+ * Namespace this route writes under. With `false`, the default key is
45
+ * `{uuid}/{name}` and follow-up keys are not namespace-checked.
43
46
  */
44
47
  keyPrefix: string | false;
45
48
  clientMetadata?: Record<string, string>;
46
49
  };
47
- /** Server-owned S3 object identity from `upload.object`. */
50
+ /** Server-owned object identity from `upload.object`. */
48
51
  export type UploadObjectInfo = {
49
52
  /**
50
- * Extra folder under the route {@link UploadObjectContext.keyPrefix}.
51
- * Nested as `{keyPrefix}/{folder}/{uuid}/{name}` unless `keyPrefix` is
52
- * `false` (`{folder}/{uuid}/{name}`). Ignored when {@link key} is set.
53
+ * Key path segment under the route `keyPrefix`:
54
+ * `{keyPrefix}/{keyFolder}/{uuid}/{name}`. Ignored when {@link key} is set.
53
55
  */
54
- folder?: string;
56
+ keyFolder?: string;
55
57
  /**
56
- * Object key, nested under {@link UploadObjectContext.keyPrefix} unless
57
- * the key is already inside that prefix or `keyPrefix` is `false`.
58
- * If omitted, `{keyPrefix}/{folder}/{uuid}/{name}` is used
59
- * (`{uuid}/{name}` when `keyPrefix` is `false` and `folder` is omitted).
58
+ * Object key, nested under the route `keyPrefix` unless it is already
59
+ * inside it or `keyPrefix` is `false`.
60
60
  */
61
61
  key?: string;
62
- /** S3 user metadata (`x-amz-meta-*`). */
63
- metadata?: Record<string, string>;
64
- /** Override the route ACL for this object. */
65
- acl?: S3ObjectAcl;
66
62
  /**
67
- * S3 storage class (`STANDARD`, `STANDARD_IA`, `INTELLIGENT_TIERING`, …).
68
- * Signed into the upload so the client cannot change it.
63
+ * S3 user metadata (`x-amz-meta-*`). Non-ASCII values are RFC 2047-encoded.
64
+ * Keys and values, including internal keys, are limited to 2048 UTF-8
65
+ * bytes in total.
69
66
  */
67
+ metadata?: Record<string, string>;
68
+ /** Overrides the route ACL for this object. */
69
+ acl?: S3ObjectAcl;
70
+ /** S3 storage class (`STANDARD_IA`, `INTELLIGENT_TIERING`, …). Signed. */
70
71
  storageClass?: string;
71
- /**
72
- * `Cache-Control` written on the object. Signed into the upload so the
73
- * client cannot set an arbitrary value.
74
- */
72
+ /** `Cache-Control` written on the object. Signed. */
75
73
  cacheControl?: string;
76
74
  /**
77
- * S3 object tags (max 10). Signed into the upload. Do not put secrets
78
- * here — the values are visible on the client for PUT/POST.
75
+ * S3 object tags (at most 10), printable ASCII only. Signed, and visible
76
+ * to the client on presigned uploads, so keep secrets out.
79
77
  */
80
78
  tagging?: Record<string, string>;
81
79
  /**
82
- * After confirm succeeds, delete this key (must stay under the route
83
- * `keyPrefix`). Use with a new generated key to rotate avatars.
80
+ * Key to delete after a successful confirm. It must stay under the route
81
+ * `keyPrefix`. Use it with a new key to replace an avatar.
84
82
  */
85
83
  previousKey?: string;
86
84
  };
87
- /** S3 headers returned from `upload.object` and forwarded onto the upload. */
85
+ /** S3 headers from `upload.object` that are signed into the upload. */
88
86
  export type ObjectS3Headers = Pick<UploadObjectInfo, "storageClass" | "cacheControl" | "tagging">;
89
87
  /**
90
- * Context for `upload.guard`.
91
- * Runs on single-shot presign and multipart init **after** `upload.object`
92
- * so `key` is already assigned (plugins like `db()` check ownership here).
93
- * Client-declared values are not verified by S3.
88
+ * Context for `upload.guard`. It runs on presign, multipart init and
89
+ * `s3.put`, after `upload.object`, so `key` is already assigned.
94
90
  */
95
- export type UploadGuardContext = StoredObjectContext & ObjectS3Headers & {
96
- /** Declared file from the presign body — same shape as `upload.object`. */
97
- file: ObjectFile;
98
- /** S3 object metadata from route `object`. */
91
+ export type UploadGuardContext = ObjectContext & ObjectS3Headers & {
92
+ kind: UploadKind;
93
+ file: UploadFile;
94
+ acl: S3ObjectAcl;
95
+ /** S3 metadata from `upload.object`. */
99
96
  metadata?: Record<string, string>;
100
- /** Client extras from the request — not written to S3 automatically. */
97
+ /** Client extras. They are never written to S3 automatically. */
101
98
  clientMetadata?: Record<string, string>;
102
- /** Resolved ACL. */
103
- acl?: S3ObjectAcl;
104
- /** Route `upload.replace`. */
105
- replace?: "overwrite";
106
- };
107
- /** Context for `upload.onPresigned` (single-shot only). */
108
- export type UploadOnPresignedContext = UploadGuardContext & {
109
- /** Presigned upload URL. */
110
- url: string;
111
- /** Validity in seconds. */
112
- expiresIn: number;
113
99
  };
114
100
  /**
115
- * Context for `upload.confirmGuard`.
116
- * Runs on single-shot confirm and multipart complete.
101
+ * Context for `upload.onStart`. It runs once the upload can begin: after
102
+ * presign, after `CreateMultipartUpload`, or before `PutObject` for
103
+ * `s3.put`. A throw cancels the upload.
117
104
  */
118
- export type UploadConfirmGuardContext = StoredObjectContext & {
119
- /** Present on multipart complete. */
105
+ export type UploadOnStartContext = UploadGuardContext & {
106
+ /** Stable id of this upload. Dedupe `onConfirmed` replays on it. */
107
+ uploadToken: string;
108
+ /** Multipart only. */
120
109
  uploadId?: string;
121
- /** Parts to assemble. Present on multipart complete. */
122
- parts?: MultipartCompletedPartRef[];
123
- /** Route `upload.replace`. */
124
- replace?: "overwrite";
125
- };
126
- /**
127
- * Context for `upload.onConfirmed`.
128
- * `contentLength` and `eTag` are verified by S3 via HeadObject.
129
- * Runs after single-shot confirm and multipart complete.
130
- */
131
- export type UploadOnConfirmedContext = StoredObjectContext & {
132
- /** MIME type from HeadObject. */
133
- contentType?: string;
134
- /** Size from HeadObject — trust this, not the presign `fileSize`. */
135
- contentLength: number;
136
- /** ETag from HeadObject. */
110
+ /** Presigned URL. POST and PUT only. */
111
+ url?: string;
112
+ /** When the presigned URL expires. POST and PUT only. */
113
+ urlExpiresAt?: Date;
114
+ /** Confirm deadline: the ticket expiry, or 15 minutes for `s3.put`. */
115
+ expiresAt: Date;
116
+ };
117
+ /** Object as HeadObject reports it. Trust these values, not the declared file. */
118
+ export type VerifiedObject = {
119
+ name?: string;
120
+ size: number;
121
+ type?: string;
137
122
  eTag?: string;
138
- /** Object metadata. */
139
- metadata?: Record<string, string>;
140
- /** ACL from the upload policy (`upload.acl` / `object`). */
141
- acl?: S3ObjectAcl;
142
- /** Stored filename. */
143
- fileName?: string;
144
- /** S3 version ID. */
145
123
  versionId?: string;
146
- /** Last modified timestamp. */
147
124
  lastModified?: string;
148
- /** Present after multipart complete. */
125
+ /** User metadata, decoded, without internal keys. */
126
+ metadata: Record<string, string>;
127
+ };
128
+ /**
129
+ * Context for `upload.confirmGuard`. It runs on confirm and multipart
130
+ * complete, after HeadObject and the size, type and content checks, so
131
+ * `object` holds the values S3 verified. A rejection deletes the object.
132
+ */
133
+ export type UploadConfirmGuardContext = ObjectContext & {
134
+ kind: Exclude<UploadKind, "server">;
135
+ uploadToken: string;
136
+ /** Multipart only. */
149
137
  uploadId?: string;
138
+ /** File declared at presign or init. Check `object` instead. */
139
+ file: UploadFile;
140
+ /** ACL from the upload policy. */
141
+ acl: S3ObjectAcl;
142
+ /** The object as HeadObject reports it. */
143
+ object: VerifiedObject;
150
144
  };
151
- /** Context for `download.resolve` and `download.guard`. */
152
- export type DownloadGuardContext = StoredObjectContext & {
153
- /** Download filename for Content-Disposition. */
154
- fileName?: string;
155
- /** Client-requested or route default disposition. */
156
- disposition?: "inline" | "attachment";
145
+ /**
146
+ * Context for `upload.onConfirmed`: the confirm guard context, and also for
147
+ * `s3.put` (`kind: "server"`). It runs at least once per upload; a retried
148
+ * confirm runs it again, so dedupe on `uploadToken`.
149
+ */
150
+ export type UploadOnConfirmedContext = Omit<UploadConfirmGuardContext, "kind"> & {
151
+ kind: UploadKind;
157
152
  /**
158
- * TTL in seconds.
159
- * `download.resolve` sees the client request when one was sent.
160
- * `download.guard` sees the TTL that will be signed
161
- * (`0` when download `mode` is `"proxy"`).
153
+ * `upload.object().previousKey`, which is deleted once every
154
+ * `onConfirmed` hook succeeds. Retire your own record of it here.
162
155
  */
156
+ previousKey?: string;
157
+ };
158
+ /** Context for `download.resolve`. */
159
+ export type DownloadResolveContext = ObjectContext & {
160
+ mode: "presign" | "proxy";
161
+ /** Download file name the client asked for. */
162
+ name?: string;
163
+ /** Requested disposition, or the route default. */
164
+ disposition: ContentDispositionType;
165
+ /** TTL the client asked for. Presign mode only. */
163
166
  expiresIn?: number;
164
167
  };
165
- /** Per-request overrides from `download.resolve`. */
168
+ /** Per-request download options from `download.resolve`. */
166
169
  export type DownloadResolveInfo = {
167
- disposition?: "inline" | "attachment";
168
- /**
169
- * Signed TTL in seconds. Replaces the route cap and any client request.
170
- * Still clamped to the instance `maxExpiresIn`. Ignored when `mode` is `"proxy"`.
171
- */
170
+ name?: string;
171
+ disposition?: ContentDispositionType;
172
+ /** Signed TTL in seconds, capped by the instance `maxExpiresIn`. Presign mode only. */
173
+ expiresIn?: number;
174
+ /** `Cache-Control` on `/file` responses. Proxy mode only. @default "private, no-cache" */
175
+ cacheControl?: string;
176
+ };
177
+ /** Context for `download.guard`, with the values that will be used. */
178
+ export type DownloadGuardContext = ObjectContext & {
179
+ mode: "presign" | "proxy";
180
+ name?: string;
181
+ disposition: ContentDispositionType;
182
+ /** Signed TTL. `undefined` in proxy mode. */
172
183
  expiresIn?: number;
173
- fileName?: string;
174
184
  };
175
185
  /** Context for `download.onPresigned`. */
176
186
  export type DownloadOnPresignedContext = DownloadGuardContext & {
177
- /** Presigned GET URL. */
187
+ /** Presigned GET URL, or the `/file` URL in proxy mode. */
178
188
  url: string;
179
- /** Validity in seconds. */
180
- expiresIn: number;
181
189
  };
182
190
  /** Context for `delete.guard`. */
183
- export type DeleteGuardContext = StoredObjectContext;
191
+ export type DeleteGuardContext = ObjectContext;
184
192
  /**
185
- * Context for `delete.onDeleted`. Delete is idempotent: this hook also runs
186
- * when the object was never uploaded or is already gone.
193
+ * Context for `delete.onDeleted`. Delete is idempotent, so this also runs
194
+ * when the object did not exist.
187
195
  */
188
- export type DeleteOnDeletedContext = StoredObjectContext & {
189
- /** `false` when HeadObject found nothing, so no `DeleteObject` was sent. */
190
- existed: boolean;
191
- };
192
- /** Shared base for multipart operations that already have an upload id. */
193
- export type MultipartUploadContext = StoredObjectContext & {
194
- /** Multipart upload ID. */
195
- uploadId: string;
196
- };
197
- /** Context for `upload.multipart.onInit`. */
198
- export type MultipartOnInitContext = UploadGuardContext & {
199
- /** Multipart upload ID. */
196
+ export type DeleteOnDeletedContext = ObjectContext;
197
+ /** Shared context for multipart calls that carry a ticket. */
198
+ export type MultipartUploadContext = ObjectContext & {
200
199
  uploadId: string;
200
+ uploadToken: string;
201
+ /** File declared at init. */
202
+ file: UploadFile;
201
203
  };
202
204
  /**
203
- * Context for `upload.multipart.guard`.
204
- * Runs on part, list, abort, and complete (init uses `upload.guard`).
205
- * Complete also runs `upload.confirmGuard`.
205
+ * Context for `upload.multipart.guard`. It runs on part signing, list,
206
+ * abort and complete. Init uses `upload.guard`.
206
207
  */
207
208
  export type MultipartGuardContext = (MultipartUploadContext & {
208
209
  action: "part";
209
210
  /** 1-based part number. */
210
211
  partNumber: number;
211
- /** Byte size locked into the presigned URL signature. */
212
- partSize: number;
213
- }) | (MultipartUploadContext & {
214
- action: "list";
212
+ /** Byte size signed into the part URL. */
213
+ size: number;
215
214
  }) | (MultipartUploadContext & {
216
- action: "abort";
217
- }) | (MultipartUploadContext & {
218
- action: "complete";
215
+ action: "list" | "abort" | "complete";
219
216
  });
220
217
  /** Context for `upload.multipart.onAbort`. */
221
218
  export type MultipartOnAbortContext = MultipartUploadContext;
222
- /** Context for `upload.multipart.onList`. */
223
- export type MultipartOnListContext = MultipartUploadContext & {
224
- /** Parts already uploaded to S3. */
225
- parts: MultipartPartInfo[];
226
- };
227
219
  //# sourceMappingURL=hook-contexts.d.ts.map
@@ -1 +1 @@
1
- {"version":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,MAAM,CAAC;CACvB,CAAC;AAEF,uEAAuE;AACvE,MAAM,MAAM,oBAAoB,GAAG,aAAa,GAAG;IACjD,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,sBAAsB,CAAC;IACpC,6CAA6C;IAC7C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,0CAA0C;AAC1C,MAAM,MAAM,0BAA0B,GAAG,oBAAoB,GAAG;IAC9D,2DAA2D;IAC3D,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,kCAAkC;AAClC,MAAM,MAAM,kBAAkB,GAAG,aAAa,CAAC;AAE/C;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAAG,aAAa,CAAC;AAEnD,8DAA8D;AAC9D,MAAM,MAAM,sBAAsB,GAAG,aAAa,GAAG;IACnD,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,6BAA6B;IAC7B,IAAI,EAAE,UAAU,CAAC;CAClB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,qBAAqB,GAC7B,CAAC,sBAAsB,GAAG;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,2BAA2B;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAC;CACd,CAAC,GACF,CAAC,sBAAsB,GAAG;IAAE,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,UAAU,CAAA;CAAE,CAAC,CAAC;AAEzE,8CAA8C;AAC9C,MAAM,MAAM,uBAAuB,GAAG,sBAAsB,CAAC"}
@@ -1,4 +1,4 @@
1
- export type { DeleteGuardContext, DeleteOnDeletedContext, DownloadGuardContext, DownloadOnPresignedContext, GuardContext, MultipartOnAbortContext, MultipartOnInitContext, MultipartOnListContext, MultipartGuardContext, MultipartUploadContext, ObjectFile, ObjectS3Headers, RouteGuardContext, StoredObjectContext, UploadConfirmGuardContext, UploadGuardContext, UploadObjectContext, UploadObjectInfo, UploadOnConfirmedContext, UploadOnPresignedContext, DownloadResolveInfo, } from "./hook-contexts";
2
- export type { DeleteConfig, DimahS3Config, DimahS3Logger, DimahS3RouteConfig, DisabledFeature, DownloadConfig, EnabledFeature, EnabledUploadConfig, FeatureToggle, MultipartConfig, OpenedRoute, ResolvedDimahS3Config, ResolvedFeature, ResolvedRoute, ResolvedUploadConfig, RouteFeature, RouteOperation, UploadConfig, } from "./config";
3
- export { ROUTE_FEATURES, ROUTE_OPERATIONS } from "./config";
1
+ export type { DeleteGuardContext, DeleteOnDeletedContext, DownloadGuardContext, DownloadOnPresignedContext, DownloadResolveContext, DownloadResolveInfo, GuardContext, MultipartGuardContext, MultipartOnAbortContext, MultipartUploadContext, ObjectContext, ObjectS3Headers, RouteGuardContext, S3Operation, UploadConfirmGuardContext, UploadFile, UploadGuardContext, UploadKind, UploadObjectContext, UploadObjectInfo, UploadOnConfirmedContext, UploadOnStartContext, VerifiedObject, } from "./hook-contexts";
2
+ export type { DeleteConfig, DimahS3Api, DimahS3Config, DimahS3Logger, DimahS3RouteConfig, DownloadConfig, FeatureToggle, MultipartConfig, PutInput, S3ServerCallOptions, TicketSubject, UploadConfig, } from "./config";
3
+ export type { DimahS3Locals, DimahS3RoutePluginOptions, Guard, GuardResult, LifecycleHook, } from "./locals";
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,kBAAkB,EAClB,sBAAsB,EACtB,oBAAoB,EACpB,0BAA0B,EAC1B,YAAY,EACZ,uBAAuB,EACvB,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB,sBAAsB,EACtB,UAAU,EACV,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,yBAAyB,EACzB,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,wBAAwB,EACxB,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,YAAY,EACZ,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,aAAa,EACb,eAAe,EACf,WAAW,EACX,qBAAqB,EACrB,eAAe,EACf,aAAa,EACb,oBAAoB,EACpB,YAAY,EACZ,cAAc,EACd,YAAY,GACb,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,kBAAkB,EAClB,sBAAsB,EACtB,oBAAoB,EACpB,0BAA0B,EAC1B,sBAAsB,EACtB,mBAAmB,EACnB,YAAY,EACZ,qBAAqB,EACrB,uBAAuB,EACvB,sBAAsB,EACtB,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,yBAAyB,EACzB,UAAU,EACV,kBAAkB,EAClB,UAAU,EACV,mBAAmB,EACnB,gBAAgB,EAChB,wBAAwB,EACxB,oBAAoB,EACpB,cAAc,GACf,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,YAAY,EACZ,UAAU,EACV,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,eAAe,EACf,QAAQ,EACR,mBAAmB,EACnB,aAAa,EACb,YAAY,GACb,MAAM,UAAU,CAAC;AAClB,YAAY,EACV,aAAa,EACb,yBAAyB,EACzB,KAAK,EACL,WAAW,EACX,aAAa,GACd,MAAM,UAAU,CAAC"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Values that guards hand to later hooks in the same call. Augment it to
3
+ * type them:
4
+ *
5
+ * ```ts
6
+ * declare module "@dimah-s3/server" {
7
+ * interface DimahS3Locals {
8
+ * userId: string;
9
+ * }
10
+ * }
11
+ * ```
12
+ *
13
+ * Each call gets its own null-prototype object. HTTP requests never set it.
14
+ */
15
+ export interface DimahS3Locals {
16
+ }
17
+ /**
18
+ * Per-route plugin options under {@link DimahS3RouteConfig.plugins}, keyed
19
+ * by plugin id. Plugins augment it (`db?: false | DbRouteOptions`). `false`
20
+ * turns the plugin off for the route.
21
+ */
22
+ export interface DimahS3RoutePluginOptions {
23
+ [pluginId: string]: false | object | undefined;
24
+ }
25
+ /**
26
+ * What a guard returns. Return nothing to allow, `{ locals }` to allow and
27
+ * pass values to later hooks, and throw to reject. Any other value is a
28
+ * config error: it is logged, the call returns `500`, and it never allows.
29
+ */
30
+ export type GuardResult = void | undefined | {
31
+ locals: Partial<DimahS3Locals>;
32
+ };
33
+ /** Authorization hook. See {@link GuardResult}. */
34
+ export type Guard<C> = (context: C) => GuardResult | Promise<GuardResult>;
35
+ /** Lifecycle `on*` hook. It runs after plugin hooks for the same slot. */
36
+ export type LifecycleHook<C> = (context: C) => void | Promise<void>;
37
+ //# sourceMappingURL=locals.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locals.d.ts","sourceRoot":"","sources":["../../src/types/locals.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,MAAM,WAAW,aAAa;CAAG;AAEjC;;;;GAIG;AACH,MAAM,WAAW,yBAAyB;IACxC,CAAC,QAAQ,EAAE,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,SAAS,CAAC;CAChD;AAED;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,IAAI,GAAG,SAAS,GAAG;IAAE,MAAM,EAAE,OAAO,CAAC,aAAa,CAAC,CAAA;CAAE,CAAC;AAEhF,mDAAmD;AACnD,MAAM,MAAM,KAAK,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,KAAK,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AAE1E,0EAA0E;AAC1E,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC"}
@@ -0,0 +1,118 @@
1
+ import type { S3Client } from "@aws-sdk/client-s3";
2
+ import type { ContentDispositionType, S3ObjectAcl, UploadPresignMethod } from "@dimah-s3/core";
3
+ import type { DimahS3Config, DimahS3Logger, DownloadConfig, TicketSubject, UploadConfig } from "./config";
4
+ import type { DeleteGuardContext, DeleteOnDeletedContext, DownloadGuardContext, DownloadOnPresignedContext, GuardContext, MultipartGuardContext, MultipartOnAbortContext, RouteGuardContext, UploadConfirmGuardContext, UploadGuardContext, UploadOnConfirmedContext, UploadOnStartContext } from "./hook-contexts";
5
+ import type { DimahS3RoutePluginOptions, Guard, LifecycleHook } from "./locals";
6
+ /**
7
+ * A route feature a call can hit. `multipart` is nested under upload, and
8
+ * `proxy` is a download in `mode: "proxy"`, the only one `/file` serves.
9
+ */
10
+ export type RouteFeature = "upload" | "download" | "delete" | "multipart" | "proxy";
11
+ /** One hook and its owner. `plugin` is the plugin id; the user hook has none. */
12
+ export type HookEntry<H> = {
13
+ plugin?: string;
14
+ hook: H;
15
+ };
16
+ /** Hooks for one slot, in run order: plugins in plugin order, then the user hook. */
17
+ export type HookList<H> = readonly HookEntry<H>[];
18
+ export type DisabledFeature = {
19
+ enabled: false;
20
+ };
21
+ export type ResolvedMultipart = {
22
+ enabled: true;
23
+ /** Preferred part size. The part layout may raise it. */
24
+ partSize?: number;
25
+ ticketExpiresIn: number;
26
+ guard: HookList<Guard<MultipartGuardContext>>;
27
+ onAbort: HookList<LifecycleHook<MultipartOnAbortContext>>;
28
+ };
29
+ export type ResolvedUpload = {
30
+ enabled: true;
31
+ fileTypes?: readonly string[];
32
+ maxFileSize?: number;
33
+ object?: UploadConfig["object"];
34
+ acl: S3ObjectAcl;
35
+ method: UploadPresignMethod;
36
+ /** URL TTL, already capped by the instance `maxExpiresIn`. */
37
+ expiresIn: number;
38
+ confirmWindow: number;
39
+ /** Effective value: `true` whenever `verifyContent` is on. */
40
+ checksum: boolean;
41
+ verifyContent: boolean;
42
+ multipart: ResolvedMultipart | DisabledFeature;
43
+ guard: HookList<Guard<UploadGuardContext>>;
44
+ onStart: HookList<LifecycleHook<UploadOnStartContext>>;
45
+ confirmGuard: HookList<Guard<UploadConfirmGuardContext>>;
46
+ onConfirmed: HookList<LifecycleHook<UploadOnConfirmedContext>>;
47
+ };
48
+ export type ResolvedDownload = {
49
+ enabled: true;
50
+ /** Already capped by the instance `maxExpiresIn`. */
51
+ maxExpiresIn: number;
52
+ disposition: ContentDispositionType;
53
+ /**
54
+ * Effective allow-list: the config value, else `DEFAULT_INLINE_TYPES`
55
+ * (without `application/pdf` in proxy mode). `false` never inlines.
56
+ */
57
+ inlineTypes: readonly string[] | false;
58
+ mode: "presign" | "proxy";
59
+ resolve?: DownloadConfig["resolve"];
60
+ guard: HookList<Guard<DownloadGuardContext>>;
61
+ onPresigned: HookList<LifecycleHook<DownloadOnPresignedContext>>;
62
+ };
63
+ export type ResolvedDelete = {
64
+ enabled: true;
65
+ guard: HookList<Guard<DeleteGuardContext>>;
66
+ onDeleted: HookList<LifecycleHook<DeleteOnDeletedContext>>;
67
+ };
68
+ export type ResolvedRoute = {
69
+ name: string;
70
+ client: S3Client;
71
+ bucket: string;
72
+ /** `false` means keys are not namespace-checked. */
73
+ keyPrefix: string | false;
74
+ /** The route `plugins` field as configured. */
75
+ plugins: DimahS3RoutePluginOptions;
76
+ guard: HookList<Guard<RouteGuardContext>>;
77
+ upload: ResolvedUpload | (DisabledFeature & {
78
+ multipart: DisabledFeature;
79
+ });
80
+ download: ResolvedDownload | DisabledFeature;
81
+ delete: ResolvedDelete | DisabledFeature;
82
+ };
83
+ /** A {@link ResolvedRoute} after the feature `F` was checked to be on. */
84
+ export type OpenedRoute<F extends RouteFeature> = ResolvedRoute & (F extends "multipart" ? {
85
+ upload: ResolvedUpload & {
86
+ multipart: ResolvedMultipart;
87
+ };
88
+ } : F extends "upload" ? {
89
+ upload: ResolvedUpload;
90
+ } : F extends "download" ? {
91
+ download: ResolvedDownload;
92
+ } : F extends "proxy" ? {
93
+ download: ResolvedDownload & {
94
+ mode: "proxy";
95
+ };
96
+ } : {
97
+ delete: ResolvedDelete;
98
+ });
99
+ export type ResolvedConfig = {
100
+ /** Normalized, without a trailing slash. */
101
+ basePath: string;
102
+ baseURL?: string;
103
+ /**
104
+ * Secrets from the config, first one signs. `undefined` means the
105
+ * environment or development fallback is resolved on first use.
106
+ */
107
+ secret?: readonly string[];
108
+ /** From the config, else the first plugin that provides one. */
109
+ ticketSubject?: TicketSubject;
110
+ maxExpiresIn: number;
111
+ maxRequestBodySize: number;
112
+ /** `false` in the config resolves to a logger with no methods. */
113
+ logger: DimahS3Logger;
114
+ onError?: DimahS3Config["onError"];
115
+ guard: HookList<Guard<GuardContext>>;
116
+ routes: Readonly<Record<string, ResolvedRoute>>;
117
+ };
118
+ //# sourceMappingURL=resolved.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolved.d.ts","sourceRoot":"","sources":["../../src/types/resolved.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EACV,sBAAsB,EACtB,WAAW,EACX,mBAAmB,EACpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EACV,aAAa,EACb,aAAa,EACb,cAAc,EACd,aAAa,EACb,YAAY,EACb,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EACV,kBAAkB,EAClB,sBAAsB,EACtB,oBAAoB,EACpB,0BAA0B,EAC1B,YAAY,EACZ,qBAAqB,EACrB,uBAAuB,EACvB,iBAAiB,EACjB,yBAAyB,EACzB,kBAAkB,EAClB,wBAAwB,EACxB,oBAAoB,EACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,yBAAyB,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAOhF;;;GAGG;AACH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,6 @@
1
1
  {
2
2
  "name": "@dimah-s3/server",
3
- "version": "1.7.0",
3
+ "version": "2.0.0-beta.0",
4
4
  "description": "Presigned S3 server — dimahS3() with HTTP handler and direct api for upload, download, delete, and multipart",
5
5
  "keywords": [
6
6
  "s3",
@@ -25,7 +25,7 @@
25
25
  "sveltekit",
26
26
  "typescript"
27
27
  ],
28
- "homepage": "https://s3.dimah.dev/docs/server",
28
+ "homepage": "https://v2.s3.dimah.dev/docs/server",
29
29
  "bugs": {
30
30
  "url": "https://github.com/dimah-kz/dimah-s3/issues"
31
31
  },
@@ -74,31 +74,27 @@
74
74
  "./plugins": {
75
75
  "types": "./dist/plugins.d.ts",
76
76
  "default": "./dist/plugins.js"
77
- },
78
- "./api": {
79
- "types": "./dist/api/index.d.ts",
80
- "default": "./dist/api/index.js"
81
77
  }
82
78
  },
83
79
  "files": [
84
80
  "dist"
85
81
  ],
86
82
  "dependencies": {
87
- "@aws-sdk/s3-presigned-post": "^3.1158.0",
88
- "@aws-sdk/s3-request-presigner": "^3.1158.0",
89
- "@dimah-s3/core": "1.7.0",
83
+ "@aws-sdk/s3-presigned-post": "^3.1161.0",
84
+ "@aws-sdk/s3-request-presigner": "^3.1161.0",
85
+ "@dimah-s3/core": "2.0.0-beta.0",
90
86
  "better-call": "1.4.4",
91
87
  "zod": "^4.6.7"
92
88
  },
93
89
  "devDependencies": {
94
- "@aws-sdk/client-s3": "^3.1158.0",
95
- "@types/node": "^26.6.5",
90
+ "@aws-sdk/client-s3": "^3.1161.0",
91
+ "@types/node": "^26.6.6",
96
92
  "@workspace/eslint-config": "0.0.1",
97
93
  "@workspace/tsup-config": "0.0.0",
98
94
  "@workspace/typescript-config": "0.0.1",
99
95
  "@workspace/vitest-config": "0.0.7",
100
- "eslint": "^10.13.0",
101
- "tsc-alias": "^1.9.9",
96
+ "eslint": "^10.14.0",
97
+ "tsc-alias": "^1.9.10",
102
98
  "tsup": "^9.0.0",
103
99
  "typescript": "7.0.2",
104
100
  "vitest": "^5.0.5"