@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
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiDocument = void 0;
|
|
4
|
+
const index_js_1 = require("../exception/index.js");
|
|
5
|
+
const index_js_2 = require("../helpers/index.js");
|
|
6
|
+
const index_js_3 = require("../schema/index.js");
|
|
7
|
+
const constants_js_1 = require("./constants.js");
|
|
8
|
+
const complex_type_js_1 = require("./data-type/complex-type.js");
|
|
9
|
+
const simple_type_js_1 = require("./data-type/simple-type.js");
|
|
10
|
+
class ApiDocument {
|
|
11
|
+
constructor() {
|
|
12
|
+
this._typeCache = new index_js_2.ResponsiveMap();
|
|
13
|
+
this._typesCacheByCtor = new Map();
|
|
14
|
+
this.references = new index_js_2.ResponsiveMap();
|
|
15
|
+
this.types = new index_js_2.ResponsiveMap();
|
|
16
|
+
this.resources = new index_js_2.ResponsiveMap();
|
|
17
|
+
this.info = {
|
|
18
|
+
version: '',
|
|
19
|
+
title: ''
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
getDataType(nameOrCtor, silent) {
|
|
23
|
+
let dataType;
|
|
24
|
+
if (nameOrCtor === Object)
|
|
25
|
+
nameOrCtor = 'any';
|
|
26
|
+
const nameOrCtorName = typeof nameOrCtor === 'function' ? nameOrCtor.name : nameOrCtor;
|
|
27
|
+
// Try to get instance from cache
|
|
28
|
+
const t = typeof nameOrCtor === 'string'
|
|
29
|
+
? this._typeCache.get(nameOrCtor)
|
|
30
|
+
: this._typesCacheByCtor.get(nameOrCtor);
|
|
31
|
+
if (t)
|
|
32
|
+
return t;
|
|
33
|
+
if (t === null) {
|
|
34
|
+
if (silent)
|
|
35
|
+
return;
|
|
36
|
+
throw new index_js_1.NotFoundError(`Data type "${nameOrCtorName}" does not exists`);
|
|
37
|
+
}
|
|
38
|
+
if (typeof nameOrCtor === 'string') {
|
|
39
|
+
const m = constants_js_1.NAMESPACE_PATTERN.exec(nameOrCtor);
|
|
40
|
+
if (!m)
|
|
41
|
+
throw new index_js_1.NotFoundError(`Invalid data type name "${nameOrCtorName}"`);
|
|
42
|
+
// If given string has namespace pattern (ns:type_name)
|
|
43
|
+
if (m[2]) {
|
|
44
|
+
const ref = this.references.get(m[1]);
|
|
45
|
+
if (!ref) {
|
|
46
|
+
if (silent)
|
|
47
|
+
return;
|
|
48
|
+
throw new index_js_1.NotFoundError(`Reference "${m[1]}" not found`);
|
|
49
|
+
}
|
|
50
|
+
dataType = ref.getDataType(m[2]);
|
|
51
|
+
this._typeCache.set(nameOrCtor, dataType);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
const name = m[1];
|
|
55
|
+
// Get instance from own types
|
|
56
|
+
dataType = this.types.get(name);
|
|
57
|
+
// if not found, search in references (from last to first)
|
|
58
|
+
if (!dataType) {
|
|
59
|
+
const references = Array.from(this.references.values()).reverse();
|
|
60
|
+
for (const ref of references) {
|
|
61
|
+
dataType = ref.getDataType(name);
|
|
62
|
+
if (dataType)
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (dataType)
|
|
67
|
+
this._typeCache.set(dataType.name || name, dataType);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
else if (typeof nameOrCtor === 'function') {
|
|
71
|
+
const types = Array.from(this.types.values()).reverse();
|
|
72
|
+
for (const dt of types) {
|
|
73
|
+
if ((dt instanceof complex_type_js_1.ComplexType || dt instanceof simple_type_js_1.SimpleType) && dt.own.ctor === nameOrCtor) {
|
|
74
|
+
dataType = dt;
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// if not found, search in references (from last to first)
|
|
79
|
+
if (!dataType) {
|
|
80
|
+
const references = Array.from(this.references.values()).reverse();
|
|
81
|
+
for (const ref of references) {
|
|
82
|
+
dataType = ref.getDataType(nameOrCtor, true);
|
|
83
|
+
if (dataType)
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (dataType) {
|
|
89
|
+
if ((dataType instanceof complex_type_js_1.ComplexType || dataType instanceof simple_type_js_1.SimpleType) &&
|
|
90
|
+
dataType.own?.ctor && dataType.own.ctor !== Object)
|
|
91
|
+
this._typesCacheByCtor.set(dataType.own.ctor, dataType);
|
|
92
|
+
return dataType;
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
if (typeof nameOrCtor === 'string')
|
|
96
|
+
this._typeCache.set(nameOrCtor, null);
|
|
97
|
+
else
|
|
98
|
+
this._typesCacheByCtor.set(nameOrCtor, null);
|
|
99
|
+
}
|
|
100
|
+
if (silent)
|
|
101
|
+
return;
|
|
102
|
+
throw new index_js_1.NotFoundError(`Data type "${nameOrCtorName}" does not exists`);
|
|
103
|
+
}
|
|
104
|
+
getComplexType(nameOrCtor, silent) {
|
|
105
|
+
if (nameOrCtor === Object)
|
|
106
|
+
nameOrCtor = 'object';
|
|
107
|
+
const t = this.getDataType(nameOrCtor);
|
|
108
|
+
if (!t && silent)
|
|
109
|
+
return;
|
|
110
|
+
if (t && t.kind === index_js_3.OpraSchema.ComplexType.Kind)
|
|
111
|
+
return t;
|
|
112
|
+
throw new index_js_1.NotAcceptableError(`Data type "${t.name}" is not a ComplexType`);
|
|
113
|
+
}
|
|
114
|
+
getSimpleType(nameOrCtor, silent) {
|
|
115
|
+
const t = this.getDataType(nameOrCtor);
|
|
116
|
+
if (!t && silent)
|
|
117
|
+
return;
|
|
118
|
+
if (t && t.kind === index_js_3.OpraSchema.SimpleType.Kind)
|
|
119
|
+
return t;
|
|
120
|
+
throw new index_js_1.NotAcceptableError(`Data type "${t.name || t}" is not a SimpleType`);
|
|
121
|
+
}
|
|
122
|
+
getResource(path, silent) {
|
|
123
|
+
let resource;
|
|
124
|
+
const m = constants_js_1.NAMESPACE_PATTERN.exec(path);
|
|
125
|
+
if (!m)
|
|
126
|
+
throw new index_js_1.NotFoundError(`Invalid resource path "${path}"`);
|
|
127
|
+
// If given string has namespace pattern (ns:type_name)
|
|
128
|
+
if (m[2]) {
|
|
129
|
+
const ref = this.references.get(m[1]);
|
|
130
|
+
if (!ref) {
|
|
131
|
+
if (silent)
|
|
132
|
+
return;
|
|
133
|
+
throw new index_js_1.NotFoundError(`Reference "${m[1]}" not found`);
|
|
134
|
+
}
|
|
135
|
+
return ref.getResource(m[2]);
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
const name = m[1];
|
|
139
|
+
// Get instance from own types
|
|
140
|
+
resource = this.resources.get(name);
|
|
141
|
+
if (resource)
|
|
142
|
+
return resource;
|
|
143
|
+
// if not found, search in references (from last to first)
|
|
144
|
+
const references = Array.from(this.references.values()).reverse();
|
|
145
|
+
for (const ref of references) {
|
|
146
|
+
resource = silent ? ref.getResource(name, silent) : ref.getResource(name);
|
|
147
|
+
if (resource)
|
|
148
|
+
return resource;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
if (silent)
|
|
152
|
+
return;
|
|
153
|
+
throw new index_js_1.NotFoundError(`Resource not found (${path})`);
|
|
154
|
+
}
|
|
155
|
+
getCollection(path, silent) {
|
|
156
|
+
const t = this.getResource(path);
|
|
157
|
+
if (!t && silent)
|
|
158
|
+
return;
|
|
159
|
+
if (t && t.kind === index_js_3.OpraSchema.Collection.Kind)
|
|
160
|
+
return t;
|
|
161
|
+
throw new index_js_1.NotAcceptableError(`Resource type "${t.name}" is not a Collection`);
|
|
162
|
+
}
|
|
163
|
+
getSingleton(path, silent) {
|
|
164
|
+
const t = this.getResource(path);
|
|
165
|
+
if (!t && silent)
|
|
166
|
+
return;
|
|
167
|
+
if (t && t.kind === index_js_3.OpraSchema.Singleton.Kind)
|
|
168
|
+
return t;
|
|
169
|
+
throw new index_js_1.NotAcceptableError(`Resource type "${t.name}" is not a Singleton`);
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Export as Opra schema definition object
|
|
173
|
+
*/
|
|
174
|
+
exportSchema() {
|
|
175
|
+
const schema = {
|
|
176
|
+
version: index_js_3.OpraSchema.SpecVersion,
|
|
177
|
+
url: this.url,
|
|
178
|
+
info: (0, index_js_2.cloneObject)(this.info)
|
|
179
|
+
};
|
|
180
|
+
if (this.references.size) {
|
|
181
|
+
const references = {};
|
|
182
|
+
let i = 0;
|
|
183
|
+
for (const [ns, r] of this.references.entries()) {
|
|
184
|
+
if (ns.toLowerCase() === 'opra')
|
|
185
|
+
continue;
|
|
186
|
+
references[ns] = r.url ? r.url : r.exportSchema();
|
|
187
|
+
i++;
|
|
188
|
+
}
|
|
189
|
+
if (i)
|
|
190
|
+
schema.references = references;
|
|
191
|
+
}
|
|
192
|
+
if (this.resources.size) {
|
|
193
|
+
const resources = schema.resources = {};
|
|
194
|
+
for (const [name, r] of this.resources.entries()) {
|
|
195
|
+
resources[name] = r.exportSchema();
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
if (this.types.size) {
|
|
199
|
+
const types = schema.types = {};
|
|
200
|
+
for (const [name, r] of this.types.entries()) {
|
|
201
|
+
types[name] = r.exportSchema();
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return (0, index_js_2.omitUndefined)(schema);
|
|
205
|
+
}
|
|
206
|
+
invalidate() {
|
|
207
|
+
this._typeCache.clear();
|
|
208
|
+
this._typesCacheByCtor.clear();
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
exports.ApiDocument = ApiDocument;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TYPENAME_PATTERN = exports.NAMESPACE_PATTERN = exports.METADATA_KEY = void 0;
|
|
4
|
+
exports.METADATA_KEY = Symbol.for('opra.metadata');
|
|
5
|
+
exports.NAMESPACE_PATTERN = /([A-Z$_]\w+)(?::.+)?/i;
|
|
6
|
+
exports.TYPENAME_PATTERN = /^(.*)Type$/;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiField = void 0;
|
|
4
|
+
const index_js_1 = require("../../helpers/index.js");
|
|
5
|
+
const index_js_2 = require("../../schema/index.js");
|
|
6
|
+
const constants_js_1 = require("../constants.js");
|
|
7
|
+
const enum_type_js_1 = require("./enum-type.js");
|
|
8
|
+
/**
|
|
9
|
+
* @class ComplexType
|
|
10
|
+
*/
|
|
11
|
+
exports.ApiField = function (...args) {
|
|
12
|
+
// ClassDecorator
|
|
13
|
+
if (!this) {
|
|
14
|
+
const [options] = args;
|
|
15
|
+
return function (target, propertyKey) {
|
|
16
|
+
if (typeof propertyKey !== 'string')
|
|
17
|
+
throw new TypeError(`Symbol properties can't be used as a field`);
|
|
18
|
+
const metadata = Reflect.getOwnMetadata(constants_js_1.METADATA_KEY, target.constructor) || {};
|
|
19
|
+
metadata.kind = index_js_2.OpraSchema.ComplexType.Kind;
|
|
20
|
+
metadata.fields = metadata.fields || {};
|
|
21
|
+
const designType = Reflect.getMetadata('design:type', target, propertyKey);
|
|
22
|
+
const isArray = designType === Array;
|
|
23
|
+
const elemMeta = metadata.fields[propertyKey] = {
|
|
24
|
+
...options,
|
|
25
|
+
enum: undefined,
|
|
26
|
+
designType: isArray ? undefined : designType
|
|
27
|
+
};
|
|
28
|
+
if (designType === Array)
|
|
29
|
+
elemMeta.isArray = true;
|
|
30
|
+
if (options?.enum) {
|
|
31
|
+
elemMeta.type = undefined;
|
|
32
|
+
if (Array.isArray(options.enum)) {
|
|
33
|
+
const enumObj = options.enum.reduce((o, v) => {
|
|
34
|
+
o[v] = v;
|
|
35
|
+
return o;
|
|
36
|
+
}, {});
|
|
37
|
+
(0, enum_type_js_1.EnumType)(enumObj);
|
|
38
|
+
elemMeta.enum = enumObj;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
const m = Reflect.getOwnMetadata(constants_js_1.METADATA_KEY, options?.enum);
|
|
42
|
+
if (!index_js_2.OpraSchema.isEnumType(m))
|
|
43
|
+
throw new TypeError(`Invalid "enum" value. Did you forget to set metadata using EnumType() method?`);
|
|
44
|
+
elemMeta.enum = options.enum;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
Reflect.defineMetadata(constants_js_1.METADATA_KEY, (0, index_js_1.omitUndefined)(metadata), target.constructor);
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
// Constructor
|
|
51
|
+
const [owner, init] = args;
|
|
52
|
+
const _this = this;
|
|
53
|
+
_this.owner = owner;
|
|
54
|
+
_this.name = init.name;
|
|
55
|
+
_this.origin = init.origin || owner;
|
|
56
|
+
_this.type = init.type;
|
|
57
|
+
if (init?.description)
|
|
58
|
+
this.description = init?.description;
|
|
59
|
+
if (init?.isArray != null)
|
|
60
|
+
this.isArray = init?.isArray;
|
|
61
|
+
this.default = init?.default;
|
|
62
|
+
this.fixed = init?.fixed;
|
|
63
|
+
if (init?.deprecated != null)
|
|
64
|
+
this.deprecated = init?.deprecated;
|
|
65
|
+
if (init?.exclusive != null)
|
|
66
|
+
this.exclusive = init?.exclusive;
|
|
67
|
+
if (init?.required != null)
|
|
68
|
+
this.required = init?.required;
|
|
69
|
+
};
|
|
70
|
+
const proto = {
|
|
71
|
+
exportSchema() {
|
|
72
|
+
const out = {
|
|
73
|
+
type: this.type.name ? this.type.name : this.type.exportSchema(),
|
|
74
|
+
description: this.description,
|
|
75
|
+
isArray: this.isArray,
|
|
76
|
+
default: this.default,
|
|
77
|
+
fixed: this.fixed
|
|
78
|
+
};
|
|
79
|
+
return out;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
Object.assign(exports.ApiField.prototype, proto);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AnyType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const simple_type_js_1 = require("../simple-type.js");
|
|
6
|
+
let AnyType = class AnyType {
|
|
7
|
+
};
|
|
8
|
+
AnyType = tslib_1.__decorate([
|
|
9
|
+
(0, simple_type_js_1.SimpleType)({
|
|
10
|
+
description: 'Any value',
|
|
11
|
+
ctor: Object
|
|
12
|
+
})
|
|
13
|
+
], AnyType);
|
|
14
|
+
exports.AnyType = AnyType;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Base64Type = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const simple_type_js_1 = require("../simple-type.js");
|
|
6
|
+
const BASE64_PATTERN = /^(?:[A-Za-z0-9+/]{4})*(?:(?:[A-Za-z0-9+/][AQgw](:?==)?)|(?:[A-Za-z0-9+/]{2}[AEIMQUYcgkosw048]=?))?$/;
|
|
7
|
+
let Base64Type = class Base64Type {
|
|
8
|
+
decode(v) {
|
|
9
|
+
if (v == null)
|
|
10
|
+
return v;
|
|
11
|
+
if (typeof v === 'string')
|
|
12
|
+
this.validate(v);
|
|
13
|
+
return Buffer.from(v, 'base64').buffer.slice(0);
|
|
14
|
+
}
|
|
15
|
+
encode(v) {
|
|
16
|
+
if (v == null)
|
|
17
|
+
return v;
|
|
18
|
+
if (Buffer.isBuffer(v))
|
|
19
|
+
return v.toString('base64');
|
|
20
|
+
return Buffer.from(v).toString('base64');
|
|
21
|
+
}
|
|
22
|
+
coerce(v) {
|
|
23
|
+
if (v instanceof ArrayBuffer)
|
|
24
|
+
return v;
|
|
25
|
+
return this.decode(v);
|
|
26
|
+
}
|
|
27
|
+
validate(v) {
|
|
28
|
+
if (!(typeof v === 'string' && BASE64_PATTERN.test(v)))
|
|
29
|
+
throw new TypeError(`Invalid base64 value "${String(v).substring(0, 10)}..."`);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
Base64Type = tslib_1.__decorate([
|
|
33
|
+
(0, simple_type_js_1.SimpleType)({
|
|
34
|
+
description: 'A stream of bytes, base64 encoded',
|
|
35
|
+
ctor: ArrayBuffer
|
|
36
|
+
})
|
|
37
|
+
], Base64Type);
|
|
38
|
+
exports.Base64Type = Base64Type;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BigIntType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const simple_type_js_1 = require("../simple-type.js");
|
|
6
|
+
const BigIntConstructor = Object.getPrototypeOf(BigInt(0)).constructor;
|
|
7
|
+
let BigIntType = class BigIntType {
|
|
8
|
+
decode(v) {
|
|
9
|
+
if (v == null)
|
|
10
|
+
return v;
|
|
11
|
+
return typeof v === 'bigint' ? v : BigInt(v);
|
|
12
|
+
}
|
|
13
|
+
encode(v) {
|
|
14
|
+
if (v == null)
|
|
15
|
+
return v;
|
|
16
|
+
return typeof v === 'bigint' ? String(v) : undefined;
|
|
17
|
+
}
|
|
18
|
+
coerce(v) {
|
|
19
|
+
return this.decode(v);
|
|
20
|
+
}
|
|
21
|
+
validate(v) {
|
|
22
|
+
if (!((typeof v === 'number' && !isNaN(v)) || typeof v === 'bigint'))
|
|
23
|
+
throw new TypeError(`Invalid number value "${v}"`);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
BigIntType = tslib_1.__decorate([
|
|
27
|
+
(0, simple_type_js_1.SimpleType)({
|
|
28
|
+
name: 'bigint',
|
|
29
|
+
description: 'BigInt number',
|
|
30
|
+
ctor: BigIntConstructor
|
|
31
|
+
})
|
|
32
|
+
], BigIntType);
|
|
33
|
+
exports.BigIntType = BigIntType;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BooleanType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const putil_varhelpers_1 = require("putil-varhelpers");
|
|
6
|
+
const simple_type_js_1 = require("../simple-type.js");
|
|
7
|
+
let BooleanType = class BooleanType {
|
|
8
|
+
decode(v) {
|
|
9
|
+
if (v == null)
|
|
10
|
+
return v;
|
|
11
|
+
return (0, putil_varhelpers_1.toBoolean)(v);
|
|
12
|
+
}
|
|
13
|
+
encode(v) {
|
|
14
|
+
if (v == null)
|
|
15
|
+
return v;
|
|
16
|
+
return (0, putil_varhelpers_1.toBoolean)(v);
|
|
17
|
+
}
|
|
18
|
+
coerce(v) {
|
|
19
|
+
return this.decode(v);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
BooleanType = tslib_1.__decorate([
|
|
23
|
+
(0, simple_type_js_1.SimpleType)({
|
|
24
|
+
description: 'Simple true/false value',
|
|
25
|
+
ctor: Boolean
|
|
26
|
+
})
|
|
27
|
+
], BooleanType);
|
|
28
|
+
exports.BooleanType = BooleanType;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DateType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const simple_type_js_1 = require("../simple-type.js");
|
|
6
|
+
const timestamp_type_js_1 = require("./timestamp.type.js");
|
|
7
|
+
let DateType = class DateType extends timestamp_type_js_1.TimestampType {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.format = 'YYYY-MM-DD';
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
DateType = tslib_1.__decorate([
|
|
14
|
+
(0, simple_type_js_1.SimpleType)({
|
|
15
|
+
description: 'full-date notation as defined by RFC 3339, section 5.6, for example, 2021-04-18',
|
|
16
|
+
})
|
|
17
|
+
], DateType);
|
|
18
|
+
exports.DateType = DateType;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GuidType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const putil_varhelpers_1 = require("putil-varhelpers");
|
|
6
|
+
const simple_type_js_1 = require("../simple-type.js");
|
|
7
|
+
const string_type_js_1 = require("./string.type.js");
|
|
8
|
+
const GUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
9
|
+
let GuidType = class GuidType extends string_type_js_1.StringType {
|
|
10
|
+
decode(v) {
|
|
11
|
+
if (v == null)
|
|
12
|
+
return v;
|
|
13
|
+
const s = (0, putil_varhelpers_1.toString)(v);
|
|
14
|
+
if (s)
|
|
15
|
+
this.validate(s);
|
|
16
|
+
return s;
|
|
17
|
+
}
|
|
18
|
+
encode(v) {
|
|
19
|
+
return this.decode(v);
|
|
20
|
+
}
|
|
21
|
+
coerce(v) {
|
|
22
|
+
return this.decode(v);
|
|
23
|
+
}
|
|
24
|
+
validate(v) {
|
|
25
|
+
// noinspection SuspiciousTypeOfGuard
|
|
26
|
+
if (typeof v === 'string' && !GUID_PATTERN.test(v))
|
|
27
|
+
throw new TypeError(`Invalid GUID value "${v}"`);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
GuidType = tslib_1.__decorate([
|
|
31
|
+
(0, simple_type_js_1.SimpleType)({
|
|
32
|
+
description: 'A Globally Unique Identifier (GUID) value',
|
|
33
|
+
})
|
|
34
|
+
], GuidType);
|
|
35
|
+
exports.GuidType = GuidType;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./any.type.js"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./base64.type.js"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./bigint.type.js"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./boolean.type.js"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./date.type.js"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./guid.type.js"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./integer.type.js"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./number.type.js"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./object.type.js"), exports);
|
|
13
|
+
tslib_1.__exportStar(require("./string.type.js"), exports);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IntegerType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const putil_varhelpers_1 = require("putil-varhelpers");
|
|
6
|
+
const simple_type_js_1 = require("../simple-type.js");
|
|
7
|
+
const number_type_js_1 = require("./number.type.js");
|
|
8
|
+
let IntegerType = class IntegerType extends number_type_js_1.NumberType {
|
|
9
|
+
decode(v) {
|
|
10
|
+
if (v == null)
|
|
11
|
+
return v;
|
|
12
|
+
return (0, putil_varhelpers_1.toInt)(super.decode(v));
|
|
13
|
+
}
|
|
14
|
+
encode(v) {
|
|
15
|
+
if (v == null)
|
|
16
|
+
return v;
|
|
17
|
+
return (0, putil_varhelpers_1.toInt)(super.encode(v));
|
|
18
|
+
}
|
|
19
|
+
coerce(v) {
|
|
20
|
+
return this.decode(v);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
IntegerType = tslib_1.__decorate([
|
|
24
|
+
(0, simple_type_js_1.SimpleType)({
|
|
25
|
+
description: 'An integer number',
|
|
26
|
+
})
|
|
27
|
+
], IntegerType);
|
|
28
|
+
exports.IntegerType = IntegerType;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NumberType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const putil_varhelpers_1 = require("putil-varhelpers");
|
|
6
|
+
const simple_type_js_1 = require("../simple-type.js");
|
|
7
|
+
let NumberType = class NumberType {
|
|
8
|
+
decode(v) {
|
|
9
|
+
if (v == null)
|
|
10
|
+
return v;
|
|
11
|
+
const x = (0, putil_varhelpers_1.toNumber)(v);
|
|
12
|
+
if (x)
|
|
13
|
+
this.validate(x);
|
|
14
|
+
return x;
|
|
15
|
+
}
|
|
16
|
+
encode(v) {
|
|
17
|
+
return this.decode(v);
|
|
18
|
+
}
|
|
19
|
+
coerce(v) {
|
|
20
|
+
return this.decode(v);
|
|
21
|
+
}
|
|
22
|
+
validate(v) {
|
|
23
|
+
if (typeof v !== 'number' || isNaN(v))
|
|
24
|
+
throw new TypeError(`Invalid number value "${v}"`);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
NumberType = tslib_1.__decorate([
|
|
28
|
+
(0, simple_type_js_1.SimpleType)({
|
|
29
|
+
description: 'Both Integer as well as Floating-Point numbers',
|
|
30
|
+
ctor: Number
|
|
31
|
+
})
|
|
32
|
+
], NumberType);
|
|
33
|
+
exports.NumberType = NumberType;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ObjectType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const complex_type_js_1 = require("../complex-type.js");
|
|
6
|
+
let ObjectType = class ObjectType {
|
|
7
|
+
coerce(v) {
|
|
8
|
+
if (v == null)
|
|
9
|
+
return v;
|
|
10
|
+
return typeof v === 'object' ? v : {};
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
ObjectType = tslib_1.__decorate([
|
|
14
|
+
(0, complex_type_js_1.ComplexType)({
|
|
15
|
+
name: 'object',
|
|
16
|
+
description: 'A non modelled object',
|
|
17
|
+
additionalFields: true
|
|
18
|
+
})
|
|
19
|
+
], ObjectType);
|
|
20
|
+
exports.ObjectType = ObjectType;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StringType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const putil_varhelpers_1 = require("putil-varhelpers");
|
|
6
|
+
const simple_type_js_1 = require("../simple-type.js");
|
|
7
|
+
let StringType = class StringType {
|
|
8
|
+
decode(v) {
|
|
9
|
+
return (0, putil_varhelpers_1.toString)(v);
|
|
10
|
+
}
|
|
11
|
+
encode(v) {
|
|
12
|
+
return (0, putil_varhelpers_1.toString)(v);
|
|
13
|
+
}
|
|
14
|
+
coerce(v) {
|
|
15
|
+
return this.decode(v);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
StringType = tslib_1.__decorate([
|
|
19
|
+
(0, simple_type_js_1.SimpleType)({
|
|
20
|
+
description: 'A sequence of characters',
|
|
21
|
+
ctor: String
|
|
22
|
+
})
|
|
23
|
+
], StringType);
|
|
24
|
+
exports.StringType = StringType;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TimeType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const simple_type_js_1 = require("../simple-type.js");
|
|
6
|
+
const string_type_js_1 = require("./string.type.js");
|
|
7
|
+
const TIME_PATTERN = /^([01][0-9]|2[0-3]):?([0-5][0-9]):?([0-5][0-9])?(?:\.(\d+))?$/;
|
|
8
|
+
let TimeType = class TimeType extends string_type_js_1.StringType {
|
|
9
|
+
decode(v) {
|
|
10
|
+
if (v == null)
|
|
11
|
+
return v;
|
|
12
|
+
this.validate(v);
|
|
13
|
+
return v;
|
|
14
|
+
}
|
|
15
|
+
encode(v) {
|
|
16
|
+
return this.decode(v);
|
|
17
|
+
}
|
|
18
|
+
coerce(v) {
|
|
19
|
+
return this.decode(v);
|
|
20
|
+
}
|
|
21
|
+
validate(v) {
|
|
22
|
+
// noinspection SuspiciousTypeOfGuard
|
|
23
|
+
if (typeof v === 'string' && !TIME_PATTERN.test(v))
|
|
24
|
+
throw new TypeError(`Invalid Time value "${v}"`);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
TimeType = tslib_1.__decorate([
|
|
28
|
+
(0, simple_type_js_1.SimpleType)({
|
|
29
|
+
description: 'Time formatted string',
|
|
30
|
+
})
|
|
31
|
+
], TimeType);
|
|
32
|
+
exports.TimeType = TimeType;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TimestampType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
|
6
|
+
const simple_type_js_1 = require("../simple-type.js");
|
|
7
|
+
let TimestampType = class TimestampType {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.format = 'YYYY-MM-DDTHH:mm:ss';
|
|
10
|
+
}
|
|
11
|
+
decode(v) {
|
|
12
|
+
return (0, dayjs_1.default)(v).toDate();
|
|
13
|
+
}
|
|
14
|
+
encode(v) {
|
|
15
|
+
if (!v)
|
|
16
|
+
return undefined;
|
|
17
|
+
const d = (0, dayjs_1.default)(v);
|
|
18
|
+
if (!d.isValid())
|
|
19
|
+
throw new TypeError(`Invalid date value ${v}`);
|
|
20
|
+
return (0, dayjs_1.default)(v).format(this.format);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
TimestampType = tslib_1.__decorate([
|
|
24
|
+
(0, simple_type_js_1.SimpleType)({
|
|
25
|
+
description: 'date-time notation as defined by RFC 3339, section 5.6, for example, 2021-04-18T09:12:53',
|
|
26
|
+
ctor: Date
|
|
27
|
+
})
|
|
28
|
+
], TimestampType);
|
|
29
|
+
exports.TimestampType = TimestampType;
|