@opra/common 0.14.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/document/api-document.js +211 -0
- package/cjs/document/constants.js +6 -0
- package/cjs/document/data-type/api-field.js +82 -0
- package/cjs/document/data-type/builtin/any.type.js +14 -0
- package/cjs/document/data-type/builtin/base64.type.js +38 -0
- package/cjs/document/data-type/builtin/bigint.type.js +33 -0
- package/cjs/document/data-type/builtin/boolean.type.js +28 -0
- package/cjs/document/data-type/builtin/date.type.js +18 -0
- package/cjs/document/data-type/builtin/guid.type.js +35 -0
- package/cjs/document/data-type/builtin/index.js +13 -0
- package/cjs/document/data-type/builtin/integer.type.js +28 -0
- package/cjs/document/data-type/builtin/number.type.js +33 -0
- package/cjs/document/data-type/builtin/object.type.js +20 -0
- package/cjs/document/data-type/builtin/string.type.js +24 -0
- package/cjs/document/data-type/builtin/time.type.js +32 -0
- package/cjs/document/data-type/builtin/timestamp.type.js +29 -0
- package/cjs/document/data-type/complex-type.js +154 -0
- package/cjs/document/data-type/data-type.js +46 -0
- package/cjs/document/data-type/enum-type.js +62 -0
- package/cjs/document/data-type/mapped-type.js +96 -0
- package/cjs/document/data-type/simple-type.js +61 -0
- package/cjs/document/data-type/union-type.js +81 -0
- package/cjs/document/factory/add-references.js +20 -0
- package/cjs/document/factory/create-document.js +81 -0
- package/cjs/document/factory/factory.js +62 -0
- package/cjs/document/factory/import-resource-class.js +54 -0
- package/cjs/document/factory/import-type-class.js +137 -0
- package/cjs/document/factory/index.js +4 -0
- package/cjs/document/factory/process-resources.js +55 -0
- package/cjs/document/factory/process-types.js +191 -0
- package/cjs/document/index.js +17 -0
- package/cjs/document/resource/collection.js +185 -0
- package/cjs/document/resource/resource.js +38 -0
- package/cjs/document/resource/singleton.js +91 -0
- package/cjs/exception/opra-exception.js +2 -0
- package/cjs/exception/resource-errors/resource-not-found.error.js +4 -0
- package/cjs/filter/parse.js +3 -1
- package/cjs/helpers/function-utils.js +25 -0
- package/cjs/helpers/get-stack-filename.js +24 -0
- package/cjs/helpers/index.js +7 -0
- package/cjs/{utils → helpers}/is-url.js +2 -2
- package/cjs/{schema/utils/clone-object.util.js → helpers/object-utils.js} +13 -1
- package/cjs/{utils/path-to-tree.js → helpers/path-to-object-tree.js} +9 -9
- package/cjs/helpers/responsive-map.js +62 -14
- package/cjs/{utils → helpers}/type-guards.js +12 -5
- package/cjs/http/{param-codec → codecs}/boolean-codec.js +1 -2
- package/{esm/http/param-codec → cjs/http/codecs}/date-codec.js +5 -4
- package/cjs/http/{param-codec → codecs}/filter-codec.js +1 -2
- package/cjs/http/{param-codec → codecs}/number-codec.js +1 -3
- package/cjs/http/{param-codec → codecs}/string-codec.js +1 -3
- package/cjs/http/enums/http-headers-codes.enum.js +13 -4
- package/cjs/http/enums/http-status-messages.js +68 -0
- package/cjs/http/http-headers.js +138 -124
- package/cjs/http/http-message.host.js +251 -0
- package/cjs/http/http-params.js +78 -45
- package/cjs/http/http-request-message.js +152 -0
- package/cjs/http/http-response-message.js +238 -0
- package/cjs/http/index.js +8 -11
- package/cjs/http/multipart/batch-multipart.js +169 -153
- package/cjs/http/multipart/http-request-content.js +16 -11
- package/cjs/http/multipart/http-response-content.js +13 -10
- package/cjs/http/multipart/index.js +1 -3
- package/cjs/i18n/i18n.js +1 -1
- package/cjs/index.js +6 -5
- package/cjs/schema/constants.js +2 -9
- package/cjs/schema/data-type/complex-type.interface.js +7 -0
- package/cjs/schema/data-type/enum-type.interface.js +7 -0
- package/cjs/schema/data-type/mapped-type.interface.js +7 -0
- package/cjs/schema/data-type/simple-type.interface.js +7 -0
- package/cjs/schema/data-type/union-type.interface.js +7 -0
- package/cjs/schema/index.js +42 -26
- package/cjs/schema/resource/collection.interface.js +7 -0
- package/cjs/schema/resource/container.interface.js +7 -0
- package/cjs/schema/resource/resource.interface.js +2 -0
- package/cjs/schema/resource/singleton.interface.js +7 -0
- package/cjs/schema/type-guards.js +59 -0
- package/cjs/types.js +2 -0
- package/cjs/url/index.js +2 -2
- package/cjs/url/opra-url-path-component.js +2 -2
- package/cjs/url/opra-url-path.js +7 -4
- package/cjs/url/opra-url.js +86 -117
- package/cjs/url/utils/{path-utils.js → decode-path-component.js} +1 -46
- package/cjs/url/utils/encode-path-component.js +27 -0
- package/cjs/utils/path-utils.js +24 -0
- package/esm/document/api-document.js +211 -0
- package/esm/document/constants.js +6 -0
- package/esm/document/data-type/api-field.js +82 -0
- package/esm/document/data-type/builtin/any.type.js +14 -0
- package/esm/document/data-type/builtin/base64.type.js +38 -0
- package/esm/document/data-type/builtin/bigint.type.js +33 -0
- package/esm/document/data-type/builtin/boolean.type.js +28 -0
- package/esm/document/data-type/builtin/date.type.js +18 -0
- package/esm/document/data-type/builtin/guid.type.js +35 -0
- package/esm/document/data-type/builtin/index.js +13 -0
- package/esm/document/data-type/builtin/integer.type.js +28 -0
- package/esm/document/data-type/builtin/number.type.js +33 -0
- package/esm/document/data-type/builtin/object.type.js +20 -0
- package/esm/document/data-type/builtin/string.type.js +24 -0
- package/esm/document/data-type/builtin/time.type.js +32 -0
- package/esm/document/data-type/builtin/timestamp.type.js +29 -0
- package/esm/document/data-type/complex-type.js +154 -0
- package/esm/document/data-type/data-type.js +46 -0
- package/esm/document/data-type/enum-type.js +62 -0
- package/esm/document/data-type/mapped-type.js +96 -0
- package/esm/document/data-type/simple-type.js +61 -0
- package/esm/document/data-type/union-type.js +81 -0
- package/esm/document/factory/add-references.js +20 -0
- package/esm/document/factory/create-document.js +81 -0
- package/esm/document/factory/factory.js +62 -0
- package/esm/document/factory/import-resource-class.js +54 -0
- package/esm/document/factory/import-type-class.js +137 -0
- package/esm/document/factory/index.js +4 -0
- package/esm/document/factory/process-resources.js +55 -0
- package/esm/document/factory/process-types.js +191 -0
- package/esm/document/index.js +17 -0
- package/esm/document/resource/collection.js +185 -0
- package/esm/document/resource/resource.js +38 -0
- package/esm/document/resource/singleton.js +91 -0
- package/esm/document/utils/inspect.util.js +7 -0
- package/esm/document/utils/string-compare.util.js +11 -0
- package/esm/exception/enums/issue-severity.enum.js +5 -2
- package/esm/exception/error-issue.js +2 -1
- package/esm/exception/http-errors/bad-request.error.js +8 -4
- package/esm/exception/http-errors/failed-dependency.error.js +8 -4
- package/esm/exception/http-errors/forbidden.error.js +8 -4
- package/esm/exception/http-errors/internal-server.error.js +8 -4
- package/esm/exception/http-errors/method-not-allowed.error.js +8 -4
- package/esm/exception/http-errors/not-acceptable.error.js +8 -4
- package/esm/exception/http-errors/not-found.error.js +8 -4
- package/esm/exception/http-errors/unauthorized.error.js +8 -4
- package/esm/exception/http-errors/unprocessable-entity.error.js +8 -4
- package/esm/exception/index.js +18 -15
- package/esm/exception/opra-exception.js +9 -3
- package/esm/exception/resource-errors/resource-conflict.error.js +8 -4
- package/esm/exception/resource-errors/resource-not-found.error.js +12 -4
- package/esm/exception/wrap-exception.js +24 -20
- package/esm/filter/antlr/OpraFilterLexer.js +9 -6
- package/esm/filter/antlr/OpraFilterListener.js +5 -2
- package/esm/filter/antlr/OpraFilterParser.js +126 -79
- package/esm/filter/antlr/OpraFilterVisitor.js +5 -2
- package/esm/filter/ast/abstract/ast.js +5 -1
- package/esm/filter/ast/abstract/expression.js +6 -2
- package/esm/filter/ast/abstract/literal.js +6 -2
- package/esm/filter/ast/abstract/term.js +6 -2
- package/esm/filter/ast/expressions/arithmetic-expression.js +8 -3
- package/esm/filter/ast/expressions/array-expression.js +6 -2
- package/esm/filter/ast/expressions/comparison-expression.js +6 -2
- package/esm/filter/ast/expressions/logical-expression.js +6 -2
- package/esm/filter/ast/expressions/parentheses-expression.js +6 -2
- package/esm/filter/ast/index.js +19 -16
- package/esm/filter/ast/terms/boolean-literal.js +6 -2
- package/esm/filter/ast/terms/date-literal.js +12 -8
- package/esm/filter/ast/terms/external-constant.js +6 -2
- package/esm/filter/ast/terms/null-literal.js +6 -2
- package/esm/filter/ast/terms/number-literal.js +8 -4
- package/esm/filter/ast/terms/qualified-identifier.js +6 -2
- package/esm/filter/ast/terms/string-literal.js +8 -4
- package/esm/filter/ast/terms/time-literal.js +10 -6
- package/esm/filter/build.js +69 -45
- package/esm/filter/errors.js +9 -3
- package/esm/filter/filter-tree-visitor.js +31 -26
- package/esm/filter/index.js +8 -5
- package/esm/filter/opra-error-listener.js +8 -4
- package/esm/filter/parse.js +22 -15
- package/esm/filter/utils.js +7 -2
- package/esm/helpers/function-utils.js +25 -0
- package/esm/helpers/get-stack-filename.js +24 -0
- package/esm/helpers/index.js +11 -1
- package/esm/helpers/is-url.js +8 -0
- package/esm/{schema/type-helpers/mixin.utils.js → helpers/mixin-utils.js} +7 -2
- package/esm/helpers/object-utils.js +31 -0
- package/esm/helpers/path-to-object-tree.js +28 -0
- package/esm/helpers/responsive-map.js +67 -15
- package/esm/{utils → helpers}/type-guards.js +24 -8
- package/esm/http/{param-codec → codecs}/boolean-codec.js +5 -2
- package/{cjs/http/param-codec → esm/http/codecs}/date-codec.js +1 -4
- package/{cjs/url/formats/filter-format.js → esm/http/codecs/filter-codec.js} +5 -6
- package/{cjs/url/formats/integer-format.js → esm/http/codecs/integer-codec.js} +6 -6
- package/esm/http/{param-codec → codecs}/number-codec.js +5 -3
- package/esm/http/{param-codec → codecs}/string-codec.js +5 -3
- package/esm/http/enums/http-headers-codes.enum.js +18 -6
- package/esm/http/enums/http-status-codes.enum.js +5 -2
- package/esm/http/enums/http-status-messages.js +68 -0
- package/esm/http/http-headers.js +144 -126
- package/esm/http/http-message.host.js +251 -0
- package/esm/http/http-params.js +86 -49
- package/esm/http/http-request-message.js +152 -0
- package/esm/http/http-response-message.js +238 -0
- package/esm/http/index.js +17 -17
- package/esm/http/interfaces/client-http-headers.interface.js +2 -1
- package/esm/http/interfaces/cookie-options.interface.js +2 -0
- package/esm/http/interfaces/server-http-headers.interface.js +2 -1
- package/esm/http/multipart/batch-multipart.js +170 -149
- package/esm/http/multipart/http-request-content.js +17 -8
- package/esm/http/multipart/http-response-content.js +14 -7
- package/esm/http/multipart/index.js +2 -1
- package/esm/i18n/i18n.js +28 -23
- package/esm/i18n/index.js +9 -5
- package/esm/i18n/string-utils.js +7 -2
- package/esm/i18n/translate.js +7 -3
- package/esm/index.js +16 -10
- package/esm/schema/constants.js +4 -8
- package/esm/schema/data-type/complex-type.interface.js +7 -0
- package/esm/schema/data-type/data-type.interface.js +2 -0
- package/esm/schema/data-type/enum-type.interface.js +7 -0
- package/esm/schema/data-type/field.interface.js +2 -0
- package/esm/schema/data-type/mapped-type.interface.js +7 -0
- package/esm/schema/data-type/simple-type.interface.js +7 -0
- package/esm/schema/data-type/union-type.interface.js +7 -0
- package/esm/schema/document.interface.js +2 -0
- package/esm/schema/index.js +44 -25
- package/esm/schema/resource/collection.interface.js +7 -0
- package/esm/schema/resource/container.interface.js +7 -0
- package/esm/schema/resource/endpoint.interface.js +2 -0
- package/esm/schema/resource/resource.interface.js +2 -0
- package/esm/schema/resource/singleton.interface.js +7 -0
- package/esm/schema/type-guards.js +59 -0
- package/esm/types.js +2 -0
- package/esm/url/index.js +8 -5
- package/esm/url/opra-url-path-component.js +7 -3
- package/esm/url/opra-url-path.js +19 -12
- package/esm/url/opra-url.js +100 -127
- package/esm/url/utils/decode-path-component.js +41 -0
- package/esm/url/utils/encode-path-component.js +27 -0
- package/esm/utils/path-utils.js +24 -0
- package/package.json +23 -7
- package/types/document/api-document.d.ts +102 -0
- package/types/document/constants.d.ts +3 -0
- package/types/document/data-type/api-field.d.ts +41 -0
- package/types/document/data-type/builtin/any.type.d.ts +2 -0
- package/types/document/data-type/builtin/base64.type.d.ts +6 -0
- package/types/document/data-type/builtin/bigint.type.d.ts +6 -0
- package/types/document/data-type/builtin/boolean.type.d.ts +5 -0
- package/types/document/data-type/builtin/date.type.d.ts +4 -0
- package/types/document/data-type/builtin/guid.type.d.ts +7 -0
- package/types/document/data-type/builtin/index.d.ts +10 -0
- package/types/document/data-type/builtin/integer.type.d.ts +6 -0
- package/types/document/data-type/builtin/number.type.d.ts +6 -0
- package/types/document/data-type/builtin/object.type.d.ts +3 -0
- package/types/document/data-type/builtin/string.type.d.ts +5 -0
- package/types/document/data-type/builtin/time.type.d.ts +7 -0
- package/types/document/data-type/builtin/timestamp.type.d.ts +5 -0
- package/types/document/data-type/complex-type.d.ts +50 -0
- package/types/document/data-type/data-type.d.ts +33 -0
- package/types/document/data-type/enum-type.d.ts +32 -0
- package/types/document/data-type/mapped-type.d.ts +53 -0
- package/types/document/data-type/simple-type.d.ts +33 -0
- package/types/document/data-type/union-type.d.ts +42 -0
- package/types/document/factory/add-references.d.ts +4 -0
- package/types/document/factory/create-document.d.ts +12 -0
- package/types/document/factory/factory.d.ts +61 -0
- package/types/document/factory/import-resource-class.d.ts +10 -0
- package/types/document/factory/import-type-class.d.ts +17 -0
- package/types/document/factory/index.d.ts +1 -0
- package/types/document/factory/process-resources.d.ts +7 -0
- package/types/document/factory/process-types.d.ts +6 -0
- package/types/document/index.d.ts +14 -0
- package/types/document/resource/collection.d.ts +67 -0
- package/types/document/resource/resource.d.ts +29 -0
- package/types/document/resource/singleton.d.ts +49 -0
- package/{esm → types}/exception/resource-errors/resource-not-found.error.d.ts +4 -0
- package/types/helpers/function-utils.d.ts +4 -0
- package/types/helpers/get-stack-filename.d.ts +1 -0
- package/types/helpers/index.d.ts +8 -0
- package/types/helpers/is-url.d.ts +1 -0
- package/{esm/schema/utils/clone-object.util.d.ts → types/helpers/object-utils.d.ts} +1 -0
- package/types/helpers/path-to-object-tree.d.ts +4 -0
- package/types/helpers/responsive-map.d.ts +34 -0
- package/{esm/utils → types/helpers}/type-guards.d.ts +3 -1
- package/types/http/codecs/boolean-codec.d.ts +5 -0
- package/{esm/http/param-codec → types/http/codecs}/date-codec.d.ts +2 -2
- package/{esm/http/param-codec → types/http/codecs}/filter-codec.d.ts +2 -2
- package/types/http/codecs/integer-codec.d.ts +11 -0
- package/types/http/codecs/number-codec.d.ts +14 -0
- package/types/http/codecs/string-codec.d.ts +16 -0
- package/{esm → types}/http/enums/http-headers-codes.enum.d.ts +13 -4
- package/types/http/enums/http-status-messages.d.ts +65 -0
- package/types/http/http-headers.d.ts +86 -0
- package/types/http/http-message.host.d.ts +122 -0
- package/{esm → types}/http/http-params.d.ts +43 -29
- package/types/http/http-request-message.d.ts +213 -0
- package/types/http/http-response-message.d.ts +318 -0
- package/types/http/index.d.ts +14 -0
- package/types/http/interfaces/cookie-options.interface.d.ts +4 -0
- package/types/http/multipart/http-request-content.d.ts +0 -0
- package/types/http/multipart/http-response-content.d.ts +0 -0
- package/types/http/multipart/index.d.ts +0 -0
- package/{esm → types}/index.d.ts +6 -5
- package/types/schema/constants.d.ts +2 -0
- package/types/schema/data-type/complex-type.interface.d.ts +16 -0
- package/types/schema/data-type/data-type.interface.d.ts +14 -0
- package/types/schema/data-type/enum-type.interface.d.ts +15 -0
- package/types/schema/data-type/field.interface.d.ts +21 -0
- package/types/schema/data-type/mapped-type.interface.d.ts +11 -0
- package/types/schema/data-type/simple-type.interface.d.ts +18 -0
- package/types/schema/data-type/union-type.interface.d.ts +10 -0
- package/types/schema/document.interface.d.ts +34 -0
- package/types/schema/index.d.ts +51 -0
- package/types/schema/resource/collection.interface.d.ts +33 -0
- package/types/schema/resource/container.interface.d.ts +9 -0
- package/types/schema/resource/endpoint.interface.d.ts +29 -0
- package/types/schema/resource/resource.interface.d.ts +12 -0
- package/types/schema/resource/singleton.interface.d.ts +22 -0
- package/types/schema/type-guards.d.ts +20 -0
- package/{esm/schema → types}/types.d.ts +0 -3
- package/{esm → types}/url/index.d.ts +2 -2
- package/{esm → types}/url/opra-url.d.ts +10 -29
- package/types/url/utils/decode-path-component.d.ts +5 -0
- package/types/url/utils/encode-path-component.d.ts +1 -0
- package/types/utils/path-utils.d.ts +2 -0
- package/cjs/constants.js +0 -1
- package/cjs/http/http-param-codec.js +0 -6
- package/cjs/http/http-request-node.js +0 -105
- package/cjs/http/http-request.js +0 -89
- package/cjs/http/http-response.js +0 -23
- package/cjs/http/utils/encodeURIParam.js +0 -21
- package/cjs/http/utils/normalize-headers.js +0 -28
- package/cjs/schema/decorators/opr-collection-resource.decorator.js +0 -24
- package/cjs/schema/decorators/opr-complex-type.decorator.js +0 -28
- package/cjs/schema/decorators/opr-field.decorator.js +0 -29
- package/cjs/schema/decorators/opr-resolver.decorator.js +0 -81
- package/cjs/schema/decorators/opr-simple-type.decorator.js +0 -19
- package/cjs/schema/decorators/opr-singleton-resource.decorator.js +0 -24
- package/cjs/schema/implementation/data-type/builtin/any.type.js +0 -9
- package/cjs/schema/implementation/data-type/builtin/base64-binary.type.js +0 -15
- package/cjs/schema/implementation/data-type/builtin/bigint.type.js +0 -15
- package/cjs/schema/implementation/data-type/builtin/boolean.type.js +0 -15
- package/cjs/schema/implementation/data-type/builtin/date-string.type.js +0 -15
- package/cjs/schema/implementation/data-type/builtin/date.type.js +0 -15
- package/cjs/schema/implementation/data-type/builtin/guid.type.js +0 -15
- package/cjs/schema/implementation/data-type/builtin/integer.type.js +0 -15
- package/cjs/schema/implementation/data-type/builtin/number.type.js +0 -15
- package/cjs/schema/implementation/data-type/builtin/object.type.js +0 -15
- package/cjs/schema/implementation/data-type/builtin/string.type.js +0 -15
- package/cjs/schema/implementation/data-type/builtin-data-types.js +0 -37
- package/cjs/schema/implementation/data-type/complex-type.js +0 -110
- package/cjs/schema/implementation/data-type/data-type.js +0 -37
- package/cjs/schema/implementation/data-type/simple-type.js +0 -21
- package/cjs/schema/implementation/data-type/union-type.js +0 -24
- package/cjs/schema/implementation/document-builder.js +0 -140
- package/cjs/schema/implementation/opra-document.js +0 -183
- package/cjs/schema/implementation/query/collection-count-query.js +0 -17
- package/cjs/schema/implementation/query/collection-create-query.js +0 -23
- package/cjs/schema/implementation/query/collection-delete-many-query.js +0 -17
- package/cjs/schema/implementation/query/collection-delete-query.js +0 -25
- package/cjs/schema/implementation/query/collection-get-query.js +0 -32
- package/cjs/schema/implementation/query/collection-search-query.js +0 -45
- package/cjs/schema/implementation/query/collection-update-many-query.js +0 -18
- package/cjs/schema/implementation/query/collection-update-query.js +0 -33
- package/cjs/schema/implementation/query/field-get-query.js +0 -34
- package/cjs/schema/implementation/query/index.js +0 -22
- package/cjs/schema/implementation/query/singleton-get-query.js +0 -22
- package/cjs/schema/implementation/resource/collection-resource-info.js +0 -72
- package/cjs/schema/implementation/resource/container-resource-info.js +0 -30
- package/cjs/schema/implementation/resource/resource-info.js +0 -35
- package/cjs/schema/implementation/resource/singleton-resource-info.js +0 -44
- package/cjs/schema/implementation/schema-builder/extract-resource-metadata.util.js +0 -84
- package/cjs/schema/implementation/schema-builder/extract-type-metadata.util.js +0 -94
- package/cjs/schema/opra-schema.definition.js +0 -49
- package/cjs/schema/type-helpers/extend-type.helper.js +0 -65
- package/cjs/schema/type-helpers/mixin-type.helper.js +0 -46
- package/cjs/schema/utils/class.utils.js +0 -8
- package/cjs/schema/utils/normalize-field-array.util.js +0 -44
- package/cjs/schema/utils/path-to-tree.util.js +0 -26
- package/cjs/url/formats/boolean-format.js +0 -25
- package/cjs/url/formats/date-format.js +0 -44
- package/cjs/url/formats/format.js +0 -6
- package/cjs/url/formats/number-format.js +0 -26
- package/cjs/url/formats/string-format.js +0 -25
- package/cjs/url/opra-url-search-params.js +0 -28
- package/cjs/utils/index.js +0 -6
- package/esm/constants.js +0 -1
- package/esm/helpers/index.d.ts +0 -1
- package/esm/helpers/responsive-map.d.ts +0 -32
- package/esm/http/http-headers.d.ts +0 -70
- package/esm/http/http-param-codec.d.ts +0 -4
- package/esm/http/http-param-codec.js +0 -2
- package/esm/http/http-request-node.d.ts +0 -34
- package/esm/http/http-request-node.js +0 -101
- package/esm/http/http-request.d.ts +0 -76
- package/esm/http/http-request.js +0 -85
- package/esm/http/http-response.d.ts +0 -41
- package/esm/http/http-response.js +0 -19
- package/esm/http/index.d.ts +0 -17
- package/esm/http/multipart/batch-multipart.d.ts +0 -31
- package/esm/http/multipart/http-request-content.d.ts +0 -8
- package/esm/http/multipart/http-response-content.d.ts +0 -7
- package/esm/http/multipart/index.d.ts +0 -1
- package/esm/http/param-codec/boolean-codec.d.ts +0 -5
- package/esm/http/param-codec/filter-codec.js +0 -14
- package/esm/http/param-codec/integer-codec.d.ts +0 -9
- package/esm/http/param-codec/integer-codec.js +0 -15
- package/esm/http/param-codec/number-codec.d.ts +0 -12
- package/esm/http/param-codec/string-codec.d.ts +0 -14
- package/esm/http/utils/encodeURIParam.d.ts +0 -1
- package/esm/http/utils/encodeURIParam.js +0 -17
- package/esm/http/utils/normalize-headers.d.ts +0 -1
- package/esm/http/utils/normalize-headers.js +0 -24
- package/esm/schema/constants.d.ts +0 -8
- package/esm/schema/decorators/opr-collection-resource.decorator.d.ts +0 -8
- package/esm/schema/decorators/opr-collection-resource.decorator.js +0 -19
- package/esm/schema/decorators/opr-complex-type.decorator.d.ts +0 -6
- package/esm/schema/decorators/opr-complex-type.decorator.js +0 -23
- package/esm/schema/decorators/opr-field.decorator.d.ts +0 -3
- package/esm/schema/decorators/opr-field.decorator.js +0 -24
- package/esm/schema/decorators/opr-resolver.decorator.d.ts +0 -8
- package/esm/schema/decorators/opr-resolver.decorator.js +0 -71
- package/esm/schema/decorators/opr-simple-type.decorator.d.ts +0 -6
- package/esm/schema/decorators/opr-simple-type.decorator.js +0 -14
- package/esm/schema/decorators/opr-singleton-resource.decorator.d.ts +0 -8
- package/esm/schema/decorators/opr-singleton-resource.decorator.js +0 -19
- package/esm/schema/implementation/data-type/builtin/any.type.d.ts +0 -2
- package/esm/schema/implementation/data-type/builtin/any.type.js +0 -6
- package/esm/schema/implementation/data-type/builtin/base64-binary.type.d.ts +0 -2
- package/esm/schema/implementation/data-type/builtin/base64-binary.type.js +0 -12
- package/esm/schema/implementation/data-type/builtin/bigint.type.d.ts +0 -2
- package/esm/schema/implementation/data-type/builtin/bigint.type.js +0 -12
- package/esm/schema/implementation/data-type/builtin/boolean.type.d.ts +0 -2
- package/esm/schema/implementation/data-type/builtin/boolean.type.js +0 -12
- package/esm/schema/implementation/data-type/builtin/date-string.type.d.ts +0 -2
- package/esm/schema/implementation/data-type/builtin/date-string.type.js +0 -12
- package/esm/schema/implementation/data-type/builtin/date.type.d.ts +0 -2
- package/esm/schema/implementation/data-type/builtin/date.type.js +0 -12
- package/esm/schema/implementation/data-type/builtin/guid.type.d.ts +0 -2
- package/esm/schema/implementation/data-type/builtin/guid.type.js +0 -12
- package/esm/schema/implementation/data-type/builtin/integer.type.d.ts +0 -2
- package/esm/schema/implementation/data-type/builtin/integer.type.js +0 -12
- package/esm/schema/implementation/data-type/builtin/number.type.d.ts +0 -2
- package/esm/schema/implementation/data-type/builtin/number.type.js +0 -12
- package/esm/schema/implementation/data-type/builtin/object.type.d.ts +0 -2
- package/esm/schema/implementation/data-type/builtin/object.type.js +0 -12
- package/esm/schema/implementation/data-type/builtin/string.type.d.ts +0 -2
- package/esm/schema/implementation/data-type/builtin/string.type.js +0 -12
- package/esm/schema/implementation/data-type/builtin-data-types.d.ts +0 -4
- package/esm/schema/implementation/data-type/builtin-data-types.js +0 -34
- package/esm/schema/implementation/data-type/complex-type.d.ts +0 -29
- package/esm/schema/implementation/data-type/complex-type.js +0 -106
- package/esm/schema/implementation/data-type/data-type.d.ts +0 -17
- package/esm/schema/implementation/data-type/data-type.js +0 -33
- package/esm/schema/implementation/data-type/simple-type.d.ts +0 -12
- package/esm/schema/implementation/data-type/simple-type.js +0 -17
- package/esm/schema/implementation/data-type/union-type.d.ts +0 -16
- package/esm/schema/implementation/data-type/union-type.js +0 -19
- package/esm/schema/implementation/document-builder.d.ts +0 -16
- package/esm/schema/implementation/document-builder.js +0 -135
- package/esm/schema/implementation/opra-document.d.ts +0 -44
- package/esm/schema/implementation/opra-document.js +0 -178
- package/esm/schema/implementation/query/collection-count-query.d.ts +0 -14
- package/esm/schema/implementation/query/collection-count-query.js +0 -13
- package/esm/schema/implementation/query/collection-create-query.d.ts +0 -18
- package/esm/schema/implementation/query/collection-create-query.js +0 -19
- package/esm/schema/implementation/query/collection-delete-many-query.d.ts +0 -14
- package/esm/schema/implementation/query/collection-delete-many-query.js +0 -13
- package/esm/schema/implementation/query/collection-delete-query.d.ts +0 -10
- package/esm/schema/implementation/query/collection-delete-query.js +0 -21
- package/esm/schema/implementation/query/collection-get-query.d.ts +0 -21
- package/esm/schema/implementation/query/collection-get-query.js +0 -28
- package/esm/schema/implementation/query/collection-search-query.d.ts +0 -30
- package/esm/schema/implementation/query/collection-search-query.js +0 -41
- package/esm/schema/implementation/query/collection-update-many-query.d.ts +0 -15
- package/esm/schema/implementation/query/collection-update-many-query.js +0 -14
- package/esm/schema/implementation/query/collection-update-query.d.ts +0 -19
- package/esm/schema/implementation/query/collection-update-query.js +0 -29
- package/esm/schema/implementation/query/field-get-query.d.ts +0 -30
- package/esm/schema/implementation/query/field-get-query.js +0 -30
- package/esm/schema/implementation/query/index.d.ts +0 -27
- package/esm/schema/implementation/query/index.js +0 -17
- package/esm/schema/implementation/query/singleton-get-query.d.ts +0 -20
- package/esm/schema/implementation/query/singleton-get-query.js +0 -18
- package/esm/schema/implementation/resource/collection-resource-info.d.ts +0 -22
- package/esm/schema/implementation/resource/collection-resource-info.js +0 -68
- package/esm/schema/implementation/resource/container-resource-info.d.ts +0 -13
- package/esm/schema/implementation/resource/container-resource-info.js +0 -26
- package/esm/schema/implementation/resource/resource-info.d.ts +0 -17
- package/esm/schema/implementation/resource/resource-info.js +0 -31
- package/esm/schema/implementation/resource/singleton-resource-info.d.ts +0 -15
- package/esm/schema/implementation/resource/singleton-resource-info.js +0 -40
- package/esm/schema/implementation/schema-builder/extract-resource-metadata.util.d.ts +0 -3
- package/esm/schema/implementation/schema-builder/extract-resource-metadata.util.js +0 -80
- package/esm/schema/implementation/schema-builder/extract-type-metadata.util.d.ts +0 -4
- package/esm/schema/implementation/schema-builder/extract-type-metadata.util.js +0 -90
- package/esm/schema/index.d.ts +0 -25
- package/esm/schema/interfaces/child-field-query.interface.d.ts +0 -4
- package/esm/schema/interfaces/child-field-query.interface.js +0 -1
- package/esm/schema/interfaces/data-type.metadata.d.ts +0 -18
- package/esm/schema/interfaces/data-type.metadata.js +0 -1
- package/esm/schema/interfaces/resource-container.interface.d.ts +0 -8
- package/esm/schema/interfaces/resource-container.interface.js +0 -1
- package/esm/schema/interfaces/resource.metadata.d.ts +0 -18
- package/esm/schema/interfaces/resource.metadata.js +0 -1
- package/esm/schema/opra-schema.definition.d.ts +0 -178
- package/esm/schema/opra-schema.definition.js +0 -46
- package/esm/schema/type-helpers/extend-type.helper.d.ts +0 -3
- package/esm/schema/type-helpers/extend-type.helper.js +0 -60
- package/esm/schema/type-helpers/mixin-type.helper.d.ts +0 -2
- package/esm/schema/type-helpers/mixin-type.helper.js +0 -42
- package/esm/schema/types.js +0 -1
- package/esm/schema/utils/class.utils.d.ts +0 -2
- package/esm/schema/utils/class.utils.js +0 -4
- package/esm/schema/utils/clone-object.util.js +0 -14
- package/esm/schema/utils/inspect.util.js +0 -4
- package/esm/schema/utils/normalize-field-array.util.d.ts +0 -3
- package/esm/schema/utils/normalize-field-array.util.js +0 -40
- package/esm/schema/utils/path-to-tree.util.d.ts +0 -4
- package/esm/schema/utils/path-to-tree.util.js +0 -22
- package/esm/schema/utils/string-compare.util.js +0 -7
- package/esm/url/formats/boolean-format.d.ts +0 -5
- package/esm/url/formats/boolean-format.js +0 -21
- package/esm/url/formats/date-format.d.ts +0 -16
- package/esm/url/formats/date-format.js +0 -40
- package/esm/url/formats/filter-format.d.ts +0 -6
- package/esm/url/formats/filter-format.js +0 -14
- package/esm/url/formats/format.d.ts +0 -4
- package/esm/url/formats/format.js +0 -2
- package/esm/url/formats/integer-format.d.ts +0 -9
- package/esm/url/formats/integer-format.js +0 -15
- package/esm/url/formats/number-format.d.ts +0 -12
- package/esm/url/formats/number-format.js +0 -22
- package/esm/url/formats/string-format.d.ts +0 -14
- package/esm/url/formats/string-format.js +0 -21
- package/esm/url/opra-url-search-params.d.ts +0 -5
- package/esm/url/opra-url-search-params.js +0 -24
- package/esm/url/utils/path-utils.d.ts +0 -8
- package/esm/url/utils/path-utils.js +0 -78
- package/esm/utils/index.d.ts +0 -3
- package/esm/utils/index.js +0 -3
- package/esm/utils/is-url.d.ts +0 -1
- package/esm/utils/is-url.js +0 -4
- package/esm/utils/path-to-tree.d.ts +0 -4
- package/esm/utils/path-to-tree.js +0 -24
- /package/cjs/{schema → document}/utils/inspect.util.js +0 -0
- /package/cjs/{schema → document}/utils/string-compare.util.js +0 -0
- /package/cjs/{schema/type-helpers/mixin.utils.js → helpers/mixin-utils.js} +0 -0
- /package/cjs/http/{param-codec → codecs}/integer-codec.js +0 -0
- /package/cjs/{schema/interfaces/child-field-query.interface.js → http/interfaces/cookie-options.interface.js} +0 -0
- /package/cjs/schema/{interfaces/data-type.metadata.js → data-type/data-type.interface.js} +0 -0
- /package/cjs/schema/{interfaces/resource-container.interface.js → data-type/field.interface.js} +0 -0
- /package/cjs/schema/{interfaces/resource.metadata.js → document.interface.js} +0 -0
- /package/cjs/schema/{types.js → resource/endpoint.interface.js} +0 -0
- /package/{esm/schema → types/document}/utils/inspect.util.d.ts +0 -0
- /package/{esm/schema → types/document}/utils/string-compare.util.d.ts +0 -0
- /package/{esm → types}/exception/enums/issue-severity.enum.d.ts +0 -0
- /package/{esm → types}/exception/error-issue.d.ts +0 -0
- /package/{esm → types}/exception/http-errors/bad-request.error.d.ts +0 -0
- /package/{esm → types}/exception/http-errors/failed-dependency.error.d.ts +0 -0
- /package/{esm → types}/exception/http-errors/forbidden.error.d.ts +0 -0
- /package/{esm → types}/exception/http-errors/internal-server.error.d.ts +0 -0
- /package/{esm → types}/exception/http-errors/method-not-allowed.error.d.ts +0 -0
- /package/{esm → types}/exception/http-errors/not-acceptable.error.d.ts +0 -0
- /package/{esm → types}/exception/http-errors/not-found.error.d.ts +0 -0
- /package/{esm → types}/exception/http-errors/unauthorized.error.d.ts +0 -0
- /package/{esm → types}/exception/http-errors/unprocessable-entity.error.d.ts +0 -0
- /package/{esm → types}/exception/index.d.ts +0 -0
- /package/{esm → types}/exception/opra-exception.d.ts +0 -0
- /package/{esm → types}/exception/resource-errors/resource-conflict.error.d.ts +0 -0
- /package/{esm → types}/exception/wrap-exception.d.ts +0 -0
- /package/{esm → types}/filter/antlr/OpraFilterLexer.d.ts +0 -0
- /package/{esm → types}/filter/antlr/OpraFilterListener.d.ts +0 -0
- /package/{esm → types}/filter/antlr/OpraFilterParser.d.ts +0 -0
- /package/{esm → types}/filter/antlr/OpraFilterVisitor.d.ts +0 -0
- /package/{esm → types}/filter/ast/abstract/ast.d.ts +0 -0
- /package/{esm → types}/filter/ast/abstract/expression.d.ts +0 -0
- /package/{esm → types}/filter/ast/abstract/literal.d.ts +0 -0
- /package/{esm → types}/filter/ast/abstract/term.d.ts +0 -0
- /package/{esm → types}/filter/ast/expressions/arithmetic-expression.d.ts +0 -0
- /package/{esm → types}/filter/ast/expressions/array-expression.d.ts +0 -0
- /package/{esm → types}/filter/ast/expressions/comparison-expression.d.ts +0 -0
- /package/{esm → types}/filter/ast/expressions/logical-expression.d.ts +0 -0
- /package/{esm → types}/filter/ast/expressions/parentheses-expression.d.ts +0 -0
- /package/{esm → types}/filter/ast/index.d.ts +0 -0
- /package/{esm → types}/filter/ast/terms/boolean-literal.d.ts +0 -0
- /package/{esm → types}/filter/ast/terms/date-literal.d.ts +0 -0
- /package/{esm → types}/filter/ast/terms/external-constant.d.ts +0 -0
- /package/{esm → types}/filter/ast/terms/null-literal.d.ts +0 -0
- /package/{esm → types}/filter/ast/terms/number-literal.d.ts +0 -0
- /package/{esm → types}/filter/ast/terms/qualified-identifier.d.ts +0 -0
- /package/{esm → types}/filter/ast/terms/string-literal.d.ts +0 -0
- /package/{esm → types}/filter/ast/terms/time-literal.d.ts +0 -0
- /package/{esm → types}/filter/build.d.ts +0 -0
- /package/{esm → types}/filter/errors.d.ts +0 -0
- /package/{esm → types}/filter/filter-tree-visitor.d.ts +0 -0
- /package/{esm → types}/filter/index.d.ts +0 -0
- /package/{esm → types}/filter/opra-error-listener.d.ts +0 -0
- /package/{esm → types}/filter/parse.d.ts +0 -0
- /package/{esm → types}/filter/utils.d.ts +0 -0
- /package/{esm/schema/type-helpers/mixin.utils.d.ts → types/helpers/mixin-utils.d.ts} +0 -0
- /package/{esm → types}/http/enums/http-status-codes.enum.d.ts +0 -0
- /package/{esm → types}/http/interfaces/client-http-headers.interface.d.ts +0 -0
- /package/{esm → types}/http/interfaces/server-http-headers.interface.d.ts +0 -0
- /package/{esm/constants.d.ts → types/http/multipart/batch-multipart.d.ts} +0 -0
- /package/{esm → types}/i18n/i18n.d.ts +0 -0
- /package/{esm → types}/i18n/index.d.ts +0 -0
- /package/{esm → types}/i18n/string-utils.d.ts +0 -0
- /package/{esm → types}/i18n/translate.d.ts +0 -0
- /package/{esm → types}/url/opra-url-path-component.d.ts +0 -0
- /package/{esm → types}/url/opra-url-path.d.ts +0 -0
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { cloneObject } from '../../utils/clone-object.util.js';
|
|
2
|
-
import { colorFgMagenta, colorFgYellow, colorReset, nodeInspectCustom } from '../../utils/inspect.util.js';
|
|
3
|
-
export class ResourceInfo {
|
|
4
|
-
constructor(document, name, metadata) {
|
|
5
|
-
this.document = document;
|
|
6
|
-
this.name = name;
|
|
7
|
-
this.metadata = metadata;
|
|
8
|
-
}
|
|
9
|
-
get instance() {
|
|
10
|
-
return this.metadata.instance;
|
|
11
|
-
}
|
|
12
|
-
get kind() {
|
|
13
|
-
return this.metadata.kind;
|
|
14
|
-
}
|
|
15
|
-
get description() {
|
|
16
|
-
return this.metadata.description;
|
|
17
|
-
}
|
|
18
|
-
toString() {
|
|
19
|
-
return `[${Object.getPrototypeOf(this).constructor.name} ${this.name}]`;
|
|
20
|
-
}
|
|
21
|
-
validateQueryOptions() {
|
|
22
|
-
//
|
|
23
|
-
}
|
|
24
|
-
getSchema(jsonOnly) {
|
|
25
|
-
return cloneObject(this.metadata, jsonOnly);
|
|
26
|
-
}
|
|
27
|
-
[nodeInspectCustom]() {
|
|
28
|
-
return `[${colorFgYellow + Object.getPrototypeOf(this).constructor.name + colorReset}` +
|
|
29
|
-
` ${colorFgMagenta + this.name + colorReset}]`;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { OpraSchema } from '../../opra-schema.definition.js';
|
|
2
|
-
import { ComplexType } from '../data-type/complex-type.js';
|
|
3
|
-
import type { OpraDocument } from '../opra-document.js';
|
|
4
|
-
import { ResourceInfo } from './resource-info.js';
|
|
5
|
-
export declare class SingletonResourceInfo extends ResourceInfo {
|
|
6
|
-
readonly metadata: OpraSchema.SingletonResource;
|
|
7
|
-
readonly dataType: ComplexType;
|
|
8
|
-
constructor(document: OpraDocument, name: string, dataType: ComplexType, metadata: OpraSchema.SingletonResource);
|
|
9
|
-
get create(): OpraSchema.CreateMethodResolver | undefined;
|
|
10
|
-
get delete(): OpraSchema.MethodResolver | undefined;
|
|
11
|
-
get get(): OpraSchema.GetMethodResolver | undefined;
|
|
12
|
-
get update(): OpraSchema.UpdateMethodResolver | undefined;
|
|
13
|
-
getHandlerNames(): string[];
|
|
14
|
-
getSchema(jsonOnly?: boolean): OpraSchema.SingletonResource;
|
|
15
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { singletonMethods } from '../../constants.js';
|
|
2
|
-
import { ComplexType } from '../data-type/complex-type.js';
|
|
3
|
-
import { ResourceInfo } from './resource-info.js';
|
|
4
|
-
export class SingletonResourceInfo extends ResourceInfo {
|
|
5
|
-
constructor(document, name, dataType, metadata) {
|
|
6
|
-
// noinspection SuspiciousTypeOfGuard
|
|
7
|
-
if (!(dataType instanceof ComplexType))
|
|
8
|
-
throw new TypeError(`You should provide a ComplexType as "dataType" argument`);
|
|
9
|
-
super(document, name, metadata);
|
|
10
|
-
this.dataType = dataType;
|
|
11
|
-
}
|
|
12
|
-
get create() {
|
|
13
|
-
return this.metadata.create;
|
|
14
|
-
}
|
|
15
|
-
get delete() {
|
|
16
|
-
return this.metadata.delete;
|
|
17
|
-
}
|
|
18
|
-
get get() {
|
|
19
|
-
return this.metadata.get;
|
|
20
|
-
}
|
|
21
|
-
get update() {
|
|
22
|
-
return this.metadata.update;
|
|
23
|
-
}
|
|
24
|
-
getHandlerNames() {
|
|
25
|
-
const out = [];
|
|
26
|
-
singletonMethods.forEach(m => {
|
|
27
|
-
if (this.metadata[m])
|
|
28
|
-
out.push(m);
|
|
29
|
-
});
|
|
30
|
-
return out;
|
|
31
|
-
}
|
|
32
|
-
getSchema(jsonOnly) {
|
|
33
|
-
const out = super.getSchema(jsonOnly);
|
|
34
|
-
for (const k of singletonMethods) {
|
|
35
|
-
if (typeof out[k] === 'object' && !Object.keys(out[k]).length)
|
|
36
|
-
out[k] = true;
|
|
37
|
-
}
|
|
38
|
-
return out;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { collectionMethods, IGNORE_RESOLVER_METHOD, RESOLVER_METADATA, RESOURCE_METADATA, singletonMethods } from '../../constants.js';
|
|
2
|
-
import { OpraSchema } from '../../opra-schema.definition.js';
|
|
3
|
-
import { cloneObject } from '../../utils/clone-object.util.js';
|
|
4
|
-
export async function extractResourceSchema(instance) {
|
|
5
|
-
const proto = Object.getPrototypeOf(instance);
|
|
6
|
-
const ctor = proto.constructor;
|
|
7
|
-
const metadata = Reflect.getMetadata(RESOURCE_METADATA, ctor);
|
|
8
|
-
if (!metadata)
|
|
9
|
-
throw new TypeError(`Class "${ctor.name}" doesn't have "Resource" metadata information`);
|
|
10
|
-
const schema = cloneObject(metadata);
|
|
11
|
-
schema.instance = instance;
|
|
12
|
-
schema.name = metadata.name || ctor.name.replace(/(Resource|Controller)$/, '');
|
|
13
|
-
if (OpraSchema.isCollectionResource(metadata))
|
|
14
|
-
return await processCollectionResource(schema);
|
|
15
|
-
if (OpraSchema.isSingletonResource(metadata))
|
|
16
|
-
return await processSingletonResource(schema);
|
|
17
|
-
throw new TypeError(`Invalid Resource metadata`);
|
|
18
|
-
}
|
|
19
|
-
async function processCollectionResource(schema) {
|
|
20
|
-
const instance = schema.instance;
|
|
21
|
-
const proto = Object.getPrototypeOf(schema.instance);
|
|
22
|
-
let methodMetadata;
|
|
23
|
-
let fn;
|
|
24
|
-
const locateFn = (inst, methodName) => {
|
|
25
|
-
fn = inst[methodName];
|
|
26
|
-
methodMetadata = Reflect.getMetadata(RESOLVER_METADATA, inst, methodName);
|
|
27
|
-
if (fn == null) {
|
|
28
|
-
if (methodMetadata) {
|
|
29
|
-
inst = Object.getPrototypeOf(inst);
|
|
30
|
-
fn = inst[methodName];
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
for (const methodName of collectionMethods) {
|
|
35
|
-
locateFn(instance, methodName);
|
|
36
|
-
if (typeof fn !== 'function')
|
|
37
|
-
continue;
|
|
38
|
-
const info = schema[methodName] = {
|
|
39
|
-
...methodMetadata
|
|
40
|
-
};
|
|
41
|
-
if (!Reflect.hasMetadata(IGNORE_RESOLVER_METHOD, proto.constructor, methodName)) {
|
|
42
|
-
info.handler = fn.bind(instance);
|
|
43
|
-
fn = instance['pre_' + methodName];
|
|
44
|
-
if (typeof fn === 'function')
|
|
45
|
-
schema['pre_' + methodName] = fn.bind(instance);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return schema;
|
|
49
|
-
}
|
|
50
|
-
async function processSingletonResource(schema) {
|
|
51
|
-
const instance = schema.instance;
|
|
52
|
-
const proto = Object.getPrototypeOf(schema.instance);
|
|
53
|
-
let methodMetadata;
|
|
54
|
-
let fn;
|
|
55
|
-
const locateFn = (inst, methodName) => {
|
|
56
|
-
fn = inst[methodName];
|
|
57
|
-
methodMetadata = Reflect.getMetadata(RESOLVER_METADATA, inst, methodName);
|
|
58
|
-
if (fn == null) {
|
|
59
|
-
if (methodMetadata) {
|
|
60
|
-
inst = Object.getPrototypeOf(inst);
|
|
61
|
-
fn = inst[methodName];
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
for (const methodName of singletonMethods) {
|
|
66
|
-
locateFn(instance, methodName);
|
|
67
|
-
if (typeof fn !== 'function')
|
|
68
|
-
continue;
|
|
69
|
-
const info = schema[methodName] = {
|
|
70
|
-
...methodMetadata
|
|
71
|
-
};
|
|
72
|
-
if (!Reflect.hasMetadata(IGNORE_RESOLVER_METHOD, proto.constructor, methodName)) {
|
|
73
|
-
info.handler = fn.bind(instance);
|
|
74
|
-
fn = instance['pre_' + methodName];
|
|
75
|
-
if (typeof fn === 'function')
|
|
76
|
-
schema['pre_' + methodName] = fn.bind(instance);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return schema;
|
|
80
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { COMPLEXTYPE_FIELDS, DATATYPE_METADATA, MAPPED_TYPE_METADATA } from '../../constants.js';
|
|
2
|
-
import { OpraSchema } from '../../opra-schema.definition.js';
|
|
3
|
-
import { cloneObject } from '../../utils/clone-object.util.js';
|
|
4
|
-
import { primitiveClasses } from '../data-type/builtin-data-types.js';
|
|
5
|
-
const optionalsSymbol = Symbol.for('opra.optional-lib.sqb-connect');
|
|
6
|
-
export async function extractDataTypeSchema(ctor) {
|
|
7
|
-
const metadata = Reflect.getMetadata(DATATYPE_METADATA, ctor);
|
|
8
|
-
if (!metadata)
|
|
9
|
-
throw new TypeError(`Class "${ctor}" doesn't have "DataType" metadata information`);
|
|
10
|
-
if (OpraSchema.isComplexType(metadata))
|
|
11
|
-
return await extractComplexTypeSchema(ctor, metadata);
|
|
12
|
-
if (OpraSchema.isSimpleType(metadata))
|
|
13
|
-
return await extractSimpleTypeSchema(ctor, metadata);
|
|
14
|
-
throw new TypeError(`Invalid DataType metadata`);
|
|
15
|
-
}
|
|
16
|
-
async function extractSimpleTypeSchema(ctor, metadata) {
|
|
17
|
-
const out = cloneObject(metadata);
|
|
18
|
-
out.ctor = ctor;
|
|
19
|
-
return out;
|
|
20
|
-
}
|
|
21
|
-
async function extractComplexTypeSchema(ctor, metadata) {
|
|
22
|
-
const out = cloneObject(metadata);
|
|
23
|
-
out.ctor = ctor;
|
|
24
|
-
const mappedTypeMetadata = Reflect.getMetadata(MAPPED_TYPE_METADATA, ctor);
|
|
25
|
-
if (mappedTypeMetadata) {
|
|
26
|
-
out.extends = [...mappedTypeMetadata.map(x => cloneObject(x))];
|
|
27
|
-
}
|
|
28
|
-
const fields = Reflect.getMetadata(COMPLEXTYPE_FIELDS, ctor);
|
|
29
|
-
if (fields) {
|
|
30
|
-
out.fields = cloneObject(fields);
|
|
31
|
-
for (const [fieldName, field] of Object.entries(out.fields)) {
|
|
32
|
-
if (typeof field.type === 'function') {
|
|
33
|
-
const type = primitiveClasses.get(field.type);
|
|
34
|
-
if (type)
|
|
35
|
-
field.type = type;
|
|
36
|
-
}
|
|
37
|
-
const SqbConnect = globalThis[optionalsSymbol]?.SqbConnect;
|
|
38
|
-
let sqbField;
|
|
39
|
-
if (SqbConnect) {
|
|
40
|
-
const { EntityMetadata, isAssociationField } = SqbConnect;
|
|
41
|
-
const meta = EntityMetadata.get(ctor);
|
|
42
|
-
sqbField = meta && EntityMetadata.getField(meta, fieldName);
|
|
43
|
-
if (sqbField) {
|
|
44
|
-
if (field.type === Function || field.type === 'object' ||
|
|
45
|
-
field.type === Object || field.type === 'any') {
|
|
46
|
-
field.type = 'any';
|
|
47
|
-
if (isAssociationField(sqbField)) {
|
|
48
|
-
if (!sqbField.association.returnsMany())
|
|
49
|
-
delete field.isArray;
|
|
50
|
-
const trg = await sqbField.association.resolveTarget();
|
|
51
|
-
if (trg) {
|
|
52
|
-
field.type = trg.ctor;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
if (sqbField.exclusive && field.exclusive === undefined)
|
|
57
|
-
field.exclusive = sqbField.exclusive;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
if (sqbField && sqbField.kind === 'column') {
|
|
61
|
-
const DataType = SqbConnect.DataType;
|
|
62
|
-
if (field.type === 'number' || field.type === Number) {
|
|
63
|
-
switch (sqbField.dataType) {
|
|
64
|
-
case DataType.INTEGER:
|
|
65
|
-
case DataType.SMALLINT:
|
|
66
|
-
field.type = 'integer';
|
|
67
|
-
break;
|
|
68
|
-
case DataType.BIGINT:
|
|
69
|
-
field.type = 'bigint';
|
|
70
|
-
break;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
else if (field.type === 'string' || field.type === String) {
|
|
74
|
-
switch (sqbField.dataType) {
|
|
75
|
-
case DataType.GUID:
|
|
76
|
-
field.type = 'guid';
|
|
77
|
-
break;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
if (sqbField.notNull && field.required === undefined)
|
|
81
|
-
field.required = sqbField.notNull;
|
|
82
|
-
if (sqbField.exclusive && field.exclusive === undefined)
|
|
83
|
-
field.exclusive = sqbField.exclusive;
|
|
84
|
-
if (sqbField.default !== undefined && field.default === undefined)
|
|
85
|
-
field.default = sqbField.default;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return out;
|
|
90
|
-
}
|
package/esm/schema/index.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import 'reflect-metadata';
|
|
2
|
-
export * from './constants.js';
|
|
3
|
-
export * from './types.js';
|
|
4
|
-
export * from './opra-schema.definition.js';
|
|
5
|
-
export * from './decorators/opr-complex-type.decorator.js';
|
|
6
|
-
export * from './decorators/opr-field.decorator.js';
|
|
7
|
-
export * from './decorators/opr-collection-resource.decorator.js';
|
|
8
|
-
export * from './decorators/opr-singleton-resource.decorator.js';
|
|
9
|
-
export * from './decorators/opr-resolver.decorator.js';
|
|
10
|
-
export * from './interfaces/resource-container.interface.js';
|
|
11
|
-
export * from './implementation/document-builder.js';
|
|
12
|
-
export * from './implementation/opra-document.js';
|
|
13
|
-
export * from './implementation/data-type/data-type.js';
|
|
14
|
-
export * from './implementation/data-type/complex-type.js';
|
|
15
|
-
export * from './implementation/data-type/simple-type.js';
|
|
16
|
-
export * from './implementation/data-type/union-type.js';
|
|
17
|
-
export * from './implementation/resource/resource-info.js';
|
|
18
|
-
export * from './implementation/resource/container-resource-info.js';
|
|
19
|
-
export * from './implementation/resource/collection-resource-info.js';
|
|
20
|
-
export * from './implementation/resource/singleton-resource-info.js';
|
|
21
|
-
export * from './implementation/query/index.js';
|
|
22
|
-
export * from './type-helpers/mixin-type.helper.js';
|
|
23
|
-
export * from './type-helpers/extend-type.helper.js';
|
|
24
|
-
export * from './implementation/schema-builder/extract-type-metadata.util.js';
|
|
25
|
-
export * from './implementation/schema-builder/extract-resource-metadata.util.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { StrictOmit, Type } from 'ts-gems';
|
|
2
|
-
import { OpraSchema } from '../opra-schema.definition.js';
|
|
3
|
-
import { TypeThunkAsync } from '../types.js';
|
|
4
|
-
export type SimpleTypeMetadata = OpraSchema.SimpleType & {
|
|
5
|
-
name: string;
|
|
6
|
-
};
|
|
7
|
-
export type ComplexTypeMetadata = StrictOmit<OpraSchema.ComplexType, 'fields' | 'extends'> & {
|
|
8
|
-
name: string;
|
|
9
|
-
extends?: ComplexTypeExtendingMetadata[];
|
|
10
|
-
fields?: Record<string, FieldMetadata>;
|
|
11
|
-
};
|
|
12
|
-
export type FieldMetadata = StrictOmit<OpraSchema.Field, 'type'> & {
|
|
13
|
-
type?: string | TypeThunkAsync | (string | TypeThunkAsync)[];
|
|
14
|
-
};
|
|
15
|
-
type ComplexTypeExtendingMetadata = StrictOmit<OpraSchema.ComplexTypeExtendingInfo, 'type'> & {
|
|
16
|
-
type: string | Type;
|
|
17
|
-
};
|
|
18
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { CollectionResourceInfo } from '../implementation/resource/collection-resource-info.js';
|
|
2
|
-
import { ResourceInfo } from '../implementation/resource/resource-info.js';
|
|
3
|
-
import { SingletonResourceInfo } from '../implementation/resource/singleton-resource-info.js';
|
|
4
|
-
export interface IResourceContainer {
|
|
5
|
-
getResource<T extends ResourceInfo>(name: string): T;
|
|
6
|
-
getCollectionResource(name: string): CollectionResourceInfo;
|
|
7
|
-
getSingletonResource(name: string): SingletonResourceInfo;
|
|
8
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { PartialSome, StrictOmit } from 'ts-gems';
|
|
2
|
-
import { OpraSchema } from '../opra-schema.definition.js';
|
|
3
|
-
import { TypeThunkAsync } from '../types.js';
|
|
4
|
-
export type CollectionResourceMetadata = PartialSome<StrictOmit<OpraSchema.CollectionResource, 'type'>, 'keyFields'> & {
|
|
5
|
-
type: TypeThunkAsync | string;
|
|
6
|
-
name: string;
|
|
7
|
-
};
|
|
8
|
-
export type SingletonResourceMetadata = StrictOmit<OpraSchema.SingletonResource, 'type'> & {
|
|
9
|
-
type: TypeThunkAsync | string;
|
|
10
|
-
name: string;
|
|
11
|
-
};
|
|
12
|
-
export type ICreateResolverMetadata = StrictOmit<OpraSchema.CreateMethodResolver, 'handler'>;
|
|
13
|
-
export type IDeleteResolverMetadata = StrictOmit<OpraSchema.DeleteMethodResolver, 'handler'>;
|
|
14
|
-
export type IDeleteManyResolverMetadata = StrictOmit<OpraSchema.DeleteManyMethodResolver, 'handler'>;
|
|
15
|
-
export type IGetResolverMetadata = StrictOmit<OpraSchema.GetMethodResolver, 'handler'>;
|
|
16
|
-
export type IUpdateResolverMetadata = StrictOmit<OpraSchema.UpdateMethodResolver, 'handler'>;
|
|
17
|
-
export type IUpdateManyResolverMetadata = StrictOmit<OpraSchema.UpdateManyMethodResolver, 'handler'>;
|
|
18
|
-
export type ISearchResolverMetadata = StrictOmit<OpraSchema.SearchMethodResolver, 'handler'>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
import { Type } from 'ts-gems';
|
|
2
|
-
import { ComparisonOperator } from '../filter/index.js';
|
|
3
|
-
export declare namespace OpraSchema {
|
|
4
|
-
/**
|
|
5
|
-
* *** === Constants === ***
|
|
6
|
-
*/
|
|
7
|
-
export const Version = "1.0";
|
|
8
|
-
/**
|
|
9
|
-
* *** === Type definitions === ***
|
|
10
|
-
*/
|
|
11
|
-
export type Extensible<T = any> = {
|
|
12
|
-
[key: `$${string}`]: T;
|
|
13
|
-
};
|
|
14
|
-
export type ResourceKind = 'ContainerResource' | 'CollectionResource' | 'SingletonResource';
|
|
15
|
-
export type DataTypeKind = 'SimpleType' | 'ComplexType' | 'UnionType';
|
|
16
|
-
export type SingletonMethod = 'get' | 'create' | 'update' | 'delete';
|
|
17
|
-
export type CollectionMethod = SingletonMethod | 'search' | 'count' | 'updateMany' | 'deleteMany';
|
|
18
|
-
/**
|
|
19
|
-
* *** === Document related === ***
|
|
20
|
-
*/
|
|
21
|
-
export interface Document {
|
|
22
|
-
version: string;
|
|
23
|
-
info: DocumentInfo;
|
|
24
|
-
references?: Record<string, Reference>;
|
|
25
|
-
types?: Record<string, DataType>;
|
|
26
|
-
resources?: Record<string, Resource>;
|
|
27
|
-
servers?: ServerInfo[];
|
|
28
|
-
}
|
|
29
|
-
export type ServerInfo = Extensible & {
|
|
30
|
-
url: string;
|
|
31
|
-
description?: string;
|
|
32
|
-
};
|
|
33
|
-
export type Reference = Extensible & {
|
|
34
|
-
url?: string;
|
|
35
|
-
document?: Document;
|
|
36
|
-
};
|
|
37
|
-
export type DocumentInfo = Extensible & {
|
|
38
|
-
title: string;
|
|
39
|
-
version: string;
|
|
40
|
-
description?: string;
|
|
41
|
-
termsOfService?: string;
|
|
42
|
-
contact?: ContactPerson[];
|
|
43
|
-
license?: LicenseInfo;
|
|
44
|
-
};
|
|
45
|
-
export type ContactPerson = Extensible & {
|
|
46
|
-
name?: string;
|
|
47
|
-
email?: string;
|
|
48
|
-
url?: string;
|
|
49
|
-
};
|
|
50
|
-
export type LicenseInfo = Extensible & {
|
|
51
|
-
name: string;
|
|
52
|
-
url?: string;
|
|
53
|
-
content?: string;
|
|
54
|
-
};
|
|
55
|
-
/**
|
|
56
|
-
* *** === Data Type related === ***
|
|
57
|
-
*/
|
|
58
|
-
export type DataType = ComplexType | SimpleType | UnionType;
|
|
59
|
-
export type BaseDataType = {
|
|
60
|
-
kind: DataTypeKind;
|
|
61
|
-
description?: string;
|
|
62
|
-
ctor?: Type;
|
|
63
|
-
parse?: (v: any) => any;
|
|
64
|
-
serialize?: (v: any) => any;
|
|
65
|
-
};
|
|
66
|
-
export interface SimpleType extends BaseDataType {
|
|
67
|
-
kind: 'SimpleType';
|
|
68
|
-
}
|
|
69
|
-
export interface UnionType extends BaseDataType {
|
|
70
|
-
kind: 'UnionType';
|
|
71
|
-
types: DataType[];
|
|
72
|
-
}
|
|
73
|
-
export interface ComplexType extends BaseDataType {
|
|
74
|
-
kind: 'ComplexType';
|
|
75
|
-
description?: string;
|
|
76
|
-
abstract?: boolean;
|
|
77
|
-
extends?: ComplexTypeExtendingInfo[];
|
|
78
|
-
fields?: Record<string, Field>;
|
|
79
|
-
additionalFields?: boolean | string | Pick<Field, 'type' | 'format' | 'isArray' | 'enum'>;
|
|
80
|
-
}
|
|
81
|
-
export interface ComplexTypeExtendingInfo {
|
|
82
|
-
type: string;
|
|
83
|
-
pick?: string[];
|
|
84
|
-
omit?: string[];
|
|
85
|
-
}
|
|
86
|
-
export type Field = Extensible & {
|
|
87
|
-
type: string;
|
|
88
|
-
description?: string;
|
|
89
|
-
required?: boolean;
|
|
90
|
-
isArray?: boolean;
|
|
91
|
-
format?: string;
|
|
92
|
-
default?: any;
|
|
93
|
-
fixed?: string | number;
|
|
94
|
-
enum?: string | string[] | Record<string, string>;
|
|
95
|
-
enumName?: string;
|
|
96
|
-
examples?: any[] | Record<string, any>;
|
|
97
|
-
deprecated?: boolean | string;
|
|
98
|
-
/**
|
|
99
|
-
* If true, this property will not be included in results by default.
|
|
100
|
-
* The client side should include the property name in the "include" query parameter.
|
|
101
|
-
*/
|
|
102
|
-
exclusive?: boolean;
|
|
103
|
-
};
|
|
104
|
-
/**
|
|
105
|
-
* *** === Resource related === ***
|
|
106
|
-
*/
|
|
107
|
-
export type Resource = ContainerResource | CollectionResource | SingletonResource;
|
|
108
|
-
export interface BaseResource {
|
|
109
|
-
kind: ResourceKind;
|
|
110
|
-
description?: string;
|
|
111
|
-
instance?: {};
|
|
112
|
-
}
|
|
113
|
-
export interface CollectionResource extends BaseResource {
|
|
114
|
-
kind: 'CollectionResource';
|
|
115
|
-
type: string;
|
|
116
|
-
keyFields: string | string[];
|
|
117
|
-
create?: CreateMethodResolver;
|
|
118
|
-
count?: CountMethodResolver;
|
|
119
|
-
delete?: DeleteMethodResolver;
|
|
120
|
-
deleteMany?: DeleteManyMethodResolver;
|
|
121
|
-
get?: GetMethodResolver;
|
|
122
|
-
update?: UpdateMethodResolver;
|
|
123
|
-
updateMany?: UpdateManyMethodResolver;
|
|
124
|
-
search?: SearchMethodResolver;
|
|
125
|
-
}
|
|
126
|
-
export interface SingletonResource extends BaseResource {
|
|
127
|
-
kind: 'SingletonResource';
|
|
128
|
-
type: string;
|
|
129
|
-
create?: CreateMethodResolver;
|
|
130
|
-
get?: GetMethodResolver;
|
|
131
|
-
update?: UpdateMethodResolver;
|
|
132
|
-
delete?: DeleteMethodResolver;
|
|
133
|
-
}
|
|
134
|
-
export interface ContainerResource extends BaseResource {
|
|
135
|
-
kind: 'ContainerResource';
|
|
136
|
-
resources: Resource[];
|
|
137
|
-
}
|
|
138
|
-
export type MethodResolver = {
|
|
139
|
-
handler?: Function;
|
|
140
|
-
};
|
|
141
|
-
type MethodResolverInputOptions = {
|
|
142
|
-
inputPick?: string[];
|
|
143
|
-
inputOmit?: string[];
|
|
144
|
-
};
|
|
145
|
-
type MethodResolverOutputOptions = {
|
|
146
|
-
outputPick?: string[];
|
|
147
|
-
outputOmit?: string[];
|
|
148
|
-
};
|
|
149
|
-
type MethodResolverFilterOptions = {
|
|
150
|
-
filters?: {
|
|
151
|
-
field: string;
|
|
152
|
-
operators?: ComparisonOperator[];
|
|
153
|
-
}[];
|
|
154
|
-
};
|
|
155
|
-
export type CreateMethodResolver = MethodResolver & MethodResolverInputOptions & MethodResolverOutputOptions;
|
|
156
|
-
export type CountMethodResolver = MethodResolver & {};
|
|
157
|
-
export type DeleteMethodResolver = MethodResolver & {};
|
|
158
|
-
export type DeleteManyMethodResolver = MethodResolver & MethodResolverFilterOptions;
|
|
159
|
-
export type GetMethodResolver = MethodResolver & MethodResolverOutputOptions;
|
|
160
|
-
export type UpdateMethodResolver = MethodResolver & MethodResolverInputOptions & MethodResolverOutputOptions;
|
|
161
|
-
export type UpdateManyMethodResolver = MethodResolver & MethodResolverFilterOptions;
|
|
162
|
-
export type SearchMethodResolver = MethodResolver & MethodResolverOutputOptions & {
|
|
163
|
-
sortFields?: string[];
|
|
164
|
-
defaultSort?: string[];
|
|
165
|
-
} & MethodResolverFilterOptions;
|
|
166
|
-
/**
|
|
167
|
-
* *** === Type Guards === ***
|
|
168
|
-
*/
|
|
169
|
-
export function isDataType(obj: any): obj is DataType;
|
|
170
|
-
export function isComplexType(obj: any): obj is ComplexType;
|
|
171
|
-
export function isSimpleType(obj: any): obj is SimpleType;
|
|
172
|
-
export function isUnionTypee(obj: any): obj is UnionType;
|
|
173
|
-
export function isResource(obj: any): obj is Resource;
|
|
174
|
-
export function isCollectionResource(obj: any): obj is CollectionResource;
|
|
175
|
-
export function isSingletonResource(obj: any): obj is SingletonResource;
|
|
176
|
-
export function isContainerResource(obj: any): obj is ContainerResource;
|
|
177
|
-
export {};
|
|
178
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
export var OpraSchema;
|
|
2
|
-
(function (OpraSchema) {
|
|
3
|
-
/**
|
|
4
|
-
* *** === Constants === ***
|
|
5
|
-
*/
|
|
6
|
-
OpraSchema.Version = '1.0';
|
|
7
|
-
/**
|
|
8
|
-
* *** === Type Guards === ***
|
|
9
|
-
*/
|
|
10
|
-
function isDataType(obj) {
|
|
11
|
-
return obj && typeof obj === 'object' &&
|
|
12
|
-
(obj.kind === 'ComplexType' || obj.kind === 'SimpleType' || obj.kind === 'UnionType');
|
|
13
|
-
}
|
|
14
|
-
OpraSchema.isDataType = isDataType;
|
|
15
|
-
function isComplexType(obj) {
|
|
16
|
-
return obj && typeof obj === 'object' && obj.kind === 'ComplexType';
|
|
17
|
-
}
|
|
18
|
-
OpraSchema.isComplexType = isComplexType;
|
|
19
|
-
function isSimpleType(obj) {
|
|
20
|
-
return obj && typeof obj === 'object' && obj.kind === 'SimpleType';
|
|
21
|
-
}
|
|
22
|
-
OpraSchema.isSimpleType = isSimpleType;
|
|
23
|
-
function isUnionTypee(obj) {
|
|
24
|
-
return obj && typeof obj === 'object' && obj.kind === 'UnionType';
|
|
25
|
-
}
|
|
26
|
-
OpraSchema.isUnionTypee = isUnionTypee;
|
|
27
|
-
function isResource(obj) {
|
|
28
|
-
return obj && typeof obj === 'object' &&
|
|
29
|
-
obj.kind === 'ContainerResource' ||
|
|
30
|
-
obj.kind === 'CollectionResource' ||
|
|
31
|
-
obj.kind === 'SingletonResource';
|
|
32
|
-
}
|
|
33
|
-
OpraSchema.isResource = isResource;
|
|
34
|
-
function isCollectionResource(obj) {
|
|
35
|
-
return obj && typeof obj === 'object' && obj.kind === 'CollectionResource';
|
|
36
|
-
}
|
|
37
|
-
OpraSchema.isCollectionResource = isCollectionResource;
|
|
38
|
-
function isSingletonResource(obj) {
|
|
39
|
-
return obj && typeof obj === 'object' && obj.kind === 'SingletonResource';
|
|
40
|
-
}
|
|
41
|
-
OpraSchema.isSingletonResource = isSingletonResource;
|
|
42
|
-
function isContainerResource(obj) {
|
|
43
|
-
return obj && typeof obj === 'object' && obj.kind === 'ContainerResource';
|
|
44
|
-
}
|
|
45
|
-
OpraSchema.isContainerResource = isContainerResource;
|
|
46
|
-
})(OpraSchema || (OpraSchema = {}));
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { Class } from 'ts-gems';
|
|
2
|
-
export declare function PickType<T extends any[], I1, S1, K extends keyof I1>(classRef: Class<T, I1, S1>, keys: readonly K[]): Class<T, Pick<I1, K>> & Omit<Pick<S1, keyof typeof classRef>, 'prototype' | 'constructor'>;
|
|
3
|
-
export declare function OmitType<T extends any[], I1, S1, K extends keyof I1>(classRef: Class<T, I1, S1>, keys: readonly K[]): Class<T, Omit<I1, K>> & Omit<Pick<S1, keyof typeof classRef>, 'prototype' | 'constructor'>;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { DATATYPE_METADATA, MAPPED_TYPE_METADATA } from '../constants.js';
|
|
2
|
-
import { applyMixins, inheritPropertyInitializers } from './mixin.utils.js';
|
|
3
|
-
const optionalsSymbol = Symbol.for('opra.optional-lib.sqb-connect');
|
|
4
|
-
export function PickType(classRef, keys) {
|
|
5
|
-
return ExtendType(classRef, classRef, { pickKeys: keys });
|
|
6
|
-
}
|
|
7
|
-
export function OmitType(classRef, keys) {
|
|
8
|
-
return ExtendType(classRef, classRef, { omitKeys: keys });
|
|
9
|
-
}
|
|
10
|
-
function ExtendType(classRef, orgClassRef, options) {
|
|
11
|
-
const pickKeys = options.pickKeys && options.pickKeys.map(x => String(x).toLowerCase());
|
|
12
|
-
const omitKeys = options.omitKeys && options.omitKeys.map(x => String(x).toLowerCase());
|
|
13
|
-
const isInheritedPredicate = (propertyName) => {
|
|
14
|
-
if (omitKeys && omitKeys.includes(propertyName.toLowerCase()))
|
|
15
|
-
return false;
|
|
16
|
-
if (pickKeys)
|
|
17
|
-
return pickKeys.includes(propertyName.toLowerCase());
|
|
18
|
-
return true;
|
|
19
|
-
};
|
|
20
|
-
// const isRequiredPredicate = (propertyName: string): boolean | undefined => {
|
|
21
|
-
// if (options.requiredKeys && options.requiredKeys.includes(propertyName as RequiredKey))
|
|
22
|
-
// return true;
|
|
23
|
-
// if (options.partialKeys && options.partialKeys.includes(propertyName as PartialKey))
|
|
24
|
-
// return false;
|
|
25
|
-
// return;
|
|
26
|
-
// };
|
|
27
|
-
class MappedClass {
|
|
28
|
-
constructor() {
|
|
29
|
-
inheritPropertyInitializers(this, classRef, isInheritedPredicate);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
applyMixins(MappedClass, classRef);
|
|
33
|
-
const mappedTypeMetadata = [];
|
|
34
|
-
const m = Reflect.getOwnMetadata(DATATYPE_METADATA, classRef);
|
|
35
|
-
if (m) {
|
|
36
|
-
if (!(m.kind === 'ComplexType'))
|
|
37
|
-
throw new TypeError(`Class "${classRef}" is not a ComplexType`);
|
|
38
|
-
const meta = {
|
|
39
|
-
type: classRef
|
|
40
|
-
};
|
|
41
|
-
if (options.pickKeys)
|
|
42
|
-
meta.pick = options.pickKeys;
|
|
43
|
-
if (options.omitKeys)
|
|
44
|
-
meta.omit = options.omitKeys;
|
|
45
|
-
mappedTypeMetadata.push(meta);
|
|
46
|
-
}
|
|
47
|
-
else
|
|
48
|
-
throw new TypeError(`Class "${classRef}" doesn't have datatype metadata information`);
|
|
49
|
-
const SqbConnect = globalThis[optionalsSymbol]?.SqbConnect;
|
|
50
|
-
if (SqbConnect) {
|
|
51
|
-
const { Entity, EntityMetadata } = SqbConnect;
|
|
52
|
-
const srcMeta = Entity.getMetadata(classRef);
|
|
53
|
-
if (srcMeta) {
|
|
54
|
-
const trgMeta = EntityMetadata.define(MappedClass);
|
|
55
|
-
EntityMetadata.mixin(trgMeta, srcMeta, k => isInheritedPredicate(k));
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
Reflect.defineMetadata(MAPPED_TYPE_METADATA, mappedTypeMetadata, MappedClass);
|
|
59
|
-
return MappedClass;
|
|
60
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { Class } from 'ts-gems';
|
|
2
|
-
export declare function MixinType<A1 extends any[], I1, S1, A2 extends any[], I2, S2, A3 extends any[], I3, S3, A4 extends any[], I4, S4>(c1: Class<A1, I1, S1>, c2: Class<A2, I2, S2>, c3?: Class<A3, I3, S3>, c4?: Class<A4, I4, S4>): Class<any[], I1 & I2 & I3 & I4, S1 & S2 & S3 & S4>;
|