@opra/common 0.13.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +53 -0
- package/cjs/document/factory/import-type-class.js +130 -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/cjs/http/{param-codec → codecs}/date-codec.js +1 -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 +84 -115
- 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.d.ts +102 -0
- package/esm/document/api-document.js +207 -0
- package/esm/document/constants.d.ts +3 -0
- package/esm/document/constants.js +3 -0
- package/esm/document/data-type/api-field.d.ts +41 -0
- package/esm/document/data-type/api-field.js +79 -0
- package/esm/document/data-type/builtin/any.type.d.ts +2 -0
- package/esm/document/data-type/builtin/any.type.js +11 -0
- package/esm/document/data-type/builtin/base64.type.d.ts +6 -0
- package/esm/document/data-type/builtin/base64.type.js +35 -0
- package/esm/document/data-type/builtin/bigint.type.d.ts +6 -0
- package/esm/document/data-type/builtin/bigint.type.js +30 -0
- package/esm/document/data-type/builtin/boolean.type.d.ts +5 -0
- package/esm/document/data-type/builtin/boolean.type.js +25 -0
- package/esm/document/data-type/builtin/date.type.d.ts +4 -0
- package/esm/document/data-type/builtin/date.type.js +15 -0
- package/esm/document/data-type/builtin/guid.type.d.ts +7 -0
- package/esm/document/data-type/builtin/guid.type.js +32 -0
- package/esm/document/data-type/builtin/index.d.ts +10 -0
- package/esm/document/data-type/builtin/index.js +10 -0
- package/esm/document/data-type/builtin/integer.type.d.ts +6 -0
- package/esm/document/data-type/builtin/integer.type.js +25 -0
- package/esm/document/data-type/builtin/number.type.d.ts +6 -0
- package/esm/document/data-type/builtin/number.type.js +30 -0
- package/esm/document/data-type/builtin/object.type.d.ts +3 -0
- package/esm/document/data-type/builtin/object.type.js +17 -0
- package/esm/document/data-type/builtin/string.type.d.ts +5 -0
- package/esm/document/data-type/builtin/string.type.js +21 -0
- package/esm/document/data-type/builtin/time.type.d.ts +7 -0
- package/esm/document/data-type/builtin/time.type.js +29 -0
- package/esm/document/data-type/builtin/timestamp.type.d.ts +5 -0
- package/esm/document/data-type/builtin/timestamp.type.js +26 -0
- package/esm/document/data-type/complex-type.d.ts +50 -0
- package/esm/document/data-type/complex-type.js +150 -0
- package/esm/document/data-type/data-type.d.ts +33 -0
- package/esm/document/data-type/data-type.js +43 -0
- package/esm/document/data-type/enum-type.d.ts +32 -0
- package/esm/document/data-type/enum-type.js +58 -0
- package/esm/document/data-type/mapped-type.d.ts +53 -0
- package/esm/document/data-type/mapped-type.js +91 -0
- package/esm/document/data-type/simple-type.d.ts +33 -0
- package/esm/document/data-type/simple-type.js +57 -0
- package/esm/document/data-type/union-type.d.ts +42 -0
- package/esm/document/data-type/union-type.js +78 -0
- package/esm/document/factory/add-references.d.ts +4 -0
- package/esm/document/factory/add-references.js +16 -0
- package/esm/document/factory/create-document.d.ts +12 -0
- package/esm/document/factory/create-document.js +75 -0
- package/esm/document/factory/factory.d.ts +61 -0
- package/esm/document/factory/factory.js +58 -0
- package/esm/document/factory/import-resource-class.d.ts +9 -0
- package/esm/document/factory/import-resource-class.js +47 -0
- package/esm/document/factory/import-type-class.d.ts +17 -0
- package/esm/document/factory/import-type-class.js +120 -0
- package/esm/document/factory/index.d.ts +1 -0
- package/esm/document/factory/index.js +1 -0
- package/esm/document/factory/process-resources.d.ts +7 -0
- package/esm/document/factory/process-resources.js +49 -0
- package/esm/document/factory/process-types.d.ts +6 -0
- package/esm/document/factory/process-types.js +185 -0
- package/esm/document/index.d.ts +14 -0
- package/esm/document/index.js +14 -0
- package/esm/document/resource/collection.d.ts +67 -0
- package/esm/document/resource/collection.js +181 -0
- package/esm/document/resource/resource.d.ts +29 -0
- package/esm/document/resource/resource.js +35 -0
- package/esm/document/resource/singleton.d.ts +49 -0
- package/esm/document/resource/singleton.js +87 -0
- package/esm/exception/opra-exception.js +2 -0
- package/esm/exception/resource-errors/resource-not-found.error.d.ts +4 -0
- package/esm/exception/resource-errors/resource-not-found.error.js +4 -0
- package/esm/filter/parse.js +3 -1
- package/esm/helpers/function-utils.d.ts +4 -0
- package/esm/helpers/function-utils.js +19 -0
- package/esm/helpers/get-stack-filename.d.ts +1 -0
- package/esm/helpers/get-stack-filename.js +20 -0
- package/esm/helpers/index.d.ts +7 -0
- package/esm/helpers/index.js +7 -0
- package/esm/helpers/is-url.d.ts +1 -0
- package/esm/helpers/is-url.js +4 -0
- package/esm/{schema/utils/clone-object.util.d.ts → helpers/object-utils.d.ts} +1 -0
- package/esm/{schema/utils/clone-object.util.js → helpers/object-utils.js} +11 -0
- package/esm/helpers/path-to-object-tree.d.ts +4 -0
- package/esm/{utils/path-to-tree.js → helpers/path-to-object-tree.js} +7 -7
- package/esm/helpers/responsive-map.d.ts +15 -13
- package/esm/helpers/responsive-map.js +62 -14
- package/esm/{utils → helpers}/type-guards.d.ts +3 -1
- package/esm/{utils → helpers}/type-guards.js +9 -3
- package/esm/http/codecs/boolean-codec.d.ts +5 -0
- package/esm/http/{param-codec → codecs}/boolean-codec.js +1 -2
- package/esm/http/{param-codec → codecs}/date-codec.d.ts +2 -2
- package/esm/http/{param-codec → codecs}/date-codec.js +1 -4
- package/esm/http/{param-codec → codecs}/filter-codec.d.ts +2 -2
- package/esm/http/{param-codec → codecs}/filter-codec.js +1 -2
- package/esm/http/codecs/integer-codec.d.ts +11 -0
- package/esm/http/codecs/number-codec.d.ts +14 -0
- package/esm/http/{param-codec → codecs}/number-codec.js +1 -3
- package/esm/http/codecs/string-codec.d.ts +16 -0
- package/esm/http/{param-codec → codecs}/string-codec.js +1 -3
- package/esm/http/enums/http-headers-codes.enum.d.ts +13 -4
- package/esm/http/enums/http-headers-codes.enum.js +13 -4
- package/esm/http/enums/http-status-messages.d.ts +65 -0
- package/esm/http/enums/http-status-messages.js +65 -0
- package/esm/http/http-headers.d.ts +50 -34
- package/esm/http/http-headers.js +137 -123
- package/esm/http/http-message.host.d.ts +122 -0
- package/esm/http/http-message.host.js +246 -0
- package/esm/http/http-params.d.ts +43 -29
- package/esm/http/http-params.js +75 -43
- package/esm/http/http-request-message.d.ts +213 -0
- package/esm/http/http-request-message.js +148 -0
- package/esm/http/http-response-message.d.ts +318 -0
- package/esm/http/http-response-message.js +233 -0
- package/esm/http/index.d.ts +8 -11
- package/esm/http/index.js +8 -11
- package/esm/http/interfaces/cookie-options.interface.d.ts +4 -0
- package/esm/http/multipart/batch-multipart.d.ts +0 -31
- package/esm/http/multipart/batch-multipart.js +170 -149
- package/esm/http/multipart/http-request-content.d.ts +0 -8
- package/esm/http/multipart/http-request-content.js +17 -8
- package/esm/http/multipart/http-response-content.d.ts +0 -7
- package/esm/http/multipart/http-response-content.js +14 -7
- package/esm/http/multipart/index.d.ts +0 -1
- package/esm/http/multipart/index.js +2 -1
- package/esm/i18n/i18n.js +1 -1
- package/esm/index.d.ts +6 -5
- package/esm/index.js +6 -5
- package/esm/schema/constants.d.ts +2 -8
- package/esm/schema/constants.js +1 -8
- package/esm/schema/data-type/complex-type.interface.d.ts +16 -0
- package/esm/schema/data-type/complex-type.interface.js +4 -0
- package/esm/schema/data-type/data-type.interface.d.ts +14 -0
- package/esm/schema/data-type/enum-type.interface.d.ts +15 -0
- package/esm/schema/data-type/enum-type.interface.js +4 -0
- package/esm/schema/data-type/field.interface.d.ts +21 -0
- package/esm/schema/data-type/mapped-type.interface.d.ts +11 -0
- package/esm/schema/data-type/mapped-type.interface.js +4 -0
- package/esm/schema/data-type/simple-type.interface.d.ts +18 -0
- package/esm/schema/data-type/simple-type.interface.js +4 -0
- package/esm/schema/data-type/union-type.interface.d.ts +10 -0
- package/esm/schema/data-type/union-type.interface.js +4 -0
- package/esm/schema/document.interface.d.ts +34 -0
- package/esm/schema/index.d.ts +51 -25
- package/esm/schema/index.js +41 -25
- package/esm/schema/resource/collection.interface.d.ts +33 -0
- package/esm/schema/resource/collection.interface.js +4 -0
- package/esm/schema/resource/container.interface.d.ts +9 -0
- package/esm/schema/resource/container.interface.js +4 -0
- package/esm/schema/resource/endpoint.interface.d.ts +29 -0
- package/esm/schema/resource/resource.interface.d.ts +12 -0
- package/esm/schema/resource/resource.interface.js +1 -0
- package/esm/schema/resource/singleton.interface.d.ts +22 -0
- package/esm/schema/resource/singleton.interface.js +4 -0
- package/esm/schema/type-guards.d.ts +20 -0
- package/esm/schema/type-guards.js +46 -0
- package/esm/{schema/types.d.ts → types.d.ts} +0 -3
- package/esm/types.js +1 -0
- package/esm/url/index.d.ts +2 -2
- package/esm/url/index.js +2 -2
- package/esm/url/opra-url-path-component.js +1 -1
- package/esm/url/opra-url-path.js +6 -3
- package/esm/url/opra-url.d.ts +8 -27
- package/esm/url/opra-url.js +83 -114
- package/esm/url/utils/decode-path-component.d.ts +5 -0
- package/esm/url/utils/{path-utils.js → decode-path-component.js} +0 -41
- package/esm/url/utils/encode-path-component.d.ts +1 -0
- package/esm/url/utils/encode-path-component.js +22 -0
- package/esm/utils/path-utils.d.ts +2 -0
- package/esm/utils/path-utils.js +19 -0
- package/package.json +21 -6
- 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/filter-format.js +0 -18
- package/cjs/url/formats/format.js +0 -6
- package/cjs/url/formats/integer-format.js +0 -19
- 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.d.ts +0 -0
- package/esm/constants.js +0 -1
- 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/param-codec/boolean-codec.d.ts +0 -5
- package/esm/http/param-codec/integer-codec.d.ts +0 -9
- 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/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/interfaces/child-field-query.interface.d.ts +0 -4
- package/esm/schema/interfaces/data-type.metadata.d.ts +0 -18
- package/esm/schema/interfaces/resource-container.interface.d.ts +0 -8
- package/esm/schema/interfaces/resource.metadata.d.ts +0 -18
- 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/utils/class.utils.d.ts +0 -2
- package/esm/schema/utils/class.utils.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/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/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/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 → document}/utils/inspect.util.d.ts +0 -0
- /package/esm/{schema → document}/utils/inspect.util.js +0 -0
- /package/esm/{schema → document}/utils/string-compare.util.d.ts +0 -0
- /package/esm/{schema → document}/utils/string-compare.util.js +0 -0
- /package/esm/{schema/type-helpers/mixin.utils.d.ts → helpers/mixin-utils.d.ts} +0 -0
- /package/esm/{schema/type-helpers/mixin.utils.js → helpers/mixin-utils.js} +0 -0
- /package/esm/http/{param-codec → codecs}/integer-codec.js +0 -0
- /package/esm/{schema/interfaces/child-field-query.interface.js → http/interfaces/cookie-options.interface.js} +0 -0
- /package/esm/schema/{interfaces/data-type.metadata.js → data-type/data-type.interface.js} +0 -0
- /package/esm/schema/{interfaces/resource-container.interface.js → data-type/field.interface.js} +0 -0
- /package/esm/schema/{interfaces/resource.metadata.js → document.interface.js} +0 -0
- /package/esm/schema/{types.js → resource/endpoint.interface.js} +0 -0
package/esm/url/opra-url.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
var _a;
|
|
2
2
|
import { splitString, tokenize } from 'fast-tokenizer';
|
|
3
|
+
import { HttpParams } from '../http/index.js';
|
|
4
|
+
import { normalizePath } from '../utils/path-utils.js';
|
|
3
5
|
import { OpraURLPath } from './opra-url-path.js';
|
|
4
|
-
import {
|
|
5
|
-
import { decodePathComponent, normalizePath } from './utils/path-utils.js';
|
|
6
|
+
import { decodePathComponent } from './utils/decode-path-component.js';
|
|
6
7
|
const nodeInspectCustom = Symbol.for('nodejs.util.inspect.custom');
|
|
7
8
|
const urlRegEx = /^(?:((?:[A-Z][A-Z+-.]+:)+)\/\/([^/?]+))?(.*)?$/i;
|
|
8
9
|
const schemeRegEx = /^([A-Z][A-Z+-.]+:?)+$/i;
|
|
@@ -12,32 +13,27 @@ const kContext = Symbol('kContext');
|
|
|
12
13
|
const kPath = Symbol('kPath');
|
|
13
14
|
const kSearchParams = Symbol('kSearchParams');
|
|
14
15
|
export class OpraURL {
|
|
15
|
-
constructor(input,
|
|
16
|
+
constructor(input, base) {
|
|
16
17
|
this[_a] = {
|
|
17
18
|
protocol: '',
|
|
18
19
|
username: '',
|
|
19
|
-
pathname: '',
|
|
20
20
|
prefix: '',
|
|
21
21
|
hostname: '',
|
|
22
22
|
port: '',
|
|
23
23
|
hash: '',
|
|
24
|
-
password: ''
|
|
25
|
-
search: '',
|
|
26
|
-
address: '',
|
|
27
|
-
needUpdate: true
|
|
24
|
+
password: ''
|
|
28
25
|
};
|
|
29
26
|
this[kPath] = new OpraURLPath('', {
|
|
30
|
-
onChange: () =>
|
|
27
|
+
onChange: () => {
|
|
28
|
+
this[kContext].pathname = undefined;
|
|
29
|
+
this[kContext].address = undefined;
|
|
30
|
+
}
|
|
31
31
|
});
|
|
32
|
-
this[kSearchParams] = new
|
|
33
|
-
onChange: () =>
|
|
32
|
+
this[kSearchParams] = new HttpParams('', {
|
|
33
|
+
onChange: () => {
|
|
34
|
+
this[kContext].search = undefined;
|
|
35
|
+
}
|
|
34
36
|
});
|
|
35
|
-
const base = typeof arg1 === 'object' ? arg1.base : arg1;
|
|
36
|
-
if (typeof arg1 === 'object') {
|
|
37
|
-
const defineParams = arg1?.params;
|
|
38
|
-
if (defineParams)
|
|
39
|
-
Object.keys(defineParams).forEach(key => this.searchParams.define(key, defineParams[key]));
|
|
40
|
-
}
|
|
41
37
|
if (input)
|
|
42
38
|
this.parse(typeof input === 'object' ? input.toString() : input);
|
|
43
39
|
if (base) {
|
|
@@ -49,7 +45,19 @@ export class OpraURL {
|
|
|
49
45
|
}
|
|
50
46
|
}
|
|
51
47
|
get address() {
|
|
52
|
-
this.
|
|
48
|
+
if (this[kContext].address == null) {
|
|
49
|
+
let address = '';
|
|
50
|
+
if (this[kContext].hostname) {
|
|
51
|
+
address += (this[kContext].protocol || 'http:') + '//' +
|
|
52
|
+
(this[kContext].username || this[kContext].password
|
|
53
|
+
? ((this[kContext].username ? encodeURIComponent(this[kContext].username) : '') +
|
|
54
|
+
(this[kContext].password ? ':' + encodeURIComponent(this[kContext].password) : '') + '@')
|
|
55
|
+
: '') + this.host;
|
|
56
|
+
}
|
|
57
|
+
this[kContext].address = address +
|
|
58
|
+
(this.prefix !== '/' ? this.prefix : '') +
|
|
59
|
+
(this.pathname !== '/' ? this.pathname : '');
|
|
60
|
+
}
|
|
53
61
|
return this[kContext].address;
|
|
54
62
|
}
|
|
55
63
|
get host() {
|
|
@@ -63,17 +71,16 @@ export class OpraURL {
|
|
|
63
71
|
host: v,
|
|
64
72
|
code: 'ERR_INVALID_URL'
|
|
65
73
|
});
|
|
66
|
-
this
|
|
67
|
-
this
|
|
74
|
+
this.hostname = m[1];
|
|
75
|
+
this.port = m[2] || '';
|
|
68
76
|
}
|
|
69
77
|
else {
|
|
70
|
-
this
|
|
71
|
-
this
|
|
78
|
+
this.hostname = '';
|
|
79
|
+
this.port = '';
|
|
72
80
|
}
|
|
73
|
-
this._changed();
|
|
74
81
|
}
|
|
75
82
|
get hostname() {
|
|
76
|
-
return this[kContext].hostname
|
|
83
|
+
return this[kContext].hostname;
|
|
77
84
|
}
|
|
78
85
|
set hostname(v) {
|
|
79
86
|
if (v) {
|
|
@@ -86,7 +93,7 @@ export class OpraURL {
|
|
|
86
93
|
}
|
|
87
94
|
else
|
|
88
95
|
this[kContext].hostname = '';
|
|
89
|
-
this.
|
|
96
|
+
this[kContext].address = undefined;
|
|
90
97
|
}
|
|
91
98
|
get href() {
|
|
92
99
|
return this.address + this.search + this.hash;
|
|
@@ -95,8 +102,8 @@ export class OpraURL {
|
|
|
95
102
|
return this[kContext].password;
|
|
96
103
|
}
|
|
97
104
|
set password(v) {
|
|
98
|
-
this[kContext].password = v
|
|
99
|
-
this.
|
|
105
|
+
this[kContext].password = v ?? '';
|
|
106
|
+
this[kContext].address = undefined;
|
|
100
107
|
}
|
|
101
108
|
get port() {
|
|
102
109
|
return this[kContext].port;
|
|
@@ -104,17 +111,16 @@ export class OpraURL {
|
|
|
104
111
|
set port(value) {
|
|
105
112
|
if (value) {
|
|
106
113
|
// noinspection SuspiciousTypeOfGuard
|
|
107
|
-
const v = parseInt(value, 10);
|
|
114
|
+
const v = typeof value === 'number' ? value : parseInt(value, 10);
|
|
108
115
|
if (isNaN(v) || v < 1 || v > 35535 || v % 1 > 0)
|
|
109
116
|
throw Object.assign(new TypeError('Invalid port'), {
|
|
110
117
|
hostname: v,
|
|
111
118
|
code: 'ERR_INVALID_URL'
|
|
112
119
|
});
|
|
113
|
-
this[kContext].port =
|
|
120
|
+
this[kContext].port = String(v);
|
|
114
121
|
}
|
|
115
122
|
else
|
|
116
123
|
this[kContext].port = '';
|
|
117
|
-
this._changed();
|
|
118
124
|
}
|
|
119
125
|
get prefix() {
|
|
120
126
|
return this[kContext].prefix;
|
|
@@ -126,10 +132,10 @@ export class OpraURL {
|
|
|
126
132
|
}
|
|
127
133
|
else
|
|
128
134
|
this[kContext].prefix = '';
|
|
129
|
-
this.
|
|
135
|
+
this[kContext].address = undefined;
|
|
130
136
|
}
|
|
131
137
|
get protocol() {
|
|
132
|
-
return this[kContext].protocol
|
|
138
|
+
return this[kContext].protocol;
|
|
133
139
|
}
|
|
134
140
|
set protocol(v) {
|
|
135
141
|
if (v) {
|
|
@@ -142,14 +148,14 @@ export class OpraURL {
|
|
|
142
148
|
}
|
|
143
149
|
else
|
|
144
150
|
this[kContext].protocol = '';
|
|
145
|
-
this.
|
|
151
|
+
this[kContext].address = undefined;
|
|
146
152
|
}
|
|
147
153
|
get username() {
|
|
148
154
|
return this[kContext].username;
|
|
149
155
|
}
|
|
150
156
|
set username(v) {
|
|
151
|
-
this[kContext].username = v
|
|
152
|
-
this.
|
|
157
|
+
this[kContext].username = v ?? '';
|
|
158
|
+
this[kContext].address = undefined;
|
|
153
159
|
}
|
|
154
160
|
get origin() {
|
|
155
161
|
return this.hostname ? (this.protocol + '//' + this.hostname) : '';
|
|
@@ -158,29 +164,35 @@ export class OpraURL {
|
|
|
158
164
|
return this[kPath];
|
|
159
165
|
}
|
|
160
166
|
get pathname() {
|
|
161
|
-
this.
|
|
162
|
-
|
|
167
|
+
if (this[kContext].pathname == null)
|
|
168
|
+
this[kContext].pathname = '/' + this[kPath].toString();
|
|
169
|
+
return this[kContext].pathname;
|
|
163
170
|
}
|
|
164
171
|
set pathname(v) {
|
|
165
172
|
this._setPathname(v, false);
|
|
166
173
|
}
|
|
167
|
-
get searchParams() {
|
|
168
|
-
return this[kSearchParams];
|
|
169
|
-
}
|
|
170
174
|
get hash() {
|
|
171
|
-
return this[kContext].hash
|
|
175
|
+
return this[kContext].hash;
|
|
172
176
|
}
|
|
173
177
|
set hash(v) {
|
|
174
178
|
this[kContext].hash = v ? (v.startsWith('#') ? v : '#' + v) : '';
|
|
175
|
-
this._changed();
|
|
176
179
|
}
|
|
177
180
|
get search() {
|
|
178
|
-
this.
|
|
179
|
-
|
|
181
|
+
if (this[kContext].search == null) {
|
|
182
|
+
const s = this[kSearchParams].toString();
|
|
183
|
+
this[kContext].search = s ? ('?' + s) : '';
|
|
184
|
+
}
|
|
185
|
+
return this[kContext].search;
|
|
180
186
|
}
|
|
181
187
|
set search(v) {
|
|
182
|
-
|
|
183
|
-
|
|
188
|
+
if (v) {
|
|
189
|
+
this[kSearchParams].clear();
|
|
190
|
+
this[kSearchParams].appendAll(v);
|
|
191
|
+
}
|
|
192
|
+
this[kContext].search = undefined;
|
|
193
|
+
}
|
|
194
|
+
get searchParams() {
|
|
195
|
+
return this[kSearchParams];
|
|
184
196
|
}
|
|
185
197
|
parse(input) {
|
|
186
198
|
const m = urlRegEx.exec(input);
|
|
@@ -213,60 +225,18 @@ export class OpraURL {
|
|
|
213
225
|
this.hash = tokenizer.join('#');
|
|
214
226
|
tokenizer = tokenize(input, { delimiters: '?', quotes: true, brackets: true });
|
|
215
227
|
this._setPathname(tokenizer.next() || '', isAbsolute);
|
|
216
|
-
this.
|
|
217
|
-
this.searchParams.appendAll(tokenizer.join('&'));
|
|
218
|
-
this._changed();
|
|
228
|
+
this.search = tokenizer.join('&');
|
|
219
229
|
}
|
|
220
230
|
join(...source) {
|
|
221
231
|
this.path.join(...source);
|
|
222
232
|
return this;
|
|
223
233
|
}
|
|
224
|
-
addParam(name, value) {
|
|
225
|
-
this.searchParams.append(name, value);
|
|
226
|
-
return this;
|
|
227
|
-
}
|
|
228
|
-
setParam(name, value) {
|
|
229
|
-
this.searchParams.set(name, value);
|
|
230
|
-
return this;
|
|
231
|
-
}
|
|
232
|
-
setHost(v) {
|
|
233
|
-
this.host = v;
|
|
234
|
-
return this;
|
|
235
|
-
}
|
|
236
|
-
setHostname(v) {
|
|
237
|
-
this.hostname = v;
|
|
238
|
-
return this;
|
|
239
|
-
}
|
|
240
|
-
setProtocol(v) {
|
|
241
|
-
this.protocol = v;
|
|
242
|
-
return this;
|
|
243
|
-
}
|
|
244
|
-
setPort(v) {
|
|
245
|
-
this.port = v ? String(v) : '';
|
|
246
|
-
return this;
|
|
247
|
-
}
|
|
248
|
-
setPrefix(v) {
|
|
249
|
-
this.prefix = v;
|
|
250
|
-
return this;
|
|
251
|
-
}
|
|
252
|
-
setPathname(v) {
|
|
253
|
-
this.pathname = v;
|
|
254
|
-
return this;
|
|
255
|
-
}
|
|
256
|
-
setHash(v) {
|
|
257
|
-
this.hash = v;
|
|
258
|
-
return this;
|
|
259
|
-
}
|
|
260
|
-
setSearch(v) {
|
|
261
|
-
this.search = v;
|
|
262
|
-
return this;
|
|
263
|
-
}
|
|
264
234
|
toString() {
|
|
265
235
|
return this.href;
|
|
266
236
|
}
|
|
267
237
|
/* istanbul ignore next */
|
|
268
238
|
[(_a = kContext, nodeInspectCustom)]() {
|
|
269
|
-
this._update();
|
|
239
|
+
// this._update();
|
|
270
240
|
return {
|
|
271
241
|
protocol: this.protocol,
|
|
272
242
|
username: this.username,
|
|
@@ -278,29 +248,32 @@ export class OpraURL {
|
|
|
278
248
|
path: this.path,
|
|
279
249
|
pathname: this.pathname,
|
|
280
250
|
search: this.search,
|
|
281
|
-
searchParams: this.searchParams,
|
|
282
251
|
hash: this.hash,
|
|
283
252
|
};
|
|
284
253
|
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
254
|
+
//
|
|
255
|
+
// protected _update() {
|
|
256
|
+
// if (!this[kContext].needUpdate)
|
|
257
|
+
// return;
|
|
258
|
+
// const ctx = this[kContext];
|
|
259
|
+
// ctx.needUpdate = false;
|
|
260
|
+
// let s = this.path.toString();
|
|
261
|
+
// ctx.pathname = s ? '/' + s : '';
|
|
262
|
+
// s = this.searchParams.toString();
|
|
263
|
+
// ctx.search = s ? '?' + s : '';
|
|
264
|
+
//
|
|
265
|
+
// let address = '';
|
|
266
|
+
// if (ctx.hostname) {
|
|
267
|
+
// address += (ctx.protocol || 'http:') + '//' +
|
|
268
|
+
// (ctx.username || ctx.password
|
|
269
|
+
// ? (
|
|
270
|
+
// (ctx.username ? encodeURIComponent(ctx.username) : '') +
|
|
271
|
+
// (ctx.password ? ':' + encodeURIComponent(ctx.password) : '') + '@'
|
|
272
|
+
// )
|
|
273
|
+
// : '') + this.host;
|
|
274
|
+
// }
|
|
275
|
+
// ctx.address = address + ctx.prefix + ctx.pathname;
|
|
276
|
+
// }
|
|
304
277
|
_setPathname(v, trimPrefix) {
|
|
305
278
|
this.path.clear();
|
|
306
279
|
if (!v)
|
|
@@ -322,10 +295,6 @@ export class OpraURL {
|
|
|
322
295
|
const p = decodePathComponent(x);
|
|
323
296
|
this.path.join(p);
|
|
324
297
|
}
|
|
325
|
-
this._changed();
|
|
326
|
-
}
|
|
327
|
-
_changed() {
|
|
328
|
-
this[kContext].needUpdate = true;
|
|
329
298
|
}
|
|
330
299
|
}
|
|
331
300
|
OpraURL.kContext = kContext;
|
|
@@ -1,24 +1,4 @@
|
|
|
1
1
|
import { splitString } from 'fast-tokenizer';
|
|
2
|
-
import isPlainObject from 'putil-isplainobject';
|
|
3
|
-
export function normalizePath(p, noLeadingSlash) {
|
|
4
|
-
if (!p)
|
|
5
|
-
return '';
|
|
6
|
-
while (noLeadingSlash && p.startsWith('/'))
|
|
7
|
-
p = p.substring(1);
|
|
8
|
-
while (p.endsWith('/'))
|
|
9
|
-
p = p.substring(0, p.length - 1);
|
|
10
|
-
return p;
|
|
11
|
-
}
|
|
12
|
-
export function joinPath(...p) {
|
|
13
|
-
const out = [];
|
|
14
|
-
let s;
|
|
15
|
-
for (let i = 0, l = p.length; i < l; i++) {
|
|
16
|
-
s = normalizePath(p[i], i > 0);
|
|
17
|
-
if (s)
|
|
18
|
-
out.push(s);
|
|
19
|
-
}
|
|
20
|
-
return out.join('/');
|
|
21
|
-
}
|
|
22
2
|
const pathComponentRegEx = /^([^/?#:@]+)(?:@([^/?#:]*))?(?:::(.*))?$/;
|
|
23
3
|
export function decodePathComponent(input) {
|
|
24
4
|
const m = pathComponentRegEx.exec(input);
|
|
@@ -55,24 +35,3 @@ export function decodePathComponent(input) {
|
|
|
55
35
|
}
|
|
56
36
|
return { resource, key };
|
|
57
37
|
}
|
|
58
|
-
export function encodePathComponent(resource, key, typeCast) {
|
|
59
|
-
if (resource == null)
|
|
60
|
-
return '';
|
|
61
|
-
let keyString = '';
|
|
62
|
-
if (key !== '' && key != null) {
|
|
63
|
-
if (isPlainObject(key)) {
|
|
64
|
-
const arr = [];
|
|
65
|
-
for (const k of Object.keys(key)) {
|
|
66
|
-
arr.push(encodeURIComponent(k) + '=' + encodeURIComponent(key[k]));
|
|
67
|
-
}
|
|
68
|
-
keyString = arr.join(';');
|
|
69
|
-
}
|
|
70
|
-
else
|
|
71
|
-
keyString = encodeURIComponent('' + key);
|
|
72
|
-
}
|
|
73
|
-
if (typeCast)
|
|
74
|
-
typeCast = encodeURIComponent(typeCast);
|
|
75
|
-
return encodeURIComponent(resource).replace(/%24/, '$') +
|
|
76
|
-
(keyString ? '@' + keyString : '') +
|
|
77
|
-
(typeCast ? '::' + typeCast : '');
|
|
78
|
-
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function encodePathComponent(resource: string, key?: any, typeCast?: string): string;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import isPlainObject from 'putil-isplainobject';
|
|
2
|
+
export function encodePathComponent(resource, key, typeCast) {
|
|
3
|
+
if (resource == null)
|
|
4
|
+
return '';
|
|
5
|
+
let keyString = '';
|
|
6
|
+
if (key !== '' && key != null) {
|
|
7
|
+
if (isPlainObject(key)) {
|
|
8
|
+
const arr = [];
|
|
9
|
+
for (const k of Object.keys(key)) {
|
|
10
|
+
arr.push(encodeURIComponent(k) + '=' + encodeURIComponent(key[k]));
|
|
11
|
+
}
|
|
12
|
+
keyString = arr.join(';');
|
|
13
|
+
}
|
|
14
|
+
else
|
|
15
|
+
keyString = encodeURIComponent('' + key);
|
|
16
|
+
}
|
|
17
|
+
if (typeCast)
|
|
18
|
+
typeCast = encodeURIComponent(typeCast);
|
|
19
|
+
return encodeURIComponent(resource).replace(/%24/, '$') +
|
|
20
|
+
(keyString ? '@' + keyString : '') +
|
|
21
|
+
(typeCast ? '::' + typeCast : '');
|
|
22
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export function normalizePath(p, noLeadingSlash) {
|
|
2
|
+
if (!p)
|
|
3
|
+
return '';
|
|
4
|
+
while (noLeadingSlash && p.startsWith('/'))
|
|
5
|
+
p = p.substring(1);
|
|
6
|
+
while (p.endsWith('/'))
|
|
7
|
+
p = p.substring(0, p.length - 1);
|
|
8
|
+
return p;
|
|
9
|
+
}
|
|
10
|
+
export function joinPath(...p) {
|
|
11
|
+
const out = [];
|
|
12
|
+
let s;
|
|
13
|
+
for (let i = 0, l = p.length; i < l; i++) {
|
|
14
|
+
s = normalizePath(p[i], i > 0);
|
|
15
|
+
if (s)
|
|
16
|
+
out.push(s);
|
|
17
|
+
}
|
|
18
|
+
return out.join('/');
|
|
19
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/common",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "Opra internationalization package",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"postbuild": "cp package.json ../../LICENSE ../../build/common && cp ../../package.cjs.json ../../build/common/cjs/package.json",
|
|
19
19
|
"lint": "eslint . --max-warnings=0",
|
|
20
20
|
"check": "madge --circular src/**",
|
|
21
|
-
"test": "
|
|
22
|
-
"cover": "
|
|
21
|
+
"test": "jest",
|
|
22
|
+
"cover": "jest --collect-coverage",
|
|
23
23
|
"clean": "npm run clean:src && npm run clean:dist && npm run clean:cover",
|
|
24
24
|
"clean:src": "ts-cleanup -s src --all && ts-cleanup -s test --all",
|
|
25
25
|
"clean:dist": "rimraf ../../build/common",
|
|
@@ -28,19 +28,34 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@browsery/antlr4": "^0.2.0",
|
|
31
|
-
"
|
|
31
|
+
"accepts": "^1.3.8",
|
|
32
|
+
"content-disposition": "^0.5.4",
|
|
33
|
+
"cookie": "^0.5.0",
|
|
34
|
+
"cookie-signature": "^1.0.7",
|
|
35
|
+
"dayjs": "^1.11.7",
|
|
36
|
+
"encodeurl": "^1.0.2",
|
|
37
|
+
"fast-tokenizer": "^1.2.2",
|
|
32
38
|
"highland": "^2.13.5",
|
|
33
39
|
"http-parser-js": "^0.5.8",
|
|
34
|
-
"i18next": "^22.4.
|
|
40
|
+
"i18next": "^22.4.14",
|
|
35
41
|
"lodash.omit": "^4.5.0",
|
|
42
|
+
"mime-types": "^2.1.35",
|
|
36
43
|
"putil-isplainobject": "^1.1.5",
|
|
37
|
-
"putil-merge": "^3.10.
|
|
44
|
+
"putil-merge": "^3.10.3",
|
|
38
45
|
"putil-promisify": "^1.10.0",
|
|
39
46
|
"putil-varhelpers": "^1.6.5",
|
|
40
47
|
"reflect-metadata": "^0.1.13",
|
|
48
|
+
"type-is": "^1.6.18",
|
|
41
49
|
"uid": "^2.0.1"
|
|
42
50
|
},
|
|
43
51
|
"devDependencies": {
|
|
52
|
+
"@types/accepts": "^1.3.5",
|
|
53
|
+
"@types/content-disposition": "^0.5.5",
|
|
54
|
+
"@types/cookie": "^0.5.1",
|
|
55
|
+
"@types/cookie-signature": "^1.1.0",
|
|
56
|
+
"@types/encodeurl": "^1.0.0",
|
|
57
|
+
"@types/type-is": "^1.6.3",
|
|
58
|
+
"@types/mime-types": "^2.1.1",
|
|
44
59
|
"ts-gems": "^2.3.0"
|
|
45
60
|
},
|
|
46
61
|
"type": "module",
|
package/cjs/constants.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HttpRequestNode = void 0;
|
|
4
|
-
const http_parser_js_1 = require("http-parser-js");
|
|
5
|
-
const stream_1 = require("stream");
|
|
6
|
-
const crlfBuffer = Buffer.from('\r\n');
|
|
7
|
-
const kHeaders = Symbol('kHeaders');
|
|
8
|
-
const kHeadersCount = Symbol('kHeadersCount');
|
|
9
|
-
const kTrailers = Symbol('kTrailers');
|
|
10
|
-
const kTrailersCount = Symbol('kTrailersCount');
|
|
11
|
-
// todo: Check is this class should be in common library
|
|
12
|
-
class HttpRequestNode extends stream_1.Readable {
|
|
13
|
-
constructor() {
|
|
14
|
-
super(...arguments);
|
|
15
|
-
this.aborted = false;
|
|
16
|
-
}
|
|
17
|
-
get headers() {
|
|
18
|
-
if (!this[kHeaders])
|
|
19
|
-
this[kHeaders] = arrayToHeaders(this.rawHeaders);
|
|
20
|
-
return this[kHeaders];
|
|
21
|
-
}
|
|
22
|
-
get headersCount() {
|
|
23
|
-
return this[kHeadersCount];
|
|
24
|
-
}
|
|
25
|
-
get trailers() {
|
|
26
|
-
if (!this[kTrailers])
|
|
27
|
-
this[kTrailers] = arrayToHeaders(this.rawTrailers);
|
|
28
|
-
return this[kTrailers];
|
|
29
|
-
}
|
|
30
|
-
get trailersCount() {
|
|
31
|
-
return this[kTrailersCount];
|
|
32
|
-
}
|
|
33
|
-
_read() {
|
|
34
|
-
if (this.data) {
|
|
35
|
-
this.push(this.data);
|
|
36
|
-
}
|
|
37
|
-
this.push(null);
|
|
38
|
-
}
|
|
39
|
-
static parse(input) {
|
|
40
|
-
const parser = new http_parser_js_1.HTTPParser(http_parser_js_1.HTTPParser.REQUEST);
|
|
41
|
-
const out = new HttpRequestNode();
|
|
42
|
-
const bodyChunks = [];
|
|
43
|
-
parser[http_parser_js_1.HTTPParser.kOnHeadersComplete] = function (req) {
|
|
44
|
-
out.shouldKeepAlive = req.shouldKeepAlive;
|
|
45
|
-
out.upgrade = req.upgrade;
|
|
46
|
-
out.method = http_parser_js_1.HTTPParser.methods[req.method];
|
|
47
|
-
out.url = req.url;
|
|
48
|
-
out.originalUrl = req.url;
|
|
49
|
-
out.httpVersionMajor = req.versionMajor;
|
|
50
|
-
out.httpVersionMinor = req.versionMinor;
|
|
51
|
-
out.httpVersion = req.versionMajor + '.' + req.versionMinor;
|
|
52
|
-
out.rawHeaders = req.headers;
|
|
53
|
-
out[kHeadersCount] = Math.ceil(req.headers.length / 2);
|
|
54
|
-
out[kTrailersCount] = 0;
|
|
55
|
-
};
|
|
56
|
-
parser[http_parser_js_1.HTTPParser.kOnBody] = function (chunk, offset, length) {
|
|
57
|
-
bodyChunks.push(chunk.subarray(offset, offset + length));
|
|
58
|
-
};
|
|
59
|
-
// This is actually the event for trailers, go figure.
|
|
60
|
-
parser[http_parser_js_1.HTTPParser.kOnHeaders] = function (t) {
|
|
61
|
-
out.rawTrailers = t;
|
|
62
|
-
out[kTrailersCount] = Math.ceil(t.length / 2);
|
|
63
|
-
};
|
|
64
|
-
parser[http_parser_js_1.HTTPParser.kOnMessageComplete] = function () {
|
|
65
|
-
out.complete = true;
|
|
66
|
-
};
|
|
67
|
-
// Since we are sending the entire Buffer at once here all callbacks above happen synchronously.
|
|
68
|
-
// The parser does not do _anything_ asynchronous.
|
|
69
|
-
// However, you can of course call execute() multiple times with multiple chunks, e.g. from a stream.
|
|
70
|
-
// But then you have to refactor the entire logic to be async (e.g. resolve a Promise in kOnMessageComplete and add timeout logic).
|
|
71
|
-
parser.execute(input);
|
|
72
|
-
if (!out.complete)
|
|
73
|
-
parser.execute(crlfBuffer);
|
|
74
|
-
parser.finish();
|
|
75
|
-
if (!out.complete) {
|
|
76
|
-
throw new Error('Could not parse request');
|
|
77
|
-
}
|
|
78
|
-
out.rawTrailers = out.rawTrailers || [];
|
|
79
|
-
if (bodyChunks.length)
|
|
80
|
-
out.data = Buffer.concat(bodyChunks);
|
|
81
|
-
out.resume();
|
|
82
|
-
return out;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
exports.HttpRequestNode = HttpRequestNode;
|
|
86
|
-
function arrayToHeaders(arr) {
|
|
87
|
-
const headers = {};
|
|
88
|
-
for (let i = 0; i < arr.length; i++) {
|
|
89
|
-
const k = arr[i].toLowerCase();
|
|
90
|
-
const v = arr[++i];
|
|
91
|
-
const trgV = headers[k];
|
|
92
|
-
// Array header -- only Set-Cookie at the moment
|
|
93
|
-
if (trgV && k === 'set-cookie') {
|
|
94
|
-
const a = Array.isArray(trgV) ? trgV : [trgV];
|
|
95
|
-
a.push(v);
|
|
96
|
-
headers[k] = a;
|
|
97
|
-
}
|
|
98
|
-
else if (typeof trgV === 'string') {
|
|
99
|
-
headers[k] += (k === 'cookie' ? '; ' : ', ') + v;
|
|
100
|
-
}
|
|
101
|
-
else
|
|
102
|
-
headers[k] = v;
|
|
103
|
-
}
|
|
104
|
-
return headers;
|
|
105
|
-
}
|