@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.
- package/dist/adapters/types.d.ts +1 -1
- package/dist/api/bind-endpoints.d.ts +4 -0
- package/dist/api/bind-endpoints.d.ts.map +1 -1
- package/dist/api/context.d.ts +1 -1
- package/dist/api/create-s3-endpoint.d.ts +3 -2
- package/dist/api/create-s3-endpoint.d.ts.map +1 -1
- package/dist/api/index.js +5 -1
- package/dist/api/index.js.map +1 -1
- package/dist/api/router.d.ts +1 -1
- package/dist/api/routes/catalog.d.ts +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/helpers/constraints.d.ts +1 -1
- package/dist/helpers/features.d.ts +1 -1
- package/dist/helpers/finalize-confirmed.d.ts +1 -1
- package/dist/helpers/hooks.d.ts +1 -1
- package/dist/helpers/logger.d.ts +1 -1
- package/dist/helpers/object-s3.d.ts +1 -1
- package/dist/helpers/request.d.ts +14 -1
- package/dist/helpers/request.d.ts.map +1 -1
- package/dist/helpers/resolve-route.d.ts +2 -2
- package/dist/helpers/resolve-target.d.ts +1 -1
- package/dist/index.js +57 -5
- package/dist/index.js.map +1 -1
- package/dist/plugin/apply-plugins.d.ts +1 -1
- package/dist/plugin/types.d.ts +1 -1
- package/dist/plugins.js +5 -1
- package/dist/plugins.js.map +1 -1
- package/dist/put.d.ts +1 -1
- package/dist/route.d.ts +1 -1
- package/dist/types/config.d.ts +1 -1
- package/package.json +10 -10
package/dist/adapters/types.d.ts
CHANGED
|
@@ -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;
|
|
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"}
|
package/dist/api/context.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ResolvedDimahS3Config } from "../types/index.
|
|
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`.
|
|
130
|
-
*
|
|
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;
|
|
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(
|
|
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
|
})
|