@ddd-ts-kit/http 0.13.0 → 0.15.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 +320 -9
- package/dist/controller/controller-routes.d.ts.map +1 -1
- package/dist/controller/controller-routes.js +8 -0
- package/dist/controller/controller-routes.js.map +1 -1
- package/dist/controller/controller-spec.d.ts +7 -0
- package/dist/controller/controller-spec.d.ts.map +1 -1
- package/dist/error/default-error-mapping.d.ts.map +1 -1
- package/dist/error/default-error-mapping.js +1 -0
- package/dist/error/default-error-mapping.js.map +1 -1
- package/dist/express/mount-express.d.ts +4 -2
- package/dist/express/mount-express.d.ts.map +1 -1
- package/dist/express/mount-express.js +25 -11
- package/dist/express/mount-express.js.map +1 -1
- package/dist/fastify/mount-fastify.d.ts +2 -1
- package/dist/fastify/mount-fastify.d.ts.map +1 -1
- package/dist/fastify/mount-fastify.js +23 -4
- package/dist/fastify/mount-fastify.js.map +1 -1
- package/dist/field-access/assert-writable.d.ts +8 -0
- package/dist/field-access/assert-writable.d.ts.map +1 -0
- package/dist/field-access/assert-writable.js +29 -0
- package/dist/field-access/assert-writable.js.map +1 -0
- package/dist/field-access/field-access-entry.d.ts +7 -0
- package/dist/field-access/field-access-entry.d.ts.map +1 -0
- package/dist/field-access/field-access-entry.js +2 -0
- package/dist/field-access/field-access-entry.js.map +1 -0
- package/dist/field-access/field-access.d.ts +13 -0
- package/dist/field-access/field-access.d.ts.map +1 -0
- package/dist/field-access/field-access.js +41 -0
- package/dist/field-access/field-access.js.map +1 -0
- package/dist/field-access/field-decider-of.d.ts +37 -0
- package/dist/field-access/field-decider-of.d.ts.map +1 -0
- package/dist/field-access/field-decider-of.js +30 -0
- package/dist/field-access/field-decider-of.js.map +1 -0
- package/dist/field-access/field-decider.d.ts +4 -0
- package/dist/field-access/field-decider.d.ts.map +1 -0
- package/dist/field-access/field-decider.js +2 -0
- package/dist/field-access/field-decider.js.map +1 -0
- package/dist/field-access/field-judge.d.ts +33 -0
- package/dist/field-access/field-judge.d.ts.map +1 -0
- package/dist/field-access/field-judge.js +81 -0
- package/dist/field-access/field-judge.js.map +1 -0
- package/dist/field-access/field-policy.d.ts +15 -0
- package/dist/field-access/field-policy.d.ts.map +1 -0
- package/dist/field-access/field-policy.js +2 -0
- package/dist/field-access/field-policy.js.map +1 -0
- package/dist/field-access/field-question.d.ts +18 -0
- package/dist/field-access/field-question.d.ts.map +1 -0
- package/dist/field-access/field-question.js +2 -0
- package/dist/field-access/field-question.js.map +1 -0
- package/dist/field-access/field-requirement.d.ts +13 -0
- package/dist/field-access/field-requirement.d.ts.map +1 -0
- package/dist/field-access/field-requirement.js +2 -0
- package/dist/field-access/field-requirement.js.map +1 -0
- package/dist/field-access/field-rule.d.ts +11 -0
- package/dist/field-access/field-rule.d.ts.map +1 -0
- package/dist/field-access/field-rule.js +2 -0
- package/dist/field-access/field-rule.js.map +1 -0
- package/dist/field-access/field-rules.d.ts +6 -0
- package/dist/field-access/field-rules.d.ts.map +1 -0
- package/dist/field-access/field-rules.js +2 -0
- package/dist/field-access/field-rules.js.map +1 -0
- package/dist/field-access/field-tree.d.ts +16 -0
- package/dist/field-access/field-tree.d.ts.map +1 -0
- package/dist/field-access/field-tree.js +28 -0
- package/dist/field-access/field-tree.js.map +1 -0
- package/dist/field-access/visible-body.d.ts +9 -0
- package/dist/field-access/visible-body.d.ts.map +1 -0
- package/dist/field-access/visible-body.js +42 -0
- package/dist/field-access/visible-body.js.map +1 -0
- package/dist/field-access/with-field-access.d.ts +17 -0
- package/dist/field-access/with-field-access.d.ts.map +1 -0
- package/dist/field-access/with-field-access.js +63 -0
- package/dist/field-access/with-field-access.js.map +1 -0
- package/dist/forms/assert-hints.d.ts +12 -0
- package/dist/forms/assert-hints.d.ts.map +1 -0
- package/dist/forms/assert-hints.js +32 -0
- package/dist/forms/assert-hints.js.map +1 -0
- package/dist/forms/assert-opens.d.ts +16 -0
- package/dist/forms/assert-opens.d.ts.map +1 -0
- package/dist/forms/assert-opens.js +24 -0
- package/dist/forms/assert-opens.js.map +1 -0
- package/dist/forms/constraints-of.d.ts +4 -0
- package/dist/forms/constraints-of.d.ts.map +1 -0
- package/dist/forms/constraints-of.js +24 -0
- package/dist/forms/constraints-of.js.map +1 -0
- package/dist/forms/define-form.d.ts +20 -0
- package/dist/forms/define-form.d.ts.map +1 -0
- package/dist/forms/define-form.js +8 -0
- package/dist/forms/define-form.js.map +1 -0
- package/dist/forms/field-block.d.ts +33 -0
- package/dist/forms/field-block.d.ts.map +1 -0
- package/dist/forms/field-block.js +2 -0
- package/dist/forms/field-block.js.map +1 -0
- package/dist/forms/field-hint.d.ts +18 -0
- package/dist/forms/field-hint.d.ts.map +1 -0
- package/dist/forms/field-hint.js +2 -0
- package/dist/forms/field-hint.js.map +1 -0
- package/dist/forms/field-lookup.d.ts +7 -0
- package/dist/forms/field-lookup.d.ts.map +1 -0
- package/dist/forms/field-lookup.js +2 -0
- package/dist/forms/field-lookup.js.map +1 -0
- package/dist/forms/form-block.d.ts +5 -0
- package/dist/forms/form-block.d.ts.map +1 -0
- package/dist/forms/form-block.js +2 -0
- package/dist/forms/form-block.js.map +1 -0
- package/dist/forms/form-condition.d.ts +9 -0
- package/dist/forms/form-condition.d.ts.map +1 -0
- package/dist/forms/form-condition.js +2 -0
- package/dist/forms/form-condition.js.map +1 -0
- package/dist/forms/form-describer.d.ts +35 -0
- package/dist/forms/form-describer.d.ts.map +1 -0
- package/dist/forms/form-describer.js +132 -0
- package/dist/forms/form-describer.js.map +1 -0
- package/dist/forms/form-description.d.ts +17 -0
- package/dist/forms/form-description.d.ts.map +1 -0
- package/dist/forms/form-description.js +2 -0
- package/dist/forms/form-description.js.map +1 -0
- package/dist/forms/form-document.d.ts +9 -0
- package/dist/forms/form-document.d.ts.map +1 -0
- package/dist/forms/form-document.js +2 -0
- package/dist/forms/form-document.js.map +1 -0
- package/dist/forms/form-documents-of.d.ts +10 -0
- package/dist/forms/form-documents-of.d.ts.map +1 -0
- package/dist/forms/form-documents-of.js +22 -0
- package/dist/forms/form-documents-of.js.map +1 -0
- package/dist/forms/form-format.d.ts +7 -0
- package/dist/forms/form-format.d.ts.map +1 -0
- package/dist/forms/form-format.js +3 -0
- package/dist/forms/form-format.js.map +1 -0
- package/dist/forms/form-group-hint.d.ts +8 -0
- package/dist/forms/form-group-hint.d.ts.map +1 -0
- package/dist/forms/form-group-hint.js +2 -0
- package/dist/forms/form-group-hint.js.map +1 -0
- package/dist/forms/form-hints.d.ts +16 -0
- package/dist/forms/form-hints.d.ts.map +1 -0
- package/dist/forms/form-hints.js +2 -0
- package/dist/forms/form-hints.js.map +1 -0
- package/dist/forms/form-of-route.d.ts +17 -0
- package/dist/forms/form-of-route.d.ts.map +1 -0
- package/dist/forms/form-of-route.js +47 -0
- package/dist/forms/form-of-route.js.map +1 -0
- package/dist/forms/form-query-schema.d.ts +10 -0
- package/dist/forms/form-query-schema.d.ts.map +1 -0
- package/dist/forms/form-query-schema.js +58 -0
- package/dist/forms/form-query-schema.js.map +1 -0
- package/dist/forms/form-query.d.ts +7 -0
- package/dist/forms/form-query.d.ts.map +1 -0
- package/dist/forms/form-query.js +2 -0
- package/dist/forms/form-query.js.map +1 -0
- package/dist/forms/form-requirement.d.ts +18 -0
- package/dist/forms/form-requirement.d.ts.map +1 -0
- package/dist/forms/form-requirement.js +2 -0
- package/dist/forms/form-requirement.js.map +1 -0
- package/dist/forms/form-routes.d.ts +19 -0
- package/dist/forms/form-routes.d.ts.map +1 -0
- package/dist/forms/form-routes.js +67 -0
- package/dist/forms/form-routes.js.map +1 -0
- package/dist/forms/form-schema.d.ts +4 -0
- package/dist/forms/form-schema.d.ts.map +1 -0
- package/dist/forms/form-schema.js +52 -0
- package/dist/forms/form-schema.js.map +1 -0
- package/dist/forms/group-block.d.ts +9 -0
- package/dist/forms/group-block.d.ts.map +1 -0
- package/dist/forms/group-block.js +2 -0
- package/dist/forms/group-block.js.map +1 -0
- package/dist/forms/json-form.d.ts +8 -0
- package/dist/forms/json-form.d.ts.map +1 -0
- package/dist/forms/json-form.js +2 -0
- package/dist/forms/json-form.js.map +1 -0
- package/dist/forms/json-forms-of.d.ts +12 -0
- package/dist/forms/json-forms-of.d.ts.map +1 -0
- package/dist/forms/json-forms-of.js +129 -0
- package/dist/forms/json-forms-of.js.map +1 -0
- package/dist/forms/lookups-of.d.ts +5 -0
- package/dist/forms/lookups-of.d.ts.map +1 -0
- package/dist/forms/lookups-of.js +7 -0
- package/dist/forms/lookups-of.js.map +1 -0
- package/dist/forms/widget-of.d.ts +5 -0
- package/dist/forms/widget-of.d.ts.map +1 -0
- package/dist/forms/widget-of.js +25 -0
- package/dist/forms/widget-of.js.map +1 -0
- package/dist/forms/widget.d.ts +3 -0
- package/dist/forms/widget.d.ts.map +1 -0
- package/dist/forms/widget.js +2 -0
- package/dist/forms/widget.js.map +1 -0
- package/dist/hono/mount-hono.d.ts +4 -2
- package/dist/hono/mount-hono.d.ts.map +1 -1
- package/dist/hono/mount-hono.js +19 -7
- package/dist/hono/mount-hono.js.map +1 -1
- package/dist/hono/read-body.d.ts +4 -3
- package/dist/hono/read-body.d.ts.map +1 -1
- package/dist/hono/read-body.js +12 -5
- package/dist/hono/read-body.js.map +1 -1
- package/dist/index.d.ts +42 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -1
- package/dist/openapi/cache-response-headers.d.ts +5 -2
- package/dist/openapi/cache-response-headers.d.ts.map +1 -1
- package/dist/openapi/cache-response-headers.js +10 -5
- package/dist/openapi/cache-response-headers.js.map +1 -1
- package/dist/openapi/documenting.d.ts +11 -0
- package/dist/openapi/documenting.d.ts.map +1 -0
- package/dist/openapi/documenting.js +2 -0
- package/dist/openapi/documenting.js.map +1 -0
- package/dist/openapi/generate-open-api.d.ts +7 -0
- package/dist/openapi/generate-open-api.d.ts.map +1 -1
- package/dist/openapi/generate-open-api.js +5 -1
- package/dist/openapi/generate-open-api.js.map +1 -1
- package/dist/openapi/path-items.d.ts +2 -3
- package/dist/openapi/path-items.d.ts.map +1 -1
- package/dist/openapi/path-items.js +8 -7
- package/dist/openapi/path-items.js.map +1 -1
- package/dist/openapi/request-body.d.ts +6 -3
- package/dist/openapi/request-body.d.ts.map +1 -1
- package/dist/openapi/request-body.js +13 -3
- package/dist/openapi/request-body.js.map +1 -1
- package/dist/openapi/responses.d.ts +2 -3
- package/dist/openapi/responses.d.ts.map +1 -1
- package/dist/openapi/responses.js +40 -12
- package/dist/openapi/responses.js.map +1 -1
- package/dist/pagination/every-page.d.ts +15 -0
- package/dist/pagination/every-page.d.ts.map +1 -0
- package/dist/pagination/every-page.js +21 -0
- package/dist/pagination/every-page.js.map +1 -0
- 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 +6 -2
- package/dist/pagination/page-schema-of.js.map +1 -1
- package/dist/pipeline/assert-cached-routes.d.ts +4 -2
- package/dist/pipeline/assert-cached-routes.d.ts.map +1 -1
- package/dist/pipeline/assert-cached-routes.js +46 -8
- package/dist/pipeline/assert-cached-routes.js.map +1 -1
- package/dist/pipeline/conditional-answer.d.ts +7 -2
- package/dist/pipeline/conditional-answer.d.ts.map +1 -1
- package/dist/pipeline/conditional-answer.js +10 -6
- package/dist/pipeline/conditional-answer.js.map +1 -1
- package/dist/pipeline/entity-tag-of.d.ts +3 -3
- package/dist/pipeline/entity-tag-of.d.ts.map +1 -1
- package/dist/pipeline/entity-tag-of.js +4 -4
- package/dist/pipeline/entity-tag-of.js.map +1 -1
- package/dist/pipeline/error-context.d.ts +6 -1
- package/dist/pipeline/error-context.d.ts.map +1 -1
- package/dist/pipeline/execute-options.d.ts +17 -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 +121 -35
- package/dist/pipeline/execute-route.js.map +1 -1
- package/dist/pipeline/iterated-within.d.ts +9 -0
- package/dist/pipeline/iterated-within.d.ts.map +1 -0
- package/dist/pipeline/iterated-within.js +17 -0
- package/dist/pipeline/iterated-within.js.map +1 -0
- package/dist/pipeline/negotiated-vary.d.ts +6 -0
- package/dist/pipeline/negotiated-vary.d.ts.map +1 -0
- package/dist/pipeline/negotiated-vary.js +15 -0
- package/dist/pipeline/negotiated-vary.js.map +1 -0
- package/dist/pipeline/negotiation.d.ts +19 -0
- package/dist/pipeline/negotiation.d.ts.map +1 -0
- package/dist/pipeline/negotiation.js +19 -0
- package/dist/pipeline/negotiation.js.map +1 -0
- package/dist/pipeline/primed.d.ts +6 -0
- package/dist/pipeline/primed.d.ts.map +1 -0
- package/dist/pipeline/primed.js +20 -0
- package/dist/pipeline/primed.js.map +1 -0
- package/dist/pipeline/read-body.d.ts +10 -0
- package/dist/pipeline/read-body.d.ts.map +1 -0
- package/dist/pipeline/read-body.js +33 -0
- package/dist/pipeline/read-body.js.map +1 -0
- package/dist/pipeline/reported-stream.d.ts +6 -0
- package/dist/pipeline/reported-stream.d.ts.map +1 -0
- package/dist/pipeline/reported-stream.js +14 -0
- package/dist/pipeline/reported-stream.js.map +1 -0
- package/dist/pipeline/represented-answer.d.ts +7 -0
- package/dist/pipeline/represented-answer.d.ts.map +1 -0
- package/dist/pipeline/represented-answer.js +2 -0
- package/dist/pipeline/represented-answer.js.map +1 -0
- package/dist/pipeline/represented.d.ts +7 -0
- package/dist/pipeline/represented.d.ts.map +1 -0
- package/dist/pipeline/represented.js +19 -0
- package/dist/pipeline/represented.js.map +1 -0
- package/dist/pipeline/route-response.d.ts +2 -0
- package/dist/pipeline/route-response.d.ts.map +1 -1
- package/dist/pipeline/tagged-answer.d.ts +5 -2
- package/dist/pipeline/tagged-answer.d.ts.map +1 -1
- package/dist/pipeline/tagged-answer.js +1 -1
- package/dist/pipeline/tagged-answer.js.map +1 -1
- package/dist/pipeline/write-stream.d.ts +8 -0
- package/dist/pipeline/write-stream.d.ts.map +1 -0
- package/dist/pipeline/write-stream.js +23 -0
- package/dist/pipeline/write-stream.js.map +1 -0
- package/dist/pipeline/written-in.d.ts +10 -0
- package/dist/pipeline/written-in.d.ts.map +1 -0
- package/dist/pipeline/written-in.js +17 -0
- package/dist/pipeline/written-in.js.map +1 -0
- package/dist/representation/assert-served.d.ts +10 -0
- package/dist/representation/assert-served.d.ts.map +1 -0
- package/dist/representation/assert-served.js +18 -0
- package/dist/representation/assert-served.js.map +1 -0
- package/dist/representation/body-shape.d.ts +9 -0
- package/dist/representation/body-shape.d.ts.map +1 -0
- package/dist/representation/body-shape.js +2 -0
- package/dist/representation/body-shape.js.map +1 -0
- package/dist/representation/csv/csv-cell.d.ts +8 -0
- package/dist/representation/csv/csv-cell.d.ts.map +1 -0
- package/dist/representation/csv/csv-cell.js +19 -0
- package/dist/representation/csv/csv-cell.js.map +1 -0
- package/dist/representation/csv/csv-representation.d.ts +16 -0
- package/dist/representation/csv/csv-representation.d.ts.map +1 -0
- package/dist/representation/csv/csv-representation.js +54 -0
- package/dist/representation/csv/csv-representation.js.map +1 -0
- package/dist/representation/is-json-media-type.d.ts +3 -0
- package/dist/representation/is-json-media-type.d.ts.map +1 -0
- package/dist/representation/is-json-media-type.js +5 -0
- package/dist/representation/is-json-media-type.js.map +1 -0
- package/dist/representation/json-representation.d.ts +14 -0
- package/dist/representation/json-representation.d.ts.map +1 -0
- package/dist/representation/json-representation.js +40 -0
- package/dist/representation/json-representation.js.map +1 -0
- package/dist/representation/malformed-body.d.ts +4 -0
- package/dist/representation/malformed-body.d.ts.map +1 -0
- package/dist/representation/malformed-body.js +6 -0
- package/dist/representation/malformed-body.js.map +1 -0
- package/dist/representation/media-type-of.d.ts +3 -0
- package/dist/representation/media-type-of.d.ts.map +1 -0
- package/dist/representation/media-type-of.js +7 -0
- package/dist/representation/media-type-of.js.map +1 -0
- package/dist/representation/negotiate.d.ts +8 -0
- package/dist/representation/negotiate.d.ts.map +1 -0
- package/dist/representation/negotiate.js +55 -0
- package/dist/representation/negotiate.js.map +1 -0
- package/dist/representation/not-acceptable-error.d.ts +7 -0
- package/dist/representation/not-acceptable-error.d.ts.map +1 -0
- package/dist/representation/not-acceptable-error.js +7 -0
- package/dist/representation/not-acceptable-error.js.map +1 -0
- package/dist/representation/problem-shape.d.ts +4 -0
- package/dist/representation/problem-shape.d.ts.map +1 -0
- package/dist/representation/problem-shape.js +7 -0
- package/dist/representation/problem-shape.js.map +1 -0
- package/dist/representation/representation.d.ts +20 -0
- package/dist/representation/representation.d.ts.map +1 -0
- package/dist/representation/representation.js +9 -0
- package/dist/representation/representation.js.map +1 -0
- package/dist/representation/representations.d.ts +33 -0
- package/dist/representation/representations.d.ts.map +1 -0
- package/dist/representation/representations.js +85 -0
- package/dist/representation/representations.js.map +1 -0
- package/dist/representation/represented-body.d.ts +3 -0
- package/dist/representation/represented-body.d.ts.map +1 -0
- package/dist/representation/represented-body.js +2 -0
- package/dist/representation/represented-body.js.map +1 -0
- package/dist/representation/stream-schema-of.d.ts +10 -0
- package/dist/representation/stream-schema-of.d.ts.map +1 -0
- package/dist/representation/stream-schema-of.js +31 -0
- package/dist/representation/stream-schema-of.js.map +1 -0
- package/dist/representation/unsupported-media-type-error.d.ts +7 -0
- package/dist/representation/unsupported-media-type-error.d.ts.map +1 -0
- package/dist/representation/unsupported-media-type-error.js +7 -0
- package/dist/representation/unsupported-media-type-error.js.map +1 -0
- package/dist/representation/wire-text.d.ts +7 -0
- package/dist/representation/wire-text.d.ts.map +1 -0
- package/dist/representation/wire-text.js +21 -0
- package/dist/representation/wire-text.js.map +1 -0
- package/dist/representation/xml/decode-entities.d.ts +3 -0
- package/dist/representation/xml/decode-entities.d.ts.map +1 -0
- package/dist/representation/xml/decode-entities.js +38 -0
- package/dist/representation/xml/decode-entities.js.map +1 -0
- package/dist/representation/xml/is-xml-name.d.ts +3 -0
- package/dist/representation/xml/is-xml-name.d.ts.map +1 -0
- package/dist/representation/xml/is-xml-name.js +6 -0
- package/dist/representation/xml/is-xml-name.js.map +1 -0
- package/dist/representation/xml/xml-convention.d.ts +10 -0
- package/dist/representation/xml/xml-convention.d.ts.map +1 -0
- package/dist/representation/xml/xml-convention.js +10 -0
- package/dist/representation/xml/xml-convention.js.map +1 -0
- package/dist/representation/xml/xml-element-writer.d.ts +16 -0
- package/dist/representation/xml/xml-element-writer.d.ts.map +1 -0
- package/dist/representation/xml/xml-element-writer.js +71 -0
- package/dist/representation/xml/xml-element-writer.js.map +1 -0
- package/dist/representation/xml/xml-element.d.ts +9 -0
- package/dist/representation/xml/xml-element.d.ts.map +1 -0
- package/dist/representation/xml/xml-element.js +2 -0
- package/dist/representation/xml/xml-element.js.map +1 -0
- package/dist/representation/xml/xml-parser.d.ts +27 -0
- package/dist/representation/xml/xml-parser.d.ts.map +1 -0
- package/dist/representation/xml/xml-parser.js +154 -0
- package/dist/representation/xml/xml-parser.js.map +1 -0
- package/dist/representation/xml/xml-representation.d.ts +20 -0
- package/dist/representation/xml/xml-representation.d.ts.map +1 -0
- package/dist/representation/xml/xml-representation.js +52 -0
- package/dist/representation/xml/xml-representation.js.map +1 -0
- package/dist/representation/xml/xml-syntax-error.d.ts +5 -0
- package/dist/representation/xml/xml-syntax-error.d.ts.map +1 -0
- package/dist/representation/xml/xml-syntax-error.js +8 -0
- package/dist/representation/xml/xml-syntax-error.js.map +1 -0
- package/dist/representation/xml/xml-text.d.ts +7 -0
- package/dist/representation/xml/xml-text.d.ts.map +1 -0
- package/dist/representation/xml/xml-text.js +30 -0
- package/dist/representation/xml/xml-text.js.map +1 -0
- package/dist/representation/xml/xml-value-reader.d.ts +15 -0
- package/dist/representation/xml/xml-value-reader.d.ts.map +1 -0
- package/dist/representation/xml/xml-value-reader.js +101 -0
- package/dist/representation/xml/xml-value-reader.js.map +1 -0
- package/dist/route/answers-with-schema.d.ts +7 -0
- package/dist/route/answers-with-schema.d.ts.map +1 -0
- package/dist/route/answers-with-schema.js +10 -0
- package/dist/route/answers-with-schema.js.map +1 -0
- package/dist/route/route-spec.d.ts +11 -0
- package/dist/route/route-spec.d.ts.map +1 -1
- package/dist/schema/json-schema-of.d.ts +7 -0
- package/dist/schema/json-schema-of.d.ts.map +1 -0
- package/dist/schema/json-schema-of.js +15 -0
- package/dist/schema/json-schema-of.js.map +1 -0
- package/dist/schema/schema-node.d.ts +25 -0
- package/dist/schema/schema-node.d.ts.map +1 -0
- package/dist/schema/schema-node.js +92 -0
- package/dist/schema/schema-node.js.map +1 -0
- package/dist/schema/schema-type.d.ts +3 -0
- package/dist/schema/schema-type.d.ts.map +1 -0
- package/dist/schema/schema-type.js +2 -0
- package/dist/schema/schema-type.js.map +1 -0
- package/dist/schema/xml-hints.d.ts +9 -0
- package/dist/schema/xml-hints.d.ts.map +1 -0
- package/dist/schema/xml-hints.js +2 -0
- package/dist/schema/xml-hints.js.map +1 -0
- package/dist/serialization/decimal-text.d.ts +6 -0
- package/dist/serialization/decimal-text.d.ts.map +1 -0
- package/dist/serialization/decimal-text.js +13 -0
- package/dist/serialization/decimal-text.js.map +1 -0
- package/dist/serialization/money-body.d.ts +6 -0
- package/dist/serialization/money-body.d.ts.map +1 -0
- package/dist/serialization/money-body.js +2 -0
- package/dist/serialization/money-body.js.map +1 -0
- package/dist/serialization/money.d.ts +4 -0
- package/dist/serialization/money.d.ts.map +1 -0
- package/dist/serialization/money.js +10 -0
- package/dist/serialization/money.js.map +1 -0
- package/dist/support/is-async-iterable.d.ts +3 -0
- package/dist/support/is-async-iterable.d.ts.map +1 -0
- package/dist/support/is-async-iterable.js +5 -0
- package/dist/support/is-async-iterable.js.map +1 -0
- package/dist/tenancy/served-tenant-of.d.ts +9 -0
- package/dist/tenancy/served-tenant-of.d.ts.map +1 -0
- package/dist/tenancy/served-tenant-of.js +19 -0
- package/dist/tenancy/served-tenant-of.js.map +1 -0
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page-schema-of.js","sourceRoot":"","sources":["../../src/pagination/page-schema-of.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GA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AE,WAAW,EAAE,oCAAoC,EAAE;YACzF,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,iCAAiC,EAAE;SAC/E;QACD,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC;QACzC,GAAG,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC;KACtD,CAAC;AACJ,CAAC"}
|
|
@@ -4,8 +4,10 @@ import type { ExecuteOptions } from './execute-options.js';
|
|
|
4
4
|
* Refuses, when the routes are mounted with the options of the application, a public answer the
|
|
5
5
|
* caches in front could hand to the wrong caller: one of a route that knows its caller whose
|
|
6
6
|
* `vary` names neither who calls (`Authorization`, `Cookie`) nor the header its tenant is read
|
|
7
|
-
* from; one
|
|
8
|
-
*
|
|
7
|
+
* from; one whose fields are shown to some callers only (`withFieldAccess`) whose `vary` names
|
|
8
|
+
* neither `Authorization` nor `Cookie`, whoever may call the route; one that varies, on a header
|
|
9
|
+
* or on `Accept` among the representations of the route, behind a cache that ignores `Vary`; one
|
|
10
|
+
* filed per tenant on a route anybody may call, when nothing names the tenant of an anonymous call.
|
|
9
11
|
*/
|
|
10
12
|
export declare function assertCachedRoutes(routes: readonly Route[], options: ExecuteOptions): void;
|
|
11
13
|
//# sourceMappingURL=assert-cached-routes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assert-cached-routes.d.ts","sourceRoot":"","sources":["../../src/pipeline/assert-cached-routes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"assert-cached-routes.d.ts","sourceRoot":"","sources":["../../src/pipeline/assert-cached-routes.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAS3D;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,KAAK,EAAE,EAAE,OAAO,EAAE,cAAc,GAAG,IAAI,CAM1F"}
|
|
@@ -2,6 +2,8 @@ import { DeclarationError } from '@ddd-ts-kit/kernel/declarations';
|
|
|
2
2
|
import { CacheScope } from '../cache/cache-scope.js';
|
|
3
3
|
import { CacheTagHeader } from '../cache/cache-tag-header.js';
|
|
4
4
|
import { varyOf } from '../cache/vary-of.js';
|
|
5
|
+
import { fieldAccess } from '../field-access/field-access.js';
|
|
6
|
+
import { answersWithSchema } from '../route/answers-with-schema.js';
|
|
5
7
|
// The request headers that say who calls: an answer that varies on one is never handed to another caller.
|
|
6
8
|
const ACTOR_HEADERS = ['authorization', 'cookie'];
|
|
7
9
|
// The caches that key their answers on Vary: Varnish (xkey) and Fastly. Cloudflare and Bunny do not.
|
|
@@ -10,8 +12,10 @@ const HONOURING_VARY = [CacheTagHeader.xkey, CacheTagHeader.surrogateKey];
|
|
|
10
12
|
* Refuses, when the routes are mounted with the options of the application, a public answer the
|
|
11
13
|
* caches in front could hand to the wrong caller: one of a route that knows its caller whose
|
|
12
14
|
* `vary` names neither who calls (`Authorization`, `Cookie`) nor the header its tenant is read
|
|
13
|
-
* from; one
|
|
14
|
-
*
|
|
15
|
+
* from; one whose fields are shown to some callers only (`withFieldAccess`) whose `vary` names
|
|
16
|
+
* neither `Authorization` nor `Cookie`, whoever may call the route; one that varies, on a header
|
|
17
|
+
* or on `Accept` among the representations of the route, behind a cache that ignores `Vary`; one
|
|
18
|
+
* filed per tenant on a route anybody may call, when nothing names the tenant of an anonymous call.
|
|
15
19
|
*/
|
|
16
20
|
export function assertCachedRoutes(routes, options) {
|
|
17
21
|
for (const route of routes) {
|
|
@@ -22,16 +26,50 @@ export function assertCachedRoutes(routes, options) {
|
|
|
22
26
|
}
|
|
23
27
|
function assertCachedRoute(route, options) {
|
|
24
28
|
const refused = (reason) => new DeclarationError(`Route "${route.operationId}" (${route.method} ${route.path}): ${reason}`);
|
|
29
|
+
const reason = callerRefusal(route, options) ?? fieldsRefusal(route) ?? varyRefusal(route, options);
|
|
30
|
+
if (reason !== undefined) {
|
|
31
|
+
throw refused(reason);
|
|
32
|
+
}
|
|
33
|
+
assertTenantNamed(route, options, refused);
|
|
34
|
+
}
|
|
35
|
+
/** On a route that knows its caller, why its answer could reach another caller, if it could. */
|
|
36
|
+
function callerRefusal(route, options) {
|
|
25
37
|
const tenantHeaders = lowerCase(options.resolveTenant?.headers ?? []);
|
|
26
|
-
const declared = lowerCase(route.cache.vary ?? []);
|
|
27
38
|
const dimensions = [...ACTOR_HEADERS, ...tenantHeaders];
|
|
28
|
-
if (route.security
|
|
29
|
-
|
|
39
|
+
if (route.security === false || namesOneOf(route, dimensions)) {
|
|
40
|
+
return undefined;
|
|
30
41
|
}
|
|
31
|
-
|
|
32
|
-
|
|
42
|
+
return `the route knows its caller, and its public answer is kept by shared caches: name in vary one of ${dimensions.join(', ')}, what says who calls or the tenant, or declare scope private.`;
|
|
43
|
+
}
|
|
44
|
+
/** On an answer with fields some callers may not read, why it could reach another caller, if it could. */
|
|
45
|
+
function fieldsRefusal(route) {
|
|
46
|
+
if (!showsFieldsPerCaller(route) || namesOneOf(route, ACTOR_HEADERS)) {
|
|
47
|
+
return undefined;
|
|
33
48
|
}
|
|
34
|
-
|
|
49
|
+
return `its answer shows some fields to some callers only, and a shared cache would hand the answer of the first caller to the next: name in vary one of ${ACTOR_HEADERS.join(', ')}, or declare scope private.`;
|
|
50
|
+
}
|
|
51
|
+
/** Behind a cache that ignores Vary, why a varying answer would reach every caller, if it would. */
|
|
52
|
+
function varyRefusal(route, options) {
|
|
53
|
+
if (honoursVary(options) || !varies(route, options)) {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
return `the cache in front (${options.cacheTags?.header ?? ''}) ignores Vary, and would hand one variant to every caller: declare scope private, answer in one media type, read the tenant from the host or the path, or set cacheTags.honoursVary once the cache keys on these headers.`;
|
|
57
|
+
}
|
|
58
|
+
function namesOneOf(route, headers) {
|
|
59
|
+
return lowerCase(route.cache.vary ?? []).some((name) => headers.includes(name));
|
|
60
|
+
}
|
|
61
|
+
/** Whether the answer varies: on the headers its policy or the tenant names, or on `Accept` among several media types. */
|
|
62
|
+
function varies(route, options) {
|
|
63
|
+
const { representations, resolveTenant } = options;
|
|
64
|
+
const named = varyOf(route.cache.vary ?? [], resolveTenant?.headers ?? []);
|
|
65
|
+
const negotiated = representations !== undefined && answersWithSchema(route) && representations.offeredBy(route).length > 1;
|
|
66
|
+
return named.length > 0 || negotiated;
|
|
67
|
+
}
|
|
68
|
+
/** Whether a schema the route answers with holds a field some callers may not see. */
|
|
69
|
+
function showsFieldsPerCaller(route) {
|
|
70
|
+
// A copy has a string index, which is how the statuses are enumerated.
|
|
71
|
+
const declared = { ...route.responses };
|
|
72
|
+
return Object.values(declared).some(({ body }) => fieldAccess.of(body).some(({ rule }) => rule.read !== undefined));
|
|
35
73
|
}
|
|
36
74
|
function lowerCase(names) {
|
|
37
75
|
return names.map((name) => name.toLowerCase());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assert-cached-routes.js","sourceRoot":"","sources":["../../src/pipeline/assert-cached-routes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAEnE,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"assert-cached-routes.js","sourceRoot":"","sources":["../../src/pipeline/assert-cached-routes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAEnE,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,cA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C,KAAa,EAAE,OAAuB,EAAE,OAAkC;IACnG,MAAM,MAAM,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;IAEnD,IAAI,OAAO,CAAC,SAAS,EAAE,SAAS,KAAK,IAAI,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC,QAAQ,KAAK,KAAK,EAAE,CAAC;QACjF,OAAO;IACT,CAAC;IAED,IAAI,OAAO,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;QACxC,MAAM,OAAO,CACX,qNAAqN,CACtN,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -4,7 +4,12 @@ import type { RouteResponse } from './route-response.js';
|
|
|
4
4
|
/**
|
|
5
5
|
* A successful read that declares validators answers its `ETag` and `Last-Modified`, and
|
|
6
6
|
* `304 Not Modified` without a body when the caller already holds that version. A header the
|
|
7
|
-
* handler answered itself wins.
|
|
7
|
+
* handler answered itself wins. A version and an instant are read from `value`, what the handler
|
|
8
|
+
* answered, whatever representation wrote it; a strong `ETag` digests the bytes sent, so an
|
|
9
|
+
* answer streamed as it is written, whose bytes are not known when its headers go, has none.
|
|
8
10
|
*/
|
|
9
|
-
export declare function conditionalAnswer(route: Pick<Route, 'method' | 'cache'>, request: Readonly<RawHeaders>,
|
|
11
|
+
export declare function conditionalAnswer(route: Pick<Route, 'method' | 'cache'>, request: Readonly<RawHeaders>, answered: {
|
|
12
|
+
readonly response: RouteResponse;
|
|
13
|
+
readonly value: unknown;
|
|
14
|
+
}): Promise<RouteResponse>;
|
|
10
15
|
//# sourceMappingURL=conditional-answer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conditional-answer.d.ts","sourceRoot":"","sources":["../../src/pipeline/conditional-answer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAI/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAOzD
|
|
1
|
+
{"version":3,"file":"conditional-answer.d.ts","sourceRoot":"","sources":["../../src/pipeline/conditional-answer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAI/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAOzD;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,EACtC,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,EAC7B,QAAQ,EAAE;IAAE,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GACtE,OAAO,CAAC,aAAa,CAAC,CAkBxB"}
|
|
@@ -8,14 +8,17 @@ const READS = ['GET', 'HEAD'];
|
|
|
8
8
|
/**
|
|
9
9
|
* A successful read that declares validators answers its `ETag` and `Last-Modified`, and
|
|
10
10
|
* `304 Not Modified` without a body when the caller already holds that version. A header the
|
|
11
|
-
* handler answered itself wins.
|
|
11
|
+
* handler answered itself wins. A version and an instant are read from `value`, what the handler
|
|
12
|
+
* answered, whatever representation wrote it; a strong `ETag` digests the bytes sent, so an
|
|
13
|
+
* answer streamed as it is written, whose bytes are not known when its headers go, has none.
|
|
12
14
|
*/
|
|
13
|
-
export async function conditionalAnswer(route, request,
|
|
15
|
+
export async function conditionalAnswer(route, request, answered) {
|
|
14
16
|
const { cache } = route;
|
|
17
|
+
const { response, value } = answered;
|
|
15
18
|
if (cache === undefined || response.status < SUCCESS_FROM || response.status > SUCCESS_TO) {
|
|
16
19
|
return response;
|
|
17
20
|
}
|
|
18
|
-
const headers = { ...(await validatorsOf(cache, response)), ...response.headers };
|
|
21
|
+
const headers = { ...(await validatorsOf(cache, response, value)), ...response.headers };
|
|
19
22
|
if (!READS.includes(route.method) || !isNotModified(request, headers)) {
|
|
20
23
|
return { ...response, headers };
|
|
21
24
|
}
|
|
@@ -24,10 +27,11 @@ export async function conditionalAnswer(route, request, response) {
|
|
|
24
27
|
headers: Object.fromEntries(Object.entries(headers).filter(([name]) => name !== 'content-type')),
|
|
25
28
|
};
|
|
26
29
|
}
|
|
27
|
-
async function validatorsOf(cache, response) {
|
|
30
|
+
async function validatorsOf(cache, response, value) {
|
|
31
|
+
const streamed = response.stream !== undefined && cache.etag === 'representation';
|
|
28
32
|
return {
|
|
29
|
-
...(cache.etag === undefined ? {} : { etag: await entityTagOf(cache.etag, response) }),
|
|
30
|
-
...(cache.lastModified === undefined ? {} : { 'last-modified': lastModifiedOf(cache.lastModified,
|
|
33
|
+
...(cache.etag === undefined || streamed ? {} : { etag: await entityTagOf(cache.etag, response, value) }),
|
|
34
|
+
...(cache.lastModified === undefined ? {} : { 'last-modified': lastModifiedOf(cache.lastModified, value) }),
|
|
31
35
|
};
|
|
32
36
|
}
|
|
33
37
|
//# sourceMappingURL=conditional-answer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conditional-answer.js","sourceRoot":"","sources":["../../src/pipeline/conditional-answer.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGvD,MAAM,YAAY,GAAG,GAAG,CAAC;AACzB,MAAM,YAAY,GAAG,GAAG,CAAC;AACzB,MAAM,UAAU,GAAG,GAAG,CAAC;AACvB,MAAM,KAAK,GAAsB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAEjD
|
|
1
|
+
{"version":3,"file":"conditional-answer.js","sourceRo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AE,EAAE,CAAC,IAAI,KAAK,cAAc,CAAC,CAAC;KACjG,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,YAAY,CACzB,KAAkB,EAClB,QAAuB,EACvB,KAAc;IAEd,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,KAAK,SAAS,IAAI,KAAK,CAAC,IAAI,KAAK,gBAAgB,CAAC;IAElF,OAAO;QACL,GAAG,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,IAAI,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC,KAAK,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC;QACzG,GAAG,CAAC,KAAK,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,cAAc,CAAC,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC;KAC5G,CAAC;AACJ,CAAC"}
|
|
@@ -2,8 +2,8 @@ import type { EntityTagSource } from '../cache/entity-tag-source.js';
|
|
|
2
2
|
import type { RouteResponse } from './route-response.js';
|
|
3
3
|
/**
|
|
4
4
|
* The `ETag` of an answer: strong, the SHA-256 of the bytes sent, for `representation`; weak,
|
|
5
|
-
* the version the
|
|
6
|
-
* declaration does not allow.
|
|
5
|
+
* the version the value answered carries, for `{ version }`, the same in every representation.
|
|
6
|
+
* A value without that version is an answer its declaration does not allow.
|
|
7
7
|
*/
|
|
8
|
-
export declare function entityTagOf(source: EntityTagSource, response: RouteResponse): Promise<string>;
|
|
8
|
+
export declare function entityTagOf(source: EntityTagSource, response: RouteResponse, value?: unknown): Promise<string>;
|
|
9
9
|
//# sourceMappingURL=entity-tag-of.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-tag-of.d.ts","sourceRoot":"","sources":["../../src/pipeline/entity-tag-of.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAGrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGzD;;;;GAIG;AACH,wBAAsB,WAAW,
|
|
1
|
+
{"version":3,"file":"entity-tag-of.d.ts","sourceRoot":"","sources":["../../src/pipeline/entity-tag-of.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAGrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGzD;;;;GAIG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE,aAAa,EACvB,KAAK,GAAE,OAAuB,GAC7B,OAAO,CAAC,MAAM,CAAC,CAYjB"}
|
|
@@ -3,14 +3,14 @@ import { valuesAt } from '../support/values-at.js';
|
|
|
3
3
|
import { serializeBody } from './serialize-body.js';
|
|
4
4
|
/**
|
|
5
5
|
* The `ETag` of an answer: strong, the SHA-256 of the bytes sent, for `representation`; weak,
|
|
6
|
-
* the version the
|
|
7
|
-
* declaration does not allow.
|
|
6
|
+
* the version the value answered carries, for `{ version }`, the same in every representation.
|
|
7
|
+
* A value without that version is an answer its declaration does not allow.
|
|
8
8
|
*/
|
|
9
|
-
export async function entityTagOf(source, response) {
|
|
9
|
+
export async function entityTagOf(source, response, value = response.body) {
|
|
10
10
|
if (source === 'representation') {
|
|
11
11
|
return `"${await digestOf(serializeBody(response) ?? '')}"`;
|
|
12
12
|
}
|
|
13
|
-
const [version] = valuesAt(
|
|
13
|
+
const [version] = valuesAt(value, source.version);
|
|
14
14
|
if (typeof version !== 'number' && typeof version !== 'string') {
|
|
15
15
|
throw new ResponseContractError(`The answer carries no version under "${source.version}" for its ETag.`);
|
|
16
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-tag-of.js","sourceRoot":"","sources":["../../src/pipeline/entity-tag-of.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CAAC;IAC/E,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,MAAM,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;IACvF,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;IAEpD,OAAO,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAC7E,CAAC"}
|
|
@@ -7,8 +7,13 @@ export interface ErrorContext {
|
|
|
7
7
|
readonly operationId: string;
|
|
8
8
|
readonly method: HttpMethod;
|
|
9
9
|
readonly path: string;
|
|
10
|
-
/** The response the client receives for this error. */
|
|
10
|
+
/** The response the client receives for this error; for an interrupted stream, what it would have received. */
|
|
11
11
|
readonly problem: Problem;
|
|
12
|
+
/**
|
|
13
|
+
* The failure came while a streamed list was written, after the status: the client received a
|
|
14
|
+
* response cut short, not the problem. Count it as a server fault whatever the problem says.
|
|
15
|
+
*/
|
|
16
|
+
readonly interrupted?: boolean;
|
|
12
17
|
/** The execution context of the request, when the failure happened after it was built: not for a refused credential or an invalid request. */
|
|
13
18
|
readonly execution?: ExecutionContext;
|
|
14
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-context.d.ts","sourceRoot":"","sources":["../../src/pipeline/error-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1D,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB
|
|
1
|
+
{"version":3,"file":"error-context.d.ts","sourceRoot":"","sources":["../../src/pipeline/error-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1D,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,+GAA+G;IAC/G,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAC/B,8IAA8I;IAC9I,QAAQ,CAAC,SAAS,CAAC,EAAE,gBAAgB,CAAC;CACvC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Clock, ExecutionScope } from '@ddd-ts-kit/kernel';
|
|
2
2
|
import type { CacheTagHeader } from '../cache/cache-tag-header.js';
|
|
3
3
|
import type { ErrorMapper } from '../error/error-mapper.js';
|
|
4
|
+
import type { FieldDecider } from '../field-access/field-decider.js';
|
|
5
|
+
import type { Representations } from '../representation/representations.js';
|
|
4
6
|
import type { TenantResolver } from '../tenancy/tenant-resolver.js';
|
|
5
7
|
import type { ErrorContext } from './error-context.js';
|
|
6
8
|
import type { GuardRefusal } from './guard-refusal.js';
|
|
@@ -54,6 +56,21 @@ export interface ExecuteOptions {
|
|
|
54
56
|
* `@ddd-ts-kit/tracing` fits as it is.
|
|
55
57
|
*/
|
|
56
58
|
readonly around?: RouteAround;
|
|
59
|
+
/**
|
|
60
|
+
* The media types the application answers and reads in (`Representations.standard()`): each
|
|
61
|
+
* request is answered in the one its `Accept` header prefers among those its route declares
|
|
62
|
+
* (406 when none fits), a refusal in the matching problem type, and a body sent in a media
|
|
63
|
+
* type the route consumes is read before its schema validates it (415 for another one). Left
|
|
64
|
+
* out, every answer is JSON whatever the request accepts, as before.
|
|
65
|
+
*/
|
|
66
|
+
readonly representations?: Representations;
|
|
67
|
+
/**
|
|
68
|
+
* Decides the fields a schema reserves to some callers (`withFieldAccess`): left out of an
|
|
69
|
+
* answer for an actor who may not read them, refused in a body for one who may not set them.
|
|
70
|
+
* `fieldDeciderOf({ access, clock })` builds it from the `Access` of `@ddd-ts-kit/auth`. Left
|
|
71
|
+
* out, every restricted field is left out of every answer and refused in every body.
|
|
72
|
+
*/
|
|
73
|
+
readonly fieldAccess?: FieldDecider;
|
|
57
74
|
/**
|
|
58
75
|
* The header the shared cache in front of the application reads the tags of an answer from:
|
|
59
76
|
* `xkey` for Varnish, `surrogate-key` for Fastly, `cache-tag` for Cloudflare, `cdn-tag` for
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute-options.d.ts","sourceRoot":"","sources":["../../src/pipeline/execute-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,YA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Q,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;KAChC,CAAC;IACF,+GAA+G;IAC/G,QAAQ,CAAC,OAAO,CAAC,EAAE,YAAY,CAAC;CACjC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute-route.d.ts","sourceRoot":"","sources":["../../src/pipeline/execute-route.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"execute-route.d.ts","sourceRoot":"","sources":["../../src/pipeline/execute-route.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAU/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAM3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAMnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAsBzD,wBAAsB,YAAY,CAChC,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,UAAU,EACnB,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,aAAa,CAAC,CASxB"}
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { Readable } from 'node:stream';
|
|
2
2
|
import { createErrorMapper } from '../error/create-error-mapper.js';
|
|
3
3
|
import { toProblem } from '../error/to-problem.js';
|
|
4
|
+
import { assertWritable } from '../field-access/assert-writable.js';
|
|
5
|
+
import { fieldAccess } from '../field-access/field-access.js';
|
|
6
|
+
import { FieldJudge } from '../field-access/field-judge.js';
|
|
7
|
+
import { FieldTree } from '../field-access/field-tree.js';
|
|
8
|
+
import { visibleBody } from '../field-access/visible-body.js';
|
|
9
|
+
import { NotAcceptableError } from '../representation/not-acceptable-error.js';
|
|
10
|
+
import { PROBLEM_SHAPE } from '../representation/problem-shape.js';
|
|
11
|
+
import { isAsyncIterable } from '../support/is-async-iterable.js';
|
|
12
|
+
import { resolvedTenant } from '../tenancy/resolved-tenant.js';
|
|
13
|
+
import { guardRefusals } from '../controller/guard-refusals.js';
|
|
4
14
|
import { assertDeclaredResponse } from './assert-declared-response.js';
|
|
5
15
|
import { cacheHeadersOf } from './cache-headers-of.js';
|
|
6
16
|
import { conditionalAnswer } from './conditional-answer.js';
|
|
@@ -8,27 +18,34 @@ import { CORRELATION_HEADER } from './correlation-header.js';
|
|
|
8
18
|
import { correlationIdOf } from './correlation-id-of.js';
|
|
9
19
|
import { executionOfRequest } from './execution-of-request.js';
|
|
10
20
|
import { expectedVersionOf } from './expected-version-of.js';
|
|
21
|
+
import { iteratedWithin } from './iterated-within.js';
|
|
22
|
+
import { negotiatedVary } from './negotiated-vary.js';
|
|
23
|
+
import { negotiation } from './negotiation.js';
|
|
24
|
+
import { readBody } from './read-body.js';
|
|
11
25
|
import { receiveUpload } from './receive-upload.js';
|
|
26
|
+
import { represented } from './represented.js';
|
|
27
|
+
import { reportedStream } from './reported-stream.js';
|
|
12
28
|
import { taggedAnswer } from './tagged-answer.js';
|
|
13
|
-
import { resolvedTenant } from '../tenancy/resolved-tenant.js';
|
|
14
|
-
import { guardRefusals } from '../controller/guard-refusals.js';
|
|
15
29
|
import { validateRequest } from './validate-request.js';
|
|
16
30
|
import { wellFormedIdentifier } from './well-formed-identifier.js';
|
|
31
|
+
import { writtenIn } from './written-in.js';
|
|
17
32
|
const defaultErrorMapper = createErrorMapper();
|
|
18
33
|
const JSON_CONTENT_TYPE = 'application/json; charset=utf-8';
|
|
19
34
|
const PROBLEM_CONTENT_TYPE = 'application/problem+json; charset=utf-8';
|
|
20
35
|
export async function executeRoute(route, request, options = {}) {
|
|
21
36
|
const requestId = (options.requestId ?? defaultRequestId)(request);
|
|
22
37
|
const correlationId = correlationIdOf(request.headers, requestId);
|
|
23
|
-
const
|
|
38
|
+
const { representations } = options;
|
|
39
|
+
const negotiated = representations === undefined ? undefined : negotiation(route, request.headers, representations);
|
|
40
|
+
const call = { route, request, options, requestId, correlationId, negotiated, reached: {} };
|
|
24
41
|
const respond = () => responded(call);
|
|
25
42
|
return options.around === undefined ? respond() : options.around(route, respond);
|
|
26
43
|
}
|
|
27
44
|
async function responded(call) {
|
|
28
45
|
try {
|
|
29
|
-
const
|
|
30
|
-
const tagged = taggedAnswer(
|
|
31
|
-
return await conditionalAnswer(call.route, call.request.headers, tagged);
|
|
46
|
+
const result = await handled(call);
|
|
47
|
+
const tagged = taggedAnswer(await answer(result, call), taggingOf(call, result.body));
|
|
48
|
+
return await conditionalAnswer(call.route, call.request.headers, { response: tagged, value: result.body });
|
|
32
49
|
}
|
|
33
50
|
catch (error) {
|
|
34
51
|
const { response, context } = refusal(error, call);
|
|
@@ -36,40 +53,81 @@ async function responded(call) {
|
|
|
36
53
|
return response;
|
|
37
54
|
}
|
|
38
55
|
}
|
|
39
|
-
|
|
56
|
+
/** The tags are read from the value the handler answered, whatever representation writes it. */
|
|
57
|
+
function taggingOf({ route, options, reached }, body) {
|
|
40
58
|
const perTenant = options.cacheTags?.perTenant === true;
|
|
41
59
|
const tenantId = perTenant ? reached.execution?.tenantId : undefined;
|
|
42
|
-
return { route, header: options.cacheTags?.header, perTenant, params: reached.params, tenantId };
|
|
60
|
+
return { route, header: options.cacheTags?.header, perTenant, params: reached.params, body, tenantId };
|
|
43
61
|
}
|
|
44
62
|
function defaultRequestId(request) {
|
|
45
63
|
return wellFormedIdentifier(request.headers['x-request-id']) ?? globalThis.crypto.randomUUID();
|
|
46
64
|
}
|
|
47
65
|
async function handled(call) {
|
|
48
|
-
const { route, request, options
|
|
66
|
+
const { route, request, options } = call;
|
|
49
67
|
const principal = await options.resolvePrincipal?.(request.raw);
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
const { headers } = request;
|
|
53
|
-
const expectedVersion = expectedVersionOf(route, headers);
|
|
68
|
+
const input = await acceptedInput(call);
|
|
69
|
+
const expectedVersion = expectedVersionOf(route, request.headers);
|
|
54
70
|
const execution = executionOf(call, principal, input.params);
|
|
71
|
+
// A field set in a body is an act, recorded; a field shown or left out of the answer only shapes it.
|
|
72
|
+
const setting = new FieldJudge(execution.actor, options.fieldAccess, true);
|
|
73
|
+
const showing = new FieldJudge(execution.actor, options.fieldAccess);
|
|
74
|
+
const context = requestContext(call, { execution, principal, expectedVersion });
|
|
55
75
|
call.reached.params = input.params;
|
|
56
|
-
const
|
|
76
|
+
const within = (work) => {
|
|
77
|
+
const asPrincipal = () => options.withPrincipal?.(principal, work) ?? work();
|
|
78
|
+
return options.executionScope?.run(execution, asPrincipal) ?? asPrincipal();
|
|
79
|
+
};
|
|
80
|
+
// The fields are decided in the scope of the request too: a decision is recorded with who asked and under which correlation.
|
|
81
|
+
const result = await within(async () => {
|
|
82
|
+
await assertWritable(input.body, FieldTree.of(fieldAccess.of(route.request?.body)), setting);
|
|
83
|
+
return visibleOutput(route, await answered(call, { ...input, context }), showing);
|
|
84
|
+
});
|
|
85
|
+
return streamedWithin(result, within);
|
|
86
|
+
}
|
|
87
|
+
/** What the handler answers, checked against the declaration when the options ask for it. */
|
|
88
|
+
async function answered({ route, options }, input) {
|
|
89
|
+
const result = await route.handle(input);
|
|
90
|
+
if (options.validateResponses === true) {
|
|
91
|
+
assertDeclaredResponse(route, result);
|
|
92
|
+
}
|
|
93
|
+
return result;
|
|
94
|
+
}
|
|
95
|
+
/** A list streamed after the handler returned is still read inside the scope of the request; a file is the handler's own. */
|
|
96
|
+
function streamedWithin(result, within) {
|
|
97
|
+
const listed = isAsyncIterable(result.body) && !(result.body instanceof Readable);
|
|
98
|
+
return listed ? { ...result, body: iteratedWithin(result.body, within) } : result;
|
|
99
|
+
}
|
|
100
|
+
function requestContext({ request, requestId, route }, { execution, principal, expectedVersion }) {
|
|
101
|
+
return {
|
|
57
102
|
requestId,
|
|
58
103
|
execution,
|
|
59
104
|
raw: request.raw,
|
|
60
|
-
rawHeaders: headers,
|
|
105
|
+
rawHeaders: request.headers,
|
|
61
106
|
...(principal === undefined ? {} : { principal }),
|
|
62
107
|
...(expectedVersion === undefined ? {} : { expectedVersion }),
|
|
63
108
|
...(route.rawBody === true && request.stream !== undefined ? { stream: request.stream } : {}),
|
|
64
109
|
};
|
|
110
|
+
}
|
|
111
|
+
/** The answer without the fields its schema reserves to callers this one is not. */
|
|
112
|
+
async function visibleOutput(route, result, judge) {
|
|
113
|
+
const tree = FieldTree.of(fieldAccess.of(route.responses[result.status]?.body));
|
|
114
|
+
return tree.isEmpty() ? result : { ...result, body: await visibleBody(result.body, tree, judge) };
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* The parts of the request through their schemas, once the request accepts an answer and its
|
|
118
|
+
* body is read: an upload gives its fields, a body sent in another media type is read by its
|
|
119
|
+
* representation, a raw body is the handler's.
|
|
120
|
+
*/
|
|
121
|
+
async function acceptedInput(call) {
|
|
122
|
+
const { route, request, options, negotiated } = call;
|
|
123
|
+
const received = await receiveUpload(route, request, options);
|
|
65
124
|
const upload = received.upload === undefined ? {} : { upload: received.upload };
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const result = await (options.executionScope?.run(execution, asPrincipal) ?? asPrincipal());
|
|
69
|
-
if (options.validateResponses === true) {
|
|
70
|
-
assertDeclaredResponse(route, result);
|
|
125
|
+
if (negotiated?.refused === true) {
|
|
126
|
+
throw new NotAcceptableError('The route answers in none of the media types the request accepts.');
|
|
71
127
|
}
|
|
72
|
-
|
|
128
|
+
const readable = negotiated !== undefined && route.upload === undefined && route.rawBody !== true;
|
|
129
|
+
const read = readable ? readBody(route, received.request, negotiated.representations) : received.request;
|
|
130
|
+
return { ...validateRequest(route, read), ...upload };
|
|
73
131
|
}
|
|
74
132
|
/** The execution context of the request, in the tenant it names once the caller is known to belong to it. */
|
|
75
133
|
function executionOf(call, principal, params) {
|
|
@@ -90,18 +148,39 @@ function deadlineOf(options) {
|
|
|
90
148
|
const arrivedAt = options.clock?.now() ?? new Date();
|
|
91
149
|
return new Date(arrivedAt.getTime() + options.requestTimeoutMs);
|
|
92
150
|
}
|
|
93
|
-
function answer(result, call) {
|
|
151
|
+
async function answer(result, call) {
|
|
152
|
+
const chosen = call.negotiated?.answer;
|
|
153
|
+
const written = reportingFailures(chosen === undefined ? asItIs(result) : await represented(call.route, result, chosen), call);
|
|
154
|
+
const kept = {
|
|
155
|
+
...cacheHeadersOf(call.route, result.status, call.options.resolveTenant?.headers),
|
|
156
|
+
...lowerCaseKeys(result.headers ?? {}),
|
|
157
|
+
};
|
|
94
158
|
return {
|
|
159
|
+
...written,
|
|
95
160
|
status: result.status,
|
|
96
161
|
headers: {
|
|
97
162
|
...defaultContentType(result.body),
|
|
98
|
-
...
|
|
99
|
-
...
|
|
163
|
+
...written.headers,
|
|
164
|
+
...kept,
|
|
165
|
+
...negotiatedVary(call.negotiated?.varies === true, kept['vary']),
|
|
100
166
|
...identifierHeaders(call),
|
|
101
167
|
},
|
|
102
|
-
...(result.body === undefined ? {} : { body: result.body }),
|
|
103
168
|
};
|
|
104
169
|
}
|
|
170
|
+
/** A streamed list that fails after its status is told to the error hook, as a fault, before the response is cut short. */
|
|
171
|
+
function reportingFailures(written, call) {
|
|
172
|
+
if (written.stream === undefined) {
|
|
173
|
+
return written;
|
|
174
|
+
}
|
|
175
|
+
const report = (error) => {
|
|
176
|
+
notify(call.options, error, { ...contextOf(error, call), interrupted: true });
|
|
177
|
+
};
|
|
178
|
+
return { ...written, stream: reportedStream(written.stream, report) };
|
|
179
|
+
}
|
|
180
|
+
/** An answer no representation writes: the value of the handler, for the adapter to serialize. */
|
|
181
|
+
function asItIs({ body }) {
|
|
182
|
+
return body === undefined ? { headers: {} } : { headers: {}, body };
|
|
183
|
+
}
|
|
105
184
|
function defaultContentType(body) {
|
|
106
185
|
if (body === undefined) {
|
|
107
186
|
return {};
|
|
@@ -116,25 +195,32 @@ function identifierHeaders({ requestId, correlationId }) {
|
|
|
116
195
|
return { 'x-request-id': requestId, [CORRELATION_HEADER]: correlationId };
|
|
117
196
|
}
|
|
118
197
|
function refusal(error, call) {
|
|
198
|
+
const context = contextOf(error, call);
|
|
199
|
+
const { problem } = context;
|
|
200
|
+
notify(call.options, error, context);
|
|
201
|
+
return { response: { status: problem.status, ...problemBody(problem, call) }, context };
|
|
202
|
+
}
|
|
203
|
+
function contextOf(error, call) {
|
|
119
204
|
const { route, options, requestId, correlationId } = call;
|
|
120
205
|
const { execution } = call.reached;
|
|
121
|
-
|
|
122
|
-
const context = {
|
|
206
|
+
return {
|
|
123
207
|
requestId,
|
|
124
208
|
correlationId,
|
|
125
209
|
operationId: route.operationId,
|
|
126
210
|
method: route.method,
|
|
127
211
|
path: route.path,
|
|
128
|
-
problem,
|
|
212
|
+
problem: toProblem(error, options.errorMapper ?? defaultErrorMapper, requestId),
|
|
129
213
|
...(execution === undefined ? {} : { execution }),
|
|
130
214
|
};
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
215
|
+
}
|
|
216
|
+
function problemBody(problem, call) {
|
|
217
|
+
const chosen = call.negotiated?.problem;
|
|
218
|
+
const kept = { ...cacheHeadersOf(call.route, problem.status), ...identifierHeaders(call) };
|
|
219
|
+
if (chosen === undefined) {
|
|
220
|
+
return { headers: { 'content-type': PROBLEM_CONTENT_TYPE, ...kept }, body: problem };
|
|
221
|
+
}
|
|
222
|
+
const written = writtenIn(problem, chosen, PROBLEM_SHAPE);
|
|
223
|
+
return { ...written, headers: { ...written.headers, ...kept } };
|
|
138
224
|
}
|
|
139
225
|
async function reportGuardRefusal(options, error, context) {
|
|
140
226
|
const { execution } = context;
|