@dimah-s3/server 1.5.9 → 1.5.11

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.
@@ -1,4 +1,4 @@
1
- import type { DimahS3 } from "../dimah-s3.d.ts";
1
+ import type { DimahS3 } from "../dimah-s3.js";
2
2
  /** Minimal surface adapters need from a dimah-s3 instance. */
3
3
  export type DimahS3HandlerSource = Pick<DimahS3, "handler">;
4
4
  //# sourceMappingURL=types.d.ts.map
@@ -3,6 +3,10 @@ import type { S3EndpointContext } from "./context";
3
3
  /**
4
4
  * Wrap better-call endpoints so `s3.api.upload({ body, headers })` injects
5
5
  * `routerContext` the same way HTTP `createRouter` does.
6
+ *
7
+ * The synthetic `Request` includes method, pathname, `query`, and a JSON
8
+ * `body`, so guards see the same request an HTTP call would. A `request`
9
+ * argument is passed through unchanged.
6
10
  */
7
11
  export declare function bindEndpoints<E extends Record<string, Endpoint>>(endpoints: E, context: Pick<S3EndpointContext, "config">): E;
8
12
  //# sourceMappingURL=bind-endpoints.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bind-endpoints.d.ts","sourceRoot":"","sources":["../../src/api/bind-endpoints.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAGnD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,EAC9D,SAAS,EAAE,CAAC,EACZ,OAAO,EAAE,IAAI,CAAC,iBAAiB,EAAE,QAAQ,CAAC,GACzC,CAAC,CAsBH"}
1
+ {"version":3,"file":"bind-endpoints.d.ts","sourceRoot":"","sources":["../../src/api/bind-endpoints.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG5C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAEnD;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,EAC9D,SAAS,EAAE,CAAC,EACZ,OAAO,EAAE,IAAI,CAAC,iBAAiB,EAAE,QAAQ,CAAC,GACzC,CAAC,CA8BH"}
@@ -1,4 +1,4 @@
1
- import type { ResolvedDimahS3Config } from "../types/index.d.ts";
1
+ import type { ResolvedDimahS3Config } from "../types/index.js";
2
2
  /**
3
3
  * Injected on every {@link createS3Endpoint} via better-call `routerContext`
4
4
  * (HTTP) and {@link bindEndpoints} (direct `s3.api` calls).
@@ -126,8 +126,9 @@ type CreateS3Endpoint = typeof createEndpointWithContext;
126
126
  * Paths are absolute under `basePath` (e.g. `/db/objects`). Context
127
127
  * (`config`, `request`) is injected by the router / `s3.api`.
128
128
  * Zod failures throw `APIError` (`VALIDATION_ERROR`) via
129
- * better-call `onValidationError`. Zod `body` / `query` schemas are
130
- * compiled with `z.compile()` so valid requests skip the interpreter.
129
+ * better-call `onValidationError`. Endpoints with a `body` set
130
+ * `cloneRequest` so hooks can still read that JSON. Zod `body` / `query`
131
+ * schemas are compiled with `z.compile()` so valid requests skip the interpreter.
131
132
  * Unsupported schemas, and runtimes that reject `new Function`, keep
132
133
  * the runtime parser.
133
134
  *
@@ -1 +1 @@
1
- {"version":3,"file":"create-s3-endpoint.d.ts","sourceRoot":"","sources":["../../src/api/create-s3-endpoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAKnE,QAAA,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAE7B,CAAC;AAwBH,KAAK,gBAAgB,GAAG,OAAO,yBAAyB,CAAC;AAEzD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,gBAAgB,EAAE,gBAgBE,CAAC"}
1
+ {"version":3,"file":"create-s3-endpoint.d.ts","sourceRoot":"","sources":["../../src/api/create-s3-endpoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAKnE,QAAA,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAE7B,CAAC;AA6BH,KAAK,gBAAgB,GAAG,OAAO,yBAAyB,CAAC;AAEzD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,gBAAgB,EAAE,gBAgBE,CAAC"}
package/dist/api/index.js CHANGED
@@ -315,8 +315,9 @@ function isEnabled(feature) {
315
315
  }
316
316
 
317
317
  // src/helpers/request.ts
318
+ var SYNTHETIC_ORIGIN = "http://dimah-s3.local";
318
319
  function requestFromHeaders(headers) {
319
- return new Request("http://dimah-s3.local", { headers });
320
+ return new Request(SYNTHETIC_ORIGIN, { headers });
320
321
  }
321
322
  function assertWithinMaxFileSize(maxFileSize, size) {
322
323
  if (typeof maxFileSize === "number" && size > maxFileSize) {
@@ -536,6 +537,9 @@ function withS3Validation(options) {
536
537
  ...options,
537
538
  ...options.body !== void 0 ? { body: compileIfZod(options.body) } : {},
538
539
  ...options.query !== void 0 ? { query: compileIfZod(options.query) } : {},
540
+ // better-call reads the body before hooks. Clone first so
541
+ // `request.clone().json()` in guard / resolveScope still works.
542
+ ...options.body !== void 0 && options.cloneRequest === void 0 ? { cloneRequest: true } : {},
539
543
  onValidationError: options.onValidationError ?? (({ message }) => {
540
544
  throw errors.validationError(message);
541
545
  })