@opra/common 0.14.0 → 0.16.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/cjs/document/api-document.js +211 -0
- package/cjs/document/constants.js +6 -0
- package/cjs/document/data-type/api-field.js +82 -0
- package/cjs/document/data-type/builtin/any.type.js +14 -0
- package/cjs/document/data-type/builtin/base64.type.js +38 -0
- package/cjs/document/data-type/builtin/bigint.type.js +33 -0
- package/cjs/document/data-type/builtin/boolean.type.js +28 -0
- package/cjs/document/data-type/builtin/date.type.js +18 -0
- package/cjs/document/data-type/builtin/guid.type.js +35 -0
- package/cjs/document/data-type/builtin/index.js +13 -0
- package/cjs/document/data-type/builtin/integer.type.js +28 -0
- package/cjs/document/data-type/builtin/number.type.js +33 -0
- package/cjs/document/data-type/builtin/object.type.js +20 -0
- package/cjs/document/data-type/builtin/string.type.js +24 -0
- package/cjs/document/data-type/builtin/time.type.js +32 -0
- package/cjs/document/data-type/builtin/timestamp.type.js +29 -0
- package/cjs/document/data-type/complex-type.js +154 -0
- package/cjs/document/data-type/data-type.js +46 -0
- package/cjs/document/data-type/enum-type.js +62 -0
- package/cjs/document/data-type/mapped-type.js +96 -0
- package/cjs/document/data-type/simple-type.js +61 -0
- package/cjs/document/data-type/union-type.js +81 -0
- package/cjs/document/factory/add-references.js +20 -0
- package/cjs/document/factory/create-document.js +81 -0
- package/cjs/document/factory/factory.js +62 -0
- package/cjs/document/factory/import-resource-class.js +54 -0
- package/cjs/document/factory/import-type-class.js +137 -0
- package/cjs/document/factory/index.js +4 -0
- package/cjs/document/factory/process-resources.js +55 -0
- package/cjs/document/factory/process-types.js +191 -0
- package/cjs/document/index.js +17 -0
- package/cjs/document/resource/collection.js +185 -0
- package/cjs/document/resource/resource.js +38 -0
- package/cjs/document/resource/singleton.js +91 -0
- package/cjs/exception/opra-exception.js +2 -0
- package/cjs/exception/resource-errors/resource-not-found.error.js +4 -0
- package/cjs/filter/parse.js +3 -1
- package/cjs/helpers/function-utils.js +25 -0
- package/cjs/helpers/get-stack-filename.js +24 -0
- package/cjs/helpers/index.js +7 -0
- package/cjs/{utils → helpers}/is-url.js +2 -2
- package/cjs/{schema/utils/clone-object.util.js → helpers/object-utils.js} +13 -1
- package/cjs/{utils/path-to-tree.js → helpers/path-to-object-tree.js} +9 -9
- package/cjs/helpers/responsive-map.js +62 -14
- package/cjs/{utils → helpers}/type-guards.js +12 -5
- package/cjs/http/{param-codec → codecs}/boolean-codec.js +1 -2
- package/{esm/http/param-codec → cjs/http/codecs}/date-codec.js +5 -4
- package/cjs/http/{param-codec → codecs}/filter-codec.js +1 -2
- package/cjs/http/{param-codec → codecs}/number-codec.js +1 -3
- package/cjs/http/{param-codec → codecs}/string-codec.js +1 -3
- package/cjs/http/enums/http-headers-codes.enum.js +13 -4
- package/cjs/http/enums/http-status-messages.js +68 -0
- package/cjs/http/http-headers.js +138 -124
- package/cjs/http/http-message.host.js +251 -0
- package/cjs/http/http-params.js +78 -45
- package/cjs/http/http-request-message.js +152 -0
- package/cjs/http/http-response-message.js +238 -0
- package/cjs/http/index.js +8 -11
- package/cjs/http/multipart/batch-multipart.js +169 -153
- package/cjs/http/multipart/http-request-content.js +16 -11
- package/cjs/http/multipart/http-response-content.js +13 -10
- package/cjs/http/multipart/index.js +1 -3
- package/cjs/i18n/i18n.js +1 -1
- package/cjs/index.js +6 -5
- package/cjs/schema/constants.js +2 -9
- package/cjs/schema/data-type/complex-type.interface.js +7 -0
- package/cjs/schema/data-type/enum-type.interface.js +7 -0
- package/cjs/schema/data-type/mapped-type.interface.js +7 -0
- package/cjs/schema/data-type/simple-type.interface.js +7 -0
- package/cjs/schema/data-type/union-type.interface.js +7 -0
- package/cjs/schema/index.js +42 -26
- package/cjs/schema/resource/collection.interface.js +7 -0
- package/cjs/schema/resource/container.interface.js +7 -0
- package/cjs/schema/resource/resource.interface.js +2 -0
- package/cjs/schema/resource/singleton.interface.js +7 -0
- package/cjs/schema/type-guards.js +59 -0
- package/cjs/types.js +2 -0
- package/cjs/url/index.js +2 -2
- package/cjs/url/opra-url-path-component.js +2 -2
- package/cjs/url/opra-url-path.js +7 -4
- package/cjs/url/opra-url.js +86 -117
- package/cjs/url/utils/{path-utils.js → decode-path-component.js} +1 -46
- package/cjs/url/utils/encode-path-component.js +27 -0
- package/cjs/utils/path-utils.js +24 -0
- package/esm/document/api-document.js +211 -0
- package/esm/document/constants.js +6 -0
- package/esm/document/data-type/api-field.js +82 -0
- package/esm/document/data-type/builtin/any.type.js +14 -0
- package/esm/document/data-type/builtin/base64.type.js +38 -0
- package/esm/document/data-type/builtin/bigint.type.js +33 -0
- package/esm/document/data-type/builtin/boolean.type.js +28 -0
- package/esm/document/data-type/builtin/date.type.js +18 -0
- package/esm/document/data-type/builtin/guid.type.js +35 -0
- package/esm/document/data-type/builtin/index.js +13 -0
- package/esm/document/data-type/builtin/integer.type.js +28 -0
- package/esm/document/data-type/builtin/number.type.js +33 -0
- package/esm/document/data-type/builtin/object.type.js +20 -0
- package/esm/document/data-type/builtin/string.type.js +24 -0
- package/esm/document/data-type/builtin/time.type.js +32 -0
- package/esm/document/data-type/builtin/timestamp.type.js +29 -0
- package/esm/document/data-type/complex-type.js +154 -0
- package/esm/document/data-type/data-type.js +46 -0
- package/esm/document/data-type/enum-type.js +62 -0
- package/esm/document/data-type/mapped-type.js +96 -0
- package/esm/document/data-type/simple-type.js +61 -0
- package/esm/document/data-type/union-type.js +81 -0
- package/esm/document/factory/add-references.js +20 -0
- package/esm/document/factory/create-document.js +81 -0
- package/esm/document/factory/factory.js +62 -0
- package/esm/document/factory/import-resource-class.js +54 -0
- package/esm/document/factory/import-type-class.js +137 -0
- package/esm/document/factory/index.js +4 -0
- package/esm/document/factory/process-resources.js +55 -0
- package/esm/document/factory/process-types.js +191 -0
- package/esm/document/index.js +17 -0
- package/esm/document/resource/collection.js +185 -0
- package/esm/document/resource/resource.js +38 -0
- package/esm/document/resource/singleton.js +91 -0
- package/esm/document/utils/inspect.util.js +7 -0
- package/esm/document/utils/string-compare.util.js +11 -0
- package/esm/exception/enums/issue-severity.enum.js +5 -2
- package/esm/exception/error-issue.js +2 -1
- package/esm/exception/http-errors/bad-request.error.js +8 -4
- package/esm/exception/http-errors/failed-dependency.error.js +8 -4
- package/esm/exception/http-errors/forbidden.error.js +8 -4
- package/esm/exception/http-errors/internal-server.error.js +8 -4
- package/esm/exception/http-errors/method-not-allowed.error.js +8 -4
- package/esm/exception/http-errors/not-acceptable.error.js +8 -4
- package/esm/exception/http-errors/not-found.error.js +8 -4
- package/esm/exception/http-errors/unauthorized.error.js +8 -4
- package/esm/exception/http-errors/unprocessable-entity.error.js +8 -4
- package/esm/exception/index.js +18 -15
- package/esm/exception/opra-exception.js +9 -3
- package/esm/exception/resource-errors/resource-conflict.error.js +8 -4
- package/esm/exception/resource-errors/resource-not-found.error.js +12 -4
- package/esm/exception/wrap-exception.js +24 -20
- package/esm/filter/antlr/OpraFilterLexer.js +9 -6
- package/esm/filter/antlr/OpraFilterListener.js +5 -2
- package/esm/filter/antlr/OpraFilterParser.js +126 -79
- package/esm/filter/antlr/OpraFilterVisitor.js +5 -2
- package/esm/filter/ast/abstract/ast.js +5 -1
- package/esm/filter/ast/abstract/expression.js +6 -2
- package/esm/filter/ast/abstract/literal.js +6 -2
- package/esm/filter/ast/abstract/term.js +6 -2
- package/esm/filter/ast/expressions/arithmetic-expression.js +8 -3
- package/esm/filter/ast/expressions/array-expression.js +6 -2
- package/esm/filter/ast/expressions/comparison-expression.js +6 -2
- package/esm/filter/ast/expressions/logical-expression.js +6 -2
- package/esm/filter/ast/expressions/parentheses-expression.js +6 -2
- package/esm/filter/ast/index.js +19 -16
- package/esm/filter/ast/terms/boolean-literal.js +6 -2
- package/esm/filter/ast/terms/date-literal.js +12 -8
- package/esm/filter/ast/terms/external-constant.js +6 -2
- package/esm/filter/ast/terms/null-literal.js +6 -2
- package/esm/filter/ast/terms/number-literal.js +8 -4
- package/esm/filter/ast/terms/qualified-identifier.js +6 -2
- package/esm/filter/ast/terms/string-literal.js +8 -4
- package/esm/filter/ast/terms/time-literal.js +10 -6
- package/esm/filter/build.js +69 -45
- package/esm/filter/errors.js +9 -3
- package/esm/filter/filter-tree-visitor.js +31 -26
- package/esm/filter/index.js +8 -5
- package/esm/filter/opra-error-listener.js +8 -4
- package/esm/filter/parse.js +22 -15
- package/esm/filter/utils.js +7 -2
- package/esm/helpers/function-utils.js +25 -0
- package/esm/helpers/get-stack-filename.js +24 -0
- package/esm/helpers/index.js +11 -1
- package/esm/helpers/is-url.js +8 -0
- package/esm/{schema/type-helpers/mixin.utils.js → helpers/mixin-utils.js} +7 -2
- package/esm/helpers/object-utils.js +31 -0
- package/esm/helpers/path-to-object-tree.js +28 -0
- package/esm/helpers/responsive-map.js +67 -15
- package/esm/{utils → helpers}/type-guards.js +24 -8
- package/esm/http/{param-codec → codecs}/boolean-codec.js +5 -2
- package/{cjs/http/param-codec → esm/http/codecs}/date-codec.js +1 -4
- package/{cjs/url/formats/filter-format.js → esm/http/codecs/filter-codec.js} +5 -6
- package/{cjs/url/formats/integer-format.js → esm/http/codecs/integer-codec.js} +6 -6
- package/esm/http/{param-codec → codecs}/number-codec.js +5 -3
- package/esm/http/{param-codec → codecs}/string-codec.js +5 -3
- package/esm/http/enums/http-headers-codes.enum.js +18 -6
- package/esm/http/enums/http-status-codes.enum.js +5 -2
- package/esm/http/enums/http-status-messages.js +68 -0
- package/esm/http/http-headers.js +144 -126
- package/esm/http/http-message.host.js +251 -0
- package/esm/http/http-params.js +86 -49
- package/esm/http/http-request-message.js +152 -0
- package/esm/http/http-response-message.js +238 -0
- package/esm/http/index.js +17 -17
- package/esm/http/interfaces/client-http-headers.interface.js +2 -1
- package/esm/http/interfaces/cookie-options.interface.js +2 -0
- package/esm/http/interfaces/server-http-headers.interface.js +2 -1
- package/esm/http/multipart/batch-multipart.js +170 -149
- package/esm/http/multipart/http-request-content.js +17 -8
- package/esm/http/multipart/http-response-content.js +14 -7
- package/esm/http/multipart/index.js +2 -1
- package/esm/i18n/i18n.js +28 -23
- package/esm/i18n/index.js +9 -5
- package/esm/i18n/string-utils.js +7 -2
- package/esm/i18n/translate.js +7 -3
- package/esm/index.js +16 -10
- package/esm/schema/constants.js +4 -8
- package/esm/schema/data-type/complex-type.interface.js +7 -0
- package/esm/schema/data-type/data-type.interface.js +2 -0
- package/esm/schema/data-type/enum-type.interface.js +7 -0
- package/esm/schema/data-type/field.interface.js +2 -0
- package/esm/schema/data-type/mapped-type.interface.js +7 -0
- package/esm/schema/data-type/simple-type.interface.js +7 -0
- package/esm/schema/data-type/union-type.interface.js +7 -0
- package/esm/schema/document.interface.js +2 -0
- package/esm/schema/index.js +44 -25
- package/esm/schema/resource/collection.interface.js +7 -0
- package/esm/schema/resource/container.interface.js +7 -0
- package/esm/schema/resource/endpoint.interface.js +2 -0
- package/esm/schema/resource/resource.interface.js +2 -0
- package/esm/schema/resource/singleton.interface.js +7 -0
- package/esm/schema/type-guards.js +59 -0
- package/esm/types.js +2 -0
- package/esm/url/index.js +8 -5
- package/esm/url/opra-url-path-component.js +7 -3
- package/esm/url/opra-url-path.js +19 -12
- package/esm/url/opra-url.js +100 -127
- package/esm/url/utils/decode-path-component.js +41 -0
- package/esm/url/utils/encode-path-component.js +27 -0
- package/esm/utils/path-utils.js +24 -0
- package/package.json +23 -7
- package/types/document/api-document.d.ts +102 -0
- package/types/document/constants.d.ts +3 -0
- package/types/document/data-type/api-field.d.ts +41 -0
- package/types/document/data-type/builtin/any.type.d.ts +2 -0
- package/types/document/data-type/builtin/base64.type.d.ts +6 -0
- package/types/document/data-type/builtin/bigint.type.d.ts +6 -0
- package/types/document/data-type/builtin/boolean.type.d.ts +5 -0
- package/types/document/data-type/builtin/date.type.d.ts +4 -0
- package/types/document/data-type/builtin/guid.type.d.ts +7 -0
- package/types/document/data-type/builtin/index.d.ts +10 -0
- package/types/document/data-type/builtin/integer.type.d.ts +6 -0
- package/types/document/data-type/builtin/number.type.d.ts +6 -0
- package/types/document/data-type/builtin/object.type.d.ts +3 -0
- package/types/document/data-type/builtin/string.type.d.ts +5 -0
- package/types/document/data-type/builtin/time.type.d.ts +7 -0
- package/types/document/data-type/builtin/timestamp.type.d.ts +5 -0
- package/types/document/data-type/complex-type.d.ts +50 -0
- package/types/document/data-type/data-type.d.ts +33 -0
- package/types/document/data-type/enum-type.d.ts +32 -0
- package/types/document/data-type/mapped-type.d.ts +53 -0
- package/types/document/data-type/simple-type.d.ts +33 -0
- package/types/document/data-type/union-type.d.ts +42 -0
- package/types/document/factory/add-references.d.ts +4 -0
- package/types/document/factory/create-document.d.ts +12 -0
- package/types/document/factory/factory.d.ts +61 -0
- package/types/document/factory/import-resource-class.d.ts +10 -0
- package/types/document/factory/import-type-class.d.ts +17 -0
- package/types/document/factory/index.d.ts +1 -0
- package/types/document/factory/process-resources.d.ts +7 -0
- package/types/document/factory/process-types.d.ts +6 -0
- package/types/document/index.d.ts +14 -0
- package/types/document/resource/collection.d.ts +67 -0
- package/types/document/resource/resource.d.ts +29 -0
- package/types/document/resource/singleton.d.ts +49 -0
- package/{esm → types}/exception/resource-errors/resource-not-found.error.d.ts +4 -0
- package/types/helpers/function-utils.d.ts +4 -0
- package/types/helpers/get-stack-filename.d.ts +1 -0
- package/types/helpers/index.d.ts +8 -0
- package/types/helpers/is-url.d.ts +1 -0
- package/{esm/schema/utils/clone-object.util.d.ts → types/helpers/object-utils.d.ts} +1 -0
- package/types/helpers/path-to-object-tree.d.ts +4 -0
- package/types/helpers/responsive-map.d.ts +34 -0
- package/{esm/utils → types/helpers}/type-guards.d.ts +3 -1
- package/types/http/codecs/boolean-codec.d.ts +5 -0
- package/{esm/http/param-codec → types/http/codecs}/date-codec.d.ts +2 -2
- package/{esm/http/param-codec → types/http/codecs}/filter-codec.d.ts +2 -2
- package/types/http/codecs/integer-codec.d.ts +11 -0
- package/types/http/codecs/number-codec.d.ts +14 -0
- package/types/http/codecs/string-codec.d.ts +16 -0
- package/{esm → types}/http/enums/http-headers-codes.enum.d.ts +13 -4
- package/types/http/enums/http-status-messages.d.ts +65 -0
- package/types/http/http-headers.d.ts +86 -0
- package/types/http/http-message.host.d.ts +122 -0
- package/{esm → types}/http/http-params.d.ts +43 -29
- package/types/http/http-request-message.d.ts +213 -0
- package/types/http/http-response-message.d.ts +318 -0
- package/types/http/index.d.ts +14 -0
- package/types/http/interfaces/cookie-options.interface.d.ts +4 -0
- package/types/http/multipart/http-request-content.d.ts +0 -0
- package/types/http/multipart/http-response-content.d.ts +0 -0
- package/types/http/multipart/index.d.ts +0 -0
- package/{esm → types}/index.d.ts +6 -5
- package/types/schema/constants.d.ts +2 -0
- package/types/schema/data-type/complex-type.interface.d.ts +16 -0
- package/types/schema/data-type/data-type.interface.d.ts +14 -0
- package/types/schema/data-type/enum-type.interface.d.ts +15 -0
- package/types/schema/data-type/field.interface.d.ts +21 -0
- package/types/schema/data-type/mapped-type.interface.d.ts +11 -0
- package/types/schema/data-type/simple-type.interface.d.ts +18 -0
- package/types/schema/data-type/union-type.interface.d.ts +10 -0
- package/types/schema/document.interface.d.ts +34 -0
- package/types/schema/index.d.ts +51 -0
- package/types/schema/resource/collection.interface.d.ts +33 -0
- package/types/schema/resource/container.interface.d.ts +9 -0
- package/types/schema/resource/endpoint.interface.d.ts +29 -0
- package/types/schema/resource/resource.interface.d.ts +12 -0
- package/types/schema/resource/singleton.interface.d.ts +22 -0
- package/types/schema/type-guards.d.ts +20 -0
- package/{esm/schema → types}/types.d.ts +0 -3
- package/{esm → types}/url/index.d.ts +2 -2
- package/{esm → types}/url/opra-url.d.ts +10 -29
- package/types/url/utils/decode-path-component.d.ts +5 -0
- package/types/url/utils/encode-path-component.d.ts +1 -0
- package/types/utils/path-utils.d.ts +2 -0
- package/cjs/constants.js +0 -1
- package/cjs/http/http-param-codec.js +0 -6
- package/cjs/http/http-request-node.js +0 -105
- package/cjs/http/http-request.js +0 -89
- package/cjs/http/http-response.js +0 -23
- package/cjs/http/utils/encodeURIParam.js +0 -21
- package/cjs/http/utils/normalize-headers.js +0 -28
- package/cjs/schema/decorators/opr-collection-resource.decorator.js +0 -24
- package/cjs/schema/decorators/opr-complex-type.decorator.js +0 -28
- package/cjs/schema/decorators/opr-field.decorator.js +0 -29
- package/cjs/schema/decorators/opr-resolver.decorator.js +0 -81
- package/cjs/schema/decorators/opr-simple-type.decorator.js +0 -19
- package/cjs/schema/decorators/opr-singleton-resource.decorator.js +0 -24
- package/cjs/schema/implementation/data-type/builtin/any.type.js +0 -9
- package/cjs/schema/implementation/data-type/builtin/base64-binary.type.js +0 -15
- package/cjs/schema/implementation/data-type/builtin/bigint.type.js +0 -15
- package/cjs/schema/implementation/data-type/builtin/boolean.type.js +0 -15
- package/cjs/schema/implementation/data-type/builtin/date-string.type.js +0 -15
- package/cjs/schema/implementation/data-type/builtin/date.type.js +0 -15
- package/cjs/schema/implementation/data-type/builtin/guid.type.js +0 -15
- package/cjs/schema/implementation/data-type/builtin/integer.type.js +0 -15
- package/cjs/schema/implementation/data-type/builtin/number.type.js +0 -15
- package/cjs/schema/implementation/data-type/builtin/object.type.js +0 -15
- package/cjs/schema/implementation/data-type/builtin/string.type.js +0 -15
- package/cjs/schema/implementation/data-type/builtin-data-types.js +0 -37
- package/cjs/schema/implementation/data-type/complex-type.js +0 -110
- package/cjs/schema/implementation/data-type/data-type.js +0 -37
- package/cjs/schema/implementation/data-type/simple-type.js +0 -21
- package/cjs/schema/implementation/data-type/union-type.js +0 -24
- package/cjs/schema/implementation/document-builder.js +0 -140
- package/cjs/schema/implementation/opra-document.js +0 -183
- package/cjs/schema/implementation/query/collection-count-query.js +0 -17
- package/cjs/schema/implementation/query/collection-create-query.js +0 -23
- package/cjs/schema/implementation/query/collection-delete-many-query.js +0 -17
- package/cjs/schema/implementation/query/collection-delete-query.js +0 -25
- package/cjs/schema/implementation/query/collection-get-query.js +0 -32
- package/cjs/schema/implementation/query/collection-search-query.js +0 -45
- package/cjs/schema/implementation/query/collection-update-many-query.js +0 -18
- package/cjs/schema/implementation/query/collection-update-query.js +0 -33
- package/cjs/schema/implementation/query/field-get-query.js +0 -34
- package/cjs/schema/implementation/query/index.js +0 -22
- package/cjs/schema/implementation/query/singleton-get-query.js +0 -22
- package/cjs/schema/implementation/resource/collection-resource-info.js +0 -72
- package/cjs/schema/implementation/resource/container-resource-info.js +0 -30
- package/cjs/schema/implementation/resource/resource-info.js +0 -35
- package/cjs/schema/implementation/resource/singleton-resource-info.js +0 -44
- package/cjs/schema/implementation/schema-builder/extract-resource-metadata.util.js +0 -84
- package/cjs/schema/implementation/schema-builder/extract-type-metadata.util.js +0 -94
- package/cjs/schema/opra-schema.definition.js +0 -49
- package/cjs/schema/type-helpers/extend-type.helper.js +0 -65
- package/cjs/schema/type-helpers/mixin-type.helper.js +0 -46
- package/cjs/schema/utils/class.utils.js +0 -8
- package/cjs/schema/utils/normalize-field-array.util.js +0 -44
- package/cjs/schema/utils/path-to-tree.util.js +0 -26
- package/cjs/url/formats/boolean-format.js +0 -25
- package/cjs/url/formats/date-format.js +0 -44
- package/cjs/url/formats/format.js +0 -6
- package/cjs/url/formats/number-format.js +0 -26
- package/cjs/url/formats/string-format.js +0 -25
- package/cjs/url/opra-url-search-params.js +0 -28
- package/cjs/utils/index.js +0 -6
- package/esm/constants.js +0 -1
- package/esm/helpers/index.d.ts +0 -1
- package/esm/helpers/responsive-map.d.ts +0 -32
- package/esm/http/http-headers.d.ts +0 -70
- package/esm/http/http-param-codec.d.ts +0 -4
- package/esm/http/http-param-codec.js +0 -2
- package/esm/http/http-request-node.d.ts +0 -34
- package/esm/http/http-request-node.js +0 -101
- package/esm/http/http-request.d.ts +0 -76
- package/esm/http/http-request.js +0 -85
- package/esm/http/http-response.d.ts +0 -41
- package/esm/http/http-response.js +0 -19
- package/esm/http/index.d.ts +0 -17
- package/esm/http/multipart/batch-multipart.d.ts +0 -31
- package/esm/http/multipart/http-request-content.d.ts +0 -8
- package/esm/http/multipart/http-response-content.d.ts +0 -7
- package/esm/http/multipart/index.d.ts +0 -1
- package/esm/http/param-codec/boolean-codec.d.ts +0 -5
- package/esm/http/param-codec/filter-codec.js +0 -14
- package/esm/http/param-codec/integer-codec.d.ts +0 -9
- package/esm/http/param-codec/integer-codec.js +0 -15
- package/esm/http/param-codec/number-codec.d.ts +0 -12
- package/esm/http/param-codec/string-codec.d.ts +0 -14
- package/esm/http/utils/encodeURIParam.d.ts +0 -1
- package/esm/http/utils/encodeURIParam.js +0 -17
- package/esm/http/utils/normalize-headers.d.ts +0 -1
- package/esm/http/utils/normalize-headers.js +0 -24
- package/esm/schema/constants.d.ts +0 -8
- package/esm/schema/decorators/opr-collection-resource.decorator.d.ts +0 -8
- package/esm/schema/decorators/opr-collection-resource.decorator.js +0 -19
- package/esm/schema/decorators/opr-complex-type.decorator.d.ts +0 -6
- package/esm/schema/decorators/opr-complex-type.decorator.js +0 -23
- package/esm/schema/decorators/opr-field.decorator.d.ts +0 -3
- package/esm/schema/decorators/opr-field.decorator.js +0 -24
- package/esm/schema/decorators/opr-resolver.decorator.d.ts +0 -8
- package/esm/schema/decorators/opr-resolver.decorator.js +0 -71
- package/esm/schema/decorators/opr-simple-type.decorator.d.ts +0 -6
- package/esm/schema/decorators/opr-simple-type.decorator.js +0 -14
- package/esm/schema/decorators/opr-singleton-resource.decorator.d.ts +0 -8
- package/esm/schema/decorators/opr-singleton-resource.decorator.js +0 -19
- package/esm/schema/implementation/data-type/builtin/any.type.d.ts +0 -2
- package/esm/schema/implementation/data-type/builtin/any.type.js +0 -6
- package/esm/schema/implementation/data-type/builtin/base64-binary.type.d.ts +0 -2
- package/esm/schema/implementation/data-type/builtin/base64-binary.type.js +0 -12
- package/esm/schema/implementation/data-type/builtin/bigint.type.d.ts +0 -2
- package/esm/schema/implementation/data-type/builtin/bigint.type.js +0 -12
- package/esm/schema/implementation/data-type/builtin/boolean.type.d.ts +0 -2
- package/esm/schema/implementation/data-type/builtin/boolean.type.js +0 -12
- package/esm/schema/implementation/data-type/builtin/date-string.type.d.ts +0 -2
- package/esm/schema/implementation/data-type/builtin/date-string.type.js +0 -12
- package/esm/schema/implementation/data-type/builtin/date.type.d.ts +0 -2
- package/esm/schema/implementation/data-type/builtin/date.type.js +0 -12
- package/esm/schema/implementation/data-type/builtin/guid.type.d.ts +0 -2
- package/esm/schema/implementation/data-type/builtin/guid.type.js +0 -12
- package/esm/schema/implementation/data-type/builtin/integer.type.d.ts +0 -2
- package/esm/schema/implementation/data-type/builtin/integer.type.js +0 -12
- package/esm/schema/implementation/data-type/builtin/number.type.d.ts +0 -2
- package/esm/schema/implementation/data-type/builtin/number.type.js +0 -12
- package/esm/schema/implementation/data-type/builtin/object.type.d.ts +0 -2
- package/esm/schema/implementation/data-type/builtin/object.type.js +0 -12
- package/esm/schema/implementation/data-type/builtin/string.type.d.ts +0 -2
- package/esm/schema/implementation/data-type/builtin/string.type.js +0 -12
- package/esm/schema/implementation/data-type/builtin-data-types.d.ts +0 -4
- package/esm/schema/implementation/data-type/builtin-data-types.js +0 -34
- package/esm/schema/implementation/data-type/complex-type.d.ts +0 -29
- package/esm/schema/implementation/data-type/complex-type.js +0 -106
- package/esm/schema/implementation/data-type/data-type.d.ts +0 -17
- package/esm/schema/implementation/data-type/data-type.js +0 -33
- package/esm/schema/implementation/data-type/simple-type.d.ts +0 -12
- package/esm/schema/implementation/data-type/simple-type.js +0 -17
- package/esm/schema/implementation/data-type/union-type.d.ts +0 -16
- package/esm/schema/implementation/data-type/union-type.js +0 -19
- package/esm/schema/implementation/document-builder.d.ts +0 -16
- package/esm/schema/implementation/document-builder.js +0 -135
- package/esm/schema/implementation/opra-document.d.ts +0 -44
- package/esm/schema/implementation/opra-document.js +0 -178
- package/esm/schema/implementation/query/collection-count-query.d.ts +0 -14
- package/esm/schema/implementation/query/collection-count-query.js +0 -13
- package/esm/schema/implementation/query/collection-create-query.d.ts +0 -18
- package/esm/schema/implementation/query/collection-create-query.js +0 -19
- package/esm/schema/implementation/query/collection-delete-many-query.d.ts +0 -14
- package/esm/schema/implementation/query/collection-delete-many-query.js +0 -13
- package/esm/schema/implementation/query/collection-delete-query.d.ts +0 -10
- package/esm/schema/implementation/query/collection-delete-query.js +0 -21
- package/esm/schema/implementation/query/collection-get-query.d.ts +0 -21
- package/esm/schema/implementation/query/collection-get-query.js +0 -28
- package/esm/schema/implementation/query/collection-search-query.d.ts +0 -30
- package/esm/schema/implementation/query/collection-search-query.js +0 -41
- package/esm/schema/implementation/query/collection-update-many-query.d.ts +0 -15
- package/esm/schema/implementation/query/collection-update-many-query.js +0 -14
- package/esm/schema/implementation/query/collection-update-query.d.ts +0 -19
- package/esm/schema/implementation/query/collection-update-query.js +0 -29
- package/esm/schema/implementation/query/field-get-query.d.ts +0 -30
- package/esm/schema/implementation/query/field-get-query.js +0 -30
- package/esm/schema/implementation/query/index.d.ts +0 -27
- package/esm/schema/implementation/query/index.js +0 -17
- package/esm/schema/implementation/query/singleton-get-query.d.ts +0 -20
- package/esm/schema/implementation/query/singleton-get-query.js +0 -18
- package/esm/schema/implementation/resource/collection-resource-info.d.ts +0 -22
- package/esm/schema/implementation/resource/collection-resource-info.js +0 -68
- package/esm/schema/implementation/resource/container-resource-info.d.ts +0 -13
- package/esm/schema/implementation/resource/container-resource-info.js +0 -26
- package/esm/schema/implementation/resource/resource-info.d.ts +0 -17
- package/esm/schema/implementation/resource/resource-info.js +0 -31
- package/esm/schema/implementation/resource/singleton-resource-info.d.ts +0 -15
- package/esm/schema/implementation/resource/singleton-resource-info.js +0 -40
- package/esm/schema/implementation/schema-builder/extract-resource-metadata.util.d.ts +0 -3
- package/esm/schema/implementation/schema-builder/extract-resource-metadata.util.js +0 -80
- package/esm/schema/implementation/schema-builder/extract-type-metadata.util.d.ts +0 -4
- package/esm/schema/implementation/schema-builder/extract-type-metadata.util.js +0 -90
- package/esm/schema/index.d.ts +0 -25
- package/esm/schema/interfaces/child-field-query.interface.d.ts +0 -4
- package/esm/schema/interfaces/child-field-query.interface.js +0 -1
- package/esm/schema/interfaces/data-type.metadata.d.ts +0 -18
- package/esm/schema/interfaces/data-type.metadata.js +0 -1
- package/esm/schema/interfaces/resource-container.interface.d.ts +0 -8
- package/esm/schema/interfaces/resource-container.interface.js +0 -1
- package/esm/schema/interfaces/resource.metadata.d.ts +0 -18
- package/esm/schema/interfaces/resource.metadata.js +0 -1
- package/esm/schema/opra-schema.definition.d.ts +0 -178
- package/esm/schema/opra-schema.definition.js +0 -46
- package/esm/schema/type-helpers/extend-type.helper.d.ts +0 -3
- package/esm/schema/type-helpers/extend-type.helper.js +0 -60
- package/esm/schema/type-helpers/mixin-type.helper.d.ts +0 -2
- package/esm/schema/type-helpers/mixin-type.helper.js +0 -42
- package/esm/schema/types.js +0 -1
- package/esm/schema/utils/class.utils.d.ts +0 -2
- package/esm/schema/utils/class.utils.js +0 -4
- package/esm/schema/utils/clone-object.util.js +0 -14
- package/esm/schema/utils/inspect.util.js +0 -4
- package/esm/schema/utils/normalize-field-array.util.d.ts +0 -3
- package/esm/schema/utils/normalize-field-array.util.js +0 -40
- package/esm/schema/utils/path-to-tree.util.d.ts +0 -4
- package/esm/schema/utils/path-to-tree.util.js +0 -22
- package/esm/schema/utils/string-compare.util.js +0 -7
- package/esm/url/formats/boolean-format.d.ts +0 -5
- package/esm/url/formats/boolean-format.js +0 -21
- package/esm/url/formats/date-format.d.ts +0 -16
- package/esm/url/formats/date-format.js +0 -40
- package/esm/url/formats/filter-format.d.ts +0 -6
- package/esm/url/formats/filter-format.js +0 -14
- package/esm/url/formats/format.d.ts +0 -4
- package/esm/url/formats/format.js +0 -2
- package/esm/url/formats/integer-format.d.ts +0 -9
- package/esm/url/formats/integer-format.js +0 -15
- package/esm/url/formats/number-format.d.ts +0 -12
- package/esm/url/formats/number-format.js +0 -22
- package/esm/url/formats/string-format.d.ts +0 -14
- package/esm/url/formats/string-format.js +0 -21
- package/esm/url/opra-url-search-params.d.ts +0 -5
- package/esm/url/opra-url-search-params.js +0 -24
- package/esm/url/utils/path-utils.d.ts +0 -8
- package/esm/url/utils/path-utils.js +0 -78
- package/esm/utils/index.d.ts +0 -3
- package/esm/utils/index.js +0 -3
- package/esm/utils/is-url.d.ts +0 -1
- package/esm/utils/is-url.js +0 -4
- package/esm/utils/path-to-tree.d.ts +0 -4
- package/esm/utils/path-to-tree.js +0 -24
- /package/cjs/{schema → document}/utils/inspect.util.js +0 -0
- /package/cjs/{schema → document}/utils/string-compare.util.js +0 -0
- /package/cjs/{schema/type-helpers/mixin.utils.js → helpers/mixin-utils.js} +0 -0
- /package/cjs/http/{param-codec → codecs}/integer-codec.js +0 -0
- /package/cjs/{schema/interfaces/child-field-query.interface.js → http/interfaces/cookie-options.interface.js} +0 -0
- /package/cjs/schema/{interfaces/data-type.metadata.js → data-type/data-type.interface.js} +0 -0
- /package/cjs/schema/{interfaces/resource-container.interface.js → data-type/field.interface.js} +0 -0
- /package/cjs/schema/{interfaces/resource.metadata.js → document.interface.js} +0 -0
- /package/cjs/schema/{types.js → resource/endpoint.interface.js} +0 -0
- /package/{esm/schema → types/document}/utils/inspect.util.d.ts +0 -0
- /package/{esm/schema → types/document}/utils/string-compare.util.d.ts +0 -0
- /package/{esm → types}/exception/enums/issue-severity.enum.d.ts +0 -0
- /package/{esm → types}/exception/error-issue.d.ts +0 -0
- /package/{esm → types}/exception/http-errors/bad-request.error.d.ts +0 -0
- /package/{esm → types}/exception/http-errors/failed-dependency.error.d.ts +0 -0
- /package/{esm → types}/exception/http-errors/forbidden.error.d.ts +0 -0
- /package/{esm → types}/exception/http-errors/internal-server.error.d.ts +0 -0
- /package/{esm → types}/exception/http-errors/method-not-allowed.error.d.ts +0 -0
- /package/{esm → types}/exception/http-errors/not-acceptable.error.d.ts +0 -0
- /package/{esm → types}/exception/http-errors/not-found.error.d.ts +0 -0
- /package/{esm → types}/exception/http-errors/unauthorized.error.d.ts +0 -0
- /package/{esm → types}/exception/http-errors/unprocessable-entity.error.d.ts +0 -0
- /package/{esm → types}/exception/index.d.ts +0 -0
- /package/{esm → types}/exception/opra-exception.d.ts +0 -0
- /package/{esm → types}/exception/resource-errors/resource-conflict.error.d.ts +0 -0
- /package/{esm → types}/exception/wrap-exception.d.ts +0 -0
- /package/{esm → types}/filter/antlr/OpraFilterLexer.d.ts +0 -0
- /package/{esm → types}/filter/antlr/OpraFilterListener.d.ts +0 -0
- /package/{esm → types}/filter/antlr/OpraFilterParser.d.ts +0 -0
- /package/{esm → types}/filter/antlr/OpraFilterVisitor.d.ts +0 -0
- /package/{esm → types}/filter/ast/abstract/ast.d.ts +0 -0
- /package/{esm → types}/filter/ast/abstract/expression.d.ts +0 -0
- /package/{esm → types}/filter/ast/abstract/literal.d.ts +0 -0
- /package/{esm → types}/filter/ast/abstract/term.d.ts +0 -0
- /package/{esm → types}/filter/ast/expressions/arithmetic-expression.d.ts +0 -0
- /package/{esm → types}/filter/ast/expressions/array-expression.d.ts +0 -0
- /package/{esm → types}/filter/ast/expressions/comparison-expression.d.ts +0 -0
- /package/{esm → types}/filter/ast/expressions/logical-expression.d.ts +0 -0
- /package/{esm → types}/filter/ast/expressions/parentheses-expression.d.ts +0 -0
- /package/{esm → types}/filter/ast/index.d.ts +0 -0
- /package/{esm → types}/filter/ast/terms/boolean-literal.d.ts +0 -0
- /package/{esm → types}/filter/ast/terms/date-literal.d.ts +0 -0
- /package/{esm → types}/filter/ast/terms/external-constant.d.ts +0 -0
- /package/{esm → types}/filter/ast/terms/null-literal.d.ts +0 -0
- /package/{esm → types}/filter/ast/terms/number-literal.d.ts +0 -0
- /package/{esm → types}/filter/ast/terms/qualified-identifier.d.ts +0 -0
- /package/{esm → types}/filter/ast/terms/string-literal.d.ts +0 -0
- /package/{esm → types}/filter/ast/terms/time-literal.d.ts +0 -0
- /package/{esm → types}/filter/build.d.ts +0 -0
- /package/{esm → types}/filter/errors.d.ts +0 -0
- /package/{esm → types}/filter/filter-tree-visitor.d.ts +0 -0
- /package/{esm → types}/filter/index.d.ts +0 -0
- /package/{esm → types}/filter/opra-error-listener.d.ts +0 -0
- /package/{esm → types}/filter/parse.d.ts +0 -0
- /package/{esm → types}/filter/utils.d.ts +0 -0
- /package/{esm/schema/type-helpers/mixin.utils.d.ts → types/helpers/mixin-utils.d.ts} +0 -0
- /package/{esm → types}/http/enums/http-status-codes.enum.d.ts +0 -0
- /package/{esm → types}/http/interfaces/client-http-headers.interface.d.ts +0 -0
- /package/{esm → types}/http/interfaces/server-http-headers.interface.d.ts +0 -0
- /package/{esm/constants.d.ts → types/http/multipart/batch-multipart.d.ts} +0 -0
- /package/{esm → types}/i18n/i18n.d.ts +0 -0
- /package/{esm → types}/i18n/index.d.ts +0 -0
- /package/{esm → types}/i18n/string-utils.d.ts +0 -0
- /package/{esm → types}/i18n/translate.d.ts +0 -0
- /package/{esm → types}/url/opra-url-path-component.d.ts +0 -0
- /package/{esm → types}/url/opra-url-path.d.ts +0 -0
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HttpResponseMessageHost = exports.HttpResponseMessage = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const content_disposition_1 = tslib_1.__importDefault(require("content-disposition"));
|
|
6
|
+
const cookie_1 = tslib_1.__importDefault(require("cookie"));
|
|
7
|
+
const cookie_signature_1 = tslib_1.__importDefault(require("cookie-signature"));
|
|
8
|
+
const encodeurl_1 = tslib_1.__importDefault(require("encodeurl"));
|
|
9
|
+
const http_parser_js_1 = require("http-parser-js");
|
|
10
|
+
const mime_types_1 = tslib_1.__importDefault(require("mime-types"));
|
|
11
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
12
|
+
const http_status_messages_js_1 = require("./enums/http-status-messages.js");
|
|
13
|
+
const http_message_host_js_1 = require("./http-message.host.js");
|
|
14
|
+
/**
|
|
15
|
+
* @namespace HttpResponseMessage
|
|
16
|
+
*/
|
|
17
|
+
var HttpResponseMessage;
|
|
18
|
+
(function (HttpResponseMessage) {
|
|
19
|
+
function create(init) {
|
|
20
|
+
return HttpResponseMessageHost.create(init);
|
|
21
|
+
}
|
|
22
|
+
HttpResponseMessage.create = create;
|
|
23
|
+
function fromBuffer(buffer) {
|
|
24
|
+
return HttpResponseMessageHost.fromBuffer(buffer);
|
|
25
|
+
}
|
|
26
|
+
HttpResponseMessage.fromBuffer = fromBuffer;
|
|
27
|
+
async function fromStream(readable) {
|
|
28
|
+
return HttpResponseMessageHost.fromStream(readable);
|
|
29
|
+
}
|
|
30
|
+
HttpResponseMessage.fromStream = fromStream;
|
|
31
|
+
})(HttpResponseMessage = exports.HttpResponseMessage || (exports.HttpResponseMessage = {}));
|
|
32
|
+
/**
|
|
33
|
+
* @class HttpResponseMessageHost
|
|
34
|
+
*/
|
|
35
|
+
class HttpResponseMessageHost extends http_message_host_js_1.HttpMessageHost {
|
|
36
|
+
constructor() {
|
|
37
|
+
super();
|
|
38
|
+
}
|
|
39
|
+
header(arg0, arg1) {
|
|
40
|
+
return this.set(arg0, arg1);
|
|
41
|
+
}
|
|
42
|
+
append(name, value) {
|
|
43
|
+
this[http_message_host_js_1.HttpMessageHost.kHeaders].append(name, value);
|
|
44
|
+
return this;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Set "Content-Disposition" header to "attachment" with optional `filename`.
|
|
48
|
+
*/
|
|
49
|
+
attachment(filename) {
|
|
50
|
+
if (filename)
|
|
51
|
+
this.type(path_1.default.extname(filename));
|
|
52
|
+
this.set('Content-Disposition', (0, content_disposition_1.default)(filename));
|
|
53
|
+
return this;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Alias for msg.type()
|
|
57
|
+
*/
|
|
58
|
+
contentType(type) {
|
|
59
|
+
return this.type(type);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Set _Content-Type_ response header with `type` through `mime.lookup()`
|
|
63
|
+
* when it does not contain "/", or set the Content-Type to `type` otherwise.
|
|
64
|
+
*
|
|
65
|
+
* Examples:
|
|
66
|
+
*
|
|
67
|
+
* res.type('.html');
|
|
68
|
+
* res.type('html');
|
|
69
|
+
* res.type('json');
|
|
70
|
+
* res.type('application/json');
|
|
71
|
+
* res.type('png');
|
|
72
|
+
*/
|
|
73
|
+
type(type) {
|
|
74
|
+
const ct = type.indexOf('/') === -1
|
|
75
|
+
? mime_types_1.default.lookup(type)
|
|
76
|
+
: type;
|
|
77
|
+
if (ct)
|
|
78
|
+
this.set('Content-Type', ct);
|
|
79
|
+
return this;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Set cookie `name` to `value`, with the given `options`.
|
|
83
|
+
*
|
|
84
|
+
* Options:
|
|
85
|
+
*
|
|
86
|
+
* - `maxAge` max-age in milliseconds, converted to `expires`
|
|
87
|
+
* - `signed` sign the cookie
|
|
88
|
+
* - `path` defaults to "/"
|
|
89
|
+
*
|
|
90
|
+
* Examples:
|
|
91
|
+
*
|
|
92
|
+
* // "Remember Me" for 15 minutes
|
|
93
|
+
* res.cookie('rememberme', '1', { expires: new Date(Date.now() + 900000), httpOnly: true });
|
|
94
|
+
*
|
|
95
|
+
* // same as above
|
|
96
|
+
* res.cookie('rememberme', '1', { maxAge: 900000, httpOnly: true })
|
|
97
|
+
*
|
|
98
|
+
*/
|
|
99
|
+
cookie(name, value, options) {
|
|
100
|
+
const opts = { ...options };
|
|
101
|
+
const secret = this.req?.secret;
|
|
102
|
+
const signed = opts.signed;
|
|
103
|
+
if (signed && !secret) {
|
|
104
|
+
throw new Error('cookieParser("secret") required for signed cookies');
|
|
105
|
+
}
|
|
106
|
+
let val = typeof value === 'object'
|
|
107
|
+
? 'j:' + JSON.stringify(value)
|
|
108
|
+
: String(value);
|
|
109
|
+
if (signed)
|
|
110
|
+
val = 's:' + cookie_signature_1.default.sign(val, secret);
|
|
111
|
+
if (opts.maxAge != null) {
|
|
112
|
+
const maxAge = opts.maxAge - 0;
|
|
113
|
+
if (!isNaN(maxAge)) {
|
|
114
|
+
opts.expires = new Date(Date.now() + maxAge);
|
|
115
|
+
opts.maxAge = Math.floor(maxAge / 1000);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (opts.path == null)
|
|
119
|
+
opts.path = '/';
|
|
120
|
+
// Remove old cookie
|
|
121
|
+
let a = this.get('Set-Cookie');
|
|
122
|
+
if (a && Array.isArray(a)) {
|
|
123
|
+
a = a.filter(x => !x.startsWith(name + '='));
|
|
124
|
+
this.set('Set-Cookie', a);
|
|
125
|
+
}
|
|
126
|
+
this.append('Set-Cookie', cookie_1.default.serialize(name, String(val), opts));
|
|
127
|
+
return this;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Clear cookie `name`.
|
|
131
|
+
*/
|
|
132
|
+
clearCookie(name, options) {
|
|
133
|
+
return this.cookie(name, '', { expires: new Date(1), path: '/', ...options });
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Set Link header field with the given `links`.
|
|
137
|
+
*
|
|
138
|
+
* Examples:
|
|
139
|
+
*
|
|
140
|
+
* res.links({
|
|
141
|
+
* next: 'http://api.example.com/users?page=2',
|
|
142
|
+
* last: 'http://api.example.com/users?page=5'
|
|
143
|
+
* });
|
|
144
|
+
*
|
|
145
|
+
*/
|
|
146
|
+
links(links) {
|
|
147
|
+
let link = this.get('Link') || '';
|
|
148
|
+
if (link)
|
|
149
|
+
link += ', ';
|
|
150
|
+
return this.set('Link', link + Object.keys(links).map(rel => '<' + links[rel] + '>; rel="' + rel + '"').join(', '));
|
|
151
|
+
}
|
|
152
|
+
redirect(arg0, url) {
|
|
153
|
+
let status = 302;
|
|
154
|
+
// allow status / url
|
|
155
|
+
if (typeof arg0 === 'number') {
|
|
156
|
+
status = arg0;
|
|
157
|
+
}
|
|
158
|
+
else
|
|
159
|
+
url = arg0 || '';
|
|
160
|
+
// Set location header
|
|
161
|
+
this.location(url || '/');
|
|
162
|
+
// Respond
|
|
163
|
+
this.statusCode = status;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Send JSON response.
|
|
167
|
+
*
|
|
168
|
+
* Examples:
|
|
169
|
+
*
|
|
170
|
+
* res.json(null);
|
|
171
|
+
* res.json({ user: 'tj' });
|
|
172
|
+
*/
|
|
173
|
+
json(obj) {
|
|
174
|
+
if (!this.get('Content-Type'))
|
|
175
|
+
this.set('Content-Type', 'application/json');
|
|
176
|
+
const body = JSON.stringify(obj);
|
|
177
|
+
return this.send(body);
|
|
178
|
+
}
|
|
179
|
+
location(url) {
|
|
180
|
+
let loc = url;
|
|
181
|
+
// "back" is an alias for the referrer
|
|
182
|
+
if (url === 'back')
|
|
183
|
+
loc = this.req?.get('Referrer') || '/';
|
|
184
|
+
// set location
|
|
185
|
+
return this.set('Location', (0, encodeurl_1.default)(loc));
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Set status `code`.
|
|
189
|
+
*/
|
|
190
|
+
status(code) {
|
|
191
|
+
this.statusCode = code;
|
|
192
|
+
return this;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Set the response HTTP status code to `statusCode` and send its string representation as the response body.
|
|
196
|
+
* @link http://expressjs.com/4x/api.html#res.sendStatus
|
|
197
|
+
*
|
|
198
|
+
* Examples:
|
|
199
|
+
*
|
|
200
|
+
* res.sendStatus(200); // equivalent to res.status(200).send('OK')
|
|
201
|
+
* res.sendStatus(403); // equivalent to res.status(403).send('Forbidden')
|
|
202
|
+
* res.sendStatus(404); // equivalent to res.status(404).send('Not Found')
|
|
203
|
+
* res.sendStatus(500); // equivalent to res.status(500).send('Internal Server Error')
|
|
204
|
+
*/
|
|
205
|
+
sendStatus(statusCode) {
|
|
206
|
+
const body = http_status_messages_js_1.HttpStatusMessages[statusCode] || String(statusCode);
|
|
207
|
+
this.statusCode = statusCode;
|
|
208
|
+
this.type('txt');
|
|
209
|
+
return this.send(body);
|
|
210
|
+
}
|
|
211
|
+
_init(init) {
|
|
212
|
+
super._init(init);
|
|
213
|
+
this.statusCode = init?.statusCode;
|
|
214
|
+
this.statusMessage = init?.statusMessage;
|
|
215
|
+
this.req = init?.req;
|
|
216
|
+
this.chunkedEncoding = init?.chunkedEncoding;
|
|
217
|
+
}
|
|
218
|
+
[http_message_host_js_1.HttpMessageHost.kOnHeaderReceived](info) {
|
|
219
|
+
super[http_message_host_js_1.HttpMessageHost.kOnHeaderReceived](info);
|
|
220
|
+
this.statusCode = info.statusCode;
|
|
221
|
+
this.statusMessage = info.statusMessage;
|
|
222
|
+
}
|
|
223
|
+
static create(init) {
|
|
224
|
+
const msg = new HttpResponseMessageHost();
|
|
225
|
+
msg._init(init);
|
|
226
|
+
return msg;
|
|
227
|
+
}
|
|
228
|
+
static fromBuffer(buffer) {
|
|
229
|
+
const msg = new HttpResponseMessageHost();
|
|
230
|
+
msg._parseBuffer(buffer, http_parser_js_1.HTTPParser.RESPONSE);
|
|
231
|
+
return msg;
|
|
232
|
+
}
|
|
233
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
234
|
+
static async fromStream(readable) {
|
|
235
|
+
throw new Error('fromStream is not implemented yet');
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
exports.HttpResponseMessageHost = HttpResponseMessageHost;
|
package/esm/http/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./http-headers.js"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./http-params.js"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./http-response-message.js"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./http-request-message.js"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./enums/http-headers-codes.enum.js"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./enums/http-status-codes.enum.js"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./interfaces/client-http-headers.interface.js"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./interfaces/server-http-headers.interface.js"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./codecs/date-codec.js"), exports);
|
|
13
|
+
tslib_1.__exportStar(require("./codecs/boolean-codec.js"), exports);
|
|
14
|
+
tslib_1.__exportStar(require("./codecs/filter-codec.js"), exports);
|
|
15
|
+
tslib_1.__exportStar(require("./codecs/integer-codec.js"), exports);
|
|
16
|
+
tslib_1.__exportStar(require("./codecs/number-codec.js"), exports);
|
|
17
|
+
tslib_1.__exportStar(require("./codecs/string-codec.js"), exports);
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,149 +1,170 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// import Highland from 'highland';
|
|
3
|
+
// import { Readable } from 'stream';
|
|
4
|
+
// import { uid } from 'uid';
|
|
5
|
+
// import { isReadable } from '../../helpers/index.js';
|
|
6
|
+
// import { HttpHeaderCodes } from '../enums/http-headers-codes.enum.js';
|
|
7
|
+
// import { HttpStatusCodes } from '../enums/http-status-codes.enum.js';
|
|
8
|
+
// import { normalizeHeaders } from '../utils/normalize-headers.js';
|
|
9
|
+
// import { HttpRequestContent, IHttpRequestContent } from './http-request-content.js';
|
|
10
|
+
// import { HttpResponseContent, IHttpResponseContent } from './http-response-content.js';
|
|
11
|
+
//
|
|
12
|
+
// const CRLF = '\r\n';
|
|
13
|
+
// const CHARSET_PATTERN = / *charset=./i;
|
|
14
|
+
//
|
|
15
|
+
// type Part = {
|
|
16
|
+
// headers: Record<string, string | string[]>;
|
|
17
|
+
// contentId?: string;
|
|
18
|
+
// content: HttpRequestContent | HttpResponseContent | BatchMultipart;
|
|
19
|
+
// }
|
|
20
|
+
//
|
|
21
|
+
// export class BatchMultipart {
|
|
22
|
+
// protected _parts: Part[] = [];
|
|
23
|
+
// readonly boundary: string;
|
|
24
|
+
//
|
|
25
|
+
// constructor() {
|
|
26
|
+
// this.boundary = 'batch_' + uid(12);
|
|
27
|
+
// }
|
|
28
|
+
//
|
|
29
|
+
// addRequestPart(content: IHttpRequestContent, part?: {
|
|
30
|
+
// contentId?: string;
|
|
31
|
+
// headers?: Record<string, string | string[]>;
|
|
32
|
+
// }): this {
|
|
33
|
+
// const headers: any = {
|
|
34
|
+
// ...normalizeHeaders(part?.headers || {}, true),
|
|
35
|
+
// [HttpHeaderCodes.Content_Type]: 'application/http',
|
|
36
|
+
// [HttpHeaderCodes.Content_Transfer_Encoding]: 'binary'
|
|
37
|
+
// };
|
|
38
|
+
// if (part?.contentId)
|
|
39
|
+
// headers[HttpHeaderCodes.Content_ID] = part.contentId;
|
|
40
|
+
// this._parts.push({
|
|
41
|
+
// headers,
|
|
42
|
+
// contentId: part?.contentId,
|
|
43
|
+
// content: new HttpRequestContent(content)
|
|
44
|
+
// });
|
|
45
|
+
// return this;
|
|
46
|
+
// }
|
|
47
|
+
//
|
|
48
|
+
// addHttpResponse(content: IHttpResponseContent, part?: {
|
|
49
|
+
// contentId?: string;
|
|
50
|
+
// headers?: Record<string, string | string[]>;
|
|
51
|
+
// }): this {
|
|
52
|
+
// const headers: any = {
|
|
53
|
+
// ...normalizeHeaders(part?.headers || {}, true),
|
|
54
|
+
// [HttpHeaderCodes.Content_Type]: 'application/http',
|
|
55
|
+
// [HttpHeaderCodes.Content_Transfer_Encoding]: 'binary'
|
|
56
|
+
// };
|
|
57
|
+
// if (part?.contentId)
|
|
58
|
+
// headers[HttpHeaderCodes.Content_ID] = part.contentId;
|
|
59
|
+
// this._parts.push({
|
|
60
|
+
// headers,
|
|
61
|
+
// contentId: part?.contentId,
|
|
62
|
+
// content: new HttpResponseContent(content)
|
|
63
|
+
// });
|
|
64
|
+
// return this;
|
|
65
|
+
// }
|
|
66
|
+
//
|
|
67
|
+
// addBatch(batch: BatchMultipart, part?: {
|
|
68
|
+
// contentId?: string;
|
|
69
|
+
// headers?: Record<string, string | string[]>;
|
|
70
|
+
// }): this {
|
|
71
|
+
// const headers: any = {
|
|
72
|
+
// ...normalizeHeaders(part?.headers || {}, true),
|
|
73
|
+
// [HttpHeaderCodes.Content_Type]: 'application/http',
|
|
74
|
+
// [HttpHeaderCodes.Content_Transfer_Encoding]: 'binary'
|
|
75
|
+
// };
|
|
76
|
+
// if (part?.contentId)
|
|
77
|
+
// headers[HttpHeaderCodes.Content_ID] = part.contentId;
|
|
78
|
+
// this._parts.push({
|
|
79
|
+
// headers,
|
|
80
|
+
// contentId: part?.contentId,
|
|
81
|
+
// content: batch
|
|
82
|
+
// });
|
|
83
|
+
// return this;
|
|
84
|
+
// }
|
|
85
|
+
//
|
|
86
|
+
// stream(): NodeJS.ReadableStream {
|
|
87
|
+
// const chunks: (Buffer | Readable)[] = [];
|
|
88
|
+
// this._build(chunks);
|
|
89
|
+
// return Highland(chunks).flatten().toNodeStream();
|
|
90
|
+
// }
|
|
91
|
+
//
|
|
92
|
+
// protected _build(target: (Buffer | Readable)[]) {
|
|
93
|
+
// for (const part of this._parts) {
|
|
94
|
+
// if (part.content instanceof HttpRequestContent || part.content instanceof HttpResponseContent) {
|
|
95
|
+
// let contentBody = part.content.data;
|
|
96
|
+
// let contentLength = 0;
|
|
97
|
+
// const contentHeaders = normalizeHeaders(part.content.headers);
|
|
98
|
+
// if (contentBody) {
|
|
99
|
+
// const contentType = String(contentHeaders['content-type'] || '').split(/\s*;\s*/);
|
|
100
|
+
// let charset = '';
|
|
101
|
+
// if (isReadable(contentBody)) {
|
|
102
|
+
// contentLength = parseInt(String(contentHeaders['content-length']), 10) || 0;
|
|
103
|
+
// // const l = parseInt(String(contentHeaders['content-length']), 10);
|
|
104
|
+
// // if (isNaN(l))
|
|
105
|
+
// // throw new TypeError('"content-length" header required for streamed responses');
|
|
106
|
+
// } else if (typeof contentBody === 'object') {
|
|
107
|
+
// if (typeof contentBody.stream === 'function') { // File and Blob
|
|
108
|
+
// contentType[0] = contentBody.type || 'binary';
|
|
109
|
+
// contentLength = contentBody.size;
|
|
110
|
+
// contentBody = contentBody.stream();
|
|
111
|
+
// } else if (Buffer.isBuffer(contentBody)) {
|
|
112
|
+
// contentHeaders['content-length'] = String(contentBody.length);
|
|
113
|
+
// } else {
|
|
114
|
+
// contentType[0] = contentType[0] || 'application/json';
|
|
115
|
+
// charset = 'utf-8';
|
|
116
|
+
// contentBody = Buffer.from(JSON.stringify(contentBody), 'utf-8');
|
|
117
|
+
// contentLength = contentBody.length;
|
|
118
|
+
// }
|
|
119
|
+
// } else {
|
|
120
|
+
// contentType[0] = contentType[0] || 'text/plain';
|
|
121
|
+
// charset = 'utf-8';
|
|
122
|
+
// contentBody = Buffer.from(String(contentBody), 'utf-8');
|
|
123
|
+
// contentLength = contentBody.length;
|
|
124
|
+
// }
|
|
125
|
+
// if (contentType[0]) {
|
|
126
|
+
// if (charset) {
|
|
127
|
+
// const i = contentType.findIndex(x => CHARSET_PATTERN.test(String(x)));
|
|
128
|
+
// if (i > 0) contentType[i] = 'charset=' + charset;
|
|
129
|
+
// else contentType.join('charset=' + charset);
|
|
130
|
+
// }
|
|
131
|
+
// contentHeaders['content-type'] = contentType.join(';');
|
|
132
|
+
// }
|
|
133
|
+
// if (contentLength)
|
|
134
|
+
// contentHeaders['content-length'] = String(contentLength);
|
|
135
|
+
// }
|
|
136
|
+
//
|
|
137
|
+
// let s = '--' + this.boundary + CRLF;
|
|
138
|
+
// for (const [k, v] of Object.entries(part.headers)) {
|
|
139
|
+
// if (!(v === '' || v == null))
|
|
140
|
+
// s += k + ': ' + (Array.isArray(v) ? v.join(';') : v) + CRLF;
|
|
141
|
+
// }
|
|
142
|
+
// s += CRLF;
|
|
143
|
+
//
|
|
144
|
+
// if (part.content instanceof HttpRequestContent)
|
|
145
|
+
// s += (part.content.method || 'GET').toUpperCase() + ' ' + part.content.url + ' HTTP/1.1' + CRLF;
|
|
146
|
+
// else
|
|
147
|
+
// s += 'HTTP/1.1 ' + part.content.status + (HttpStatusCodes[part.content.status] || 'Unknown') + CRLF;
|
|
148
|
+
// if (part.content.headers) {
|
|
149
|
+
// for (const [k, v] of Object.entries(part.content.headers)) {
|
|
150
|
+
// if (v === '' || v == null)
|
|
151
|
+
// continue;
|
|
152
|
+
// if (k === 'set-cookie' && Array.isArray(v)) {
|
|
153
|
+
// v.forEach(x => s += k + ': ' + x);
|
|
154
|
+
// } else
|
|
155
|
+
// s += k + ': ' + (Array.isArray(v) ? v.join(';') : v) + CRLF;
|
|
156
|
+
// }
|
|
157
|
+
// }
|
|
158
|
+
// s += CRLF;
|
|
159
|
+
// target.push(Buffer.from(s, 'utf-8'));
|
|
160
|
+
//
|
|
161
|
+
// if (contentBody) {
|
|
162
|
+
// target.push(contentBody);
|
|
163
|
+
// target.push(Buffer.from(CRLF + CRLF));
|
|
164
|
+
// }
|
|
165
|
+
// } else throw new Error('Not implemented yet');
|
|
166
|
+
// }
|
|
167
|
+
// target.push(Buffer.from('--' + this.boundary + '--' + CRLF, 'utf-8'));
|
|
168
|
+
// }
|
|
169
|
+
//
|
|
170
|
+
// }
|
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
//
|
|
3
|
+
// export type IHttpRequestContent = Pick<HttpRequestContent, 'method' | 'url' | 'headers' | 'data'>;
|
|
4
|
+
//
|
|
5
|
+
// export class HttpRequestContent {
|
|
6
|
+
// method: string;
|
|
7
|
+
// url: string;
|
|
8
|
+
// headers?: Record<string, string | string[]>;
|
|
9
|
+
// data?: any;
|
|
10
|
+
//
|
|
11
|
+
// constructor(init: IHttpRequestContent) {
|
|
12
|
+
// this.method = init.method;
|
|
13
|
+
// this.url = encodeURI(decodeURI(init.url));
|
|
14
|
+
// this.headers = init.headers;
|
|
15
|
+
// this.data = init.data;
|
|
16
|
+
// }
|
|
17
|
+
// }
|