@opra/common 0.14.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
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MixinType = void 0;
|
|
4
|
-
const constants_js_1 = require("../constants.js");
|
|
5
|
-
const mixin_utils_js_1 = require("./mixin.utils.js");
|
|
6
|
-
const optionalsSymbol = Symbol.for('opra.optional-lib.sqb-connect');
|
|
7
|
-
function MixinType(c1, c2, c3, c4) {
|
|
8
|
-
const clasRefs = [...arguments].filter(x => !!x);
|
|
9
|
-
if (!clasRefs.length)
|
|
10
|
-
throw new TypeError('You must provide base classeses');
|
|
11
|
-
if (clasRefs.length === 1)
|
|
12
|
-
return clasRefs[0];
|
|
13
|
-
class MappedClass {
|
|
14
|
-
constructor() {
|
|
15
|
-
for (const c of clasRefs)
|
|
16
|
-
(0, mixin_utils_js_1.inheritPropertyInitializers)(this, c);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
const mappedTypeMetadata = [];
|
|
20
|
-
for (const c of clasRefs) {
|
|
21
|
-
const m = Reflect.getOwnMetadata(constants_js_1.DATATYPE_METADATA, c);
|
|
22
|
-
if (m) {
|
|
23
|
-
if (!(m.kind === 'ComplexType'))
|
|
24
|
-
throw new TypeError(`Class "${c}" is not a ComplexType`);
|
|
25
|
-
mappedTypeMetadata.push({
|
|
26
|
-
type: c
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
else if (Reflect.hasMetadata(constants_js_1.MAPPED_TYPE_METADATA, c)) {
|
|
30
|
-
const mtm = Reflect.getMetadata(constants_js_1.MAPPED_TYPE_METADATA, c);
|
|
31
|
-
if (mtm)
|
|
32
|
-
mappedTypeMetadata.push(...mtm);
|
|
33
|
-
}
|
|
34
|
-
else
|
|
35
|
-
throw new TypeError(`Class "${c}" doesn't have datatype metadata information`);
|
|
36
|
-
(0, mixin_utils_js_1.applyMixins)(MappedClass, c);
|
|
37
|
-
}
|
|
38
|
-
const SqbConnect = globalThis[optionalsSymbol]?.SqbConnect;
|
|
39
|
-
if (SqbConnect) {
|
|
40
|
-
const { Entity } = SqbConnect;
|
|
41
|
-
Entity.mixin(MappedClass, ...clasRefs);
|
|
42
|
-
}
|
|
43
|
-
Reflect.defineMetadata(constants_js_1.MAPPED_TYPE_METADATA, mappedTypeMetadata, MappedClass);
|
|
44
|
-
return MappedClass;
|
|
45
|
-
}
|
|
46
|
-
exports.MixinType = MixinType;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isConstructor = void 0;
|
|
4
|
-
function isConstructor(obj) {
|
|
5
|
-
return typeof obj === 'function' &&
|
|
6
|
-
!!(obj.prototype && obj.prototype.constructor);
|
|
7
|
-
}
|
|
8
|
-
exports.isConstructor = isConstructor;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.normalizeFieldArray = void 0;
|
|
4
|
-
const complex_type_js_1 = require("../implementation/data-type/complex-type.js");
|
|
5
|
-
const path_to_tree_util_js_1 = require("./path-to-tree.util.js");
|
|
6
|
-
function normalizeFieldArray(document, dataType, fields, parentPath = '') {
|
|
7
|
-
const fieldsTree = (0, path_to_tree_util_js_1.pathToTree)(fields) || {};
|
|
8
|
-
return _normalizeFieldsList([], document, dataType, fieldsTree, '', parentPath, {
|
|
9
|
-
additionalFields: true
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
exports.normalizeFieldArray = normalizeFieldArray;
|
|
13
|
-
function _normalizeFieldsList(target, document, dataType, node, parentPath = '', actualPath = '', options) {
|
|
14
|
-
let curPath = '';
|
|
15
|
-
for (const k of Object.keys(node)) {
|
|
16
|
-
const nodeVal = node[k];
|
|
17
|
-
const prop = dataType?.fields.get(k);
|
|
18
|
-
if (!prop) {
|
|
19
|
-
curPath = parentPath ? parentPath + '.' + k : k;
|
|
20
|
-
if (!options?.additionalFields || (dataType && !dataType.additionalFields))
|
|
21
|
-
throw new TypeError(`Unknown field "${curPath}"`);
|
|
22
|
-
if (typeof nodeVal === 'object')
|
|
23
|
-
_normalizeFieldsList(target, document, undefined, nodeVal, curPath, actualPath, options);
|
|
24
|
-
else
|
|
25
|
-
target.push(curPath);
|
|
26
|
-
continue;
|
|
27
|
-
}
|
|
28
|
-
curPath = parentPath ? parentPath + '.' + prop.name : prop.name;
|
|
29
|
-
const propType = document.getDataType(prop.type || 'string');
|
|
30
|
-
if (typeof nodeVal === 'object') {
|
|
31
|
-
if (!(propType && propType instanceof complex_type_js_1.ComplexType))
|
|
32
|
-
throw new TypeError(`"${(actualPath ? actualPath + '.' + curPath : curPath)}" is not a complex type and has no sub fields`);
|
|
33
|
-
if (target.findIndex(x => x === parentPath) >= 0)
|
|
34
|
-
continue;
|
|
35
|
-
target = _normalizeFieldsList(target, document, propType, nodeVal, curPath, actualPath, options);
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
if (target.findIndex(x => x.startsWith(curPath + '.')) >= 0) {
|
|
39
|
-
target = target.filter(x => !x.startsWith(curPath + '.'));
|
|
40
|
-
}
|
|
41
|
-
target.push(curPath);
|
|
42
|
-
}
|
|
43
|
-
return target;
|
|
44
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.pathToTree = void 0;
|
|
4
|
-
const dotPattern = /^([^.]+)\.(.*)$/;
|
|
5
|
-
function pathToTree(arr) {
|
|
6
|
-
if (!arr.length)
|
|
7
|
-
return;
|
|
8
|
-
return _stringPathToObjectTree(arr, {});
|
|
9
|
-
}
|
|
10
|
-
exports.pathToTree = pathToTree;
|
|
11
|
-
function _stringPathToObjectTree(arr, target) {
|
|
12
|
-
for (const k of arr) {
|
|
13
|
-
const m = dotPattern.exec(k);
|
|
14
|
-
if (m) {
|
|
15
|
-
const key = m[1];
|
|
16
|
-
if (target[key] === true)
|
|
17
|
-
continue;
|
|
18
|
-
const sub = target[key] = typeof target[key] === 'object' ? target[key] : {};
|
|
19
|
-
_stringPathToObjectTree([m[2]], sub);
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
target[k] = true;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return target;
|
|
26
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BooleanFormat = void 0;
|
|
4
|
-
const format_js_1 = require("./format.js");
|
|
5
|
-
const trueValues = ['true', 't', 'yes', 'y', '1'];
|
|
6
|
-
const falseValues = ['false', 'f', 'no', 'n', '0'];
|
|
7
|
-
class BooleanFormat extends format_js_1.Format {
|
|
8
|
-
parse(value) {
|
|
9
|
-
if (value === '')
|
|
10
|
-
return true;
|
|
11
|
-
// noinspection SuspiciousTypeOfGuard
|
|
12
|
-
if (typeof value === 'boolean')
|
|
13
|
-
return value;
|
|
14
|
-
if (trueValues.includes(value.toLowerCase()))
|
|
15
|
-
return true;
|
|
16
|
-
if (falseValues.includes(value.toLowerCase()))
|
|
17
|
-
return false;
|
|
18
|
-
throw new TypeError(`"${value}" is not a valid boolean`);
|
|
19
|
-
}
|
|
20
|
-
stringify(value) {
|
|
21
|
-
return typeof value === 'boolean' ?
|
|
22
|
-
(value ? 'true' : 'false') : '';
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
exports.BooleanFormat = BooleanFormat;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DateFormat = void 0;
|
|
4
|
-
/* eslint-disable max-len */
|
|
5
|
-
const format_js_1 = require("./format.js");
|
|
6
|
-
// noinspection RegExpUnnecessaryNonCapturingGroup
|
|
7
|
-
const DATE_FORMAT_PATTERN = /^(\d{4})(?:-?(0[1-9]|1[012])(?:-?([123]0|[012][1-9]|31))?)?(?:[T ]?([01][0-9]|2[0-3]):?([0-5][0-9]):?([0-5][0-9])?(?:\.(\d+))?(?:(Z)|(?:([+-])([01]?[0-9]|2[0-3]):?([0-5][0-9])?))?)?$/;
|
|
8
|
-
class DateFormat extends format_js_1.Format {
|
|
9
|
-
constructor(options) {
|
|
10
|
-
super();
|
|
11
|
-
this.max = options?.max ? coerceToDateString(options.max) : undefined;
|
|
12
|
-
this.min = options?.min ? coerceToDateString(options.min) : undefined;
|
|
13
|
-
this.time = options?.time ?? true;
|
|
14
|
-
this.timeZone = options?.timeZone ?? true;
|
|
15
|
-
}
|
|
16
|
-
parse(value) {
|
|
17
|
-
const v = coerceToDateString(value, this.time, this.timeZone);
|
|
18
|
-
if (this.min != null && v < this.min)
|
|
19
|
-
throw new TypeError(`Value must be ${this.min} or greater.`);
|
|
20
|
-
if (this.max != null && v > this.max)
|
|
21
|
-
throw new TypeError(`Value must be ${this.max} or less.`);
|
|
22
|
-
return v;
|
|
23
|
-
}
|
|
24
|
-
stringify(value) {
|
|
25
|
-
return coerceToDateString(value, this.time, this.timeZone);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
exports.DateFormat = DateFormat;
|
|
29
|
-
function coerceToDateString(value, time, timeZone) {
|
|
30
|
-
if (value === '' || value == null)
|
|
31
|
-
return '';
|
|
32
|
-
const m = value.match(DATE_FORMAT_PATTERN);
|
|
33
|
-
if (!m)
|
|
34
|
-
throw new TypeError(`"${value}" is not a valid date.`);
|
|
35
|
-
let v = m[1] + '-' + (m[2] || '01') + '-' + (m[3] || '01');
|
|
36
|
-
if (time) {
|
|
37
|
-
v += 'T' + (m[4] || '00') + ':' + (m[5] || '00') + ':' + (m[6] || '00') +
|
|
38
|
-
(m[7] ? '.' + m[7] : '');
|
|
39
|
-
if (timeZone)
|
|
40
|
-
v += m[8] ? 'Z' :
|
|
41
|
-
(m[9] ? (m[9] + (m[10] || '00') + ':' + (m[11] || '00')) : '');
|
|
42
|
-
}
|
|
43
|
-
return v;
|
|
44
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FilterFormat = void 0;
|
|
4
|
-
const index_js_1 = require("../../filter/ast/index.js");
|
|
5
|
-
const parse_js_1 = require("../../filter/parse.js");
|
|
6
|
-
const format_js_1 = require("./format.js");
|
|
7
|
-
class FilterFormat extends format_js_1.Format {
|
|
8
|
-
parse(value) {
|
|
9
|
-
if (value instanceof index_js_1.Expression)
|
|
10
|
-
return value;
|
|
11
|
-
return (0, parse_js_1.parseFilter)(value);
|
|
12
|
-
}
|
|
13
|
-
stringify(value) {
|
|
14
|
-
// @ts-ignore
|
|
15
|
-
return value ? '' + value : '';
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
exports.FilterFormat = FilterFormat;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IntegerFormat = void 0;
|
|
4
|
-
const number_format_js_1 = require("./number-format.js");
|
|
5
|
-
class IntegerFormat extends number_format_js_1.NumberFormat {
|
|
6
|
-
constructor(options) {
|
|
7
|
-
super(options);
|
|
8
|
-
this.enum = options?.enum;
|
|
9
|
-
}
|
|
10
|
-
parse(value) {
|
|
11
|
-
const v = super.parse(value);
|
|
12
|
-
if (!Number.isInteger(v))
|
|
13
|
-
throw new TypeError(`"${value}" is not a valid integer`);
|
|
14
|
-
if (this.enum && !this.enum.includes(v))
|
|
15
|
-
throw new TypeError(`"${value}" is not one of allowed enum values (${this.enum}).`);
|
|
16
|
-
return v;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
exports.IntegerFormat = IntegerFormat;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NumberFormat = void 0;
|
|
4
|
-
const format_js_1 = require("./format.js");
|
|
5
|
-
class NumberFormat extends format_js_1.Format {
|
|
6
|
-
constructor(options) {
|
|
7
|
-
super();
|
|
8
|
-
this.max = options?.max;
|
|
9
|
-
this.min = options?.min;
|
|
10
|
-
}
|
|
11
|
-
parse(value) {
|
|
12
|
-
// noinspection SuspiciousTypeOfGuard
|
|
13
|
-
const v = typeof value === 'number' ? value : parseFloat(value);
|
|
14
|
-
if (isNaN(v))
|
|
15
|
-
throw new TypeError(`"${value}" is not a valid number`);
|
|
16
|
-
if (this.min != null && v < this.min)
|
|
17
|
-
throw new TypeError(`Value must be ${this.min} or greater.`);
|
|
18
|
-
if (this.max != null && v > this.max)
|
|
19
|
-
throw new TypeError(`Value must be ${this.max} or less.`);
|
|
20
|
-
return v;
|
|
21
|
-
}
|
|
22
|
-
stringify(value) {
|
|
23
|
-
return typeof value === 'number' ? '' + value : '';
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
exports.NumberFormat = NumberFormat;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StringFormat = void 0;
|
|
4
|
-
const format_js_1 = require("./format.js");
|
|
5
|
-
class StringFormat extends format_js_1.Format {
|
|
6
|
-
constructor(options) {
|
|
7
|
-
super();
|
|
8
|
-
this.maxLength = options?.maxLength;
|
|
9
|
-
this.minLength = options?.minLength;
|
|
10
|
-
this.enum = options?.enum;
|
|
11
|
-
}
|
|
12
|
-
parse(value) {
|
|
13
|
-
if (this.minLength != null && value.length < this.minLength)
|
|
14
|
-
throw new TypeError(`Value must be at least ${this.minLength} character${this.minLength > 1 ? 's' : ''} long.`);
|
|
15
|
-
if (this.maxLength != null && value.length > this.maxLength)
|
|
16
|
-
throw new TypeError(`Value can be up to ${this.maxLength} character${this.maxLength > 1 ? 's' : ''} long.`);
|
|
17
|
-
if (this.enum && !this.enum.includes(value))
|
|
18
|
-
throw new TypeError(`"${value}" is not one of allowed enum values (${this.enum}).`);
|
|
19
|
-
return value;
|
|
20
|
-
}
|
|
21
|
-
stringify(value) {
|
|
22
|
-
return value == null ? '' : '' + value;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
exports.StringFormat = StringFormat;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OpraURLSearchParams = void 0;
|
|
4
|
-
const http_params_js_1 = require("../http/http-params.js");
|
|
5
|
-
const integer_codec_js_1 = require("../http/param-codec/integer-codec.js");
|
|
6
|
-
class OpraURLSearchParams extends http_params_js_1.HttpParams {
|
|
7
|
-
constructor(init, options) {
|
|
8
|
-
super(init, {
|
|
9
|
-
...options,
|
|
10
|
-
params: {
|
|
11
|
-
'$filter': { codec: 'filter' },
|
|
12
|
-
'$limit': { codec: new integer_codec_js_1.IntegerCodec({ min: 0 }) },
|
|
13
|
-
'$skip': { codec: new integer_codec_js_1.IntegerCodec({ min: 0 }) },
|
|
14
|
-
'$pick': { codec: 'string', array: 'strict' },
|
|
15
|
-
'$omit': { codec: 'string', array: 'strict' },
|
|
16
|
-
'$include': { codec: 'string', array: 'strict' },
|
|
17
|
-
'$sort': { codec: 'string', array: 'strict' },
|
|
18
|
-
'$distinct': { codec: 'boolean' },
|
|
19
|
-
'$count': { codec: 'boolean' },
|
|
20
|
-
...options?.params
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
get [Symbol.toStringTag]() {
|
|
25
|
-
return 'URLSearchParams';
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
exports.OpraURLSearchParams = OpraURLSearchParams;
|
package/cjs/utils/index.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./path-to-tree.js"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./type-guards.js"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./is-url.js"), exports);
|
package/esm/constants.d.ts
DELETED
|
File without changes
|
package/esm/constants.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
import { Readable } from 'stream';
|
|
4
|
-
declare const kHeaders: unique symbol;
|
|
5
|
-
declare const kHeadersCount: unique symbol;
|
|
6
|
-
declare const kTrailers: unique symbol;
|
|
7
|
-
declare const kTrailersCount: unique symbol;
|
|
8
|
-
export declare class HttpRequestNode extends Readable {
|
|
9
|
-
httpVersionMajor: number;
|
|
10
|
-
httpVersionMinor: number;
|
|
11
|
-
httpVersion: string;
|
|
12
|
-
complete: boolean;
|
|
13
|
-
rawHeaders: string[];
|
|
14
|
-
rawTrailers: string[];
|
|
15
|
-
aborted: boolean;
|
|
16
|
-
upgrade: boolean;
|
|
17
|
-
url: string;
|
|
18
|
-
originalUrl: string;
|
|
19
|
-
method: string;
|
|
20
|
-
shouldKeepAlive: boolean;
|
|
21
|
-
data?: Buffer;
|
|
22
|
-
body?: any;
|
|
23
|
-
[kHeaders]: Record<string, string | string[]>;
|
|
24
|
-
[kHeadersCount]: number;
|
|
25
|
-
[kTrailers]: Record<string, string | string[]>;
|
|
26
|
-
[kTrailersCount]: number;
|
|
27
|
-
get headers(): Record<string, string | string[]>;
|
|
28
|
-
get headersCount(): number;
|
|
29
|
-
get trailers(): Record<string, string | string[]>;
|
|
30
|
-
get trailersCount(): number;
|
|
31
|
-
_read(): void;
|
|
32
|
-
static parse(input: Buffer): HttpRequestNode;
|
|
33
|
-
}
|
|
34
|
-
export {};
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { HTTPParser } from 'http-parser-js';
|
|
2
|
-
import { Readable } from 'stream';
|
|
3
|
-
const crlfBuffer = Buffer.from('\r\n');
|
|
4
|
-
const kHeaders = Symbol('kHeaders');
|
|
5
|
-
const kHeadersCount = Symbol('kHeadersCount');
|
|
6
|
-
const kTrailers = Symbol('kTrailers');
|
|
7
|
-
const kTrailersCount = Symbol('kTrailersCount');
|
|
8
|
-
// todo: Check is this class should be in common library
|
|
9
|
-
export class HttpRequestNode extends Readable {
|
|
10
|
-
constructor() {
|
|
11
|
-
super(...arguments);
|
|
12
|
-
this.aborted = false;
|
|
13
|
-
}
|
|
14
|
-
get headers() {
|
|
15
|
-
if (!this[kHeaders])
|
|
16
|
-
this[kHeaders] = arrayToHeaders(this.rawHeaders);
|
|
17
|
-
return this[kHeaders];
|
|
18
|
-
}
|
|
19
|
-
get headersCount() {
|
|
20
|
-
return this[kHeadersCount];
|
|
21
|
-
}
|
|
22
|
-
get trailers() {
|
|
23
|
-
if (!this[kTrailers])
|
|
24
|
-
this[kTrailers] = arrayToHeaders(this.rawTrailers);
|
|
25
|
-
return this[kTrailers];
|
|
26
|
-
}
|
|
27
|
-
get trailersCount() {
|
|
28
|
-
return this[kTrailersCount];
|
|
29
|
-
}
|
|
30
|
-
_read() {
|
|
31
|
-
if (this.data) {
|
|
32
|
-
this.push(this.data);
|
|
33
|
-
}
|
|
34
|
-
this.push(null);
|
|
35
|
-
}
|
|
36
|
-
static parse(input) {
|
|
37
|
-
const parser = new HTTPParser(HTTPParser.REQUEST);
|
|
38
|
-
const out = new HttpRequestNode();
|
|
39
|
-
const bodyChunks = [];
|
|
40
|
-
parser[HTTPParser.kOnHeadersComplete] = function (req) {
|
|
41
|
-
out.shouldKeepAlive = req.shouldKeepAlive;
|
|
42
|
-
out.upgrade = req.upgrade;
|
|
43
|
-
out.method = HTTPParser.methods[req.method];
|
|
44
|
-
out.url = req.url;
|
|
45
|
-
out.originalUrl = req.url;
|
|
46
|
-
out.httpVersionMajor = req.versionMajor;
|
|
47
|
-
out.httpVersionMinor = req.versionMinor;
|
|
48
|
-
out.httpVersion = req.versionMajor + '.' + req.versionMinor;
|
|
49
|
-
out.rawHeaders = req.headers;
|
|
50
|
-
out[kHeadersCount] = Math.ceil(req.headers.length / 2);
|
|
51
|
-
out[kTrailersCount] = 0;
|
|
52
|
-
};
|
|
53
|
-
parser[HTTPParser.kOnBody] = function (chunk, offset, length) {
|
|
54
|
-
bodyChunks.push(chunk.subarray(offset, offset + length));
|
|
55
|
-
};
|
|
56
|
-
// This is actually the event for trailers, go figure.
|
|
57
|
-
parser[HTTPParser.kOnHeaders] = function (t) {
|
|
58
|
-
out.rawTrailers = t;
|
|
59
|
-
out[kTrailersCount] = Math.ceil(t.length / 2);
|
|
60
|
-
};
|
|
61
|
-
parser[HTTPParser.kOnMessageComplete] = function () {
|
|
62
|
-
out.complete = true;
|
|
63
|
-
};
|
|
64
|
-
// Since we are sending the entire Buffer at once here all callbacks above happen synchronously.
|
|
65
|
-
// The parser does not do _anything_ asynchronous.
|
|
66
|
-
// However, you can of course call execute() multiple times with multiple chunks, e.g. from a stream.
|
|
67
|
-
// But then you have to refactor the entire logic to be async (e.g. resolve a Promise in kOnMessageComplete and add timeout logic).
|
|
68
|
-
parser.execute(input);
|
|
69
|
-
if (!out.complete)
|
|
70
|
-
parser.execute(crlfBuffer);
|
|
71
|
-
parser.finish();
|
|
72
|
-
if (!out.complete) {
|
|
73
|
-
throw new Error('Could not parse request');
|
|
74
|
-
}
|
|
75
|
-
out.rawTrailers = out.rawTrailers || [];
|
|
76
|
-
if (bodyChunks.length)
|
|
77
|
-
out.data = Buffer.concat(bodyChunks);
|
|
78
|
-
out.resume();
|
|
79
|
-
return out;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
function arrayToHeaders(arr) {
|
|
83
|
-
const headers = {};
|
|
84
|
-
for (let i = 0; i < arr.length; i++) {
|
|
85
|
-
const k = arr[i].toLowerCase();
|
|
86
|
-
const v = arr[++i];
|
|
87
|
-
const trgV = headers[k];
|
|
88
|
-
// Array header -- only Set-Cookie at the moment
|
|
89
|
-
if (trgV && k === 'set-cookie') {
|
|
90
|
-
const a = Array.isArray(trgV) ? trgV : [trgV];
|
|
91
|
-
a.push(v);
|
|
92
|
-
headers[k] = a;
|
|
93
|
-
}
|
|
94
|
-
else if (typeof trgV === 'string') {
|
|
95
|
-
headers[k] += (k === 'cookie' ? '; ' : ', ') + v;
|
|
96
|
-
}
|
|
97
|
-
else
|
|
98
|
-
headers[k] = v;
|
|
99
|
-
}
|
|
100
|
-
return headers;
|
|
101
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
/// <reference lib="dom" />
|
|
2
|
-
import { OpraURL, OpraURLPath, OpraURLSearchParams } from '../url/index.js';
|
|
3
|
-
import { HttpHeaders, HttpHeadersInit } from './http-headers.js';
|
|
4
|
-
import { HttpParamsInit } from './http-params.js';
|
|
5
|
-
export interface HttpRequestInit {
|
|
6
|
-
cache?: RequestCache;
|
|
7
|
-
credentials?: RequestCredentials;
|
|
8
|
-
destination?: RequestDestination;
|
|
9
|
-
headers?: HttpHeadersInit;
|
|
10
|
-
integrity?: string;
|
|
11
|
-
keepalive?: boolean;
|
|
12
|
-
method?: string;
|
|
13
|
-
mode?: RequestMode;
|
|
14
|
-
params?: HttpParamsInit;
|
|
15
|
-
redirect?: RequestRedirect;
|
|
16
|
-
referrer?: string;
|
|
17
|
-
referrerPolicy?: ReferrerPolicy;
|
|
18
|
-
signal?: AbortSignal;
|
|
19
|
-
url?: string;
|
|
20
|
-
body?: any;
|
|
21
|
-
}
|
|
22
|
-
export declare class HttpRequest {
|
|
23
|
-
/** Returns the cache mode associated with request, which is a string indicating
|
|
24
|
-
* how the request will interact with the browser's cache when fetching. */
|
|
25
|
-
cache: RequestCache;
|
|
26
|
-
/** Returns the credentials mode associated with request, which is a string indicating
|
|
27
|
-
* whether credentials will be sent with the request always, never,
|
|
28
|
-
* or only when sent to a same-origin URL. */
|
|
29
|
-
credentials: RequestCredentials;
|
|
30
|
-
/** Returns the kind of resource requested by request, e.g., "document" or "script". */
|
|
31
|
-
destination: RequestDestination;
|
|
32
|
-
/** Returns a Headers object consisting of the headers associated with request.
|
|
33
|
-
* Note that headers added in the network layer by the user agent will not be accounted for in this object,
|
|
34
|
-
* e.g., the "Host" header. */
|
|
35
|
-
headers: HttpHeaders;
|
|
36
|
-
/** Returns request's subresource integrity metadata, which is a cryptographic
|
|
37
|
-
* hash of the resource being fetched.
|
|
38
|
-
* Its value consists of multiple hashes separated by whitespace. [SRI] */
|
|
39
|
-
integrity: string;
|
|
40
|
-
/** Returns a boolean indicating whether or not request can outlive the global in which it was created. */
|
|
41
|
-
keepalive: boolean;
|
|
42
|
-
/** Returns request's HTTP method, which is "GET" by default. */
|
|
43
|
-
method: string;
|
|
44
|
-
/** Returns the mode associated with request, which is a string indicating whether the request will use CORS,
|
|
45
|
-
* or will be restricted to same-origin URLs. */
|
|
46
|
-
mode: RequestMode;
|
|
47
|
-
/** Returns the redirect mode associated with request, which is a string indicating
|
|
48
|
-
* how redirects for the request will be handled during fetching. A request will follow redirects by default. */
|
|
49
|
-
redirect: RequestRedirect;
|
|
50
|
-
/** Returns the referrer of request. Its value can be a same-origin URL if explicitly set in init,
|
|
51
|
-
* the empty string to indicate no referrer, and "about:client" when defaulting to the global's default.
|
|
52
|
-
* This is used during fetching to determine the value of the `Referer` header of the request being made. */
|
|
53
|
-
referrer: string;
|
|
54
|
-
/** Returns the referrer policy associated with request. This is used during fetching
|
|
55
|
-
* to compute the value of the request's referrer. */
|
|
56
|
-
referrerPolicy: ReferrerPolicy;
|
|
57
|
-
/** Returns the signal associated with request, which is an AbortSignal object indicating
|
|
58
|
-
* whether or not request has been aborted, and its abort event handler. */
|
|
59
|
-
signal?: AbortSignal;
|
|
60
|
-
/** Returns the parsed url as OpraURL instance */
|
|
61
|
-
readonly urlInstance: OpraURL;
|
|
62
|
-
/** Body of the http request */
|
|
63
|
-
body?: any;
|
|
64
|
-
duplex?: 'half';
|
|
65
|
-
constructor(init?: HttpRequestInit);
|
|
66
|
-
/** Returns the URL of request as a string. */
|
|
67
|
-
get url(): string;
|
|
68
|
-
set url(value: string);
|
|
69
|
-
/** Returns the searchParams of the URL as OpraURLSearchParams */
|
|
70
|
-
get params(): OpraURLSearchParams;
|
|
71
|
-
/** Returns the path part of URL as OpraURLPath */
|
|
72
|
-
get path(): OpraURLPath;
|
|
73
|
-
clone(...update: (HttpRequest | HttpRequestInit)[]): HttpRequest;
|
|
74
|
-
merge(update: HttpRequest | HttpRequestInit): void;
|
|
75
|
-
inset(src: HttpRequest | HttpRequestInit): void;
|
|
76
|
-
}
|
package/esm/http/http-request.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/// <reference lib="dom" />
|
|
2
|
-
import { OpraURL } from '../url/index.js';
|
|
3
|
-
import { HttpHeaders } from './http-headers.js';
|
|
4
|
-
const directCopyProperties = ['cache', 'credentials', 'destination', 'headers', 'integrity',
|
|
5
|
-
'keepalive', 'mode', 'redirect', 'referrer', 'referrerPolicy'];
|
|
6
|
-
export class HttpRequest {
|
|
7
|
-
constructor(init) {
|
|
8
|
-
this.cache = init?.cache || 'default';
|
|
9
|
-
this.credentials = init?.credentials || 'same-origin';
|
|
10
|
-
this.destination = init?.destination || '';
|
|
11
|
-
this.headers = new HttpHeaders(init?.headers);
|
|
12
|
-
this.integrity = init?.integrity || '';
|
|
13
|
-
this.keepalive = init?.keepalive ?? false;
|
|
14
|
-
this.method = (init?.method || 'GET').toUpperCase();
|
|
15
|
-
this.mode = init?.mode || 'cors';
|
|
16
|
-
this.redirect = init?.redirect || 'follow';
|
|
17
|
-
this.mode = init?.mode || 'cors';
|
|
18
|
-
this.referrer = init?.referrer || '';
|
|
19
|
-
this.referrerPolicy = init?.referrerPolicy || '';
|
|
20
|
-
this.signal = init?.signal || new AbortController().signal;
|
|
21
|
-
this.body = init?.body;
|
|
22
|
-
this.urlInstance = new OpraURL(init?.url);
|
|
23
|
-
if (init?.params)
|
|
24
|
-
this.params.appendAll(init.params);
|
|
25
|
-
}
|
|
26
|
-
/** Returns the URL of request as a string. */
|
|
27
|
-
get url() {
|
|
28
|
-
return this.urlInstance.href;
|
|
29
|
-
}
|
|
30
|
-
set url(value) {
|
|
31
|
-
this.urlInstance.parse(value);
|
|
32
|
-
}
|
|
33
|
-
/** Returns the searchParams of the URL as OpraURLSearchParams */
|
|
34
|
-
get params() {
|
|
35
|
-
return this.urlInstance.searchParams;
|
|
36
|
-
}
|
|
37
|
-
/** Returns the path part of URL as OpraURLPath */
|
|
38
|
-
get path() {
|
|
39
|
-
return this.urlInstance.path;
|
|
40
|
-
}
|
|
41
|
-
clone(...update) {
|
|
42
|
-
const out = new HttpRequest();
|
|
43
|
-
out.merge(this);
|
|
44
|
-
for (const upd of update) {
|
|
45
|
-
out.merge(upd);
|
|
46
|
-
}
|
|
47
|
-
return out;
|
|
48
|
-
}
|
|
49
|
-
merge(update) {
|
|
50
|
-
directCopyProperties.forEach(k => {
|
|
51
|
-
if (update[k] != null)
|
|
52
|
-
this[k] = update[k];
|
|
53
|
-
});
|
|
54
|
-
if (update.headers) {
|
|
55
|
-
const h = update.headers instanceof HttpHeaders
|
|
56
|
-
? update.headers
|
|
57
|
-
: new HttpHeaders(update.headers);
|
|
58
|
-
h.forEach((v, k) => {
|
|
59
|
-
if (k.toLowerCase() === 'set-cookie') {
|
|
60
|
-
this.headers.append(k, v);
|
|
61
|
-
}
|
|
62
|
-
else
|
|
63
|
-
this.headers.set(k, v);
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
inset(src) {
|
|
68
|
-
directCopyProperties.forEach(k => {
|
|
69
|
-
if (this[k] == null && src[k] != null)
|
|
70
|
-
this[k] = src[k];
|
|
71
|
-
});
|
|
72
|
-
if (src.headers) {
|
|
73
|
-
const h = src.headers instanceof HttpHeaders
|
|
74
|
-
? src.headers
|
|
75
|
-
: new HttpHeaders(src.headers);
|
|
76
|
-
h.forEach((v, k) => {
|
|
77
|
-
if (k.toLowerCase() === 'set-cookie') {
|
|
78
|
-
this.headers.append(k, v);
|
|
79
|
-
}
|
|
80
|
-
else if (!this.headers.has(k))
|
|
81
|
-
this.headers.set(k, v);
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|