@ddd-ts-kit/http 0.11.0 → 0.13.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.
- package/README.md +260 -7
- package/dist/cache/assert-cache-declaration.d.ts +9 -0
- package/dist/cache/assert-cache-declaration.d.ts.map +1 -0
- package/dist/cache/assert-cache-declaration.js +82 -0
- package/dist/cache/assert-cache-declaration.js.map +1 -0
- package/dist/cache/cache-control-of.d.ts +4 -0
- package/dist/cache/cache-control-of.d.ts.map +1 -0
- package/dist/cache/cache-control-of.js +22 -0
- package/dist/cache/cache-control-of.js.map +1 -0
- package/dist/cache/cache-declaration.d.ts +14 -0
- package/dist/cache/cache-declaration.d.ts.map +1 -0
- package/dist/cache/cache-declaration.js +2 -0
- package/dist/cache/cache-declaration.js.map +1 -0
- package/dist/cache/cache-policy.d.ts +39 -0
- package/dist/cache/cache-policy.d.ts.map +1 -0
- package/dist/cache/cache-policy.js +2 -0
- package/dist/cache/cache-policy.js.map +1 -0
- package/dist/cache/cache-scope.d.ts +11 -0
- package/dist/cache/cache-scope.d.ts.map +1 -0
- package/dist/cache/cache-scope.js +10 -0
- package/dist/cache/cache-scope.js.map +1 -0
- package/dist/cache/cache-seconds.d.ts +4 -0
- package/dist/cache/cache-seconds.d.ts.map +1 -0
- package/dist/cache/cache-seconds.js +17 -0
- package/dist/cache/cache-seconds.js.map +1 -0
- package/dist/cache/cache-tag-header.d.ts +12 -0
- package/dist/cache/cache-tag-header.d.ts.map +1 -0
- package/dist/cache/cache-tag-header.js +11 -0
- package/dist/cache/cache-tag-header.js.map +1 -0
- package/dist/cache/cache-tag-source.d.ts +17 -0
- package/dist/cache/cache-tag-source.d.ts.map +1 -0
- package/dist/cache/cache-tag-source.js +2 -0
- package/dist/cache/cache-tag-source.js.map +1 -0
- package/dist/cache/entity-tag-source.d.ts +9 -0
- package/dist/cache/entity-tag-source.d.ts.map +1 -0
- package/dist/cache/entity-tag-source.js +2 -0
- package/dist/cache/entity-tag-source.js.map +1 -0
- package/dist/cache/if-match.d.ts +11 -0
- package/dist/cache/if-match.d.ts.map +1 -0
- package/dist/cache/if-match.js +10 -0
- package/dist/cache/if-match.js.map +1 -0
- package/dist/cache/vary-of.d.ts +3 -0
- package/dist/cache/vary-of.d.ts.map +1 -0
- package/dist/cache/vary-of.js +11 -0
- package/dist/cache/vary-of.js.map +1 -0
- package/dist/controller/controller-routes.d.ts.map +1 -1
- package/dist/controller/controller-routes.js +27 -10
- package/dist/controller/controller-routes.js.map +1 -1
- package/dist/controller/controller-spec.d.ts +6 -0
- package/dist/controller/controller-spec.d.ts.map +1 -1
- package/dist/controller/declared-route.d.ts +3 -0
- package/dist/controller/declared-route.d.ts.map +1 -1
- package/dist/controller/declared-route.js +9 -0
- package/dist/controller/declared-route.js.map +1 -1
- package/dist/controller/route-group-options.d.ts +6 -0
- package/dist/controller/route-group-options.d.ts.map +1 -1
- package/dist/error/default-error-mapping.d.ts.map +1 -1
- package/dist/error/default-error-mapping.js +2 -0
- package/dist/error/default-error-mapping.js.map +1 -1
- package/dist/error/precondition-required-error.d.ts +8 -0
- package/dist/error/precondition-required-error.d.ts.map +1 -0
- package/dist/error/precondition-required-error.js +8 -0
- package/dist/error/precondition-required-error.js.map +1 -0
- package/dist/express/mount-express.d.ts.map +1 -1
- package/dist/express/mount-express.js +2 -0
- package/dist/express/mount-express.js.map +1 -1
- package/dist/fastify/mount-fastify.d.ts.map +1 -1
- package/dist/fastify/mount-fastify.js +2 -0
- package/dist/fastify/mount-fastify.js.map +1 -1
- package/dist/hono/edge-problem.d.ts +11 -0
- package/dist/hono/edge-problem.d.ts.map +1 -0
- package/dist/hono/edge-problem.js +15 -0
- package/dist/hono/edge-problem.js.map +1 -0
- package/dist/hono/hono-mount-options.d.ts +10 -0
- package/dist/hono/hono-mount-options.d.ts.map +1 -0
- package/dist/hono/hono-mount-options.js +2 -0
- package/dist/hono/hono-mount-options.js.map +1 -0
- package/dist/hono/hono-raw.d.ts +11 -0
- package/dist/hono/hono-raw.d.ts.map +1 -0
- package/dist/hono/hono-raw.js +2 -0
- package/dist/hono/hono-raw.js.map +1 -0
- package/dist/hono/mount-hono.d.ts +11 -0
- package/dist/hono/mount-hono.d.ts.map +1 -0
- package/dist/hono/mount-hono.js +65 -0
- package/dist/hono/mount-hono.js.map +1 -0
- package/dist/hono/read-body.d.ts +15 -0
- package/dist/hono/read-body.d.ts.map +1 -0
- package/dist/hono/read-body.js +58 -0
- package/dist/hono/read-body.js.map +1 -0
- package/dist/hono.d.ts +4 -0
- package/dist/hono.d.ts.map +1 -0
- package/dist/hono.js +2 -0
- package/dist/hono.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/openapi/cache-response-headers.d.ts +7 -0
- package/dist/openapi/cache-response-headers.d.ts.map +1 -0
- package/dist/openapi/cache-response-headers.js +35 -0
- package/dist/openapi/cache-response-headers.js.map +1 -0
- package/dist/openapi/cache-tags-extension.d.ts +9 -0
- package/dist/openapi/cache-tags-extension.d.ts.map +1 -0
- package/dist/openapi/cache-tags-extension.js +15 -0
- package/dist/openapi/cache-tags-extension.js.map +1 -0
- package/dist/openapi/conditional-parameters.d.ts +5 -0
- package/dist/openapi/conditional-parameters.d.ts.map +1 -0
- package/dist/openapi/conditional-parameters.js +26 -0
- package/dist/openapi/conditional-parameters.js.map +1 -0
- package/dist/openapi/definitions.d.ts +6 -1
- package/dist/openapi/definitions.d.ts.map +1 -1
- package/dist/openapi/definitions.js +12 -1
- package/dist/openapi/definitions.js.map +1 -1
- package/dist/openapi/path-items.d.ts.map +1 -1
- package/dist/openapi/path-items.js +4 -0
- package/dist/openapi/path-items.js.map +1 -1
- package/dist/openapi/responses.d.ts.map +1 -1
- package/dist/openapi/responses.js +23 -1
- package/dist/openapi/responses.js.map +1 -1
- package/dist/openapi/schema-parameters.js +1 -1
- package/dist/openapi/schema-parameters.js.map +1 -1
- package/dist/pagination/page-schema-of.d.ts +2 -1
- package/dist/pagination/page-schema-of.d.ts.map +1 -1
- package/dist/pagination/page-schema-of.js +7 -3
- package/dist/pagination/page-schema-of.js.map +1 -1
- package/dist/pipeline/assert-cached-routes.d.ts +11 -0
- package/dist/pipeline/assert-cached-routes.d.ts.map +1 -0
- package/dist/pipeline/assert-cached-routes.js +54 -0
- package/dist/pipeline/assert-cached-routes.js.map +1 -0
- package/dist/pipeline/cache-headers-of.d.ts +9 -0
- package/dist/pipeline/cache-headers-of.d.ts.map +1 -0
- package/dist/pipeline/cache-headers-of.js +24 -0
- package/dist/pipeline/cache-headers-of.js.map +1 -0
- package/dist/pipeline/cache-tags-of.d.ts +10 -0
- package/dist/pipeline/cache-tags-of.d.ts.map +1 -0
- package/dist/pipeline/cache-tags-of.js +20 -0
- package/dist/pipeline/cache-tags-of.js.map +1 -0
- package/dist/pipeline/conditional-answer.d.ts +10 -0
- package/dist/pipeline/conditional-answer.d.ts.map +1 -0
- package/dist/pipeline/conditional-answer.js +33 -0
- package/dist/pipeline/conditional-answer.js.map +1 -0
- package/dist/pipeline/entity-tag-of.d.ts +9 -0
- package/dist/pipeline/entity-tag-of.d.ts.map +1 -0
- package/dist/pipeline/entity-tag-of.js +25 -0
- package/dist/pipeline/entity-tag-of.js.map +1 -0
- package/dist/pipeline/execute-options.d.ts +23 -0
- package/dist/pipeline/execute-options.d.ts.map +1 -1
- package/dist/pipeline/execute-route.d.ts.map +1 -1
- package/dist/pipeline/execute-route.js +21 -2
- package/dist/pipeline/execute-route.js.map +1 -1
- package/dist/pipeline/expected-version-of.d.ts +10 -0
- package/dist/pipeline/expected-version-of.d.ts.map +1 -0
- package/dist/pipeline/expected-version-of.js +33 -0
- package/dist/pipeline/expected-version-of.js.map +1 -0
- package/dist/pipeline/is-not-modified.d.ts +8 -0
- package/dist/pipeline/is-not-modified.d.ts.map +1 -0
- package/dist/pipeline/is-not-modified.js +27 -0
- package/dist/pipeline/is-not-modified.js.map +1 -0
- package/dist/pipeline/last-modified-of.d.ts +3 -0
- package/dist/pipeline/last-modified-of.d.ts.map +1 -0
- package/dist/pipeline/last-modified-of.js +15 -0
- package/dist/pipeline/last-modified-of.js.map +1 -0
- package/dist/pipeline/tagged-answer.d.ts +19 -0
- package/dist/pipeline/tagged-answer.d.ts.map +1 -0
- package/dist/pipeline/tagged-answer.js +32 -0
- package/dist/pipeline/tagged-answer.js.map +1 -0
- package/dist/purgers/cache-purge-error.d.ts +11 -0
- package/dist/purgers/cache-purge-error.d.ts.map +1 -0
- package/dist/purgers/cache-purge-error.js +12 -0
- package/dist/purgers/cache-purge-error.js.map +1 -0
- package/dist/purgers/chunks-of.d.ts +3 -0
- package/dist/purgers/chunks-of.d.ts.map +1 -0
- package/dist/purgers/chunks-of.js +9 -0
- package/dist/purgers/chunks-of.js.map +1 -0
- package/dist/purgers/cloudflare-cache-purger.d.ts +20 -0
- package/dist/purgers/cloudflare-cache-purger.d.ts.map +1 -0
- package/dist/purgers/cloudflare-cache-purger.js +28 -0
- package/dist/purgers/cloudflare-cache-purger.js.map +1 -0
- package/dist/purgers/fastly-cache-purger.d.ts +19 -0
- package/dist/purgers/fastly-cache-purger.d.ts.map +1 -0
- package/dist/purgers/fastly-cache-purger.js +29 -0
- package/dist/purgers/fastly-cache-purger.js.map +1 -0
- package/dist/purgers/purge-request.d.ts +8 -0
- package/dist/purgers/purge-request.d.ts.map +1 -0
- package/dist/purgers/purge-request.js +2 -0
- package/dist/purgers/purge-request.js.map +1 -0
- package/dist/purgers/send-purge.d.ts +4 -0
- package/dist/purgers/send-purge.d.ts.map +1 -0
- package/dist/purgers/send-purge.js +19 -0
- package/dist/purgers/send-purge.js.map +1 -0
- package/dist/purgers/varnish-cache-purger.d.ts +27 -0
- package/dist/purgers/varnish-cache-purger.d.ts.map +1 -0
- package/dist/purgers/varnish-cache-purger.js +34 -0
- package/dist/purgers/varnish-cache-purger.js.map +1 -0
- package/dist/purgers/varnish-purge-mode.d.ts +13 -0
- package/dist/purgers/varnish-purge-mode.d.ts.map +1 -0
- package/dist/purgers/varnish-purge-mode.js +12 -0
- package/dist/purgers/varnish-purge-mode.js.map +1 -0
- package/dist/purgers.d.ts +6 -0
- package/dist/purgers.d.ts.map +1 -0
- package/dist/purgers.js +6 -0
- package/dist/purgers.js.map +1 -0
- package/dist/route/define-route.d.ts.map +1 -1
- package/dist/route/define-route.js +2 -0
- package/dist/route/define-route.js.map +1 -1
- package/dist/route/request-context.d.ts +2 -0
- package/dist/route/request-context.d.ts.map +1 -1
- package/dist/route/route-spec.d.ts +12 -0
- package/dist/route/route-spec.d.ts.map +1 -1
- package/dist/schemas/accepted-schema.d.ts +8 -0
- package/dist/schemas/accepted-schema.d.ts.map +1 -0
- package/dist/schemas/accepted-schema.js +20 -0
- package/dist/schemas/accepted-schema.js.map +1 -0
- package/dist/schemas/accepted.d.ts +5 -0
- package/dist/schemas/accepted.d.ts.map +1 -0
- package/dist/schemas/accepted.js +2 -0
- package/dist/schemas/accepted.js.map +1 -0
- package/dist/support/header-text.d.ts +3 -0
- package/dist/support/header-text.d.ts.map +1 -0
- package/dist/support/header-text.js +8 -0
- package/dist/support/header-text.js.map +1 -0
- package/dist/support/values-at.d.ts +6 -0
- package/dist/support/values-at.d.ts.map +1 -0
- package/dist/support/values-at.js +19 -0
- package/dist/support/values-at.js.map +1 -0
- package/dist/tenancy/first-tenant-of.d.ts +4 -1
- package/dist/tenancy/first-tenant-of.d.ts.map +1 -1
- package/dist/tenancy/first-tenant-of.js +7 -2
- package/dist/tenancy/first-tenant-of.js.map +1 -1
- package/dist/tenancy/tenant-from-header.d.ts +4 -1
- package/dist/tenancy/tenant-from-header.d.ts.map +1 -1
- package/dist/tenancy/tenant-from-header.js +6 -2
- package/dist/tenancy/tenant-from-header.js.map +1 -1
- package/dist/tenancy/tenant-resolver.d.ts +10 -1
- package/dist/tenancy/tenant-resolver.d.ts.map +1 -1
- package/package.json +19 -4
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The response header a shared cache reads the tags of an answer from: `surrogate-key` (Fastly,
|
|
3
|
+
* Varnish with xkey), `xkey` (Varnish), `cache-tag` (Cloudflare), `cdn-tag` (Bunny).
|
|
4
|
+
*/
|
|
5
|
+
export const CacheTagHeader = {
|
|
6
|
+
surrogateKey: 'surrogate-key',
|
|
7
|
+
xkey: 'xkey',
|
|
8
|
+
cacheTag: 'cache-tag',
|
|
9
|
+
cdnTag: 'cdn-tag',
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=cache-tag-header.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache-tag-header.js","sourceRoot":"","sources":["../../src/cache/cache-tag-header.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,YAAY,EAAE,eAAe;IAC7B,IAAI,EAAE,MAAM;IACZ,QAAQ,EAAE,WAAW;IACrB,MAAM,EAAE,SAAS;CACT,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A resource an answer shows, named as a cache tag so that a change of that resource purges
|
|
3
|
+
* the answer: `{ resource: 'calendar', param: 'calendarId' }` tags `calendar:<calendarId>`;
|
|
4
|
+
* `{ resource: 'appointment', field: 'items.id' }` tags each value found at that path of the
|
|
5
|
+
* body (a list is walked through); `{ resource: 'appointment' }` tags the whole kind, which a
|
|
6
|
+
* change of any appointment purges.
|
|
7
|
+
*/
|
|
8
|
+
export type CacheTagSource = {
|
|
9
|
+
readonly resource: string;
|
|
10
|
+
readonly param: string;
|
|
11
|
+
} | {
|
|
12
|
+
readonly resource: string;
|
|
13
|
+
readonly field: string;
|
|
14
|
+
} | {
|
|
15
|
+
readonly resource: string;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=cache-tag-source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache-tag-source.d.ts","sourceRoot":"","sources":["../../src/cache/cache-tag-source.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GACtB;IAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACrD;IAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACrD;IAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache-tag-source.js","sourceRoot":"","sources":["../../src/cache/cache-tag-source.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What names the version of an answer, for a conditional request: `representation`, a strong
|
|
3
|
+
* tag hashed from the bytes answered; `{ version: field }`, a weak tag made of the version the
|
|
4
|
+
* body carries under that field (the version of the read model or of the aggregate it shows).
|
|
5
|
+
*/
|
|
6
|
+
export type EntityTagSource = 'representation' | {
|
|
7
|
+
readonly version: string;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=entity-tag-source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-tag-source.d.ts","sourceRoot":"","sources":["../../src/cache/entity-tag-source.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,gBAAgB,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-tag-source.js","sourceRoot":"","sources":["../../src/cache/entity-tag-source.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether a write is conditional on the version a client read: `required`, a request without
|
|
3
|
+
* `If-Match` is refused with 428; `optional`, it runs unconditionally. Either way a tag that names
|
|
4
|
+
* another version than the current one is refused with 412 by the use case, which compares it.
|
|
5
|
+
*/
|
|
6
|
+
export declare const IfMatch: {
|
|
7
|
+
readonly required: 'required';
|
|
8
|
+
readonly optional: 'optional';
|
|
9
|
+
};
|
|
10
|
+
export type IfMatch = (typeof IfMatch)[keyof typeof IfMatch];
|
|
11
|
+
//# sourceMappingURL=if-match.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"if-match.d.ts","sourceRoot":"","sources":["../../src/cache/if-match.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,OAAO;aAClB,QAAQ,EAAE,UAAU;aACpB,QAAQ,EAAE,UAAU;CACZ,CAAC;AAEX,MAAM,MAAM,OAAO,GAAG,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,OAAO,OAAO,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether a write is conditional on the version a client read: `required`, a request without
|
|
3
|
+
* `If-Match` is refused with 428; `optional`, it runs unconditionally. Either way a tag that names
|
|
4
|
+
* another version than the current one is refused with 412 by the use case, which compares it.
|
|
5
|
+
*/
|
|
6
|
+
export const IfMatch = {
|
|
7
|
+
required: 'required',
|
|
8
|
+
optional: 'optional',
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=if-match.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"if-match.js","sourceRoot":"","sources":["../../src/cache/if-match.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,QAAQ,EAAE,UAAU;IACpB,QAAQ,EAAE,UAAU;CACZ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vary-of.d.ts","sourceRoot":"","sources":["../../src/cache/vary-of.ts"],"names":[],"mappings":"AAAA,sGAAsG;AACtG,wBAAgB,MAAM,CAAC,GAAG,KAAK,EAAE,SAAS,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,GAAG,MAAM,EAAE,CAUzE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** The request headers of several lists, once each whatever their case, in the spelling first met. */
|
|
2
|
+
export function varyOf(...lists) {
|
|
3
|
+
const byName = new Map();
|
|
4
|
+
for (const name of lists.flat()) {
|
|
5
|
+
if (!byName.has(name.toLowerCase())) {
|
|
6
|
+
byName.set(name.toLowerCase(), name);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return [...byName.values()];
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=vary-of.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vary-of.js","sourceRoot":"","sources":["../../src/cache/vary-of.ts"],"names":[],"mappings":"AAAA,sGAAsG;AACtG,MAAM,UAAU,MAAM,CAAC,GAAG,KAAqC;IAC7D,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;IAEzC,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;QAChC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC;YACpC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,IAAI,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;IAED,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller-routes.d.ts","sourceRoot":"","sources":["../../src/controller/controller-routes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"controller-routes.d.ts","sourceRoot":"","sources":["../../src/controller/controller-routes.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAQ9E;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,SAAS,CAAC,eAAe,GAAG,gBAAgB,CAAC,EAAE,EAC5D,OAAO,GAAE,uBAA4B,GACpC,SAAS,KAAK,EAAE,CAMlB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DomainError } from '@ddd-ts-kit/kernel';
|
|
2
|
+
import { assertCacheDeclaration } from '../cache/assert-cache-declaration.js';
|
|
2
3
|
import { assertUniqueRoutes } from '../route/assert-unique-routes.js';
|
|
3
4
|
import { guardRefusals } from './guard-refusals.js';
|
|
4
5
|
import { resolvedController } from './resolved-controller.js';
|
|
@@ -14,12 +15,24 @@ export function controllerRoutes(controllers, options = {}) {
|
|
|
14
15
|
return routes;
|
|
15
16
|
}
|
|
16
17
|
function routeOf(resolved, options) {
|
|
17
|
-
const {
|
|
18
|
-
const guards = options.guards === 'skip' ? [] : resolved.guards;
|
|
19
|
-
const { status, body, description } = spec.response;
|
|
18
|
+
const { spec, declared } = resolved;
|
|
20
19
|
const identity = { method: spec.method, path: declared.path, operationId: declared.operationId };
|
|
20
|
+
const security = securityOf(resolved.guards, options.security ?? DEFAULT_SECURITY);
|
|
21
|
+
const cache = declared.cache === undefined ? {} : { cache: declared.cache };
|
|
22
|
+
const ifMatch = spec.ifMatch === undefined ? {} : { ifMatch: spec.ifMatch };
|
|
23
|
+
assertCacheDeclaration({ ...identity, security, ...cache, ...ifMatch });
|
|
21
24
|
return {
|
|
22
25
|
...identity,
|
|
26
|
+
...documentationOf(resolved),
|
|
27
|
+
security,
|
|
28
|
+
...cache,
|
|
29
|
+
...ifMatch,
|
|
30
|
+
handle: handlerOf(resolved, options, identity),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function documentationOf({ spec, declared, guards }) {
|
|
34
|
+
const { status, body, description } = spec.response;
|
|
35
|
+
return {
|
|
23
36
|
summary: spec.summary,
|
|
24
37
|
...(spec.description === undefined ? {} : { description: spec.description }),
|
|
25
38
|
...(declared.tags.length === 0 ? {} : { tags: declared.tags }),
|
|
@@ -27,14 +40,18 @@ function routeOf(resolved, options) {
|
|
|
27
40
|
...requestOf(spec),
|
|
28
41
|
...(spec.upload === undefined ? {} : { upload: spec.upload }),
|
|
29
42
|
responses: { [status]: { description: description ?? defaultDescription(body), ...bodyOf(body) } },
|
|
30
|
-
errors: [...new Set([...declared.errors, ...
|
|
31
|
-
security: securityOf(resolved.guards, options.security ?? DEFAULT_SECURITY),
|
|
43
|
+
errors: [...new Set([...declared.errors, ...guards.flatMap((guard) => guard.documents?.errors ?? [])])],
|
|
32
44
|
...(spec.deprecated === true ? { deprecated: true } : {}),
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function handlerOf(resolved, options, identity) {
|
|
48
|
+
const { controller } = resolved;
|
|
49
|
+
const guards = options.guards === 'skip' ? [] : resolved.guards;
|
|
50
|
+
const { status, body } = resolved.spec.response;
|
|
51
|
+
return async (input) => {
|
|
52
|
+
await passedGuards(guards, guardRequest(identity, input));
|
|
53
|
+
const answer = await controller.handle({ ...input, actor: input.context.execution.actor });
|
|
54
|
+
return body === undefined ? { status } : { status, body: answer };
|
|
38
55
|
};
|
|
39
56
|
}
|
|
40
57
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller-routes.js","sourceRoot":"","sources":["../../src/controller/controller-routes.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"controller-routes.js","s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SAAS,UAAU,CAAC,MAAwB,EAAE,OAA0B;IACtE,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC,EAAE,CAAC;QAC7D,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,EAAE,QAAQ,IAAI,EAAE,CAAC,CAAC;IAEzE,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;AAC5D,CAAC;AAED,SAAS,YAAY,CACnB,QAA+D,EAC/D,KAAiB;IAEjB,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IAC1B,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC;IAE7C,OAAO;QACL,GAAG,QAAQ;QACX,MAAM,EAAE,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE;QAC5F,OAAO,EAAE,OAAO,CAAC,UAAU,IAAI,EAAE;QACjC,KAAK;QACL,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC;QAC7C,OAAO;KACR,CAAC;AACJ,CAAC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { Schema } from '@ddd-ts-kit/validation';
|
|
2
|
+
import type { CachePolicy } from '../cache/cache-policy.js';
|
|
3
|
+
import type { IfMatch } from '../cache/if-match.js';
|
|
2
4
|
import type { HttpMethod } from '../route/http-method.js';
|
|
3
5
|
import type { UploadSpec } from '../route/upload-spec.js';
|
|
4
6
|
import type { ControllerResponse } from './controller-response.js';
|
|
@@ -33,5 +35,9 @@ export interface ControllerSpec {
|
|
|
33
35
|
/** Run after the guards of the group. With no group, at least one is required: `[Public]` says the route is open. */
|
|
34
36
|
readonly guards?: readonly GuardReference[];
|
|
35
37
|
readonly deprecated?: boolean;
|
|
38
|
+
/** How the caches on the way may keep the answer; replaces the policy of the group. */
|
|
39
|
+
readonly cache?: CachePolicy;
|
|
40
|
+
/** A write conditional on the version the client read, handed to `handle` as `context.expectedVersion`. */
|
|
41
|
+
readonly ifMatch?: IfMatch;
|
|
36
42
|
}
|
|
37
43
|
//# sourceMappingURL=controller-spec.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller-spec.d.ts","sourceRoot":"","sources":["../../src/controller/controller-spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D,oFAAoF;AACpF,MAAM,WAAW,cAAc;IAC7B,uFAAuF;IACvF,QAAQ,CAAC,KAAK,CAAC,EAAE,eAAe,CAAC;IACjC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,yGAAyG;IACzG,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,0EAA0E;IAC1E,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC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+
import type { CachePolicy } from '../cache/cache-policy.js';
|
|
1
2
|
import type { ControllerSpec } from './controller-spec.js';
|
|
2
3
|
import type { GuardReference } from './guard-reference.js';
|
|
3
4
|
/** What a controller says once the groups above it are folded in. */
|
|
@@ -9,6 +10,8 @@ export interface DeclaredRoute {
|
|
|
9
10
|
readonly errors: readonly string[];
|
|
10
11
|
/** The class names of its route group and of every group above it, nearest first. */
|
|
11
12
|
readonly groups: readonly string[];
|
|
13
|
+
/** The policy of the controller, else, for a read, of the nearest group that declares one. */
|
|
14
|
+
readonly cache?: CachePolicy;
|
|
12
15
|
}
|
|
13
16
|
/** Folds the groups of a controller into its declaration, and refuses one that cannot stand. */
|
|
14
17
|
export declare function declaredRoute(className: string, spec: ControllerSpec): DeclaredRoute;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"declared-route.d.ts","sourceRoot":"","sources":["../../src/controller/declared-route.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"declared-route.d.ts","sourceRoot":"","sources":["../../src/controller/declared-route.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAE5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAK3D,qEAAqE;AACrE,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,QAAQ,CAAC,MAAM,EAAE,SAAS,cAAc,EAAE,CAAC;IAC3C,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,qFAAqF;IACrF,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,8FAA8F;IAC9F,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC;CAC9B;AAeD,gGAAgG;AAChG,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,aAAa,CAkBpF"}
|
|
@@ -3,11 +3,14 @@ import { ROUTE_PATH_PATTERN } from '../route/route-path-pattern.js';
|
|
|
3
3
|
import { Public } from './guards/public.js';
|
|
4
4
|
import { presentationRegistry } from './presentation-registry.js';
|
|
5
5
|
const NOTHING = { groups: [], prefix: '', tags: [], guards: [], errors: [] };
|
|
6
|
+
// The methods whose answer a cache keeps: a write of a cached group keeps the default of a write.
|
|
7
|
+
const READS = ['GET', 'HEAD'];
|
|
6
8
|
/** Folds the groups of a controller into its declaration, and refuses one that cannot stand. */
|
|
7
9
|
export function declaredRoute(className, spec) {
|
|
8
10
|
const inherited = spec.group === undefined ? NOTHING : inheritedFrom(className, spec.group);
|
|
9
11
|
const guards = [...inherited.guards, ...(spec.guards ?? [])];
|
|
10
12
|
const path = `${inherited.prefix}${spec.path === '/' && inherited.prefix !== '' ? '' : spec.path}`;
|
|
13
|
+
const cache = cacheOf(spec, inherited);
|
|
11
14
|
assertPath(className, spec.path, path);
|
|
12
15
|
assertAccess(className, guards);
|
|
13
16
|
return {
|
|
@@ -17,20 +20,26 @@ export function declaredRoute(className, spec) {
|
|
|
17
20
|
guards,
|
|
18
21
|
errors: distinct([...inherited.errors, ...(spec.errors ?? [])]),
|
|
19
22
|
groups: inherited.groups,
|
|
23
|
+
...(cache === undefined ? {} : { cache }),
|
|
20
24
|
};
|
|
21
25
|
}
|
|
26
|
+
function cacheOf(spec, inherited) {
|
|
27
|
+
return spec.cache ?? (READS.includes(spec.method) ? inherited.cache : undefined);
|
|
28
|
+
}
|
|
22
29
|
function inheritedFrom(className, group) {
|
|
23
30
|
const options = presentationRegistry().groups.get(group);
|
|
24
31
|
if (options === undefined) {
|
|
25
32
|
throw new DeclarationError(`Controller ${className}: its group ${group.name} carries no @RouteGroup.`);
|
|
26
33
|
}
|
|
27
34
|
const above = options.parent === undefined ? NOTHING : inheritedFrom(className, options.parent);
|
|
35
|
+
const cache = options.cache ?? above.cache;
|
|
28
36
|
return {
|
|
29
37
|
groups: [group.name, ...above.groups],
|
|
30
38
|
prefix: `${above.prefix}${options.prefix ?? ''}`,
|
|
31
39
|
tags: [...above.tags, ...(options.tags ?? [])],
|
|
32
40
|
guards: [...above.guards, ...(options.guards ?? [])],
|
|
33
41
|
errors: [...above.errors, ...(options.errors ?? [])],
|
|
42
|
+
...(cache === undefined ? {} : { cache }),
|
|
34
43
|
};
|
|
35
44
|
}
|
|
36
45
|
function assertPath(className, written, path) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"declared-route.js","sourceRoot":"","sources":["../../src/controller/declared-route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"declared-route.js","sourceRoot":"","sources":["../../src/controller/declared-route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAEnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGpE,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAyBlE,MAAM,OAAO,GAAc,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;AACxF,kGAAkG;AAClG,MAAM,KAAK,GAAsB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAEjD,gGAAgG;AAChG,MAAM,UAAU,aAAa,CAAC,SAAiB,EAAE,IAAoB;IACnE,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CA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AU,CAAC,SAAiB,EAAE,OAAe,EAAE,IAAY;IAClE,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACxE,MAAM,IAAI,gBAAgB,CACxB,cAAc,SAAS,eAAe,OAAO,4DAA4D,CAC1G,CAAC;IACJ,CAAC;AACH,CAAC;AAED,SAAS,YAAY,CAAC,SAAiB,EAAE,MAAiC;IACxE,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,gBAAgB,CACxB,cAAc,SAAS,sJAAsJ,CAC9K,CAAC;IACJ,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACjD,MAAM,IAAI,gBAAgB,CACxB,cAAc,SAAS,wGAAwG,CAChI,CAAC;IACJ,CAAC;AACH,CAAC;AAED,SAAS,aAAa,CAAC,SAAiB;IACtC,MAAM,IAAI,GAAG,SAAS,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;IAElD,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AAC3D,CAAC;AAED,SAAS,QAAQ,CAAC,MAAyB;IACzC,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CachePolicy } from '../cache/cache-policy.js';
|
|
1
2
|
import type { GuardReference } from './guard-reference.js';
|
|
2
3
|
import type { RouteGroupClass } from './route-group-class.js';
|
|
3
4
|
export interface RouteGroupOptions {
|
|
@@ -10,5 +11,10 @@ export interface RouteGroupOptions {
|
|
|
10
11
|
readonly guards?: readonly GuardReference[];
|
|
11
12
|
/** Error codes every route of the group may answer, such as `FORBIDDEN` behind protected use cases. */
|
|
12
13
|
readonly errors?: readonly string[];
|
|
14
|
+
/**
|
|
15
|
+
* The cache policy of every read (GET, HEAD) of the group, unless a controller declares its
|
|
16
|
+
* own; a child group may replace it. A write of the group never inherits it.
|
|
17
|
+
*/
|
|
18
|
+
readonly cache?: CachePolicy;
|
|
13
19
|
}
|
|
14
20
|
//# sourceMappingURL=route-group-options.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route-group-options.d.ts","sourceRoot":"","sources":["../../src/controller/route-group-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D,MAAM,WAAW,iBAAiB;IAChC,0GAA0G;IAC1G,QAAQ,CAAC,MAAM,CAAC,EAAE,eAAe,CAAC;IAClC,mGAAmG;IACnG,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,yFAAyF;IACzF,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,cAAc,EAAE,CAAC;IAC5C,uGAAuG;IACvG,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"route-group-options.d.ts","sourceRoot":"","sources":["../../src/controller/route-group-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D,MAAM,WAAW,iBAAiB;IAChC,0GAA0G;IAC1G,QAAQ,CAAC,MAAM,CAAC,EAAE,eAAe,CAAC;IAClC,mGAAmG;IACnG,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,yFAAyF;IACzF,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,cAAc,EAAE,CAAC;IAC5C,uGAAuG;IACvG,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC;;;OAGG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC;CAC9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-error-mapping.d.ts","sourceRoot":"","sources":["../../src/error/default-error-mapping.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,eAAO,MAAM,qBAAqB,EAAE,
|
|
1
|
+
{"version":3,"file":"default-error-mapping.d.ts","sourceRoot":"","sources":["../../src/error/default-error-mapping.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,eAAO,MAAM,qBAAqB,EAAE,YAYnC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-error-mapping.js","sourceRoot":"","sources":["../../src/error/default-error-mapping.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,qBAAqB,GAAiB;IACjD,iBAAiB,EAAE,GAAG;IACtB,SAAS,EAAE,GAAG;IACd,QAAQ,EAAE,GAAG;IACb,mBAAmB,EAAE,GAAG;IACxB,YAAY,EAAE,GAAG;IACjB,SAAS,EAAE,GAAG;IACd,cAAc,EAAE,GAAG;IACnB,cAAc,EAAE,GAAG;IACnB,sBAAsB,EAAE,GAAG;CAC5B,CAAC"}
|
|
1
|
+
{"version":3,"file":"default-error-mapping.js","sourceRoot":"","sources":["../../src/error/default-error-mapping.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,qBAAqB,GAAiB;IACjD,iBAAiB,EAAE,GAAG;IACtB,SAAS,EAAE,GAAG;IACd,QAAQ,EAAE,GAAG;IACb,mBAAmB,EAAE,GAAG;IACxB,YAAY,EAAE,GAAG;IACjB,SAAS,EAAE,GAAG;IACd,mBAAmB,EAAE,GAAG;IACxB,qBAAqB,EAAE,GAAG;IAC1B,cAAc,EAAE,GAAG;IACnB,cAAc,EAAE,GAAG;IACnB,sBAAsB,EAAE,GAAG;CAC5B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DomainError } from '@ddd-ts-kit/kernel';
|
|
2
|
+
/** The code of a write refused because it does not name the version it was made on. */
|
|
3
|
+
export declare const PRECONDITION_REQUIRED = "PRECONDITION_REQUIRED";
|
|
4
|
+
/** A route that requires `If-Match` was called without it: answered 428. */
|
|
5
|
+
export declare class PreconditionRequiredError extends DomainError {
|
|
6
|
+
readonly code = "PRECONDITION_REQUIRED";
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=precondition-required-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"precondition-required-error.d.ts","sourceRoot":"","sources":["../../src/error/precondition-required-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,uFAAuF;AACvF,eAAO,MAAM,qBAAqB,0BAA0B,CAAC;AAE7D,4EAA4E;AAC5E,qBAAa,yBAA0B,SAAQ,WAAW;IACxD,QAAQ,CAAC,IAAI,2BAAyB;CACvC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DomainError } from '@ddd-ts-kit/kernel';
|
|
2
|
+
/** The code of a write refused because it does not name the version it was made on. */
|
|
3
|
+
export const PRECONDITION_REQUIRED = 'PRECONDITION_REQUIRED';
|
|
4
|
+
/** A route that requires `If-Match` was called without it: answered 428. */
|
|
5
|
+
export class PreconditionRequiredError extends DomainError {
|
|
6
|
+
code = PRECONDITION_REQUIRED;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=precondition-required-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"precondition-required-error.js","sourceRoot":"","sources":["../../src/error/precondition-required-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,uFAAuF;AACvF,MAAM,CAAC,MAAM,qBAAqB,GAAG,uBAAuB,CAAC;AAE7D,4EAA4E;AAC5E,MAAM,OAAO,yBAA0B,SAAQ,WAAW;IAC/C,IAAI,GAAG,qBAAqB,CAAC;CACvC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mount-express.d.ts","sourceRoot":"","sources":["../../src/express/mount-express.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAqB,MAAM,SAAS,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"mount-express.d.ts","sourceRoot":"","sources":["../../src/express/mount-express.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAqB,MAAM,SAAS,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAMrE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE/C,MAAM,MAAM,mBAAmB,GAAG,cAAc,CAAC;AAMjD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,KAAK,EAAE,EAAE,OAAO,GAAE,mBAAwB,GAAG,IAAI,CAS/G"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Readable } from 'node:stream';
|
|
2
2
|
import { pipeline } from 'node:stream/promises';
|
|
3
|
+
import { assertCachedRoutes } from '../pipeline/assert-cached-routes.js';
|
|
3
4
|
import { executeRoute } from '../pipeline/execute-route.js';
|
|
4
5
|
import { serializeBody } from '../pipeline/serialize-body.js';
|
|
5
6
|
import { assertUniqueRoutes } from '../route/assert-unique-routes.js';
|
|
@@ -11,6 +12,7 @@ import { assertUniqueRoutes } from '../route/assert-unique-routes.js';
|
|
|
11
12
|
*/
|
|
12
13
|
export function mountExpress(target, routes, options = {}) {
|
|
13
14
|
assertUniqueRoutes(routes);
|
|
15
|
+
assertCachedRoutes(routes, options);
|
|
14
16
|
const register = registrarOf(target);
|
|
15
17
|
for (const route of routes) {
|
|
16
18
|
register[route.method](route.path, handlerOf(route, options));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mount-express.js","sourceRoot":"","sources":["../../src/express/mount-express.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGhD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAUtE;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,MAAe,EAAE,MAAwB,EAAE,OAAO,GAAwB,EAAE;IACvG,kBAAkB,CAAC,MAAM,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"mount-express.js","sourceRoot":"","sources":["../../src/express/mount-express.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGhD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,kBAAkB,E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":["../../src/fastify/mount-fastify.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAK/C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEtE;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,eAAe,EACzB,MAAM,EAAE,SAAS,KAAK,EAAE,EACxB,OAAO,GAAE,mBAAwB,GAChC,IAAI,CAuBN"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Readable } from 'node:stream';
|
|
2
|
+
import { assertCachedRoutes } from '../pipeline/assert-cached-routes.js';
|
|
2
3
|
import { executeRoute } from '../pipeline/execute-route.js';
|
|
3
4
|
import { serializeBody } from '../pipeline/serialize-body.js';
|
|
4
5
|
import { assertUniqueRoutes } from '../route/assert-unique-routes.js';
|
|
@@ -9,6 +10,7 @@ import { assertUniqueRoutes } from '../route/assert-unique-routes.js';
|
|
|
9
10
|
*/
|
|
10
11
|
export function mountFastify(instance, routes, options = {}) {
|
|
11
12
|
assertUniqueRoutes(routes);
|
|
13
|
+
assertCachedRoutes(routes, options);
|
|
12
14
|
const streamed = routes.filter(readsItsStream);
|
|
13
15
|
register(instance, routes.filter((route) => !readsItsStream(route)), options);
|
|
14
16
|
if (streamed.length > 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mount-fastify.js","sourceRoot":"","sources":["../../src/fastify/mount-fastify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAItE;;;;GAIG;AACH,MAAM,UAAU,YAAY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AAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC;AAED,SAAS,cAAc,CAAC,KAAY;IAClC,OAAO,KAAK,CAAC,MAAM,KAAK,SAAS,IAAI,KAAK,CAAC,OAAO,KAAK,IAAI,CAAC;AAC9D,CAAC;AAED,SAAS,QAAQ,CAAC,QAAyB,EAAE,MAAwB,EAAE,OAA4B;IACjG,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,QAAQ,CAAC,KAAK,CAAC;YACb,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,GAAG,EAAE,KAAK,CAAC,IAAI;YACf,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;gBAChC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;gBACjD,MAAM,GAAG,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC;gBAChF,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;gBACvD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,YAAY,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;gBAEnF,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACtE,CAAC;SACF,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { RawHeaders } from '../route/raw-headers.js';
|
|
2
|
+
/** A request the adapter refuses before the pipeline runs: its status, its code and what is wrong. */
|
|
3
|
+
export interface EdgeRefusal {
|
|
4
|
+
readonly status: number;
|
|
5
|
+
readonly title: string;
|
|
6
|
+
readonly code: string;
|
|
7
|
+
readonly detail: string;
|
|
8
|
+
}
|
|
9
|
+
/** The answer to a request refused at the edge: a problem document, as every other refusal. */
|
|
10
|
+
export declare function edgeProblem(headers: RawHeaders, refusal: EdgeRefusal): Response;
|
|
11
|
+
//# sourceMappingURL=edge-problem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edge-problem.d.ts","sourceRoot":"","sources":["../../src/hono/edge-problem.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1D,sGAAsG;AACtG,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,+FAA+F;AAC/F,wBAAgB,WAAW,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,GAAG,QAAQ,CAW/E"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CORRELATION_HEADER } from '../pipeline/correlation-header.js';
|
|
2
|
+
import { wellFormedIdentifier } from '../pipeline/well-formed-identifier.js';
|
|
3
|
+
/** The answer to a request refused at the edge: a problem document, as every other refusal. */
|
|
4
|
+
export function edgeProblem(headers, refusal) {
|
|
5
|
+
const requestId = wellFormedIdentifier(headers['x-request-id']) ?? globalThis.crypto.randomUUID();
|
|
6
|
+
const problem = { type: 'about:blank', ...refusal, requestId };
|
|
7
|
+
return new Response(JSON.stringify(problem), {
|
|
8
|
+
status: refusal.status,
|
|
9
|
+
headers: {
|
|
10
|
+
'content-type': 'application/problem+json',
|
|
11
|
+
[CORRELATION_HEADER]: wellFormedIdentifier(headers[CORRELATION_HEADER]) ?? requestId,
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=edge-problem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edge-problem.js","sourceRoot":"","sources":["../../src/hono/edge-problem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAW7E,+FAA+F;AAC/F,MAAM,UAAU,WAAW,CAAC,OAAmB,EAAE,OAAoB;IACnE,MAAM,SAAS,GAAG,oBAAoB,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;IAClG,MAAM,OAAO,GAAG,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,OAAO,EAAE,SAAS,EAAE,CAAC;IAE/D,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE;QAC3C,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,OAAO,EAAE;YACP,cAAc,EAAE,0BAA0B;YAC1C,CAAC,kBAAkB,CAAC,EAAE,oBAAoB,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,IAAI,SAAS;SACrF;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ExecuteOptions } from '../pipeline/execute-options.js';
|
|
2
|
+
export interface HonoMountOptions extends ExecuteOptions {
|
|
3
|
+
/**
|
|
4
|
+
* The largest JSON body read, in bytes: a larger one is answered 413 as a problem
|
|
5
|
+
* (`BODY_TOO_LARGE`) before the pipeline runs, without being held in memory. 1 MiB by default,
|
|
6
|
+
* the limit of Fastify; Express answers beyond 100 kB. An upload has the limit its route declares.
|
|
7
|
+
*/
|
|
8
|
+
readonly bodyLimit?: number;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=hono-mount-options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hono-mount-options.d.ts","sourceRoot":"","sources":["../../src/hono/hono-mount-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAErE,MAAM,WAAW,gBAAiB,SAAQ,cAAc;IACtD;;;;OAIG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hono-mount-options.js","sourceRoot":"","sources":["../../src/hono/hono-mount-options.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Context } from 'hono';
|
|
2
|
+
import type { RawHeaders } from '../route/raw-headers.js';
|
|
3
|
+
/**
|
|
4
|
+
* What `resolvePrincipal` and the hooks receive as the request on Hono: the headers as a plain
|
|
5
|
+
* record, which the authenticators of the kit read, and the context of Hono for the rest.
|
|
6
|
+
*/
|
|
7
|
+
export interface HonoRaw {
|
|
8
|
+
readonly headers: RawHeaders;
|
|
9
|
+
readonly context: Context;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=hono-raw.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hono-raw.d.ts","sourceRoot":"","sources":["../../src/hono/hono-raw.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1D;;;GAGG;AACH,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hono-raw.js","sourceRoot":"","sources":["../../src/hono/hono-raw.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Hono } from 'hono';
|
|
2
|
+
import type { Route } from '../route/route.js';
|
|
3
|
+
import type { HonoMountOptions } from './hono-mount-options.js';
|
|
4
|
+
/**
|
|
5
|
+
* Registers the routes on a Hono application. The adapter reads the JSON body itself, up to
|
|
6
|
+
* `bodyLimit` (1 MiB by default): a larger body is answered 413 and a body that is not JSON 400,
|
|
7
|
+
* both as problems, before the pipeline runs. An upload and a raw body are read from the
|
|
8
|
+
* request stream; a body that is a stream is streamed to the response.
|
|
9
|
+
*/
|
|
10
|
+
export declare function mountHono(app: Pick<Hono, 'on'>, routes: readonly Route[], options?: HonoMountOptions): void;
|
|
11
|
+
//# sourceMappingURL=mount-hono.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mount-hono.d.ts","sourceRoot":"","sources":["../../src/hono/mount-hono.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAW,IAAI,EAAE,MAAM,MAAM,CAAC;AAM1C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAShE;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,SAAS,KAAK,EAAE,EAAE,OAAO,GAAE,gBAAqB,GAAG,IAAI,CAM/G"}
|