@ddd-ts-kit/http 0.12.0 → 0.14.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 +373 -11
- 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/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 +13 -0
- package/dist/hono/mount-hono.d.ts.map +1 -0
- package/dist/hono/mount-hono.js +77 -0
- package/dist/hono/mount-hono.js.map +1 -0
- package/dist/hono/read-body.d.ts +16 -0
- package/dist/hono/read-body.d.ts.map +1 -0
- package/dist/hono/read-body.js +65 -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 +43 -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/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/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/openapi/schema-parameters.js +1 -1
- package/dist/openapi/schema-parameters.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 +3 -1
- package/dist/pagination/page-schema-of.d.ts.map +1 -1
- package/dist/pagination/page-schema-of.js +11 -3
- 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/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/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/package.json +15 -5
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# @ddd-ts-kit/http
|
|
2
2
|
|
|
3
|
-
Declare a route once, without a framework. Mount it on Express 5, Fastify 5
|
|
4
|
-
generate the OpenAPI 3.1 contract from the same declaration.
|
|
3
|
+
Declare a route once, without a framework. Mount it on Express 5, Fastify 5, Hono 4 (on Node)
|
|
4
|
+
or NestJS, and generate the OpenAPI 3.1 contract from the same declaration.
|
|
5
5
|
|
|
6
6
|
Every adapter goes through one pipeline (`executeRoute`): validation, handler, error mapping.
|
|
7
|
-
The behaviour is therefore the same on the
|
|
7
|
+
The behaviour is therefore the same on the four frameworks, and one test suite proves it.
|
|
8
8
|
|
|
9
9
|
## Declare
|
|
10
10
|
|
|
@@ -84,7 +84,7 @@ const routes = controllerRoutes([PlaceOrderController], { resolve: application.r
|
|
|
84
84
|
|
|
85
85
|
| Export | What it is |
|
|
86
86
|
|---|---|
|
|
87
|
-
| `Controller(spec)` | the decorator of a controller: `group`, `method`, `path` (after the prefix of the group), `operationId` (the class name without `Controller` by default), `summary`, `description`, `tags`, `params`, `query`, `headers`, `body`, `response: { status, description?, body? }`, `errors`, `guards`, `deprecated`, `cache` and `ifMatch` (see "HTTP caching") |
|
|
87
|
+
| `Controller(spec)` | the decorator of a controller: `group`, `method`, `path` (after the prefix of the group), `operationId` (the class name without `Controller` by default), `summary`, `description`, `tags`, `params`, `query`, `headers`, `body`, `response: { status, description?, body? }`, `errors`, `guards`, `deprecated`, `cache` and `ifMatch` (see "HTTP caching"), `produces` and `consumes` (see [Representations](#representations-json-xml-csv)), `form` (see [Forms described by the server](#forms-described-by-the-server)) |
|
|
88
88
|
| `RouteGroup({ parent, prefix, tags, guards, errors, cache })` | names a set of routes on an empty class; a child inherits from its `parent` and adds; the nearest `cache` wins |
|
|
89
89
|
| `Guard` | the interface `{ documents?, check(request: GuardRequest) }`, and the decorator of a guard class that takes dependencies |
|
|
90
90
|
| `Authenticated`, `Public`, `HasRole(...roles)`, `HasScope(...scopes)`, `TenantMember` | the guards the package ships, over the `Actor` and the `Session` of the request: 401 to the anonymous caller, 403 without one of the roles, without every scope named (`Session.scopes`, typed by the `SessionScopes` of the project) or outside the tenant of the request; `Public` lets everybody in and stands alone. A refusal of a guard is reported to `onGuardRefusal` |
|
|
@@ -152,9 +152,12 @@ the application are known, and a public answer is held to them with a `Declarati
|
|
|
152
152
|
|
|
153
153
|
- on a route that knows its caller, `vary` names `Authorization`, `Cookie`, or a header the tenant
|
|
154
154
|
is read from (`resolveTenant`): `vary: ['Accept-Language']` alone is refused;
|
|
155
|
+
- on any route, even one anybody may call, an answer whose schema reserves fields to some
|
|
156
|
+
callers (`withFieldAccess` with a `read` requirement, on the answer, its page or its stream)
|
|
157
|
+
names `Authorization` or `Cookie` in `vary`: what it shows depends on who calls;
|
|
155
158
|
- behind a cache that ignores `Vary` (`cacheTags.header` of Cloudflare or Bunny), a public answer
|
|
156
159
|
that varies is refused, unless `cacheTags.honoursVary: true` says the cache keys on those
|
|
157
|
-
headers;
|
|
160
|
+
headers; an answer chosen by `Accept` among several media types (`produces`) varies on it;
|
|
158
161
|
- with tags filed per tenant (`cacheTags.perTenant`), a tagged route anybody may call needs
|
|
159
162
|
`resolveTenant`: an anonymous call names no tenant otherwise, and no purge would meet its answer.
|
|
160
163
|
|
|
@@ -192,7 +195,10 @@ without a body to a caller that already holds that version:
|
|
|
192
195
|
`If-None-Match` is read first and compared weakly, `If-Modified-Since` only without it. A body
|
|
193
196
|
that lacks the field it names answers 500, as any answer its declaration does not allow. The
|
|
194
197
|
contract gains the `If-None-Match` and `If-Modified-Since` parameters, the `ETag` and
|
|
195
|
-
`Last-Modified` headers and the `304` answer.
|
|
198
|
+
`Last-Modified` headers and the `304` answer. Under [representations](#representations-json-xml-csv), the
|
|
199
|
+
version, the instant and the cache tags are read from what the handler answered, the same in
|
|
200
|
+
JSON, XML or CSV; a strong tag digests the bytes of the media type sent, so each representation
|
|
201
|
+
has its own, and a streamed list, whose bytes are not known when its headers go, has none.
|
|
196
202
|
|
|
197
203
|
A write made on the version a client read declares `ifMatch` (`IfMatch.optional` or
|
|
198
204
|
`IfMatch.required`). The pipeline reads the version named in `If-Match` (the weak tag the read
|
|
@@ -335,7 +341,8 @@ message nor its facts.
|
|
|
335
341
|
|
|
336
342
|
Defaults: `VALIDATION_FAILED` 422 (with `issues`, paths prefixed by the part:
|
|
337
343
|
`body.items.0.sku`), `NOT_FOUND` 404, `CONFLICT` 409, `INVARIANT_VIOLATION` 422, `UNAUTHORIZED`
|
|
338
|
-
401, `FORBIDDEN` 403, `PRECONDITION_FAILED` 412, `
|
|
344
|
+
401, `FORBIDDEN` 403, `NOT_ACCEPTABLE` 406, `PRECONDITION_FAILED` 412, `UNSUPPORTED_MEDIA_TYPE` 415,
|
|
345
|
+
`PRECONDITION_REQUIRED` 428. A domain code that is not mapped answers 422.
|
|
339
346
|
|
|
340
347
|
```ts
|
|
341
348
|
import { createErrorMapper } from '@ddd-ts-kit/http';
|
|
@@ -527,7 +534,7 @@ const searchOrders = defineRoute(
|
|
|
527
534
|
| `pageQuerySchema(options?)` | the same reading as a `Schema`, for a route whose whole query is the page |
|
|
528
535
|
| `pageResponse(page, map)` | the JSON body `{ items, total?, nextCursor? }`, each item through `map` |
|
|
529
536
|
| `pageRequestParameters(options?)` | the JSON Schema of the query (one OpenAPI parameter per property); `properties` merges into a wider schema |
|
|
530
|
-
| `pageSchemaOf(itemSchema)` | the `Schema` of a page of items: validates the envelope and each item, describes both in the contract |
|
|
537
|
+
| `pageSchemaOf(itemSchema)` | the `Schema` of a page of items: validates the envelope and each item, describes both in the contract; shared as `<Item>Page` when the item is shared ([shared schemas](#shared-schemas)) |
|
|
531
538
|
|
|
532
539
|
`options` are the `PageLimits` of the kernel (`defaultSize` 20, `maxSize` 100) plus `sortable`,
|
|
533
540
|
the closed list of fields a client may sort by, and `kind`, the variant of a query that names
|
|
@@ -609,6 +616,287 @@ issue per mistake, none quoting a value:
|
|
|
609
616
|
The scope of the actor is not a parameter: the handler of the query joins it with `scoped`,
|
|
610
617
|
and nothing in a query string can remove it.
|
|
611
618
|
|
|
619
|
+
## Representations: JSON, XML, CSV
|
|
620
|
+
|
|
621
|
+
A route keeps answering a typed value its response schema checks; a `Representation` turns it
|
|
622
|
+
into the text of one media type, chosen per request by the `Accept` header among those the
|
|
623
|
+
route declares. The application registers its representations once and gives the same set to
|
|
624
|
+
the adapters and to the contract generator:
|
|
625
|
+
|
|
626
|
+
```ts
|
|
627
|
+
import { Representations, type ExecuteOptions } from '@ddd-ts-kit/http';
|
|
628
|
+
|
|
629
|
+
const representations = Representations.standard(); // JSON, XML and CSV
|
|
630
|
+
const options: ExecuteOptions = { ...boundary, representations };
|
|
631
|
+
const document = generateOpenApi({ info, routes, errorMapper, representations });
|
|
632
|
+
```
|
|
633
|
+
|
|
634
|
+
A route says what it answers in besides JSON (`produces`) and what it reads a body in besides
|
|
635
|
+
JSON (`consumes`), on `@Controller` or on `defineRoute` alike:
|
|
636
|
+
|
|
637
|
+
```ts
|
|
638
|
+
@Controller({
|
|
639
|
+
group: PartnerRoutes, method: 'GET', path: '/:practiceId/appointments', summary: 'Export appointments',
|
|
640
|
+
params, response: { status: 200, body: streamSchemaOf(line) },
|
|
641
|
+
produces: ['text/csv', 'application/xml'],
|
|
642
|
+
})
|
|
643
|
+
```
|
|
644
|
+
|
|
645
|
+
| Media type | Answers | Reads | Notes |
|
|
646
|
+
|---|---|---|---|
|
|
647
|
+
| `application/json` | always, and first: what a request without `Accept` gets | always | as before; a big integer is written as a string |
|
|
648
|
+
| `application/problem+json` | a refusal, unless XML was negotiated | | RFC 9457, as before |
|
|
649
|
+
| `application/xml` | `XmlRepresentation` | `XmlRepresentation`, when the route `consumes` it | the convention below |
|
|
650
|
+
| `application/problem+xml` | a refusal of a request that negotiated XML | | `<problem xmlns="urn:ietf:rfc:7807">` |
|
|
651
|
+
| `text/csv` | `CsvRepresentation`, for a page or a list of flat rows | never | streamed; RFC 4180 |
|
|
652
|
+
|
|
653
|
+
- **Negotiation** (RFC 9110): the media type of highest quality among those the route offers,
|
|
654
|
+
the most specific range of the header deciding, the order `application/json` then `produces`
|
|
655
|
+
breaking ties. None acceptable: `406 NOT_ACCEPTABLE` in `application/problem+json`, before
|
|
656
|
+
the handler runs. A route that offers more than one answers with `Vary: accept`, added to the
|
|
657
|
+
`Vary` of its cache policy or the one its handler sets, and documented in the contract. A route that declares no body schema in any response (a file, a
|
|
658
|
+
redirect, no content) is never refused 406: its answer is its own, and a `Readable` or bytes
|
|
659
|
+
go out as the handler wrote them, under its content type.
|
|
660
|
+
- **Bodies**: a body sent in a media type the route consumes is read by its representation
|
|
661
|
+
into the value the JSON path produces, then validated by the same schema; one sent in a media
|
|
662
|
+
type the route does not read is refused with `415 UNSUPPORTED_MEDIA_TYPE`. `mountExpress`
|
|
663
|
+
installs a text parser on each route that consumes another media type, `mountFastify` a
|
|
664
|
+
content type parser, `mountHono` reads it as text under its `bodyLimit`: nothing to add to
|
|
665
|
+
the application.
|
|
666
|
+
- **Streaming**: a handler that answers an `AsyncIterable` under a `streamSchemaOf(item)`
|
|
667
|
+
response is written item by item in every representation (one JSON array, one XML root, one
|
|
668
|
+
CSV line per row), honouring the back pressure of the client and stopping when it leaves.
|
|
669
|
+
Each item is read inside the execution scope of the request, as the handler was. The first
|
|
670
|
+
item is read before the status is sent: a cursor that cannot open is answered as a problem. A
|
|
671
|
+
failure after that cuts the response short and is told to `onError` with the correlation of
|
|
672
|
+
the request and `interrupted: true`, to count as a server fault.
|
|
673
|
+
- **A streamed list read through the bus**: build it with `everyPage((cursor) =>
|
|
674
|
+
this.queries.execute(new SearchQuery(actor, ..., pageAt(cursor))))`, one query per page. Each
|
|
675
|
+
page then goes through the middlewares of the bus: authorization, the unit of work and its
|
|
676
|
+
transaction-scoped tenant session (the row-level security of `@ddd-ts-kit/knex` and
|
|
677
|
+
`@ddd-ts-kit/drizzle`), timeout, tracing, metrics, error reporting. A query handler that
|
|
678
|
+
answers a lazy `AsyncIterable` is read after the bus has returned, outside all of them: its
|
|
679
|
+
reads have no transaction, no tenant session, no span. The deadline of the request
|
|
680
|
+
(`requestTimeoutMs`) counts from its arrival, so a long export needs a route of its own with a
|
|
681
|
+
longer one, or a job that writes a file.
|
|
682
|
+
- **Mount-time checks**: a media type no registered representation provides, a CSV answer
|
|
683
|
+
whose rows hold a list or an object, and a consumed media type nothing reads are refused with
|
|
684
|
+
a `DeclarationError` when the routes are mounted; so is a route that declares `produces` or
|
|
685
|
+
`consumes` when no `representations` are mounted. A body in a consumed media type that another
|
|
686
|
+
parser (a plugin, a middleware) already turned into an object is a defect, answered 500.
|
|
687
|
+
- **The contract** follows the representations it is given, which must be those the server is
|
|
688
|
+
mounted with (`generateOpenApi({ representations })`): every media type a route answers in is
|
|
689
|
+
listed under its response, every media type it reads under its request body, the problem
|
|
690
|
+
types under each refusal, `406` on every route whose answer a representation writes and `415`
|
|
691
|
+
on every route that reads a body, declared in `produces` and `consumes` or not. Without
|
|
692
|
+
`representations`, the contract says JSON only and neither status, as the server answers.
|
|
693
|
+
- **Without `representations`**, nothing changes: every answer is JSON, whatever the request
|
|
694
|
+
accepts. With them, an answer in the JSON of the kit stays a value in the `RouteResponse` (a
|
|
695
|
+
spec calling `executeRoute` reads it as before); another representation gives bytes in
|
|
696
|
+
`body`, or chunks in `stream`.
|
|
697
|
+
|
|
698
|
+
### The serialization rules, the same in every representation
|
|
699
|
+
|
|
700
|
+
| Value | Written as |
|
|
701
|
+
|---|---|
|
|
702
|
+
| an instant (`Date`) | ISO 8601 in UTC, `2026-10-13T07:05:00.000Z` |
|
|
703
|
+
| a decimal | a string, `decimalText(value)`: `'12.30'`, never a binary number a client rounds |
|
|
704
|
+
| money | `money(amount, currency)`: `{ amount: '12.30', currency: 'EUR' }`, the ISO 4217 code always next to the amount |
|
|
705
|
+
| an identifier | a string; a `bigint` is written in full |
|
|
706
|
+
| a closed vocabulary | its code, the value of the object `as const` that declares it |
|
|
707
|
+
| a list | the page envelope `{ items, total?, nextCursor? }` of `pageResponse`, or a streamed list |
|
|
708
|
+
|
|
709
|
+
`standard-serialization.spec.ts` holds the three representations to this table.
|
|
710
|
+
|
|
711
|
+
### The XML convention
|
|
712
|
+
|
|
713
|
+
One convention, the default of the XML object of OpenAPI, so the contract describes the XML
|
|
714
|
+
with nothing added:
|
|
715
|
+
|
|
716
|
+
- the root element is `xml.name` of the response schema, else the operation id of the route
|
|
717
|
+
(`<getAppointment>`), and declares `xmlns:xsi`;
|
|
718
|
+
- a property is an element of its name, in the order of the schema; `xml.name` renames it,
|
|
719
|
+
`xml.attribute: true` makes a scalar an attribute; a name that cannot be an element name is
|
|
720
|
+
written `<entry key="two words">`;
|
|
721
|
+
- a list is unwrapped: one element per item, named after the property (or `items.xml.name`);
|
|
722
|
+
`xml.wrapped: true` puts them in an element of the property, each named `items.xml.name` or
|
|
723
|
+
`item`; a list at the root holds `<item>` elements;
|
|
724
|
+
- `null` is an empty element with `xsi:nil="true"`; a missing value is no element at all;
|
|
725
|
+
- a scalar is the text JSON would hold: an instant in ISO 8601 UTC, `true` or `false`, a
|
|
726
|
+
number as JavaScript writes it; a character XML 1.0 cannot carry becomes U+FFFD.
|
|
727
|
+
|
|
728
|
+
Reading follows the schema: text becomes a number or a boolean where the schema says so,
|
|
729
|
+
repeated elements a list, an element the schema does not declare stays in the value so the
|
|
730
|
+
schema refuses it as it refuses an unknown JSON property. The parser is the package's own and
|
|
731
|
+
reads elements, attributes, CDATA, comments, processing instructions, the predefined entities
|
|
732
|
+
and character references; it refuses a document type declaration, so no body can declare an
|
|
733
|
+
entity (no XXE, no expansion bomb), and nests at most 64 elements deep.
|
|
734
|
+
|
|
735
|
+
### CSV
|
|
736
|
+
|
|
737
|
+
One header line with the properties of a row in the order of the schema, then one line per
|
|
738
|
+
row, `\r\n` at the end of each. A cell holding a comma, a quote, a line break or surrounding
|
|
739
|
+
spaces is quoted; a text that starts with `=`, `+`, `-`, `@`, a tab or a carriage return is
|
|
740
|
+
prefixed with `'`, so a spreadsheet does not run it as a formula (a number never is). `null`
|
|
741
|
+
and a missing value are an empty cell. CSV is never read: an import is a route of its own,
|
|
742
|
+
with a body schema of its own.
|
|
743
|
+
|
|
744
|
+
### A representation of your own
|
|
745
|
+
|
|
746
|
+
```ts
|
|
747
|
+
class YamlRepresentation implements Representation {
|
|
748
|
+
readonly mediaType = 'application/yaml';
|
|
749
|
+
readonly problemMediaType = undefined; // refusals stay application/problem+json
|
|
750
|
+
|
|
751
|
+
write(body: unknown, shape: BodyShape): RepresentedBody { ... }
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
const representations = Representations.of(new XmlRepresentation(), new YamlRepresentation());
|
|
755
|
+
```
|
|
756
|
+
|
|
757
|
+
`write` gets the value and its shape (the JSON Schema of the response and the operation id);
|
|
758
|
+
`read`, when present, turns a body back into the value; `refuses`, when present, says at mount
|
|
759
|
+
time why a shape cannot be written. One given for `application/json` replaces the default.
|
|
760
|
+
|
|
761
|
+
## Fields reserved to some callers
|
|
762
|
+
|
|
763
|
+
A response or a request schema marks a field as requiring a permission or a policy; the
|
|
764
|
+
pipeline does the rest, for every representation, instead of an `if (admin)` in a handler:
|
|
765
|
+
|
|
766
|
+
```ts
|
|
767
|
+
import { fieldDeciderOf, withFieldAccess } from '@ddd-ts-kit/http';
|
|
768
|
+
|
|
769
|
+
const answer = withFieldAccess(classSchema(AppointmentAnswer), {
|
|
770
|
+
internalNote: {
|
|
771
|
+
read: { permission: schedulingPermissions['appointment.note.read'] },
|
|
772
|
+
write: { policy: notesOfTheirOwnCalendars }, // a policy of @ddd-ts-kit/auth fits as it is
|
|
773
|
+
subject: (row) => ({ type: 'calendar', id: row.calendarId }), // what the requirement is asked about
|
|
774
|
+
},
|
|
775
|
+
});
|
|
776
|
+
|
|
777
|
+
const options: ExecuteOptions = { ...boundary, fieldAccess: fieldDeciderOf({ access: app.resolve(Access), clock }) };
|
|
778
|
+
```
|
|
779
|
+
|
|
780
|
+
| Where | A field the actor may not read | A field the actor may read but not set |
|
|
781
|
+
|---|---|---|
|
|
782
|
+
| an answer (JSON, XML, CSV, a streamed list) | left out; in CSV the column stays, its cells empty | kept |
|
|
783
|
+
| a request body | refused with `403 FORBIDDEN`, naming the path (`body.internalNote`) | refused the same way |
|
|
784
|
+
| a form described by the server | absent | read-only |
|
|
785
|
+
| the contract | `x-field-access: { read: { permission }, write: { policy } }` on the property, which is no longer listed in `required` | the same |
|
|
786
|
+
|
|
787
|
+
- `read` absent: whoever may call the route sees the field; `write` absent: whoever sees it may
|
|
788
|
+
set it. A field left out of a body is never judged.
|
|
789
|
+
- A permission is decided by `access.decideOn(question)` of `@ddd-ts-kit/auth` (else
|
|
790
|
+
`access.decide`), the policies of the permission then the authorizer, as for a use case; a
|
|
791
|
+
policy named on the field is asked directly, with the time of `clock`. `subject` names the
|
|
792
|
+
element: left out, the requirement is asked about nothing, which a role grant answers and a
|
|
793
|
+
relationship does not.
|
|
794
|
+
- **What is recorded**: a field set in a body is an act, and its decision goes to the audit
|
|
795
|
+
trail (`onDecision`) with who asked and the correlation; a field shown or left out of an
|
|
796
|
+
answer or a form only shapes it, and its decision is not recorded. The use case keeps
|
|
797
|
+
recording its own decision.
|
|
798
|
+
- **Cost**: each requirement is decided once per element and per request, inside the execution
|
|
799
|
+
scope of the request. A requirement about no element is asked once; a page of a hundred rows
|
|
800
|
+
of the same calendar asks once. A streamed export whose rule names a subject per row asks one
|
|
801
|
+
decision per distinct row (one evaluation of the policies and of the authorizer, a lookup of
|
|
802
|
+
relationships for a relationship model); the judge remembers the last 256 elements per
|
|
803
|
+
requirement, so its memory stays bounded whatever the length of the export. For a long export,
|
|
804
|
+
prefer a rule without subject, or a read model that already holds only what the caller may
|
|
805
|
+
read.
|
|
806
|
+
- `pageSchemaOf(item)` and `streamSchemaOf(item)` carry the restricted fields of their item.
|
|
807
|
+
A shared schema carries them in either order: `withFieldAccess(sharedSchema('Note', schema),
|
|
808
|
+
rules)`, `withFieldAccess(classSchema(NoteDto, { shared: true }), rules)` and
|
|
809
|
+
`sharedSchema('Note', withFieldAccess(schema, rules))` mark the shared definition and filter
|
|
810
|
+
the answer alike.
|
|
811
|
+
- **A public cache policy**: an answer with a field some callers may not read differs per caller.
|
|
812
|
+
When the routes are mounted, a `public` policy on such a route is refused unless its `vary`
|
|
813
|
+
names `Authorization` or `Cookie`, whoever may call the route (see "HTTP caching").
|
|
814
|
+
The rules apply to the properties of the schema given to `withFieldAccess`; a nested object is
|
|
815
|
+
restricted by wrapping its own schema.
|
|
816
|
+
- Without `fieldAccess` in the options, a restricted field is left out of every answer and
|
|
817
|
+
refused in every body: nothing is shown by omission.
|
|
818
|
+
- The rule `authz/fields-by-schema` of the checker and of the ESLint plugin refuses the
|
|
819
|
+
hand-written alternative, a test on the roles of the actor under `application/queries/`;
|
|
820
|
+
`authz/in-application` already refuses one in `presentation/`.
|
|
821
|
+
|
|
822
|
+
## Forms described by the server
|
|
823
|
+
|
|
824
|
+
A route that declares `form` is described as a form, from what it already declares: its request
|
|
825
|
+
body schema, the restricted fields of that schema, and a few presentation hints. `formRoutes`
|
|
826
|
+
serves one `GET /forms/<operationId>` per such route, mounted and documented like any route:
|
|
827
|
+
|
|
828
|
+
```ts
|
|
829
|
+
// presentation/http/appointments/book-appointment/book-appointment.controller.ts, next to its schemas
|
|
830
|
+
const form = defineForm<Infer<typeof body>>({
|
|
831
|
+
groups: [{ name: 'when', fields: ['startsAt', 'appointmentTypeId'] }],
|
|
832
|
+
fields: {
|
|
833
|
+
appointmentTypeId: { lookup: 'searchAppointmentTypes' }, // options from a GET route
|
|
834
|
+
reason: { widget: 'textarea', visibleWhen: { field: 'kind', equals: AppointmentKind.consultation } },
|
|
835
|
+
},
|
|
836
|
+
});
|
|
837
|
+
|
|
838
|
+
@Controller({ ..., body, form })
|
|
839
|
+
|
|
840
|
+
// the composition root
|
|
841
|
+
const routes = defineRoutes(appRoutes, formRoutes(appRoutes, { fieldAccess }));
|
|
842
|
+
```
|
|
843
|
+
|
|
844
|
+
`GET /forms/bookAppointment?calendarId=c-1` answers **JSON Forms** (the default): `schema`,
|
|
845
|
+
`uischema` and `data`, which every renderer of JSON Forms takes as they are.
|
|
846
|
+
`?format=blocks` answers the **neutral tree of blocks** for a front end with its own engine:
|
|
847
|
+
|
|
848
|
+
```json
|
|
849
|
+
{ "type": "form", "operation": "bookAppointment", "method": "POST", "path": "/appointments", "label": "bookAppointment",
|
|
850
|
+
"blocks": [
|
|
851
|
+
{ "type": "group", "name": "when", "label": "bookAppointment.when", "blocks": [
|
|
852
|
+
{ "type": "field", "name": "startsAt", "label": "bookAppointment.startsAt", "widget": "datetime", "required": true,
|
|
853
|
+
"constraints": { "format": "date-time" } } ] },
|
|
854
|
+
{ "type": "field", "name": "internalNote", "label": "bookAppointment.internalNote", "widget": "textarea",
|
|
855
|
+
"required": false, "readOnly": true } ] }
|
|
856
|
+
```
|
|
857
|
+
|
|
858
|
+
| What | Taken from | In the tree | In JSON Forms |
|
|
859
|
+
|---|---|---|---|
|
|
860
|
+
| fields, their order, `required` | the request schema | `field` blocks | `schema` |
|
|
861
|
+
| constraints | `minLength`, `maxLength`, `minimum`, `maximum`, `exclusiveMinimum`, `exclusiveMaximum`, `multipleOf`, `pattern`, `format`, `minItems`, `maxItems` | `constraints` | the same keywords in `schema` |
|
|
862
|
+
| options | an `enum` of the schema (a closed vocabulary), else `options` of the hint | `options`, each with a translation key | `enum` |
|
|
863
|
+
| a lookup | `lookup: '<operationId>'` of a `GET` route | `lookup: { operation, method, path }` | `options.lookup` of the control |
|
|
864
|
+
| widget | the hint, else the schema: `select` for an enumeration, `checkbox`, `number`, `datetime`, `date`, `time`, `email`, `list`, `text` | `widget` | the control, `options.multi` for `textarea`, `options.format: 'radio'` |
|
|
865
|
+
| groups | `groups` of the hints, nested; a nested object of the body is a group of its own | `group` blocks | `Group` elements |
|
|
866
|
+
| a field shown on a condition | `visibleWhen: { field, equals }` or `{ field, in }` | `visibleWhen` | a `SHOW` rule |
|
|
867
|
+
| a field required on a condition | `requiredWhen` | `requiredWhen` | `allOf` of `if`/`then` in `schema` |
|
|
868
|
+
| labels | `<operationId>`, `<operationId>.<group>`, `<operationId>.<field>`, `<operationId>.<field>.<option>`; `label` of a hint replaces one | `label` | `i18n` |
|
|
869
|
+
| values known in advance | the query: `?calendarId=c-1`, typed by the schema | `value` | `data` |
|
|
870
|
+
|
|
871
|
+
**The description respects the caller.** A form names the permission of the use case it
|
|
872
|
+
describes, asked as its `@Requires` asks it, from the values of the query:
|
|
873
|
+
|
|
874
|
+
```ts
|
|
875
|
+
const form = defineForm<Infer<typeof body>>({
|
|
876
|
+
requires: {
|
|
877
|
+
permission: schedulingPermissions['appointment.book'],
|
|
878
|
+
subject: (values) => (values.calendarId === undefined ? undefined : { type: 'calendar', id: values.calendarId }),
|
|
879
|
+
context: (values, actor) => ({ selfService: (values.patientId ?? actor.id) === actor.id }),
|
|
880
|
+
},
|
|
881
|
+
});
|
|
882
|
+
```
|
|
883
|
+
|
|
884
|
+
A caller who may not run the use case is refused with 403 (recorded as a decision) and learns
|
|
885
|
+
nothing of the fields; without `fieldAccess`, nobody is given a form that declares `requires`.
|
|
886
|
+
A form without `requires` is given to whoever may call the route. Then a field the actor may not
|
|
887
|
+
read (`withFieldAccess`) is absent, one they may read but not set is `readOnly` (`readOnly` in
|
|
888
|
+
`schema`, `options.readonly` on the control), with every field it holds when it is an object,
|
|
889
|
+
each asked about the element its `subject` names from the values of the query; a value of the
|
|
890
|
+
query for a field the caller does not see is not given back in `data`. The form of a route that
|
|
891
|
+
is not public refuses the anonymous caller with 401. The server still validates the body when
|
|
892
|
+
it is sent, refuses a field the caller may not set with 403, and the use case still enforces
|
|
893
|
+
its rules: a form carries shape and presentation, never a business rule.
|
|
894
|
+
|
|
895
|
+
Hints naming a field the body does not hold, or a lookup that is no `GET` route, stop
|
|
896
|
+
`formRoutes` with a `DeclarationError`. `formDocumentsOf(routes)` gives every form whole, in
|
|
897
|
+
both formats, for the documentation: a project generated by the CLI writes them to
|
|
898
|
+
`openapi/forms/<operationId>.json` next to its contract.
|
|
899
|
+
|
|
612
900
|
## Express 5
|
|
613
901
|
|
|
614
902
|
```ts
|
|
@@ -632,6 +920,31 @@ mountFastify(app, orderRoutes(orders), options);
|
|
|
632
920
|
await app.register(fastifyRoutes(orderRoutes(orders), options), { prefix: '/api' });
|
|
633
921
|
```
|
|
634
922
|
|
|
923
|
+
## Hono 4
|
|
924
|
+
|
|
925
|
+
```ts
|
|
926
|
+
import { serve } from '@hono/node-server';
|
|
927
|
+
import { Hono } from 'hono';
|
|
928
|
+
import { mountHono } from '@ddd-ts-kit/http/hono';
|
|
929
|
+
|
|
930
|
+
const app = new Hono();
|
|
931
|
+
mountHono(app, orderRoutes(orders), options);
|
|
932
|
+
serve({ fetch: app.fetch, port: 3000 });
|
|
933
|
+
```
|
|
934
|
+
|
|
935
|
+
The adapter reads the JSON body itself, chunk by chunk and up to `bodyLimit` bytes (1 MiB by
|
|
936
|
+
default, as Fastify; Express stops at 100 kB): a larger body is answered 413 as a problem
|
|
937
|
+
(`BODY_TOO_LARGE`), a body that is not JSON 400 (`MALFORMED_BODY`), both before the pipeline and
|
|
938
|
+
without holding the body whole. A body in a media type the route consumes (`consumes`) is read
|
|
939
|
+
as text under the same limit, for its representation; another media type is not read, and the
|
|
940
|
+
pipeline answers 415 when representations are mounted. An upload and a raw body are read from
|
|
941
|
+
the request stream, with the limits their route declares, and a stream answer or a streamed
|
|
942
|
+
list is streamed. A request carries `HonoRaw` as
|
|
943
|
+
its raw request (its headers as a record, which the authenticators of the kit read, and the
|
|
944
|
+
`Context` of Hono), and a repeated query parameter is a list, as on Express and Fastify. The
|
|
945
|
+
adapter imports nothing of Hono at run time and `node:stream` for the streams: the kit proves
|
|
946
|
+
Node with `@hono/node-server`, not Bun, Deno or an edge runtime.
|
|
947
|
+
|
|
635
948
|
## NestJS
|
|
636
949
|
|
|
637
950
|
No decorator per route: a module mounts the routes on the underlying HTTP server at module
|
|
@@ -691,6 +1004,37 @@ whenever the route validates input, a shared `Problem` schema. Local `$defs` of
|
|
|
691
1004
|
moved to `components.schemas`. Paths, statuses and component keys are sorted: the output does
|
|
692
1005
|
not depend on the order of the routes, so the committed file diffs cleanly.
|
|
693
1006
|
|
|
1007
|
+
### Shared schemas
|
|
1008
|
+
|
|
1009
|
+
A schema several routes use is declared once and lands once in `components.schemas`; each route
|
|
1010
|
+
points at it with `$ref`, whether it uses it whole or inside another schema. A schema is shared
|
|
1011
|
+
when its JSON Schema is a reference to one of its own definitions, which every adapter of
|
|
1012
|
+
`@ddd-ts-kit/validation` can produce:
|
|
1013
|
+
|
|
1014
|
+
| Library | Shared by |
|
|
1015
|
+
|---|---|
|
|
1016
|
+
| zod | `.meta({ id: 'Slot' })` on the zod schema, used whole or nested |
|
|
1017
|
+
| class-validator | `classSchema(SlotDto, { shared: true })`; a nested class is always a component |
|
|
1018
|
+
| TypeBox | `{ $id: 'Slot' }` in the options of the schema, used whole or nested |
|
|
1019
|
+
| Standard Schema | the library's own ids through Standard JSON Schema, or `sharedSchema('Slot', schema)` |
|
|
1020
|
+
| any `Schema` | `sharedSchema(name, schema)` of `@ddd-ts-kit/validation` |
|
|
1021
|
+
|
|
1022
|
+
A part of a shared schema (`slot.pick(...)`, `pickClass(SlotDto, [...])`) is a new shape: it is
|
|
1023
|
+
written where it is used unless it is shared under a name of its own. Two different shapes under
|
|
1024
|
+
one name get distinct components (`Slot`, `Slot_2`): for zod, the input and the output side of a
|
|
1025
|
+
schema with defaults are two shapes, so a response gets an id of its own.
|
|
1026
|
+
|
|
1027
|
+
The platform shares three schemas of its own:
|
|
1028
|
+
|
|
1029
|
+
| Schema | Component | For |
|
|
1030
|
+
|---|---|---|
|
|
1031
|
+
| `acceptedSchema` | `Accepted`, `{ id }` | the answer of every command route that returns the identifier of what it created or changed |
|
|
1032
|
+
| `pageSchemaOf(item)` | `<Item>Page` when the item is shared | the envelope of a search answer (`items`, `total`, `nextCursor`) |
|
|
1033
|
+
| the problem document | `Problem` | every refusal, RFC 9457 with the stable `code` |
|
|
1034
|
+
|
|
1035
|
+
A shared request part (`params`, `query`, `headers`) still gives one parameter per property.
|
|
1036
|
+
Fields reserved by `withFieldAccess` stay reserved whichever of the two wraps the other.
|
|
1037
|
+
|
|
694
1038
|
## Serving the contract and its page
|
|
695
1039
|
|
|
696
1040
|
```ts
|
|
@@ -795,12 +1139,30 @@ Express, mount them before `express.json()`: that parser reads a JSON body first
|
|
|
795
1139
|
store answers its own links and needs no route.
|
|
796
1140
|
|
|
797
1141
|
A handler may answer a stream (`Readable`) as its body: it is piped to the response, with its
|
|
798
|
-
own `content-type
|
|
1142
|
+
own `content-type`, whatever `representations` the routes are mounted with: no representation
|
|
1143
|
+
writes a file, and a route that declares no body schema is never refused 406.
|
|
799
1144
|
|
|
800
1145
|
## Limits
|
|
801
1146
|
|
|
802
1147
|
- A body the framework itself refuses (malformed JSON, payload too large) is answered by the
|
|
803
1148
|
framework's own error handler, before the pipeline runs.
|
|
804
1149
|
- Routes are JSON first. A handler may answer a string, bytes or a stream by setting its own
|
|
805
|
-
`content-type` header. A request body streams only as a
|
|
806
|
-
(`rawBody`): server-sent events and WebSockets are written
|
|
1150
|
+
`content-type` header, which no representation touches. A request body streams only as a
|
|
1151
|
+
declared upload or a raw body (`rawBody`): server-sent events and WebSockets are written
|
|
1152
|
+
natively in the framework.
|
|
1153
|
+
- XML is a faithful rendering of the JSON model, not a design tool for XML vocabularies: no
|
|
1154
|
+
namespaces but the default one of the root, no mixed content, no XML Schema. A partner format
|
|
1155
|
+
with a schema of its own is an anti-corruption layer with its own mapper.
|
|
1156
|
+
- A streamed list cannot be refused once its first item is written: the connection is cut,
|
|
1157
|
+
the client sees a truncated body, and `onError` is told. The items of a stream are not checked
|
|
1158
|
+
one by one by `validateResponses`.
|
|
1159
|
+
- CSV is written, never read, and holds flat rows only.
|
|
1160
|
+
- A form describes scalars, nested objects and lists of a closed vocabulary; a list of objects
|
|
1161
|
+
is a `list` field with no detail. Layout beyond groups and order is the front end's. A lookup
|
|
1162
|
+
names the route of the options; how the front end calls it and labels its items is its own.
|
|
1163
|
+
- Field access judges the fields a schema declares, not the rows: which rows an actor may read is
|
|
1164
|
+
the access scope of the query. A requirement about an element is one decision per element of
|
|
1165
|
+
the answer, not recorded; there is no batch decision of many elements at once.
|
|
1166
|
+
- A form is given to who may run its use case only when it declares `requires`; the values of
|
|
1167
|
+
its query name the element and the context, which the caller chooses, as they would in the
|
|
1168
|
+
body they send.
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;AAS9E;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,SAAS,CAAC,eAAe,GAAG,gBAAgB,CAAC,EAAE,EAC5D,OAAO,GAAE,uBAA4B,GACpC,SAAS,KAAK,EAAE,CAMlB"}
|
|
@@ -42,6 +42,7 @@ function documentationOf({ spec, declared, guards }) {
|
|
|
42
42
|
responses: { [status]: { description: description ?? defaultDescription(body), ...bodyOf(body) } },
|
|
43
43
|
errors: [...new Set([...declared.errors, ...guards.flatMap((guard) => guard.documents?.errors ?? [])])],
|
|
44
44
|
...(spec.deprecated === true ? { deprecated: true } : {}),
|
|
45
|
+
...presentationOf(spec),
|
|
45
46
|
};
|
|
46
47
|
}
|
|
47
48
|
function handlerOf(resolved, options, identity) {
|
|
@@ -81,6 +82,13 @@ function requestOf(parts) {
|
|
|
81
82
|
}).filter(([, schema]) => schema !== undefined);
|
|
82
83
|
return declared.length === 0 ? {} : { request: Object.fromEntries(declared) };
|
|
83
84
|
}
|
|
85
|
+
function presentationOf({ produces, consumes, form }) {
|
|
86
|
+
return {
|
|
87
|
+
...(produces === undefined ? {} : { produces: [...produces] }),
|
|
88
|
+
...(consumes === undefined ? {} : { consumes: [...consumes] }),
|
|
89
|
+
...(form === undefined ? {} : { form }),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
84
92
|
function bodyOf(body) {
|
|
85
93
|
return body === undefined ? {} : { body };
|
|
86
94
|
}
|
|
@@ -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,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;
|
|
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,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAWtE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,kBAAkB,EAA2B,MAAM,0BAA0B,CAAC;AAEvF,MAAM,gBAAgB,GAAG,CAAC,QAAQ,CAAC,CAAC;AAEpC;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAC9B,WAA4D,EAC5D,OAAO,GAA4B,EAAE;IAErC,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,kBAAkB,CAAC,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;IAExG,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAE3B,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,OAAO,CAAC,QAA4B,EAAE,OAAgC;IAC7E,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,QAAQ,CAAC;IACpC,MAAM,QAAQ,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,EAAE,QAAQ,CAAC,WAAW,EAAE,CAAC;IACjG,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C,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,5 @@
|
|
|
1
1
|
import type { Schema } from '@ddd-ts-kit/validation';
|
|
2
|
+
import type { FormHints } from '../forms/form-hints.js';
|
|
2
3
|
import type { CachePolicy } from '../cache/cache-policy.js';
|
|
3
4
|
import type { IfMatch } from '../cache/if-match.js';
|
|
4
5
|
import type { HttpMethod } from '../route/http-method.js';
|
|
@@ -35,6 +36,12 @@ export interface ControllerSpec {
|
|
|
35
36
|
/** Run after the guards of the group. With no group, at least one is required: `[Public]` says the route is open. */
|
|
36
37
|
readonly guards?: readonly GuardReference[];
|
|
37
38
|
readonly deprecated?: boolean;
|
|
39
|
+
/** Media types answered besides `application/json`, chosen by `Accept`: `['application/xml', 'text/csv']`. */
|
|
40
|
+
readonly produces?: readonly string[];
|
|
41
|
+
/** Media types a body is read in besides `application/json`: `['application/xml']`. */
|
|
42
|
+
readonly consumes?: readonly string[];
|
|
43
|
+
/** Describes the body as a form at `GET /forms/<operationId>` (`formRoutes`): `defineForm(...)` next to the schemas, or `{}`. */
|
|
44
|
+
readonly form?: FormHints;
|
|
38
45
|
/** How the caches on the way may keep the answer; replaces the policy of the group. */
|
|
39
46
|
readonly cache?: CachePolicy;
|
|
40
47
|
/** A write conditional on the version the client read, handed to `handle` as `context.expectedVersion`. */
|
|
@@ -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,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpD,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;IACzB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,sCAAsC;IACtC,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,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ACtC,iIAAiI;IACjI,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC;IAC1B,uFAAuF;IACvF,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC;IAC7B,2GAA2G;IAC3G,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;CAC5B"}
|
|
@@ -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,YAanC,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,mBAAmB,EAAE,GAAG;IACxB,qBAAqB,EAAE,GAAG;IAC1B,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,cAAc,EAAE,GAAG;IACnB,mBAAmB,EAAE,GAAG;IACxB,qBAAqB,EAAE,GAAG;IAC1B,cAAc,EAAE,GAAG;IACnB,cAAc,EAAE,GAAG;IACnB,sBAAsB,EAAE,GAAG;CAC5B,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type IRouter } from 'express';
|
|
2
2
|
import type { ExecuteOptions } from '../pipeline/execute-options.js';
|
|
3
3
|
import type { Route } from '../route/route.js';
|
|
4
4
|
export type ExpressMountOptions = ExecuteOptions;
|
|
@@ -6,7 +6,9 @@ export type ExpressMountOptions = ExecuteOptions;
|
|
|
6
6
|
* Registers the routes on an Express 5 application or router. A JSON body parser
|
|
7
7
|
* (`express.json()`) must be installed before, otherwise bodies reach validation as `undefined`.
|
|
8
8
|
* An upload and a raw body are read from the request stream, which that parser leaves alone
|
|
9
|
-
* unless the request is JSON
|
|
9
|
+
* unless the request is JSON; a route that consumes another media type (`consumes`) gets a text
|
|
10
|
+
* parser of its own for it. A body that is a stream is piped to the response, a streamed list
|
|
11
|
+
* written chunk by chunk.
|
|
10
12
|
*/
|
|
11
13
|
export declare function mountExpress(target: IRouter, routes: readonly Route[], options?: ExpressMountOptions): void;
|
|
12
14
|
//# sourceMappingURL=mount-express.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mount-express.d.ts","sourceRoot":"","sources":["../../src/express/mount-express.ts"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"mount-express.d.ts","sourceRoot":"","sources":["../../src/express/mount-express.ts"],"names":[],"mappings":"AAEA,OAAgB,EAAE,KAAK,OAAO,EAAoD,MAAM,SAAS,CAAC;AAClG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAQrE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE/C,MAAM,MAAM,mBAAmB,GAAG,cAAc,CAAC;AAMjD;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,KAAK,EAAE,EAAE,OAAO,GAAE,mBAAwB,GAAG,IAAI,CAU/G"}
|