@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form-routes.js","sourceRoot":"","sources":["../../src/forms/form-routes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,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Q,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC7F,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form-schema.d.ts","sourceRoot":"","sources":["../../src/forms/form-schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAIzD,mFAAmF;AACnF,eAAO,MAAM,WAAW,EAAE,UAiDzB,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const BLOCK = { $ref: '#/$defs/FormBlock' };
|
|
2
|
+
/** What the contract says of a form: JSON Forms, or the neutral tree of blocks. */
|
|
3
|
+
export const FORM_SCHEMA = {
|
|
4
|
+
oneOf: [
|
|
5
|
+
{
|
|
6
|
+
type: 'object',
|
|
7
|
+
description: 'JSON Forms: give the three to a renderer for React, Angular or Vue.',
|
|
8
|
+
required: ['schema', 'uischema', 'data'],
|
|
9
|
+
properties: { schema: { type: 'object' }, uischema: { type: 'object' }, data: { type: 'object' } },
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
type: 'object',
|
|
13
|
+
description: 'The neutral tree of blocks, for a front end with its own rendering engine.',
|
|
14
|
+
required: ['type', 'operation', 'method', 'path', 'label', 'blocks'],
|
|
15
|
+
properties: {
|
|
16
|
+
type: { const: 'form' },
|
|
17
|
+
operation: { type: 'string' },
|
|
18
|
+
method: { type: 'string' },
|
|
19
|
+
path: { type: 'string' },
|
|
20
|
+
label: { type: 'string', description: 'A translation key.' },
|
|
21
|
+
blocks: { type: 'array', items: BLOCK },
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
$defs: {
|
|
26
|
+
FormBlock: {
|
|
27
|
+
type: 'object',
|
|
28
|
+
description: 'A group (`type: group`, `blocks`) or a field (`type: field`, `widget`, `required`, `readOnly`, `constraints`, `options`, `lookup`, `visibleWhen`, `requiredWhen`, `value`). Labels are translation keys.',
|
|
29
|
+
required: ['type', 'name', 'label'],
|
|
30
|
+
properties: {
|
|
31
|
+
type: { enum: ['group', 'field'] },
|
|
32
|
+
name: { type: 'string' },
|
|
33
|
+
label: { type: 'string' },
|
|
34
|
+
widget: { type: 'string' },
|
|
35
|
+
required: { type: 'boolean' },
|
|
36
|
+
readOnly: { type: 'boolean' },
|
|
37
|
+
constraints: { type: 'object' },
|
|
38
|
+
options: { type: 'array', items: { type: 'object', properties: { value: {}, label: { type: 'string' } } } },
|
|
39
|
+
multiple: { type: 'boolean' },
|
|
40
|
+
lookup: {
|
|
41
|
+
type: 'object',
|
|
42
|
+
properties: { operation: { type: 'string' }, method: { type: 'string' }, path: { type: 'string' } },
|
|
43
|
+
},
|
|
44
|
+
visibleWhen: { type: 'object' },
|
|
45
|
+
requiredWhen: { type: 'object' },
|
|
46
|
+
value: {},
|
|
47
|
+
blocks: { type: 'array', items: BLOCK },
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=form-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form-schema.js","sourceRoot":"","sources":["../../src/forms/form-schema.ts"],"names":[],"mappings":"AAEA,MAAM,KAAK,GAAG,EAAE,IAAI,EAAE,mBAAmB,EAAE,CAAC;AAE5C,mFAAmF;AACnF,MAAM,CAAC,MAAM,WAAW,GAAe;IACrC,KAAK,EAAE;QACL;YACE,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,qEAAqE;YAClF,QAAQ,EAAE,CAAC,QAAQ,EAAE,UAAU,EAAE,MAAM,CAAC;YACxC,UAAU,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;SACnG;QACD;YACE,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,4EAA4E;YAC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QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;gBAC7B,MAAM,EAAE;oBACN,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;iBACpG;gBACD,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBAC/B,YAAY,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBAChC,KAAK,EAAE,EAAE;gBACT,MAAM,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE;aACxC;SACF;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** A group of blocks of a form, which may hold groups of its own: `Block` is a `FormBlock`. */
|
|
2
|
+
export interface GroupBlock<Block = unknown> {
|
|
3
|
+
readonly type: 'group';
|
|
4
|
+
readonly name: string;
|
|
5
|
+
/** A translation key: `<operationId>.<group>`. */
|
|
6
|
+
readonly label: string;
|
|
7
|
+
readonly blocks: readonly Block[];
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=group-block.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group-block.d.ts","sourceRoot":"","sources":["../../src/forms/group-block.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,MAAM,WAAW,UAAU,CAAC,KAAK,GAAG,OAAO;IACzC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,kDAAkD;IAClD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,SAAS,KAAK,EAAE,CAAC;CACnC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group-block.js","sourceRoot":"","sources":["../../src/forms/group-block.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { JsonSchema } from '@ddd-ts-kit/validation';
|
|
2
|
+
/** A form in JSON Forms: what its renderers take as `schema`, `uischema` and `data`. */
|
|
3
|
+
export interface JsonForm {
|
|
4
|
+
readonly schema: JsonSchema;
|
|
5
|
+
readonly uischema: JsonSchema;
|
|
6
|
+
readonly data: Readonly<Record<string, unknown>>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=json-form.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-form.d.ts","sourceRoot":"","sources":["../../src/forms/json-form.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzD,wFAAwF;AACxF,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAClD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-form.js","sourceRoot":"","sources":["../../src/forms/json-form.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { SchemaNode } from '../schema/schema-node.js';
|
|
2
|
+
import type { FormDescription } from './form-description.js';
|
|
3
|
+
import type { JsonForm } from './json-form.js';
|
|
4
|
+
/**
|
|
5
|
+
* The form in JSON Forms, the recommended default: a JSON Schema of what the caller may see
|
|
6
|
+
* (read-only where they may not set), a UI schema of groups and controls whose labels are
|
|
7
|
+
* translation keys (`i18n`), rules for conditional visibility, `if`/`then` for a field required
|
|
8
|
+
* by a condition, and the values the request gave as `data`. Every renderer of JSON Forms
|
|
9
|
+
* (React, Angular, Vue) takes the three as they are.
|
|
10
|
+
*/
|
|
11
|
+
export declare function jsonFormsOf(description: FormDescription, body: SchemaNode, data: Readonly<Record<string, unknown>>): JsonForm;
|
|
12
|
+
//# sourceMappingURL=json-forms-of.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-forms-of.d.ts","sourceRoot":"","sources":["../../src/forms/json-forms-of.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAK3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAO/C;;;;;;GAMG;AACH,wBAAgB,WAAW,CACzB,WAAW,EAAE,eAAe,EAC5B,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACtC,QAAQ,CAMV"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { isRecord } from '../support/is-record.js';
|
|
2
|
+
const MAX_DEPTH = 16;
|
|
3
|
+
const WIDGET_FORMATS = { datetime: 'date-time', date: 'date', time: 'time' };
|
|
4
|
+
/** What a schema says of itself and of other documents, which a self-contained form schema does not need. */
|
|
5
|
+
const LEFT_OUT = new Set(['$ref', '$defs', 'definitions', '$schema', '$id', 'x-field-access']);
|
|
6
|
+
/**
|
|
7
|
+
* The form in JSON Forms, the recommended default: a JSON Schema of what the caller may see
|
|
8
|
+
* (read-only where they may not set), a UI schema of groups and controls whose labels are
|
|
9
|
+
* translation keys (`i18n`), rules for conditional visibility, `if`/`then` for a field required
|
|
10
|
+
* by a condition, and the values the request gave as `data`. Every renderer of JSON Forms
|
|
11
|
+
* (React, Angular, Vue) takes the three as they are.
|
|
12
|
+
*/
|
|
13
|
+
export function jsonFormsOf(description, body, data) {
|
|
14
|
+
return {
|
|
15
|
+
schema: objectSchema(description.blocks, body),
|
|
16
|
+
uischema: { type: 'VerticalLayout', elements: elementsOf(description.blocks, '#') },
|
|
17
|
+
data: visibleData(description.blocks, data),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/** The values the request gave, for the fields the caller sees only: a hidden field is not echoed back. */
|
|
21
|
+
function visibleData(blocks, data) {
|
|
22
|
+
return Object.fromEntries(fieldsOf(blocks).flatMap((field) => {
|
|
23
|
+
const name = lastSegment(field.name);
|
|
24
|
+
const value = data[name];
|
|
25
|
+
if (value === undefined) {
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
return [[name, field.widget === 'group' && isRecord(value) ? visibleData(field.blocks ?? [], value) : value]];
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
/** The schema of one object of the form, its properties in the order of the request schema whatever the layout. */
|
|
32
|
+
function objectSchema(blocks, node) {
|
|
33
|
+
const children = new Map(node.properties());
|
|
34
|
+
const order = [...children.keys()];
|
|
35
|
+
const fields = fieldsOf(blocks).sort((a, b) => order.indexOf(lastSegment(a.name)) - order.indexOf(lastSegment(b.name)));
|
|
36
|
+
const conditional = fields.flatMap((field) => field.requiredWhen === undefined ? [] : [requiredWhen(field, field.requiredWhen)]);
|
|
37
|
+
return {
|
|
38
|
+
type: 'object',
|
|
39
|
+
properties: Object.fromEntries(fields.map((field) => [lastSegment(field.name), propertySchema(field, children.get(lastSegment(field.name)))])),
|
|
40
|
+
required: fields.filter((field) => field.required).map((field) => lastSegment(field.name)),
|
|
41
|
+
...(conditional.length === 0 ? {} : { allOf: conditional }),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function propertySchema(field, node) {
|
|
45
|
+
if (node === undefined) {
|
|
46
|
+
return {};
|
|
47
|
+
}
|
|
48
|
+
if (field.widget === 'group') {
|
|
49
|
+
return { ...objectSchema(field.blocks ?? [], node), ...(field.readOnly === true ? { readOnly: true } : {}) };
|
|
50
|
+
}
|
|
51
|
+
const own = inlined(node, 0);
|
|
52
|
+
return {
|
|
53
|
+
...own,
|
|
54
|
+
...(field.readOnly === true ? { readOnly: true } : {}),
|
|
55
|
+
...(field.options !== undefined && own['enum'] === undefined && field.multiple !== true
|
|
56
|
+
? { enum: field.options.map(({ value }) => value) }
|
|
57
|
+
: {}),
|
|
58
|
+
...formatOf(field),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/** A widget of an instant says the format a renderer picks its control by, whatever format the schema library wrote. */
|
|
62
|
+
function formatOf({ widget }) {
|
|
63
|
+
const format = WIDGET_FORMATS[widget];
|
|
64
|
+
return format === undefined ? {} : { format };
|
|
65
|
+
}
|
|
66
|
+
/** The node with every reference followed, so the form schema holds itself. */
|
|
67
|
+
function inlined(node, depth) {
|
|
68
|
+
const own = Object.fromEntries(Object.entries(node.node).filter(([key]) => !LEFT_OUT.has(key)));
|
|
69
|
+
if (depth >= MAX_DEPTH) {
|
|
70
|
+
return own;
|
|
71
|
+
}
|
|
72
|
+
const properties = node.properties();
|
|
73
|
+
return {
|
|
74
|
+
...own,
|
|
75
|
+
...(properties.length === 0
|
|
76
|
+
? {}
|
|
77
|
+
: { properties: Object.fromEntries(properties.map(([name, child]) => [name, inlined(child, depth + 1)])) }),
|
|
78
|
+
...(isRecord(node.node['items']) ? { items: inlined(node.items(), depth + 1) } : {}),
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function elementsOf(blocks, scope) {
|
|
82
|
+
return blocks.map((block) => {
|
|
83
|
+
if (block.type === 'group') {
|
|
84
|
+
return { type: 'Group', label: block.label, i18n: block.label, elements: elementsOf(block.blocks, scope) };
|
|
85
|
+
}
|
|
86
|
+
const own = `${scope}/properties/${lastSegment(block.name)}`;
|
|
87
|
+
if (block.widget === 'group') {
|
|
88
|
+
return { type: 'Group', label: block.label, i18n: block.label, elements: elementsOf(block.blocks ?? [], own) };
|
|
89
|
+
}
|
|
90
|
+
return control(block, own);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
function control(field, scope) {
|
|
94
|
+
const options = {
|
|
95
|
+
...(field.widget === 'textarea' ? { multi: true } : {}),
|
|
96
|
+
...(field.widget === 'radio' ? { format: 'radio' } : {}),
|
|
97
|
+
...(field.readOnly === true ? { readonly: true } : {}),
|
|
98
|
+
...(field.lookup === undefined ? {} : { lookup: field.lookup }),
|
|
99
|
+
};
|
|
100
|
+
return {
|
|
101
|
+
type: 'Control',
|
|
102
|
+
scope,
|
|
103
|
+
i18n: field.label,
|
|
104
|
+
...(Object.keys(options).length === 0 ? {} : { options }),
|
|
105
|
+
...(field.visibleWhen === undefined ? {} : { rule: { effect: 'SHOW', condition: conditionOf(field.visibleWhen) } }),
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function conditionOf(condition) {
|
|
109
|
+
return {
|
|
110
|
+
scope: scopeOf(condition.field),
|
|
111
|
+
schema: 'equals' in condition ? { const: condition.equals } : { enum: [...condition.in] },
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
function requiredWhen(field, condition) {
|
|
115
|
+
const name = lastSegment(condition.field);
|
|
116
|
+
const matching = 'equals' in condition ? { const: condition.equals } : { enum: [...condition.in] };
|
|
117
|
+
return { if: { properties: { [name]: matching }, required: [name] }, then: { required: [lastSegment(field.name)] } };
|
|
118
|
+
}
|
|
119
|
+
/** The fields of one level of the body, whatever group of the layout holds them. */
|
|
120
|
+
function fieldsOf(blocks) {
|
|
121
|
+
return blocks.flatMap((block) => (block.type === 'group' ? fieldsOf(block.blocks) : [block]));
|
|
122
|
+
}
|
|
123
|
+
function scopeOf(path) {
|
|
124
|
+
return `#/properties/${path.split('.').join('/properties/')}`;
|
|
125
|
+
}
|
|
126
|
+
function lastSegment(path) {
|
|
127
|
+
return path.slice(path.lastIndexOf('.') + 1);
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=json-forms-of.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-forms-of.js","sourceRoot":"","sources":["../../src/forms/json-forms-of.ts"],"names":[],"mapp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I,CAAC,EAAE,QAAQ,EAAE,EAAE,QAAQ,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,CAAC;AACvH,CAAC;AAED,oFAAoF;AACpF,SAAS,QAAQ,CAAC,MAA4B;IAC5C,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAChG,CAAC;AAED,SAAS,OAAO,CAAC,IAAY;IAC3B,OAAO,gBAAgB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC;AAChE,CAAC;AAED,SAAS,WAAW,CAAC,IAAY;IAC/B,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Route } from '../route/route.js';
|
|
2
|
+
import type { FieldLookup } from './field-lookup.js';
|
|
3
|
+
/** The `GET` routes a field may take its options from, by operation id. */
|
|
4
|
+
export declare function lookupsOf(routes: readonly Route[]): ReadonlyMap<string, FieldLookup>;
|
|
5
|
+
//# sourceMappingURL=lookups-of.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lookups-of.d.ts","sourceRoot":"","sources":["../../src/forms/lookups-of.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,2EAA2E;AAC3E,wBAAgB,SAAS,CAAC,MAAM,EAAE,SAAS,KAAK,EAAE,GAAG,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,CAMpF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** The `GET` routes a field may take its options from, by operation id. */
|
|
2
|
+
export function lookupsOf(routes) {
|
|
3
|
+
return new Map(routes
|
|
4
|
+
.filter((route) => route.method === 'GET')
|
|
5
|
+
.map((route) => [route.operationId, { operation: route.operationId, method: 'GET', path: route.path }]));
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=lookups-of.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lookups-of.js","sourceRoot":"","sources":["../../src/forms/lookups-of.ts"],"names":[],"mappings":"AAGA,2EAA2E;AAC3E,MAAM,UAAU,SAAS,CAAC,MAAwB;IAChD,OAAO,IAAI,GAAG,CACZ,MAAM;SACH,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC;SACzC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,KAAK,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAC1G,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SchemaNode } from '../schema/schema-node.js';
|
|
2
|
+
import type { Widget } from './widget.js';
|
|
3
|
+
/** The widget a field gets when its hint names none, from its schema. */
|
|
4
|
+
export declare function widgetOf(node: SchemaNode): Widget;
|
|
5
|
+
//# sourceMappingURL=widget-of.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widget-of.d.ts","sourceRoot":"","sources":["../../src/forms/widget-of.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAS1C,yEAAyE;AACzE,wBAAgB,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAsBjD"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const BY_FORMAT = {
|
|
2
|
+
'date-time': 'datetime',
|
|
3
|
+
date: 'date',
|
|
4
|
+
time: 'time',
|
|
5
|
+
email: 'email',
|
|
6
|
+
};
|
|
7
|
+
/** The widget a field gets when its hint names none, from its schema. */
|
|
8
|
+
export function widgetOf(node) {
|
|
9
|
+
if (node.node['enum'] !== undefined) {
|
|
10
|
+
return 'select';
|
|
11
|
+
}
|
|
12
|
+
const type = node.type();
|
|
13
|
+
if (type === 'boolean') {
|
|
14
|
+
return 'checkbox';
|
|
15
|
+
}
|
|
16
|
+
if (type === 'number' || type === 'integer') {
|
|
17
|
+
return 'number';
|
|
18
|
+
}
|
|
19
|
+
if (type === 'array') {
|
|
20
|
+
return 'list';
|
|
21
|
+
}
|
|
22
|
+
const format = node.node['format'];
|
|
23
|
+
return (typeof format === 'string' ? BY_FORMAT[format] : undefined) ?? 'text';
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=widget-of.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widget-of.js","sourceRoot":"","sources":["../../src/forms/widget-of.ts"],"names":[],"mappings":"AAGA,MAAM,SAAS,GAAqC;IAClD,WAAW,EAAE,UAAU;IACvB,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,OAAO;CACf,CAAC;AAEF,yEAAyE;AACzE,MAAM,UAAU,QAAQ,CAAC,IAAgB;IACvC,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,SAAS,EAAE,CAAC;QACpC,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IAEzB,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,IAAI,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QAC5C,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;QACrB,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAEnC,OAAO,CAAC,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,MAAM,CAAC;AAChF,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/** How a field is entered: what a block of the form says, and what a renderer maps to a control of its own. */
|
|
2
|
+
export type Widget = 'text' | 'textarea' | 'number' | 'checkbox' | 'select' | 'radio' | 'date' | 'datetime' | 'time' | 'email' | 'password' | 'group' | 'list';
|
|
3
|
+
//# sourceMappingURL=widget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widget.d.ts","sourceRoot":"","sources":["../../src/forms/widget.ts"],"names":[],"mappings":"AAAA,+GAA+G;AAC/G,MAAM,MAAM,MAAM,GACd,MAAM,GACN,UAAU,GACV,QAAQ,GACR,UAAU,GACV,QAAQ,GACR,OAAO,GACP,MAAM,GACN,UAAU,GACV,MAAM,GACN,OAAO,GACP,UAAU,GACV,OAAO,GACP,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widget.js","sourceRoot":"","sources":["../../src/forms/widget.ts"],"names":[],"mappings":""}
|
|
@@ -4,8 +4,10 @@ import type { HonoMountOptions } from './hono-mount-options.js';
|
|
|
4
4
|
/**
|
|
5
5
|
* Registers the routes on a Hono application. The adapter reads the JSON body itself, up to
|
|
6
6
|
* `bodyLimit` (1 MiB by default): a larger body is answered 413 and a body that is not JSON 400,
|
|
7
|
-
* both as problems, before the pipeline runs.
|
|
8
|
-
*
|
|
7
|
+
* both as problems, before the pipeline runs. A body in a media type the route consumes
|
|
8
|
+
* (`consumes`) is read as text under the same limit, for its representation. An upload and a raw
|
|
9
|
+
* body are read from the request stream; a body that is a stream, or a streamed list, is
|
|
10
|
+
* streamed to the response.
|
|
9
11
|
*/
|
|
10
12
|
export declare function mountHono(app: Pick<Hono, 'on'>, routes: readonly Route[], options?: HonoMountOptions): void;
|
|
11
13
|
//# sourceMappingURL=mount-hono.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mount-hono.d.ts","sourceRoot":"","sources":["../../src/hono/mount-hono.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAW,IAAI,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"mount-hono.d.ts","sourceRoot":"","sources":["../../src/hono/mount-hono.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAW,IAAI,EAAE,MAAM,MAAM,CAAC;AAQ1C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAShE;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,SAAS,KAAK,EAAE,EAAE,OAAO,GAAE,gBAAqB,GAAG,IAAI,CAQ/G"}
|
package/dist/hono/mount-hono.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Readable } from 'node:stream';
|
|
2
|
+
import { assertCachedRoutes } from '../pipeline/assert-cached-routes.js';
|
|
2
3
|
import { executeRoute } from '../pipeline/execute-route.js';
|
|
3
4
|
import { serializeBody } from '../pipeline/serialize-body.js';
|
|
5
|
+
import { assertServed } from '../representation/assert-served.js';
|
|
4
6
|
import { assertUniqueRoutes } from '../route/assert-unique-routes.js';
|
|
5
7
|
import { edgeProblem } from './edge-problem.js';
|
|
6
8
|
import { readBody } from './read-body.js';
|
|
@@ -9,11 +11,15 @@ const ONE_MEBIBYTE = 1_048_576;
|
|
|
9
11
|
/**
|
|
10
12
|
* Registers the routes on a Hono application. The adapter reads the JSON body itself, up to
|
|
11
13
|
* `bodyLimit` (1 MiB by default): a larger body is answered 413 and a body that is not JSON 400,
|
|
12
|
-
* both as problems, before the pipeline runs.
|
|
13
|
-
*
|
|
14
|
+
* both as problems, before the pipeline runs. A body in a media type the route consumes
|
|
15
|
+
* (`consumes`) is read as text under the same limit, for its representation. An upload and a raw
|
|
16
|
+
* body are read from the request stream; a body that is a stream, or a streamed list, is
|
|
17
|
+
* streamed to the response.
|
|
14
18
|
*/
|
|
15
19
|
export function mountHono(app, routes, options = {}) {
|
|
16
20
|
assertUniqueRoutes(routes);
|
|
21
|
+
assertServed(routes, options.representations);
|
|
22
|
+
assertCachedRoutes(routes, options);
|
|
17
23
|
for (const route of routes) {
|
|
18
24
|
app.on(route.method, route.path, handlerOf(route, options));
|
|
19
25
|
}
|
|
@@ -21,7 +27,7 @@ export function mountHono(app, routes, options = {}) {
|
|
|
21
27
|
function handlerOf(route, options) {
|
|
22
28
|
const { bodyLimit = ONE_MEBIBYTE, ...execute } = options;
|
|
23
29
|
return async (context) => {
|
|
24
|
-
const request = streamed(route) ? streamRequest(context) : await
|
|
30
|
+
const request = streamed(route) ? streamRequest(context) : await bodyRequest(context, route, bodyLimit);
|
|
25
31
|
if (request instanceof Response) {
|
|
26
32
|
return request;
|
|
27
33
|
}
|
|
@@ -39,8 +45,8 @@ function streamRequest(context) {
|
|
|
39
45
|
...(body === null ? {} : { stream: Readable.fromWeb(body) }),
|
|
40
46
|
};
|
|
41
47
|
}
|
|
42
|
-
async function
|
|
43
|
-
const body = await readBody(context, limit);
|
|
48
|
+
async function bodyRequest(context, route, limit) {
|
|
49
|
+
const body = await readBody(context, limit, route.consumes);
|
|
44
50
|
if (!body.read) {
|
|
45
51
|
return edgeProblem(context.req.header(), body.refusal);
|
|
46
52
|
}
|
|
@@ -52,8 +58,14 @@ function common(context) {
|
|
|
52
58
|
return { params: context.req.param(), query: queryOf(context), headers, raw };
|
|
53
59
|
}
|
|
54
60
|
function responseOf(result) {
|
|
55
|
-
|
|
56
|
-
|
|
61
|
+
return new Response(sentOf(result), { status: result.status, headers: result.headers });
|
|
62
|
+
}
|
|
63
|
+
/** A file as it is, a streamed list as a stream of its chunks, anything else serialized. */
|
|
64
|
+
function sentOf(result) {
|
|
65
|
+
if (result.body instanceof Readable) {
|
|
66
|
+
return Readable.toWeb(result.body);
|
|
67
|
+
}
|
|
68
|
+
return result.stream === undefined ? (serializeBody(result) ?? null) : Readable.toWeb(Readable.from(result.stream));
|
|
57
69
|
}
|
|
58
70
|
/** A repeated key keeps its values as a list, a single one is a string: what Express and Fastify answer. */
|
|
59
71
|
function queryOf(context) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mount-hono.js","sourceRoot":"","sources":["../../src/hono/mount-hono.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAG5D,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAEtE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAI1C,gGAAgG;AAChG,MAAM,YAAY,GAAG,SAAS,CAAC;AAE/B
|
|
1
|
+
{"version":3,"file":"mount-hono.js","sourceRoot":"","sources":["../../src/hono/mount-hono.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OA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|
9
9
|
};
|
|
10
10
|
/**
|
|
11
|
-
* The JSON body of the request, `undefined` when there is none;
|
|
12
|
-
*
|
|
11
|
+
* The JSON body of the request, `undefined` when there is none; a body in a media type the route
|
|
12
|
+
* consumes (`consumes`), as text, for its representation to read; not read in any other media
|
|
13
|
+
* type. Read chunk by chunk and given up beyond `limit` bytes, so that no body is held whole past it.
|
|
13
14
|
*/
|
|
14
|
-
export declare function readBody(context: Context, limit: number): Promise<ReadBody>;
|
|
15
|
+
export declare function readBody(context: Context, limit: number, consumed?: readonly string[]): Promise<ReadBody>;
|
|
15
16
|
//# sourceMappingURL=read-body.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-body.d.ts","sourceRoot":"","sources":["../../src/hono/read-body.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"read-body.d.ts","sourceRoot":"","sources":["../../src/hono/read-body.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,MAAM,MAAM,QAAQ,GAChB;IAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAChD;IAAE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAA;CAAE,CAAC;AAW5D;;;;GAIG;AACH,wBAAsB,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,GAAE,SAAS,MAAM,EAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAmBnH"}
|
package/dist/hono/read-body.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { mediaTypeOf } from '../representation/media-type-of.js';
|
|
1
2
|
const JSON_MEDIA = /[/+]json\b/;
|
|
2
3
|
const MALFORMED = {
|
|
3
4
|
status: 400,
|
|
@@ -6,18 +7,24 @@ const MALFORMED = {
|
|
|
6
7
|
detail: 'The body is not valid JSON.',
|
|
7
8
|
};
|
|
8
9
|
/**
|
|
9
|
-
* The JSON body of the request, `undefined` when there is none;
|
|
10
|
-
*
|
|
10
|
+
* The JSON body of the request, `undefined` when there is none; a body in a media type the route
|
|
11
|
+
* consumes (`consumes`), as text, for its representation to read; not read in any other media
|
|
12
|
+
* type. Read chunk by chunk and given up beyond `limit` bytes, so that no body is held whole past it.
|
|
11
13
|
*/
|
|
12
|
-
export async function readBody(context, limit) {
|
|
13
|
-
|
|
14
|
+
export async function readBody(context, limit, consumed = []) {
|
|
15
|
+
const contentType = context.req.header('content-type') ?? '';
|
|
16
|
+
const json = JSON_MEDIA.test(contentType);
|
|
17
|
+
if (!json && !consumed.includes(mediaTypeOf(contentType) ?? '')) {
|
|
14
18
|
return { read: true, value: undefined };
|
|
15
19
|
}
|
|
16
20
|
const text = await boundedText(context.req.raw, limit);
|
|
17
21
|
if (text === undefined) {
|
|
18
22
|
return { read: false, refusal: tooLarge(limit) };
|
|
19
23
|
}
|
|
20
|
-
|
|
24
|
+
if (text === '') {
|
|
25
|
+
return { read: true, value: undefined };
|
|
26
|
+
}
|
|
27
|
+
return json ? parsed(text) : { read: true, value: text };
|
|
21
28
|
}
|
|
22
29
|
async function boundedText(request, limit) {
|
|
23
30
|
if (Number(request.headers.get('content-length') ?? 0) > limit) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-body.js","sourceRoot":"","sources":["../../src/hono/read-body.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"read-body.js","sourceRoot":"","sources":["../../src/hono/read-body.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAOjE,MAAM,UAAU,GAAG,YAAY,CAAC;AAE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AAS;KAC1D,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -48,6 +48,7 @@ export { ResponseContractError } from './error/response-contract-error.js';
|
|
|
48
48
|
export { statusTitle } from './error/status-title.js';
|
|
49
49
|
export { toProblem } from './error/to-problem.js';
|
|
50
50
|
export { UnauthorizedError } from './error/unauthorized-error.js';
|
|
51
|
+
export { everyPage } from './pagination/every-page.js';
|
|
51
52
|
export type { PageBody } from './pagination/page-body.js';
|
|
52
53
|
export type { PageQueryOptions } from './pagination/page-query-options.js';
|
|
53
54
|
export { pageQuerySchema } from './pagination/page-query-schema.js';
|
|
@@ -55,6 +56,46 @@ export { pageRequestFrom } from './pagination/page-request-from.js';
|
|
|
55
56
|
export { pageRequestParameters } from './pagination/page-request-parameters.js';
|
|
56
57
|
export { pageResponse } from './pagination/page-response.js';
|
|
57
58
|
export { pageSchemaOf } from './pagination/page-schema-of.js';
|
|
59
|
+
export type { BodyShape } from './representation/body-shape.js';
|
|
60
|
+
export { CsvRepresentation } from './representation/csv/csv-representation.js';
|
|
61
|
+
export { JsonRepresentation } from './representation/json-representation.js';
|
|
62
|
+
export { negotiate } from './representation/negotiate.js';
|
|
63
|
+
export { NOT_ACCEPTABLE, NotAcceptableError } from './representation/not-acceptable-error.js';
|
|
64
|
+
export type { RepresentedBody } from './representation/represented-body.js';
|
|
65
|
+
export { Representation } from './representation/representation.js';
|
|
66
|
+
export { Representations, type Chosen } from './representation/representations.js';
|
|
67
|
+
export { streamSchemaOf } from './representation/stream-schema-of.js';
|
|
68
|
+
export { UNSUPPORTED_MEDIA_TYPE, UnsupportedMediaTypeError } from './representation/unsupported-media-type-error.js';
|
|
69
|
+
export { wireText } from './representation/wire-text.js';
|
|
70
|
+
export { XmlRepresentation } from './representation/xml/xml-representation.js';
|
|
71
|
+
export { decimalText } from './serialization/decimal-text.js';
|
|
72
|
+
export type { MoneyBody } from './serialization/money-body.js';
|
|
73
|
+
export { money } from './serialization/money.js';
|
|
74
|
+
export type { FieldDecider } from './field-access/field-decider.js';
|
|
75
|
+
export type { FieldQuestion } from './field-access/field-question.js';
|
|
76
|
+
export { fieldDeciderOf, type FieldAccessDecisions, type FieldDeciderOptions, } from './field-access/field-decider-of.js';
|
|
77
|
+
export type { FieldPolicy } from './field-access/field-policy.js';
|
|
78
|
+
export type { FieldRequirement } from './field-access/field-requirement.js';
|
|
79
|
+
export type { FieldRule } from './field-access/field-rule.js';
|
|
80
|
+
export type { FieldRules } from './field-access/field-rules.js';
|
|
81
|
+
export { withFieldAccess } from './field-access/with-field-access.js';
|
|
82
|
+
export { defineForm, type TypedFormHints } from './forms/define-form.js';
|
|
83
|
+
export type { FieldBlock } from './forms/field-block.js';
|
|
84
|
+
export type { FieldHint } from './forms/field-hint.js';
|
|
85
|
+
export type { FieldLookup } from './forms/field-lookup.js';
|
|
86
|
+
export type { FormBlock } from './forms/form-block.js';
|
|
87
|
+
export type { FormCondition } from './forms/form-condition.js';
|
|
88
|
+
export type { FormDescription } from './forms/form-description.js';
|
|
89
|
+
export type { FormDocument } from './forms/form-document.js';
|
|
90
|
+
export { formDocumentsOf } from './forms/form-documents-of.js';
|
|
91
|
+
export { FormFormat } from './forms/form-format.js';
|
|
92
|
+
export type { FormGroupHint } from './forms/form-group-hint.js';
|
|
93
|
+
export type { FormHints } from './forms/form-hints.js';
|
|
94
|
+
export type { FormRequirement } from './forms/form-requirement.js';
|
|
95
|
+
export { formRoutes, type FormRoutesOptions } from './forms/form-routes.js';
|
|
96
|
+
export type { GroupBlock } from './forms/group-block.js';
|
|
97
|
+
export type { JsonForm } from './forms/json-form.js';
|
|
98
|
+
export type { Widget } from './forms/widget.js';
|
|
58
99
|
export { CORRELATION_HEADER } from './pipeline/correlation-header.js';
|
|
59
100
|
export type { ErrorContext } from './pipeline/error-context.js';
|
|
60
101
|
export type { GuardRefusal } from './pipeline/guard-refusal.js';
|
|
@@ -90,6 +131,7 @@ export type { Accepted } from './schemas/accepted.js';
|
|
|
90
131
|
export { acceptedSchema } from './schemas/accepted-schema.js';
|
|
91
132
|
export type { UploadSpec } from './route/upload-spec.js';
|
|
92
133
|
export { firstTenantOf } from './tenancy/first-tenant-of.js';
|
|
134
|
+
export { servedTenantOf } from './tenancy/served-tenant-of.js';
|
|
93
135
|
export { tenantFromClaim } from './tenancy/tenant-from-claim.js';
|
|
94
136
|
export { tenantFromHeader } from './tenancy/tenant-from-header.js';
|
|
95
137
|
export { tenantFromPath } from './tenancy/tenant-from-path.js';
|