@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
package/cjs/http/http-headers.js
CHANGED
|
@@ -1,26 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _a
|
|
2
|
+
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.HttpHeaders = void 0;
|
|
5
|
-
const
|
|
5
|
+
const index_js_1 = require("../helpers/index.js");
|
|
6
6
|
const http_headers_codes_enum_js_1 = require("./enums/http-headers-codes.enum.js");
|
|
7
|
-
const knownKeys = Object.
|
|
7
|
+
const knownKeys = Object.values(http_headers_codes_enum_js_1.HttpHeaderCodes);
|
|
8
8
|
const knownKeysLower = knownKeys.map(x => x.toLowerCase());
|
|
9
9
|
const nodeInspectCustom = Symbol.for('nodejs.util.inspect.custom');
|
|
10
10
|
const kEntries = Symbol('kEntries');
|
|
11
|
-
const kSize = Symbol('kSize');
|
|
12
11
|
const kOptions = Symbol('kOptions');
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @class HttpHeaders
|
|
15
|
+
*/
|
|
13
16
|
class HttpHeaders {
|
|
14
17
|
constructor(init, options) {
|
|
15
|
-
this[_a] = new
|
|
16
|
-
this[_b] = 0;
|
|
18
|
+
this[_a] = new index_js_1.ResponsiveMap();
|
|
17
19
|
this[kOptions] = { ...options, onChange: undefined };
|
|
18
|
-
if (init)
|
|
19
|
-
|
|
20
|
+
if (init) {
|
|
21
|
+
if (typeof init === 'string')
|
|
22
|
+
this.parse(init);
|
|
23
|
+
else
|
|
24
|
+
this.set(init);
|
|
25
|
+
}
|
|
20
26
|
this[kOptions].onChange = options?.onChange;
|
|
21
27
|
}
|
|
22
28
|
get size() {
|
|
23
|
-
return this[
|
|
29
|
+
return this[kEntries].size;
|
|
24
30
|
}
|
|
25
31
|
/**
|
|
26
32
|
* Appends a new value to the existing set of values for a header
|
|
@@ -36,97 +42,87 @@ class HttpHeaders {
|
|
|
36
42
|
* and returns this instance
|
|
37
43
|
*/
|
|
38
44
|
appendAll(headers) {
|
|
39
|
-
if (typeof headers === '
|
|
40
|
-
headers.split('\n').forEach(line => {
|
|
41
|
-
const index = line.indexOf(':');
|
|
42
|
-
if (index > 0) {
|
|
43
|
-
const name = line.slice(0, index);
|
|
44
|
-
const value = line.slice(index + 1).trim();
|
|
45
|
-
this._append(name, value);
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
else if (headers.forEach && typeof headers.forEach === 'function')
|
|
45
|
+
if (headers.forEach && typeof headers.forEach === 'function')
|
|
50
46
|
headers.forEach((value, name) => this._append(name, value));
|
|
51
47
|
else
|
|
52
48
|
Object.keys(headers).forEach(name => this._append(name, headers[name]));
|
|
53
49
|
this.changed();
|
|
54
50
|
return this;
|
|
55
51
|
}
|
|
56
|
-
|
|
57
|
-
if (
|
|
58
|
-
|
|
52
|
+
set(arg0, arg1) {
|
|
53
|
+
if (typeof arg0 === 'object') {
|
|
54
|
+
if (arg0.forEach && typeof arg0.forEach === 'function')
|
|
55
|
+
arg0.forEach((value, name) => this._set(name, value));
|
|
56
|
+
else
|
|
57
|
+
Object.keys(arg0).forEach(name => this._set(name, arg0[name]));
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
if (!arg1 && arg1 !== 0)
|
|
61
|
+
this[kEntries].delete(arg0);
|
|
62
|
+
else
|
|
63
|
+
this._set(arg0, arg1);
|
|
64
|
+
}
|
|
65
|
+
this.changed();
|
|
66
|
+
return this;
|
|
67
|
+
}
|
|
68
|
+
parse(init) {
|
|
69
|
+
this.clear();
|
|
70
|
+
init.split('\n').forEach(line => {
|
|
71
|
+
const index = line.indexOf(':');
|
|
72
|
+
if (index > 0) {
|
|
73
|
+
const name = line.slice(0, index);
|
|
74
|
+
const value = line.slice(index + 1).trim();
|
|
75
|
+
if (HttpHeaders.NON_DELIMITED_HEADERS[name])
|
|
76
|
+
this._append(name, value);
|
|
77
|
+
else if (HttpHeaders.SEMICOLON_DELIMITED_HEADERS[name]) {
|
|
78
|
+
const a = value.split(';');
|
|
79
|
+
this._append(name, a.length > 1 ? a : value);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
const a = value.split(',');
|
|
83
|
+
this._append(name, a.length > 1 ? a : value);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Retrieves value of a given header
|
|
90
|
+
*/
|
|
91
|
+
get(name) {
|
|
92
|
+
return this[kEntries].get(name);
|
|
59
93
|
}
|
|
60
94
|
clear() {
|
|
61
95
|
if (this[kEntries].size) {
|
|
62
96
|
this[kEntries].clear();
|
|
63
|
-
this[kSize] = 0;
|
|
64
97
|
this.changed();
|
|
65
98
|
}
|
|
66
99
|
}
|
|
67
100
|
/**
|
|
68
|
-
* Deletes
|
|
101
|
+
* Deletes a header entry
|
|
69
102
|
*/
|
|
70
|
-
delete(name
|
|
71
|
-
if (this.
|
|
103
|
+
delete(name) {
|
|
104
|
+
if (this[kEntries].delete(name)) {
|
|
72
105
|
this.changed();
|
|
73
|
-
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
return false;
|
|
74
109
|
}
|
|
75
110
|
/**
|
|
76
111
|
* Returns an iterable of key, value pairs for every entry in the map.
|
|
77
112
|
*/
|
|
78
113
|
entries() {
|
|
79
|
-
|
|
80
|
-
let i = 0;
|
|
81
|
-
let key;
|
|
82
|
-
let values;
|
|
83
|
-
return {
|
|
84
|
-
[Symbol.iterator]() {
|
|
85
|
-
return this;
|
|
86
|
-
},
|
|
87
|
-
next() {
|
|
88
|
-
if (values) {
|
|
89
|
-
if (i >= values.length) {
|
|
90
|
-
values = undefined;
|
|
91
|
-
i = 0;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
if (!values) {
|
|
95
|
-
const n = iter.next();
|
|
96
|
-
if (n.done)
|
|
97
|
-
return { done: true, value: undefined };
|
|
98
|
-
key = n.value[0];
|
|
99
|
-
values = n.value[1];
|
|
100
|
-
}
|
|
101
|
-
return {
|
|
102
|
-
done: false,
|
|
103
|
-
value: [key, values[i++]]
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
};
|
|
114
|
+
return this[kEntries].entries();
|
|
107
115
|
}
|
|
108
116
|
forEach(callbackFn, thisArg) {
|
|
109
117
|
const iterator = this.entries();
|
|
110
118
|
let entry = iterator.next();
|
|
119
|
+
let v;
|
|
111
120
|
while (!entry.done) {
|
|
112
|
-
|
|
121
|
+
v = entry.value[1];
|
|
122
|
+
callbackFn.call(thisArg || this, (Array.isArray(v) ? v.join(';') : String(v)), entry.value[0], this);
|
|
113
123
|
entry = iterator.next();
|
|
114
124
|
}
|
|
115
125
|
}
|
|
116
|
-
/**
|
|
117
|
-
* Retrieves value of a given header at given index
|
|
118
|
-
*/
|
|
119
|
-
get(name, index = 0) {
|
|
120
|
-
const values = this[kEntries].get(name.toLowerCase());
|
|
121
|
-
return values && values.length > index ? values[index] : null;
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Retrieves an array of values for a given header.
|
|
125
|
-
*/
|
|
126
|
-
getAll(name) {
|
|
127
|
-
const entry = this[kEntries].get(name);
|
|
128
|
-
return entry ? entry.slice(0) : null;
|
|
129
|
-
}
|
|
130
126
|
/**
|
|
131
127
|
* Retrieves the names of the headers.
|
|
132
128
|
*/
|
|
@@ -139,75 +135,93 @@ class HttpHeaders {
|
|
|
139
135
|
has(name) {
|
|
140
136
|
return this[kEntries].has(name);
|
|
141
137
|
}
|
|
142
|
-
/**
|
|
143
|
-
* Sets or modifies a value for a given header.
|
|
144
|
-
* If the header already exists, its value is replaced with the given value
|
|
145
|
-
*/
|
|
146
|
-
set(name, value) {
|
|
147
|
-
this._set(name, String(value));
|
|
148
|
-
this.changed();
|
|
149
|
-
return this;
|
|
150
|
-
}
|
|
151
138
|
sort(compareFn) {
|
|
152
139
|
this[kEntries].sort(compareFn);
|
|
153
140
|
this.changed();
|
|
154
141
|
return this;
|
|
155
142
|
}
|
|
143
|
+
toObject() {
|
|
144
|
+
const out = {};
|
|
145
|
+
for (const [k, v] of this.entries())
|
|
146
|
+
out[k] = Array.isArray(v) ? v.join(';') : String(v);
|
|
147
|
+
return out;
|
|
148
|
+
}
|
|
149
|
+
getProxy() {
|
|
150
|
+
const _this = this;
|
|
151
|
+
return this[kEntries].getProxy({
|
|
152
|
+
set(target, p, newValue, receiver) {
|
|
153
|
+
if (typeof p === 'string') {
|
|
154
|
+
_this.set(p, newValue);
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
157
|
+
return Reflect.set(target, p, newValue, receiver);
|
|
158
|
+
},
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
[(_a = kEntries, nodeInspectCustom)]() {
|
|
162
|
+
return this[kEntries];
|
|
163
|
+
}
|
|
164
|
+
[Symbol.iterator]() {
|
|
165
|
+
return this.entries();
|
|
166
|
+
}
|
|
167
|
+
get [Symbol.toStringTag]() {
|
|
168
|
+
return 'HttpHeaders';
|
|
169
|
+
}
|
|
156
170
|
_append(name, value) {
|
|
157
|
-
const i = knownKeysLower.indexOf(name);
|
|
171
|
+
const i = knownKeysLower.indexOf(name.toLowerCase());
|
|
158
172
|
const normalizedName = knownKeys[i] || name;
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
173
|
+
name = name.toLowerCase();
|
|
174
|
+
let stored = this[kEntries].get(normalizedName);
|
|
175
|
+
if (HttpHeaders.NON_DELIMITED_HEADERS[name]) {
|
|
176
|
+
value = String(Array.isArray(value) ? value[0] : value);
|
|
177
|
+
this[kEntries].set(normalizedName, value);
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
if (HttpHeaders.ARRAY_HEADERS[name]) {
|
|
181
|
+
stored = (stored ? [stored, value] : [value])
|
|
182
|
+
.flat().map(String);
|
|
183
|
+
this[kEntries].set(normalizedName, stored);
|
|
184
|
+
return;
|
|
163
185
|
}
|
|
164
|
-
const
|
|
186
|
+
const arr = stored ? [stored] : [];
|
|
165
187
|
if (Array.isArray(value))
|
|
166
|
-
|
|
188
|
+
arr.push(...value);
|
|
167
189
|
else
|
|
168
|
-
|
|
169
|
-
this[
|
|
170
|
-
}
|
|
171
|
-
_delete(name, value) {
|
|
172
|
-
const oldValues = this[kEntries].get(name);
|
|
173
|
-
if (!oldValues)
|
|
174
|
-
return false;
|
|
175
|
-
const oldSize = this[kSize];
|
|
176
|
-
if (value) {
|
|
177
|
-
const valueToDelete = Array.isArray(value) ? value.map(x => String(x)) : [String(value)];
|
|
178
|
-
const newValues = oldValues.filter(x => !valueToDelete.includes(x));
|
|
179
|
-
this[kEntries].set(name, newValues);
|
|
180
|
-
this[kSize] += -oldValues.length + newValues.length;
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
this[kEntries].delete(name);
|
|
184
|
-
this[kSize] -= oldValues.length;
|
|
185
|
-
}
|
|
186
|
-
return oldSize !== this[kSize];
|
|
190
|
+
arr.push(value);
|
|
191
|
+
this[kEntries].set(normalizedName, arr.join(HttpHeaders.SEMICOLON_DELIMITED_HEADERS[name] ? '; ' : ', '));
|
|
187
192
|
}
|
|
188
193
|
_set(name, value) {
|
|
189
|
-
|
|
190
|
-
|
|
194
|
+
this[kEntries].delete(name);
|
|
195
|
+
if (!value && value !== 0)
|
|
191
196
|
return;
|
|
192
|
-
|
|
193
|
-
const oldValues = this[kEntries].get(name);
|
|
194
|
-
const i = knownKeysLower.indexOf(name);
|
|
195
|
-
const normalizedName = knownKeys[i] || name;
|
|
196
|
-
const newValues = Array.isArray(value) ? value : [value];
|
|
197
|
-
this[kEntries].set(normalizedName, newValues);
|
|
198
|
-
this[kSize] += -(oldValues?.length || 0) + newValues.length;
|
|
199
|
-
}
|
|
200
|
-
[(_a = kEntries, _b = kSize, nodeInspectCustom)]() {
|
|
201
|
-
return this[kEntries];
|
|
202
|
-
}
|
|
203
|
-
[Symbol.iterator]() {
|
|
204
|
-
return this.entries();
|
|
197
|
+
this._append(name, value);
|
|
205
198
|
}
|
|
206
|
-
|
|
207
|
-
|
|
199
|
+
changed() {
|
|
200
|
+
if (this[kOptions].onChange)
|
|
201
|
+
this[kOptions].onChange();
|
|
208
202
|
}
|
|
209
203
|
}
|
|
210
204
|
exports.HttpHeaders = HttpHeaders;
|
|
211
205
|
HttpHeaders.kEntries = kEntries;
|
|
212
|
-
HttpHeaders.kSize = kSize;
|
|
213
206
|
HttpHeaders.kOptions = kOptions;
|
|
207
|
+
HttpHeaders.NON_DELIMITED_HEADERS = {
|
|
208
|
+
'age': true,
|
|
209
|
+
'from': true,
|
|
210
|
+
'etag': true,
|
|
211
|
+
'server': true,
|
|
212
|
+
'referer': true,
|
|
213
|
+
'expires': true,
|
|
214
|
+
'location': true,
|
|
215
|
+
'user-agent': true,
|
|
216
|
+
'retry-after': true,
|
|
217
|
+
'content-type': true,
|
|
218
|
+
'content-length': true,
|
|
219
|
+
'max-forwards': true,
|
|
220
|
+
'last-modified': true,
|
|
221
|
+
'authorization': true,
|
|
222
|
+
'proxy-authorization': true,
|
|
223
|
+
'if-modified-since': true,
|
|
224
|
+
'if-unmodified-since': true
|
|
225
|
+
};
|
|
226
|
+
HttpHeaders.SEMICOLON_DELIMITED_HEADERS = { 'cookie': true };
|
|
227
|
+
HttpHeaders.ARRAY_HEADERS = { 'set-cookie': true };
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HttpMessageHost = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const http_parser_js_1 = require("http-parser-js");
|
|
6
|
+
const stream_1 = tslib_1.__importDefault(require("stream"));
|
|
7
|
+
const http_headers_js_1 = require("./http-headers.js");
|
|
8
|
+
const kHeaders = Symbol('kHeaders');
|
|
9
|
+
const kHeadersProxy = Symbol('kHeadersProxy');
|
|
10
|
+
const kTrailers = Symbol('kTrailers');
|
|
11
|
+
const kTrailersProxy = Symbol('kTrailersProxy');
|
|
12
|
+
const kOnHeaderReceived = Symbol('kOnHeaderReceived');
|
|
13
|
+
const kOnTrailersReceived = Symbol('kOnTrailersReceived');
|
|
14
|
+
const kOnBodyChunk = Symbol('kOnBodyChunk');
|
|
15
|
+
const kOnReadComplete = Symbol('kOnReadComplete');
|
|
16
|
+
const crlfBuffer = Buffer.from('\r\n');
|
|
17
|
+
const HTTP_VERSION_PATTERN = /^(\d)\.(\d)$/;
|
|
18
|
+
class HttpMessageHost {
|
|
19
|
+
constructor() {
|
|
20
|
+
this.complete = false;
|
|
21
|
+
stream_1.default.Duplex.apply(this);
|
|
22
|
+
this[kHeaders] = new http_headers_js_1.HttpHeaders(undefined, {
|
|
23
|
+
onChange: () => this._headersChanged = true
|
|
24
|
+
});
|
|
25
|
+
this[kTrailers] = new http_headers_js_1.HttpHeaders(undefined, {
|
|
26
|
+
onChange: () => this._trailersChanged = true
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
get httpVersion() {
|
|
30
|
+
return this.httpVersionMajor
|
|
31
|
+
? this.httpVersionMajor + '.' + (this.httpVersionMinor || 0)
|
|
32
|
+
: undefined;
|
|
33
|
+
}
|
|
34
|
+
set httpVersion(value) {
|
|
35
|
+
if (value) {
|
|
36
|
+
const m = HTTP_VERSION_PATTERN.exec(value);
|
|
37
|
+
if (!m)
|
|
38
|
+
throw new TypeError(`Invalid http version string (${value})`);
|
|
39
|
+
this.httpVersionMajor = parseInt(m[1], 10);
|
|
40
|
+
this.httpVersionMinor = parseInt(m[2], 10);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
this.httpVersionMajor = undefined;
|
|
44
|
+
this.httpVersionMinor = undefined;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
get headers() {
|
|
48
|
+
this._initHeaders();
|
|
49
|
+
return this[kHeadersProxy];
|
|
50
|
+
}
|
|
51
|
+
set headers(headers) {
|
|
52
|
+
this[kHeaders].clear();
|
|
53
|
+
this[kHeaders].set(headers);
|
|
54
|
+
}
|
|
55
|
+
get trailers() {
|
|
56
|
+
this._initTrailers();
|
|
57
|
+
return this[kTrailersProxy];
|
|
58
|
+
}
|
|
59
|
+
set trailers(trailers) {
|
|
60
|
+
this[kTrailers].clear();
|
|
61
|
+
this[kTrailers].set(trailers);
|
|
62
|
+
}
|
|
63
|
+
get rawHeaders() {
|
|
64
|
+
this._buildRawHeaders();
|
|
65
|
+
return this._rawHeaders;
|
|
66
|
+
}
|
|
67
|
+
set rawHeaders(headers) {
|
|
68
|
+
this[kHeadersProxy] = undefined;
|
|
69
|
+
this._headersChanged = false;
|
|
70
|
+
this._rawHeaders = headers;
|
|
71
|
+
}
|
|
72
|
+
get rawTrailers() {
|
|
73
|
+
this._buildRawTrailers();
|
|
74
|
+
return this._rawTrailers;
|
|
75
|
+
}
|
|
76
|
+
set rawTrailers(trailers) {
|
|
77
|
+
this[kTrailersProxy] = undefined;
|
|
78
|
+
this._trailersChanged = false;
|
|
79
|
+
this._rawTrailers = trailers;
|
|
80
|
+
}
|
|
81
|
+
getHeader(name) {
|
|
82
|
+
if (!name)
|
|
83
|
+
return;
|
|
84
|
+
this._initHeaders();
|
|
85
|
+
switch (name.toLowerCase()) {
|
|
86
|
+
case 'referer':
|
|
87
|
+
case 'referrer':
|
|
88
|
+
return this[kHeaders].get(name) ||
|
|
89
|
+
this[kHeaders].get('referrer') ||
|
|
90
|
+
this[kHeaders].get('referer');
|
|
91
|
+
default:
|
|
92
|
+
return this[kHeaders].get(name);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
get(name) {
|
|
96
|
+
this._initHeaders();
|
|
97
|
+
return this[kHeaders].get(name);
|
|
98
|
+
}
|
|
99
|
+
setHeader(arg0, arg1) {
|
|
100
|
+
this._initHeaders();
|
|
101
|
+
if (typeof arg0 === 'object')
|
|
102
|
+
this[kHeaders].set(arg0);
|
|
103
|
+
else
|
|
104
|
+
this[kHeaders].set(arg0, arg1);
|
|
105
|
+
return this;
|
|
106
|
+
}
|
|
107
|
+
set(arg0, arg1) {
|
|
108
|
+
return this.setHeader(arg0, arg1);
|
|
109
|
+
}
|
|
110
|
+
getHeaders() {
|
|
111
|
+
this._initHeaders();
|
|
112
|
+
return this[kHeaders].toObject();
|
|
113
|
+
}
|
|
114
|
+
getHeaderNames() {
|
|
115
|
+
this._initHeaders();
|
|
116
|
+
return Array.from(this[kHeaders].keys());
|
|
117
|
+
}
|
|
118
|
+
hasHeader(name) {
|
|
119
|
+
this._initHeaders();
|
|
120
|
+
return this[kHeaders].has(name);
|
|
121
|
+
}
|
|
122
|
+
removeHeader(name) {
|
|
123
|
+
this._initHeaders();
|
|
124
|
+
this[kHeaders].delete(name);
|
|
125
|
+
}
|
|
126
|
+
send(body) {
|
|
127
|
+
this.body = body;
|
|
128
|
+
return this;
|
|
129
|
+
}
|
|
130
|
+
end(body) {
|
|
131
|
+
if (body)
|
|
132
|
+
this.body = body;
|
|
133
|
+
return this;
|
|
134
|
+
}
|
|
135
|
+
setTimeout() {
|
|
136
|
+
return this;
|
|
137
|
+
}
|
|
138
|
+
_init(args) {
|
|
139
|
+
this.complete = true;
|
|
140
|
+
this.httpVersionMajor = args?.httpVersionMajor;
|
|
141
|
+
this.httpVersionMinor = args?.httpVersionMinor;
|
|
142
|
+
this._rawHeaders = args.rawHeaders;
|
|
143
|
+
this._rawTrailers = args.rawTrailers;
|
|
144
|
+
if (args.headers)
|
|
145
|
+
this[kHeaders].set(args.headers);
|
|
146
|
+
if (args.trailers)
|
|
147
|
+
this[kTrailers].set(args.trailers);
|
|
148
|
+
this.body = args.body;
|
|
149
|
+
}
|
|
150
|
+
_parseBuffer(buf, parserType) {
|
|
151
|
+
const parser = new http_parser_js_1.HTTPParser(parserType);
|
|
152
|
+
parser[http_parser_js_1.HTTPParser.kOnHeadersComplete] = this[kOnHeaderReceived].bind(this);
|
|
153
|
+
parser[http_parser_js_1.HTTPParser.kOnBody] = this[kOnBodyChunk].bind(this);
|
|
154
|
+
parser[http_parser_js_1.HTTPParser.kOnHeaders] = this[kOnTrailersReceived].bind(this);
|
|
155
|
+
parser[http_parser_js_1.HTTPParser.kOnMessageComplete] = this[kOnReadComplete].bind(this);
|
|
156
|
+
const buffer = Buffer.from(buf);
|
|
157
|
+
let x = parser.execute(buffer);
|
|
158
|
+
if (typeof x === 'object')
|
|
159
|
+
throw x;
|
|
160
|
+
if (!this.complete) {
|
|
161
|
+
x = parser.execute(crlfBuffer);
|
|
162
|
+
if (typeof x === 'object')
|
|
163
|
+
throw x;
|
|
164
|
+
}
|
|
165
|
+
parser.finish();
|
|
166
|
+
}
|
|
167
|
+
_initHeaders() {
|
|
168
|
+
if (!this[kHeadersProxy]) {
|
|
169
|
+
this[kHeadersProxy] = this[kHeaders].getProxy();
|
|
170
|
+
if (this._rawHeaders) {
|
|
171
|
+
const src = this._rawHeaders;
|
|
172
|
+
const l = Math.floor(src.length / 2);
|
|
173
|
+
for (let n = 0; n <= l; n += 2) {
|
|
174
|
+
this[kHeaders].append(src[n], src[n + 1]);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
_initTrailers() {
|
|
180
|
+
if (!this[kTrailersProxy]) {
|
|
181
|
+
this[kTrailersProxy] = this[kTrailers].getProxy();
|
|
182
|
+
if (this._rawTrailers) {
|
|
183
|
+
const src = this._rawTrailers;
|
|
184
|
+
const l = Math.floor(src.length / 2);
|
|
185
|
+
for (let n = 0; n <= l; n += 2) {
|
|
186
|
+
this[kTrailers].append(src[n], src[n + 1]);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
_buildRawHeaders() {
|
|
192
|
+
// Rebuild rawHeaders if headers object changed
|
|
193
|
+
if (this._headersChanged || !this._rawHeaders) {
|
|
194
|
+
this._headersChanged = false;
|
|
195
|
+
this._rawHeaders = Object.entries(this.headers)
|
|
196
|
+
.reduce((a, [k, v]) => {
|
|
197
|
+
if (Array.isArray(v))
|
|
198
|
+
v.forEach(x => a.push(k, String(x)));
|
|
199
|
+
else
|
|
200
|
+
a.push(k, String(v));
|
|
201
|
+
return a;
|
|
202
|
+
}, []);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
_buildRawTrailers() {
|
|
206
|
+
// Rebuild rawHeaders if headers object changed
|
|
207
|
+
if (this._trailersChanged || !this._rawTrailers) {
|
|
208
|
+
this._trailersChanged = false;
|
|
209
|
+
this._rawTrailers = Object.entries(this.trailers)
|
|
210
|
+
.reduce((a, [k, v]) => {
|
|
211
|
+
if (Array.isArray(v))
|
|
212
|
+
v.forEach(x => a.push(k, String(x)));
|
|
213
|
+
else
|
|
214
|
+
a.push(k, String(v));
|
|
215
|
+
return a;
|
|
216
|
+
}, []);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
[kOnHeaderReceived](info) {
|
|
220
|
+
this.httpVersionMajor = info.versionMajor;
|
|
221
|
+
this.httpVersionMinor = info.versionMinor;
|
|
222
|
+
this._rawHeaders = info.headers;
|
|
223
|
+
this.shouldKeepAlive = info.shouldKeepAlive;
|
|
224
|
+
this.upgrade = info.upgrade;
|
|
225
|
+
}
|
|
226
|
+
[kOnTrailersReceived](trailers) {
|
|
227
|
+
this._rawTrailers = trailers;
|
|
228
|
+
}
|
|
229
|
+
[kOnBodyChunk](chunk, offset, length) {
|
|
230
|
+
this._bodyChunks = this._bodyChunks || [];
|
|
231
|
+
this._bodyChunks.push(chunk.subarray(offset, offset + length));
|
|
232
|
+
}
|
|
233
|
+
[kOnReadComplete]() {
|
|
234
|
+
this.complete = true;
|
|
235
|
+
if (this._bodyChunks) {
|
|
236
|
+
this.body = Buffer.concat(this._bodyChunks);
|
|
237
|
+
this._bodyChunks = undefined;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
exports.HttpMessageHost = HttpMessageHost;
|
|
242
|
+
HttpMessageHost.kHeaders = kHeaders;
|
|
243
|
+
HttpMessageHost.kHeadersProxy = kHeadersProxy;
|
|
244
|
+
HttpMessageHost.kTrailers = kTrailers;
|
|
245
|
+
HttpMessageHost.kTrailersProxy = kTrailersProxy;
|
|
246
|
+
HttpMessageHost.kOnHeaderReceived = kOnHeaderReceived;
|
|
247
|
+
HttpMessageHost.kOnTrailersReceived = kOnTrailersReceived;
|
|
248
|
+
HttpMessageHost.kOnBodyChunk = kOnBodyChunk;
|
|
249
|
+
HttpMessageHost.kOnReadComplete = kOnReadComplete;
|
|
250
|
+
// Mixin with Duplex
|
|
251
|
+
Object.assign(HttpMessageHost.prototype, stream_1.default.Duplex.prototype);
|